fix: 去除大部分lodash依赖
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import Field from '../../field';
|
||||
import CellGroup from '../../cell-group';
|
||||
import validateEmail from 'zan-utils/validate/email';
|
||||
@@ -117,7 +116,7 @@ export default {
|
||||
const value = values[i];
|
||||
const message = this.internalMessages[i];
|
||||
|
||||
if (isEmpty(value)) {
|
||||
if (value === '') {
|
||||
// 必填字段的校验
|
||||
if (message.required == '1') { // eslint-disable-line
|
||||
if (message.type === 'image') {
|
||||
|
||||
@@ -2,33 +2,15 @@
|
||||
<div class="van-sku-row">
|
||||
<div class="van-sku-row__title">{{ skuRow.k }}:</div>
|
||||
<div class="van-sku-row__items">
|
||||
<slot name="sku-row-items">
|
||||
<van-sku-row-item
|
||||
v-for="(skuValue, index) in skuRow.v"
|
||||
:key="index"
|
||||
:skuKeyStr="skuRow.k_s"
|
||||
:skuValue="skuValue"
|
||||
:skuEventBus="$attrs.skuEventBus"
|
||||
:selectedSku="$attrs.selectedSku"
|
||||
:skuList="$attrs.skuList">
|
||||
</van-sku-row-item>
|
||||
</slot>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SkuRowItem from './SkuRowItem';
|
||||
|
||||
export default {
|
||||
name: 'van-sku-row',
|
||||
|
||||
inheritAttrs: false,
|
||||
|
||||
components: {
|
||||
[SkuRowItem.name]: SkuRowItem
|
||||
},
|
||||
|
||||
props: {
|
||||
skuRow: Object
|
||||
}
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import assign from 'lodash/assign';
|
||||
import filter from 'lodash/filter';
|
||||
import keys from 'lodash/keys';
|
||||
import every from 'lodash/every';
|
||||
|
||||
export default {
|
||||
name: 'van-sku-row-item',
|
||||
|
||||
@@ -29,12 +24,12 @@ export default {
|
||||
return this.skuValue.id === this.selectedSku[this.skuKeyStr];
|
||||
},
|
||||
isChoosable() {
|
||||
const matchedSku = assign({}, this.selectedSku, {
|
||||
const matchedSku = Object.assign({}, this.selectedSku, {
|
||||
[this.skuKeyStr]: this.skuValue.id
|
||||
});
|
||||
const skusToCheck = filter(keys(matchedSku), skuKey => matchedSku[skuKey] !== '');
|
||||
const filteredSku = filter(this.skuList, sku => {
|
||||
return every(skusToCheck, function(skuKey) {
|
||||
const skusToCheck = Object.keys(matchedSku).filter(skuKey => matchedSku[skuKey] !== '');
|
||||
const filteredSku = this.skuList.filter(sku => {
|
||||
return skusToCheck.every(skuKey => {
|
||||
// 后端给的skuValue.id有时候是数字有时候是字符串,全等会匹配不上
|
||||
return matchedSku[skuKey] == sku[skuKey]; // eslint-disable-line
|
||||
});
|
||||
@@ -47,7 +42,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
onSkuSelected() {
|
||||
this.skuEventBus.$emit('sku:select', assign({}, this.skuValue, { skuKeyStr: this.skuKeyStr }));
|
||||
this.skuEventBus.$emit('sku:select', Object.assign({}, this.skuValue, { skuKeyStr: this.skuKeyStr }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user