瀏覽代碼

产品分类

zhaoxiaohai 3 年之前
父節點
當前提交
d202636946

+ 44 - 16
components/My_MultipleChoice/index.js

@@ -19,32 +19,32 @@ Component({
         /* 回调 */
         optionChange: {
             type: Function
+        },
+        /* 类型,默认供需分类 */
+        type: {
+            type: String,
+            value: 'mr'
         }
     },
     lifetimes: {
         attached: function () {
             // 在组件实例进入页面节点树时执行
-            _Http.basic({
+            //默认供需分类
+            let data = {
                 "accesstoken": wx.getStorageSync('userData').token,
                 "classname": "enterprise.system.supplyanddemand",
                 "method": "query_typeselectList",
                 "content": {}
-            }).then(res => {
+            };
+            if (this.data.type == 'product') data = {
+                "accesstoken": wx.getStorageSync('userData').token,
+                "classname": "enterprise.system.prodclass",
+                "method": "query_typeselectList",
+                "content": {}
+            };
+            _Http.basic(data).then(res => {
                 console.log(res)
-                if (res.msg != "成功") return;
-                let dataList = []
-                for (let i = 0; i < res.data.length; i++) {
-                    let checked = false;
-                    if (res.data[i].ftype == this.data.pitchOnItem) checked = true;
-                    dataList.push({
-                        value: res.data[i].ftype,
-                        index: i,
-                        checked: checked
-                    })
-                }
-                this.setData({
-                    dataList
-                })
+                this.returnClassify(res);
             })
         },
     },
@@ -81,6 +81,34 @@ Component({
             this.setData({
                 dataList
             })
+        },
+        /* 返回分类 */
+        returnClassify(res) {
+            if (res.msg != "成功") return wx.showToast({
+                title: '数据加载失败,请重新进入页面',
+                icon: "none",
+                duration: 5000
+            })
+            let dataList = []
+            for (let i = 0; i < res.data.length; i++) {
+                let checked = false,
+                    value = "";
+                if (this.data.type == 'product') {
+                    if (res.data[i] == this.data.pitchOnItem) checked = true;
+                    value = res.data[i];
+                } else if (this.data.type == 'mr') {
+                    if (res.data[i].ftype == this.data.pitchOnItem) checked = true;
+                    value = res.data[i].ftype;
+                }
+                dataList.push({
+                    value,
+                    index: i,
+                    checked: checked
+                })
+            }
+            this.setData({
+                dataList
+            })
         }
     }
 })

+ 32 - 5
pages/productManagement/change.js

@@ -14,6 +14,7 @@ Page({
         fprodname: "", //产品名称
         fprodnum: "", //产品编码
         attinfos: [], //附件列表
+        categoryListings: [], //类别列表
         fintroduction: "", //产品说明
         //ftag: [],产品标签
         showSaleprod: "", //标签显示
@@ -25,14 +26,23 @@ Page({
             fprodname: false,
             fprodnum: false,
             showSaleprod: false,
-        }
+            fprodclassname: false
+        },
+        fprodclassname: "", //产品分类
+        pupShow: false, //弹出层控制
+    },
+    selection() {
+        this.setData({
+            pupShow: !this.data.pupShow
+        })
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        console.log(options.data)
         if (options.data) {
-            const data = JSON.parse(options.data)
+            const data = JSON.parse(options.data);
             console.log(data)
             let attinfos = [];
             for (let i = 0; i < data.attinfos.length; i++) {
@@ -41,7 +51,8 @@ Page({
                     ownerid: data.attinfos[i].ownerid,
                     tattachmentid: data.attinfos[i].tattachmentid,
                     ownertable: data.attinfos[i].ownertable,
-                    fdocument: data.attinfos[i].fdocument
+                    fdocument: data.attinfos[i].fdocument,
+                    fprodclassname: data.attinfos[i].fprodclassname
                 }
                 attinfos.push(arr)
             };
@@ -70,8 +81,17 @@ Page({
                 tagents_productid: data.tagents_productid, //识别产品ID
                 showSaleprod, // 显示标签
                 checked, //是否上架
+                fprodclassname: data.fprodclassname
             });
-        }
+        };
+    },
+    /* 回调 */
+    optionChangeCallBack(e) {
+        this.setData({
+            fprodclassname: e.detail,
+            pupShow: false,
+            "errTips.fprodclassname": false
+        })
     },
 
     /**
@@ -118,6 +138,12 @@ Page({
             errTips.fprodnum = true;
             verify = false;
         }
+
+        /* 验证产品分类  */
+        if (!_Verify.required(this.data.fprodclassname)) {
+            errTips.fprodclassname = true;
+            verify = false;
+        }
         /* 验证附件列表  */
         if (!_Verify.required(this.data.attinfos, "请上传产品图片")) {
             errTips.fprodnum = true;
@@ -140,7 +166,8 @@ Page({
                 "fprodnum": this.data.fprodnum,
                 "fprodname": this.data.fprodname,
                 "fintroduction": this.data.fintroduction,
-                "fisonsale": this.data.fisonsale
+                "fisonsale": this.data.fisonsale,
+                "fprodclassname": this.data.fprodclassname
             }
         }).then(res => {
             console.log(res)

+ 2 - 1
pages/productManagement/change.json

@@ -2,6 +2,7 @@
     "usingComponents": {
         "van-switch": "@vant/weapp/switch/index",
         "My_UploadFiles": "/components/My_UploadFiles/index",
-        "My_inputPromptd": "/components/My_inputPromptd/index"
+        "My_inputPromptd": "/components/My_inputPromptd/index",
+        "My_MultipleChoice": "/components/My_MultipleChoice/index"
     }
 }

+ 8 - 1
pages/productManagement/change.wxml

@@ -18,6 +18,9 @@
             </view>
             <van-field autosize type="textarea" model:value="{{ showSaleprod }}" data-name="showSaleprod" input-class="input-class" bind:focus='inputFocus' bindblur='inputBlur' placeholder="点击填写" border="{{ false }}" />
         </My_GreyRectangleForm> -->
+        <My_GreyRectangleForm title="产品分类" required>
+            <text catchtap="selection" class="{{errTips.fprodclassname?'fprodclassname':''}}" style="opacity: {{fprodclassname?'1':'0.3'}};">{{fprodclassname?fprodclassname:'选择分类'}}</text>
+        </My_GreyRectangleForm>
 
         <My_GreyRectangleForm title="说明">
             <van-field model:value="{{ fintroduction }}" input-class="input-class" placeholder="点击填写" border="{{ false }}" />
@@ -33,4 +36,8 @@
 <!-- 提交按钮 -->
 <view class="submit_but">
     <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">保存</van-button>
-</view>
+</view>
+<van-action-sheet show="{{ pupShow }}" bind:click-overlay="selection">
+    <view class="pup-title">选择分类</view>
+    <My_MultipleChoice type='product' bind:optionChange="optionChangeCallBack" pitchOnItem='{{fprodclassname}}'></My_MultipleChoice>
+</van-action-sheet>

+ 16 - 2
pages/productManagement/change.wxss

@@ -5,9 +5,23 @@
 }
 
 /* 输入提示定位 */
-.input_text_tips{
+.input_text_tips {
     position: absolute;
     top: 0;
     left: 120rpx;
-    transform: translate(0,-110%);
+    transform: translate(0, -110%);
+}
+
+.pup-title {
+    height: 44rpx;
+    font-size: 32rpx;
+    font-family: PingFangSC-Medium, PingFang SC;
+    color: #000000;
+    line-height: 44rpx;
+    margin: 40rpx 0 0 54rpx;
+}
+
+.fprodclassname {
+    color: #F00F2B;
+    opacity: 1 !important;
 }

+ 1 - 1
pages/productManagement/index.json

@@ -3,6 +3,6 @@
     "My_MembersAndProducts": "/components/My_MembersAndProducts/index",
     "van-divider": "@vant/weapp/divider/index",
     "van-loading": "@vant/weapp/loading/index",
-    "My_SearchInputBox":"/components/My_SearchInputBox/index"
+    "My_SearchInputBox": "/components/My_SearchInputBox/index"
   }
 }

+ 2 - 2
pages/productManagement/index.wxml

@@ -11,7 +11,7 @@
                 <!-- 滚动区域 -->
                 <scroll-view scroll-y="true" style="max-height: 60vh;" lower-threshold="500px" scroll-top="0px" bindscrolltolower="scrolltolower">
                     <!-- 产品列表 -->
-                    <My_MembersAndProducts wx:for="{{productList}}" wx:key="{{item.tagents_productid}}" bind:changeMessage="changeProductMessage" data-index="{{index}}" attinfos="{{item.attinfos[0]}}" imgSize="120rpx" radius="8rpx" title="{{item.fprodname}}" twoRow="{{item.fintroduction}}" threeRow="{{item.ftag}}"  fisadministrator="{{fisadministrator}}"></My_MembersAndProducts>
+                    <My_MembersAndProducts wx:for="{{productList}}" wx:key="{{item.tagents_productid}}" bind:changeMessage="changeProductMessage" data-index="{{index}}" attinfos="{{item.attinfos[0]}}" imgSize="120rpx" radius="8rpx" title="{{item.fprodname}}" twoRow="{{item.fintroduction}}" threeRow="{{item.ftag}}" fisadministrator="{{fisadministrator}}"></My_MembersAndProducts>
                     <!-- 上拉到底,加载中样式 -->
                     <van-loading wx:if="{{pageTotal>pageNumber}}" style="width: 100%;display: flex; justify-content: center;" size="24px" color="#4BBECF">加载中...</van-loading>
                     <!-- 全部加载完成 -->
@@ -24,7 +24,7 @@
                 <!-- 滚动区域 -->
                 <scroll-view scroll-y="true" style="max-height: 60vh;" bindscrolltolower="scrolltolower">
                     <!-- 产品列表 -->
-                    <My_MembersAndProducts wx:for="{{productList}}" wx:key="{{item.tagents_productid}}" bind:changeMessage="changeProductMessage" data-index="{{index}}" attinfos="{{item.attinfos[0]}}" imgSize="120rpx" radius="8rpx" title="{{item.fprodname}}" twoRow="{{item.fintroduction}}" threeRow="{{item.ftag}}"  fisadministrator="{{fisadministrator}}"></My_MembersAndProducts>
+                    <My_MembersAndProducts wx:for="{{productList}}" wx:key="{{item.tagents_productid}}" bind:changeMessage="changeProductMessage" data-index="{{index}}" attinfos="{{item.attinfos[0]}}" imgSize="120rpx" radius="8rpx" title="{{item.fprodname}}" twoRow="{{item.fintroduction}}" threeRow="{{item.ftag}}" fisadministrator="{{fisadministrator}}"></My_MembersAndProducts>
                     <!-- 上拉到底,加载中样式 -->
                     <van-loading wx:if="{{pageTotal>pageNumber}}" style="width: 100%;display: flex; justify-content: center;" size="24px" color="#4BBECF">加载中...</van-loading>
                     <!-- 全部加载完成 -->