优化分类
This commit is contained in:
parent
bf60ee88e2
commit
273e20cccc
|
|
@ -120,13 +120,13 @@ export function tbShopCategoryGet(params) {
|
|||
}
|
||||
|
||||
/**
|
||||
* 新增分类/新增子分类
|
||||
* 新增、编辑分类/新增、编辑子分类
|
||||
* @returns
|
||||
*/
|
||||
export function tbShopCategoryPost(data) {
|
||||
export function tbShopCategoryPost(data, method = 'post') {
|
||||
return request({
|
||||
url: `/api/tbShopCategory`,
|
||||
method: 'post',
|
||||
method: method,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export default {
|
|||
const res = await tbShopCategoryGet({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
sort: 'id',
|
||||
sort: 'id,desc',
|
||||
shopId: localStorage.getItem('shopId')
|
||||
})
|
||||
this.tableData.loading = false
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ export default {
|
|||
pid: '',
|
||||
isShow: 1,
|
||||
name: '',
|
||||
shopId: localStorage.getItem('shopId'),
|
||||
sort: 0,
|
||||
sort: '',
|
||||
style: '#000000',
|
||||
pic: ''
|
||||
},
|
||||
resetForm: '',
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
|
|
@ -65,18 +65,22 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.resetForm = { ...this.form }
|
||||
},
|
||||
methods: {
|
||||
onSubmitHandle() {
|
||||
console.log(this.form)
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
let res = await tbShopCategoryPost(this.form)
|
||||
this.form.shopId = localStorage.getItem('shopId')
|
||||
let res = await tbShopCategoryPost(this.form, this.form.id ? 'put' : 'post')
|
||||
this.$emit('success', res)
|
||||
this.close()
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: `${this.form.pid ? '编辑' : '添加'}成功`,
|
||||
message: `${this.form.id ? '编辑' : '添加'}成功`,
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
@ -88,16 +92,11 @@ export default {
|
|||
show(obj) {
|
||||
// console.log(obj)
|
||||
this.dialogVisible = true
|
||||
if (obj && obj.pid) {
|
||||
if (obj.pid) {
|
||||
this.form.pid = obj.pid
|
||||
}
|
||||
if (obj && obj.id) {
|
||||
this.form.id = obj.id
|
||||
this.form.isShow = obj.isShow
|
||||
this.form.name = obj.name
|
||||
this.form.sort = obj.sort
|
||||
this.form.style = obj.style
|
||||
this.form.pic = obj.pic
|
||||
this.form = obj
|
||||
if (obj.pic) {
|
||||
setTimeout(() => {
|
||||
this.$refs.uploadImg.fileList = [
|
||||
|
|
@ -113,13 +112,7 @@ export default {
|
|||
this.dialogVisible = false
|
||||
},
|
||||
reset() {
|
||||
this.form.pid = ''
|
||||
this.form.isShow = 1
|
||||
this.form.name = ''
|
||||
this.form.sort = 0
|
||||
this.form.style = '#000000'
|
||||
this.form.pic = ''
|
||||
|
||||
this.form = { ...this.resetForm }
|
||||
this.$refs.uploadImg.clearFiles()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue