From 7e87214b6d041e346beacddf7d1aee8656e8ea90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E9=A6=99=E7=90=AA?= <624506849@qq.com> Date: Thu, 16 Jul 2026 16:52:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=20API=20=E6=8E=A5=E5=8F=A3=E4=B8=8E=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=B8=8E=E7=89=A9=E6=B5=81=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86=E4=B8=8E=E5=95=86=E5=93=81=E8=A7=84?= =?UTF-8?q?=E6=A0=BC=E7=9B=B8=E5=85=B3=E7=9A=84=20API=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=92=8C=E7=BB=84=E4=BB=B6=EF=BC=8C=E7=AE=80=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E3=80=82=20-=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E8=A1=A8=E5=8D=95=E5=AD=97=E6=AE=B5=E4=B8=8E?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=E4=B8=80=E8=87=B4=E3=80=82?= =?UTF-8?q?=20-=20=E4=BC=98=E5=8C=96=E7=89=A9=E6=B5=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8E=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E8=AF=B7=E6=B1=82=E5=8F=82=E6=95=B0=E7=9A=84=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E6=80=A7=E4=B8=8E=E4=B8=80=E8=87=B4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/src/api/goods.js | 19 -- manager/src/api/index.js | 30 ++- manager/src/api/logistics.js | 21 ++- .../src/components/editor/upload-image.vue | 54 ++++-- .../src/views/goods/goods-manage/category.vue | 57 ------ .../goods/goods-manage/parameter-edit.vue | 144 +++++++++----- .../views/goods/goods-manage/parameter.vue | 2 +- manager/src/views/logistics/index.vue | 13 +- .../views/page/article-manage/articleList.vue | 144 ++++++++++---- .../coupon-activity/coupon-publish.vue | 80 ++++---- .../kanjia/kanjia-activity-add-goods.vue | 175 ++++++++++-------- .../kanjia/kanjia-activity-edit-goods.vue | 138 ++++++++------ .../src/views/seller/shop/shopOperation.vue | 4 +- manager/src/views/sys/slider/slider.vue | 2 +- .../src/views/sys/user-manage/userManage.vue | 36 +++- seller/src/api/goods.js | 14 -- .../goods/goods-seller/goodsOperationSec.vue | 18 -- 17 files changed, 555 insertions(+), 396 deletions(-) diff --git a/manager/src/api/goods.js b/manager/src/api/goods.js index 6f0f203d..6bebf41f 100644 --- a/manager/src/api/goods.js +++ b/manager/src/api/goods.js @@ -52,19 +52,11 @@ export const saveParameterCategory = (parameter_id, categoryIds) => { "Content-Type": "application/json" }) } -//保存获取关联规格 -export const saveCategorySpec = (category_id, params) => { - return postRequest(`/goods/categorySpec/${category_id}`, params) -} //获取所有可用品牌 export const getBrandListData = (params) => { return getRequest('/goods/brand/all', params) } -// 获取所有可用规格 -export const getSpecificationList = (params) => { - return getRequest('/goods/spec/all', params) -} //获取分类列表数据 export const getAllCategoryList = (parent_id) => { @@ -93,11 +85,6 @@ export const disableCategory = (id, type) => { return putRequest(`/goods/category/disable/${id}`, type) } -//根据分类id获取关联规格 -export const getCategorySpecListData = (category_id, params) => { - return getRequest(`/goods/categorySpec/${category_id}`, params) -} - // 查询某分类下的全部子分类列表 export const getGoodsCategory = (parent_id) => { return getRequest(`/goods/category/${parent_id}/all-children`) @@ -221,12 +208,6 @@ export const deleteParamsGroup = (id, params) => { return deleteRequest(`/goods/categoryParameters/${id}`, params) } -//保存获取关联规格 -export const getGoodsSpecInfo = (category_id, params) => { - return getRequest(`/goods/categorySpec/goods/${category_id}`, params) -} - - //获取sku列表 export const getSkuPage = (params) => { return getRequest(`/goodsSku/getByPage`, params) diff --git a/manager/src/api/index.js b/manager/src/api/index.js index fe80992c..c9dd362f 100644 --- a/manager/src/api/index.js +++ b/manager/src/api/index.js @@ -120,9 +120,37 @@ export const getAllUserData = (params) => { return getRequest("/passport/user/getAll", params); }; +function buildUserRegisterFormBody(params) { + const parts = []; + const appendField = (key, value) => { + if (value === undefined || value === null || value === "") return; + parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`); + }; + appendField("username", params.username); + appendField("password", params.password); + appendField("nickName", params.nickName); + appendField("mobile", params.mobile); + appendField("email", params.email); + appendField("avatar", params.avatar); + appendField("description", params.description); + if (params.departmentId !== undefined && params.departmentId !== null && params.departmentId !== "" && params.departmentId !== 0) { + appendField("departmentId", params.departmentId); + } + if (params.isSuper !== undefined && params.isSuper !== null) { + appendField("isSuper", params.isSuper); + } + if (Array.isArray(params.roles)) { + params.roles.forEach((roleId) => appendField("roles", roleId)); + } + return parts.join("&"); +} + // 添加用户 export const addUser = (params) => { - return postRequest("/passport/user", params); + const body = buildUserRegisterFormBody(params); + return postRequest("/passport/user/register", body, { + "Content-Type": "application/x-www-form-urlencoded", + }); }; // 编辑管理员自身 export const editUser = (params) => { diff --git a/manager/src/api/logistics.js b/manager/src/api/logistics.js index 4f09d2c1..621a8384 100644 --- a/manager/src/api/logistics.js +++ b/manager/src/api/logistics.js @@ -14,11 +14,28 @@ export const getLogisticsPage = params => { }; // 删除 export const delLogistics = id => { - return deleteRequest(`/other/logistics/delete/${id}`); + return deleteRequest(`/other/logistics/${id}`); }; // 添加 +function buildLogisticsFormBody(params) { + const parts = []; + const appendField = (key, value) => { + if (value === undefined || value === null || value === "") return; + parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`); + }; + appendField("name", params.name); + appendField("code", params.code); + appendField("disabled", params.disabled); + appendField("standBy", params.standBy); + appendField("formItems", params.formItems); + return parts.join("&"); +} + export const addLogistics = params => { - return postRequest(`/other/logistics/save`,params); + const body = buildLogisticsFormBody(params); + return postRequest("/other/logistics", body, { + "Content-Type": "application/x-www-form-urlencoded", + }); }; // 通过id查询详情 export const getLogisticsDetail = id => { diff --git a/manager/src/components/editor/upload-image.vue b/manager/src/components/editor/upload-image.vue index d2a3ca13..fd6c5aa5 100644 --- a/manager/src/components/editor/upload-image.vue +++ b/manager/src/components/editor/upload-image.vue @@ -3,12 +3,12 @@ 上传图片
从资源库中导入
-
+
- - - - - - - - -
@@ -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; diff --git a/manager/src/views/goods/goods-manage/parameter-edit.vue b/manager/src/views/goods/goods-manage/parameter-edit.vue index a7e84523..38f962ac 100644 --- a/manager/src/views/goods/goods-manage/parameter-edit.vue +++ b/manager/src/views/goods/goods-manage/parameter-edit.vue @@ -25,35 +25,37 @@ - - - - - - - - -
- 新增 +
+ + + + + + + + +
+ 新增 +
- + 选择分类 {{ selectedCategoryNamesText }} - 已选择{{ selectedCategoryIds.length }}个分类 + 已选择{{ (form.categoryIds || []).length }}个分类 @@ -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 { }; - + diff --git a/manager/src/views/goods/goods-manage/parameter.vue b/manager/src/views/goods/goods-manage/parameter.vue index ccfc859e..b9c147ec 100644 --- a/manager/src/views/goods/goods-manage/parameter.vue +++ b/manager/src/views/goods/goods-manage/parameter.vue @@ -44,7 +44,7 @@ diff --git a/manager/src/views/logistics/index.vue b/manager/src/views/logistics/index.vue index 35dab4a8..f4486cb4 100644 --- a/manager/src/views/logistics/index.vue +++ b/manager/src/views/logistics/index.vue @@ -137,6 +137,13 @@ export default { trigger: "blur", }, ], + code: [ + { + required: true, + message: "请输入物流公司编码", + trigger: "blur", + }, + ], }, submitLoading: false, data: [], @@ -192,10 +199,12 @@ export default { if (this.modalTitle === "添加") { const payload = { - ...this.form, + name: this.form.name, + code: this.form.code, + disabled: this.form.disabled, standBy: normalizeStandBy(this.form.standBy), + formItems: this.form.formItems, }; - delete payload.id; addLogistics(payload).then((res) => { this.submitLoading = false; if (res.success) { diff --git a/manager/src/views/page/article-manage/articleList.vue b/manager/src/views/page/article-manage/articleList.vue index 65f5f127..651f4627 100644 --- a/manager/src/views/page/article-manage/articleList.vue +++ b/manager/src/views/page/article-manage/articleList.vue @@ -1,20 +1,19 @@ - + +
- - +
- + @@ -155,6 +155,25 @@ import { updateArticleStatus, } from "@/api/pages"; import tinymec from "@/components/editor/index.vue"; +import { regular } from "@/utils"; + +const validateArticleContent = (rule, value, callback) => { + const html = String(value || "").trim(); + if (!html) { + callback(new Error("请填写文章内容")); + return; + } + const text = html + .replace(/<[^>]+>/g, "") + .replace(/ /gi, " ") + .trim(); + const hasImage = /]/i.test(html); + if (!text && !hasImage) { + callback(new Error("请填写文章内容")); + return; + } + callback(); +}; export default { components: { @@ -190,6 +209,12 @@ export default { content: "", id: "", }, + formValidate: { + title: [{ required: true, message: "请输入文章标题", trigger: "blur" }], + categoryId: [{ required: true, message: "请选择文章分类", trigger: "change" }], + sort: [regular.REQUIRED, regular.INTEGER], + content: [{ required: true, validator: validateArticleContent, trigger: "change" }], + }, list: [], treeValue: "", treeData: [], @@ -213,6 +238,15 @@ export default { }, }, methods: { + getDefaultForm() { + return { + openStatus: false, + title: "", + categoryId: "", + sort: 1, + content: "", + }; + }, init() { this.getDataList(); this.getAllList(0); @@ -224,8 +258,8 @@ export default { handleCateChange(data) { if (!data) return; const { value, title } = data; - this.list.push({ value, title }); - this.searchForm.categoryId = value; + this.searchForm.categoryId = + value === "0" || value === 0 ? "" : value; this.searchTreeValue = title; }, changeSwitch(v) { @@ -308,10 +342,24 @@ export default { } return arr; }, + buildArticleSearchParams() { + const params = { ...this.searchForm }; + const categoryId = params.categoryId; + if ( + categoryId === "" || + categoryId === null || + categoryId === undefined || + categoryId === 0 || + categoryId === "0" + ) { + delete params.categoryId; + } + return params; + }, getDataList(val) { if (val) this.form = {}; this.loading = true; - getArticle(this.searchForm) + getArticle(this.buildArticleSearchParams()) .then((res) => { if (res.success) { this.total = res.result.total; @@ -323,6 +371,9 @@ export default { }); }, handleSubmit() { + if (this.$refs.editor?.getContent) { + this.form.content = this.$refs.editor.getContent(); + } this.$refs.form.validate((valid) => { if (valid) { this.submitLoading = true; @@ -353,20 +404,17 @@ export default { this.modalType = 0; this.modalTitle = "添加文章"; this.treeValue = ""; - this.form = { - sort: 1, - content: "", - }; - this.$refs.form?.resetFields(); - delete this.form.id; + this.form = this.getDefaultForm(); this.modalVisible = true; + this.$nextTick(() => { + this.$refs.form?.clearValidate?.(); + }); }, edit(data) { this.modalType = 1; this.modalTitle = "编辑文章"; this.treeValue = ""; - this.form = { content: "" }; - this.$refs.form?.resetFields(); + this.form = this.getDefaultForm(); seeArticle(data.id).then((res) => { if (res.result) { this.modalVisible = true; @@ -402,3 +450,35 @@ export default { }, }; + + diff --git a/manager/src/views/promotions/coupon-activity/coupon-publish.vue b/manager/src/views/promotions/coupon-activity/coupon-publish.vue index bca307e9..8cd55e9b 100644 --- a/manager/src/views/promotions/coupon-activity/coupon-publish.vue +++ b/manager/src/views/promotions/coupon-activity/coupon-publish.vue @@ -13,11 +13,11 @@ style="width: 260px" /> - + { + if (!value || !Array.isArray(value) || value.length !== 2 || !value[0] || !value[1]) { + callback(new Error("请选择活动有效期")); + } else { + callback(); + } + }, + trigger: "change", + }, + ], description: [{ required: true, message: "请输入范围描述" }], }, }; @@ -291,49 +303,31 @@ export default { this.showCouponSelect = true; }, handleSubmit() { - if (this.form.couponFrequencyEnum !== "") { - if (this.form.activityScope == "ALL") { - this.form.startTime = this.$filters.unixToDate(this.rangeTime[0] / 1000); - this.form.endTime = this.$filters.unixToDate(this.rangeTime[1] / 1000); + if (this.form.couponFrequencyEnum !== "" && this.form.activityScope != "ALL") { + this.$Message.info("自动发券只能全用户发送"); + this.form.couponActivityType = "SPECIFY"; + this.form.activityScope = "ALL"; + return; + } - this.$refs.form.validate((valid) => { - if (valid) { - const params = JSON.parse(JSON.stringify(this.form)); - this.submitLoading = true; - delete params.id; - saveActivityCoupon(params).then((res) => { - this.submitLoading = false; - if (res.success) { - this.$Message.success("优惠券活动创建成功"); - this.closeCurrentPage(); - } - }); - } - }); - } else { - this.$Message.info("自动发券只能全用户发送"); - this.form.couponActivityType = "SPECIFY"; - this.form.activityScope = "ALL"; - } - } else { - this.form.startTime = this.$filters.unixToDate(this.rangeTime[0] / 1000); - this.form.endTime = this.$filters.unixToDate(this.rangeTime[1] / 1000); + this.$refs.form.validate((valid) => { + if (!valid) return; - this.$refs.form.validate((valid) => { - if (valid) { - const params = JSON.parse(JSON.stringify(this.form)); - this.submitLoading = true; - delete params.id; - saveActivityCoupon(params).then((res) => { - this.submitLoading = false; - if (res.success) { - this.$Message.success("优惠券活动创建成功"); - this.closeCurrentPage(); - } - }); + this.form.startTime = this.$filters.unixToDate(this.form.rangeTime[0] / 1000); + this.form.endTime = this.$filters.unixToDate(this.form.rangeTime[1] / 1000); + + const params = JSON.parse(JSON.stringify(this.form)); + delete params.rangeTime; + delete params.id; + this.submitLoading = true; + saveActivityCoupon(params).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success("优惠券活动创建成功"); + this.closeCurrentPage(); } }); - } + }); }, closeCurrentPage() { this.$store.commit("removeTag", "add-platform-coupon"); diff --git a/manager/src/views/promotions/kanjia/kanjia-activity-add-goods.vue b/manager/src/views/promotions/kanjia/kanjia-activity-add-goods.vue index 42a192e7..e064b141 100644 --- a/manager/src/views/promotions/kanjia/kanjia-activity-add-goods.vue +++ b/manager/src/views/promotions/kanjia/kanjia-activity-add-goods.vue @@ -6,7 +6,7 @@

商品信息

- + 选择商品 @@ -116,13 +116,30 @@ export default { modalType: 0, form: { promotionGoodsList: [], + rangeTime: [], }, id: this.$route.query.id, submitLoading: false, selectedGoods: [], promotionGoodsList: [], formRule: { - rangeTime: [{ required: true, message: "请选择活动时间" }], + promotionGoodsList: [ + { + type: "array", + required: true, + min: 1, + message: "请至少选择一个商品", + trigger: "change", + }, + ], + rangeTime: [ + { + type: "array", + required: true, + message: "请选择活动时间", + trigger: "change", + }, + ], }, options: { disabledDate(date) { @@ -140,78 +157,80 @@ export default { methods: { handleSubmit() { this.$refs.form.validate((valid) => { - if (valid) { - const params = JSON.parse(JSON.stringify(this.form)); - if (this.form.rangeTime[0] === "" || this.form.rangeTime[0] === "") { - this.$Message.error("请选择活动时间"); - return; - } - params.startTime = this.$filters.unixToDate( - this.form.rangeTime[0] / 1000 - ); - params.endTime = this.$filters.unixToDate( - this.form.rangeTime[1] / 1000 - ); - delete params.rangeTime; - let checkResult = true; - if (this.form.promotionGoodsList.length > 0) { - this.form.promotionGoodsList.forEach((res) => { - if (res.stock <= 0 || res.stock > res.quantity) { - checkResult = false; - this.$Message.error("活动库存不能为0且不能超过商品库存"); - return; - } - - if (!regular.money.test(res.settlementPrice)) { - checkResult = false; - this.$Message.error("结算价格金额格式不正确"); - return; - } - if (res.settlementPrice < 0 || res.settlementPrice > res.price) { - checkResult = false; - this.$Message.error("结算价格金额不能为0且不能超过商品价格"); - return; - } - if (!regular.money.test(res.highestPrice)) { - checkResult = false; - this.$Message.error("最高可砍金额格式错误"); - return; - } - if (res.highestPrice <= 0 || res.highestPrice > res.price) { - checkResult = false; - this.$Message.error("最高可砍金额不能为0且不能超过商品价格"); - return; - } - if (!regular.money.test(res.lowestPrice)) { - checkResult = false; - this.$Message.error("最低可砍金额格式错误"); - return; - } - if (res.lowestPrice <= 0 || res.lowestPrice > res.price) { - checkResult = false; - this.$Message.error("最低可砍金额不能为0"); - return; - } - if (parseInt(res.lowestPrice) > parseInt(res.highestPrice)) { - checkResult = false; - this.$Message.error("最低砍价金额不能大于最高砍价金额"); - return; - } - }); - } - - if (!checkResult) { - return; - } - this.submitLoading = true; - saveKanJiaActivityGoods(params).then((res) => { - this.submitLoading = false; - if (res.success) { - this.$Message.success("砍价活动修改成功"); - this.closeCurrentPage(); - } - }); + if (!valid) { + return; } + if (!this.form.promotionGoodsList.length) { + this.$Message.warning("请至少选择一个商品"); + return; + } + + const params = JSON.parse(JSON.stringify(this.form)); + const [start, end] = this.form.rangeTime || []; + const startDate = start instanceof Date ? start : new Date(start); + const endDate = end instanceof Date ? end : new Date(end); + params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000); + params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000); + delete params.rangeTime; + + let checkResult = true; + this.form.promotionGoodsList.forEach((res) => { + if (res.stock <= 0 || res.stock > res.quantity) { + checkResult = false; + this.$Message.error("活动库存不能为0且不能超过商品库存"); + return; + } + + if (!regular.money.test(res.settlementPrice)) { + checkResult = false; + this.$Message.error("结算价格金额格式不正确"); + return; + } + if (res.settlementPrice < 0 || res.settlementPrice > res.price) { + checkResult = false; + this.$Message.error("结算价格金额不能为0且不能超过商品价格"); + return; + } + if (!regular.money.test(res.highestPrice)) { + checkResult = false; + this.$Message.error("最高可砍金额格式错误"); + return; + } + if (res.highestPrice <= 0 || res.highestPrice > res.price) { + checkResult = false; + this.$Message.error("最高可砍金额不能为0且不能超过商品价格"); + return; + } + if (!regular.money.test(res.lowestPrice)) { + checkResult = false; + this.$Message.error("最低可砍金额格式错误"); + return; + } + if (res.lowestPrice <= 0 || res.lowestPrice > res.price) { + checkResult = false; + this.$Message.error("最低可砍金额不能为0"); + return; + } + if (parseInt(res.lowestPrice) > parseInt(res.highestPrice)) { + checkResult = false; + this.$Message.error("最低砍价金额不能大于最高砍价金额"); + return; + } + }); + + if (!checkResult) { + return; + } + this.submitLoading = true; + saveKanJiaActivityGoods(params).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success( + this.modalType === 1 ? "砍价活动修改成功" : "砍价活动添加成功" + ); + this.closeCurrentPage(); + } + }); }); }, closeCurrentPage() { @@ -232,6 +251,15 @@ export default { }, delGoods(index) { this.form.promotionGoodsList.splice(index, 1); + this.touchPromotionGoodsValidate(); + }, + touchPromotionGoodsValidate() { + this.$nextTick(() => { + const form = this.$refs.form; + if (form && typeof form.validateField === "function") { + form.validateField("promotionGoodsList", () => {}); + } + }); }, selectedGoodsData(item) { let list = []; @@ -252,6 +280,7 @@ export default { }); }); this.form.promotionGoodsList = list; + this.touchPromotionGoodsValidate(); }, }, }; diff --git a/manager/src/views/promotions/kanjia/kanjia-activity-edit-goods.vue b/manager/src/views/promotions/kanjia/kanjia-activity-edit-goods.vue index 081ee760..43ece4f4 100644 --- a/manager/src/views/promotions/kanjia/kanjia-activity-edit-goods.vue +++ b/manager/src/views/promotions/kanjia/kanjia-activity-edit-goods.vue @@ -62,17 +62,16 @@ style="width: 260px" /> - +
@@ -154,9 +153,21 @@ export default { { required: true, message: "请输入最高可砍金额" }, { validator: checkHighestPrice }, ], - rangeTime: [{ required: true, message: "请选择活动时间" }], + rangeTime: [ + { + type: "array", + required: true, + message: "请选择活动时间", + trigger: "change", + }, + ], stock: [{ required: true, message: "请输入活动库存" }], }, + options: { + disabledDate(date) { + return date && date.valueOf() < Date.now() - 86400000; + }, + }, }; }, async mounted() { @@ -166,9 +177,6 @@ export default { } }, methods: { - disabledDate(date) { - return date && date.getTime() < Date.now() - 86400000; - }, getKanJiaActivityGoods() { getKanJiaActivityGoodsById(this.id).then((res) => { this.form = res.result; @@ -177,58 +185,62 @@ export default { }, handleSubmit() { this.$refs.form.validate((valid) => { - if (valid) { - const params = JSON.parse(JSON.stringify(this.form)); - if (!this.form.rangeTime || this.form.rangeTime.length !== 2) { - this.$Message.error("请选择活动时间"); - return; - } - params.startTime = this.form.rangeTime[0]; - params.endTime = this.form.rangeTime[1]; - delete params.rangeTime; - - if (params.stock <= 0 || params.stock > params.goodsSku.quantity) { - this.$Message.error("活动库存不能为0且不能超过商品库存"); - return; - } - if (!regular.money.test(params.settlementPrice)) { - this.$Message.error("结算价格金额格式不正确"); - return; - } - if (params.settlementPrice < 0 || params.settlementPrice > params.price) { - this.$Message.error("结算价格金额不能为0且不能超过商品价格"); - return; - } - if (!regular.money.test(params.highestPrice)) { - this.$Message.error("最高可砍金额格式错误"); - return; - } - if (params.highestPrice <= 0 || params.highestPrice > params.price) { - this.$Message.error("最高可砍金额不能为0且不能超过商品价格"); - return; - } - if (!regular.money.test(params.lowestPrice)) { - this.$Message.error("最低可砍金额格式错误"); - return; - } - if (params.lowestPrice <= 0 || params.lowestPrice > params.price) { - this.$Message.error("最低可砍金额不能为0"); - return; - } - if (params.lowestPrice > params.highestPrice) { - this.$Message.error("最低砍价金额不能大于最高砍价金额"); - return; - } - - this.submitLoading = true; - editKanJiaActivityGoods(params).then((res) => { - this.submitLoading = false; - if (res.success) { - this.$Message.success("砍价活动修改成功"); - this.closeCurrentPage(); - } - }); + if (!valid) { + return; } + const params = JSON.parse(JSON.stringify(this.form)); + const [start, end] = this.form.rangeTime || []; + if (!start || !end) { + this.$Message.error("请选择活动时间"); + return; + } + const startDate = start instanceof Date ? start : new Date(start); + const endDate = end instanceof Date ? end : new Date(end); + params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000); + params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000); + delete params.rangeTime; + + if (params.stock <= 0 || params.stock > params.goodsSku.quantity) { + this.$Message.error("活动库存不能为0且不能超过商品库存"); + return; + } + if (!regular.money.test(params.settlementPrice)) { + this.$Message.error("结算价格金额格式不正确"); + return; + } + if (params.settlementPrice < 0 || params.settlementPrice > params.price) { + this.$Message.error("结算价格金额不能为0且不能超过商品价格"); + return; + } + if (!regular.money.test(params.highestPrice)) { + this.$Message.error("最高可砍金额格式错误"); + return; + } + if (params.highestPrice <= 0 || params.highestPrice > params.price) { + this.$Message.error("最高可砍金额不能为0且不能超过商品价格"); + return; + } + if (!regular.money.test(params.lowestPrice)) { + this.$Message.error("最低可砍金额格式错误"); + return; + } + if (params.lowestPrice <= 0 || params.lowestPrice > params.price) { + this.$Message.error("最低可砍金额不能为0"); + return; + } + if (params.lowestPrice > params.highestPrice) { + this.$Message.error("最低砍价金额不能大于最高砍价金额"); + return; + } + + this.submitLoading = true; + editKanJiaActivityGoods(params).then((res) => { + this.submitLoading = false; + if (res.success) { + this.$Message.success("砍价活动修改成功"); + this.closeCurrentPage(); + } + }); }); }, closeCurrentPage() { @@ -252,4 +264,12 @@ h4 { line-height: 40px; text-align: left; } + +.kanjia-activity-time-form-item { + :deep(.el-date-editor) { + width: 360px !important; + max-width: 360px; + flex-grow: 0; + } +} diff --git a/manager/src/views/seller/shop/shopOperation.vue b/manager/src/views/seller/shop/shopOperation.vue index 17b697f9..3b3737a1 100644 --- a/manager/src/views/seller/shop/shopOperation.vue +++ b/manager/src/views/seller/shop/shopOperation.vue @@ -370,8 +370,9 @@ :show-close="true" > @@ -566,7 +567,6 @@ export default { //选择会员 selectMember() { - this.$refs["memberLayout"].selectedMember = true; this.memberModalFlag = true; }, diff --git a/manager/src/views/sys/slider/slider.vue b/manager/src/views/sys/slider/slider.vue index 3d1b5a62..85c80eec 100644 --- a/manager/src/views/sys/slider/slider.vue +++ b/manager/src/views/sys/slider/slider.vue @@ -44,7 +44,7 @@ diff --git a/manager/src/views/sys/user-manage/userManage.vue b/manager/src/views/sys/user-manage/userManage.vue index 0333c148..5910648e 100644 --- a/manager/src/views/sys/user-manage/userManage.vue +++ b/manager/src/views/sys/user-manage/userManage.vue @@ -104,7 +104,7 @@ - + @@ -178,9 +178,12 @@ export default { modalTitle: "", form: { username: "", + nickName: "", + password: "", mobile: "", email: "", - sex: "", + avatar: "", + description: "", roles: [], departmentId: 0, departmentTitle: "", @@ -285,18 +288,30 @@ export default { this.$refs.form.validate((valid) => { if (valid) { if (this.modalType == 0) { - const params = JSON.parse(JSON.stringify(this.form)); - delete params.id; - delete params.status; - if (params.password == "" || params.password == undefined) { + if (this.form.password == "" || this.form.password == undefined) { this.errorPass = "密码不能为空"; return; } - if (params.password.length < 6) { + if (this.form.password.length < 6) { this.errorPass = "密码长度不得少于6位"; return; } - params.password = this.md5(params.password); + if (Array.isArray(this.form.roles) && this.form.roles.length > 9) { + ElMessage.warning("角色最多选择9个"); + return; + } + const params = { + username: this.form.username, + password: this.form.password, + nickName: this.form.nickName, + mobile: this.form.mobile, + email: this.form.email, + avatar: this.form.avatar, + description: this.form.description, + departmentId: this.form.departmentId, + roles: this.form.roles, + }; + this.errorPass = ""; this.submitLoading = true; addUser(params).then((res) => { this.submitLoading = false; @@ -325,9 +340,12 @@ export default { this.modalTitle = "添加用户"; this.form = { username: "", + nickName: "", + password: "", mobile: "", email: "", - sex: "", + avatar: "", + description: "", roles: [], departmentId: 0, departmentTitle: "", diff --git a/seller/src/api/goods.js b/seller/src/api/goods.js index 8ce3d321..77e3de27 100644 --- a/seller/src/api/goods.js +++ b/seller/src/api/goods.js @@ -67,11 +67,6 @@ export const getCategoryBrandListData = (category_id, params) => { export const saveCategoryBrand = (category_id, params) => { return postRequest(`/category/brand/${category_id}`, params); }; -//保存获取关联规格 -export const saveCategorySpec = (category_id, params) => { - return postRequest(`/goods/categorySpec/${category_id}`, params); -}; - //获取所有可用品牌 export const getBrandListData = params => { return getRequest("/goods/brand/all", params); @@ -115,10 +110,6 @@ export const getSpecListData = params => { export const insertOrUpdateSpec = params => { return postRequest("/goods/spec/edit", params); }; -//根据分类id获取关联规格 -export const getCategorySpecListData = (category_id, params) => { - return getRequest(`/goods/categorySpec/${category_id}`, params); -}; //删除gUI个 export const delSpec = (id, params) => { return deleteRequest(`/goods/spec/del/${id}`, params); @@ -335,11 +326,6 @@ export const getCategoryParamsListDataSeller = (id, params) => { return getRequest(`/goods/categoryParameters/${id}`, params); }; -//保存获取关联规格 -export const getGoodsSpecInfoSeller = (category_id) => { - return getRequest(`/goods/spec/${category_id}`); -}; - //批量设置运费模板 export const batchShipTemplate = params => { return putRequest(`/goods/goods/freight`, params); diff --git a/seller/src/views/goods/goods-seller/goodsOperationSec.vue b/seller/src/views/goods/goods-seller/goodsOperationSec.vue index 31eb823d..46527058 100644 --- a/seller/src/views/goods/goods-seller/goodsOperationSec.vue +++ b/seller/src/views/goods/goods-seller/goodsOperationSec.vue @@ -1211,8 +1211,6 @@ export default { this.baseInfoForm.weight = response.result.skuList[0].weight; } - this.Get_SkuInfoByCategory(this.categoryId); - this.renderGoodsDetailSku(response.result.skuList); /** 查询品牌列表 */ @@ -2000,20 +1998,6 @@ export default { return generateCombinations(0, []); }, - /** 根据分类id获取系统设置规格信息*/ - Get_SkuInfoByCategory(categoryId) { - if (categoryId) { - API_GOODS.getGoodsSpecInfoSeller(categoryId).then((res) => { - if (res.length) { - res.forEach((e) => { - this.skuData.push(e.specName); - const vals = e.specValue ? e.specValue.split(",") : []; - this.skuVals.push(Array.from(new Set(vals))); - }); - } - }); - } - }, // 判断相同数组的值 scalarArrayEquals(array1, array2) { return ( @@ -2307,8 +2291,6 @@ export default { this.GET_GoodsParams(); /** 查询品牌列表 */ this.getGoodsBrandList(); - /** 查询分类绑定的规格信息 */ - this.Get_SkuInfoByCategory(this.categoryId); // 获取商品单位 this.GET_GoodsUnit(); // 获取当前店铺分类