版本迭代

This commit is contained in:
liuye
2023-08-06 16:50:17 +08:00
parent 590fb406cc
commit 5c0b1afe69
63 changed files with 14131 additions and 40 deletions

14
src/utils/date.js Normal file
View File

@@ -0,0 +1,14 @@
export function timestampToTime(timestamp) {
// 时间戳为10位需*1000时间戳为13位不需乘1000
let date = new Date(timestamp);
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
let h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
let m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
let s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
return Y + M + D + h + m + s;
}

96
src/utils/index.js Normal file
View File

@@ -0,0 +1,96 @@
import request from '../api'
const dict = {
url: "/dictionary/queryValsByCodeList",
loading: [],
resolves: [],
getStorage() {
const dicts = JSON.parse(localStorage.getItem('dicts') || null)
return dicts?.data || dicts || [];
},
setUrl(v) {
this.url = v
},
getData(codeList) {
codeList = [codeList].flat().filter(Boolean).toString()
return request.post(this.url, null, {
withoutToken: true, params: {codeList}
}).then(res => res?.data && this.setStorage(res.data))
},
load(...code) {
return new Promise(resolve => {
this.resolves.push(resolve)
if (this.loading.length == 2) {
const [timer, codes] = this.loading;
clearTimeout(timer)
code = Array.from(new Set([codes, code].flat()))
}
const timer = setTimeout(() => {
this.getData(code).then(() => Promise.all(this.resolves.map(e => e())).then(() => this.resolves = []))
}, 500)
this.loading = [timer, code]
})
},
setStorage(data) {
let ds = this.getStorage()
data.map(p => {
if (ds.some(d => d.key == p.key)) {
const index = ds.findIndex(d => d.key == p.key)
ds.splice(index, 1, p)
} else {
ds.push(p)
}
})
localStorage.setItem("dicts", JSON.stringify([ds].flat()))
},
getDict(key) {
let dict = this.getStorage().find(e => e.key == key)
!dict && console.warn("字典%s缺少加载...", key)
return dict ? dict.values : []
},
getValue(key, label) {
let dict = this.getDict(key)
if (dict) {
let item = dict.find(v => v.dictName == label)
return item ? item.dictValue : label
} else return label
},
getLabel(key, value) {
let dict = this.getDict(key)
if (dict) {
let item = dict.find(v => v.dictValue == value)
return item ? item.dictName : value
} else return value
},
getColor(key, value) {
let dict = this.getDict(key)
if (dict) {
let item = dict.find(v => v.dictValue == value)
return item ? item.dictColor : value
} else return value
},
}
const dateUtil = {
timestampToTime(timestamp) {
// 时间戳为10位需*1000时间戳为13位不需乘1000
let date = new Date(timestamp);
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
let h = date.getHours() + ":";
let m = date.getMinutes() + ":";
let s = date.getSeconds();
return Y + M + D + h + m + s;
}
}
export default {
dict,
dateUtil,
}

16
src/utils/install.js Normal file
View File

@@ -0,0 +1,16 @@
import Vue from 'vue' // 引入vue
function changeStr(str){
return str.charAt(0).toUpperCase() + str.slice(1)
}
const requireComponent = require.context('../components', false, /\.vue$/)
requireComponent.keys().forEach(fileName => {
const config = requireComponent(fileName)
const componentName = changeStr(
fileName.replace(/^\.\//, '').replace(/\.\w+$/, '')
)
Vue.component(componentName, config.default || config)
})

131
src/utils/product.js Normal file
View File

@@ -0,0 +1,131 @@
export function transform(leftData) {
let rightData = {};
// 分类
let leftCategory = leftData.categories;
rightData.cat1Id = leftCategory.cat1.catId;
rightData.cat2Id = leftCategory.cat2.catId;
rightData.cat3Id = leftCategory.cat3.catId;
rightData.cat4Id = leftCategory.cat4.catId;
rightData.cat5Id = leftCategory.cat5.catId;
rightData.cat6Id = leftCategory.cat6.catId;
rightData.cat7Id = leftCategory.cat7.catId;
rightData.cat8Id = leftCategory.cat8.catId;
rightData.cat9Id = leftCategory.cat9.catId;
rightData.cat10Id = leftCategory.cat10.catId;
// 普通属性
rightData.productName = leftData.productName;
rightData.materialMultiLanguages = leftData.productLocalExtAttr.materialMultiLanguages;
rightData.productI18nReqs = leftData.productI18nList;
rightData.productPropertyReqs = [];
for (let i = 0; i < leftData.productPropertyList.length; i++) {
rightData.productPropertyReqs.push({
valueUnit: leftData.productPropertyList[i].valueUnit,
propValue: leftData.productPropertyList[i].propValue,
propName: leftData.productPropertyList[i].propName,
refPid: leftData.productPropertyList[i].refPid,
vid: leftData.productPropertyList[i].vid,
controlType: 1,
pid: leftData.productPropertyList[i].pid,
templatePid: leftData.productPropertyList[i].templatePid,
valueExtendInfo: leftData.productPropertyList[i].valueExtendInfo
});
}
// SKC
let rightSkc = [];
let leftSkc = leftData.productSkcList;
let productSpecPropertyReqs = [];
for(let i = 0; i < leftSkc.length; i++) {
let rightSkcItem = {};
rightSkcItem.previewImgUrls = leftSkc[i].previewImgUrls;
rightSkcItem.productSkcCarouselImageI18nReqs = leftSkc[i].productSkcCarouselImageI18nVOList;
rightSkcItem.extCode = leftSkc[i].extCode;
rightSkcItem.mainProductSkuSpecReqs = [
{
"parentSpecId": 0,
"parentSpecName": "",
"specId": 0,
"specName": ""
}
];
rightSkcItem.productSkuReqs = [];
for(let j = 0; j < leftSkc[i].productSkuList.length; j++) {
let leftSkuItem = leftSkc[i].productSkuList[j];
let rightSkuItem = {};
rightSkuItem.thumbUrl = leftSkuItem.thumbUrl;
rightSkuItem.productSkuThumbUrlI18nReqs = leftSkuItem.productSkuThumbUrlI18nVOList;
rightSkuItem.extCode = leftSkuItem.extCode;
rightSkuItem.supplierPrice = leftSkuItem.supplierPrice;
rightSkuItem.currencyType = leftSkuItem.currencyType;
rightSkuItem.productSkuSpecReqs = leftSkuItem.productSkuSpecList;
productSpecPropertyReqs.push({
"parentSpecId": leftSkuItem.productSkuSpecList[0].parentSpecId,
"parentSpecName": leftSkuItem.productSkuSpecList[0].parentSpecName,
"specId": leftSkuItem.productSkuSpecList[0].specId,
"specName": leftSkuItem.productSkuSpecList[0].specName,
"refPid": 0,
"pid": 0,
"templatePid": 0,
"propName": leftSkuItem.productSkuSpecList[0].specName,
"vid": 0,
"propValue": leftSkuItem.productSkuSpecList[0].specName,
"valueUnit": "",
"valueGroupId": 0,
"valueGroupName": "",
"valueExtendInfo": ""
});
rightSkuItem.productSkuId = 0;
rightSkuItem.productSkuWhExtAttrReq = {
"productSkuVolumeReq": leftSkuItem.productSkuWhExtAttr.productSkuVolume,
"productSkuWeightReq": leftSkuItem.productSkuWhExtAttr.productSkuWeight,
"productSkuBarCodeReqs": leftSkuItem.productSkuWhExtAttr.productSkuBarCodes,
"productSkuSensitiveAttrReq": {
"isSensitive": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.isSensitive,
"sensitiveList": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.sensitiveList},
"productSkuSensitiveLimitReq": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveLimit,
};
rightSkuItem.currencyType = leftSkuItem.currencyType;
rightSkcItem.productSkuReqs.push(rightSkuItem);
}
rightSkcItem.productSkcId = 0;
rightSkc.push(rightSkcItem);
}
rightData.productSkcReqs = rightSkc;
// Spec
rightData.productSpecPropertyReqs = productSpecPropertyReqs;
rightData.carouselImageUrls = leftData.carouselImageUrls;
rightData.carouselImageI18nReqs = leftData.carouselImageI18nVOList;
rightData.materialImgUrl = leftData.materialImgUrl;
rightData.goodsLayerDecorationReqs = leftData.goodsLayerDecorationVOList;
rightData.sizeTemplateIds = !leftData.sizeTemplateIds ? []: leftData.sizeTemplateIds;
rightData.showSizeTemplateIds = !leftData.showSizeTemplateIds ? []: leftData.showSizeTemplateIds;
rightData.goodsModelReqs = !leftData.goodsModelList ? []: leftData.goodsModelList;
rightData.productWhExtAttrReq = {
outerGoodsUrl: leftData.productWhExtAttr.outerGoodsUrl,
productOrigin: {
countryShortName: leftData.productWhExtAttr.productOrigin.countryShortName
}
};
rightData.productCarouseVideoReqList = leftData.carouseVideoVOList;
rightData.goodsAdvantageLabelTypes = leftData.goodsAdvantageLabelVOList;
rightData.productDetailVideoReqList = leftData.detailVideoVOList;
rightData.productOuterPackageImageReqs = [];
for (let i = 0;i < leftData.outerPackageImages.length; i++) {
rightData.productOuterPackageImageReqs.push({
imageUrl: leftData.outerPackageImages[i].imageUrl
})
}
rightData.productOuterPackageReq = leftData.productWhExtAttr.productOuterPackage;
rightData.sensitiveTransNormalFileReqs = leftData.productWhExtAttr.sensitiveTransNormalFiles;
rightData.productGuideFileI18nReqs = leftData.productGuideFileI18nList;
rightData.productSaleExtAttrReq = {};
rightData.productDraftId = "";
return JSON.stringify(rightData);
}