Commit 9c3b08c6 by 张立顺

feat 功能联调

1 parent 92a16697
......@@ -20,16 +20,22 @@ export function getProductManageListPageSku(data) {
return request(data);
}
// 新增产品
// 新增产品:所有参数转 json 字符串赋值到 requestJson
export function addProductManage(data) {
data.method = `${path}productManager.add`;
return request(data, "post");
const requestData = {
method: `${path}productManager.add`,
requestJson: JSON.stringify(data),
};
return request(requestData, "post");
}
// 编辑产品
// 编辑产品:所有参数转 json 字符串赋值到 requestJson
export function UpdateProductManage(data) {
data.method = `${path}productManager.update`;
return request(data, "post");
const requestData = {
method: `${path}productManager.update`,
requestJson: JSON.stringify(data),
};
return request(requestData, "post");
}
// 获取权益/升级类目服务项目
......@@ -85,3 +91,9 @@ export function getBaseGoodsOperationLogPage(data) {
data.method = "dj.api.basegoods.get.goods.operationLog.page";
return request(data);
}
// 删除 SKU(升级商品)
export function upgradeGoodsDelete(data) {
data.method = "dj.smartcarlife.api.upgradegoods.delete";
return request(data, "post");
}
......@@ -360,10 +360,22 @@
v-if="
item.type === 'photo' ||
item.type === 'video' ||
item.type === 'descList'
item.type === 'descList' ||
item.type === 'radio'
"
>
<template v-if="item.type === 'photo'">
<template v-if="item.type === 'radio'">
<el-radio-group v-model="formData[item.name]" :disabled="item.isDisabled || pageData.pageDisabled" @change="item.name === 'accessoryType' && handleAccessoryTypeChange()">
<el-radio
v-for="(opt, optIdx) in (item.radioOptions || [])"
:key="optIdx"
:label="opt.value"
>
{{ opt.label }}
</el-radio>
</el-radio-group>
</template>
<template v-else-if="item.type === 'photo'">
<p class="photo-top-tips">
{{ item.topTips }}
</p>
......@@ -694,6 +706,19 @@ export default {
],
convertedValue: [
{ required: true, message: "请输入比例换算", trigger: "change" }
],
accessoryType: [
{
validator: (rule, value, cb) => {
// 权益/延保类目配件性质不必填
if (this.equitySceneType?.includes(this.formData?.goodsType) || this.extendedPosiType?.includes(this.formData?.goodsType))
return cb();
if (!value && value !== 0)
return cb(new Error("请选择配件性质"));
cb();
},
trigger: "change"
}
]
},
copyMembranesFormBlock: [
......@@ -787,6 +812,9 @@ export default {
handler(newVal) {
if (newVal) {
this.formData = deepClone(this.originData)
if (newVal.accessoryType != null) {
this.$nextTick(() => this.handleAccessoryTypeChange())
}
}
},
deep: true
......@@ -1147,6 +1175,9 @@ export default {
const fileType = fileName.substr(fileName.lastIndexOf(".") + 1)
this.GlOssApi.multipartUpload(file, success, fail, bucketName, fileType)
},
handleAccessoryTypeChange() {
this.$emit("accessoryTypeChange", this.formData.accessoryType)
},
// 图片删除
handleImgDelete(targetItem, subIndex = -1) {
Array.isArray(this.formData[targetItem.name])
......
......@@ -9,6 +9,7 @@
:form-list="editForm"
:form-ref="proFormRef"
:is-product="false"
@accessoryTypeChange="handleAccessoryTypeChange"
@handleAddBrandSupplyConfirm="handleAddBrandSupplyConfirm"
@handleEditBrandSupplyConfirm="handleEditBrandSupplyConfirm">
</productForm>
......@@ -44,7 +45,8 @@ export default {
positionIds: [],
carTypeList: [1, 2, 3, 4],
goodsPositionList: [],
goodsSource: 0
goodsSource: 0,
accessoryType: ''
},
proFormRef: 'pro',
editForm: [{
......@@ -115,11 +117,20 @@ export default {
type: 'video',
tips: ['注:作为商品详情页顶部展示,格式建议mp4,大小不超过20M'],
maxPhotoNum: 1
}, {
}, {
name: 'goodsDescList',
label: '详情描述',
type: 'descList',
maxlength: 256
}, {
name: 'accessoryType',
label: '配件性质',
type: 'radio',
isRequired: true,
radioOptions: [
{ value: 1, label: '原厂件' },
{ value: 2, label: '品牌件' }
]
}]
}],
baseData: {
......@@ -266,6 +277,9 @@ export default {
editBrandSupplyMerchant(data).then(res => {
this.getBrandSupplyList(data.partitionFlag)
})
},
handleAccessoryTypeChange(val) {
this.$emit('accessoryTypeChange', val)
}
}
}
......
......@@ -133,7 +133,7 @@
<script>
import { baseGoodsDelete } from "@api/commodity";
import { getAllCategory, getBrandSupplyMerchant } from "@api/product";
import { getProductManageListPageLimit, getProductManageListPageSku, productImport } from "@api/productManage";
import { getProductManageListPageLimit, getProductManageListPageSku, productImport, upgradeGoodsDelete } from "@api/productManage";
import { mapActions, mapMutations, mapState } from "vuex";
import { BaseData } from "@/common/constants";
import { Util } from "@/common/util";
......@@ -504,11 +504,15 @@ export default {
resolve();
});
},
// SKU 行编辑/查看需传 baseGoodsId 作为 id,与 SPU 一样跳转产品编辑页
// SKU 行编辑/查看需传 baseGoodsId 作为 id,与 SPU 一样跳转产品编辑页;同时保留 upgradeGoodsId/commodityCode 供详情抽屉使用
getAuthButtonData(row) {
// SKU 行(无 upgradeGoodsList)用 baseGoodsId 作为 id 跳转
// SKU 行(无 upgradeGoodsList)用 baseGoodsId 作为 id 跳转,保留 skuId 供详情用
if (!Object.keys(row || {}).includes("upgradeGoodsList") && row.baseGoodsId) {
return { ...row, id: row.baseGoodsId };
return {
...row,
id: row.baseGoodsId,
skuId: row.id,
};
}
return row;
},
......@@ -810,37 +814,49 @@ export default {
});
},
handleDelete(row) {
let html = "需下架商品才可以删除!";
row.status == 1 || row.status == 2
? this.$confirm(html, "提示", {
confirmButtonText: "确定",
showCancelButton: false,
type: "warning",
}).then(() => {
})
: this.$confirm("删除后不可恢复,是否删除?", "提示", {
confirmButtonText: "确定",
type: "warning",
}).then(() => {
baseGoodsDelete({ baseGoodsId: row.id }).then((res) => {
this.notice.okTips();
this.$refs.productManageTable.refreshTable();
});
}).catch((err) => {
console.log(err);
});
// 与 handleCommodityDetail 一致:有 upgradeGoodsList 为 SPU 行,否则为 SKU 行
const isSpuRow = row.upgradeGoodsList && row.upgradeGoodsList.length > 0;
const skuConfirmMsg = "确认删除此sku信息吗?删除后将无法恢复。";
const spuConfirmMsg = "确认删除此spu信息吗?删除将会连同下级sku一并删除,删除后将无法恢复。";
if (row.status === 1 || row.status === 2) {
this.$confirm("需下架商品才可以删除!", "提示", {
confirmButtonText: "确定",
showCancelButton: false,
type: "warning",
}).then(() => {});
return;
}
this.$confirm(isSpuRow ? spuConfirmMsg : skuConfirmMsg, "提示", {
confirmButtonText: "确定",
type: "warning",
}).then(() => {
const req = isSpuRow
? baseGoodsDelete({ baseGoodsId: row.id })
: upgradeGoodsDelete({ id: row.skuId });
req.then((res) => {
this.notice.okTips();
this.$refs.productManageTable.refreshTable();
});
}).catch((err) => {
if (err !== "cancel")
console.log(err);
});
},
handleCommodityDetail(row) {
console.log(row);
const id = row.baseGoodsId ?? row.id;
this.commodityDetailInfoId = id;
this.commodityDetailInfoSkuId = row.commodityCode;
// 根据行类型判断:有 upgradeGoodsList 为 SPU 行用 SPU 抽屉,否则为 SKU 行用 SKU 分页抽屉
this.commodityDetailInfoId = "";
this.commodityDetailInfoSkuId = "";
// 根据行类型判断:有 upgradeGoodsList 为 SPU 行用 SPU 抽屉,否则为 SKU 行用 SKU 抽屉
const isSpuRow = row.upgradeGoodsList && row.upgradeGoodsList.length > 0;
if (isSpuRow) {
this.commodityDetailInfoId = row.baseGoodsId || row.id;
this.drawerDetailVisible = true;
this.drawerSkuDetailVisible = false;
} else {
this.commodityDetailInfoId = row.baseGoodsId || row.id;
// SKU 行:用 skuId(getAuthButtonData 保留)或 upgradeGoodsId/commodityCode,避免被 id 覆盖
this.commodityDetailInfoSkuId = row.skuId;
this.drawerSkuDetailVisible = true;
this.drawerDetailVisible = false;
}
......
......@@ -5,7 +5,8 @@
<!-- SPU -->
<SourceMaterial ref="source-material-form"
:add-or-edit="addOrEdit"
:form-data="productFormData" />
:form-data="productFormData"
@accessoryTypeChange="handleAccessoryTypeChange" />
<!-- SKU -->
<Specifications ref="specifications-form" @checkGoodsInfo="checkGoodsInfo"></Specifications>
<div style="margin-top: 40px;text-align: center;">
......@@ -147,7 +148,15 @@ export default {
specificationData: val.specificationData,
specsValueList: val.specificationData?.split(";~;"),
type: val.type,
thirdPartyName: val.thirdPartyName,
thirdPartyCode: val.thirdPartyCode,
priceUnitType: val.priceUnitType,
priceUnitName: val.priceUnitName,
purchaseCost: val.purchaseCost,
operationCoefficient: val.operationCoefficient,
operationCost: val.operationCost,
applicableArea: val.applicableArea,
accessoryType: val.accessoryType,
upgradePrice: val.upgradePrice,
warningValue: val.warningValue,
warningValueMax: val.warningValueMax,
......@@ -164,6 +173,9 @@ export default {
oldwarningValue: val.warningValue,
oldwarningValueMax: val.warningValueMax,
oldwarrantyPeriod: val.warrantyPeriod,
oldpurchaseCost: val.purchaseCost,
oldoperationCoefficient: val.operationCoefficient,
oldoperationCost: val.operationCost,
olddjCost: val.djCost,
selectCarSerise: val?.carTypeConfigList?.map((v) => {
return {
......@@ -221,6 +233,7 @@ export default {
supplierCode: res.goodsInfo.supplierCode,
merchantGoodsInfos: res?.merchantGoodsInfos,
scrmFlag: res?.goodsInfo?.scrmFlag,
accessoryType: res.goodsInfo?.accessoryType,
};
this.productFormData = deepClone({ ...res.goodsInfo, status: res?.status, oldconvertedValue: res.goodsInfo?.convertedValue, tempGoodsType, secondaryGoodsType: res.goodsInfo.secondaryGoodsType, thirdLevelGoodsType: res.goodsInfo.thirdLevelGoodsType }) || {};
this.setUpdateGoodsInfo(objData);
......@@ -288,6 +301,7 @@ export default {
maxPrice: val.maxPrice,
});
});
const isEquityOrExtend = this.equitySceneType?.includes(productFormData?.goodsType) || this.extendedPosiType?.includes(productFormData?.goodsType);
arr.push({
baseGoodsId: data.baseGoodsId,
goodsCode: data.goodsCode,
......@@ -295,10 +309,18 @@ export default {
specificationData: item.specificationData,
specsValueList: [item.specificationData],
upgradePrice: item.upgradePrice,
warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) ? item.warrantyPeriod : "", // 质保年限 仅膜类
warrantyPeriod: (this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend) ? item.warrantyPeriod : "", // 质保时间 膜类或非权益/延保类
position: productFormData?.goodsType === 1 ? item.position?.join(",") : [], // 部位 太阳膜
type: item.type,
thirdPartyName: item.thirdPartyName,
thirdPartyCode: item.thirdPartyCode,
priceUnitType: item.priceUnitType,
priceUnitName: item.priceUnitName,
purchaseCost: item.purchaseCost,
operationCoefficient: item.operationCoefficient,
operationCost: item.operationCost,
applicableArea: item.applicableArea,
accessoryType: item.accessoryType,
purchasePrice: data?.shoppingMallFlag == 1 ? item.purchasePrice : "", // 采购价 仅上架至采购商城
warningValue: item.warningValue,
warningValueMax: item.warningValueMax,
......@@ -348,16 +370,25 @@ export default {
});
});
if (item.statusFlag != 2) {
const isEquityOrExtend = this.equitySceneType?.includes(productFormData?.goodsType) || this.extendedPosiType?.includes(productFormData?.goodsType);
goodsSpecificationList.push({
baseGoodsId: data.baseGoodsId,
goodsCode: data.goodsCode,
id: item.id,
specificationData,
upgradePrice: item.upgradePrice,
warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) ? item.warrantyPeriod : "", // 质保年限 仅膜类
warrantyPeriod: (this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend) ? item.warrantyPeriod : "", // 质保时间 膜类或非权益/延保类
position: (productFormData?.goodsType === 1 || (this.extendedPosiType.includes(productFormData?.goodsType) && !this.baseConfig.supplierCode.includes(`${productFormData.supplierCode}`))) ? item.position?.join(",") : [], // 部位 太阳膜/延保类(供应方为第三方)
type: item.type,
thirdPartyName: item.thirdPartyName,
thirdPartyCode: item.thirdPartyCode,
priceUnitType: item.priceUnitType,
priceUnitName: item.priceUnitName,
purchaseCost: item.purchaseCost,
operationCoefficient: item.operationCoefficient,
operationCost: item.operationCost,
applicableArea: item.applicableArea,
accessoryType: item.accessoryType,
purchasePrice: data?.shoppingMallFlag == 1 ? item.purchasePrice : "", // 采购价 仅上架至采购商城
warningValue: item.warningValue,
warningValueMax: item.warningValueMax,
......@@ -433,9 +464,25 @@ export default {
filterEmpty(data) {
return Array.isArray(data) ? data.length <= 0 : (data ?? "") === "";
},
// SPU 配件性质变更时同步到所有 SKU 行
handleAccessoryTypeChange(val) {
this.setUpdateGoodsInfo({ accessoryType: val });
const singleList = this.goodsInfoData.goodsSpecificationSingleList || [];
const multiList = this.goodsInfoData.goodsSpecificationList || [];
singleList.forEach((item) => {
item.accessoryType = val;
});
multiList.forEach((item) => {
item.accessoryType = val;
});
},
checkGoodsInfo(callback) {
// 校验SPU
this.$refs["source-material-form"].$refs.d2GoodsProductForm.handleUp((productFormData) => {
// 提交前同步 SPU 配件性质到所有 SKU 行
if (productFormData?.accessoryType != null) {
this.handleAccessoryTypeChange(productFormData.accessoryType);
}
this.checkGoods(() => {
callback(productFormData);
});
......@@ -467,6 +514,7 @@ export default {
});
return document.getElementById("specificationDetailList").scrollIntoView();
}
const isEquityOrExtend = this.equitySceneType.includes(this.goodsInfoData.goodsType) || this.extendedPosiType.includes(this.goodsInfoData.goodsType);
const arr = confirmShopData.map((item) => {
// 禁用的无需校验
if (item.statusFlag == 2)
......@@ -483,21 +531,33 @@ export default {
if (this.membraneTypeList.includes(this.goodsInfoData.goodsType)) { // 膜类
item.warrantyPeriodEmpty = true;
}
// 非权益/延保类:商品编码、计价单位、采购成本、质保时间必填;配件性质从 SPU 同步,不单独校验;原厂件时运营系数/运营成本/适用区域不必填
if (!isEquityOrExtend) {
item.typeEmpty = true;
item.priceUnitTypeEmpty = true;
item.purchaseCostEmpty = true;
item.warrantyPeriodEmpty = true;
if (item.accessoryType !== 1) {
item.operationCoefficientEmpty = true;
item.operationCostEmpty = true;
item.applicableAreaEmpty = true;
}
}
return item;
});
this.goodsInfoData.goodsSpecificationList = arr;
this.goodsInfoData.goodsSpecificationSingleList = arr;
let specialList = [];
if (this.goodsInfoData.goodsType == 1) { // 太阳膜 位置 质保 采购价 必填
specialList = ["position", "purchasePrice", "warrantyPeriod"];
if (this.goodsInfoData.goodsType == 1) { // 太阳膜 位置 质保 采购价 必填 + 新增字段(配件性质从 SPU 同步)
specialList = ["position", "purchasePrice", "warrantyPeriod", "type", "priceUnitType", "purchaseCost"];
} else if (this.extendedPosiType.includes(this.goodsInfoData.goodsType)) { // 延保类 采购价必填
specialList = ["purchasePrice"];
} else if (this.membraneTypeList.includes(this.goodsInfoData.goodsType)) { // 膜类 质保必填 采购价必填
specialList = ["purchasePrice", "warrantyPeriod"];
} else if (this.membraneTypeList.includes(this.goodsInfoData.goodsType)) { // 膜类 质保必填 采购价必填 + 新增字段
specialList = ["purchasePrice", "warrantyPeriod", "type", "priceUnitType", "purchaseCost"];
} else if (this.equitySceneType.includes(this.goodsInfoData.goodsType)) { // 权益服务 服务项目必填
specialList = !this.baseConfig.supplierCode.includes(`${this.goodsInfoData.supplierCode}`) ? ["serviceItemArr", "djCost", "purchasePrice"] : ["purchasePrice"];
} else { // 其余商品类型 采购价必填
specialList = ["purchasePrice"];
} else { // 其余商品类型 采购价必填 + 新增必填字段
specialList = ["purchasePrice", "type", "priceUnitType", "purchaseCost", "warrantyPeriod"];
}
// 仅分发至单店时,隐藏采购价/卷,无需填写
if (this.goodsInfoData.shoppingMallFlag == "0" && specialList.includes("purchasePrice"))
......@@ -510,11 +570,19 @@ export default {
if (this.goodsInfoData.specificationType == "2")
item.specificationData = item.specsValueList.join(";~;");
try {
requiredList.map((it) => {
requiredList.forEach((it) => {
if (this.filterEmpty(item[it])) {
throw it;
}
});
// 非权益/延保类 且 配件性质为品牌件(2)时,运营系数/运营成本/适用区域必填
if (!isEquityOrExtend && item.accessoryType === 2) {
["operationCoefficient", "operationCost", "applicableArea"].forEach((it) => {
if (this.filterEmpty(item[it])) {
throw it;
}
});
}
} catch (error) {
return document.getElementById("specificationDetailList").scrollIntoView();
}
......
......@@ -342,6 +342,26 @@
</template>
</el-table-column>
<el-table-column align="center"
label="领单确认时间"
prop="subOrderList"
width="160">
<template #default="scope">
<span v-for="(item, index) in scope.row.subOrderList" :key="index">
<p>{{ item.subElectronicDateStr || "-" }}</p>
</span>
</template>
</el-table-column>
<el-table-column align="center"
label="完成施工时间"
prop="subOrderList"
width="160">
<template #default="scope">
<span v-for="(item, index) in scope.row.subOrderList" :key="index">
<p>{{ item.completedTimeStr || "-" }}</p>
</span>
</template>
</el-table-column>
<el-table-column align="center"
label="技师"
prop="subOrderList"
width="200">
......@@ -888,6 +908,13 @@ export default {
pickerOptions: "rangePickerOptions",
},
{
label: "完成施工时间",
name: "completedTime",
type: "datePicker",
isClear: true,
pickerOptions: "rangePickerOptions",
},
{
label: "订单来源",
name: "sourceList",
type: "select",
......@@ -1013,12 +1040,12 @@ export default {
merchantId: "",
orderTime: "",
paySuccessDate: "",
completedTime: "",
constructionFlag: "",
sourceList: "",
channelType: "",
businessModel: "",
subShopMerchantId: "",
paySuccessDate: "",
provinceId: "",
invoiceStatus: "",
salesType: "",
......@@ -1423,6 +1450,7 @@ export default {
merchantId: "",
orderTime: "",
paySuccessDate: "",
completedTime: "",
constructionFlag: "",
channelType: "",
businessModel: "",
......@@ -1597,6 +1625,15 @@ export default {
= Util.dateFormate(form.paySuccessDate[1], "YYYY-MM-DD") + " 23:59:59";
}
if (form.completedTime && form.completedTime.length) {
params.completionBeginTime = Util.dateFormate(
form.completedTime[0],
"YYYY-MM-DD HH:mm:ss",
);
params.completionEndTime
= Util.dateFormate(form.completedTime[1], "YYYY-MM-DD") + " 23:59:59";
}
if (params.sourceList != "") {
// 处理d2-search 下拉选不支持绑定数组的问题
params.sourceList
......@@ -1638,6 +1675,12 @@ export default {
= this.positionTypeList?.filter(
subItem => val?.upgradeGoodsPosition == subItem.position,
)[0]?.confName || "-";
val.subElectronicDateStr = val.subElectronicDate
? Util.dateFormate(val.subElectronicDate, "YYYY-MM-DD HH:mm:ss")
: "";
val.completedTimeStr = val.completedTime
? Util.dateFormate(val.completedTime, "YYYY-MM-DD HH:mm:ss")
: "";
});
return item;
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!