wangyingjie 2 anni fa
parent
commit
c776b1ce7c

+ 3 - 1
app.json

@@ -44,7 +44,9 @@
                 "pages/choose-goods/choose-goods",
                 "pages/order-billing/deal/deal",
                 "pages/order-billing/detail/detail",
-                "pages/order-billing/collection-confirm/collection-confirm"
+                "pages/order-billing/collection-confirm/collection-confirm",
+                "pages/choose-sale-man/choose-sale-man",
+                "pages/account-check/account-check"
             ]
         },
         {

+ 460 - 0
package-sales/pages/account-check/account-check.js

@@ -0,0 +1,460 @@
+const app = getApp()
+const Constants = require('../../../utils/Constants.js');
+const api = require('../../../utils/api.js');
+import Dialog from '../../../dist/dialog/dialog.js'
+const util = require('../../../utils/util.js')
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    loading: false,
+    orgIsMain: {
+      allocationRatio: 100,
+      checked: true,
+      commission: 100,
+      erpOrgCode: "",
+      isMain: true,
+      organizationId: 32402,
+      organizationName: "北海富安居店",
+      ownerFlag: true
+    },
+    orgItem: {
+      goodsListFlag: true,
+      text: [
+        "北海富安居店"
+      ],
+      value: [
+        32402
+      ]
+    },
+    organizationIds: [
+      32402
+    ],
+    organizationList: [
+      {
+        allocationRatio: 100,
+        cpId: 20760,
+        erpOrgCode: "",
+        erpStaffCode: null,
+        flgValid: true,
+        multiId: 21978,
+        orderId: 11954,
+        orgCode: "GXBH1002",
+        orgId: 32402,
+        ownerFlag: true,
+        ownerId: 32402,
+        ownerName: "北海富安居店",
+        ownerType: 1,
+        staffCode: null,
+        staffId: null
+      }
+    ],
+    organizationName: [
+      "北海富安居店"
+    ],
+    showList: [
+      {
+        checked: true,
+        commission: 100,
+        defWhId: 552,
+        erpOrgCode: "",
+        flgStore: true,
+        isMain: true,
+        orgId: 32402,
+        organizationCode: "GXBH1002",
+        organizationId: 32402,
+        organizationName: "北海富安居店",
+        salesChannel: 1,
+        salesChannelName: "零售",
+        warehouseId: 552,
+        warehouseName: "钦州运营仓",
+        whId: 552,
+        whId_Name: "钦州运营仓",
+        whIdsName: "钦州运营仓"
+      }
+    ] 
+  },
+  inputBlurChange(e) {
+    let value = null
+    let index = e.currentTarget.dataset.index
+    let id = e.currentTarget.dataset.id
+    let showList = this.data.showList
+    if (Number(e.detail.value) == 0  ||  Number(e.detail.value) ) {
+      value = Number(e.detail.value)
+      if(Number(e.detail.value) > 100){
+        value = Number(100)
+      }
+      if(Number(e.detail.value) < 0){
+        value = Number(0)
+      }
+     
+    }
+    showList[index].commission = value.toFixed(2)
+    this.setData({
+      showList,
+      inputBlurChange:true
+    })
+    // let number = Number(100 - value.toFixed(2))
+    // let showListTemp = []
+    // showList.forEach(it => {
+    //   if (id != it.orgId && it.checked) {
+    //     console.log('it', it)
+    //     showListTemp.push(it)
+    //   }
+    // })
+    // let allocationRatio = (number / showListTemp.length).toFixed(2)
+    // let allocationRatioTotal = 0
+    // //数据取余2为0
+    // if (number % showListTemp.length == 0) {
+    //   //循环将计算好的百分比放入数据中
+    //   for (let i in showListTemp) {
+    //     showListTemp[i].commission = Number(allocationRatio).toFixed(2)
+    //   }
+    //   showList.forEach(item1 => {
+    //     showListTemp.forEach(item2 => {
+    //       if (item1.orgId == item2.orgId) {
+    //         item1.commission = item2.commission.toFixed(2)
+    //       }
+    //     })
+    //   })
+    //   this.setData({
+    //     showList
+    //   })
+    // } else {
+    //   let showListTemp2 = [...showListTemp]
+    //   let endList = showListTemp2.splice(-1)
+    //   for (let i = 0; i < showListTemp2.length; i++) {
+    //     console.log('showListTemp[i]', showListTemp2[i])
+    //     allocationRatioTotal = allocationRatioTotal + Number(allocationRatio)
+    //     showListTemp2[i].commission = Number(allocationRatio).toFixed(2)
+    //   }
+    //   if (endList[0]) {
+    //     endList[0].commission = (number - allocationRatioTotal)
+    //   }
+    //   showList.forEach(item1 => {
+    //     showListTemp2.forEach(item2 => {
+    //       if (item1.orgId == item2.orgId) {
+    //         item1.commission = item2.commission.toFixed(2)
+    //       }
+    //     })
+    //   })
+    //   this.setData({
+    //     showList
+    //   })
+    // }
+  },
+  calculationScale(showList) {
+
+
+    showList = showList.filter((item) => {
+      return item.checked == true
+    })
+    let allocationRatio = (100 / showList.length).toFixed(2)
+    let allocationRatioTotal = 0
+    //数据取余2为0
+    if (100 % showList.length == 0) {
+      //循环将计算好的百分比放入数据中
+      for (let i in showList) {
+        showList[i].commission = Number(allocationRatio).toFixed(2)
+      }
+    } else { //数据取余2不为0
+      //获取最后选中checkbox数组中最后一个元素
+      let endList = showList.splice(-1)
+      for (let i = 0; i < showList.length; i++) {
+        allocationRatioTotal = allocationRatioTotal + Number(allocationRatio)
+        showList[i].commission = Number(allocationRatio).toFixed(2)
+      }
+      if (endList[0]) {
+        endList[0].commission = (100 - allocationRatioTotal).toFixed(2)
+      }
+
+    }
+
+
+
+
+  },
+  /**
+    * @desc : 确定
+    * @author : 于继渤
+    * @date : 2022/6/10 12:16
+    */
+  btnOK() {
+    let TempOrgTable = []
+    // 判断是否有选择的checkbox
+    var allcheck = false;
+    var allswitch = false;
+    var indexswitch = 0;
+    var showList = this.data.showList;
+    for (let i = 0; i < showList.length; i++) {
+      if (showList[i].checked) {
+        allcheck = true;
+        break;
+      }
+    }
+    for (let i = 0; i < showList.length; i++) {
+      if (showList[i].isMain) {
+        allswitch = true;
+        indexswitch = i;
+        break;
+      }
+    }
+    let commission = Number(0)
+    for (let i = 0; i < showList.length; i++) {
+      if (showList[i].checked) {
+        commission += Number(showList[i].commission)
+      }
+    }
+    if (commission !== 100) {
+      wx.showToast({
+        title: '提成比例不足 100',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    // 校验
+    if (!allcheck) {
+      wx.showToast({
+        title: '请至少选择一个业务部门',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+    // 校验
+    if (!allswitch) {
+      wx.showToast({
+        title: '请选择主业务部门',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+
+    let sum = 0
+    showList.forEach(res => {
+      if (res.checked) {
+        sum += parseFloat(res.commission)
+      }
+    })
+    if (sum > 100 || sum < 100) {
+      wx.showToast({
+        title: '提成比率不正确',
+        icon: 'none',
+        duration: 2000
+      })
+      return;
+    }
+
+    // 取出被选中的数据
+    let organizationList = []
+    let organizationNames = []
+    let organizationIds = []
+    for (let index = 0; index < showList.length; index++) {
+      if (showList[index].checked) {
+        showList[index].allocationRatio = showList[index].commission
+        showList[index].ownerFlag = showList[index].isMain
+        showList[index].organizationId = showList[index].organizationId
+        organizationList.push(showList[index])
+        // organizationNames.push(showList[index].organizationName)
+        organizationIds.push(showList[index].organizationId)
+      }
+
+    }
+
+    var pages = getCurrentPages();
+    var prevPage = pages[pages.length - 2]; //上一个页面
+    let salesChannelItem = {}
+    let orgMain = []
+    organizationList.forEach(res2 => {
+      if (res2.isMain) {
+        orgMain = res2
+        salesChannelItem = { text: res2.salesChannelName, value: res2.salesChannel }
+      }
+    })
+
+
+    // orgItem
+    let orgGoodsListFlag = false
+    if (this.data.orgIsMain) {
+      let orgMainTemp = this.data.orgIsMain
+
+      if (orgMainTemp.organizationId != orgMain.organizationId) {
+        orgGoodsListFlag = true
+      } else {
+        orgGoodsListFlag = false
+      }
+    }
+    if (!this.data.orgIsMain && this.data.orgItem) {
+      let orgItemTemp = this.data.orgItem
+      if (orgItemTemp.value && orgItemTemp.value.length > 0 && (orgItemTemp.value[0].organizationId != orgMain.organizationId)) {
+        orgGoodsListFlag = true
+      } else {
+        orgGoodsListFlag = false
+      }
+
+    }
+
+    let organizationNamesTemp = organizationList.sort((a, b) => b.isMain - a.isMain);
+
+    organizationNamesTemp.forEach(res => {
+      organizationNames.push(res.organizationName)
+    })
+
+    let organizationItem = {
+      orgMain: orgMain,
+      orgItem: {
+        text: organizationNames.join(','),
+        value: organizationIds
+      },
+      salesChannelItem: salesChannelItem,
+      organizationList: organizationList,
+      organizationNames: organizationNames.join(',')
+    }
+
+
+    prevPage.setData({
+      organizationItem: organizationItem,
+      orgGoodsListFlag: orgGoodsListFlag,
+      orgGoodsListFlagCopy: true
+    })
+    wx.navigateBack({
+      delta: 1
+    })
+  },
+
+  //输入提成比例的
+  inputChange(e) {
+    let showList = this.data.showList;
+    showList[e.currentTarget.dataset.index].commission = e.detail.value;
+    showList[e.currentTarget.dataset.index].allocationRatio = e.detail.value;
+    this.setData({
+      showList: showList
+    })
+  },
+  /**
+   * 列表选中
+   */
+  onChangeFlag(event) {
+    var allIsMain = false
+    var _this = this
+    var showList = _this.data.showList
+    let index = event.currentTarget.dataset.index
+    // 设置点击的项目checkbox的值
+    for (let i = 0; i < showList.length; i++) {
+      if (i == index) {
+        showList[i].checked = !showList[i].checked
+        break;
+      }
+    }
+    //如果电机的是选中的
+    if (showList[index].checked) {
+      var isMain = false;
+      for (let i = 0; i < showList.length; i++) {
+        if (showList[i].isMain) {
+          isMain = true;
+          break;
+        }
+      }
+      showList[index].isMain = !isMain;
+    } else {
+      showList[index].isMain = false;
+      showList[index].commission = parseFloat(100).toFixed(2)
+    }
+    for (let i = 0; i < showList.length; i++) {
+      if (showList[i].isMain) {
+        allIsMain = true
+      }
+    }
+    if (!allIsMain) {
+      for (let i = 0; i < showList.length; i++) {
+        if (showList[i].checked) {
+          showList[i].isMain = true
+          break
+        }
+      }
+    }
+    // showList.forEach(it => {
+    //     if (it.checked) {
+    //         it.commission = parseFloat(100 / showList.filter(item => item.checked == true).length).toFixed(2)
+    //     } else {
+    //         it.commission = parseFloat(100).toFixed(2)
+    //     }
+
+    // })
+    if(!this.data.inputBlurChange){
+      this.calculationScale(showList)
+    }
+
+    // 选择条数
+    _this.setData({
+      showList: showList,
+    })
+  },
+  /**
+     * 主从业务部门的勾选
+     * @param {*} e 
+     */
+  onChangeSwitch(e) {
+    var _this = this
+    var showList = _this.data.showList
+    //如果没有选中就不能触发这个主从的勾选
+    if (!showList[e.target.dataset.index].checked) {
+      return;
+    }
+    // 设置点击的项目checkbox的值
+    for (let i = 0; i < showList.length; i++) {
+      if (i == e.target.dataset.index && showList[i].checked) {
+        showList[i].isMain = !showList[i].isMain
+        continue;
+      }
+      showList[i].isMain = false;
+    }
+    // 选择条数
+    _this.setData({
+      showList: showList,
+    })
+  },
+  /**
+* 主从业务员的勾选
+* @param {*} e 
+*/
+  onChangeSwitch(e) {
+    var _this = this
+    var showList = _this.data.showList
+    //如果没有选中就不能触发这个主从的勾选
+    if (!showList[e.target.dataset.index].checked) {
+      return;
+    }
+    // 设置点击的项目checkbox的值
+    for (let i = 0; i < showList.length; i++) {
+      if (i == e.target.dataset.index && showList[i].checked) {
+        showList[i].isMain = !showList[i].isMain
+        continue;
+      }
+      showList[i].isMain = false;
+    }
+
+    // 选择条数
+    _this.setData({
+      showList: showList,
+    })
+  },
+ 
+
+
+
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  
+  },
+
+
+
+})

+ 4 - 0
package-sales/pages/account-check/account-check.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "选择业务部门"
+  }

+ 85 - 0
package-sales/pages/account-check/account-check.wxml

@@ -0,0 +1,85 @@
+<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>
+<van-sticky scroll-top="0" >
+    <van-search model:value="{{ searchText }}" bind:search="doSearch" placeholder="请输入编码/名称" />
+</van-sticky>
+
+
+
+
+
+<view wx:for="{{showList}}" data-item="{{item}}" wx:key="StaffID" class="main-class">
+    <view class="main-foot" style="border-radius: 15rpx;">
+        <view class="table">
+
+           
+            <view style="display:flex;">
+
+                <view  data-value="{{item.checked}}"  bind:tap="onChangeFlag" data-index="{{index}}" style="width: 10%;">
+                    <view style="margin-top:45rpx;position: relative;">
+                        <van-checkbox disabled="{{flgStore}}"value="{{item.checked}}" data-index="{{index}}"  checked-color="#1989FA" />
+                    </view>
+                </view>
+
+                <view style="width: 90%;">
+                    <view style="width: 100%;padding-bottom: 5rpx;" class="table-row">
+                        <view style="width: 50%; font-size: 13px;line-height: 18px;text-align: left;">
+                            名称:{{item.organizationName}}
+                        </view>
+                        <view style="width: 50%;  font-size: 13px;line-height: 18px;  text-align: left;">
+                            编码:{{item.organizationCode}}
+                        </view>
+                    </view>
+
+
+               
+
+
+                    <view style="width: 100%;" class="table-row">
+                        <view style="width: 50%;font-size: 27rpx;  text-align: left;">
+                            主部门:
+                            <van-switch size="30rpx" custom-class='switch' data-index="{{index}}" checked="{{ item.isMain }}" catchtap="onChangeSwitch" />
+                        </view>
+                        <view style="width: 50%;font-size: 27rpx;  text-align: left;">
+                            <view style="display: flex; ">
+                                <text style="padding-bottom: 15rpx;">提成比率:</text>
+                                <view wx:if="{{item.checked}}">
+                                    <input style=" width: 120rpx; display: inline-block;vertical-align: middle;" type="digit" bindinput="inputChange" data-key="commission"
+                                    bindblur="inputBlurChange" data-id="{{item.orgId}}" data-index="{{index}}" value="{{item.commission}}" placeholder="" />
+                                </view>
+                                <view wx:else>
+                                    {{item.commission}}
+                                </view>
+                            </view>
+                        </view>
+                    </view>
+
+
+                    <view style="width: 100%;padding-bottom: 5rpx;" class="table-row">
+                        <view style="font-size: 26rpx;  text-align: left;">
+                            销售渠道:{{item.salesChannelName}}
+                        </view>
+                    </view>
+                </view>
+
+            </view>
+        </view>
+
+    </view>
+</view>
+
+
+
+
+
+
+
+
+
+<van-divider wx:if="{{nomore}}" contentPosition="center" borderColor="#DCDCDC">到底了~</van-divider>
+<view style="height:200rpx;width:100%"></view>
+
+<view class="bottom-class-1" >
+  <view style="position:fixed;bottom:0;z-index: 10;text-align: center;width: 100%; margin-bottom: 42rpx;">
+  <van-button color="#1B365D;" type="info" custom-style="width: 640rpx;height: 88rpx;" block round bindtap="btnOK">确定</van-button>
+</view>
+</view>

+ 155 - 0
package-sales/pages/account-check/account-check.wxss

@@ -0,0 +1,155 @@
+
+
+body {
+    background: #eeeeee;
+    height: 100%;
+  }
+  
+  .root {
+    /* width: 100%;
+    height: calc(100%-40rpx);  */
+    height: 100%;
+  }
+  
+  .search {
+    background: #fff;
+    width: 100%;
+    padding: 20rpx;
+    position: fixed;
+    top: 0;
+    z-index: 10;
+  }
+  
+  .search-button {
+    color: #c8c8c8 !important;
+    border-radius: 10rpx !important;
+    width: 96%;
+    height: 60rpx;
+  }
+  
+  .search-button>.van-button__text {
+    font-size: 15px;
+  }
+  
+  .search-wait {
+    height: 100rpx;
+    width: 100%;
+    line-height: 100rpx;
+    text-align: center;
+    color: #c8c8c8;
+    background: #fff;
+  }
+  
+  .pop-search-view {
+    display: flex;
+    justify-content: space-between;
+    background-color: #d9001b;
+    height: 60rpx;
+    padding: 0 3% 0 3%;
+    color: #000;
+  }
+  
+  .panellist {
+    width: 100%;
+    background-color: #fff;
+    /* overflow: hidden; */
+    display: flex;
+    flex-direction: row;
+  }
+  
+  .left {
+    margin-left: 15rpx;
+    width: 50rpx;
+    background-color: #fff;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+  }
+  
+  .right {
+    width: calc(100%-50rpx);
+    /* width: 100%; */
+    /* float: left;  */
+    background-color: #fff;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: flex-start;
+  }
+  
+  .content {
+    padding: var(--cell-vertical-padding, 10rpx) var(--cell-horizontal-padding, 10rpx);
+    /* border-top: 2px #dcdcdc dashed; */
+    /* border-bottom: 1px #ededed solid; */
+    font-size: small;
+  }
+  
+  
+  .content-item {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: flex-start;
+  
+  }
+  
+  .content-item-1 {
+    padding: 10rpx;
+    text-align: left;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+  
+  .footer {
+    color: red;
+  }
+  
+  .footer-info {
+    width: 100%;
+    text-align: right;
+    padding-right: 20rpx;
+    font-size: 20rpx;
+  }
+  
+  .footer-margin {
+    margin-bottom: 10rpx;
+    width: 100%;
+    background-color: #eeeeee
+  }
+  
+  .foot {
+    height: 100rpx;
+    width: 100%;
+    display: flex;
+    position: fixed;
+    left: 0;
+    bottom: 0;
+    z-index: 100;
+    padding-left: 20rpx;
+    background-color: #eeeeee;
+    align-items: center;
+  }
+  
+  .switch {
+    vertical-align: middle;
+    margin-left: 2rpx;
+  }
+  .van-search__content {
+    background: #F8F9FD;
+    border: 1px solid #D6E4FF;
+    border-radius: 15rpx !important;
+  }
+
+  .bottom-class-1{
+    background:#fff;
+    position:fixed;
+    bottom:0;
+    width:100%;
+    height: 182rpx; 
+    border-top:1px solid #efefef;
+    z-index: 7;
+    box-shadow: 0px -8rpx 24rpx rgba(0, 16, 39, 0.1);
+    border-radius: 30rpx 30rpx 0rpx 0rpx;
+  }

+ 434 - 0
package-sales/pages/choose-sale-man/choose-sale-man.js

@@ -0,0 +1,434 @@
+const app = getApp()
+const Constants = require('../../../utils/Constants.js');
+const api = require('../../../utils/api.js');
+import Dialog from '../../../dist/dialog/dialog.js'
+const util = require('../../../utils/util.js')
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        TempStaffTable: [],
+        loading: false,
+        showList: [
+          {
+            checked: true,
+            commission: 100,
+            erpStaffCode: null,
+            isMain: true,
+            organizationId: 32402,
+            organizationName: "北海富安居店",
+            positionId: -200,
+            positionName: "公司职员",
+            staffCode: "17794625033@0726",
+            staffId: 643,
+            staffName: "王英杰"
+          },
+          {
+            checked: false,
+            commission: "100.00",
+            erpStaffCode: null,
+            isMain: false,
+            organizationId: 32402,
+            organizationName: "北海富安居店",
+            positionId: -200,
+            positionName: "公司职员",
+            staffCode: "FSHJ-SJ@FSHJ",
+            staffId: 357,
+            staffName: "石静"
+          },
+          {
+            checked: false,
+            commission: "100.00",
+            erpStaffCode: null,
+            isMain: false,
+            organizationId: 32402,
+            organizationName: "北海富安居店",
+            positionId: -200,
+            positionName: "公司职员",
+            staffCode: "MDDG@QZHJ",
+            staffId: 979,
+            staffName: "分销富安居门店导购001"
+          },
+          {
+            checked: false,
+            commission: "100.00",
+            erpStaffCode: null,
+            isMain: false,
+            organizationId: 32402,
+            organizationName: "北海富安居店",
+            positionId: -200,
+            positionName: "公司职员",
+            staffCode: "12222222222@QZHJ",
+            staffId: 1005,
+            staffName: "无库无ERP00001"
+          },
+          {
+            checked: false,
+            commission: "100.00",
+            erpStaffCode: null,
+            isMain: false,
+            organizationId: 32402,
+            organizationName: "北海富安居店",
+            positionId: -200,
+            positionName: "公司职员",
+            staffCode: "18888888888@QZHJ",
+            staffId: 1000,
+            staffName: "无库无ERP导购"
+          }
+        ],
+        staffId: [
+          643
+        ],
+        staffIsMain: {
+          allocationRatio: 100,
+          checked: true,
+          commission: 100,
+          erpStaffCode: null,
+          isMain: true,
+          ownerFlag: true,
+          staffId: 643,
+          staffName: "王英杰"
+        },
+        staffList: [
+          {
+            allocationRatio: 100,
+            cpId: 20760,
+            erpOrgCode: null,
+            erpStaffCode: null,
+            flgValid: true,
+            multiId: 21979,
+            orderId: 11954,
+            orgCode: null,
+            orgId: null,
+            ownerFlag: true,
+            ownerId: 643,
+            ownerName: "王英杰",
+            ownerType: 3,
+            staffCode: "17794625033@0726",
+            staffId: 643
+          }
+        ],
+        staffName: [
+          "王英杰"
+        ],
+        staffTable: []
+      }  ,
+
+    /**
+   * 确定
+   * @param {*} e 
+   */
+    btnOK(e) {
+        let TempStaffTable = []
+        // 判断是否有选择的checkbox
+        var allcheck = false;
+        var allswitch = false;
+        var indexswitch = 0;
+        var showList = this.data.showList;
+        for (let i = 0; i < showList.length; i++) {
+            if (showList[i].checked) {
+                allcheck = true;
+                break;
+            }
+        }
+        for (let i = 0; i < showList.length; i++) {
+            if (showList[i].isMain) {
+                allswitch = true;
+                indexswitch = i;
+                break;
+            }
+        }
+        let commission = Number(0)
+        for (let i = 0; i < showList.length; i++) {
+            if (showList[i].checked) {
+                commission += Number(showList[i].commission)
+            }
+        }
+        if (commission !== 100) {
+            wx.showToast({
+                title: '提成比例不足 100',
+                icon: 'none',
+                duration: 2000
+            })
+            return;
+        }
+        // 校验
+        if (!allcheck) {
+            wx.showToast({
+                title: '请至少选择一条业务员',
+                icon: 'none',
+                duration: 2000
+            })
+            return;
+        }
+        // 校验
+        if (!allswitch) {
+            wx.showToast({
+                title: '请选择主业务员',
+                icon: 'none',
+                duration: 2000
+            })
+            return;
+        }
+
+
+        let sum = 0
+        showList.forEach(res => {
+            if (res.checked) {
+                sum += parseFloat(res.commission)
+            }
+        })
+        if (sum > 100 || sum < 100) {
+            wx.showToast({
+                title: '提成比率不正确',
+                icon: 'none',
+                duration: 2000
+            })
+            return;
+        }
+
+        var pages = getCurrentPages();
+        var prevPage = pages[pages.length - 2]; //上一个页面
+        let tempNames = []
+        let tempIds = []
+        let satffList = []
+        let staffMain = null
+
+        showList.forEach(item => {
+            if (item.checked) {
+                item.allocationRatio = item.commission
+                item.ownerFlag = item.isMain
+                satffList.push(item)
+                tempNames.push(item.staffName)
+                tempIds.push(item.staffId)
+                if (item.isMain) {
+                    staffMain = item
+                }
+            }
+
+        })
+
+        prevPage.setData({
+            staffMain: staffMain,
+            staffList: satffList,
+            staffItem: {
+                text: tempNames.join(','),
+                value: tempIds
+            },
+
+        })
+        wx.navigateBack({
+            delta: 1
+        })
+
+    },
+
+    //输入提成比例的
+    inputChange(e) {
+        let showList = this.data.showList;
+        showList[e.currentTarget.dataset.index].commission = e.detail.value;
+        showList[e.currentTarget.dataset.index].allocationRatio = e.detail.value;
+        this.setData({
+            showList: showList
+        })
+    },
+    inputBlurChange(e) {
+        let value = null
+        let index = e.currentTarget.dataset.index
+        let id = e.currentTarget.dataset.id
+        let showList = this.data.showList
+        if (Number(e.detail.value) == 0 || Number(e.detail.value)) {
+            value = Number(e.detail.value)
+            if (Number(e.detail.value) > 100) {
+                value = Number(100)
+            }
+            if (Number(e.detail.value) < 0) {
+                value = Number(0)
+            }
+
+        }
+        showList[index].commission = value.toFixed(2)
+        this.setData({
+            showList,
+            inputBlurChange: true
+        })
+        //   let number = Number(100 - value.toFixed(2))
+        //   let showListTemp = []
+        //   showList.forEach(it => {
+        //     if (id != it.staffId && it.checked) {
+        //       console.log('it', it)
+        //       showListTemp.push(it)
+        //     }
+        //   })
+        //   let allocationRatio = (number / showListTemp.length).toFixed(2)
+        //   let allocationRatioTotal = 0
+        //  //数据取余2为0
+        //   if (number % showListTemp.length == 0) {
+        //     //循环将计算好的百分比放入数据中
+        //     for (let i in showListTemp) {
+        //       showListTemp[i].commission = Number(allocationRatio).toFixed(2)
+        //     }
+        //     showList.forEach(item1 => {
+        //       showListTemp.forEach(item2=>{
+        //         if(item1.staffId == item2.staffId){
+        //           item1.commission = item2.commission.toFixed(2)
+        //         }
+        //       })
+        //     })
+        //     this.setData({
+        //       showList
+        //     })
+        //   } else {
+        //     let showListTemp2 = [...showListTemp]
+        //     let endList = showListTemp2.splice(-1)
+        //     for (let i = 0; i < showListTemp2.length; i++) {
+        //       console.log('showListTemp[i]', showListTemp2[i])
+        //       allocationRatioTotal = allocationRatioTotal + Number(allocationRatio)
+        //       showListTemp2[i].commission = Number(allocationRatio).toFixed(2)
+        //     }
+        //     if (endList[0]) {
+        //       endList[0].commission = (number - allocationRatioTotal).toFixed(2)
+        //     }
+        //     showList.forEach(item1 => {
+        //       showListTemp2.forEach(item2=>{
+        //         if(item1.staffId == item2.staffId){
+        //           item1.commission = item2.commission
+        //         }
+        //       })
+        //     })
+        //     this.setData({
+        //       showList
+        //     })
+        //   }
+    },
+    calculationScale(showList) {
+
+
+        showList = showList.filter((item) => {
+            return item.checked == true
+        })
+        let allocationRatio = (100 / showList.length).toFixed(2)
+        let allocationRatioTotal = 0
+        //数据取余2为0
+        if (100 % showList.length == 0) {
+            //循环将计算好的百分比放入数据中
+            for (let i in showList) {
+                showList[i].commission = Number(allocationRatio).toFixed(2)
+
+            }
+        } else { //数据取余2不为0
+            //获取最后选中checkbox数组中最后一个元素
+            let endList = showList.splice(-1)
+            for (let i = 0; i < showList.length; i++) {
+                allocationRatioTotal = allocationRatioTotal + Number(allocationRatio)
+                showList[i].commission = Number(allocationRatio).toFixed(2)
+            }
+            if (endList[0]) {
+                endList[0].commission = (100 - allocationRatioTotal).toFixed(2)
+            }
+
+        }
+
+    },
+    /**
+    * 列表选中
+    */
+    onChangeFlag(event) {
+
+        let allIsMain = false
+        var _this = this
+        var showList = _this.data.showList
+
+        let index = event.currentTarget.dataset.index
+        let checked = event.currentTarget.dataset.value
+        // 设置点击的项目checkbox的值
+        for (let i = 0; i < showList.length; i++) {
+            if (i == index) {
+                showList[i].checked = !showList[i].checked
+                break;
+            }
+        }
+        if (showList[index].checked) {
+            var isMain = false;
+            for (let i = 0; i < showList.length; i++) {
+                if (showList[i].isMain) {
+                    isMain = true;
+                    break;
+                }
+            }
+            showList[index].isMain = !isMain;
+        } else {
+            showList[index].isMain = false;
+            showList[index].commission = parseFloat(100).toFixed(2)
+        }
+
+        //实现一个关闭出现一换个主业务员
+        for (let i = 0; i < showList.length; i++) {
+            if (showList[i].isMain) {
+                allIsMain = true
+            }
+        }
+        if (!allIsMain) {
+            for (let i = 0; i < showList.length; i++) {
+                if (showList[i].checked) {
+                    showList[i].isMain = true
+                    break
+                }
+            }
+        }
+        // showList.forEach(it => {
+        //     if (it.checked) {
+        //         it.commission = parseFloat(100 / showList.filter(item => item.checked == true).length).toFixed(2)
+        //     } else {
+        //         it.commission = parseFloat(100).toFixed(2)
+        //     }
+
+        // })
+        if (!this.data.inputBlurChange) {
+            this.calculationScale(showList)
+        }
+
+
+
+        // 选择条数
+        _this.setData({
+            showList: showList,
+        })
+    },
+    /**
+   * 主从业务员的勾选
+   * @param {*} e 
+   */
+    onChangeSwitch(e) {
+        var _this = this
+        var showList = _this.data.showList
+        //如果没有选中就不能触发这个主从的勾选
+        if (!showList[e.target.dataset.index].checked) {
+            return;
+        }
+        // 设置点击的项目checkbox的值
+        for (let i = 0; i < showList.length; i++) {
+            if (i == e.target.dataset.index && showList[i].checked) {
+                showList[i].isMain = !showList[i].isMain
+                continue;
+            }
+            showList[i].isMain = false;
+        }
+
+        // 选择条数
+        _this.setData({
+            showList: showList,
+        })
+    },
+
+ 
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+       
+    },
+
+})

+ 4 - 0
package-sales/pages/choose-sale-man/choose-sale-man.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText":"选择业务员"
+  }

+ 65 - 0
package-sales/pages/choose-sale-man/choose-sale-man.wxml

@@ -0,0 +1,65 @@
+<wxs src='../../../utils/numberFormat.wxs' module="numberFormat"></wxs>
+
+<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>
+<van-sticky scroll-top="0">
+  <van-search model:value="{{ searchText }}" bind:search="doSearch" placeholder="请输入员工编码/员工名称" />
+</van-sticky>
+
+<van-empty wx:if="{{showList.length<=0}}" description="暂无数据" />
+
+<view wx:for="{{showList}}" data-item="{{item}}" wx:key="StaffID" class="main-class">
+  <view class="main-foot" style="border-radius: 15rpx;">
+    <view class="table">
+
+      <view style="display:flex;" >
+        <view style="width: 10%;" data-value="{{item.checked}}" bind:tap="onChangeFlag" data-index="{{index}}">
+          <view style="margin-top:45rpx;position: relative;">
+            <van-checkbox value="{{item.checked}}" data-index="{{index}}" checked-color="#1989FA" />
+          </view>
+        </view>
+
+        <view style="width: 90%;">
+          <view style="width: 100%;padding-bottom: 5rpx;" class="table-row">
+            <view style="width: 50%; font-size: 13px;line-height: 18px; text-align: left;">
+              名称:{{item.staffName}}
+            </view>
+            <view style="width: 50%; font-size: 13px;line-height: 18px;text-align: left;">
+              编码:{{item.staffCode}}
+            </view>
+          </view>
+
+
+          <view style="width: 100%;padding-bottom: 5rpx;" class="table-row">
+            <view style="width: 50%;font-size: 27rpx;  text-align: left;">
+              主业务员:
+              <van-switch size="30rpx" custom-class='switch' data-index="{{index}}" checked="{{ item.isMain }}" catchtap="onChangeSwitch" />
+            </view>
+            <view style="width: 50%;font-size: 27rpx;  text-align: left;">
+              <view style="display: flex; ">
+                <text style="padding-bottom: 15rpx;">提成比率:</text>
+                <view wx:if="{{item.checked}}">
+                  <input style=" width: 120rpx; display: inline-block;vertical-align: middle;" type="digit" bindinput="inputChange" data-key="commission" bindblur="inputBlurChange" data-id="{{item.staffId}}" data-index="{{index}}" value="{{item.commission}}" placeholder="" />
+                </view>
+                <view wx:else>
+                  {{item.commission}}
+                </view>
+              </view>
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+
+  </view>
+</view>
+
+
+
+<van-divider wx:if="{{nomore}}" contentPosition="center" borderColor="#DCDCDC">到底了~</van-divider>
+<view style="height:200rpx;width:100%"></view>
+
+<view class="bottom-class-1" >
+  <view style="position:fixed;bottom:0;z-index: 10;text-align: center;width: 100%; margin-bottom: 42rpx;">
+  <van-button color="#1B365D;" type="info" custom-style="width: 640rpx;height: 88rpx;" block round bindtap="btnOK">确定</van-button>
+</view>
+</view>

+ 158 - 0
package-sales/pages/choose-sale-man/choose-sale-man.wxss

@@ -0,0 +1,158 @@
+
+
+body {
+    background: #eeeeee;
+    height: 100%;
+  }
+  
+  .root {
+    /* width: 100%;
+    height: calc(100%-40rpx);  */
+    height: 100%;
+  }
+  
+  .search {
+    background: #fff;
+    width: 100%;
+    padding: 20rpx;
+    position: fixed;
+    top: 0;
+    z-index: 10;
+  }
+  
+  .search-button {
+    color: #c8c8c8 !important;
+    border-radius: 10rpx !important;
+    width: 96%;
+    height: 60rpx;
+  }
+  
+  .search-button>.van-button__text {
+    font-size: 15px;
+  }
+  
+  .search-wait {
+    height: 100rpx;
+    width: 100%;
+    line-height: 100rpx;
+    text-align: center;
+    color: #c8c8c8;
+    background: #fff;
+  }
+  
+  .pop-search-view {
+    display: flex;
+    justify-content: space-between;
+    background-color: #d9001b;
+    height: 60rpx;
+    padding: 0 3% 0 3%;
+    color: #000;
+  }
+  
+  .panellist {
+    width: 100%;
+    background-color: #fff;
+    /* overflow: hidden; */
+    display: flex;
+    flex-direction: row;
+  }
+  
+  .left {
+    margin-left: 15rpx;
+    width: 50rpx;
+    background-color: #fff;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+  }
+  
+  .right {
+    width: calc(100%-50rpx);
+    /* width: 100%; */
+    /* float: left;  */
+    background-color: #fff;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: flex-start;
+  }
+  
+  .content {
+    padding: var(--cell-vertical-padding, 10rpx) var(--cell-horizontal-padding, 10rpx);
+    /* border-top: 2px #dcdcdc dashed; */
+    /* border-bottom: 1px #ededed solid; */
+    font-size: small;
+  }
+  
+  
+  .content-item {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: flex-start;
+  
+  }
+  
+  .content-item-1 {
+    padding: 10rpx;
+    text-align: left;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+  
+  .footer {
+    color: red;
+  }
+  
+  .footer-info {
+    width: 100%;
+    text-align: right;
+    padding-right: 20rpx;
+    font-size: 20rpx;
+  }
+  
+  .footer-margin {
+    margin-bottom: 10rpx;
+    width: 100%;
+    background-color: #eeeeee
+  }
+  
+  .foot {
+    height: 100rpx;
+    width: 100%;
+    display: flex;
+    position: fixed;
+    left: 0;
+    bottom: 0;
+    z-index: 100;
+    padding-left: 20rpx;
+    background-color: #eeeeee;
+    align-items: center;
+  }
+  
+  .switch {
+    vertical-align: middle;
+    margin-left: 2rpx;
+  }
+  .van-search__content {
+    background: #F8F9FD;
+    border: 1px solid #D6E4FF;
+    border-radius: 15rpx !important;
+  }
+  .van-button--round {
+    border-radius: 15rpx !important;
+}
+
+.bottom-class-1{
+  background:#fff;
+  position:fixed;
+  bottom:0;
+  width:100%;
+  height: 182rpx; 
+  border-top:1px solid #efefef;
+  z-index: 7;
+  box-shadow: 0px -8rpx 24rpx rgba(0, 16, 39, 0.1);
+  border-radius: 30rpx 30rpx 0rpx 0rpx;
+}

+ 5 - 35
package-sales/pages/order-billing/add/add.js

@@ -689,28 +689,9 @@ Page({
       * @date : 2022/5/26 12:16
       */
     openOrgDropdown() {
-        if (this.data.form.apvResult == '审-异常') {
-            return
-        }
-        this.setData({
-            orgGoodsListFlagCopy: false
+        wx.navigateTo({
+            url: '../../account-check/account-check'  
         })
-        //有商品明细的情况下,主业务部门修改,需要提示是否(切换、不切换),点击切换就清空商品明细数据,不切换,需要把业务部门数据调整为修改之前的
-        let orgItem = this.data.orgItem
-        if (this.data.goodsList && this.data.goodsList.length > 0) {
-            orgItem.goodsListFlag = true
-        }
-
-        let orgMain = this.data.orgMain
-        if (orgMain) {
-            wx.navigateTo({
-                url: '../account-check/account-check?orgItem=' + JSON.stringify(orgItem) + '&orgMain=' + JSON.stringify(orgMain) + '&organizationList=' + JSON.stringify(this.data.organizationList),
-            })
-        } else {
-            wx.navigateTo({
-                url: '../account-check/account-check?orgItem=' + JSON.stringify(orgItem) + '&organizationList=' + JSON.stringify(this.data.organizationList),
-            })
-        }
 
     },
 
@@ -720,20 +701,9 @@ Page({
       * @date : 2022/5/26 12:16
       */
     openStaffDropdown() {
-        if (this.data.form.apvResult == '审-异常') {
-            return
-        }
-        let staffItem = this.data.staffItem
-        let staffMain = this.data.staffMain
-        if (staffMain) {
-            wx.navigateTo({
-                url: '../sale-man/sale-man?staffItem=' + JSON.stringify(staffItem) + '&staffMain=' + JSON.stringify(staffMain) + '&staffList=' + JSON.stringify(this.data.staffList ? this.data.staffList : []),
-            })
-        } else {
-            wx.navigateTo({
-                url: '../sale-man/sale-man?staffItem=' + JSON.stringify(staffItem),
-            })
-        }
+        wx.navigateTo({
+            url: '../../choose-sale-man/choose-sale-man'
+        })
 
     },
 

+ 9 - 28
package-sales/pages/order-billing/order-billing.js

@@ -1902,36 +1902,17 @@ Page({
    * @date : 2022/5/28 08:50
    */
   onclik(e) {
-    //订单冲正
-    let ORDER_Receive = common.hasButtonRight(Constants.ORDER_Receive)
-    //订单客户收款
-    let ORDER_Customer_Collection = common.hasButtonRight(Constants.ORDER_Customer_Collection)
-    //订单跟单
-    let ORDER_Return_And_Exchange = common.hasButtonRight(Constants.ORDER_Return_And_Exchange)
-    //销售退货
-    let ORDER_Sale_Return = common.hasButtonRight(Constants.ORDER_Sale_Return)
-    //销售退货冲正
-    let ORDER_Return_Reverse = common.hasButtonRight(Constants.ORDER_Return_Reverse)
-    //订单打印
-    let ORDER_Print = common.hasButtonRight(Constants.ORDER_Print)
-
-    let item = e.currentTarget.dataset.item;
-    // 查看剩余应收是否为0,如果为0,客户收款不用出现
-    if (item.receivable == 0) {
-      ORDER_Customer_Collection = false;
-    }
-    // 如果出库状态是未出,那么销售退货不应该出现
-    if (item.outStatus == '出库状态-未出') {
-      ORDER_Sale_Return = false;
-    }
+    
+
+ 
 
     this.setData({
-      ORDER_Receive: ORDER_Receive,
-      ORDER_Customer_Collection: ORDER_Customer_Collection,
-      ORDER_Return_And_Exchange: ORDER_Return_And_Exchange,
-      ORDER_Sale_Return: ORDER_Sale_Return,
-      ORDER_Return_Reverse: ORDER_Return_Reverse,
-      ORDER_Print: ORDER_Print,
+      ORDER_Receive: true,
+      ORDER_Customer_Collection: true,
+      ORDER_Return_And_Exchange: true,
+      ORDER_Sale_Return: true,
+      ORDER_Return_Reverse: true,
+      ORDER_Print: true,
       bottomItem: e.currentTarget.dataset.item,
       showShare: true
     })