打印机部分修改优化

This commit is contained in:
duan 2024-10-12 10:43:56 +08:00
parent 0e030b29c1
commit 8f7aaf87d5
1 changed files with 46 additions and 18 deletions

View File

@ -50,9 +50,12 @@
<!-- <el-radio label="2">部分商品</el-radio> -->
</el-radio-group>
<div v-if="forms.classifyPrint == 1" style="margin-left:70px">
<el-tree :data="partList" show-checkbox node-key="id" ref="tree" :default-checked-keys="this.forms.categoryIds"
<!-- <el-tree :data="partList" show-checkbox node-key="id" ref="tree" :default-checked-keys="this.forms.categoryIds"
:props="{ children: 'childrenList', label: 'name' }">
</el-tree>
</el-tree> -->
<el-checkbox-group v-model="forms.selectcheckbox">
<el-checkbox v-for="item in partList" :key="item.id" :label="item.name"></el-checkbox>
</el-checkbox-group>
</div>
</el-form-item>
@ -113,7 +116,8 @@ export default {
forms: {
sort: "0",
status: "0",
connectionType: "network", printType: []
connectionType: "network", printType: [],
selectcheckbox: []
},
partList: []
}
@ -121,13 +125,11 @@ export default {
filters: {
},
mounted() {
if (this.$route.query.id) {
this.getList(this.$route.query.id)
}
this.getpartList()
},
methods: {
handleNodeClick(d) { console.log(d) },
async onSubmit() {
//
@ -137,17 +139,17 @@ export default {
}
//
if (this.forms.classifyPrint == 1) {
let data = this.$refs.tree.getCheckedNodes()
let idstr = ''
let arr = []
data.forEach(element => {
idstr += element.id + ','
arr.push({ id: element.id, name: element.name })
});
this.forms.categoryList = JSON.stringify(arr)
this.forms.selectcheckbox.forEach(element => {
let prts = this.partList.filter(ele => ele.name == element)[0]
idstr = idstr + prts.id + ','
arr.push(prts)
})
this.forms.categoryIds = idstr.substring(0, idstr.length - 1)
}
this.forms.categoryList = JSON.stringify(arr)
}
const res = await configprinter({
shopId: localStorage.getItem('shopId'),
...this.forms,
@ -163,18 +165,44 @@ export default {
page: 0,
size: 500
})
this.partList = res.content
let arr = []
res.content.forEach(ele => {
arr.push({
id: ele.id,
name: ele.name
})
if (ele.childrenList.length > 0) {
ele.childrenList.forEach(element => {
arr.push({
id: element.id,
name: element.name
})
})
}
})
this.partList = arr
if (this.$route.query.id) {
this.getList(this.$route.query.id)
}
},
async getList(id) {
const res = await printerd(id)
this.forms = res
this.forms.categoryIds=this.forms.categoryIds.split(',')
console.log(this.forms.categoryIds,'调试11111')
if (res.categoryIds) {
let ids = res.categoryIds.split(',')
let arr = []
ids.forEach(element => {
let prts = this.partList.filter(ele => ele.id == element)[0]
arr.push(prts.name)
})
this.$set(this.forms, 'selectcheckbox', arr)
} else {
this.$set(this.forms, 'selectcheckbox', [])
}
if (res.printType) {
this.forms.printType = JSON.parse(res.printType)
} else {
this.forms.printType = []
}
}
}