18016688350 4 anni fa
parent
commit
fcb7d6b43b

+ 1 - 1
pages/device/index.js

@@ -8,7 +8,7 @@ Page({
   data: {
     searchParams: {
       pageNo: 1,
-      pageSize: 10,
+      pageSize: 20,
       storeName:'',
     },
     storeList: [],

+ 86 - 69
pages/scheme/form.js

@@ -9,11 +9,14 @@ Page({
   data: {
     isEdit: false,
     storeList: [],
+    agentList:[],
+    userInfo: {},
     values: {
       storeId: '',
       storeName: '',
       schemeName: '',
-      schemeProductList: []
+      schemeBillEntryList: []
+      
     },
     id:''
   },
@@ -29,33 +32,20 @@ Page({
         id:options.id
       })
       that.bindScheme()
-    } else {
-      if (!that.data.isEdit) {
-       
-        var schemeProductList = []
-        for (var i = 1; i <= 22; i++) {
-          var item = {
-            schemeId: '',
-            productId: '',
-            productName: '请选择商品',
-            productImg: '',
-            productSchemePrice: 0,
-            storeDivide: 0,
-            gridNum:i
-          }
-          schemeProductList.push(item)
-
-        }
-        this.setData({
-          ["values.schemeProductList"]: schemeProductList
-        })
-        console.log("---------------------------------------")
-        console.log(this.data.values.schemeProductList)
-      }
-    }
+    } 
     wx.setNavigationBarTitle({
       title: that.data.isEdit ? '方案编辑' : '新增方案'
     })
+    this.setData({
+      userInfo: app.globalData.userInfo
+    })
+    this.getAllAgentList();
+    if(this.data.userInfo.mgvmRole==3){
+      this.setData({
+        ['values.agentId']: this.data.userInfo.id,
+        ['values.agentName']: this.data.userInfo.username,
+      })
+    }
     this.bindStoreList()
   },
   bindStorePickerChange: function (e) {
@@ -65,34 +55,66 @@ Page({
       ['values.storeName']: item.storeName
     })
   },
+  bindAgentPickerChange: function (e) {
+    var item = this.data.agentList[e.detail.value]
+    this.setData({
+      ['values.agentId']: item.id,
+      ['values.agentName']: item.username
+    })
+    this.bindStoreList()
+  },
+
   formSubmit: function (e) {
+    console.log(this.data.values.schemeBillEntryList)
     var that = this
     //表单规则
     let rules = [{
       name: "schemeName",
       rule: ["required"], //可使用区间,此处主要测试功能
       msg: ["请输入方案名称"]
+    },{
+      name: "storeName",
+      rule: ["required"], //可使用区间,此处主要测试功能
+      msg: ["请输入门店"]
     }];
+    if(this.data.userInfo.mgvmRole!=3){
+      var agentRule = {
+        name: "agentName",
+        rule: ["required"],
+        msg: ["请输入代理商"]
+      }
+      rules.push(agentRule)
+    }else{
+      this.setData({
+        ['values.agentId']: this.data.userInfo.id,
+        ['values.agentName']: this.data.userInfo.username,
+      })
+    }
+
     //进行表单检查
     let formData = e.detail.value;
     let checkRes = form.validation(formData, rules);
-    let schemeProductList = this.data.values.schemeProductList;
+    let schemeBillEntryList = this.data.values.schemeBillEntryList;
     var schemeProduct = [];
     var productCount = 0; 
-    for (let i = 0; i < schemeProductList.length; i++) {
-      if(schemeProductList[i].productId!=null&&schemeProductList[i].productId!=""){
-        schemeProduct.push(schemeProductList[i])
+    for (let i = 0; i < schemeBillEntryList.length; i++) {
+      if(schemeBillEntryList[i].productId!=null&&schemeBillEntryList[i].productId!=""){
+        schemeProduct.push(schemeBillEntryList[i])
         productCount+=1;
-        if(schemeProductList[i].productSchemePrice==0){
-          util.toast("请输入商品价格")
+        if(schemeBillEntryList[i].areaDivide==""||schemeBillEntryList[i].areaDivide==null){
+          util.toast('请输入代理分成')
+          return;
+        }  
+        if(schemeBillEntryList[i].areaDivide<0||schemeBillEntryList[i].areaDivide>100){
+          util.toast('门店分成必须是0-100的分成')
           return;
         } 
-        if(schemeProductList[i].storeDivide==0){
+        if(schemeBillEntryList[i].storeDivide==""||schemeBillEntryList[i].storeDivide==null){
           util.toast('请输入门店分成')
           return;
         }  
-        if(schemeProductList[i].storeDivide<1||schemeProductList[i].storeDivide>100){
-          util.toast('门店分成必须是1-100的分成')
+        if(schemeBillEntryList[i].storeDivide<0||schemeBillEntryList[i].storeDivide>100){
+          util.toast('门店分成必须是0-100的分成')
           return;
         }  
       }
@@ -104,7 +126,7 @@ Page({
     if (!checkRes) {
       if(!that.data.isEdit){
         this.setData({
-          ["values.schemeProductList"]: schemeProduct
+          ["values.schemeBillEntryList"]: schemeProduct
         })
         util.request(util.api.addScheme, that.data.values, "POST", false, true, app.globalData.token).then((res) => {
           if (res.code == 200) {
@@ -153,7 +175,7 @@ Page({
     let dataset = e.currentTarget.dataset;
     let value = e.detail.value;
     let name = dataset.name;
-    var list = that.data.values.schemeProductList
+    var list = that.data.values.schemeBillEntryList
     var index = dataset.index;
     var itemProduct = dataset.item
 
@@ -162,24 +184,22 @@ Page({
     if(!value){
       value = 0.00;
     }
-    switch(name){
-      case "productSchemePrice":
-        value = parseInt(parseFloat(value));
-        itemProduct.productSchemePrice = value
-        break;
-      case "storeDivide":
-        itemProduct.storeDivide = value
-        break;
+    console.log(name)
+    if(name=="storeDivide"){
+      itemProduct.storeDivide = value
+    }else if(name=="areaDivide"){
+      itemProduct.areaDivide = value
     }
     list.splice(index,1,itemProduct)
     that.setData({
-      ["values.schemeProductList"]:list
+      ["values.schemeBillEntryList"]:list
     })
+    console.log(this.data.values.schemeBillEntryList)
     
   },
   bindStoreList() {
     var that = this
-    util.request(util.api.storeList, {}, "GET", false, true, app.globalData.token).then((res) => {
+    util.request(util.api.storeList, {agentId:that.data.values.agentId}, "GET", false, true, app.globalData.token).then((res) => {
       if (res.code == 200) {
         that.setData({
           storeList: res.result
@@ -187,6 +207,17 @@ Page({
       }
     }).catch((res) => {})
   },
+  //代理商
+  getAllAgentList() { 
+    var that = this
+    util.request(util.api.allAgentList, {}, "GET", false, true,app.globalData.token).then((res) => {
+      if (res.code == 200) {
+        that.setData({
+          agentList: res.result
+        })
+      }
+    }).catch((res) => {})
+  },
   toSelect(e) {
     wx.navigateTo({
       url: '/pages/scheme/select?index=' + e.currentTarget.dataset.index,
@@ -198,29 +229,6 @@ Page({
       id: that.data.id
     }, "GET", true, true, app.globalData.token).then((res) => {
 
-      let schemeProductLists = res.result.schemeProductList;
-      console.log(schemeProductLists)
-      console.log("==================================")
-      var schemeProductList = []
-      for (var i = 1; i <= 22; i++) {
-        var item = {
-          schemeId: '',
-          productId: '',
-          productName: '请选择商品',
-          productImg: '',
-          productSchemePrice: 0,
-          storeDivide: 0,
-          gridNum:i
-        }
-        for (let k = 0; k < schemeProductLists.length; k++) {
-          if(schemeProductLists[k].gridNum == i){
-            item = schemeProductLists[k];
-          }
-        }
-        schemeProductList.push(item)
-      }
-
-      res.result.schemeProductList = schemeProductList;
       if (res.code == 200) {
         that.setData({
           values: res.result,
@@ -238,6 +246,15 @@ Page({
       }
       
     }).catch((res) => {})
+  },
+  //添加格子
+  addGrid(){
+    var schemeBillEntryList =this.data.values.schemeBillEntryList;
+    var product = {productName:'请选择商品',gridNum:schemeBillEntryList.length+1};
+    schemeBillEntryList.push(product)
+    this.setData({
+      ["values.schemeBillEntryList"]: schemeBillEntryList
+    })
   }
   
 })

+ 46 - 25
pages/scheme/form.wxml

@@ -1,53 +1,74 @@
 <wxs src="../../utils/filter.wxs" module="filter"></wxs>
 <view class="container">
   <form bindsubmit="formSubmit" bindreset="formReset">
+
+    <tui-list-cell hover="{{false}}">
+      <view class="tui-line-cell">
+        <view class="tui-title"><text style="color:red;">*</text>方案名称:</view>
+        <input placeholder-class="phcolor" class="tui-input" data-name="values.schemeName" placeholder="请输入方案名称" maxlength="50" name="schemeName" value="{{values.schemeName}}" catchinput="inputedit" bindblur="inputedit"/>
+      </view>
+    </tui-list-cell>
+
+    <picker wx:if="{{userInfo.mgvmRole!=3}}" bindchange="bindAgentPickerChange" value="{{index}}" range="{{agentList}}" range-key="username">
+      <tui-list-cell hover="{{false}}">
+        <view class="tui-line-cell">
+          <view class="tui-title"><text style="color:red;">*</text>代理商</view>
+          <input placeholder-class="phcolor" class="tui-input" name="agentName" placeholder="请选择代理商" type="text" disabled="true"
+          model:value="{{values.agentName}}" />
+        </view>
+      </tui-list-cell>
+    </picker>
+
     <picker bindchange="bindStorePickerChange" value="{{index}}" range="{{storeList}}" range-key="storeName">
       <tui-list-cell hover="{{false}}">
         <view class="tui-line-cell">
-          <view class="tui-title">门店</view>
-          <input placeholder-class="phcolor" class="tui-input" placeholder="请选择门店" type="text" disabled="true"
+          <view class="tui-title"><text style="color:red;">*</text>门店</view>
+          <input placeholder-class="phcolor" class="tui-input" name="storeName" placeholder="请选择门店" type="text" disabled="true"
           model:value="{{values.storeName}}" />
         </view>
       </tui-list-cell>
     </picker>
-    <tui-list-cell hover="{{false}}">
-      <view class="tui-line-cell">
-        <view class="tui-title"><text style="color:red;">*</text>方案名称:</view>
-        <input placeholder-class="phcolor" class="tui-input" data-name="values.schemeName" placeholder="请输入方案名称" maxlength="50" name="schemeName" value="{{values.schemeName}}" catchinput="inputedit" bindblur="inputedit"/>
-      </view>
-    </tui-list-cell>
-    <view class="tui-goods-item" wx:for="{{values.schemeProductList}}">
+
+    <button class="btn-primary margin-bottom-xs" hover-class="btn-hover" bindtap="addGrid" type="primary">添加</button>
+   
+
+    
+
+    <view class="tui-goods-item" wx:for="{{values.schemeBillEntryList}}">
       <image wx:if="{{!item.productImg==''}}" src="{{item.productImg}}" class="tui-goods-img"  data-index="{{index}}"></image>      
       <view wx:else class="tui-goods-grid" bindtap="toSelect" data-index="{{index}}"><text>{{index+1}}号柜</text></view>
       <view class="tui-goods-center">
-        <tui-list-cell hover="{{false}}" padding="20rpx 20rpx">
-          <view class="tui-line-cell">
-            <view class="tui-title">{{item.productName}}</view>
+        <tui-list-cell hover="{{false}}" padding="0rpx 20rpx">
+          <view class="tui-line-cell" style="height:48rpx;">
+            <view class="tui-title" style="width:90%">{{item.productName}}</view>
           </view>
         </tui-list-cell>
-        <tui-list-cell hover="{{false}}" padding="20rpx 20rpx">
-          <view class="tui-line-cell">
-            <view class="tui-title">商品售价</view>
-            <input placeholder-class="phcolor" class="tui-input" placeholder="请输入金额,保留两位小数"
-              maxlength="50" type="digit" value="{{filter.toDecimal2Penny(item.productSchemePrice)}}"  bindblur="inputeditRow" data-name="productSchemePrice" data-index="{{index}}" data-item="{{item}}"/>
+        <tui-list-cell hover="{{false}}" padding="0rpx 20rpx">
+          <view class="tui-line-cell" style="height:48rpx;">
+            <view class="tui-title">商品售价: </view>
+            <view class="tui-title"> {{item.productSchemePrice?filter.toDecimal2Penny(item.productSchemePrice):0}}</view>
           </view>
         </tui-list-cell>
-        <tui-list-cell hover="{{false}}" padding="20rpx 20rpx">
-          <view class="tui-line-cell">
+        <tui-list-cell hover="{{false}}" padding="0rpx 20rpx">
+          <view class="tui-line-cell" style="height:48rpx;">
+            <view class="tui-title">代理分成(%):</view>
+            <input placeholder-class="phcolor" class="tui-input" placeholder="请填写代理分成比例" type="number" value="{{item.areaDivide}}" bindblur="inputeditRow" data-name="areaDivide" data-index="{{index}}" data-item="{{item}}"/>
+          </view>
+        </tui-list-cell>
+        <tui-list-cell hover="{{false}}" padding="0rpx 20rpx">
+          <view class="tui-line-cell" style="height:48rpx;">
             <view class="tui-title">门店分成(%):</view>
             <input placeholder-class="phcolor" class="tui-input" placeholder="请填写门店分成比例" type="number" value="{{item.storeDivide}}" bindblur="inputeditRow" data-name="storeDivide" data-index="{{index}}" data-item="{{item}}"/>
           </view>
         </tui-list-cell>
 
-        <tui-list-cell hover="{{false}}" padding="20rpx 20rpx">
-          <view class="tui-line-cell">
-            <view class="tui-title">格子:</view>
-            <view style="margin-left:20rpx;color:red">{{item.gridNum}}</view>
-          </view>
-        </tui-list-cell>
+
+
+
       </view>
     </view>
     <view class="tui-btn-box">
+      
       <button class="btn-primary margin-bottom-xs" hover-class="btn-hover" formType="submit" type="primary">提交</button>
       <button class="btn-primary btn-gray" hover-class="btn-gray-hover" bindtap="deleteScheme" >删除</button>
     </view>

+ 3 - 3
pages/scheme/index.wxml

@@ -41,13 +41,13 @@
     </view>
 
   </view>
-
+  <view style="height:10rpx"></view>
   <!--加载loadding-->
   <tui-loadmore visible="{{loadding}}" index="{{3}}" type="red"></tui-loadmore>
-  <tui-nomore visible="{{!pullUpOn}}" bgcolor="#fafafa"></tui-nomore>
+  <tui-nomore style="margin-bottom:60rpx" visible="{{!pullUpOn}}" bgcolor="#fafafa"></tui-nomore>
   <!--加载loadding-->
   <!--list-->
-  <tui-button type="blue" height="98rpx" shape="rightAngle" bindtap="toAddScheme" style="position:fixed;bottom:0;width:100%;">新增方案</tui-button>
+  <tui-button type="blue" height="98rpx" shape="rightAngle" bindtap="toAddScheme" style="position:fixed;bottom:0;width:100%;z-index:2">新增方案</tui-button>
   <!--弹出-->
   <time-picker pickerShow="{{isPickerShow}}" id="picker" wx:if="{{isPickerRender}}" bind:hidePicker="pickerHide"
     bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></time-picker>

+ 0 - 1
pages/scheme/index.wxss

@@ -151,7 +151,6 @@ page{
 
 .store-grid{
   margin-top: 200rpx;
-  height: 100%;
 }
 .store-list-row{
   display: flex;

+ 11 - 3
pages/scheme/select.js

@@ -97,16 +97,24 @@ Page({
     var row = e.currentTarget.dataset.item;
     var pages = getCurrentPages();
     var prevPage = pages[pages.length - 2];  //上一个页面
-    var list = prevPage.data.values.schemeProductList
+    var list = prevPage.data.values.schemeBillEntryList
+
+    var isproduct=list.some(item=>item.productId==row.id);//是否已存在商品
+    if(isproduct){
+      util.toast('不可选择相同商品')
+      return;
+    }
+
     var itemProduct = JSON.parse(JSON.stringify(list))[this.data.index]
     itemProduct.productId = row.id
     itemProduct.productName = row.skuProductName
     itemProduct.productImg = row.productImg
     itemProduct.productSchemePrice = row.productPrice
-    itemProduct.storeDivide = 30
+    itemProduct.storeDivide = 0
+    itemProduct.areaDivide = 0
     list.splice(this.data.index,1,itemProduct)
     prevPage.setData({
-      ["values.schemeProductList"]:list
+      ["values.schemeBillEntryList"]:list
     })
     wx.navigateBack()
   },

+ 3 - 3
pages/vendingMachine/settledStore.js

@@ -49,7 +49,7 @@ Page({
     if(this.data.userInfo.mgvmRole==3){
       this.setData({
         ['values.agentId']: this.data.userInfo.id,
-        ['values.agentName']: this.data.userInfo.realname,
+        ['values.agentName']: this.data.userInfo.username,
       })
     }
 
@@ -158,7 +158,7 @@ Page({
     }else{
       this.setData({
         ['values.agentId']: this.data.userInfo.id,
-        ['values.agentName']: this.data.userInfo.realname,
+        ['values.agentName']: this.data.userInfo.username,
       })
     }
 
@@ -265,7 +265,7 @@ Page({
       var item = this.data.agentList[e.detail.value]
       this.setData({
         ['values.agentId']: item.id,
-        ['values.agentName']: item.realname
+        ['values.agentName']: item.username
       })
     },
     //前往选择商品

+ 1 - 1
pages/vendingMachine/settledStore.wxml

@@ -101,7 +101,7 @@
 
       <tui-list-cell hover="{{false}}" padding="0rpx 20rpx">
         <view class="tui-line-cell">
-          <view class="tui-title">{{item.productName?item.productName:'请选择商品'}}</view>
+          <view class="tui-title" style="width:90%">{{item.productName?item.productName:'请选择商品'}}</view>
         </view>
       </tui-list-cell>
 

+ 29 - 0
project.config.json

@@ -4,6 +4,35 @@
     "ignore": []
   },
   "setting": {
+    "urlCheck": false,
+    "es6": true,
+    "enhance": false,
+    "postcss": true,
+    "preloadBackgroundData": false,
+    "minified": true,
+    "newFeature": false,
+    "coverView": true,
+    "nodeModules": false,
+    "autoAudits": false,
+    "showShadowRootInWxmlPanel": true,
+    "scopeDataCheck": false,
+    "uglifyFileName": false,
+    "checkInvalidKey": true,
+    "checkSiteMap": true,
+    "uploadWithSourceMap": true,
+    "compileHotReLoad": false,
+    "useMultiFrameRuntime": false,
+    "useApiHook": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "useIsolateContext": true,
+    "useCompilerModule": true,
+    "userConfirmedUseCompilerModuleSwitch": false,
+    "packNpmManually": false,
+    "packNpmRelationList": [],
     "useApiHostProcess": true
   },
   "compileType": "miniprogram",