|
@@ -21,7 +21,55 @@
|
|
</byTable>
|
|
</byTable>
|
|
</div>
|
|
</div>
|
|
<el-dialog :title="modalType == 'add' ? '新增' : '编辑'" v-model="dialogVisible" width="800" v-loading="loading">
|
|
<el-dialog :title="modalType == 'add' ? '新增' : '编辑'" v-model="dialogVisible" width="800" v-loading="loading">
|
|
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform"> </byForm>
|
|
|
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
|
|
|
|
+ <template #subCategorySlot>
|
|
|
|
+ <el-row style="width: 100%;margin-bottom: 10px" v-for="(row, index) in formData.data.subCategoryList" ref="sort">
|
|
|
|
+ <el-col :span="6" >
|
|
|
|
+ <el-form-item
|
|
|
|
+ :prop="'subCategoryList.' + index + '.name'"
|
|
|
|
+ :rules="rules.subName"
|
|
|
|
+ prop="name"
|
|
|
|
+ style="margin: 8px 0 8px 0">
|
|
|
|
+ <el-input v-model="row.name" placeholder="请输入子类目" :controls="false" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" style="margin-left: 8px;">
|
|
|
|
+ <el-form-item
|
|
|
|
+ :prop="'subCategoryList.' + index + '.code'"
|
|
|
|
+ prop="name"
|
|
|
|
+ style="margin: 8px 0 8px 0">
|
|
|
|
+ <el-input v-model="row.code" placeholder="请输入子类目编号" :controls="false" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" >
|
|
|
|
+ <el-form-item
|
|
|
|
+ :prop="'subCategoryList.' + index + '.status'"
|
|
|
|
+ :rules="rules.subStatus" style="margin-left: 8px;transform: translateY(8px)"
|
|
|
|
+ prop="status">
|
|
|
|
+ <el-select v-model="row.status" placeholder="请选择状态" >
|
|
|
|
+ <el-option v-for="item in enableStatus" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" >
|
|
|
|
+ <el-form-item
|
|
|
|
+ :prop="'subCategoryList.' + index + '.sort'"
|
|
|
|
+ :rules="rules.subSort" style="margin-left: 8px;transform: translateY(8px)"
|
|
|
|
+ prop="sort">
|
|
|
|
+ <el-input-number v-model="row.sort" placeholder="请输入排序" :precision="0" :max="999" :min="0" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2" >
|
|
|
|
+ <el-icon style="margin-left: 8px; color: red; cursor: pointer; transform: translateY(10px)" @click="clickDelete(index)"><Delete /></el-icon>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row style="width: 100%">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-button type="primary" @click="clickAddSubCategory()">添加</el-button>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-row>
|
|
|
|
+ </template>
|
|
|
|
+ </byForm>
|
|
<template #footer>
|
|
<template #footer>
|
|
<el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
<el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
<el-button type="primary" v-no-double-click="submitForm" size="large" :loading="submitLoading">确 定</el-button>
|
|
<el-button type="primary" v-no-double-click="submitForm" size="large" :loading="submitLoading">确 定</el-button>
|
|
@@ -53,6 +101,11 @@ let modalType = ref("add");
|
|
let rules = ref({
|
|
let rules = ref({
|
|
name: [{ required: true, message: "请输入名称" }],
|
|
name: [{ required: true, message: "请输入名称" }],
|
|
status: [{ required: true, message: "请选择启用状态", trigger: "change" }],
|
|
status: [{ required: true, message: "请选择启用状态", trigger: "change" }],
|
|
|
|
+ sort: [{ required: true, message: "请输入排序", trigger: "blur" }],
|
|
|
|
+
|
|
|
|
+ subName: [{ required: true, message: "请输入子类目", trigger: "blur" }],
|
|
|
|
+ subStatus: [{ required: true, message: "请输入子类目启用状态", trigger: "blur" }],
|
|
|
|
+ subSort: [{ required: true, message: "请输入子类目排序", trigger: "blur" }],
|
|
});
|
|
});
|
|
const { proxy } = getCurrentInstance();
|
|
const { proxy } = getCurrentInstance();
|
|
const config = computed(() => {
|
|
const config = computed(() => {
|
|
@@ -142,6 +195,7 @@ const config = computed(() => {
|
|
let formData = reactive({
|
|
let formData = reactive({
|
|
data: {},
|
|
data: {},
|
|
treeData: [],
|
|
treeData: [],
|
|
|
|
+ subCategoryList:[],
|
|
});
|
|
});
|
|
const formOption = reactive({
|
|
const formOption = reactive({
|
|
inline: true,
|
|
inline: true,
|
|
@@ -182,6 +236,12 @@ const formConfig = computed(() => {
|
|
width: "50%",
|
|
width: "50%",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ type: "slot",
|
|
|
|
+ slotName: "subCategorySlot",
|
|
|
|
+ prop: "subCategory",
|
|
|
|
+ label: "子类目",
|
|
|
|
+ },
|
|
];
|
|
];
|
|
});
|
|
});
|
|
const getList = async (req) => {
|
|
const getList = async (req) => {
|
|
@@ -204,8 +264,7 @@ const openModal = () => {
|
|
const submitForm = () => {
|
|
const submitForm = () => {
|
|
byform.value.handleSubmit((valid) => {
|
|
byform.value.handleSubmit((valid) => {
|
|
submitLoading.value = true;
|
|
submitLoading.value = true;
|
|
- proxy
|
|
|
|
- .post("/productCategory/" + modalType.value, formData.data)
|
|
|
|
|
|
+ proxy.post("/productCategory/" + modalType.value, formData.data)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
ElMessage({
|
|
ElMessage({
|
|
message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
@@ -278,6 +337,28 @@ const getDictlist = async () => {
|
|
value: x.dictKey,
|
|
value: x.dictKey,
|
|
}));
|
|
}));
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+//添加子类目
|
|
|
|
+const clickAddSubCategory = () => {
|
|
|
|
+ if (formData.data.subCategoryList && formData.data.subCategoryList.length > 0) {
|
|
|
|
+ const sort = formData.data.subCategoryList[formData.data.subCategoryList.length-1].sort
|
|
|
|
+ formData.data.subCategoryList.push({
|
|
|
|
+ name: "",
|
|
|
|
+ sort: sort+10,
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ formData.data.subCategoryList = [
|
|
|
|
+ {
|
|
|
|
+ name: "",
|
|
|
|
+ sort: 10,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const clickDelete = (index) => {
|
|
|
|
+ formData.data.subCategoryList.splice(index, 1);
|
|
|
|
+};
|
|
getList();
|
|
getList();
|
|
getDictlist();
|
|
getDictlist();
|
|
</script>
|
|
</script>
|