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

master
zhaochencheng 3 years ago
parent 8091b5f1ce
commit 9d6069a985

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

Loading…
Cancel
Save