refactor: 移除未使用的商品规格相关 API 接口与组件,优化用户管理与物流功能

- 删除了与商品规格相关的 API 接口和组件,简化代码结构。
- 更新用户管理功能,确保表单字段与验证规则一致。
- 优化物流添加与编辑功能,确保请求参数的正确性与一致性。
This commit is contained in:
田香琪
2026-07-16 16:52:55 +08:00
parent 7804d4eba6
commit 7e87214b6d
17 changed files with 555 additions and 396 deletions

View File

@@ -116,28 +116,6 @@
<el-button type="primary" :loading="submitLoading" @click="saveCategoryBrand">提交</el-button>
</template>
</el-dialog>
<el-dialog
v-model="modalSpecVisible"
:title="modalSpecTitle"
width="500px"
:close-on-click-modal="false"
>
<el-form ref="specForm" :model="specForm" label-width="100px">
<el-select v-model="specForm.categorySpecs" multiple style="width: 100%">
<el-option
v-for="item in specifications"
:key="item.id"
:label="item.specName"
:value="item.id"
/>
</el-select>
</el-form>
<template #footer>
<el-button @click="modalSpecVisible = false">取消</el-button>
<el-button type="primary" :loading="submitLoading" @click="saveCategorySpec">提交</el-button>
</template>
</el-dialog>
</el-card>
</div>
</template>
@@ -148,12 +126,9 @@ import {
disableCategory,
getBrandListData,
getCategoryBrandListData,
getCategorySpecListData,
getCategoryTree,
getSpecificationList,
insertCategory,
saveCategoryBrand,
saveCategorySpec,
updateCategory,
} from "@/api/goods";
import uploadPicInput from "@/components/lili/upload-pic-input";
@@ -171,18 +146,14 @@ export default {
categoryList: [],
loading: false,
brands: [],
specifications: [],
categoryId: "",
categorySpecs: [],
modalType: 0,
modalVisible: false,
modalBrandVisible: false,
modalSpecVisible: false,
modalTitle: "",
showParent: false,
parentTitle: "",
modalBrandTitle: "",
modalSpecTitle: "",
formAdd: {
parentId: "",
name: "",
@@ -196,9 +167,6 @@ export default {
categoryBrands: [],
},
brandWay: [],
specForm: {
categorySpecs: [],
},
formValidate: {
commissionRate: [regular.REQUIRED, regular.INTEGER],
name: [regular.REQUIRED, regular.VARCHAR20],
@@ -245,20 +213,12 @@ export default {
init() {
this.getAllList();
this.getBrandList();
this.getSpecList();
},
getBrandList() {
getBrandListData().then((res) => {
this.brandWay = res;
});
},
getSpecList() {
getSpecificationList().then((res) => {
if (res.length != 0) {
this.specifications = res.result;
}
});
},
brandOperation(v) {
getCategoryBrandListData(v.id).then((res) => {
this.categoryId = v.id;
@@ -267,23 +227,6 @@ export default {
this.modalBrandVisible = true;
});
},
specOperation(v) {
getCategorySpecListData(v.id).then((res) => {
this.categoryId = v.id;
this.modalSpecTitle = "规格关联";
this.specForm.categorySpecs = res.map((item) => item.id);
this.modalSpecVisible = true;
});
},
saveCategorySpec() {
saveCategorySpec(this.categoryId, this.specForm).then((res) => {
this.submitLoading = false;
if (res.success) {
ElMessage.success("操作成功");
this.modalSpecVisible = false;
}
});
},
saveCategoryBrand() {
saveCategoryBrand(this.categoryId, this.brandForm).then((res) => {
this.submitLoading = false;

View File

@@ -25,35 +25,37 @@
<el-input-number :min="0" v-model="form.sort" style="width: 520px" />
</el-form-item>
<el-form-item label="参数值" prop="options">
<el-table :data="form.options" border size="small" style="width: 520px">
<el-table-column label="参数值" min-width="420">
<template #default="{ row, $index }">
<el-input
v-if="row"
v-model="form.options[$index].value"
clearable
@blur="touchOptionsValidate"
/>
</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center">
<template #default="{ row, $index }">
<a v-if="row" class="link-text" @click="removeOptionRow($index)">
删除
</a>
</template>
</el-table-column>
</el-table>
<div style="margin-top: 10px">
<el-button type="primary" @click="addOptionRow">新增</el-button>
<div class="options-editor">
<el-table :data="form.options" border size="small" style="width: 520px">
<el-table-column label="参数值" min-width="420">
<template #default="{ row, $index }">
<el-input
v-if="row"
v-model="form.options[$index].value"
clearable
@blur="touchOptionsValidate"
/>
</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center">
<template #default="{ row, $index }">
<a v-if="row" class="link-text" @click="removeOptionRow($index)">
删除
</a>
</template>
</el-table-column>
</el-table>
<div class="options-editor__actions">
<el-button type="primary" @click="addOptionRow">新增</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="关联分类">
<el-form-item label="关联分类" prop="categoryIds">
<el-button @click="openCategoryModal">选择分类</el-button>
<span v-if="selectedCategoryNamesText" style="margin-left: 10px; color: #999; font-size: 12px">
{{ selectedCategoryNamesText }}</span>
<span v-else style="margin-left: 10px; color: #999; font-size: 12px">
已选择{{ selectedCategoryIds.length }}个分类
已选择{{ (form.categoryIds || []).length }}个分类
</span>
</el-form-item>
<el-form-item>
@@ -189,6 +191,28 @@ const buildCategoryIdNameMap = (list, map) => {
});
};
const buildFormState = (source, parameterId) => {
const opts = normalizeOptions(source?.options);
const options = opts.length > 0 ? opts.map((x) => ({ value: x })) : [{ value: "" }];
const categoryList = Array.isArray(source?.categoryParameterList)
? source.categoryParameterList
: [];
const categoryIds = toStringArray(
categoryList.map((x) => x && x.categoryId).filter(Boolean)
);
const formState = {
paramName: source?.paramName || "",
options,
required: normalize01(source?.required, 0),
isIndex: normalize01(source?.isIndex, 0),
sort: Number(source?.sort ?? 0) || 0,
categoryIds,
};
const id = source?.id || parameterId;
if (id) formState.id = id;
return formState;
};
export default {
name: "parameterEdit",
data() {
@@ -209,6 +233,7 @@ export default {
required: 0,
isIndex: 0,
sort: 0,
categoryIds: [],
},
formValidate: {
paramName: [regular.REQUIRED, regular.VARCHAR5],
@@ -216,6 +241,15 @@ export default {
required: [{ required: true, validator: validateRadioRequired("请选择是否必填"), trigger: "change" }],
isIndex: [{ required: true, validator: validateRadioRequired("请选择是否索引"), trigger: "change" }],
sort: [regular.REQUIRED, regular.INTEGER],
categoryIds: [
{
type: "array",
required: true,
min: 1,
message: "请选择关联分类",
trigger: "change",
},
],
},
};
},
@@ -262,15 +296,23 @@ export default {
back() {
this.$router.push({ name: "goods-parameter" });
},
syncCategoryIds(ids) {
const categoryIds = toStringArray(ids);
this.selectedCategoryIds = categoryIds;
if (!this.form) this.form = {};
this.form.categoryIds = categoryIds;
},
touchOptionsValidate() {
if (this.$refs.form && this.$refs.form.validateField) {
this.$refs.form.validateField("options");
}
this.$nextTick(() => {
const form = this.$refs.form;
if (form && typeof form.validateField === "function") {
form.validateField("options", () => {});
}
});
},
addOptionRow() {
if (!Array.isArray(this.form.options)) this.form.options = [];
this.form.options.push({ value: "" });
this.touchOptionsValidate();
},
removeOptionRow(index) {
if (!Array.isArray(this.form.options)) this.form.options = [];
@@ -290,17 +332,8 @@ export default {
const res = await getGoodsParamsDetail(parameterId).catch(() => null);
if (!(res && res.success && res.result)) return;
const dto = res.result;
const opts = normalizeOptions(dto.options);
this.form = {
id: dto.id || parameterId,
paramName: dto.paramName || "",
options: opts.map((x) => ({ value: x })),
required: normalize01(dto.required, 0),
isIndex: normalize01(dto.isIndex, 0),
sort: Number(dto.sort ?? 0) || 0,
};
const list = Array.isArray(dto.categoryParameterList) ? dto.categoryParameterList : [];
this.selectedCategoryIds = toStringArray(list.map((x) => x && x.categoryId).filter(Boolean));
this.form = buildFormState(dto, parameterId);
this.selectedCategoryIds = [...this.form.categoryIds];
},
async openCategoryModal() {
this.categoryModalVisible = true;
@@ -320,7 +353,13 @@ export default {
}
},
onCategoryTreeCheckChange(_data, checkedInfo) {
this.selectedCategoryIds = toStringArray(checkedInfo?.checkedKeys || []);
this.syncCategoryIds(checkedInfo?.checkedKeys || []);
this.$nextTick(() => {
const form = this.$refs.form;
if (form && typeof form.validateField === "function") {
form.validateField("categoryIds", () => {});
}
});
},
initForm() {
if (this.id) {
@@ -329,15 +368,8 @@ export default {
if (cached) {
try {
const row = JSON.parse(cached);
const opts = normalizeOptions(row.options);
this.form = {
id: row.id,
paramName: row.paramName || "",
options: opts.map((x) => ({ value: x })),
required: normalize01(row.required, 0),
isIndex: normalize01(row.isIndex, 0),
sort: Number(row.sort ?? 0) || 0,
};
this.form = buildFormState(row, row.id);
this.selectedCategoryIds = [...this.form.categoryIds];
} catch (e) {
this.modalType = 0;
}
@@ -348,7 +380,7 @@ export default {
if (!Array.isArray(this.form.options) || this.form.options.length === 0) {
this.form.options = [{ value: "" }];
}
this.selectedCategoryIds = [];
this.syncCategoryIds([]);
}
},
handleSubmit() {
@@ -356,7 +388,7 @@ export default {
if (!valid) return;
this.submitLoading = true;
const options = normalizeOptions(this.form.options);
const categoryIds = toStringArray(this.selectedCategoryIds);
const categoryIds = toStringArray(this.form.categoryIds);
const payload = {
...this.form,
options: options.join(","),
@@ -404,4 +436,14 @@ export default {
};
</script>
<style lang="scss"></style>
<style lang="scss">
.options-editor {
display: flex;
flex-direction: column;
width: 520px;
}
.options-editor__actions {
margin-top: 10px;
}
</style>

View File

@@ -44,7 +44,7 @@
<template #default="{ row }">
<div v-if="row">
<a class="link-text" @click="goEdit(row)">编辑</a>
<span class="op-split">|</span>|<span class="op-split">|</span>
<span class="op-split">|</span>
<a class="link-text" @click="remove(row)">删除</a>
</div>
</template>