This commit is contained in:
yanran200730
2022-10-08 14:05:21 +08:00
3 changed files with 1307 additions and 22 deletions

View File

@@ -9,13 +9,12 @@
</ai-search-bar> </ai-search-bar>
<ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size" <ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size"
@getList="getList()" :col-configs="colConfigs" :dict="dict"> @getList="getList()" :col-configs="colConfigs" :dict="dict">
<!-- @sort-change="changeTableSort" -->
<!-- <el-table-column label="商品图" slot="merchandisePhoto" align="center" width="130"> <el-table-column label="分类图标" slot="categoryIcon" align="center">
<template v-slot="{ row }"> <template v-slot="{ row }">
<ai-uploader :disabled="true" :instance="instance" v-model="row.merchandisePhoto" :limit="9"></ai-uploader> <ai-uploader :disabled="true" valueIsUrl :instance="instance" v-model="row.categoryIcon" :limit="1"></ai-uploader>
</template> </template>
</el-table-column> --> </el-table-column>
<el-table-column slot="options" label="状态" align="center"> <el-table-column slot="options" label="状态" align="center">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
@@ -23,25 +22,26 @@
<el-button type="text" title="删除" @click="handleDelete(row.id)">删除</el-button> <el-button type="text" title="删除" @click="handleDelete(row.id)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</ai-table> </ai-table>
</template> </template>
</ai-list> </ai-list>
<ai-dialog title="添加资源分类" :visible.sync="dialog" :customFooter="true" :destroyOnClose="true" width="720px" @onConfirm="onConfirm" @closed="form={}">
<ai-dialog title="添加资源分类" :visible.sync="dialog" :customFooter="true" :destroyOnClose="true" width="720px" @onConfirm="onConfirm" @closed="form={}">
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="categoryName"> <el-form-item label="分类名称" prop="categoryName">
<el-input v-model.trim="form.categoryName" placeholder="请输入" type="text" maxlength="20"></el-input> <el-input v-model.trim="form.categoryName" placeholder="请输入" type="text" maxlength="20"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="分类图标" prop="categoryIcon"> <el-form-item label="分类图标" prop="categoryIcon">
<ai-uploader :instance="instance" isShowTip v-model="form.categoryIcon" :limit="1"></ai-uploader> <ai-uploader :instance="instance" valueIsUrl isShowTip v-model="form.categoryIcon" :limit="1"></ai-uploader>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="dialog-footer" slot="footer"> <div class="dialog-footer" slot="footer">
<el-button @click="dialog=false;form={}">取消</el-button> <el-button @click="dialog=false;form={}">取消</el-button>
<el-button type="primary" @click="onConfirm">确定</el-button> <el-button type="primary" @click="onConfirm">确定</el-button>
</div> </div>
</ai-dialog> </ai-dialog>
</section> </section>
</template> </template>
@@ -67,17 +67,17 @@ export default {
dialog: false, dialog: false,
form: { form: {
categoryName: '', categoryName: '',
categoryIcon: '' categoryIcon: '',
} }
} }
}, },
computed: { computed: {
colConfigs() { colConfigs() {
return [ return [
{prop: 'resourceName', label: '分类名称', width: '300px'}, {prop: 'categoryName', label: '分类名称', width: '300px'},
{prop: 'categoryName', label: '资源数量', align: 'center'}, {prop: 'resourceNum', label: '资源数量', align: 'center'},
// {prop: "merchandisePhoto",slot: "merchandisePhoto",align: "center",label: "商品图"}, {slot: "categoryIcon"},
{prop: 'option'} {slot: 'option'},
] ]
}, },
rules() { rules() {
@@ -100,7 +100,9 @@ export default {
}).then(res=> { }).then(res=> {
if(res?.data) { if(res?.data) {
this.tableData = res.data.records this.tableData = res.data.records
this.total = res.total this.total = res.data.total
console.log(this.tableData);
} }
}) })
}, },
@@ -108,13 +110,39 @@ export default {
onConfirm() { onConfirm() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if(valid) { if(valid) {
this.instance.post(`/app/appresourcecategory/addOrUpdate`, ...this.form).then(res=> { this.instance.post(`/app/appresourcecategory/addOrUpdate`, {...this.form}).then(res=> {
console.log(res,this.form.categoryIcon); 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) {
console.log(res.data);
this.form = res.data
}
})
}
},
} }
</script> </script>

View File

@@ -15,7 +15,6 @@
</ai-search-bar> </ai-search-bar>
<ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size" <ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size"
@getList="getList()" :col-configs="colConfigs" :dict="dict"> @getList="getList()" :col-configs="colConfigs" :dict="dict">
<!-- @sort-change="changeTableSort" -->
</ai-table> </ai-table>
</template> </template>
</ai-list> </ai-list>
@@ -66,7 +65,7 @@ export default {
}).then(res=> { }).then(res=> {
if(res?.data) { if(res?.data) {
this.tableData = res.data.records this.tableData = res.data.records
this.total = res.total this.total = res.data.total
} }
}) })
}, },