Commit f0a1362c authored by ylpmty's avatar ylpmty

商品列表多选,商品选择组件增加数据回显

parent 3952fdcb
...@@ -36,92 +36,113 @@ ...@@ -36,92 +36,113 @@
</el-row> </el-row>
</template> </template>
<script> <script>
import {getProductPage} from '@/api/ecw/product' import { getProductPage } from '@/api/ecw/product'
import {getProductTypeList} from '@/api/ecw/productType' import { getProductTypeList } from '@/api/ecw/productType'
import {getProductAttrList} from '@/api/ecw/productAttr' import { getProductAttrList } from '@/api/ecw/productAttr'
export default { export default {
data(){ props: {
defaultIds: {
type: Array,
default: []
}
},
data() {
return { return {
list:[], list: [],
page: 1, page: 1,
pages: 1, pages: 1,
queryParams:{ queryParams: {
page: 1, page: 1,
attrId: null, attrId: null,
titleZh: null, titleZh: null,
typeId: null typeId: null
}, },
choosedList:[], choosedList: [],
typeList:[], typeList: [],
attrList:[] attrList: []
} }
}, },
computed:{ computed: {
ids(){ ids: {
get() {
let arr = [] let arr = []
this.choosedList.forEach(item => { this.choosedList.forEach(item => {
arr.push(item.id) arr.push(item.id)
}) })
return arr return arr
},
set(v) {
}
} }
}, },
watch:{ watch: {
ids(val){ ids(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
created(){ created() {
getProductTypeList().then(res => this.typeList = res.data) getProductTypeList().then(res => this.typeList = res.data)
getProductAttrList().then(res => this.attrList = res.data) getProductAttrList().then(res => this.attrList = res.data)
this.reLoad() this.reLoad()
this.ids = this.defaultIds //数据回显
}, },
methods:{ methods: {
reLoad(){ reLoad() {
this.queryParams.page = 1 this.queryParams.page = 1
this.list = [] this.list = []
this.getList() this.getList()
}, },
loadNextPage(){ loadNextPage() {
if(this.page >= this.pages){ if (this.page >= this.pages) {
return this.$message.error('已加载全部') return this.$message.error('已加载全部')
} }
this.queryParams.page ++ this.queryParams.page++
this.getList() this.getList()
}, },
getList(){ getList() {
getProductPage(this.queryParams).then(res => { getProductPage(this.queryParams).then(res => {
this.list = res.data.list //.concat(res.data.list || []) this.list = res.data.list //.concat(res.data.list || [])
this.page = res.data.page this.page = res.data.page
this.pages = res.data.pages this.pages = res.data.pages
this.choosedList = [] //搜搜重置,数据回显
if (this.defaultIds.length > 0) {
this.defaultIds.map(item => {
this.list.map(items => {
if (items.id == item) {
this.choosedList.push(items)
}
})
})
}
}) })
}, },
toggleCheck(item, checked){ toggleCheck(item, checked) {
if(checked){ if (checked) {
this.choose(item) this.choose(item)
}else{ } else {
this.remove(item) this.remove(item)
} }
}, },
choose(item){ choose(item) {
this.choosedList.push(item) this.choosedList.push(item)
}, },
remove(item){ remove(item) {
this.choosedList.forEach((choosed,index) => { this.choosedList.forEach((choosed, index) => {
if(choosed.id==item.id) this.choosedList.splice(index,1) if (choosed.id == item.id) this.choosedList.splice(index, 1)
}) })
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.header{ .header {
>div{ > div {
margin-right: 5px; margin-right: 5px;
} }
} }
.list{ .list {
height: 200px; height: 200px;
border: 1px solid #ccc; border: 1px solid #ccc;
overflow-y: auto; overflow-y: auto;
...@@ -130,7 +151,7 @@ export default { ...@@ -130,7 +151,7 @@ export default {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.item{ .item {
width: 50%; width: 50%;
line-height: 20px; line-height: 20px;
height: 50px; height: 50px;
......
This diff is collapsed.
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div class="app-container"> <div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="适用商品" prop="idList" v-if="form.type != 1"> <el-form-item label="适用商品" prop="idList">
<products-selector v-model="form.idList" /> <products-selector :defaultIds="form.idList" v-model="form.idList" />
</el-form-item> </el-form-item>
<el-form-item label="货柜位置" prop="containerLocation"> <el-form-item label="货柜位置" prop="containerLocation">
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
<el-checkbox style="width: 100px" v-model="checked[6]">需要修改</el-checkbox> <el-checkbox style="width: 100px" v-model="checked[6]">需要修改</el-checkbox>
<dict-selector v-if="checked[6]" form-type="checkbox" :type="DICT_TYPE.ECW_ORDER_ATTR" v-model="form.attrId" multiple /> <dict-selector v-if="checked[6]" form-type="checkbox" :type="DICT_TYPE.ECW_ORDER_ATTR" v-model="form.attrId" multiple />
</el-form-item> </el-form-item>
<!-- <el-form-item label="商品材质" prop=""> <el-form-item label="商品材质" prop="materialType">
<el-checkbox style="width: 100px" v-model="checked[7]">需要修改</el-checkbox> <el-checkbox style="width: 100px" v-model="checked[7]">需要修改</el-checkbox>
<dict-selector v-if="checked[7]" form-type="checkbox" :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form.status" multiple /> <dict-selector v-if="checked[7]" form-type="checkbox" :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form.materialType" multiple />
</el-form-item> --> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
...@@ -75,11 +75,12 @@ export default { ...@@ -75,11 +75,12 @@ export default {
"needBook": undefined, "needBook": undefined,
"packaging": undefined, "packaging": undefined,
"requirements": undefined, "requirements": undefined,
"square": undefined "square": undefined,
"materialType": undefined
}, },
// 表单校验 // 表单校验
rules: {}, rules: {},
checked: [false, false, false, false, false, false, false] checked: [false, false, false, false, false, false, false, false]
}; };
}, },
computed: { computed: {
...@@ -88,7 +89,7 @@ export default { ...@@ -88,7 +89,7 @@ export default {
watch: { watch: {
'form.idList'(val) { 'form.idList'(val) {
if (val.length > 0) { if (val.length > 0) {
this.form.isAllProduct = undefined this.form.isAllProduct = 0
} else { } else {
this.form.isAllProduct = 1 this.form.isAllProduct = 1
} }
...@@ -96,6 +97,7 @@ export default { ...@@ -96,6 +97,7 @@ export default {
}, },
created() { created() {
this.reset() this.reset()
this.form.idList = this.$route.query && this.$route.query.ids ? [...this.$route.query.ids].map(item => { return Number(item) }) : []
}, },
methods: { methods: {
/** 表单重置 */ /** 表单重置 */
...@@ -109,7 +111,8 @@ export default { ...@@ -109,7 +111,8 @@ export default {
"needBook": undefined, "needBook": undefined,
"packaging": undefined, "packaging": undefined,
"requirements": undefined, "requirements": undefined,
"square": undefined "square": undefined,
"materialType": undefined
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -130,17 +133,3 @@ export default { ...@@ -130,17 +133,3 @@ export default {
}, },
}; };
</script> </script>
\ No newline at end of file
<style scoped lang="scss">
.fee-item {
padding: 5px 0;
> div {
margin-right: 5px;
}
}
.coupon-list {
max-height: 200px;
border: 1px solid #ccc;
padding: 10px;
overflow-y: auto;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment