From 377415e6f59307027b3179243e4b74e0f01ca07d Mon Sep 17 00:00:00 2001 From: dt_2916866708 <> Date: Fri, 19 Jan 2024 10:30:20 +0800 Subject: [PATCH] 12 --- src/api/product/productAttr.js | 67 +++ src/components/CustomUpload.vue | 79 +++ .../Tinymce/components/EditorImage.vue | 35 +- src/components/Tinymce/components/Upload.vue | 75 +++ src/components/Tinymce/index.vue | 1 + src/components/Upload/index.vue | 24 +- src/router/index.js | 2 +- .../product/brand/components/AddOrEdit.vue | 1 + src/views/product/brand/index.vue | 2 +- .../productAdd/components/CustomUpload.vue | 82 +++ .../components/OilStationSelection.vue | 149 ++++++ src/views/product/productAdd/index.vue | 15 +- src/views/product/productAdd/newIndex.vue | 359 +++++++++---- .../productList/components/AuditingDetail.vue | 148 ++++++ .../productList/components/EditorStock.vue | 166 ++++++ src/views/product/productList/index.vue | 488 +++++++++++------- 16 files changed, 1357 insertions(+), 336 deletions(-) create mode 100644 src/components/CustomUpload.vue create mode 100644 src/components/Tinymce/components/Upload.vue create mode 100644 src/views/product/productAdd/components/CustomUpload.vue create mode 100644 src/views/product/productAdd/components/OilStationSelection.vue create mode 100644 src/views/product/productList/components/AuditingDetail.vue create mode 100644 src/views/product/productList/components/EditorStock.vue diff --git a/src/api/product/productAttr.js b/src/api/product/productAttr.js index c37ea2a..0ed6494 100644 --- a/src/api/product/productAttr.js +++ b/src/api/product/productAttr.js @@ -1,6 +1,73 @@ import request from '@/utils/request' var service_name = 'oil-mall' export default { + productAddGetSites(productId) { + return request({ + url: `/${service_name}/mallProductSiteRelation/get/${productId}`, + method: 'GET', + }) + }, + productAddGetEdit(productId) { + return request({ + url: `/${service_name}/mallProductInfo/getEdit/${productId}`, + method: 'GET', + }) + }, + productListAuditingDetailgetByPage(productId) { + return request({ + url: `/${service_name}/mallProductAuditHistory/getListByProductId/${productId}`, + method: 'GET', + }) + }, + productListDelete(data) { + return request({ + url: `/${service_name}/mallProductInfo/delete`, + method: 'post', + data + }) + }, + productListAuditProduct(data) { + return request({ + url: `/${service_name}/mallProductInfo/auditProduct`, + method: 'post', + data + }) + }, + productListUpdateBatchList(data) { + return request({ + url: `/${service_name}/mallProductStock/updateBatchList`, + method: 'post', + data + }) + }, + productListGetByPage(data) { + return request({ + url: `/${service_name}/mallProductInfo/getByPage`, + method: 'post', + data + }) + }, + addUpdate(data) { + return request({ + url: `/${service_name}/mallProductInfo/update`, + method: 'post', + data + }) + }, + addSave(data) { + return request({ + url: `/${service_name}/mallProductInfo/save`, + method: 'post', + data + }) + }, + getAllSites(data) { + return request({ + url: `/${service_name}/mallProductSiteRelation/getAllSites`, + method: 'post', + data + }) + }, brandGetAll(data) { return request({ url: `/${service_name}/mallProductBrands/getAll`, diff --git a/src/components/CustomUpload.vue b/src/components/CustomUpload.vue new file mode 100644 index 0000000..663e2d5 --- /dev/null +++ b/src/components/CustomUpload.vue @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/Tinymce/components/EditorImage.vue b/src/components/Tinymce/components/EditorImage.vue index eaaea6a..cb5c6b6 100644 --- a/src/components/Tinymce/components/EditorImage.vue +++ b/src/components/Tinymce/components/EditorImage.vue @@ -4,7 +4,8 @@ 上传图片 - + + + 取消 确定 + @@ -32,6 +36,7 @@ + \ No newline at end of file diff --git a/src/components/Tinymce/index.vue b/src/components/Tinymce/index.vue index 8ba95fd..2a52706 100644 --- a/src/components/Tinymce/index.vue +++ b/src/components/Tinymce/index.vue @@ -199,6 +199,7 @@ export default { window.tinymce.get(this.tinymceId).getContent() }, imageSuccessCBK(arr) { + console.log(arr,"imageSuccessCBK") const _this = this arr.forEach(v => { window.tinymce.get(_this.tinymceId).insertContent(``) diff --git a/src/components/Upload/index.vue b/src/components/Upload/index.vue index c6c608e..e0d1aed 100644 --- a/src/components/Upload/index.vue +++ b/src/components/Upload/index.vue @@ -1,21 +1,15 @@ - + - - - + + + {{ tip }} @@ -53,10 +47,10 @@ export default { } }, watch: { - photo: function(newVal, oldVal) { + photo: function (newVal, oldVal) { this.photoUrl = newVal }, - isPrivate: function(newVal, oldVal) { + isPrivate: function (newVal, oldVal) { this.changeUploadUrl } }, @@ -72,7 +66,7 @@ export default { } }, removeUrl(file, fileList) { - this.$emit('success', '', { data: { publicUrl: '' }, code: 20000 }) + this.$emit('success', undefined, { data: { publicUrl: '' }, code: 20000 }) }, uploadSuccess(res, file) { if (res.code === 20000) { diff --git a/src/router/index.js b/src/router/index.js index 3fe06e8..05d2062 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -53,7 +53,7 @@ export const constantRoutes = [{ component: () => import('@/views/product/productAttr/index'), name: 'productAttr', meta: { title: '商品属性', icon: 'iconkongzhitai', affix: true } - } + }, ] }, { path: '/CustomerMarket', component: CustomerMarket }, diff --git a/src/views/product/brand/components/AddOrEdit.vue b/src/views/product/brand/components/AddOrEdit.vue index 7e79769..a00efa3 100644 --- a/src/views/product/brand/components/AddOrEdit.vue +++ b/src/views/product/brand/components/AddOrEdit.vue @@ -54,6 +54,7 @@ export default { }); }, uploadSuccess(e, res) { + console.log(...arguments,"uploadSuccess") if (res.code == 20000) { ({ publicUrl: this.form.logoUrl } = res.data); } diff --git a/src/views/product/brand/index.vue b/src/views/product/brand/index.vue index 9b4498e..c1f0e83 100644 --- a/src/views/product/brand/index.vue +++ b/src/views/product/brand/index.vue @@ -92,7 +92,7 @@ export default { this.init() }, methods: { - addBrand() { + addBrand() { this.isAddOrEdit = true; }, brandSave(e,model="brandSave") { diff --git a/src/views/product/productAdd/components/CustomUpload.vue b/src/views/product/productAdd/components/CustomUpload.vue new file mode 100644 index 0000000..05a9c1c --- /dev/null +++ b/src/views/product/productAdd/components/CustomUpload.vue @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/views/product/productAdd/components/OilStationSelection.vue b/src/views/product/productAdd/components/OilStationSelection.vue new file mode 100644 index 0000000..2b053d3 --- /dev/null +++ b/src/views/product/productAdd/components/OilStationSelection.vue @@ -0,0 +1,149 @@ + + + + + + + + 查询 + 确定选择 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/views/product/productAdd/index.vue b/src/views/product/productAdd/index.vue index b7ef27c..e764d53 100644 --- a/src/views/product/productAdd/index.vue +++ b/src/views/product/productAdd/index.vue @@ -36,14 +36,7 @@ - - + - - + @@ -1453,10 +1445,11 @@ import WangEditor from '@/components/wangEditor/index.vue'; // import Setting from '@/setting'; // import { getCookies } from '@/libs/util'; import { uploadByPieces } from '@/utils/upload'; //引入uploadByPieces方法 - +import CustomUpload from './components/CustomUpload.vue'; export default { name: 'product_productAdd', components: { + CustomUpload, // VueUeditorWrap, uploadPictures, freightTemplate, diff --git a/src/views/product/productAdd/newIndex.vue b/src/views/product/productAdd/newIndex.vue index dabce7d..1b48c6a 100644 --- a/src/views/product/productAdd/newIndex.vue +++ b/src/views/product/productAdd/newIndex.vue @@ -9,7 +9,7 @@ - @@ -42,50 +42,61 @@ + + + + + - - + + + + + {{ tag.siteName }} + + + 添加油站 + + + + + + + + + + + + + + + - - - - - - + - - - - - - - - - - - - + + + - + - - + + - + 确认 @@ -111,7 +122,7 @@ class="el-icon-circle-close" @click="handleRemoveAttr(index)" /> + :disable-transitions="false" class="mb5 mr10" @close="handleClose(item.sku.value, indexn, index)"> {{ j }} @@ -119,19 +130,9 @@ - + - @@ -149,8 +150,8 @@ - - + + - @@ -173,7 +174,7 @@ - + @@ -182,9 +183,9 @@ - - 删除 - + + 删除 + @@ -267,6 +268,10 @@ + + + + @@ -276,6 +281,11 @@ import Tinymce from '@/components/Tinymce/index' import CreatTemplates from '@/views/systemSetting/logistics/shippingTemplates/creatTemplates' import Templates from "../../appSetting/wxAccount/wxTemplate/index"; import { Debounce } from '@/utils/validate' +import CustomUpload from './components/CustomUpload.vue'; +import OilStationSelection from './components/OilStationSelection.vue'; +import { loadingFn } from "@/utils/validate" + + const defaultObj = { image: '', sliderImages: [], @@ -336,9 +346,12 @@ const objTitle = { } export default { name: 'ProductProductAdd', - components: { Templates, CreatTemplates, Tinymce }, + components: { Templates, CreatTemplates, Tinymce, CustomUpload, OilStationSelection }, data() { return { + loading: false, + OilStationSelectionList: [], + isOilStationSelection: false, brandOptions: [], isDisabled: this.$route.params.isDisabled === '1' ? true : false, activity: { '默认': 'red', '秒杀': 'blue', '砍价': 'green', '拼团': 'yellow' }, @@ -359,7 +372,11 @@ export default { merCateList: [], // 商户分类筛选 shippingList: [], // 运费模板 formThead: Object.assign({}, objTitle), - formValidate: Object.assign({}, defaultObj), + formValidate: { + recommendOrNewMark: "1", + productStatus: "1", + attr: [] + }, formDynamics: { ruleName: '', ruleValue: [] @@ -441,12 +458,12 @@ export default { }, { label: "销售价格", - name: "销售价格", + name: "销售价格", value: "sellPrice" }, { label: "商品库存", - name: "商品库存", + name: "商品库存", value: "stock" }, { @@ -457,7 +474,7 @@ export default { }, { label: "兑换积分", - name: "兑换积分", + name: "兑换积分", value: "integral" } ] @@ -471,28 +488,104 @@ export default { } }, watch: { + $route(to, from) { + if(from.path=="/productList"&&to.params.id){ + this.chenkId() + } + console.log(from.path);//从哪来 + console.log(to.path,to.params);//到哪去 + }, + "formValidate.content": function (n) { + console.log(n, "++++++++++++++++++++++") + }, ManyAttrValue(n) { }, 'formValidate.attr': { handler: function (val) { - if (this.formValidate.specType && this.isAttr) this.watCh(val) //重要!!! + if (this.isAttr) this.watCh(val) //重要!!! }, immediate: false, deep: true } }, created() { + this.chenkId(); this.getCategorySelect(); this.productGetRule(); this.brandGetAll() }, - mounted() { - }, + mounted() { }, methods: { - brandGetAll(){ - productApi.brandGetAll().then(res=>{ - if(res.code==20000){ - this.brandOptions =res.data - } + chenkId() { + if (this.$route.params && this.$route.params.id) { + this.getproductInfo(this.$route.params.id) + } + }, + productAddGetSites(ids) { + Promise.all(ids.map(id => { + return productApi.productAddGetSites(id); + })).then(res => { + console.log(res, "productAddGetSites") + }) + }, + inverseAnalysis(data) { + console.log(data,"data") + let { categoryOneId, categoryTwoId } = data; + let categorys = [categoryOneId, categoryTwoId]; + this.OilStationSelectionList = data.siteInfos; + Object.assign(this.formValidate,{ + categorys, + ...data + }); + this.$refs.CustomUpload.fileList = [...this.formValidate.images.filter(item=>item.mainMark=="1")]; + this.$refs.CustomLBUpload.fileList = [...this.formValidate.images.filter(item=>item.mainMark!="1")] ; + this.confirm(); + this.$nextTick(()=>{ + setTimeout(() => { + console.log(this.formValidate,"this.formValidate.arr") + }, 1000); + this.formValidate.attr = this.formValidate.attr.map(item=>{ + let align = this.formValidate.checkedList.find(i=>item.id==i.attributeId); + if(align){ + return { + ...item, + sku:{ + ...item.sku, + value:align.checked.split(",") + } + } + }else{ + return null + } + // return Boolean(this.formValidate.checkedList.filter(i=>item.id==i.attributeId).length) + }).filter(item=>item) + this.ManyAttrValue = this.ManyAttrValue.map(item=>{ + + }) + }) + + }, + getproductInfo(id) { + productApi.productAddGetEdit(id).then(res => { + if (res.code == 20000) { + this.inverseAnalysis(res.data) + } + }) + }, + setPreferred(setPreferred) { + console.log(setPreferred, "setPreferred") + }, + delectOilStationSelectionList(e, index) { + this.OilStationSelectionList.splice(index, 1) + }, + oilStationSelectionSubmit(e) { + this.OilStationSelectionList = e; + this.isOilStationSelection = false; + }, + brandGetAll() { + productApi.brandGetAll().then(res => { + if (res.code == 20000) { + this.brandOptions = res.data + } }) }, cascaderChange(e) { @@ -565,23 +658,23 @@ export default { // sku算法 watCh(val) { let arr = []; - this.manyTabDate = []; + this.manyTabDate = []; for (let i = 0; i < val.length; i++) { arr.push(val[i].sku); this.manyTabDate.push(val[i].sku.name) - }; + }; this.ManyAttrValue = arr.reduce((a, b, c) => { - let res = []; - a.map(x => { - b.value.map(y => { - res.push({ - ...x, + let res = []; + a.map(x => { + b.value.map(y => { + res.push({ + ...x, [b.name]: y, - data: Object.assign({},x.data||{},{ [b.name]: y}), - ...Object.fromEntries(this.attrValue.map(item=>{ - return [item.value,""] + data: Object.assign({}, x.data || {}, { [b.name]: y }), + ...Object.fromEntries(this.attrValue.map(item => { + return [item.value, ""] })) - }) + }) }) }) return res @@ -677,12 +770,13 @@ export default { if (num) this.productGetRule() }, // 选择属性确认 - confirm() { + async confirm() { this.isAttr = true - if (!this.formValidate.selectRule) { + if (!this.formValidate.attributesTypeId) { return this.$message.warning('请选择属性') - } - this.formValidate.attr = JSON.parse(JSON.stringify(this.ruleList.find(item => item.id == this.formValidate.selectRule).attributesList)); + } + await this.productGetRule(); + this.formValidate.attr = JSON.parse(JSON.stringify(this.ruleList.find(item => item.id == this.formValidate.attributesTypeId).attributesList)); }, // 商品分类; getCategorySelect() { @@ -703,21 +797,25 @@ export default { }, // 获取商品属性模板; productGetRule() { - productApi.getAllAttributesType().then(res => { - if (res.code == 20000) { - this.ruleList = res.data.map(item => { - return { - ...item, - attributesList: item.attributesList.map(citem => { - return { - ...citem, - sku: { name: citem.attributeName, value: citem.attributeContent.split(",") } - } - }) - } - }); - }; - }) + return new Promise((re, rj) => { + productApi.getAllAttributesType().then(res => { + if (res.code == 20000) { + this.ruleList = res.data.map(item => { + return { + ...item, + attributesList: item.attributesList.map(citem => { + return { + ...citem, + sku: { name: citem.attributeName, value: citem.attributeContent.split(",") } + } + }) + } + }); + re(this.ruleList) + }; + }) + }); + }, // 运费模板; getShippingList() { @@ -759,10 +857,10 @@ export default { batchAdd() { // if (!this.oneFormBatch[0].pic || !this.oneFormBatch[0].price || !this.oneFormBatch[0].cost || !this.oneFormBatch[0].ot_price || // !this.oneFormBatch[0].stock || !this.oneFormBatch[0].bar_code) return this.$Message.warning('请填写完整的批量设置内容!'); - console.log( this.ManyAttrValue,this.oneFormBatch," this.ManyAttrValue"); - this.ManyAttrValue.forEach(item=>{ - Object.assign(item,this.oneFormBatch[0]) - }) + console.log(this.ManyAttrValue, this.oneFormBatch, " this.ManyAttrValue"); + this.ManyAttrValue.forEach(item => { + Object.assign(item, this.oneFormBatch[0]) + }) }, // 添加按钮 addBtn() { @@ -786,7 +884,7 @@ export default { }, // 删除属性 - handleClose(item, index,parentIndex) { + handleClose(item, index, parentIndex) { if (item.length == 1) { this.handleRemoveAttr(parentIndex) } else { @@ -1009,6 +1107,69 @@ export default { }, // 提交 handleSubmit: Debounce(function (name) { + let cover = this.$refs.CustomUpload.getFileList(); + let Carousel = this.$refs.CustomLBUpload.getFileList(); + cover.length && (cover[0]["mainMark"] = 1); + let [categoryOneId, categoryTwoId] = this.formValidate.categorys; + let isRecommendOrNewMark = this.formValidate.recommendOrNewMark == "1" ? "newMark" : "recommend"; + let siteIds = this.OilStationSelectionList.map(item => item.siteId); + let checkedList = this.formValidate.attr.map(item => { + let attributeId = item.id; + let checked = item.sku.value.join(','); + return { attributeId, checked } + }); + let images = cover.concat(Carousel).map((item, index) => { + let { name, url, mainMark = "" } = item; + return { + name, + url, + mainMark + } + }); + let stockList = this.ManyAttrValue.map(item => { + let { marketPrice = "", sellPrice = "", stock = "", integral = "", skuNum = "" } = item; + return { + attributeJson: JSON.stringify(item.data), + marketPrice, + sellPrice, + stock, + integral, + skuNum + } + }) + console.log(this.formValidate, "formValidate"); + console.log(categoryOneId, categoryTwoId, "categoryOneId categoryTwoId"); + console.log(isRecommendOrNewMark, "isRecommendOrNewMark"); + console.log(siteIds, "siteIds"); + console.log(checkedList, "checkedList"); + console.log(images, "images"); + console.log(stockList, "stockList"); + this.formValidate[isRecommendOrNewMark] = "1"; + loadingFn.call(this, "loading", productApi[this.$route.params.id?"addUpdate":"addSave"](Object.assign(this.formValidate, { + categoryOneId, + categoryTwoId, + siteIds, + checkedList, + images, + stockList + })).then(res => { + if (res.code == 20000) { + this.$message.success("操作成功"); + setTimeout(() => { + this.$router.push({ path: 'productList' }); + this.$destroy(); + }, 1000); + } + })); + + + + + + + + + // this.onChangeGroup() // if (this.formValidate.specType && this.formValidate.attr.length < 1) return this.$message.warning("请填写多规格属性!"); // this.formValidate.cateId = this.formValidate.cateIds.join(',') diff --git a/src/views/product/productList/components/AuditingDetail.vue b/src/views/product/productList/components/AuditingDetail.vue new file mode 100644 index 0000000..efe4399 --- /dev/null +++ b/src/views/product/productList/components/AuditingDetail.vue @@ -0,0 +1,148 @@ + + + + + + + + {{ scope.row.auditStatus | auditStatus }} + + + + + + + + + \ No newline at end of file diff --git a/src/views/product/productList/components/EditorStock.vue b/src/views/product/productList/components/EditorStock.vue new file mode 100644 index 0000000..83c2076 --- /dev/null +++ b/src/views/product/productList/components/EditorStock.vue @@ -0,0 +1,166 @@ + + + + + + + + + {{ scope.row.attributeJson[item] }} + + + + + + + + + + + + + + + + + + + + 修改 + + + + + + \ No newline at end of file diff --git a/src/views/product/productList/index.vue b/src/views/product/productList/index.vue index 2607ed9..ef919eb 100644 --- a/src/views/product/productList/index.vue +++ b/src/views/product/productList/index.vue @@ -1,33 +1,30 @@ - + - - + + - - - - - + + - + + + + + + + + + + + + + 查询 @@ -36,8 +33,8 @@ 添加商品 - 商品采集 - + 商品采集 + + 批量下架 + 批量上架 + 导出 - - - - - - + - + {{ scope.row.id }} - + + + {{ scope.row.productType ? '平台' : '店铺' }} + + + - {{ scope.row.store_name }} + {{ scope.row.productName }} - + - {{ scope.row.product_type }} + 价格:¥{{ scope.row.price }} + 货号:{{ scope.row.productNum }} + - + - {{ scope.row.price }} - - - - - {{ scope.row.sales }} + + 上架: + + + + 新品: + + + + 推荐: + + - {{ scope.row.stock }} + {{ scope.row.stockList.length }} + + 编辑库存 - + - {{ scope.row.sort }} + + {{ scope.row.updateTime }} + - + - - + {{ scope.row.auditStatus | auditStatusFilter }} + 审核详情 + - - 编辑 + + 编辑 + + 删除 + + + 审核 + + + + 审核通过 + + + 审核驳回 + + + + - + @@ -173,34 +172,16 @@ > --> - - + + - - - + + + @@ -219,38 +200,23 @@ - + - + - + - + @@ -293,13 +259,7 @@ - + @@ -308,22 +268,49 @@ + + + + + +