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"
})
}
//保存获取关联规格
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)

View File

@@ -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) => {

View File

@@ -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 => {

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

@@ -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) {

View File

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

View File

@@ -68,10 +68,10 @@
v-model="form.rangeTime"
type="datetimerange"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
start-placeholder="开始时间"
end-placeholder="结束时间"
:disabled-date="disabledDate"
placeholder="请选择"
:disabled-date="options.disabledDate"
/>
</el-form-item>
<div>
@@ -153,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() {
@@ -165,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;
@@ -176,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() {

View File

@@ -104,7 +104,7 @@
<el-form-item label="用户名" prop="username">
<el-input v-model="form.username" autocomplete="off" />
</el-form-item>
<el-form-item label="昵称" prop="username">
<el-form-item label="昵称" prop="nickName">
<el-input v-model="form.nickName" autocomplete="off" />
</el-form-item>
<el-form-item v-if="modalType == 0" label="密码" prop="password" :error="errorPass">
@@ -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: "",

View File

@@ -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);

View File

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