Merge branch 'vue3'

This commit is contained in:
田香琪
2026-07-16 16:56:45 +08:00
10 changed files with 170 additions and 185 deletions

View File

@@ -52,19 +52,11 @@ export const saveParameterCategory = (parameter_id, categoryIds) => {
"Content-Type": "application/json" "Content-Type": "application/json"
}) })
} }
//保存获取关联规格
export const saveCategorySpec = (category_id, params) => {
return postRequest(`/goods/categorySpec/${category_id}`, params)
}
//获取所有可用品牌 //获取所有可用品牌
export const getBrandListData = (params) => { export const getBrandListData = (params) => {
return getRequest('/goods/brand/all', params) return getRequest('/goods/brand/all', params)
} }
// 获取所有可用规格
export const getSpecificationList = (params) => {
return getRequest('/goods/spec/all', params)
}
//获取分类列表数据 //获取分类列表数据
export const getAllCategoryList = (parent_id) => { export const getAllCategoryList = (parent_id) => {
@@ -93,11 +85,6 @@ export const disableCategory = (id, type) => {
return putRequest(`/goods/category/disable/${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) => { export const getGoodsCategory = (parent_id) => {
return getRequest(`/goods/category/${parent_id}/all-children`) return getRequest(`/goods/category/${parent_id}/all-children`)
@@ -221,12 +208,6 @@ export const deleteParamsGroup = (id, params) => {
return deleteRequest(`/goods/categoryParameters/${id}`, params) return deleteRequest(`/goods/categoryParameters/${id}`, params)
} }
//保存获取关联规格
export const getGoodsSpecInfo = (category_id, params) => {
return getRequest(`/goods/categorySpec/goods/${category_id}`, params)
}
//获取sku列表 //获取sku列表
export const getSkuPage = (params) => { export const getSkuPage = (params) => {
return getRequest(`/goodsSku/getByPage`, params) return getRequest(`/goodsSku/getByPage`, params)

View File

@@ -120,9 +120,37 @@ export const getAllUserData = (params) => {
return getRequest("/passport/user/getAll", 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) => { 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) => { export const editUser = (params) => {

View File

@@ -14,11 +14,28 @@ export const getLogisticsPage = params => {
}; };
// 删除 // 删除
export const delLogistics = id => { 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 => { 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查询详情 // 通过id查询详情
export const getLogisticsDetail = id => { export const getLogisticsDetail = id => {

View File

@@ -116,28 +116,6 @@
<el-button type="primary" :loading="submitLoading" @click="saveCategoryBrand">提交</el-button> <el-button type="primary" :loading="submitLoading" @click="saveCategoryBrand">提交</el-button>
</template> </template>
</el-dialog> </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> </el-card>
</div> </div>
</template> </template>
@@ -148,12 +126,9 @@ import {
disableCategory, disableCategory,
getBrandListData, getBrandListData,
getCategoryBrandListData, getCategoryBrandListData,
getCategorySpecListData,
getCategoryTree, getCategoryTree,
getSpecificationList,
insertCategory, insertCategory,
saveCategoryBrand, saveCategoryBrand,
saveCategorySpec,
updateCategory, updateCategory,
} from "@/api/goods"; } from "@/api/goods";
import uploadPicInput from "@/components/lili/upload-pic-input"; import uploadPicInput from "@/components/lili/upload-pic-input";
@@ -171,18 +146,14 @@ export default {
categoryList: [], categoryList: [],
loading: false, loading: false,
brands: [], brands: [],
specifications: [],
categoryId: "", categoryId: "",
categorySpecs: [],
modalType: 0, modalType: 0,
modalVisible: false, modalVisible: false,
modalBrandVisible: false, modalBrandVisible: false,
modalSpecVisible: false,
modalTitle: "", modalTitle: "",
showParent: false, showParent: false,
parentTitle: "", parentTitle: "",
modalBrandTitle: "", modalBrandTitle: "",
modalSpecTitle: "",
formAdd: { formAdd: {
parentId: "", parentId: "",
name: "", name: "",
@@ -196,9 +167,6 @@ export default {
categoryBrands: [], categoryBrands: [],
}, },
brandWay: [], brandWay: [],
specForm: {
categorySpecs: [],
},
formValidate: { formValidate: {
commissionRate: [regular.REQUIRED, regular.INTEGER], commissionRate: [regular.REQUIRED, regular.INTEGER],
name: [regular.REQUIRED, regular.VARCHAR20], name: [regular.REQUIRED, regular.VARCHAR20],
@@ -245,20 +213,12 @@ export default {
init() { init() {
this.getAllList(); this.getAllList();
this.getBrandList(); this.getBrandList();
this.getSpecList();
}, },
getBrandList() { getBrandList() {
getBrandListData().then((res) => { getBrandListData().then((res) => {
this.brandWay = res; this.brandWay = res;
}); });
}, },
getSpecList() {
getSpecificationList().then((res) => {
if (res.length != 0) {
this.specifications = res.result;
}
});
},
brandOperation(v) { brandOperation(v) {
getCategoryBrandListData(v.id).then((res) => { getCategoryBrandListData(v.id).then((res) => {
this.categoryId = v.id; this.categoryId = v.id;
@@ -267,23 +227,6 @@ export default {
this.modalBrandVisible = true; 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() {
saveCategoryBrand(this.categoryId, this.brandForm).then((res) => { saveCategoryBrand(this.categoryId, this.brandForm).then((res) => {
this.submitLoading = false; this.submitLoading = false;

View File

@@ -137,6 +137,13 @@ export default {
trigger: "blur", trigger: "blur",
}, },
], ],
code: [
{
required: true,
message: "请输入物流公司编码",
trigger: "blur",
},
],
}, },
submitLoading: false, submitLoading: false,
data: [], data: [],
@@ -192,10 +199,12 @@ export default {
if (this.modalTitle === "添加") { if (this.modalTitle === "添加") {
const payload = { const payload = {
...this.form, name: this.form.name,
code: this.form.code,
disabled: this.form.disabled,
standBy: normalizeStandBy(this.form.standBy), standBy: normalizeStandBy(this.form.standBy),
formItems: this.form.formItems,
}; };
delete payload.id;
addLogistics(payload).then((res) => { addLogistics(payload).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {

View File

@@ -200,15 +200,21 @@ export default {
submitLoading: false, submitLoading: false,
selectCouponList: [], selectCouponList: [],
formRule: { formRule: {
promotionName: [{ required: true, message: "活动名称不能为空", trigger: "blur" }], promotionName: [{ required: true, message: "活动名称不能为空" }],
rangeTime: [ rangeTime: [
{ {
type: "array",
required: true, required: true,
message: "请选择活动有效期", validator: (rule, value, callback) => {
if (!value || !Array.isArray(value) || value.length !== 2 || !value[0] || !value[1]) {
callback(new Error("请选择活动有效期"));
} else {
callback();
}
},
trigger: "change", trigger: "change",
}, },
], ],
description: [{ required: true, message: "请输入范围描述" }],
}, },
}; };
}, },
@@ -297,6 +303,7 @@ export default {
this.showCouponSelect = true; this.showCouponSelect = true;
}, },
handleSubmit() { handleSubmit() {
// 自动发券只能全用户发送:如有自动发券且非全用户,提示并强制切换
if ( if (
this.form.couponActivityType === "AUTO_COUPON" && this.form.couponActivityType === "AUTO_COUPON" &&
this.form.activityScope !== "ALL" this.form.activityScope !== "ALL"
@@ -326,15 +333,16 @@ export default {
return; return;
} }
// 统一取时间逻辑
const [start, end] = this.form.rangeTime; const [start, end] = this.form.rangeTime;
const startDate = start instanceof Date ? start : new Date(start); const startDate = start instanceof Date ? start : new Date(start);
const endDate = end instanceof Date ? end : new Date(end); const endDate = end instanceof Date ? end : new Date(end);
this.form.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
this.form.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
const params = JSON.parse(JSON.stringify(this.form)); const params = JSON.parse(JSON.stringify(this.form));
params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
delete params.rangeTime; delete params.rangeTime;
delete params.id; delete params.id;
this.submitLoading = true; this.submitLoading = true;
saveActivityCoupon(params).then((res) => { saveActivityCoupon(params).then((res) => {
this.submitLoading = false; this.submitLoading = false;

View File

@@ -68,10 +68,10 @@
v-model="form.rangeTime" v-model="form.rangeTime"
type="datetimerange" type="datetimerange"
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
start-placeholder="开始时间" start-placeholder="开始时间"
end-placeholder="结束时间" end-placeholder="结束时间"
:disabled-date="disabledDate" placeholder="请选择"
:disabled-date="options.disabledDate"
/> />
</el-form-item> </el-form-item>
<div> <div>
@@ -153,9 +153,21 @@ export default {
{ required: true, message: "请输入最高可砍金额" }, { required: true, message: "请输入最高可砍金额" },
{ validator: checkHighestPrice }, { validator: checkHighestPrice },
], ],
rangeTime: [{ required: true, message: "请选择活动时间" }], rangeTime: [
{
type: "array",
required: true,
message: "请选择活动时间",
trigger: "change",
},
],
stock: [{ required: true, message: "请输入活动库存" }], stock: [{ required: true, message: "请输入活动库存" }],
}, },
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
},
}; };
}, },
async mounted() { async mounted() {
@@ -165,9 +177,6 @@ export default {
} }
}, },
methods: { methods: {
disabledDate(date) {
return date && date.getTime() < Date.now() - 86400000;
},
getKanJiaActivityGoods() { getKanJiaActivityGoods() {
getKanJiaActivityGoodsById(this.id).then((res) => { getKanJiaActivityGoodsById(this.id).then((res) => {
this.form = res.result; this.form = res.result;
@@ -176,14 +185,19 @@ export default {
}, },
handleSubmit() { handleSubmit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (!valid) {
return;
}
const params = JSON.parse(JSON.stringify(this.form)); const params = JSON.parse(JSON.stringify(this.form));
if (!this.form.rangeTime || this.form.rangeTime.length !== 2) { const [start, end] = this.form.rangeTime || [];
if (!start || !end) {
this.$Message.error("请选择活动时间"); this.$Message.error("请选择活动时间");
return; return;
} }
params.startTime = this.form.rangeTime[0]; const startDate = start instanceof Date ? start : new Date(start);
params.endTime = this.form.rangeTime[1]; 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; delete params.rangeTime;
if (params.stock <= 0 || params.stock > params.goodsSku.quantity) { if (params.stock <= 0 || params.stock > params.goodsSku.quantity) {
@@ -227,7 +241,6 @@ export default {
this.closeCurrentPage(); this.closeCurrentPage();
} }
}); });
}
}); });
}, },
closeCurrentPage() { closeCurrentPage() {

View File

@@ -104,7 +104,7 @@
<el-form-item label="用户名" prop="username"> <el-form-item label="用户名" prop="username">
<el-input v-model="form.username" autocomplete="off" /> <el-input v-model="form.username" autocomplete="off" />
</el-form-item> </el-form-item>
<el-form-item label="昵称" prop="username"> <el-form-item label="昵称" prop="nickName">
<el-input v-model="form.nickName" autocomplete="off" /> <el-input v-model="form.nickName" autocomplete="off" />
</el-form-item> </el-form-item>
<el-form-item v-if="modalType == 0" label="密码" prop="password" :error="errorPass"> <el-form-item v-if="modalType == 0" label="密码" prop="password" :error="errorPass">
@@ -178,9 +178,12 @@ export default {
modalTitle: "", modalTitle: "",
form: { form: {
username: "", username: "",
nickName: "",
password: "",
mobile: "", mobile: "",
email: "", email: "",
sex: "", avatar: "",
description: "",
roles: [], roles: [],
departmentId: 0, departmentId: 0,
departmentTitle: "", departmentTitle: "",
@@ -285,18 +288,30 @@ export default {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
if (this.modalType == 0) { if (this.modalType == 0) {
const params = JSON.parse(JSON.stringify(this.form)); if (this.form.password == "" || this.form.password == undefined) {
delete params.id;
delete params.status;
if (params.password == "" || params.password == undefined) {
this.errorPass = "密码不能为空"; this.errorPass = "密码不能为空";
return; return;
} }
if (params.password.length < 6) { if (this.form.password.length < 6) {
this.errorPass = "密码长度不得少于6位"; this.errorPass = "密码长度不得少于6位";
return; 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; this.submitLoading = true;
addUser(params).then((res) => { addUser(params).then((res) => {
this.submitLoading = false; this.submitLoading = false;
@@ -325,9 +340,12 @@ export default {
this.modalTitle = "添加用户"; this.modalTitle = "添加用户";
this.form = { this.form = {
username: "", username: "",
nickName: "",
password: "",
mobile: "", mobile: "",
email: "", email: "",
sex: "", avatar: "",
description: "",
roles: [], roles: [],
departmentId: 0, departmentId: 0,
departmentTitle: "", departmentTitle: "",

View File

@@ -67,11 +67,6 @@ export const getCategoryBrandListData = (category_id, params) => {
export const saveCategoryBrand = (category_id, params) => { export const saveCategoryBrand = (category_id, params) => {
return postRequest(`/category/brand/${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 => { export const getBrandListData = params => {
return getRequest("/goods/brand/all", params); return getRequest("/goods/brand/all", params);
@@ -115,10 +110,6 @@ export const getSpecListData = params => {
export const insertOrUpdateSpec = params => { export const insertOrUpdateSpec = params => {
return postRequest("/goods/spec/edit", params); return postRequest("/goods/spec/edit", params);
}; };
//根据分类id获取关联规格
export const getCategorySpecListData = (category_id, params) => {
return getRequest(`/goods/categorySpec/${category_id}`, params);
};
//删除gUI个 //删除gUI个
export const delSpec = (id, params) => { export const delSpec = (id, params) => {
return deleteRequest(`/goods/spec/del/${id}`, params); return deleteRequest(`/goods/spec/del/${id}`, params);
@@ -335,11 +326,6 @@ export const getCategoryParamsListDataSeller = (id, params) => {
return getRequest(`/goods/categoryParameters/${id}`, params); return getRequest(`/goods/categoryParameters/${id}`, params);
}; };
//保存获取关联规格
export const getGoodsSpecInfoSeller = (category_id) => {
return getRequest(`/goods/spec/${category_id}`);
};
//批量设置运费模板 //批量设置运费模板
export const batchShipTemplate = params => { export const batchShipTemplate = params => {
return putRequest(`/goods/goods/freight`, params); return putRequest(`/goods/goods/freight`, params);

View File

@@ -1219,8 +1219,6 @@ export default {
this.baseInfoForm.weight = response.result.skuList[0].weight; this.baseInfoForm.weight = response.result.skuList[0].weight;
} }
this.Get_SkuInfoByCategory(this.categoryId);
this.renderGoodsDetailSku(response.result.skuList); this.renderGoodsDetailSku(response.result.skuList);
/** 查询品牌列表 */ /** 查询品牌列表 */
@@ -2008,20 +2006,6 @@ export default {
return generateCombinations(0, []); 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) { scalarArrayEquals(array1, array2) {
return ( return (
@@ -2315,8 +2299,6 @@ export default {
this.GET_GoodsParams(); this.GET_GoodsParams();
/** 查询品牌列表 */ /** 查询品牌列表 */
this.getGoodsBrandList(); this.getGoodsBrandList();
/** 查询分类绑定的规格信息 */
this.Get_SkuInfoByCategory(this.categoryId);
// 获取商品单位 // 获取商品单位
this.GET_GoodsUnit(); this.GET_GoodsUnit();
// 获取当前店铺分类 // 获取当前店铺分类