Browse Source

订单增加仓库

fubin 2 years ago
parent
commit
80ee262532

+ 2 - 0
src/api/pages/common/common.js

@@ -111,6 +111,8 @@ export default {
     getPurviewType:'get_purview_type',
     //获取基础数据
     getInitData:'get_init_data',
+    // 获取组织仓库
+    getOrgWh:'get_org_wh',
   },
 }
 

+ 1 - 1
src/components/business/table-select/table-select.vue

@@ -1257,7 +1257,7 @@ export default {
             valueFormat: {code: 'skuName'},
           },
         ]
-        this.modalWidth = 550
+        this.modalWidth = 900
         this.colCount = 2
         this.selectKey = 'skuId'
         this.selectLabel = 'skuName'

+ 9 - 0
src/store/module/user.js

@@ -166,6 +166,12 @@ export default {
     setJoinedCpList(state, joinedCpList){
       state.joinedCpList = joinedCpList
     },
+    setDefaultWhId(state, defaultWhId){
+      state.defaultWhId = defaultWhId
+    },
+    setDefaultWhName(state, defaultWhName){
+      state.defaultWhName = defaultWhName
+    },
   },
   getters: {
     messageUnreadCount: state => state.messageUnreadList.length,
@@ -266,6 +272,9 @@ export default {
       // 记录部门信息
       commit('setOrgId', data.staff.orgId)
       commit('setOrgName', data.staff.orgName)
+      // 默认仓库
+      commit('setDefaultWhId', data.staff.defaultWhId)
+      commit('setDefaultWhName', data.staff.defaultWhName)
       // 角色
       commit('setRoleIds',data.staff.roleIds)
       if(data.settingValue && data.settingValue.setting){

+ 158 - 102
src/view/sale/order/form.vue

@@ -76,25 +76,6 @@
                          @ok="staffOk($event)"
                          :type="this.$config.MagnifierType.staff"/>
           </DkFormItem>
-
-          <!--          &lt;!&ndash;业务部门&ndash;&gt;-->
-          <!--          <DkFormItem prop="orgId" :label="$t('orgId')" :required="true">-->
-          <!--            <SelectMagnifier v-model="formData.orgId" :display-text="formData.orgName"-->
-          <!--                             :type="this.$config.MagnifierType.org"-->
-          <!--                             @ok="orgOk"-->
-          <!--                             :readonly="checkColumnIsEdit('orgId')"-->
-          <!--                             :disabled="checkColumnIsEdit('orgId')"-->
-          <!--                             :multiple="false"/>-->
-          <!--          </DkFormItem>-->
-          <!--          &lt;!&ndash;业务员&ndash;&gt;-->
-          <!--          <DkFormItem prop="staffId" :label="$t('staffId')" :required="true">-->
-          <!--            <SelectMagnifier v-model="formData.staffId" :display-text="formData.staffName"-->
-          <!--                             :type="this.$config.MagnifierType.staff"-->
-          <!--                             @ok="staffOk"-->
-          <!--                             :readonly="checkColumnIsEdit('staffId')"-->
-          <!--                             :disabled="checkColumnIsEdit('staffId')"-->
-          <!--                             :multiple="false"/>-->
-          <!--          </DkFormItem>-->
           <!--客户来源-->
           <DkFormItem prop="cusFrom" :required="true">
             <SelectPop v-model="formData.cusFrom" ref="cusFrom" :multiple="false"
@@ -195,41 +176,36 @@ export default {
   data() {
     let self = this
     return {
-      setCustomerFlag: false,  // 是否是选择客户设置以及编辑时设置
-      loading: false,
-      // 画面表单数据
       formData: {
-        orderId: null, //订单Id
+        orderId: null,
         orderNo: null,
-        orderStatus: self.$config.orderStatus.done,//订单状态
-        cusId: null,//客户Id
+        cusId: null,
         cusName: null,
         cusPhone: null,
         contactName: null,
         contactPhone: null,
-        customerDistrict: null,         // 客户区域
-        addressArea: null,              // 行政区划
-        addressGcj02: null,             // 经纬度
-        addressName: null,              // 小区
-        addressNo: null,                // 门牌号
-        addressFull: null,              // 详细地址
-        staffList: [],//存放从业务员id和分配百分比
-        staffId: null,
-        staffName: null,
-        staffCode: null,
-        orgList: [],//存放从业务部门id和分配百分比
-        orgId: null,
-        orgName: null,
-        orgCode: null,
-        salesChannel: null, //销售渠道
-        cusFrom: null,//客户来源
+        customerDistrict: null,   // 客户区域
+        addressArea: null,        // 行政区划
+        addressGcj02: null,       // 经纬度
+        addressName: null,        // 小区
+        addressNo: null,          // 门牌号
+        addressFull: null,        // 详细地址
+        salesChannel: null,       //销售渠道
+        cusFrom: null,            //客户来源
         deliveryDate: new Date().addDays(1),//送货时间
+        annexPaths: null,
         remarks: null,
         itemList: [],
         deleteItemList: [],
         receiptList: [],
-        annexPaths: null,
+        staffList: [],    //存放从业务员id和分配百分比
+        orgList: [],      //存放从业务部门id和分配百分比
+        orderStatus: self.$config.orderStatus.done, //订单状态
         outStatus: self.$config.outStatus.daiChuKu,
+        staffId: self.$store.state.user.id,
+        staffName: self.$store.state.user.staffName,
+        orgId: self.$store.state.user.orgId,
+        orgName: self.$store.state.user.orgName,
         makeStaff: self.$store.state.user.id,
       },
       //商品合计信息
@@ -249,6 +225,7 @@ export default {
       cityData: [],
       channelList: [],
       cusFromList: [],
+      defaultWhList: [],     // 默认仓库
       addOrderItemColumns: [
         {
           field: 'skuModel',
@@ -279,7 +256,6 @@ export default {
           digits: 2,
           formula: {
             itemAmt: ['itemQty*priceSale', 'itemQty', 'priceSale'],
-            amtStd: ['itemQty*priceStd', 'itemQty', 'priceStd'],
             priceDiscount: ['priceSale/priceStd*100', 'priceSale', 'priceStd'],
           },
         },
@@ -295,6 +271,25 @@ export default {
             priceDiscount: ['priceSale/priceStd*100', 'priceSale', 'priceStd'],
           },
         },
+        // 仓库
+        {
+          field: 'whName',
+          type: 'tableSelect',
+          multiple: false,
+          sortBoolean: false,
+          dataType: self.$config.tableSelectType.warehouse,
+          otherSearchParam: () => {
+            return {
+              skuId: self.currentRow?.skuId,
+              nonStdCode: self.currentRow?.nonStdCode,
+            }
+          },
+          fieldUpdate: [
+            {updateField: 'whId', valueFiled: 'whId'},
+            {updateField: 'whName', valueFiled: 'whName'},
+          ],
+          searchDetailFlag: true
+        },
         //金额
         {
           field: 'itemAmt',
@@ -302,7 +297,7 @@ export default {
           digits: 2,
           number: true,
           sum: true,
-          formulaLate:true,
+          formulaLate: true,
           formula: {
             priceSale: ['itemAmt/itemQty', 'itemAmt', 'itemQty'],
             priceDiscount: ['itemAmt/itemQty/priceStd*100', 'itemAmt', 'itemQty', 'priceStd'],
@@ -360,7 +355,6 @@ export default {
           digits: 2,
           formula: {
             itemAmt: ['itemQty*priceSale', 'itemQty', 'priceSale'],
-            amtStd: ['itemQty*priceStd', 'itemQty', 'priceStd'],
             priceDiscount: ['priceSale/priceStd*100', 'priceSale', 'priceStd'],
           },
         },
@@ -376,6 +370,25 @@ export default {
             priceDiscount: ['priceSale/priceStd*100', 'priceSale', 'priceStd'],
           },
         },
+        // 仓库
+        {
+          field: 'whName',
+          type: 'tableSelect',
+          multiple: false,
+          sortBoolean: false,
+          dataType: self.$config.tableSelectType.warehouse,
+          otherSearchParam: () => {
+            return {
+              skuId: self.currentRow?.skuId,
+              nonStdCode: self.currentRow?.nonStdCode,
+            }
+          },
+          fieldUpdate: [
+            {updateField: 'whId', valueFiled: 'whId'},
+            {updateField: 'whName', valueFiled: 'whName'},
+          ],
+          searchDetailFlag: true
+        },
         //金额
         {
           field: 'itemAmt',
@@ -453,7 +466,6 @@ export default {
           field: 'remarks', type: 'text', equal: true,
         },
       ],
-      receiptList: [],//定金
     }
   },
 
@@ -464,10 +476,12 @@ export default {
      * @date   : 2024-02-20 15:53
      */
     initData() {
-      //获取渠道
-      this.getChannel()
-      //获取数据字典
-      this.getDictionaryData()
+      // 获取渠道
+      this.getChannel();
+      // 获取数据字典
+      this.getDictionaryData();
+      // 获取默认仓库
+      this.getDefaultWh();
 
       // 设置默认业务员业务部门
       this.formData.staffList = []
@@ -486,11 +500,6 @@ export default {
       org.allocationRatio = 100;
       org.ownerFlag = true;
       this.formData.orgList.push(org);
-
-      this.formData.staffId = this.$store.state.user.id
-      this.formData.staffName = this.$store.state.user.staffName
-      this.formData.orgId = this.$store.state.user.orgId
-      this.formData.orgName = this.$store.state.user.orgName
     },
     /**
      * @desc   : 获取渠道
@@ -520,7 +529,35 @@ export default {
       })
     },
     /**
-     *   @desc   : 获取业务员相关
+     * @desc   : 获取默认仓库
+     * @author : 付斌
+     * @date   : 2024-03-02 11:15
+     */
+    getDefaultWh(orgId) {
+      if (!orgId) {
+        orgId = this.$store.state.user.orgId
+      }
+      let params = {orgId: orgId}
+      this.excute(this.$service.commonService, this.$service.commonService.getOrgWh, params, false).then(res => {
+        if (res.code === this.$config.SUCCESS_CODE) {
+          let list = res.data.filter(it => it.flgDefault)
+          if (list.length > 0) {
+            this.defaultWhList = list
+          } else {
+            this.excute(this.$service.commonService, this.$service.commonService.getWarehouse, {}, false).then(res => {
+              if (res.code === this.$config.SUCCESS_CODE) {
+                let list = res.data.filter(it => it.flgDefault)
+                if (list.length > 0) {
+                  this.defaultWhList = list
+                }
+              }
+            })
+          }
+        }
+      })
+    },
+    /**
+     *   @desc   : 业务部门OK
      *   @date   : 2022/5/28 10:43
      *   @author : 付斌
      */
@@ -528,14 +565,15 @@ export default {
       if (rows && rows.length > 0) {
         this.formData.orgList = []
         for (let i of rows) {
-          //找到主业务员
+          //找到主部门
           if (i.ownerFlag) {
             this.formData.orgId = i.orgId
             this.formData.orgCode = i.orgCode
             this.formData.orgName = i.orgName
             this.formData.allocationRatio = i.allocationRatio
+            this.getDefaultWh(i.orgId);
           }
-          //存放从业务员id和分配比
+          //存放从部门id和分配比
           this.formData.orgList.push({
             orgId: i.orgId,
             orgCode: i.orgCode,
@@ -544,10 +582,22 @@ export default {
             ownerFlag: i.ownerFlag
           })
         }
+        // 设置默认仓库
+        if (this.defaultWhList && this.defaultWhList.length > 0) {
+          let table = this.$refs['goodsTable'].tableData
+          if (table && table.length > 0) {
+            table.forEach(row => {
+              if (!row["whId"] || row["whId"] == '') {
+                this.$set(row, 'whId', this.defaultWhList[0].whId);
+                this.$set(row, 'whName', this.defaultWhList[0].whName);
+              }
+            })
+          }
+        }
       }
     },
     /**
-     *   @desc   : 获取业务员相关
+     *   @desc   : 业务员OK
      *   @date   : 2022/5/28 10:43
      *   @author : 付斌
      */
@@ -640,7 +690,7 @@ export default {
      */
     setAddressFull(e) {
       // 客户区域有值才会拼接详细地址
-      if (!this.setCustomerFlag && this.formData.customerDistrict && this.formData.customerDistrict.addressFull) {
+      if (this.formData.customerDistrict && this.formData.customerDistrict.addressFull) {
         this.formData.addressFull = this.formData.customerDistrict.addressFull + (this.formData.addressNo ? this.formData.addressNo : '')
       }
     },
@@ -650,7 +700,6 @@ export default {
      * @date   : 2024-02-27 10:36
      */
     clearCutomer() {
-      this.setCustomerFlag = true;
       this.formData.customerDistrict = null;
       this.formData.cusId = null
       this.formData.cusCode = null
@@ -662,28 +711,15 @@ export default {
       this.addressArea = []
       this.formData.addressName = null
       this.formData.addressNo = null
-
       this.formData.latitude = null
       this.formData.longitude = null
       this.formData.cusFrom = null;
-      // 清空收款
-      if (this.$refs['amtHandle']) {
-        this.$refs['amtHandle'].clear();
-      }
+
       // 清空客户区域
       if (this.$refs.customerDistrict) {
         this.$refs.customerDistrict.clear();
       }
       this.formData.addressFull = null;
-      this.setCustomerFlag = false;
-    },
-    /**
-     * @desc   : 收款金额
-     * @author : 付斌
-     * @date   : 2022/6/17 9:10
-     */
-    chooseReceipt(amount, list, remarks, annexPaths) {
-
     },
     /**
      *   @desc   : 获取商品表格中数量、金额后计算总单信息
@@ -691,7 +727,7 @@ export default {
      *   @author : 付斌
      */
     getTotals(field, row, rowIndex) {
-      let table = this.$refs['goodsTable'].getTableDataFilter();
+      let table = this.$refs['goodsTable'].tableData
       let sumQuantity = 0;  // 合计数量
       let sumAmount = 0;    // 货物金额
       let sumStandard = 0;  // 标价总额
@@ -705,12 +741,17 @@ export default {
           }
           this.$set(row, 'amtStd', parseFloat(row["itemQty"]) * parseFloat(row["priceStd"]));
           sumStandard += parseFloat(row["amtStd"]);
+
+          if (!row["whId"] || row["whId"] == '') {
+            this.$set(row, 'whId', this.defaultWhList[0].whId);
+            this.$set(row, 'whName', this.defaultWhList[0].whName);
+          }
         })
-        this.goodsFootFormData.sumQuantity = sumQuantity;
-        this.goodsFootFormData.sumAmount = sumAmount;
-        this.goodsFootFormData.sumStandard = sumStandard;
-        this.goodsFootFormData.saleDiscount = (sumAmount / sumStandard * 100).toFixed(2);
       }
+      this.goodsFootFormData.sumQuantity = sumQuantity;
+      this.goodsFootFormData.sumAmount = sumAmount;
+      this.goodsFootFormData.sumStandard = sumStandard;
+      this.goodsFootFormData.saleDiscount = (sumAmount / sumStandard * 100).toFixed(2);
     },
     /**
      * @desc   : 通过id查询
@@ -823,46 +864,61 @@ export default {
      */
     clear() {
       let self = this
-      this.setCustomerFlag = true;
       this.formData = {
-        orderId: null, //订单Id
+        orderId: null,
         orderNo: null,
-        orderStatus: self.$config.orderStatus.done,//订单状态
-        cusId: null,//客户Id
+        cusId: null,
         cusName: null,
         cusPhone: null,
         contactName: null,
         contactPhone: null,
-        customerDistrict: null,         // 客户区域
-        addressArea: null,              // 行政区划
-        addressGcj02: null,             // 经纬度
-        addressName: null,              // 小区
-        addressNo: null,                // 门牌号
-        addressFull: null,              // 详细地址
-        staffList: [],//存放从业务员id和分配百分比
-        staffId: null,
-        staffName: null,
-        staffCode: null,
-        orgList: [],//存放从业务部门id和分配百分比
-        orgId: null,
-        orgName: null,
-        orgCode: null,
-        salesChannel: null, //销售渠道
-        cusFrom: null,//客户来源
+        customerDistrict: null,   // 客户区域
+        addressArea: null,        // 行政区划
+        addressGcj02: null,       // 经纬度
+        addressName: null,        // 小区
+        addressNo: null,          // 门牌号
+        addressFull: null,        // 详细地址
+        salesChannel: null,       //销售渠道
+        cusFrom: null,            //客户来源
         deliveryDate: new Date().addDays(1),//送货时间
+        annexPaths: null,
         remarks: null,
         itemList: [],
         deleteItemList: [],
         receiptList: [],
-        annexPaths: null,
+        staffList: [],    //存放从业务员id和分配百分比
+        orgList: [],      //存放从业务部门id和分配百分比
+        orderStatus: self.$config.orderStatus.done, //订单状态
         outStatus: self.$config.outStatus.daiChuKu,
+        staffId: self.$store.state.user.id,
+        staffName: self.$store.state.user.staffName,
+        orgId: self.$store.state.user.orgId,
+        orgName: self.$store.state.user.orgName,
         makeStaff: self.$store.state.user.id,
       }
+
+      // 设置默认业务员业务部门
+      this.formData.staffList = []
+      let staff = {}
+      staff.staffId = this.$store.state.user.staffId
+      staff.staffCode = this.$store.state.user.staffCode
+      staff.staffName = this.$store.state.user.staffName
+      staff.allocationRatio = 100;
+      staff.ownerFlag = true;
+      this.formData.staffList.push(staff);
+
+      this.formData.orgList = []
+      let org = {}
+      org.orgId = this.$store.state.user.orgId
+      org.orgName = this.$store.state.user.orgName
+      org.allocationRatio = 100;
+      org.ownerFlag = true;
+      this.formData.orgList.push(org);
+
       // 清空客户区域
       if (this.$refs.customerDistrict) {
         this.$refs.customerDistrict.clear();
       }
-      this.setCustomerFlag = false;
     },
     /**
      * @desc   : 判断列是否可以编辑