From b082164ff696fb8fe1b7d43081834b9cc7ebce39 Mon Sep 17 00:00:00 2001 From: shijingjing <1789544664@qq.com> Date: Sat, 8 Oct 2022 10:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/resourceClassification.vue | 77 ++++++++++++++----- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/project/pengliuyang/apps/AppCommunityResource/components/resourceClassification.vue b/project/pengliuyang/apps/AppCommunityResource/components/resourceClassification.vue index b9275d3f..44734c2e 100644 --- a/project/pengliuyang/apps/AppCommunityResource/components/resourceClassification.vue +++ b/project/pengliuyang/apps/AppCommunityResource/components/resourceClassification.vue @@ -9,13 +9,12 @@ - - + + + - - - + + - + @@ -67,23 +67,24 @@ export default { dialog: false, form: { categoryName: '', - categoryIcon: '' + categoryIcon: '', + categoryIconArr: [] } } }, computed: { colConfigs() { return [ - {prop: 'resourceName', label: '分类名称', width: '300px'}, - {prop: 'categoryName', label: '资源数量', align: 'center'}, - // {prop: "merchandisePhoto",slot: "merchandisePhoto",align: "center",label: "商品图"}, - {prop: 'option'} + {prop: 'categoryName', label: '分类名称', width: '300px'}, + {prop: 'resourceNum', label: '资源数量', align: 'center'}, + {slot: "categoryIcon"}, + {slot: 'option'}, ] }, rules() { return { categoryName: [{required: true, message: "请输入分类名称"}], - categoryIcon: [{required: true, message: "请上传分类图标"}], + categoryIconArr: [{required: true, message: "请上传分类图标"}], } } }, @@ -99,8 +100,17 @@ export default { } }).then(res=> { if(res?.data) { - this.tableData = res.data.records - this.total = res.total + this.tableData = res.data.records.map(e=> { + return { + categoryName: e.categoryName, + resourceNum: e.resourceNum, + categoryIcon: e.categoryIcon, + id: e.id, + categoryIconArr: [{0:e.categoryIcon}] + } + }) + this.total = res.data.total + console.log(this.tableData); } }) }, @@ -108,13 +118,42 @@ export default { onConfirm() { this.$refs.form.validate((valid) => { if(valid) { - this.instance.post(`/app/appresourcecategory/addOrUpdate`, ...this.form).then(res=> { - console.log(res,this.form.categoryIcon); + if(this.form.categoryIconArr.length) { + this.form.categoryIcon = this.form.categoryIconArr[0].url + } + this.instance.post(`/app/appresourcecategory/addOrUpdate`, {...this.form}).then(res=> { + if(res.code == 0) { + this.$message.success('新增成功') + this.dialog = false + this.getList() + } }) } }) }, - } + handleDelete(ids) { + this.$confirm('确定删除该数据?').then(() => { + this.instance.post(`/app/appresourcecategory/delete?ids=${ids}`).then(res=> { + if (res.code== 0) { + this.$message.success('删除成功!') + this.getList() + } + }) + }) + }, + toEdit(id) { + this.getDetail(id) + this.dialog = true + }, + getDetail(ids) { + this.instance.post(`/app/appresourcecategory/queryDetailById?id=${ids}`).then(res=> { + if(res.data) { + this.form = res.data + // this.form.categoryIconArr = [...res.data.categoryIcon] + } + }) + } + }, }