业务修改:目前只有一级分类

master
zhaochencheng 3 years ago
parent 8091b5f1ce
commit 9d6069a985

@ -1,10 +1,22 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium"
class="ry_form">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="100px"
size="medium"
class="ry_form"
>
<el-form-item label="状态" prop="showStatus">
<DictRadio v-model="queryParams.showStatus" @change="handleQuery" size="small"
:radioData="dict.type.sys_show_status" :showAll="'all'"/>
<DictRadio
v-model="queryParams.showStatus"
@change="handleQuery"
size="small"
:radioData="dict.type.sys_show_status"
:showAll="'all'"
/>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input
@ -17,8 +29,16 @@
</el-form-item>
<el-form-item class="flex_one tr">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
@ -40,20 +60,33 @@
:data="pmsProductCategoryList"
:tree-props="{ hasChildren: 'hasChildren', children: 'children' }"
@selection-change="handleSelectionChange"
row-key="id">
<el-table-column label="名称" align="center" prop="name"/>
row-key="id"
>
<el-table-column label="名称" align="center" prop="name" />
<el-table-column label="图片" align="center" prop="icon">
<template slot-scope="{ row }">
<el-image v-if="row.icon" :src="row.icon" :preview-src-list="[row.icon]" class="small-img circle-img"/>
<el-image
v-if="row.icon"
:src="row.icon"
:preview-src-list="[row.icon]"
class="small-img circle-img"
/>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sort"/>
<el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="状态" align="center" prop="showStatus">
<template v-slot="{ row }">
<dict-tag :value="row.showStatus" prop-name="sys_show_status"></dict-tag>
<dict-tag
:value="row.showStatus"
prop-name="sys_show_status"
></dict-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -77,24 +110,27 @@
<el-dialog :title="title" :visible.sync="open" width="500px">
<el-form ref="form" :model="form" :rules="rules" label-width="108px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="名称"/>
<el-input v-model="form.name" placeholder="名称" />
</el-form-item>
<el-form-item label="图片" prop="icon">
<oss-image-upload v-model="form.icon" :limit="1" />
</el-form-item>
<el-form-item label="状态">
<DictRadio v-model="form.showStatus" size="small"
:radioData="dict.type.sys_show_status"/>
<DictRadio
v-model="form.showStatus"
size="small"
:radioData="dict.type.sys_show_status"
/>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="form.sort" placeholder="排序"/>
<el-input v-model="form.sort" placeholder="排序" />
</el-form-item>
<el-form-item label="层级" prop="level">
<el-input v-model="form.level" placeholder="层级"/>
<el-input v-model="form.level" placeholder="层级" />
</el-form-item>
<el-form-item label="上级分类" prop="parentId">
<!-- <el-form-item label="上级分类" prop="parentId">
<product-category-select class="w200" v-model="form.parentId" :props="{ checkStrictly: true }"/>
</el-form-item>
</el-form-item> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -111,14 +147,14 @@ import {
delPmsProductCategory,
addPmsProductCategory,
updatePmsProductCategory,
exportPmsProductCategory
exportPmsProductCategory,
} from "@/api/pms/productCategory";
import ProductCategorySelect from "@/views/components/ProductCategorySelect";
export default {
name: "PmsProductCategory",
dicts: ['sys_show_status'],
components: {ProductCategorySelect},
dicts: ["sys_show_status"],
components: { ProductCategorySelect },
data() {
return {
//
@ -160,8 +196,8 @@ export default {
/** 查询商品分类列表 */
getList() {
this.loading = true;
const query = {...this.queryParams};
listPmsProductCategory(query).then(rows => {
const query = { ...this.queryParams };
listPmsProductCategory(query).then((rows) => {
this.pmsProductCategoryList = rows;
this.loading = false;
});
@ -184,7 +220,7 @@ export default {
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
updateTime: null,
};
this.resetForm("form");
},
@ -199,9 +235,9 @@ export default {
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -212,8 +248,8 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getPmsProductCategory(id).then(response => {
const id = row.id || this.ids;
getPmsProductCategory(id).then((response) => {
this.form = response;
this.open = true;
this.title = "修改商品分类";
@ -221,58 +257,64 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
let p;
if(this.form.parentId){
this.form.parentId = this.form.parentId.pop()
if (this.form.parentId) {
this.form.parentId = this.form.parentId.pop();
}
if (this.form.id != null) {
p = updatePmsProductCategory(this.form).then(response => {
p = updatePmsProductCategory(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
p = addPmsProductCategory(this.form).then(response => {
p = addPmsProductCategory(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
p.then(() => {
this.$store.dispatch('mall/loadProductCategories', true)
})
this.$store.dispatch("mall/loadProductCategories", true);
});
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
if (row.children && row.children.length > 0) {
this.$message.error('请先删除子目录');
this.$message.error("请先删除子目录");
return;
}
const ids = row.id;
this.$modal.confirm('是否确认删除商品分类编号为"' + ids + '"的数据项?').then(function () {
this.$modal
.confirm('是否确认删除商品分类编号为"' + ids + '"的数据项?')
.then(function () {
return delPmsProductCategory(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$modal.confirm('是否确认导出所有商品分类数据项?').then(() => {
this.$modal
.confirm("是否确认导出所有商品分类数据项?")
.then(() => {
this.exportLoading = true;
return exportPmsProductCategory(queryParams);
}).then(response => {
})
.then((response) => {
this.$download.download(response);
this.exportLoading = false;
}).catch(() => {
});
}
}
})
.catch(() => {});
},
},
};
</script>

Loading…
Cancel
Save