From de920312841ae1b21f1dc5df7a82066c80cae3d4 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Thu, 28 Mar 2024 09:43:43 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/packageIntegral/productList.js | 49 ++ packageIntegral/components/mulpicker.vue | 40 +- packageIntegral/productAddition/index.vue | 429 ++++++++++++-- .../productAddition/productAddStep2.vue | 122 +++- packageIntegral/productList/index.vue | 156 ++++-- packageIntegral/takeGoods/index.vue | 2 +- pages/stationDetail/ZYSite.vue | 2 +- uni_modules/uni-data-select/changelog.md | 37 ++ .../uni-data-select/uni-data-select.vue | 527 ++++++++++++++++++ uni_modules/uni-data-select/package.json | 85 +++ uni_modules/uni-data-select/readme.md | 8 + 11 files changed, 1301 insertions(+), 156 deletions(-) create mode 100644 api/packageIntegral/productList.js create mode 100644 uni_modules/uni-data-select/changelog.md create mode 100644 uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue create mode 100644 uni_modules/uni-data-select/package.json create mode 100644 uni_modules/uni-data-select/readme.md diff --git a/api/packageIntegral/productList.js b/api/packageIntegral/productList.js new file mode 100644 index 0000000..746fa8a --- /dev/null +++ b/api/packageIntegral/productList.js @@ -0,0 +1,49 @@ +import request from '@/utils/request' + +export default{ + productByPage(data) { // 商品分页查询 + return request({ + url: `/oil-mall/mobile/productByPage`, + method: 'post', + data + }) + }, + getTopInfo() { // 获取头部信息 + return request({ + url: `/oil-mall/mobile/getTopInfo`, + method: 'get', + }) + }, + productStatus(data) { // 上下架接口 + return request({ + url: `/oil-mall/mobile/productStatus`, + method: 'post', + data + }) + }, + productAuditHistory(data) { // 审核信息接口 + return request({ + url: `/oil-mall/mobile/productAuditHistory`, + method: 'post', + data + }) + }, + classification() { // 商品分类-树形接口 + return request({ + url: `/oil-mall/mobile/classification`, + method: 'get', + }) + }, + getProductBrands() { // 品牌信息接口 + return request({ + url: `/oil-mall/mobile/getProductBrands`, + method: 'get', + }) + }, + getAttributesType() { // 属性类型接口 + return request({ + url: `/oil-mall/mobile/getAttributesType`, + method: 'get', + }) + }, +} \ No newline at end of file diff --git a/packageIntegral/components/mulpicker.vue b/packageIntegral/components/mulpicker.vue index eb1b465..b180403 100644 --- a/packageIntegral/components/mulpicker.vue +++ b/packageIntegral/components/mulpicker.vue @@ -19,7 +19,7 @@ pidkey: { default: 'pid' }, // 对应父id取值 placeholder: { default: '请选择' }, emitPath: { default: false, type: Boolean }, // 是否子父级关联 ,是的时候返回的是逗号分隔的父子code - level: { default: 3, type: Number } // 列数 2或者3 + level: { default: 2, type: Number } // 列数 2或者3 }, data() { return { @@ -30,21 +30,20 @@ }, methods: { handleColumnChange(e) { - let columnindex = e.detail.value; // 拖动列索引 switch (e.detail.column) { case 0: //拖动第1列 - + // 第二级 let arr1 = this.multiArray[0]; this.multiArray[1] = arr1[columnindex][this.childkey]||[]; - + if(this.level === 3) { // 第三级 let arr2 = this.multiArray[1]; this.multiArray[2] = arr2[0][this.childkey]||[]; } - + this.multiIndex.splice(0, 1, columnindex) this.multiIndex.splice(1, 1, 0) this.multiIndex.splice(2, 1, 0) @@ -55,14 +54,14 @@ let arr3 = this.multiArray[1]; this.multiArray[2] = arr3[columnindex][this.childkey]||[]; } - + this.multiIndex.splice(1, 1, columnindex) this.multiIndex.splice(2, 1, 0) break } - + }, - // + // pickerChange(e) { let multiIndex = e.detail.value; if(this.emitPath) { @@ -75,21 +74,19 @@ } let code = codeArr.join(','); this.name = nameArr.join('/'); - console.log('code1',code); this.$emit('input', code) }else { - + let curArr = this.multiArray[2], code=''; if(curArr && curArr.length) { code = curArr[multiIndex[2]][this.code]; this.name = curArr[multiIndex[2]][this.rangekey]; - }else { + }else { curArr = this.multiArray[1] code = curArr[multiIndex[1]][this.code]; this.name = curArr[multiIndex[1]][this.rangekey]; } - - console.log('code2',code); + this.$emit('input', code) } }, @@ -104,7 +101,7 @@ // 第三级 let arr2 = this.multiArray[1]; this.multiArray.push(arr2[this.multiIndex[1]][this.childkey]||[]); - + } }, curDataFind (data, code) { @@ -151,16 +148,17 @@ list: { immediate: true, handler(val) { - console.log(val) - this.dataInit(); - this.initName(); + if(JSON.stringify(val) != '[]'){ + this.dataInit(); + this.initName(); + } + } }, value: { // immediate: true, handler(val) { - console.log(val) - this.initName(); + this.initName(); } }, } @@ -168,5 +166,5 @@ \ No newline at end of file + + diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 04a0c16..61b3b60 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -5,39 +5,44 @@ 新增商品 - + - - + + - - + + - - + + + - - + + - - + + - + @@ -53,10 +58,78 @@ - + + + + + + + 商品类型: + + + + {{item.attributeName}}: + + + + + + + + + + + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 + {{item.label}} + 确定 + + + + * + 规格: + {{radioAttributes}}+{{items}} + + {{item.label}} + 删除 + + + + * + 规格: + {{radioAttributes}} + + {{item.label}} + 删除 + + + + * + 商品图片:最多可上传10张图片 + + 商品主图 + 设为主图 + + + + + + + + + + + 详情图片:最多可上传10张图片 + + + 上一步 - 完成 + 完成 @@ -67,7 +140,8 @@ @@ -41,15 +105,33 @@ .container{ .body{ padding: 30rpx; + width: 100%; } } .bodyContent{ - position: relative; - // padding-left:150rpx; - .bodyLabel{ - display: inline-block; - width: 150rpx; - } + width: 100%; + + } + .tagButton{ + display: inline-block; + width: 133rpx; + height: 58rpx; + background: #f5f5f5; + color: #666666; + border-radius: 10rpx; + line-height: 58rpx; + text-align: center; + margin: 10rpx; + } + .redButton{ + display: inline-block; + width: 84rpx; + height: 58rpx; + background: red; + color: #fff; + border-radius: 10rpx; + line-height: 58rpx; + text-align: center; } \ No newline at end of file diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index 54e62db..b02a0a1 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -9,29 +9,31 @@ {{item.text}}({{item.count}}) - - + + - 已上架 + {{item.productStatus =='1'?'已上架':'未上架'}} - + {{item.productName}} 规格:默认 - ¥{{item.marketPrice}} X{{item.orderNum}} - 库存:{{item.orderNum}} + 库存:{{item.totalStock}} - {{statusEnum[1].value}} + {{statusEnum[item.auditStatus].value}} 删除 编辑 - 上架 + {{item.productStatus =='1'?'上架':'下架'}} @@ -50,13 +52,13 @@ 审核时间 {{item.createTime}} - + 审核结果 - {{item.status}} + {{statusEnum[item.auditStatus].value}} 反馈详情 - {{item.dateil}} + {{item.remark}} @@ -77,10 +79,10 @@ - 是否上架/下架该商品? + 是否{{productData.productStatus =='1'?'下架':'上架'}}该商品? 取消 - 确认 + 确认 @@ -89,7 +91,7 @@ + + diff --git a/uni_modules/uni-data-select/package.json b/uni_modules/uni-data-select/package.json new file mode 100644 index 0000000..47afe60 --- /dev/null +++ b/uni_modules/uni-data-select/package.json @@ -0,0 +1,85 @@ +{ + "id": "uni-data-select", + "displayName": "uni-data-select 下拉框选择器", + "version": "1.0.7", + "description": "通过数据驱动的下拉框选择器", + "keywords": [ + "uni-ui", + "select", + "uni-data-select", + "下拉框", + "下拉选" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "^3.1.1" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": ["uni-load-more"], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "u", + "app-nvue": "n" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} diff --git a/uni_modules/uni-data-select/readme.md b/uni_modules/uni-data-select/readme.md new file mode 100644 index 0000000..eb58de3 --- /dev/null +++ b/uni_modules/uni-data-select/readme.md @@ -0,0 +1,8 @@ +## DataSelect 下拉框选择器 +> **组件名:uni-data-select** +> 代码块: `uDataSelect` + +当选项过多时,使用下拉菜单展示并选择内容 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 -- 2.49.1 From e7721ff978f2c15a9c12640f06c549b7b4fd93f6 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Thu, 28 Mar 2024 16:13:29 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/packageIntegral/productList.js | 20 + packageIntegral/productAddition/index.vue | 156 +++- .../productAddition/productAddStep2.vue | 137 ---- packageIntegral/productList/index.vue | 11 +- packageIntegral/productUpdate/index.vue | 684 ++++++++++++++++++ 5 files changed, 834 insertions(+), 174 deletions(-) delete mode 100644 packageIntegral/productAddition/productAddStep2.vue create mode 100644 packageIntegral/productUpdate/index.vue diff --git a/api/packageIntegral/productList.js b/api/packageIntegral/productList.js index 746fa8a..84df717 100644 --- a/api/packageIntegral/productList.js +++ b/api/packageIntegral/productList.js @@ -46,4 +46,24 @@ export default{ method: 'get', }) }, + getEdit(id) { // 根据id查询商品数据接口 + return request({ + url: `/oil-mall/mallProductInfo/getEdit/${id}`, + method: 'get' + }) + }, + saveProduct(data) { // 新增商品接口 + return request({ + url: `/oil-mall/mobile/saveProduct`, + method: 'post', + data + }) + }, + updateProduct(data) { // 编辑更新商品数据接口 + return request({ + url: `/oil-mall/mobile/updateProduct`, + method: 'post', + data + }) + }, } \ No newline at end of file diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 61b3b60..cd0fa06 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -58,7 +58,6 @@ - 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} - 确定 + {{item.label}} + 确定 @@ -94,7 +93,9 @@ 规格: {{radioAttributes}}+{{items}} - {{item.label}} + + + 删除 @@ -103,29 +104,38 @@ 规格: {{radioAttributes}} - {{item.label}} + + + 删除 * 商品图片:最多可上传10张图片 - - 商品主图 - 设为主图 - - - - - + + + + 商品主图 + + + + + 设为主图 + + + + + + - + 上一步 @@ -143,17 +153,17 @@ import utils from '@/utils/encode' import serve from '@/api/packageIntegral/productList.js' import mulpicker from '@/packageIntegral/components/mulpicker.vue' - import productAddStep2 from '@/packageIntegral/productAddition/productAddStep2.vue' export default { components: { - mulpicker, - productAddStep2 + mulpicker }, data() { return { currentBoxId: 'instruction', //当前显示的view的id isBoxShow: false, - productDate:{}, + productDate:{ + images:[] + }, productList:[], brandIdList:[], radioItem:[{ @@ -172,13 +182,14 @@ attributesTypeList:[], attributesList:[], bottonList:[ - {label:'市场价格',value:'marketPrice'}, - {label:'销售价格',value:'sellPrice'}, - {label:'商品库存',value:'stock'}, - {label:'兑换积分',value:'integral'} + {label:'市场价格',value:'marketPrice',checked:false}, + {label:'销售价格',value:'sellPrice',checked:false}, + {label:'商品库存',value:'stock',checked:false}, + {label:'兑换积分',value:'integral',checked:false} ], radioAttributes:'', - checkboxAttributes:[] + checkboxAttributes:[], + stockList:[] } }, @@ -296,6 +307,30 @@ }, deleteRadio(){ this.radioAttributes = '' + }, + changeChecked(item){ + + item.checked = !item.checked + console.log(this.radioAttributes,this.checkboxAttributes) + + }, + addStockList(){ + this.stockList = [] + let obj = {} + this.bottonList.forEach(tab=>{ + if(tab.checked == true){ + if(tab.value == 'marketPrice'){ + obj.marketPrice = '' + }else if(tab.value == 'sellPrice'){ + obj.sellPrice = '' + }else if(tab.value == 'stock'){ + obj.stock = '' + }else if(tab.value == 'integral'){ + obj.integral = '' + } + } + }) + this.stockList.push(obj) }, // 调用系统相机 takePhoto() { @@ -319,13 +354,13 @@ success: (modalRes) => { if (modalRes.confirm) { // 引导用户去设置中打开权限 - wx.openSetting({ + uni.openSetting({ success(res) { if (res.authSetting['scope.camera']) { re() - // 授权成功,重新定位 + // 授权成功 } else { - // 没有允许定位权限 + // 没有允许相机权限 wx.showToast({ title: '您拒绝了相机权限,将无法使用相机功能', icon: 'none' @@ -356,6 +391,7 @@ //调起上传图片 srcFileImage() { let _that = this + let imageUrl = '' uni.chooseImage({ count: 10, //默认9 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 @@ -386,8 +422,8 @@ console.log('进入2') console.log(e) let obj = JSON.parse(e.data), - url = obj.data.publicUrl - console.log(obj.data.publicUrl) + imageUrl = obj.data.publicUrl + _that.getImage(imageUrl) }, fail(err) { console.log(err) @@ -398,6 +434,27 @@ } }) }, + getImage(imageUrl){ + if(JSON.stringify(this.productDate.images) == '[]'){ + this.productDate.images.push({ + url:imageUrl, + mainMark:1 + }) + }else{ + this.productDate.images.push({ + url:imageUrl, + mainMark:'' + }) + } + }, + clearImage(index){ + if(this.productDate.images[index].mainMark == 1){ + this.productDate.images.splice(index,1) + this.productDate.images[0].mainMark = 1 + }else{ + this.productDate.images.splice(index,1) + } + }, picker2(e){ console.log(e.detail.value) this.productDate.value = e.detail.value @@ -500,6 +557,10 @@ text-align: center; margin: 8rpx; } + .checkedTag{ + background-color: #2979ff; + color: #FFFFFF; + } .redButton{ display: inline-block; width: 84rpx; @@ -510,16 +571,41 @@ line-height: 58rpx; text-align: center; } + .commodityImage{ + display: inline-block; + max-width: calc(100%-150rpx); + } + .imageList{ + display: inline-block; + width: 140rpx; + margin: 0 10rpx; + } .imageBlack{ display: inline-block; width: 140rpx; height: 140rpx; - line-height: 140rpx; - // position: relative; - .cameraImage{ - // position: absolute; - // left: 70rpx; - // top: 70rpx; + position: relative; + >image{ + width: 100%; + height: 100%; + } + .cameraText{ + width: 140rpx; + height: 30rpx; + text-align: center; + line-height: 30rpx; + position: absolute; + background-color: #333; + opacity: 0.3; + color: #FFFFFF; + left: 0rpx; + top: 110rpx; + } + .cameraClear{ + position: absolute; + left: 120rpx; + top: -10rpx; + z-index: 20; } } diff --git a/packageIntegral/productAddition/productAddStep2.vue b/packageIntegral/productAddition/productAddStep2.vue deleted file mode 100644 index bd45224..0000000 --- a/packageIntegral/productAddition/productAddStep2.vue +++ /dev/null @@ -1,137 +0,0 @@ - - - - - \ No newline at end of file diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index b02a0a1..8ee4a14 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -32,7 +32,7 @@ :style="{background:statusEnum[item.auditStatus].color}" >{{statusEnum[item.auditStatus].value}} 删除 - 编辑 + 编辑 {{item.productStatus =='1'?'上架':'下架'}} @@ -194,7 +194,7 @@ }, toDetails(item) { uni.navigateTo({ - url: `../orderDetails/index?orderId=${item.orderId}` + url: `../orderDetails/index?orderId=${item.id}` }) }, getTopInfo(){ @@ -242,6 +242,13 @@ orderDelete(){ this.$refs.delete.open('center') }, + editOrder(item){ + console.log(item) + uni.navigateTo({ + url: `../productUpdate/index??orderId=${item.id}` + }) + + }, upDownFrame(item) { this.productData = item this.$refs.popup.open('center') diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue new file mode 100644 index 0000000..cd0fa06 --- /dev/null +++ b/packageIntegral/productUpdate/index.vue @@ -0,0 +1,684 @@ + + + + + -- 2.49.1 From 53aa029391efcdda20c390b3e50a30f32c7e6240 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Fri, 29 Mar 2024 17:11:02 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageIntegral/productAddition/index.vue | 193 ++++++++---------- packageIntegral/productList/index.vue | 7 +- packageIntegral/productUpdate/index.vue | 237 ++++++++++++---------- pages.json | 3 + 4 files changed, 220 insertions(+), 220 deletions(-) diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index cd0fa06..320c023 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ > - 商品类型: + 商品类型: @@ -83,36 +83,37 @@ - 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 + {{item.label}} 确定 - - + + * 规格: - {{radioAttributes}}+{{items}} + {{radioAttributes}} + {{radioAttributes}}+{{checkboxAttributes[index]}} - - + + - 删除 - - - - * - 规格: - {{radioAttributes}} + + - - + + - 删除 + + + + 删除 - + * - 商品图片:最多可上传10张图片 + 商品图片: + 最多可上传10张图片 + @@ -121,12 +122,12 @@ - 设为主图 + 设为主图 - - + + @@ -159,7 +160,7 @@ }, data() { return { - currentBoxId: 'instruction', //当前显示的view的id + currentBoxId: 'chooseType', //当前显示的view的id isBoxShow: false, productDate:{ images:[] @@ -193,8 +194,7 @@ } }, - onLoad(options) { - // this.get(options.orderId) + onLoad() { this.classfication() this.getProductBrands() this.getAttributesType() @@ -208,6 +208,13 @@ } }, methods: { + switchChange(e){ + if(e.detail.value == true){ + this.productDate.productStatus = '1' + }else if(e.detail.value == false){ + this.productDate.productStatus = '2' + } + }, classfication(){ serve.classification().then(res=>{ this.productList = res.data @@ -304,90 +311,43 @@ this.checkboxAttributes.splice(i,1) this.radioAttributes = '' } + this.stockList.splice(i,1) }, deleteRadio(){ this.radioAttributes = '' }, changeChecked(item){ - item.checked = !item.checked - console.log(this.radioAttributes,this.checkboxAttributes) - }, addStockList(){ this.stockList = [] - let obj = {} - this.bottonList.forEach(tab=>{ - if(tab.checked == true){ - if(tab.value == 'marketPrice'){ - obj.marketPrice = '' - }else if(tab.value == 'sellPrice'){ - obj.sellPrice = '' - }else if(tab.value == 'stock'){ - obj.stock = '' - }else if(tab.value == 'integral'){ - obj.integral = '' - } - } - }) - this.stockList.push(obj) + let obj = { + marketPrice:'', + sellPrice:'', + stock:'', + integral:'' + } + if(this.attributesList.length ==1){ + let data = {} + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + data[name] = value + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + }else{ + this.checkboxAttributes.forEach((tab,index)=>{ + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + let tabName = this.attributesList[index+1].attributeName + let tabValue = tab + data[name] = value + data[tabName] = tabValue + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + }) + + } }, - // 调用系统相机 - takePhoto() { - // 先检查权限 - let _that = this - uni.getSetting({ - success(res) { - if (!res.authSetting['scope.camera']) { - // 请求权限 - uni.authorize({ - scope: 'scope.camera', - success() { - // 权限已经获取,可以调用相机 - _that.srcFileImage() - }, - fail() { - // 用户拒绝授权,需引导用户开启权限 - uni.showModal({ - title: '提示', - content: '需要相机权限才能使用相机功能,请在设置中打开', - success: (modalRes) => { - if (modalRes.confirm) { - // 引导用户去设置中打开权限 - uni.openSetting({ - success(res) { - if (res.authSetting['scope.camera']) { - re() - // 授权成功 - } else { - // 没有允许相机权限 - wx.showToast({ - title: '您拒绝了相机权限,将无法使用相机功能', - icon: 'none' - }); - rj('拒绝了相机权限') - } - }, - fail() { - rj('openSetting调用失败') - } - }) - } - }, - }); - }, - }); - } else { - // 权限已经获取,可以直接调用相机 - _that.srcFileImage() - } - }, - fail(err) { - // 获取设置失败 - console.error(err); - }, - }); - }, //调起上传图片 srcFileImage() { let _that = this @@ -447,6 +407,15 @@ }) } }, + setMainImage(index){ + this.productDate.images.forEach((tab,i)=>{ + if(i == index){ + tab.mainMark = 1 + }else{ + tab.mainMark = '' + } + }) + }, clearImage(index){ if(this.productDate.images[index].mainMark == 1){ this.productDate.images.splice(index,1) @@ -455,17 +424,26 @@ this.productDate.images.splice(index,1) } }, - picker2(e){ - console.log(e.detail.value) - this.productDate.value = e.detail.value - }, closed(){ uni.navigateTo({ url: '/pages/index/index' }) }, addCompleted(){ - + if(this.radioItem[0].checked =true){ + this.productDate.newMark == '1' + }else{ + this.productDate.newMark == '2' + } + if(this.radioItem[1].checked =true){ + this.productDate.recommend == '1' + }else{ + this.productDate.recommend == '2' + } + this.productDate.stockList = this.stockList + serve.saveProduct(this.productDate).then(res=>{ + console.log(res) + }) } } } @@ -549,7 +527,6 @@ .tagButton{ display: inline-block; width: 133rpx; - height: 58rpx; background: #f5f5f5; color: #666666; border-radius: 8rpx; @@ -584,6 +561,8 @@ display: inline-block; width: 140rpx; height: 140rpx; + vertical-align: middle; + text-align: center; position: relative; >image{ width: 100%; diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index 8ee4a14..e98ebdb 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -32,7 +32,7 @@ :style="{background:statusEnum[item.auditStatus].color}" >{{statusEnum[item.auditStatus].value}} 删除 - 编辑 + 编辑 {{item.productStatus =='1'?'上架':'下架'}} @@ -242,10 +242,9 @@ orderDelete(){ this.$refs.delete.open('center') }, - editOrder(item){ - console.log(item) + toEditOrder(item){ uni.navigateTo({ - url: `../productUpdate/index??orderId=${item.id}` + url: `../productUpdate/index?id=${item.id}` }) }, diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index cd0fa06..5d9665e 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ > - 商品类型: + 商品类型: @@ -83,36 +83,37 @@ - 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 + {{item.label}} 确定 - - + + * 规格: - {{radioAttributes}}+{{items}} + {{radioAttributes}} + {{radioAttributes}}+{{checkboxAttributes[index]}} - - + + - 删除 - - - - * - 规格: - {{radioAttributes}} + + - - + + - 删除 + + + + 删除 - + * - 商品图片:最多可上传10张图片 + 商品图片: + 最多可上传10张图片 + @@ -121,12 +122,12 @@ - 设为主图 + 设为主图 - - + + @@ -159,7 +160,7 @@ }, data() { return { - currentBoxId: 'instruction', //当前显示的view的id + currentBoxId: 'chooseType', //当前显示的view的id isBoxShow: false, productDate:{ images:[] @@ -194,7 +195,8 @@ }, onLoad(options) { - // this.get(options.orderId) + console.log(options,'options') + this.getEdit(options) this.classfication() this.getProductBrands() this.getAttributesType() @@ -208,6 +210,56 @@ } }, methods: { + getEdit(options){ + serve.getEdit(options.id).then(res=>{ + if(res.code === 20000&&res.data!=null){ + this.productDate = res.data + this.productDate.demandRegion = res.data.categoryOneId+','+res.data.categoryTwoId + if(this.productDate.newMark == '1'){ + this.radioItem[0].checked =true + }else{ + this.radioItem[0].checked =false + } + if(this.productDate.recommend == '1'){ + this.radioItem[1].checked =true + }else{ + this.radioItem[1].checked =false + } + this.attributesTypeList.forEach(tab=>{ + if(tab.id = this.productDate.attributesTypeId){ + this.attributesList = tab.attributesList + this.attributesList.forEach(tab=>{ + tab.attributesList = [] + tab.attributeContent.split(',').forEach(item=>{ + tab.attributesList.push({value:item,text:item}) + }) + }) + } + }) + if(this.productDate.checkedList.length==1){ + this.radioAttributes = this.productDate.checkedList[0].checked + }else{ + this.checkboxAttributes = [] + this.productDate.checkedList.forEach((tab,index)=>{ + if(index!=0){ + this.checkboxAttributes.push(tab.checked) + } + }) + } + this.stockList = this.productDate.stockList + + + } + console.log(res.data) + }) + }, + switchChange(e){ + if(e.detail.value == true){ + this.productDate.productStatus = '1' + }else if(e.detail.value == false){ + this.productDate.productStatus = '2' + } + }, classfication(){ serve.classification().then(res=>{ this.productList = res.data @@ -304,90 +356,43 @@ this.checkboxAttributes.splice(i,1) this.radioAttributes = '' } + this.stockList.splice(i,1) }, deleteRadio(){ this.radioAttributes = '' }, changeChecked(item){ - item.checked = !item.checked - console.log(this.radioAttributes,this.checkboxAttributes) - }, addStockList(){ this.stockList = [] - let obj = {} - this.bottonList.forEach(tab=>{ - if(tab.checked == true){ - if(tab.value == 'marketPrice'){ - obj.marketPrice = '' - }else if(tab.value == 'sellPrice'){ - obj.sellPrice = '' - }else if(tab.value == 'stock'){ - obj.stock = '' - }else if(tab.value == 'integral'){ - obj.integral = '' - } - } - }) - this.stockList.push(obj) + let obj = { + marketPrice:'', + sellPrice:'', + stock:'', + integral:'' + } + if(this.attributesList.length ==1){ + let data = {} + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + data[name] = value + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + }else{ + this.checkboxAttributes.forEach((tab,index)=>{ + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + let tabName = this.attributesList[index+1].attributeName + let tabValue = tab + data[name] = value + data[tabName] = tabValue + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + }) + + } }, - // 调用系统相机 - takePhoto() { - // 先检查权限 - let _that = this - uni.getSetting({ - success(res) { - if (!res.authSetting['scope.camera']) { - // 请求权限 - uni.authorize({ - scope: 'scope.camera', - success() { - // 权限已经获取,可以调用相机 - _that.srcFileImage() - }, - fail() { - // 用户拒绝授权,需引导用户开启权限 - uni.showModal({ - title: '提示', - content: '需要相机权限才能使用相机功能,请在设置中打开', - success: (modalRes) => { - if (modalRes.confirm) { - // 引导用户去设置中打开权限 - uni.openSetting({ - success(res) { - if (res.authSetting['scope.camera']) { - re() - // 授权成功 - } else { - // 没有允许相机权限 - wx.showToast({ - title: '您拒绝了相机权限,将无法使用相机功能', - icon: 'none' - }); - rj('拒绝了相机权限') - } - }, - fail() { - rj('openSetting调用失败') - } - }) - } - }, - }); - }, - }); - } else { - // 权限已经获取,可以直接调用相机 - _that.srcFileImage() - } - }, - fail(err) { - // 获取设置失败 - console.error(err); - }, - }); - }, //调起上传图片 srcFileImage() { let _that = this @@ -447,6 +452,15 @@ }) } }, + setMainImage(index){ + this.productDate.images.forEach((tab,i)=>{ + if(i == index){ + tab.mainMark = 1 + }else{ + tab.mainMark = '' + } + }) + }, clearImage(index){ if(this.productDate.images[index].mainMark == 1){ this.productDate.images.splice(index,1) @@ -455,17 +469,21 @@ this.productDate.images.splice(index,1) } }, - picker2(e){ - console.log(e.detail.value) - this.productDate.value = e.detail.value - }, closed(){ - uni.navigateTo({ - url: '/pages/index/index' - }) + uni.navigateBack() }, addCompleted(){ - + if(this.radioItem[0].checked =true){ + this.productDate.newMark == '1' + }else{ + this.productDate.newMark == '2' + } + if(this.radioItem[1].checked =true){ + this.productDate.recommend == '1' + }else{ + this.productDate.recommend == '2' + } + this.productDate.stockList = this.stockList } } } @@ -549,7 +567,6 @@ .tagButton{ display: inline-block; width: 133rpx; - height: 58rpx; background: #f5f5f5; color: #666666; border-radius: 8rpx; @@ -584,6 +601,8 @@ display: inline-block; width: 140rpx; height: 140rpx; + vertical-align: middle; + text-align: center; position: relative; >image{ width: 100%; diff --git a/pages.json b/pages.json index cf9ca96..5a51986 100644 --- a/pages.json +++ b/pages.json @@ -103,6 +103,9 @@ },{ "path": "productAddition/index", "style": {} + },{ + "path": "productUpdate/index", + "style": {} }] }, { -- 2.49.1 From 7cf3af639dbf1e89ed27c3ea5dc6ecc048298a0b Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Tue, 9 Apr 2024 08:56:34 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageIntegral/productAddition/index.vue | 102 ++++++++++--- packageIntegral/productList/index.vue | 20 +-- packageIntegral/productUpdate/index.vue | 178 ++++++++++++++-------- 3 files changed, 202 insertions(+), 98 deletions(-) diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 320c023..bab6ca5 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -6,7 +6,7 @@ - + {{item.attributeName}}: - - + + - + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} + {{item.label}} 确定 - + * 规格: @@ -163,6 +163,7 @@ currentBoxId: 'chooseType', //当前显示的view的id isBoxShow: false, productDate:{ + productStatus:'1', images:[] }, productList:[], @@ -175,9 +176,9 @@ checked: false }], rules:{ - name:{rules:[{required: true,errorMessage: '请选择商品分类'}]}, + demandRegion:{rules:[{required: true,errorMessage: '请选择商品分类'}]}, productName:{rules:[{required: true,errorMessage: '请输入商品名称'}]}, - brandId:{rules:[{required: true,errorMessage: '请输入商品品牌'}]}, + brandId:{rules:[{required: true,errorMessage: '请选择商品品牌'}]}, price:{rules:[{required: true,errorMessage: '请输入商品售价'}]}, }, attributesTypeList:[], @@ -190,7 +191,8 @@ ], radioAttributes:'', checkboxAttributes:[], - stockList:[] + stockList:[], + checkedList:[] } }, @@ -205,6 +207,11 @@ this.productDate.categoryOneId = val.split(',')[0] this.productDate.categoryTwoId = val.split(',')[1] } + }, + 'productDate.attributesTypeId'(val){ + if(!val){ + this.stockList = [] + } } }, methods: { @@ -257,20 +264,40 @@ }, changeBox(e){ let currentFlag = e.currentTarget.id; - switch(currentFlag){ - case 'next': - this.currentBoxId = 'instruction' - break; - case 'previous': - this.currentBoxId = 'chooseType' - break; - default: - this.currentBoxId = 'viewInstruction' - break; - } if(currentFlag == 'next'){ - this.getAttributesType() + this.$refs.productForm.validate().then(res=>{ + console.log('表单数据信息:', res); + switch(currentFlag){ + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; + } + if(currentFlag == 'next'){ + this.getAttributesType() + } + }).catch(err =>{ + console.log('表单错误信息:', err); + }) + }else{ + switch(currentFlag){ + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; + } } + }, getAttributesType(){ this.attributesTypeList = [] @@ -304,6 +331,25 @@ } }, + changeRadio(item,index){ + if(JSON.stringify(this.checkedList) == '[]'){ + this.checkedList.push({attributeId:item.id,checked:item.attributeName}) + }else{ + this.checkedList[index].checked = item.attributeName + } + }, + changeCheckBox(item,index){ + if(this.checkedList.length{ + checked.push(tab) + }) + this.checkedList[index].checked = checked.join(',') + this.checkedList.checked + } + }, deleteCheckAll(i){ if(this.checkboxAttributes.length>1){ this.checkboxAttributes.splice(i,1) @@ -358,7 +404,6 @@ sourceType: ['album'], //从相册选择 success: function(res) { console.log(res) - console.log('进入1') const JSESSIONID = utils.uuid() uni.uploadFile({ url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile', @@ -379,14 +424,11 @@ 'token': utils.md5Salt(JSESSIONID) }, success(e) { - console.log('进入2') - console.log(e) let obj = JSON.parse(e.data), imageUrl = obj.data.publicUrl _that.getImage(imageUrl) }, fail(err) { - console.log(err) } }) },fail() { @@ -440,9 +482,15 @@ }else{ this.productDate.recommend == '2' } + this.productDate.checkedList = this.checkedList this.productDate.stockList = this.stockList serve.saveProduct(this.productDate).then(res=>{ console.log(res) + uni.showToast({ + title: res.msg, + icon: 'none' + }) + this.closed() }) } } @@ -524,6 +572,10 @@ line-height: 72rpx; } } + .content{ + padding-bottom: 20rpx; + border-bottom: 1rpx solid #F6F6F6; + } .tagButton{ display: inline-block; width: 133rpx; diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index e98ebdb..6a7a5dd 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -17,12 +17,12 @@ - + {{item.productStatus =='1'?'已上架':'未上架'}} - + {{item.productName}} 规格:默认 @@ -192,11 +192,11 @@ }, '') return text }, - toDetails(item) { - uni.navigateTo({ - url: `../orderDetails/index?orderId=${item.id}` - }) - }, + // toDetails(item) { + // uni.navigateTo({ + // url: `../orderDetails/index?orderId=${item.id}` + // }) + // }, getTopInfo(){ serve.getTopInfo(this.paramter).then(res => { if (res.code === 20000) { @@ -246,7 +246,7 @@ uni.navigateTo({ url: `../productUpdate/index?id=${item.id}` }) - + }, upDownFrame(item) { this.productData = item @@ -260,7 +260,7 @@ }else if(this.productData.productStatus ==2){ data.productStatus = 1 } - + serve.productStatus(data).then(res=>{ uni.showToast({ title: res.msg, @@ -489,7 +489,7 @@ width: 160rpx; } } - + .header{ font-size: 32rpx; color: #000; diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index 5d9665e..0f9f715 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -6,14 +6,14 @@ - + 下一步 - - + + @@ -74,20 +74,20 @@ {{item.attributeName}}: - - + + - + - + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 {{item.label}} 确定 - + * 规格: @@ -131,7 +131,7 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取消 - 下一步 + 下一步 - - - - - - - + + + + + + + 商品类型: - - {{item.attributeName}}: - - - - - - - + + {{item.attributeName}}: + + + + + + + - + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} - 确定 + + + + + + + + + + + + + + 确定 + * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + {{radioAttributes}} + {{radioAttributes}}+{{checkboxAttributes[index]}} @@ -106,44 +111,45 @@ - 删除 + 删除 * 商品图片: 最多可上传10张图片 + + + + + 商品主图 + - - - - 商品主图 - - - - - 设为主图 - - + + + 设为主图 + - - - - + + + + - + + - - - 上一步 - 完成 + + + 上一步 + 完成 + - - + @@ -155,44 +161,64 @@ import serve from '@/api/packageIntegral/productList.js' import mulpicker from '@/packageIntegral/components/mulpicker.vue' export default { - components: { - mulpicker - }, + components: { + mulpicker + }, data() { return { currentBoxId: 'chooseType', //当前显示的view的id isBoxShow: false, - productDate:{ - productStatus:'1', - images:[] + productDate: { + productStatus: '1', + images: [] }, - productList:[], - brandIdList:[], - radioItem:[{ - name: '新品', - checked: true - }, { - name: '推荐', - checked: false - }], - rules:{ - demandRegion:{rules:[{required: true,errorMessage: '请选择商品分类'}]}, - productName:{rules:[{required: true,errorMessage: '请输入商品名称'}]}, - brandId:{rules:[{required: true,errorMessage: '请选择商品品牌'}]}, - price:{rules:[{required: true,errorMessage: '请输入商品售价'}]}, - }, - attributesTypeList:[], - attributesList:[], - bottonList:[ - {label:'市场价格',value:'marketPrice',checked:false}, - {label:'销售价格',value:'sellPrice',checked:false}, - {label:'商品库存',value:'stock',checked:false}, - {label:'兑换积分',value:'integral',checked:false} - ], - radioAttributes:'', - checkboxAttributes:[], - stockList:[], - checkedList:[] + productList: [], + brandIdList: [], + radioItem: [{ + name: '新品', + checked: true + }, { + name: '推荐', + checked: false + }], + rules: { + demandRegion: { + rules: [{ + required: true, + errorMessage: '请选择商品分类' + }] + }, + productName: { + rules: [{ + required: true, + errorMessage: '请输入商品名称' + }] + }, + brandId: { + rules: [{ + required: true, + errorMessage: '请选择商品品牌' + }] + }, + price: { + rules: [{ + required: true, + errorMessage: '请输入商品售价' + }] + }, + }, + attributesTypeList: [], + attributesList: [], + bottonList: [{ + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + }], + radioAttributes: '', + checkboxAttributes: [], + stockList: [], + checkedList: [] } }, @@ -201,515 +227,579 @@ this.getProductBrands() this.getAttributesType() }, - watch:{ - 'productDate.demandRegion'(val){ - if(val){ + watch: { + 'productDate.demandRegion'(val) { + if (val) { this.productDate.categoryOneId = val.split(',')[0] this.productDate.categoryTwoId = val.split(',')[1] } }, - 'productDate.attributesTypeId'(val){ - if(!val){ + 'productDate.attributesTypeId'(val) { + if (!val) { this.stockList = [] } } }, methods: { - switchChange(e){ - if(e.detail.value == true){ + switchChange(e) { + if (e.detail.value == true) { this.productDate.productStatus = '1' - }else if(e.detail.value == false){ + } else if (e.detail.value == false) { this.productDate.productStatus = '2' } }, - classfication(){ - serve.classification().then(res=>{ + classfication() { + serve.classification().then(res => { this.productList = res.data }) }, - getProductBrands(){ + getProductBrands() { this.brandIdList = [] - serve.getProductBrands().then(res=>{ - console.log(res) - res.data.forEach(tab=>{ - this.brandIdList.push({value:tab.id,text:tab.brandName}) + serve.getProductBrands().then(res => { + res.data.forEach(tab => { + this.brandIdList.push({ + value: tab.id, + text: tab.brandName + }) }) - + }) }, - checkbox (e) { - var index = e;//获取当前点击的下标 - var checkboxArr = this.radioItem;//选项集合 - // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 - // checkboxArr.forEach(item => { - // item.checked = false - // }) - if(checkboxArr[index].checked ==false){ - checkboxArr[index].checked = true; //改变当前选中的checked值 + checkbox(e) { + var index = e; //获取当前点击的下标 + var checkboxArr = this.radioItem; //选项集合 + // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 + // checkboxArr.forEach(item => { + // item.checked = false + // }) + if (checkboxArr[index].checked == false) { + checkboxArr[index].checked = true; //改变当前选中的checked值 - }else { - checkboxArr[index].checked = false; //改变当前选中的checked值 - } - if(checkboxArr[0].checked ==true){ - this.productDate.newMark = 1 - }else{ - this.productDate.newMark = 2 - } - if(checkboxArr[1].checked ==true){ - this.productDate.recommend = 1 - }else{ - this.productDate.recommend = 2 - } - - }, - changeBox(e){ - let currentFlag = e.currentTarget.id; - if(currentFlag == 'next'){ - this.$refs.productForm.validate().then(res=>{ - console.log('表单数据信息:', res); - switch(currentFlag){ - case 'next': - this.currentBoxId = 'instruction' - break; - case 'previous': - this.currentBoxId = 'chooseType' - break; - default: - this.currentBoxId = 'viewInstruction' - break; + } else { + checkboxArr[index].checked = false; //改变当前选中的checked值 + } + if (checkboxArr[0].checked == true) { + this.productDate.newMark = 1 + } else { + this.productDate.newMark = 2 + } + if (checkboxArr[1].checked == true) { + this.productDate.recommend = 1 + } else { + this.productDate.recommend = 2 + } + + }, + changeBox(e) { + let currentFlag = e.currentTarget.id; + if (currentFlag == 'next') { + this.$refs.productForm.validate().then(res => { + switch (currentFlag) { + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; } - if(currentFlag == 'next'){ + if (currentFlag == 'next') { this.getAttributesType() } - }).catch(err =>{ - console.log('表单错误信息:', err); - }) - }else{ - switch(currentFlag){ - case 'next': - this.currentBoxId = 'instruction' - break; - case 'previous': - this.currentBoxId = 'chooseType' - break; - default: - this.currentBoxId = 'viewInstruction' - break; + }).catch(err => {}) + } else { + switch (currentFlag) { + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; } } - - }, - getAttributesType(){ - this.attributesTypeList = [] - serve.getAttributesType().then(res=>{ - res.data.forEach(tab=>{ + + }, + getAttributesType() { + this.attributesTypeList = [] + serve.getAttributesType().then(res => { + res.data.forEach(tab => { this.attributesTypeList.push({ - value:tab.id, - text:tab.name, - number:tab.number, - attributesList:tab.attributesList - }) + value: tab.id, + text: tab.name, + number: tab.number, + attributesList: tab.attributesList + }) }) - }) - }, - attributesData(){ - if(this.productDate.attributesTypeId){ - this.attributesTypeList.forEach(tab=>{ - if(tab.id = this.productDate.attributesTypeId){ - this.attributesList = tab.attributesList - this.attributesList.forEach(tab=>{ - tab.attributesList = [] - tab.attributeContent.split(',').forEach(item=>{ - tab.attributesList.push({value:item,text:item}) - }) - }) - - } - }) - }else{ - this.attributesList = [] - } - - }, - changeRadio(item,index){ - if(JSON.stringify(this.checkedList) == '[]'){ - this.checkedList.push({attributeId:item.id,checked:item.attributeName}) - }else{ - this.checkedList[index].checked = item.attributeName - } - }, - changeCheckBox(item,index){ - if(this.checkedList.length{ - checked.push(tab) - }) - this.checkedList[index].checked = checked.join(',') - this.checkedList.checked - } - }, - deleteCheckAll(i){ - if(this.checkboxAttributes.length>1){ - this.checkboxAttributes.splice(i,1) - }else{ - this.checkboxAttributes.splice(i,1) - this.radioAttributes = '' - } - this.stockList.splice(i,1) - }, - deleteRadio(){ - this.radioAttributes = '' - }, - changeChecked(item){ - item.checked = !item.checked - }, - addStockList(){ - this.stockList = [] - let obj = { - marketPrice:'', - sellPrice:'', - stock:'', - integral:'' - } - if(this.attributesList.length ==1){ - let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - }else{ - this.checkboxAttributes.forEach((tab,index)=>{ - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - let tabName = this.attributesList[index+1].attributeName - let tabValue = tab - data[name] = value - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - }) - - } - }, - //调起上传图片 - srcFileImage() { - let _that = this - let imageUrl = '' - uni.chooseImage({ - count: 10, //默认9 - sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 - sourceType: ['album'], //从相册选择 - success: function(res) { - console.log(res) - const JSESSIONID = utils.uuid() - uni.uploadFile({ - url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile', - filePath: res.tempFilePaths[0], - formData: { - ossKey: 'xingyou', - pathKey: 'publicxingyou', - encrypt: 'PUBLIC', - }, - name: 'file', - header: { - "Content-Type": "multipart/form-data", - "Authorization": uni.getStorageSync('Authorization'), - 'dataSources': 'MP', - "imei": uni.getStorageSync('unionid'), - "openId": uni.getStorageSync('openid'), - 'JSESSIONID': JSESSIONID, - 'token': utils.md5Salt(JSESSIONID) - }, - success(e) { - let obj = JSON.parse(e.data), - imageUrl = obj.data.publicUrl - _that.getImage(imageUrl) - }, - fail(err) { - } - }) - },fail() { - console.log('相机调用失败') - } - }) - }, - getImage(imageUrl){ - if(JSON.stringify(this.productDate.images) == '[]'){ - this.productDate.images.push({ - url:imageUrl, - mainMark:1 - }) - }else{ - this.productDate.images.push({ - url:imageUrl, - mainMark:'' - }) - } - }, - setMainImage(index){ - this.productDate.images.forEach((tab,i)=>{ - if(i == index){ - tab.mainMark = 1 - }else{ - tab.mainMark = '' - } - }) - }, - clearImage(index){ - if(this.productDate.images[index].mainMark == 1){ - this.productDate.images.splice(index,1) - this.productDate.images[0].mainMark = 1 - }else{ - this.productDate.images.splice(index,1) + }) + }, + attributesData() { + this.bottonList = [{ + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + }] + this.stockList = [] + this.radioAttributes = '' + this.checkboxAttributes = [] + if (this.productDate.attributesTypeId) { + this.attributesTypeList.forEach(tab => { + if (tab.value == this.productDate.attributesTypeId) { + this.attributesList = tab.attributesList + this.attributesList.forEach(tab => { + tab.attributesList = [] + tab.attributeContent.split(',').forEach(item => { + tab.attributesList.push({ + value: item, + text: item + }) + }) + }) + + } + }) + } else { + this.attributesList = [] } - }, - closed(){ - uni.navigateTo({ - url: '/pages/index/index' - }) - }, - addCompleted(){ - if(this.radioItem[0].checked =true){ + + }, + changeRadio(item, index) { + if (JSON.stringify(this.checkedList) == '[]') { + this.checkedList.push({ + attributeId: item.id, + checked: this.radioAttributes + }) + } else { + this.checkedList[index].checked = this.radioAttributes + } + this.stockCheck() + }, + changeCheckBox(item, index) { + if (this.checkedList.length < index + 1) { + this.checkedList.push({ + attributeId: item.id, + checked: this.radioAttributes + }) + } else { + let checked = [] + this.checkboxAttributes.forEach(tab => { + checked.push(tab) + }) + this.checkedList[index].checked = checked.join(',') + this.checkedList.checked + } + this.stockCheck() + }, + stockCheck() { + this.stockList = [] + let obj = { + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + } + if (this.attributesList.length == 1) { + let data = {} + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + data[name] = value + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + } else { + this.attributesList.forEach((item, ind) => { + if (ind != 0) { + this.checkboxAttributes.forEach((tab, index) => { + let data = {} + let tabName = this.attributesList[ind].attributeName + let tabValue = tab + data[tabName] = tabValue + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) + } + }) + + + } + }, + deleteCheckAll(i) { + if (this.checkboxAttributes.length > 1) { + this.checkboxAttributes.splice(i, 1) + } else { + this.checkboxAttributes.splice(i, 1) + this.radioAttributes = '' + } + this.stockList.splice(i, 1) + }, + deleteRadio() { + this.radioAttributes = '' + }, + changeChecked(item) { + item.checked = !item.checked + }, + addStockList() { + this.stockList.forEach(tab => { + tab.marketPrice = this.bottonList[0].marketPrice + tab.sellPrice = this.bottonList[0].sellPrice + tab.stock = this.bottonList[0].stock + tab.integral = this.bottonList[0].integral + }) + }, + //调起上传图片 + srcFileImage() { + let _that = this + let imageUrl = '' + uni.chooseImage({ + count: 10, //默认9 + sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album'], //从相册选择 + success: function(res) { + const JSESSIONID = utils.uuid() + uni.uploadFile({ + url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile', + filePath: res.tempFilePaths[0], + formData: { + ossKey: 'xingyou', + pathKey: 'publicxingyou', + encrypt: 'PUBLIC', + }, + name: 'file', + header: { + "Content-Type": "multipart/form-data", + "Authorization": uni.getStorageSync('Authorization'), + 'dataSources': 'MP', + "imei": uni.getStorageSync('unionid'), + "openId": uni.getStorageSync('openid'), + 'JSESSIONID': JSESSIONID, + 'token': utils.md5Salt(JSESSIONID) + }, + success(e) { + let obj = JSON.parse(e.data), + imageUrl = obj.data.publicUrl + _that.getImage(imageUrl) + }, + fail(err) {} + }) + }, + fail() { + console.log('相机调用失败') + } + }) + }, + getImage(imageUrl) { + if (JSON.stringify(this.productDate.images) == '[]') { + this.productDate.images.push({ + url: imageUrl, + mainMark: 1 + }) + } else { + this.productDate.images.push({ + url: imageUrl, + mainMark: '' + }) + } + }, + setMainImage(items, index) { + let obj = items + obj.mainMark = 1 + this.productDate.images.splice(index, 1) + this.productDate.images.forEach((tab, i) => { + tab.mainMark = '' + }) + + this.productDate.images.unshift(obj) + }, + clearImage(index) { + if (this.productDate.images[index].mainMark == 1) { + this.productDate.images.splice(index, 1) + this.productDate.images[0].mainMark = 1 + } else { + this.productDate.images.splice(index, 1) + } + }, + closed() { + uni.navigateTo({ + url: '/pages/index/index' + }) + }, + addCompleted() { + if (this.radioItem[0].checked = true) { this.productDate.newMark == '1' - }else{ - this.productDate.newMark == '2' - } - if(this.radioItem[1].checked =true){ - this.productDate.recommend == '1' - }else{ - this.productDate.recommend == '2' - } - this.productDate.checkedList = this.checkedList - this.productDate.stockList = this.stockList - serve.saveProduct(this.productDate).then(res=>{ - console.log(res) - uni.showToast({ - title: res.msg, - icon: 'none' - }) - this.closed() - }) - } + } else { + this.productDate.newMark == '2' + } + if (this.radioItem[1].checked = true) { + this.productDate.recommend == '1' + } else { + this.productDate.recommend == '2' + } + this.productDate.checkedList = this.checkedList + this.productDate.stockList = this.stockList + serve.saveProduct(this.productDate).then(res => { + uni.showToast({ + title: res.msg, + icon: 'none' + }) + this.closed() + }) + } } } + } + + .show { + display: flex; + flex-wrap: wrap; + } + + .hidden { + display: none; + } + \ No newline at end of file diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index 6a7a5dd..a1b0ed8 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -10,16 +10,15 @@ @click="selectOptions(index)">{{item.text}}({{item.count}}) - + - {{item.productStatus =='1'?'已上架':'未上架'}} @@ -29,7 +28,8 @@ 库存:{{item.totalStock}} {{statusEnum[item.auditStatus].value}} + :style="{background:statusEnum[item.auditStatus].color}">{{statusEnum[item.auditStatus].value}} + 删除 编辑 @@ -128,7 +128,7 @@ count: 0, value: '' }], - identifying:{ + identifying: { 1: { background: '#F83D3D', opacity: 1, @@ -154,8 +154,8 @@ value: "已驳回" }, }, - examineDetailList:[], - productData:{} + examineDetailList: [], + productData: {} } }, @@ -167,17 +167,17 @@ methods: { selectOptions(index) { this.currentIndex = index - console.log(index,'index') - if(index == 0){ - this.paramter.params ={} - }else if(index ==1){ - this.paramter.params ={} + console.log(index, 'index') + if (index == 0) { + this.paramter.params = {} + } else if (index == 1) { + this.paramter.params = {} this.paramter.params.productStatus = 1 - }else if(index ==2){ - this.paramter.params ={} + } else if (index == 2) { + this.paramter.params = {} this.paramter.params.productStatus = 2 - }else if(index ==3){ - this.paramter.params ={} + } else if (index == 3) { + this.paramter.params = {} this.paramter.params.auditStatus = 1 } this.productByPage() @@ -197,7 +197,7 @@ // url: `../orderDetails/index?orderId=${item.id}` // }) // }, - getTopInfo(){ + getTopInfo() { serve.getTopInfo(this.paramter).then(res => { if (res.code === 20000) { this.optionsList[0].count = res.data.count @@ -233,16 +233,18 @@ this.paramter.currentPage += 1 this.productByPage() }, - examineDetail(item){ - serve.productAuditHistory({id:item.id}).then(res=>{ + examineDetail(item) { + serve.productAuditHistory({ + id: item.id + }).then(res => { this.examineDetailList = res.data }) this.$refs.detail.open('center') }, - orderDelete(){ + orderDelete() { this.$refs.delete.open('center') }, - toEditOrder(item){ + toEditOrder(item) { uni.navigateTo({ url: `../productUpdate/index?id=${item.id}` }) @@ -252,16 +254,16 @@ this.productData = item this.$refs.popup.open('center') }, - submitProduct(){ + submitProduct() { let data = {} data.id = this.productData.id - if(this.productData.productStatus ==1){ + if (this.productData.productStatus == 1) { data.productStatus = 2 - }else if(this.productData.productStatus ==2){ + } else if (this.productData.productStatus == 2) { data.productStatus = 1 } - serve.productStatus(data).then(res=>{ + serve.productStatus(data).then(res => { uni.showToast({ title: res.msg, icon: 'none' @@ -297,6 +299,7 @@ background: #FFF; } + >.options-frame { display: flex; justify-content: space-between; @@ -354,7 +357,7 @@ color: #666; border-top: 1rpx solid #D7D7D7; - .identifying{ + .identifying { width: 120rpx; height: 60rpx; line-height: 60rpx; @@ -404,7 +407,8 @@ } } } - .examine{ + + .examine { width: 120rpx; height: 45rpx; color: #FFF; @@ -438,14 +442,16 @@ border-radius: 10rpx; } - >.button{ - &:nth-of-type(1){ + >.button { + &:nth-of-type(1) { right: 360rpx; } - &:nth-of-type(2){ + + &:nth-of-type(2) { right: 200rpx; } - &:nth-of-type(3){ + + &:nth-of-type(3) { right: 40rpx; } @@ -467,30 +473,35 @@ color: #000; margin-bottom: 20rpx; } - >uni-icons{ + + >uni-icons { position: absolute; top: 30rpx; right: 30rpx; } - >.item{ + + >.item { display: flex; justify-content: space-evenly; overflow-y: hidden; font-size: 22rpx; color: #666; padding: 10rpx; - view{ + + view { width: 240rpx; line-height: 46rpx; } - >.status{ + + >.status { width: 160rpx; - >view{ + + >view { width: 160rpx; } } - .header{ + .header { font-size: 32rpx; color: #000; } @@ -574,4 +585,4 @@ } } - + \ No newline at end of file diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index 0f9f715..4b5748b 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -2,147 +2,156 @@ 返回 - 新增商品 + 编辑商品 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取消 - 下一步 + 下一步 - - - - - + + + + + 商品类型: - - {{item.attributeName}}: - - - - + + {{item.attributeName}}: + + + + - - + + 批量填充:批量填充填入信息后,可以批量将内容填写到SKU 信息里 - {{item.label}} - 确定 + + + + + + + + + + + + + + 确定 + + + - + * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + {{radioAttributes}} + {{radioAttributes}}+{{checkboxAttributes[index]}} - + - + - + - + - 删除 + 删除 * 商品图片: 最多可上传10张图片 + + + + + 商品主图 + - - - - 商品主图 - - - - - 设为主图 - - + + + 设为主图 + - - - - + + + + + - - - 上一步 - 完成 + + + 上一步 + 完成 + - @@ -155,102 +164,129 @@ import serve from '@/api/packageIntegral/productList.js' import mulpicker from '@/packageIntegral/components/mulpicker.vue' export default { - components: { - mulpicker - }, + components: { + mulpicker + }, data() { return { currentBoxId: 'chooseType', //当前显示的view的id isBoxShow: false, - productDate:{ - productStatus:'1', - images:[] + productDate: { + productStatus: '1', + images: [] }, - productList:[], - brandIdList:[], - radioItem:[{ - name: '新品', - checked: true - }, { - name: '推荐', - checked: false - }], - rules:{ - demandRegion:{rules:[{required: true,errorMessage: '请选择商品分类'}]}, - productName:{rules:[{required: true,errorMessage: '请输入商品名称'}]}, - brandId:{rules:[{required: true,errorMessage: '请选择商品品牌'}]}, - price:{rules:[{required: true,errorMessage: '请输入商品售价'}]}, - }, - attributesTypeList:[], - attributesList:[], - bottonList:[ - {label:'市场价格',value:'marketPrice',checked:false}, - {label:'销售价格',value:'sellPrice',checked:false}, - {label:'商品库存',value:'stock',checked:false}, - {label:'兑换积分',value:'integral',checked:false} - ], - radioAttributes:'', - checkboxAttributes:[], - stockList:[], - checkedList:[] + productList: [], + brandIdList: [], + radioItem: [{ + name: '新品', + checked: true + }, { + name: '推荐', + checked: false + }], + rules: { + demandRegion: { + rules: [{ + required: true, + errorMessage: '请选择商品分类' + }] + }, + productName: { + rules: [{ + required: true, + errorMessage: '请输入商品名称' + }] + }, + brandId: { + rules: [{ + required: true, + errorMessage: '请选择商品品牌' + }] + }, + price: { + rules: [{ + required: true, + errorMessage: '请输入商品售价' + }] + }, + }, + attributesTypeList: [], + attributesList: [], + bottonList: [{ + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + }], + radioAttributes: '', + checkboxAttributes: [], + stockList: [], + checkedList: [] } }, onLoad(options) { - console.log(options,'options') this.getEdit(options) this.classfication() this.getProductBrands() this.getAttributesType() }, - watch:{ - 'productDate.demandRegion'(val){ - if(val){ + watch: { + 'productDate.demandRegion'(val) { + if (val) { this.productDate.categoryOneId = val.split(',')[0] this.productDate.categoryTwoId = val.split(',')[1] } }, - 'productDate.attributesTypeId'(val){ - if(!val){ - this.stockList = [] - } - } + 'productDate.attributesTypeId'(val) { + if (!val) { + this.stockList = [] + } + } }, methods: { - getEdit(options){ - serve.getEdit(options.id).then(res=>{ - if(res.code === 20000&&res.data!=null){ + getEdit(options) { + serve.getEdit(options.id).then(res => { + if (res.code === 20000 && res.data != null) { this.productDate = res.data - this.productDate.demandRegion = res.data.categoryOneId+','+res.data.categoryTwoId - if(this.productDate.newMark == '1'){ - this.radioItem[0].checked =true - }else{ - this.radioItem[0].checked =false + this.productDate.demandRegion = res.data.categoryOneId + ',' + res.data.categoryTwoId + if (this.productDate.newMark == '1') { + this.radioItem[0].checked = true + } else { + this.radioItem[0].checked = false } - if(this.productDate.recommend == '1'){ - this.radioItem[1].checked =true - }else{ - this.radioItem[1].checked =false + if (this.productDate.recommend == '1') { + this.radioItem[1].checked = true + } else { + this.radioItem[1].checked = false } - this.attributesTypeList.forEach(tab=>{ - if(tab.id = this.productDate.attributesTypeId){ + this.attributesTypeList.forEach(tab => { + if (tab.value == this.productDate.attributesTypeId) { this.attributesList = tab.attributesList - this.attributesList.forEach(tab=>{ + this.attributesList.forEach(tab => { tab.attributesList = [] - tab.attributeContent.split(',').forEach(item=>{ - tab.attributesList.push({value:item,text:item}) + tab.attributeContent.split(',').forEach(item => { + tab.attributesList.push({ + value: item, + text: item + }) }) }) } }) this.checkedList = this.productDate.checkedList - if(this.productDate.checkedList.length==1){ + if (this.productDate.checkedList.length == 1) { this.radioAttributes = this.productDate.checkedList[0].checked - }else{ + } else { this.checkboxAttributes = [] - this.productDate.checkedList.forEach((tab,index)=>{ - if(index!=0){ - this.checkboxAttributes.push(tab.checked) + this.productDate.checkedList.forEach((tab, index) => { + if (index == 0) { + this.radioAttributes = this.productDate.checkedList[0].checked + } else { + tab.checked.split(',').forEach(item => { + this.checkboxAttributes.push(item) + }) + } }) } @@ -258,498 +294,561 @@ } - console.log(res.data) }) }, - switchChange(e){ - if(e.detail.value == true){ + switchChange(e) { + if (e.detail.value == true) { this.productDate.productStatus = '1' - }else if(e.detail.value == false){ + } else if (e.detail.value == false) { this.productDate.productStatus = '2' } }, - classfication(){ - serve.classification().then(res=>{ + classfication() { + serve.classification().then(res => { this.productList = res.data }) }, - getProductBrands(){ + getProductBrands() { this.brandIdList = [] - serve.getProductBrands().then(res=>{ - console.log(res) - res.data.forEach(tab=>{ - this.brandIdList.push({value:tab.id,text:tab.brandName}) + serve.getProductBrands().then(res => { + res.data.forEach(tab => { + this.brandIdList.push({ + value: tab.id, + text: tab.brandName + }) }) }) }, - checkbox (e) { - var index = e;//获取当前点击的下标 - var checkboxArr = this.radioItem;//选项集合 - // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 - // checkboxArr.forEach(item => { - // item.checked = false - // }) - if(checkboxArr[index].checked ==false){ - checkboxArr[index].checked = true; //改变当前选中的checked值 + checkbox(e) { + var index = e; //获取当前点击的下标 + var checkboxArr = this.radioItem; //选项集合 + // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 + // checkboxArr.forEach(item => { + // item.checked = false + // }) + if (checkboxArr[index].checked == false) { + checkboxArr[index].checked = true; //改变当前选中的checked值 - }else { - checkboxArr[index].checked = false; //改变当前选中的checked值 - } - if(checkboxArr[0].checked ==true){ - this.productDate.newMark = 1 - }else{ - this.productDate.newMark = 2 - } - if(checkboxArr[1].checked ==true){ - this.productDate.recommend = 1 - }else{ - this.productDate.recommend = 2 - } + } else { + checkboxArr[index].checked = false; //改变当前选中的checked值 + } + if (checkboxArr[0].checked == true) { + this.productDate.newMark = 1 + } else { + this.productDate.newMark = 2 + } + if (checkboxArr[1].checked == true) { + this.productDate.recommend = 1 + } else { + this.productDate.recommend = 2 + } - }, - changeBox(e){ - let currentFlag = e.currentTarget.id; - if(currentFlag == 'next'){ - this.$refs.productForm.validate().then(res=>{ - console.log('表单数据信息:', res); - switch(currentFlag){ - case 'next': - this.currentBoxId = 'instruction' - break; - case 'previous': - this.currentBoxId = 'chooseType' - break; - default: - this.currentBoxId = 'viewInstruction' - break; - } - if(currentFlag == 'next'){ - this.getAttributesType() - } - }).catch(err =>{ - console.log('表单错误信息:', err); - }) - }else{ - switch(currentFlag){ - case 'next': - this.currentBoxId = 'instruction' - break; - case 'previous': - this.currentBoxId = 'chooseType' - break; - default: - this.currentBoxId = 'viewInstruction' - break; - } - } + }, + changeBox(e) { + let currentFlag = e.currentTarget.id; + if (currentFlag == 'next') { + this.$refs.productForm.validate().then(res => { + switch (currentFlag) { + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; + } + if (currentFlag == 'next') { + this.getAttributesType() + } + }).catch(err => {}) + } else { + switch (currentFlag) { + case 'next': + this.currentBoxId = 'instruction' + break; + case 'previous': + this.currentBoxId = 'chooseType' + break; + default: + this.currentBoxId = 'viewInstruction' + break; + } + } - }, - getAttributesType(){ - this.attributesTypeList = [] - serve.getAttributesType().then(res=>{ - res.data.forEach(tab=>{ + }, + getAttributesType() { + this.attributesTypeList = [] + serve.getAttributesType().then(res => { + res.data.forEach(tab => { this.attributesTypeList.push({ - value:tab.id, - text:tab.name, - number:tab.number, - attributesList:tab.attributesList - }) + value: tab.id, + text: tab.name, + number: tab.number, + attributesList: tab.attributesList + }) }) }) - }, - attributesData(){ - if(this.productDate.attributesTypeId){ - this.attributesTypeList.forEach(tab=>{ - if(tab.id = this.productDate.attributesTypeId){ - this.attributesList = tab.attributesList - this.attributesList.forEach(tab=>{ - tab.attributesList = [] - tab.attributeContent.split(',').forEach(item=>{ - tab.attributesList.push({value:item,text:item}) - }) - }) + }, + attributesData() { + this.bottonList = [{ + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + }] + this.stockList = [] + this.radioAttributes = '' + this.checkboxAttributes = [] + if (this.productDate.attributesTypeId) { + this.attributesTypeList.forEach(tab => { + if (tab.value == this.productDate.attributesTypeId) { + this.attributesList = tab.attributesList + this.attributesList.forEach(tab => { + tab.attributesList = [] + tab.attributeContent.split(',').forEach(item => { + tab.attributesList.push({ + value: item, + text: item + }) + }) + }) - } - }) - }else{ - this.attributesList = [] - } - - }, - changeRadio(item,index){ - if(JSON.stringify(this.checkedList) == '[]'){ - this.checkedList.push({attributeId:item.id,checked:item.attributeName}) - }else{ - this.checkedList[index].checked = item.attributeName - } - }, - changeCheckBox(item,index){ - if(this.checkedList.length{ - checked.push(tab) - }) - this.checkedList[index].checked = checked.join(',') - this.checkedList.checked - } - }, - deleteCheckAll(i){ - if(this.checkboxAttributes.length>1){ - this.checkboxAttributes.splice(i,1) - }else{ - this.checkboxAttributes.splice(i,1) - this.radioAttributes = '' - } - this.stockList.splice(i,1) - }, - deleteRadio(){ - this.radioAttributes = '' - }, - changeChecked(item){ - item.checked = !item.checked - }, - addStockList(){ - this.stockList = [] - let obj = { - marketPrice:'', - sellPrice:'', - stock:'', - integral:'' - } - if(this.attributesList.length ==1){ - let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - }else{ - this.checkboxAttributes.forEach((tab,index)=>{ - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - let tabName = this.attributesList[index+1].attributeName - let tabValue = tab - data[name] = value - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - }) - - } - }, - //调起上传图片 - srcFileImage() { - let _that = this - let imageUrl = '' - uni.chooseImage({ - count: 10, //默认9 - sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 - sourceType: ['album'], //从相册选择 - success: function(res) { - const JSESSIONID = utils.uuid() - uni.uploadFile({ - url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile', - filePath: res.tempFilePaths[0], - formData: { - ossKey: 'xingyou', - pathKey: 'publicxingyou', - encrypt: 'PUBLIC', - }, - name: 'file', - header: { - "Content-Type": "multipart/form-data", - "Authorization": uni.getStorageSync('Authorization'), - 'dataSources': 'MP', - "imei": uni.getStorageSync('unionid'), - "openId": uni.getStorageSync('openid'), - 'JSESSIONID': JSESSIONID, - 'token': utils.md5Salt(JSESSIONID) - }, - success(e) { - let obj = JSON.parse(e.data), - imageUrl = obj.data.publicUrl - _that.getImage(imageUrl) - }, - fail(err) { - } - }) - },fail() { - console.log('相机调用失败') - } - }) - }, - getImage(imageUrl){ - if(JSON.stringify(this.productDate.images) == '[]'){ - this.productDate.images.push({ - url:imageUrl, - mainMark:1 - }) - }else{ - this.productDate.images.push({ - url:imageUrl, - mainMark:'' - }) - } - }, - setMainImage(index){ - this.productDate.images.forEach((tab,i)=>{ - if(i == index){ - tab.mainMark = 1 - }else{ - tab.mainMark = '' - } - }) - }, - clearImage(index){ - if(this.productDate.images[index].mainMark == 1){ - this.productDate.images.splice(index,1) - this.productDate.images[0].mainMark = 1 - }else{ - this.productDate.images.splice(index,1) + } + }) + } else { + this.attributesList = [] } - }, - closed(){ - uni.navigateBack() - }, - addCompleted(){ - if(this.radioItem[0].checked =true){ + + }, + changeRadio(item, index) { + if (JSON.stringify(this.checkedList) == '[]') { + this.checkedList.push({ + attributeId: item.id, + checked: this.radioAttributes + }) + } else { + this.checkedList[index].checked = this.radioAttributes + } + this.stockCheck() + + }, + changeCheckBox(item, index) { + if (this.checkedList.length < index + 1) { + this.checkedList.push({ + attributeId: item.id, + checked: this.radioAttributes + }) + } else { + let checked = [] + this.checkboxAttributes.forEach(tab => { + checked.push(tab) + }) + this.checkedList[index].checked = checked.join(',') + this.checkedList.checked + } + this.stockCheck() + + }, + stockCheck() { + this.stockList = [] + let obj = { + marketPrice: '', + sellPrice: '', + stock: '', + integral: '' + } + if (this.attributesList.length == 1) { + let data = {} + let name = this.attributesList[0].attributeName + let value = this.radioAttributes + data[name] = value + obj.attributeJson = JSON.stringify(data) + this.stockList.push(obj) + } else { + this.attributesList.forEach((item, ind) => { + if (ind != 0) { + this.checkboxAttributes.forEach((tab, index) => { + let data = {} + let tabName = this.attributesList[ind].attributeName + let tabValue = tab + data[tabName] = tabValue + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) + } + }) + + + } + }, + deleteCheckAll(i) { + if (this.checkboxAttributes.length > 1) { + this.checkboxAttributes.splice(i, 1) + } else { + this.checkboxAttributes.splice(i, 1) + this.radioAttributes = '' + } + this.stockList.splice(i, 1) + }, + deleteRadio() { + this.radioAttributes = '' + }, + addStockList() { + this.stockList.forEach(tab => { + tab.marketPrice = this.bottonList[0].marketPrice + tab.sellPrice = this.bottonList[0].sellPrice + tab.stock = this.bottonList[0].stock + tab.integral = this.bottonList[0].integral + }) + }, + //调起上传图片 + srcFileImage() { + let _that = this + let imageUrl = '' + uni.chooseImage({ + count: 10, //默认9 + sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album'], //从相册选择 + success: function(res) { + const JSESSIONID = utils.uuid() + uni.uploadFile({ + url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile', + filePath: res.tempFilePaths[0], + formData: { + ossKey: 'xingyou', + pathKey: 'publicxingyou', + encrypt: 'PUBLIC', + }, + name: 'file', + header: { + "Content-Type": "multipart/form-data", + "Authorization": uni.getStorageSync('Authorization'), + 'dataSources': 'MP', + "imei": uni.getStorageSync('unionid'), + "openId": uni.getStorageSync('openid'), + 'JSESSIONID': JSESSIONID, + 'token': utils.md5Salt(JSESSIONID) + }, + success(e) { + let obj = JSON.parse(e.data), + imageUrl = obj.data.publicUrl + _that.getImage(imageUrl) + }, + fail(err) {} + }) + }, + fail() { + console.log('相机调用失败') + } + }) + }, + getImage(imageUrl) { + if (JSON.stringify(this.productDate.images) == '[]') { + this.productDate.images.push({ + url: imageUrl, + mainMark: 1 + }) + } else { + this.productDate.images.push({ + url: imageUrl, + mainMark: '' + }) + } + }, + setMainImage(items, index) { + let obj = items + obj.mainMark = 1 + this.productDate.images.splice(index, 1) + this.productDate.images.forEach((tab, i) => { + tab.mainMark = '' + }) + + this.productDate.images.unshift(obj) + }, + clearImage(index) { + if (this.productDate.images[index].mainMark == 1) { + this.productDate.images.splice(index, 1) + this.productDate.images[0].mainMark = 1 + } else { + this.productDate.images.splice(index, 1) + } + }, + closed() { + uni.navigateBack() + }, + addCompleted() { + if (this.radioItem[0].checked = true) { this.productDate.newMark == '1' - }else{ - this.productDate.newMark == '2' - } - if(this.radioItem[1].checked =true){ - this.productDate.recommend == '1' - }else{ - this.productDate.recommend == '2' - } - this.productDate.checkedList = this.checkedList - this.productDate.stockList = this.stockList - serve.updateProduct(this.productDate).then(res=>{ - uni.showToast({ - title: res.msg, - icon: 'none' - }) - uni.navigateTo({ - url: `../productList/index` - }) - }) - } + } else { + this.productDate.newMark == '2' + } + if (this.radioItem[1].checked = true) { + this.productDate.recommend == '1' + } else { + this.productDate.recommend == '2' + } + this.productDate.checkedList = this.checkedList + this.productDate.stockList = this.stockList + serve.updateProduct(this.productDate).then(res => { + uni.showToast({ + title: res.msg, + icon: 'none' + }) + uni.navigateTo({ + url: `../productList/index` + }) + }) + } } } + } + + .show { + display: flex; + flex-wrap: wrap; + } + + .hidden { + display: none; + } + \ No newline at end of file diff --git a/pages.json b/pages.json index 5a51986..74e0572 100644 --- a/pages.json +++ b/pages.json @@ -108,6 +108,21 @@ "style": {} }] }, + { + "root": "packageElectron", + "pages": [{ + "path": "index", + "style": {} + }, + { + "path": "reconciliationDetails/index", + "style": {} + }, { + "path": "components/autograph", + "style": {} + } + ] + }, { "root": "packageOrders", "pages": [{ diff --git a/pages/home/home.vue b/pages/home/home.vue index fd18300..0d0bd4c 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -445,6 +445,12 @@ obj.color = 'blue', obj.badge = 0 obj.name = list.roleName + }else if (list.roleName == '电子对账单') { + obj.cuIcon = 'punch', + obj.path = '/packageElectron/index', + obj.color = 'blue', + obj.badge = 0 + obj.name = list.roleName } return obj }, -- 2.49.1 From dfbafd8ea803aab41d4477834ad80c6e8d5bf5e9 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Tue, 16 Apr 2024 17:16:00 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=94=B5=E5=AD=90=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/packageElectron/packageElectron.js | 18 + api/packageIntegral/productList.js | 7 + components/my-sign/index.js | 16 + components/my-sign/my-sign.vue | 320 ++++++++++++++++++ packageElectron/components/autograph.vue | 188 +++++++++- packageElectron/index.vue | 257 ++++++-------- .../reconciliationDetails/index.vue | 192 ++++++++++- packageIntegral/productAddition/index.vue | 168 +++++++-- packageIntegral/productList/index.vue | 23 +- packageIntegral/productUpdate/index.vue | 169 +++++++-- pages.json | 20 +- 11 files changed, 1171 insertions(+), 207 deletions(-) create mode 100644 api/packageElectron/packageElectron.js create mode 100644 components/my-sign/index.js create mode 100644 components/my-sign/my-sign.vue diff --git a/api/packageElectron/packageElectron.js b/api/packageElectron/packageElectron.js new file mode 100644 index 0000000..0e69b48 --- /dev/null +++ b/api/packageElectron/packageElectron.js @@ -0,0 +1,18 @@ +import request from '@/utils/request' + +export default{ + getByPage(data) { + return request({ + url: `/oil-finance/xoilSiteElectronicStatement/getByPage`, + method: 'post', + data + }) + }, + update(data) { + return request({ + url: `/oil-finance/xoilSiteElectronicStatement/update`, + method: 'PUT', + data + }) + } +} \ No newline at end of file diff --git a/api/packageIntegral/productList.js b/api/packageIntegral/productList.js index 84df717..6077a23 100644 --- a/api/packageIntegral/productList.js +++ b/api/packageIntegral/productList.js @@ -66,4 +66,11 @@ export default{ data }) }, + deleteProductById(data) { // 删除商品接口 + return request({ + url: `/oil-mall/mobile/deleteProductById`, + method: 'post', + data + }) + }, } \ No newline at end of file diff --git a/components/my-sign/index.js b/components/my-sign/index.js new file mode 100644 index 0000000..ab58258 --- /dev/null +++ b/components/my-sign/index.js @@ -0,0 +1,16 @@ +/** + * 判断是否未数值 + * @param {Object} val + */ +export function isNumber(val) { + return !isNaN(Number(val)) +} + +/** + * 处理大小单位 + * @param {Object} val + */ +export function formatSize(val, unit = 'rpx') { + return isNumber(val) ? `${val}${unit}` : val +} + diff --git a/components/my-sign/my-sign.vue b/components/my-sign/my-sign.vue new file mode 100644 index 0000000..352095a --- /dev/null +++ b/components/my-sign/my-sign.vue @@ -0,0 +1,320 @@ + + + + + diff --git a/packageElectron/components/autograph.vue b/packageElectron/components/autograph.vue index 02409e3..39d4cc0 100644 --- a/packageElectron/components/autograph.vue +++ b/packageElectron/components/autograph.vue @@ -1,8 +1,192 @@ - \ No newline at end of file + + diff --git a/packageElectron/index.vue b/packageElectron/index.vue index ff853b0..e991e75 100644 --- a/packageElectron/index.vue +++ b/packageElectron/index.vue @@ -2,29 +2,33 @@ 返回 - 商品列表 + 电子对账单 {{item.text}}({{item.count}}) + @click="selectOptions(index)">{{item.text}} - - - {{item.productName}} - 规格:默认 - 库存:{{item.totalStock}} - - - 删除 - 编辑 + + {{item.id}} + + 结算周期: + {{item.beginReconciliationTime}}至 {{item.endReconciliationTime}} + + 结算金额:{{item.statementAmount}}元 + 推送时间:{{item.reviewTime?item.reviewTime:'暂无'}} + + 点击确认 + 已确认 + 金额有误 + + - @@ -35,12 +39,9 @@ - \ No newline at end of file diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 54e42f7..7df9313 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -51,12 +51,12 @@ - + + placeholder="请选择规格" @change="attributesData"> - 商品类型: + 商品规格: @@ -170,6 +170,7 @@ isBoxShow: false, productDate: { productStatus: '1', + newMark: 1, images: [] }, productList: [], @@ -268,16 +269,18 @@ checkbox(e) { var index = e; //获取当前点击的下标 var checkboxArr = this.radioItem; //选项集合 - // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 - // checkboxArr.forEach(item => { - // item.checked = false - // }) - if (checkboxArr[index].checked == false) { - checkboxArr[index].checked = true; //改变当前选中的checked值 + if (checkboxArr[index].checked) return; //如果点击的当前已选中则返回 + checkboxArr.forEach(item => { + item.checked = false + }) + checkboxArr[index].checked = true; //改变当前选中的checked值 - } else { - checkboxArr[index].checked = false; //改变当前选中的checked值 - } + // if (checkboxArr[index].checked == false) { + // checkboxArr[index].checked = true; //改变当前选中的checked值 + + // } else { + // checkboxArr[index].checked = false; //改变当前选中的checked值 + // } if (checkboxArr[0].checked == true) { this.productDate.newMark = 1 } else { @@ -294,6 +297,13 @@ let currentFlag = e.currentTarget.id; if (currentFlag == 'next') { this.$refs.productForm.validate().then(res => { + if (this.isNumber(this.productDate.price) == false) { + uni.showToast({ + title: '商品售价不是数字', + icon: 'none' + }) + return + } switch (currentFlag) { case 'next': this.currentBoxId = 'instruction' @@ -383,7 +393,7 @@ if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: this.radioAttributes + checked: item.attributesList[index].value }) } else { let checked = [] @@ -456,7 +466,7 @@ let _that = this let imageUrl = '' uni.chooseImage({ - count: 10, //默认9 + count: 1, //默认9 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], //从相册选择 success: function(res) { @@ -493,17 +503,25 @@ }) }, getImage(imageUrl) { - if (JSON.stringify(this.productDate.images) == '[]') { - this.productDate.images.push({ - url: imageUrl, - mainMark: 1 - }) + if (this.productDate.images.length < 10) { + if (JSON.stringify(this.productDate.images) == '[]') { + this.productDate.images.push({ + url: imageUrl, + mainMark: 1 + }) + } else { + this.productDate.images.push({ + url: imageUrl, + mainMark: '' + }) + } } else { - this.productDate.images.push({ - url: imageUrl, - mainMark: '' + uni.showToast({ + title: '最多只能上传十张图片~', + icon: 'none' }) } + }, setMainImage(items, index) { let obj = items @@ -528,6 +546,9 @@ url: '/pages/index/index' }) }, + isNumber(value) { + return /^[0-9]+$/.test(value); + }, addCompleted() { if (this.radioItem[0].checked = true) { this.productDate.newMark == '1' @@ -539,6 +560,109 @@ } else { this.productDate.recommend == '2' } + if (!this.productDate.attributesTypeId) { + uni.showToast({ + title: '请选择请选择规格', + icon: 'none' + }) + return + } + if(this.attributesList.length==1){ + if(!this.radioAttributes){ + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } + } + if(this.attributesList.length>1){ + if(JSON.stringify(this.checkboxAttributes) == '[]'){ + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } + } + if (JSON.stringify(this.stockList.length) == '[]') { + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } else { + this.stockList.forEach(tab => { + + if (!tab.marketPrice) { + uni.showToast({ + title: '市场价格必填!', + icon: 'none' + }) + throw Error(`市场价格必填!`) + } else { + if (this.isNumber(tab.marketPrice) == false) { + uni.showToast({ + title: '市场价格不是数字!', + icon: 'none' + }) + throw Error(`市场价格不是数字!`) + } + } + if (!tab.sellPrice) { + uni.showToast({ + title: '销售价格必填!', + icon: 'none' + }) + throw Error(`销售价格必填!`) + } else { + if (this.isNumber(tab.sellPrice) == false) { + uni.showToast({ + title: '销售价格不是数字!', + icon: 'none' + }) + throw Error(`销售价格不是数字!`) + } + } + if (!tab.stock) { + uni.showToast({ + title: '库存数量必填!', + icon: 'none' + }) + throw Error(`库存数量必填!`) + } else { + if (this.isNumber(tab.stock) == false) { + uni.showToast({ + title: '库存数量不是数字!', + icon: 'none' + }) + throw Error(`库存数量不是数字!`) + } + } + if (!tab.integral) { + uni.showToast({ + title: '积分价值必填!', + icon: 'none' + }) + throw Error(`积分价值必填!`) + } else { + if (this.isNumber(tab.integral) == false) { + uni.showToast({ + title: '积分价值不是数字!', + icon: 'none' + }) + throw Error(`积分价值不是数字!`) + } + } + }) + } + if (JSON.stringify(this.productDate.images) == '[]') { + uni.showToast({ + title: '请上传商品图片', + icon: 'none' + }) + return + } this.productDate.checkedList = this.checkedList this.productDate.stockList = this.stockList serve.saveProduct(this.productDate).then(res => { diff --git a/packageIntegral/productList/index.vue b/packageIntegral/productList/index.vue index a1b0ed8..286d7ac 100644 --- a/packageIntegral/productList/index.vue +++ b/packageIntegral/productList/index.vue @@ -31,9 +31,9 @@ :style="{background:statusEnum[item.auditStatus].color}">{{statusEnum[item.auditStatus].value}} - 删除 + 删除 编辑 - {{item.productStatus =='1'?'上架':'下架'}} + {{item.productStatus =='1'?'下架':'上架'}} @@ -72,7 +72,7 @@ 是否删除该商品? 取消 - 确认 + 确认 @@ -167,7 +167,7 @@ methods: { selectOptions(index) { this.currentIndex = index - console.log(index, 'index') + this.paramter.currentPage = 1 if (index == 0) { this.paramter.params = {} } else if (index == 1) { @@ -215,7 +215,7 @@ productByPage() { serve.productByPage(this.paramter).then(res => { if (res.code === 20000) { - if (!res.data.list.length) { + if (!res.data.list.length&&this.paramter.currentPage!=1) { uni.showToast({ title: '没有更多订单啦~', icon: 'none' @@ -241,8 +241,19 @@ }) this.$refs.detail.open('center') }, - orderDelete() { + orderDelete(item) { this.$refs.delete.open('center') + this.deleteData = item + }, + deleteIntegral(){ + serve.deleteProductById({id:this.deleteData.id}).then(res=>{ + uni.showToast({ + title: res.msg, + icon: 'none' + }) + this.$refs.delete.close() + this.search() + }) }, toEditOrder(item) { uni.navigateTo({ diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index 4b5748b..6ad39e6 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -51,12 +51,12 @@ - + + placeholder="请选择规格" @change="attributesData"> - 商品类型: + 商品规格: @@ -323,16 +323,18 @@ checkbox(e) { var index = e; //获取当前点击的下标 var checkboxArr = this.radioItem; //选项集合 - // if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回 - // checkboxArr.forEach(item => { - // item.checked = false - // }) - if (checkboxArr[index].checked == false) { - checkboxArr[index].checked = true; //改变当前选中的checked值 + if (checkboxArr[index].checked) return; //如果点击的当前已选中则返回 + checkboxArr.forEach(item => { + item.checked = false + }) + checkboxArr[index].checked = true; //改变当前选中的checked值 - } else { - checkboxArr[index].checked = false; //改变当前选中的checked值 - } + // if (checkboxArr[index].checked == false) { + // checkboxArr[index].checked = true; //改变当前选中的checked值 + + // } else { + // checkboxArr[index].checked = false; //改变当前选中的checked值 + // } if (checkboxArr[0].checked == true) { this.productDate.newMark = 1 } else { @@ -349,6 +351,13 @@ let currentFlag = e.currentTarget.id; if (currentFlag == 'next') { this.$refs.productForm.validate().then(res => { + if (this.isNumber(this.productDate.price) == false) { + uni.showToast({ + title: '商品售价请输入数字', + icon: 'none' + }) + return + } switch (currentFlag) { case 'next': this.currentBoxId = 'instruction' @@ -439,7 +448,7 @@ if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: this.radioAttributes + checked: item.attributesList[index].value }) } else { let checked = [] @@ -541,21 +550,28 @@ fail(err) {} }) }, - fail() { - console.log('相机调用失败') + fail(err) { + console.log('相机调用失败',err) } }) }, getImage(imageUrl) { - if (JSON.stringify(this.productDate.images) == '[]') { - this.productDate.images.push({ - url: imageUrl, - mainMark: 1 - }) + if (this.productDate.images.length < 10) { + if (JSON.stringify(this.productDate.images) == '[]') { + this.productDate.images.push({ + url: imageUrl, + mainMark: 1 + }) + } else { + this.productDate.images.push({ + url: imageUrl, + mainMark: '' + }) + } } else { - this.productDate.images.push({ - url: imageUrl, - mainMark: '' + uni.showToast({ + title: '最多只能上传十张图片~', + icon: 'none' }) } }, @@ -580,6 +596,9 @@ closed() { uni.navigateBack() }, + isNumber(value) { + return /^[0-9]+$/.test(value); + }, addCompleted() { if (this.radioItem[0].checked = true) { this.productDate.newMark == '1' @@ -591,6 +610,108 @@ } else { this.productDate.recommend == '2' } + if(this.attributesList.length==1){ + if(!this.radioAttributes){ + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } + } + if(this.attributesList.length>1){ + if(JSON.stringify(this.checkboxAttributes) == '[]'){ + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } + } + if (!this.productDate.attributesTypeId) { + uni.showToast({ + title: '请选择规格', + icon: 'none' + }) + return + } + if (JSON.stringify(this.stockList.length) == '[]') { + uni.showToast({ + title: '请选择商品规格', + icon: 'none' + }) + return + } else { + this.stockList.forEach(tab => { + if (!tab.marketPrice) { + uni.showToast({ + title: '市场价格必填!', + icon: 'none' + }) + throw Error(`市场价格必填!`) + } else { + if (this.isNumber(tab.marketPrice) == false) { + uni.showToast({ + title: '市场价格不是数字!', + icon: 'none' + }) + throw Error(`市场价格不是数字!`) + } + } + if (!tab.sellPrice) { + uni.showToast({ + title: '销售价格必填!', + icon: 'none' + }) + throw Error(`销售价格必填!`) + } else { + if (this.isNumber(tab.sellPrice) == false) { + uni.showToast({ + title: '销售价格不是数字!', + icon: 'none' + }) + throw Error(`销售价格不是数字!`) + } + } + if (!tab.stock) { + uni.showToast({ + title: '库存数量必填!', + icon: 'none' + }) + throw Error(`库存数量必填!`) + } else { + if (this.isNumber(tab.stock) == false) { + uni.showToast({ + title: '库存数量不是数字!', + icon: 'none' + }) + throw Error(`库存数量不是数字!`) + } + } + if (!tab.integral) { + uni.showToast({ + title: '积分价值必填!', + icon: 'none' + }) + throw Error(`积分价值必填!`) + } else { + if (this.isNumber(tab.integral) == false) { + uni.showToast({ + title: '积分价值不是数字!', + icon: 'none' + }) + throw Error(`积分价值不是数字!`) + } + } + }) + } + if (JSON.stringify(this.productDate.images) == '[]') { + uni.showToast({ + title: '请上传商品图片', + icon: 'none' + }) + return + } this.productDate.checkedList = this.checkedList this.productDate.stockList = this.stockList serve.updateProduct(this.productDate).then(res => { @@ -598,7 +719,7 @@ title: res.msg, icon: 'none' }) - uni.navigateTo({ + wx.navigateBack({ url: `../productList/index` }) }) diff --git a/pages.json b/pages.json index 74e0572..462adcb 100644 --- a/pages.json +++ b/pages.json @@ -91,19 +91,19 @@ "pages": [{ "path": "takeGoods/index", "style": {} - },{ + }, { "path": "orderDetails/index", "style": {} - },{ + }, { "path": "orderList/index", "style": {} - },{ + }, { "path": "productList/index", "style": {} - },{ + }, { "path": "productAddition/index", "style": {} - },{ + }, { "path": "productUpdate/index", "style": {} }] @@ -119,7 +119,13 @@ "style": {} }, { "path": "components/autograph", - "style": {} + "style": { + "navigationBarTitleText": "签字", + "enablePullDownRefresh": false, + "pageOrientation": "landscape", + "backgroundColor": "#f8f8f8", + "navigationStyle": "custom" + } } ] }, @@ -299,4 +305,4 @@ } -} +} \ No newline at end of file -- 2.49.1 From 2796a734f6d3e6c6838e52bed5a6281318a3c1fa Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Wed, 17 Apr 2024 15:18:22 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=8D=95=E9=80=89=E6=94=B9=E5=A4=9A=E9=80=89=EF=BC=8C=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E5=AF=B9=E8=B4=A6=E5=8D=95=E9=99=90=E5=88=B6=E5=88=B0?= =?UTF-8?q?=E6=B2=B9=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageElectron/index.vue | 14 +- packageIntegral/productAddition/index.vue | 166 +++++++++----------- packageIntegral/productUpdate/index.vue | 175 +++++++++------------- 3 files changed, 148 insertions(+), 207 deletions(-) diff --git a/packageElectron/index.vue b/packageElectron/index.vue index e991e75..3803aac 100644 --- a/packageElectron/index.vue +++ b/packageElectron/index.vue @@ -48,7 +48,9 @@ paramter: { currentPage: 1, pagesize: 20, - params: {}, + params: { + siteId: uni.getStorageSync('oilSitePriceId') + }, }, dataList: [], optionsList: [{ @@ -63,7 +65,7 @@ }, { text: '金额异常', value: '' - }], + }] } @@ -77,22 +79,22 @@ selectOptions(index) { this.currentIndex = index this.paramter.currentPage = 1 + this.paramter.params ={ + siteId: uni.getStorageSync('oilSitePriceId') + } if(index == 0){ - this.paramter.params ={} this.paramter.params.status = '5' }else if(index ==1){ - this.paramter.params ={} this.paramter.params.status = '1' }else if(index ==2){ - this.paramter.params ={} this.paramter.params.status = '2' }else if(index ==3){ - this.paramter.params ={} this.paramter.params.status = '3' } this.getByPage() }, getByPage(){ + // this.parameter.params.siteId = this.siteId serve.getByPage(this.paramter).then(res=>{ if (res.code === 20000) { if (!res.data.list.length&&this.paramter.currentPage!=1) { diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 7df9313..dc32b42 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -62,10 +62,8 @@ {{item.attributeName}}: - - @@ -95,9 +93,10 @@ * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + + {{value}} + + {{value}} + @@ -139,10 +138,6 @@ - 上一步 @@ -216,8 +211,7 @@ stock: '', integral: '' }], - radioAttributes: '', - checkboxAttributes: [], + stockList: [], checkedList: [] } @@ -275,12 +269,6 @@ }) checkboxArr[index].checked = true; //改变当前选中的checked值 - // if (checkboxArr[index].checked == false) { - // checkboxArr[index].checked = true; //改变当前选中的checked值 - - // } else { - // checkboxArr[index].checked = false; //改变当前选中的checked值 - // } if (checkboxArr[0].checked == true) { this.productDate.newMark = 1 } else { @@ -355,14 +343,13 @@ integral: '' }] this.stockList = [] - this.radioAttributes = '' - this.checkboxAttributes = [] if (this.productDate.attributesTypeId) { this.attributesTypeList.forEach(tab => { if (tab.value == this.productDate.attributesTypeId) { this.attributesList = tab.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes=[] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -378,34 +365,53 @@ } }, - changeRadio(item, index) { - if (JSON.stringify(this.checkedList) == '[]') { - this.checkedList.push({ - attributeId: item.id, - checked: this.radioAttributes - }) - } else { - this.checkedList[index].checked = this.radioAttributes - } - this.stockCheck() - }, changeCheckBox(item, index) { if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: item.attributesList[index].value + checked: item.checkboxAttributes[index] }) } else { let checked = [] - this.checkboxAttributes.forEach(tab => { + item.checkboxAttributes.forEach(tab => { checked.push(tab) }) this.checkedList[index].checked = checked.join(',') - this.checkedList.checked } - this.stockCheck() + let arrays = [] + this.attributesList.forEach(tab=>{ + arrays.push(tab.checkboxAttributes) + }) + let arrList = this.combineArrays(arrays) + this.stockCheck(arrList) }, - stockCheck() { + combineArrays(arr) { + if (arr.length === 0) { + return []; + } else if (arr.length === 1) { + return arr[0]; + } else if (arr.length === 2 && JSON.stringify(arr[1])=='[]') { + let result = []; + arr[0].forEach(tab=>{ + result.push([tab]) + }) + return result; + } else { + let result = []; + let subCombinations = this.combineArrays(arr.slice(1)); + for (let elem of arr[0]) { + if (Array.isArray(subCombinations)) { + for (let subComb of subCombinations) { + result.push([elem].concat(subComb)); + } + } else { + result.push([elem, subCombinations]); + } + } + return result; + } + }, + stockCheck(arrList) { this.stockList = [] let obj = { marketPrice: '', @@ -413,46 +419,23 @@ stock: '', integral: '' } - if (this.attributesList.length == 1) { + arrList.forEach(tab=>{ let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - } else { - this.attributesList.forEach((item, ind) => { - if (ind != 0) { - this.checkboxAttributes.forEach((tab, index) => { - let data = {} - let tabName = this.attributesList[ind].attributeName - let tabValue = tab - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - let stockObj = JSON.parse(JSON.stringify(obj)) - this.stockList.push(stockObj) - }) - } + let tabName = '' + let tabValue = '' + tab.forEach((item,i)=>{ + tabName = this.attributesList[i].attributeName + tabValue = item + data[tabName] = tabValue }) - - - } + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) }, deleteCheckAll(i) { - if (this.checkboxAttributes.length > 1) { - this.checkboxAttributes.splice(i, 1) - } else { - this.checkboxAttributes.splice(i, 1) - this.radioAttributes = '' - } this.stockList.splice(i, 1) }, - deleteRadio() { - this.radioAttributes = '' - }, - changeChecked(item) { - item.checked = !item.checked - }, addStockList() { this.stockList.forEach(tab => { tab.marketPrice = this.bottonList[0].marketPrice @@ -550,16 +533,16 @@ return /^[0-9]+$/.test(value); }, addCompleted() { - if (this.radioItem[0].checked = true) { - this.productDate.newMark == '1' - } else { - this.productDate.newMark == '2' - } - if (this.radioItem[1].checked = true) { - this.productDate.recommend == '1' - } else { - this.productDate.recommend == '2' - } + if (this.radioItem[0].checked = true) { + this.productDate.newMark == 1 + } else { + this.productDate.newMark == 2 + } + if (this.radioItem[1].checked = true) { + this.productDate.recommend == 1 + } else { + this.productDate.recommend == 2 + } if (!this.productDate.attributesTypeId) { uni.showToast({ title: '请选择请选择规格', @@ -567,26 +550,17 @@ }) return } - if(this.attributesList.length==1){ - if(!this.radioAttributes){ + this.attributesList.forEach(tab=>{ + if(JSON.stringify(tab.checkboxAttributes) == '[]'){ uni.showToast({ title: '请选择商品规格', icon: 'none' }) - return + throw Error(`请选择商品规格!`) } - } - if(this.attributesList.length>1){ - if(JSON.stringify(this.checkboxAttributes) == '[]'){ - uni.showToast({ - title: '请选择商品规格', - icon: 'none' - }) - return - } - } + }) if (JSON.stringify(this.stockList.length) == '[]') { - uni.showToast({ + uni.showToast({ title: '请选择商品规格', icon: 'none' }) @@ -926,4 +900,4 @@ .hidden { display: none; } - \ No newline at end of file + diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index 6ad39e6..19421c4 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -62,10 +62,8 @@ {{item.attributeName}}: - - @@ -98,9 +96,10 @@ * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + + {{value}} + + {{value}} + @@ -142,10 +141,6 @@ - 上一步 @@ -218,8 +213,7 @@ stock: '', integral: '' }], - radioAttributes: '', - checkboxAttributes: [], + stockList: [], checkedList: [] } @@ -260,11 +254,12 @@ } else { this.radioItem[1].checked = false } - this.attributesTypeList.forEach(tab => { - if (tab.value == this.productDate.attributesTypeId) { - this.attributesList = tab.attributesList + this.attributesTypeList.forEach(tabs => { + if (tabs.value == this.productDate.attributesTypeId) { + this.attributesList = tabs.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes = [] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -275,21 +270,9 @@ } }) this.checkedList = this.productDate.checkedList - if (this.productDate.checkedList.length == 1) { - this.radioAttributes = this.productDate.checkedList[0].checked - } else { - this.checkboxAttributes = [] - this.productDate.checkedList.forEach((tab, index) => { - if (index == 0) { - this.radioAttributes = this.productDate.checkedList[0].checked - } else { - tab.checked.split(',').forEach(item => { - this.checkboxAttributes.push(item) - }) - - } - }) - } + this.productDate.checkedList.forEach((tab, index) => { + this.attributesList[index].checkboxAttributes = tab.checked.split(',') + }) this.stockList = this.productDate.stockList @@ -329,12 +312,6 @@ }) checkboxArr[index].checked = true; //改变当前选中的checked值 - // if (checkboxArr[index].checked == false) { - // checkboxArr[index].checked = true; //改变当前选中的checked值 - - // } else { - // checkboxArr[index].checked = false; //改变当前选中的checked值 - // } if (checkboxArr[0].checked == true) { this.productDate.newMark = 1 } else { @@ -409,14 +386,13 @@ integral: '' }] this.stockList = [] - this.radioAttributes = '' - this.checkboxAttributes = [] if (this.productDate.attributesTypeId) { this.attributesTypeList.forEach(tab => { if (tab.value == this.productDate.attributesTypeId) { this.attributesList = tab.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes = [] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -431,37 +407,55 @@ this.attributesList = [] } - }, - changeRadio(item, index) { - if (JSON.stringify(this.checkedList) == '[]') { - this.checkedList.push({ - attributeId: item.id, - checked: this.radioAttributes - }) - } else { - this.checkedList[index].checked = this.radioAttributes - } - this.stockCheck() - }, changeCheckBox(item, index) { if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: item.attributesList[index].value + checked: item.checkboxAttributes[index] }) } else { let checked = [] - this.checkboxAttributes.forEach(tab => { + item.checkboxAttributes.forEach(tab => { checked.push(tab) }) this.checkedList[index].checked = checked.join(',') - this.checkedList.checked } - this.stockCheck() + let arrays = [] + this.attributesList.forEach(tab => { + arrays.push(tab.checkboxAttributes) + }) + let arrList = this.combineArrays(arrays) + this.stockCheck(arrList) }, - stockCheck() { + combineArrays(arr) { + if (arr.length === 0) { + return []; + } else if (arr.length === 1) { + return arr[0]; + } else if (arr.length === 2 && JSON.stringify(arr[1]) == '[]') { + let result = []; + arr[0].forEach(tab => { + result.push([tab]) + }) + return result; + } else { + let result = []; + let subCombinations = this.combineArrays(arr.slice(1)); + for (let elem of arr[0]) { + if (Array.isArray(subCombinations)) { + for (let subComb of subCombinations) { + result.push([elem].concat(subComb)); + } + } else { + result.push([elem, subCombinations]); + } + } + return result; + } + }, + stockCheck(arrList) { this.stockList = [] let obj = { marketPrice: '', @@ -469,43 +463,23 @@ stock: '', integral: '' } - if (this.attributesList.length == 1) { + arrList.forEach(tab => { let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - } else { - this.attributesList.forEach((item, ind) => { - if (ind != 0) { - this.checkboxAttributes.forEach((tab, index) => { - let data = {} - let tabName = this.attributesList[ind].attributeName - let tabValue = tab - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - let stockObj = JSON.parse(JSON.stringify(obj)) - this.stockList.push(stockObj) - }) - } + let tabName = '' + let tabValue = '' + tab.forEach((item, i) => { + tabName = this.attributesList[i].attributeName + tabValue = item + data[tabName] = tabValue }) - - - } + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) }, deleteCheckAll(i) { - if (this.checkboxAttributes.length > 1) { - this.checkboxAttributes.splice(i, 1) - } else { - this.checkboxAttributes.splice(i, 1) - this.radioAttributes = '' - } this.stockList.splice(i, 1) }, - deleteRadio() { - this.radioAttributes = '' - }, addStockList() { this.stockList.forEach(tab => { tab.marketPrice = this.bottonList[0].marketPrice @@ -551,7 +525,7 @@ }) }, fail(err) { - console.log('相机调用失败',err) + console.log('相机调用失败', err) } }) }, @@ -601,33 +575,24 @@ }, addCompleted() { if (this.radioItem[0].checked = true) { - this.productDate.newMark == '1' + this.productDate.newMark == 1 } else { - this.productDate.newMark == '2' + this.productDate.newMark == 2 } if (this.radioItem[1].checked = true) { - this.productDate.recommend == '1' + this.productDate.recommend == 1 } else { - this.productDate.recommend == '2' + this.productDate.recommend == 2 } - if(this.attributesList.length==1){ - if(!this.radioAttributes){ + this.attributesList.forEach(tab => { + if (JSON.stringify(tab.checkboxAttributes) == '[]') { uni.showToast({ title: '请选择商品规格', icon: 'none' }) - return + throw Error(`请选择商品规格!`) } - } - if(this.attributesList.length>1){ - if(JSON.stringify(this.checkboxAttributes) == '[]'){ - uni.showToast({ - title: '请选择商品规格', - icon: 'none' - }) - return - } - } + }) if (!this.productDate.attributesTypeId) { uni.showToast({ title: '请选择规格', -- 2.49.1