|
@@ -2,26 +2,26 @@
|
|
|
<div class="select-goodsClass">
|
|
|
<el-cascader
|
|
|
v-if="!loading"
|
|
|
+ v-model="value"
|
|
|
:size="size || 'medium'"
|
|
|
style="width: 100%"
|
|
|
filterable
|
|
|
clearable
|
|
|
- v-model="value"
|
|
|
:placeholder="placeholder || ''"
|
|
|
:props="props"
|
|
|
:disabled="disabled"
|
|
|
@change="handleChange"
|
|
|
- ></el-cascader>
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import asyncRequest from "@/apis/components/goods-class-youzan";
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
+import asyncRequest from '@/apis/components/goods-class-youzan'
|
|
|
+import resToken from '@/mixins/resToken'
|
|
|
export default {
|
|
|
- name: "goodClassYouzan",
|
|
|
+ name: 'GoodClassYouzan',
|
|
|
mixins: [resToken],
|
|
|
- props: ["size", "value", "placeholder", "isDetail", "disabled"],
|
|
|
+ props: ['size', 'value', 'placeholder', 'isDetail', 'disabled'],
|
|
|
/**
|
|
|
* 属性集合
|
|
|
* @param {String} size : 组件大小 非必填
|
|
@@ -39,43 +39,44 @@ export default {
|
|
|
loading: false,
|
|
|
props: {
|
|
|
checkStrictly: false,
|
|
|
- expandTrigger: "hover",
|
|
|
- lazy: true, //开启远程加载
|
|
|
+ expandTrigger: 'hover',
|
|
|
+ lazy: true, // 开启远程加载
|
|
|
async lazyLoad(node, resolve) {
|
|
|
- const { level, value, root, loading } = node;
|
|
|
- let model = {
|
|
|
- parent_cid: "",
|
|
|
- };
|
|
|
- let list = [];
|
|
|
- console.log(level);
|
|
|
- if (level > 1) {
|
|
|
- resolve([]);
|
|
|
- return;
|
|
|
+ const { level, value, root, loading, hasChildren } = node
|
|
|
+ const model = {
|
|
|
+ parent_cid: ''
|
|
|
}
|
|
|
+ const list = []
|
|
|
+
|
|
|
+ if ('hasChildren' in node && !hasChildren) {
|
|
|
+ resolve([])
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (level === 0) {
|
|
|
- model.parent_cid = "0";
|
|
|
+ model.parent_cid = '0'
|
|
|
} else {
|
|
|
- model.parent_cid = value;
|
|
|
+ model.parent_cid = value
|
|
|
}
|
|
|
- const res = await asyncRequest.list(model);
|
|
|
- const { code, data } = res;
|
|
|
+ const res = await asyncRequest.list(model)
|
|
|
+ const { code, data } = res
|
|
|
if (code === 0) {
|
|
|
data.forEach((v1) => {
|
|
|
- let province = {
|
|
|
+ const province = {
|
|
|
youzanIid: v1.yz_cat_id,
|
|
|
value: v1.id,
|
|
|
label: v1.yz_cat_name,
|
|
|
- leaf: level >= 1,
|
|
|
- };
|
|
|
- list.push(province);
|
|
|
- });
|
|
|
- resolve(list);
|
|
|
+ leaf: v1.has_children === '0'
|
|
|
+ }
|
|
|
+ list.push(province)
|
|
|
+ })
|
|
|
+ resolve(list)
|
|
|
} else {
|
|
|
- resolve([]);
|
|
|
+ resolve([])
|
|
|
}
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
// watch: {
|
|
|
// // value: function (val, old) {
|
|
@@ -88,15 +89,15 @@ export default {
|
|
|
// // },
|
|
|
// },
|
|
|
mounted() {
|
|
|
- this.options = [];
|
|
|
- this.selectLoading = false;
|
|
|
+ this.options = []
|
|
|
+ this.selectLoading = false
|
|
|
},
|
|
|
methods: {
|
|
|
async handleChange(value) {
|
|
|
- this.$emit("handleChange", value);
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ this.$emit('handleChange', value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|