浏览代码

Merge branch 'master' of http://git.zthymaoyi.com/gdc/yiliangyiyun-pc

achao 2 年之前
父节点
当前提交
36fda9542b

+ 1 - 1
src/layout/index/top/index.vue

@@ -56,7 +56,7 @@
       </div>
       <div class="compName-row">
         <!-- <span class="compName">{{compName}}</span> -->
-        <el-select style='width:260px;' @change='compNameChange' v-model="compName" placeholder="请选择">
+        <el-select style='width:260px;' @change='compNameChange' disabled v-model="compName" placeholder="请选择">
         <el-option
           v-for="item in compNameoptions"
           :key="item"

+ 1 - 1
src/views/home/index.vue

@@ -169,7 +169,7 @@ export default {
 
     this.dataListTimer = setInterval(() => {
       this.selectData(1)
-      }, 30000);
+      }, 10*60000);
     
 
   },

+ 22 - 21
src/views/profitable/cashout.vue

@@ -126,10 +126,10 @@
               @change="dateChange">
             </el-date-picker>
         </div>
-        <ws-select v-if='deptBudgetList.purpose == "库点费用" && deptBudgetList.flag == "否" &&mode != "暂不分配"' :disabled='disabled' v-model="orderId" placeholder="全部客户" 
+        <ws-select v-if='(deptBudgetList.purpose == "库点费用"  &&mode != "暂不分配"&& deptBudgetList.flag == "否")'  v-model="goodsSource" placeholder="全部客户" 
             @change='sourceChange'>
-            <ws-option key="全部客户" label="全部客户" value="" style="color: #8890b1" />
-            <ws-option v-for="item in customerList" :key="item.id" :label="item.goodsSource" :value="item.id"
+            <ws-option key="全部客户" label="全部客户" value="全部客户" style="color: #8890b1" />
+            <ws-option v-for="item in customerList" :key="item.goodsSource" :label="item.goodsSource" :value="item.goodsSource"
               style="color: #8890b1" />
         </ws-select>
         <el-button @click="queren" v-if='deptBudgetList.purpose == "库点费用" && deptBudgetList.flag == "否" &&mode != "暂不分配"'>确认</el-button>
@@ -167,11 +167,16 @@
           <el-table-column v-if='deptBudgetList.purpose=="库点费用"||deptBudgetList.purpose=="合同费用"' prop="date" label="货源">
               <template slot-scope="scope">
                 <!-- {{scope.row.goodsourcelist}} -->
-                <el-select class="goodsource" v-if="scope.row.orderId &&confirmFlag==0" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                <!-- <el-select class="goodsource" v-if="scope.row.orderId &&confirmFlag==0" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
                     <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
                         style="color: #8890b1" />
                 </el-select>
-                <el-select class="goodsource" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                <el-select class="goodsource" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})"> -->
+                <el-select style="width: 100%;" v-if="(scope.row.orderId &&confirmFlag==0 && !scope.row.goodsSource)" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select>
+                <el-select style="width: 100%;" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
                     <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
                         style="color: #8890b1" />
                 </el-select>
@@ -292,29 +297,25 @@
     // 计算属性的 getter
       amount: function () {
         // `this` 指向 vm 实例
-        var num=0
-        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-          if(this.feeDetailsDistributions[i].distributionMoney){
-            num+=Number(this.feeDetailsDistributions[i].distributionMoney)
-          }
-        }
-        return num
-      }
+         var num = 0
+         if (this.feeDetailsDistributions) {
+           for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+             if (this.feeDetailsDistributions[i].distributionMoney) {
+               num += Number(this.feeDetailsDistributions[i].distributionMoney)
+             }
+           }
+           return num
+         }
+       }
     },
     methods: {
       sourceChange(e) {
       if (e == '') {
         this.goodsSource = '全部客户'
-        this.selectOrderList()
       } else {
-        for (let i = 0; i < this.customerList.length; i++) {
-          if (this.customerList[i].id == e) {
-            this.goodsSource = this.customerList[i].goodsSource
-            this.orderId = this.customerList[i].id
-            this.selectOrderList()
-          }
-        }
+        this.goodsSource  = e
       }
+        this.selectOrderList()
     },
       getNowTime() {
       const start = new Date(new Date().getTime() - 3600 * 1000 * 24)

+ 6 - 2
src/views/profitable/cashoutaduit.vue

@@ -29,6 +29,10 @@
                 <ws-option label="保证金" value="5" style="color: #8890b1" />
             </ws-select>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouse" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -129,7 +133,7 @@
           </el-table>
 
       </div> -->
-      <div>
+      <div v-if='(deptBudgetList.expensesPurpose==2)'>
         <div class="wenzi">车辆详情</div>
         <el-table :data="deptBudgetList.tranSettlementReportList" style="width: 90%; margin: 20px auto; " ref="warehouseList"  >
         <el-table-column type="index" label="序号" width="50"></el-table-column>
@@ -217,7 +221,7 @@ import WsUpload from '@/components/WsUpload'
       return {
         value: [],
         profitList: [{
-          name: "玉米",
+          name: '玉米',
           count: 2000,
         }],
         mode:'全部分配',

+ 218 - 22
src/views/profitable/cashoutaduitNQ.vue

@@ -24,6 +24,10 @@
               <span v-if='deptBudgetList.costType==3'>非粮款</span>
               <span v-if='deptBudgetList.costType==5'>保证金</span>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouse" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -71,8 +75,8 @@
             <el-input disabled class='input50 input_css' placeholder="输入开户支行" v-model="deptBudgetList.bankBranch"></el-input>
           </el-form-item>
         </el-form>
-        <div class="wenzi">车辆详情</div>
-        <el-table :data="deptBudgetList.tranSettlementReportList" style="width: 90%; margin: 20px auto; " ref="warehouseList"  >
+        <div class="wenzi" v-if='(deptBudgetList.expensesPurpose==2)'>车辆详情</div>
+        <el-table :data="deptBudgetList.tranSettlementReportList" v-if='(deptBudgetList.expensesPurpose==2)' style="width: 90%; margin: 20px auto; " ref="warehouseList"  >
         <el-table-column type="index" label="序号" width="50"></el-table-column>
         <el-table-column class="table_td" prop="contractNo" width="120" label="合同编号"></el-table-column>
         <el-table-column class="table_td" prop="startAddress" width="120" label="发货库"></el-table-column>
@@ -117,7 +121,7 @@
         <!-- 经营性费用不分配 -->
         <div v-if='deptBudgetList.expensesPurpose!=5'>
           <div style='margin:0 50px 10px;font-weight:bold'>费用分配</div>
-        <div style='margin:10px auto;width:90%;'>
+        <div style='margin:10px auto;width:90%;display: flex;'>
             <ws-select v-model="mode" placeholder="费用分配方式" class="typeselect" @change="modeselect">
           <ws-option v-for="item in modeList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
@@ -126,7 +130,22 @@
           <ws-option v-for="item in moneysList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
         </ws-select>
-        合计分配:{{amount}}元
+        <div style='width:30%;' v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>
+            <el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
+              start-placeholder="开始日期" value-format='yyyy-MM-dd' end-placeholder="结束日期" :picker-options="pickerOptions"
+              @change="dateChange">
+            </el-date-picker>
+        </div>
+        <!-- && deptBudgetList.flag == "否" -->
+        <!-- :disabled='disabled' -->
+        <el-button type="primary" @click="queren" v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>确认</el-button>
+        <ws-select v-if='(deptBudgetList.purpose == "库点费用"  &&mode != "暂不分配"&& deptBudgetList.storageFeeFlag==0)'  v-model="goodsSource" placeholder="全部客户" 
+            @change='sourceChange'>
+            <ws-option key="全部客户" label="全部客户" value="全部客户" style="color: #8890b1" />
+            <ws-option v-for="item in customerList" :key="item.goodsSource" :label="item.goodsSource" :value="item.goodsSource"
+              style="color: #8890b1" />
+        </ws-select>
+        <span style="margin-top:5px" v-if='mode!="暂不分配"'>合计分配:{{amount}}元</span>
         </div>
         </div>
  
@@ -156,7 +175,15 @@
           <el-table-column v-if='deptBudgetList.purpose=="库点费用"' prop="date" label="货源">
               <template slot-scope="scope">
                 <!-- {{scope.row.goodsourcelist}} -->
-                <el-select class="goodsource" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                <!-- <el-select v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select> -->
+                <el-select style="width: 100%;" v-if="(scope.row.orderId &&confirmFlag==0 && !scope.row.goodsSource)" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select>
+                <el-select style="width: 100%;" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
                     <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
                         style="color: #8890b1" />
                 </el-select>
@@ -220,13 +247,30 @@
     import {
     woekflowhandle
   } from '@/model/tasksport/index'
-  import {lookexenseinfo,getcontract,getwarehouse,addexenseinfo,getwarehousingorder,editexenseinfo} from '@/model/profitable/index'
+  import {lookexenseinfo,getcontract,getwarehouse,addexenseinfo,getwarehousingorder,editexenseinfo,getwarehousingorderList,deloneallocationinfo } from '@/model/profitable/index'
   export default {
     components: {
       WsUpload,
     },
     data() {
       return {
+        customerList: [],
+        goodsSource: '',
+        value2: '',
+        endDate: '',
+        startDate: '',
+        baseId: '',
+        warehouseName:'',
+        currentPage: 1,
+        pageSize: 10,
+        searchType: '',
+        searchKeyWord: '',
+        goodsName: '',
+        //是否按时间筛选标识,1是
+        confirmFlag: 0,
+        datas: [],
+        datas1: [],
+        orderId: '',
         value: [],
         profitList: [{
           name: '玉米',
@@ -269,22 +313,124 @@
       }
     },
     activated() {
+      this.value2 = this.getNowTime()
       this.getList()
     },
     computed: {
     // 计算属性的 getter
       amount: function () {
         // `this` 指向 vm 实例
-        var num=0
-        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-          if(this.feeDetailsDistributions[i].distributionMoney){
-            num+=Number(this.feeDetailsDistributions[i].distributionMoney)
+        var num = 0
+        if (this.feeDetailsDistributions) {
+          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+            if (this.feeDetailsDistributions[i].distributionMoney) {
+              num += Number(this.feeDetailsDistributions[i].distributionMoney)
+            }
           }
+          return num
         }
-        return num
       }
     },
     methods: {
+      sourceChange(e) {
+      if (e == '') {
+        this.goodsSource = '全部客户'
+      } else {
+        this.goodsSource  = e
+      }
+        this.selectOrderList()
+    },
+      getNowTime() {
+      const start = new Date(new Date().getTime() - 3600 * 1000 * 24)
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0] //默认开始时间1天前
+      const end = new Date(new Date().getTime())
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0]//默认结束时间今天
+      // console.log([start.split(' '), end])
+      return [start.split(' ')[0], end.split(' ')[0]]
+    },
+      queren() {
+      this.confirmFlag = 1
+      this.selectOrderList()
+    },
+    dateChange(e) {
+      this.value2 = e
+    },
+    selectOrderList() {
+      var arr = []
+      var weight = 0
+      var money = 0
+      var moneyDiff = 0
+      this.startDate = this.value2[0]
+      this.endDate = this.value2[1]
+      getwarehousingorderList({
+        compId: localStorage.getItem('ws-pf_compId'),
+        startDate: this.startDate,
+        endDate: this.endDate,
+        baseId: this.deptBudgetList.warehouseId,
+        warehouseName : this.deptBudgetList.warehouseName,
+        currentPage: this.currentPage,
+        pageSize: this.pageSize,
+        searchType: this.searchType,
+        searchKeyWord: this.searchKeyWord,
+        goodsName: this.goodsName,
+        goodsSource: this.goodsSource == '全部客户' ? '' : this.goodsSource
+      })
+        .toPromise()
+        .then((response) => {
+          this.datas = []
+          this.datas1 = []
+          if (this.goodsSource && this.goodsSource != '全部客户') {
+            for (let i = 0; i < response.records.length; i++) {
+              this.datas.push(response.records[i])
+            }
+            //
+            for (let z = 0; z < this.datas.length; z++) {
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource , id: '', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+          } else {
+            for (let i = 0; i < response.records.length; i++) {
+              for (let j = 0; j < response.records[i].warehousingOrderList.length; j++) {
+                this.datas.push(response.records[i].warehousingOrderList[j])
+              }
+              
+            }
+            for (let z = 0; z < this.datas.length; z++) {
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource,orderId:this.datas[z].id, id: '', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+
+            //获取客户
+            this.customerList = this.unique(arr)
+          }
+          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+            this.feeDetailsDistributions[i].inWarehouseWeight = this.feeDetailsDistributions[i].weight
+            weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
+          }
+          if (this.moneys == '按重量自动分配') {
+            for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+              if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+            }
+          }
+        })
+    },
+    unique(arr) {
+      const res = new Map();
+      return arr.filter((arr) => !res.has(arr.goodsSource) && res.set(arr.goodsSource, 1));
+    },
       handleClose(){
         this.rejectshow=false
       },
@@ -322,6 +468,7 @@
       },
       selectgoodsSource(e,item,index){
         var weight=0
+        var moneyDiff = 0
         console.log(e)
         var money=0
         if(!this.deptBudgetList.amountMoney&&this.moneys=='按重量自动分配'){
@@ -342,17 +489,35 @@
             this.feeDetailsDistributions[index].inWarehouseWeight=this.goodsourcelist[index][i].weight
             this.feeDetailsDistributions[index].goodsName=this.goodsourcelist[index][i].goodsName
             this.feeDetailsDistributions[index].goodsNameKey=this.goodsourcelist[index][i].goodsNameKey
+            this.feeDetailsDistributions[index].orderId = this.goodsourcelist[index][i].id
             }
         }
-        if(this.moneys=='按重量自动分配'){
-          weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
-              return total + currentValue.inWarehouseWeight;
-          }, 0)
-          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-              this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
-              money+=this.feeDetailsDistributions[i].distributionMoney
-          }
+        // if(this.moneys=='按重量自动分配'){
+        //   weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
+        //       return total + currentValue.inWarehouseWeight;
+        //   }, 0)
+        //   for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+        //       this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
+        //       money+=this.feeDetailsDistributions[i].distributionMoney
+        //   }
+        // }
+        if (this.moneys == '按重量自动分配') {
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
+        }
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
         }
+      }
       },
       selecttime(e,item,index){
         var weight=0
@@ -451,6 +616,7 @@
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].orderId==item.orderId&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -481,6 +647,7 @@
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].warehouseName==item.warehouseName&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -608,9 +775,38 @@
       addlist(){
         this.feeDetailsDistributions.push({proDate:'',weight:'',money:'',warehouse:'',belonging:'',index:this.feeDetailsDistributions.length})
       },
-      dellist(row){
-          this.feeDetailsDistributions.splice(row.index,1)
-      },
+      dellist(row) {
+      var weight = 0
+      var money = 0
+      var moneyDiff = 0
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          if (this.feeDetailsDistributions[i]) {
+            if (this.feeDetailsDistributions[i] == row) {
+              this.feeDetailsDistributions.splice(i, 1)
+              if (this.moneys == '按重量自动分配' ) {
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  weight += this.feeDetailsDistributions[i].inWarehouseWeight
+                }
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+              
+                }
+              }
+              deloneallocationinfo({ id: row.id }).toPromise().then((response) => {
+                  })
+            }
+          }
+        }
+    },
       getList() {
         getcontract({
           compId:localStorage.getItem('ws-pf_compId'),

+ 227 - 23
src/views/profitable/expenseallot.vue

@@ -25,6 +25,10 @@
               <span v-if='deptBudgetList.costType==3'>非粮款</span>
               <span v-if='deptBudgetList.costType==5'>保证金</span>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouse" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -64,8 +68,7 @@
           <div style='margin:0 50px 10px;font-weight:bold'>费用分配</div>
           <div>可分配金额{{deptBudgetList.unallocatedAmount}}元</div>
         </div>
-        
-        <div style='margin:10px auto;width:90%;'>
+        <div style='margin:10px auto;width:90%;display: flex;'>
             <ws-select v-model="mode" placeholder="费用分配方式" class="typeselect" @change="modeselect">
           <ws-option v-for="item in modeList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
@@ -74,7 +77,21 @@
           <ws-option v-for="item in moneysList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
         </ws-select>
-        合计分配:{{amount}}元
+        <div style='width:30%;' v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>
+            <el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
+              start-placeholder="开始日期" value-format='yyyy-MM-dd' end-placeholder="结束日期" :picker-options="pickerOptions"
+              @change="dateChange">
+            </el-date-picker>
+        </div>
+        <!-- && deptBudgetList.flag == "否"  :disabled='disabled'-->
+        <el-button type="primary" @click="queren" v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>确认</el-button>
+        <ws-select v-if='(deptBudgetList.purpose == "库点费用"  &&mode != "暂不分配"&& deptBudgetList.storageFeeFlag==0)'  v-model="goodsSource" placeholder="全部客户" 
+            @change='sourceChange'>
+            <ws-option key="全部客户" label="全部客户" value="全部客户" style="color: #8890b1" />
+            <ws-option v-for="item in customerList" :key="item.goodsSource" :label="item.goodsSource" :value="item.goodsSource"
+              style="color: #8890b1" />
+        </ws-select>
+        <span style="margin-top:5px" v-if='mode!="暂不分配"'>合计分配:{{amount}}元</span>  
         </div>
         <el-table ref="tableref" v-if='deptBudgetList.expensesPurpose==1&&deptBudgetList.type=="非粮款"&&mode!="暂不分配"||deptBudgetList.expensesPurpose==3&&mode!="暂不分配"||deptBudgetList.expensesPurpose==2&&mode!="暂不分配"' :data="feeDetailsDistributions" style="width: 90%;margin:0 auto;">
           <el-table-column width="200" v-if='deptBudgetList.expensesPurpose==1' prop="date" label="仓库名称" min-width="110">
@@ -112,9 +129,17 @@
             </template>
           </el-table-column>
           <el-table-column v-if='deptBudgetList.expensesPurpose==3||deptBudgetList.expensesPurpose==2||deptBudgetList.expensesPurpose==1' prop="date" label="货源">
-              <template slot-scope="scope">
+              <template slot-scope="scope" >
                 <!-- {{scope.row.goodsourcelist}} -->
-                <el-select class="goodsource" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                <!-- <el-select v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select> -->
+                <el-select style="width: 100%;" v-if="(scope.row.orderId && confirmFlag==0 && !scope.row.goodsSource)" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select>
+                <el-select style="width: 100%;" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
                     <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
                         style="color: #8890b1" />
                 </el-select>
@@ -155,7 +180,7 @@
 </template>
 <script>
   import WsUpload from '@/components/WsUpload'
-  import {lookexenseinfo,getcontract,getwarehouse,addexenseinfo,getwarehousingorder,editexenseinfo} from '@/model/profitable/index'
+  import {lookexenseinfo,getcontract,getwarehouse,addexenseinfo,getwarehousingorder,editexenseinfo,getwarehousingorderList,deloneallocationinfo} from '@/model/profitable/index'
   export default {
     components: {
       WsUpload,
@@ -163,8 +188,25 @@
     data() {
       return {
         value: [],
+        customerList: [],
+        goodsSource: '',
+        value2: '',
+        endDate: '',
+        startDate: '',
+        baseId: '',
+        warehouseName:'',
+        currentPage: 1,
+        pageSize: 10,
+        searchType: '',
+        searchKeyWord: '',
+        goodsName: '',
+        //是否按时间筛选标识,1是
+        confirmFlag: 0,
+        datas: [],
+        datas1:[],
+        orderId: '',
         profitList: [{
-          name: "玉米",
+          name: '玉米',
           count: 2000,
         }],
         mode:'全部分配',
@@ -201,6 +243,7 @@
       }
     },
     activated() {
+      this.value2 = this.getNowTime()
       this.getList()
     },
     computed: {
@@ -208,15 +251,126 @@
       amount: function () {
         // `this` 指向 vm 实例
         var num=0
-        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-          if(this.feeDetailsDistributions[i].distributionMoney){
-            num+=Number(this.feeDetailsDistributions[i].distributionMoney)
+        if (this.feeDetailsDistributions) {
+          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+            if (this.feeDetailsDistributions[i].distributionMoney) {
+              num += Number(this.feeDetailsDistributions[i].distributionMoney)
+            }
           }
+          return num
         }
-        return num
+        
       }
     },
     methods: {
+      sourceChange(e) {
+      if (e == '') {
+        this.goodsSource = '全部客户'
+      } else {
+        this.goodsSource  = e
+      }
+        this.selectOrderList()
+    },
+      getNowTime() {
+      const start = new Date(new Date().getTime() - 3600 * 1000 * 24)
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0] //默认开始时间1天前
+      const end = new Date(new Date().getTime())
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0]//默认结束时间今天
+      // console.log([start.split(' '), end])
+      return [start.split(' ')[0], end.split(' ')[0]]
+    },
+      queren() {
+      if (!this.deptBudgetList.amountMoney && this.moneys == '按重量自动分配') {
+        this.$message({
+          message: '请输入金额之后进行操作',
+          type: 'warning',
+        })
+        return
+      }
+      this.confirmFlag = 1
+      this.selectOrderList()
+    },
+    dateChange(e) {
+      this.value2 = e
+    },
+    selectOrderList() {
+      var arr = []
+      var weight = 0
+      var money = 0
+      var moneyDiff = 0
+      this.startDate = this.value2[0]
+      this.endDate = this.value2[1]
+      getwarehousingorderList({
+        compId: localStorage.getItem('ws-pf_compId'),
+        startDate: this.startDate,
+        endDate: this.endDate,
+        baseId: this.deptBudgetList.warehouseId,
+        warehouseName : this.deptBudgetList.warehouseName,
+        currentPage: this.currentPage,
+        pageSize: this.pageSize,
+        searchType: this.searchType,
+        searchKeyWord: this.searchKeyWord,
+        goodsName: this.goodsName,
+        goodsSource: this.goodsSource == '全部客户' ? '' : this.goodsSource
+      })
+        .toPromise()
+        .then((response) => {
+          this.datas = []
+          this.datas1 = []
+          if (this.goodsSource && this.goodsSource != '全部客户') {
+            for (let i = 0; i < response.records.length; i++) {
+              this.datas.push(response.records[i])
+              // for (let x = 0; x < response.records[i].expenseAllocationInfoList.length; x++) {
+              //     this.datas1.push(response.records[i].expenseAllocationInfoList[x])
+              //   }
+            }
+            for (let z = 0; z < this.datas.length; z++) {
+              // this.datas[z].id
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource, id: '', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+          } else {
+            for (let i = 0; i < response.records.length; i++) {
+              for (let j = 0; j < response.records[i].warehousingOrderList.length; j++) {
+                this.datas.push(response.records[i].warehousingOrderList[j])
+              }
+            }
+            for (let z = 0; z < this.datas.length; z++) {
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource,orderId:this.datas[z].id, id:'', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+
+            //获取客户
+            this.customerList = this.unique(arr)
+          }
+          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+            this.feeDetailsDistributions[i].inWarehouseWeight = this.feeDetailsDistributions[i].weight
+            weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
+          }
+          if (this.moneys == '按重量自动分配') {
+            for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+              if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.unallocatedAmount)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.unallocatedAmount - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+            }
+          }
+        })
+    },
+    unique(arr) {
+      const res = new Map();
+      return arr.filter((arr) => !res.has(arr.goodsSource) && res.set(arr.goodsSource, 1));
+    },
       modeselect(e){
         if(e=='全部分配'){
           this.moneys='按重量自动分配'
@@ -240,8 +394,8 @@
       },
       selectgoodsSource(e,item,index){
         var weight=0
-        console.log(e)
         var money=0
+        var moneyDiff = 0
         if(!this.deptBudgetList.amountMoney&&this.moneys=='按重量自动分配'){
           for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
             if(this.feeDetailsDistributions[i].orderId==e){
@@ -260,17 +414,35 @@
             this.feeDetailsDistributions[index].inWarehouseWeight=this.goodsourcelist[index][i].weight
             this.feeDetailsDistributions[index].goodsName=this.goodsourcelist[index][i].goodsName
             this.feeDetailsDistributions[index].goodsNameKey=this.goodsourcelist[index][i].goodsNameKey
+            this.feeDetailsDistributions[index].orderId = this.goodsourcelist[index][i].id
             }
         }
-        if(this.moneys=='按重量自动分配'){
-          weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
-              return total + currentValue.inWarehouseWeight;
-          }, 0)
-          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-              this.$set(this.feeDetailsDistributions[i],'distributionMoney',Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney))
-              money+=this.feeDetailsDistributions[i].distributionMoney
-          }
+        // if(this.moneys=='按重量自动分配'){
+        //   weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
+        //       return total + currentValue.inWarehouseWeight;
+        //   }, 0)
+        //   for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+        //       this.$set(this.feeDetailsDistributions[i],'distributionMoney',Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney))
+        //       money+=this.feeDetailsDistributions[i].distributionMoney
+        //   }
+        // }
+        if (this.moneys == '按重量自动分配') {
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
+        }
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.unallocatedAmount)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.unallocatedAmount - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
         }
+      }
       },
       selecttime(e,item,index){
         var weight=0
@@ -374,6 +546,7 @@
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].orderId==item.orderId&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -404,6 +577,7 @@
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].warehouseName==item.warehouseName&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -462,9 +636,38 @@
       addlist(){
         this.feeDetailsDistributions.push({proDate:'',weight:'',money:'',warehouse:'',belonging:'',index:this.feeDetailsDistributions.length})
       },
-      dellist(row){
-          this.feeDetailsDistributions.splice(row.index,1)
-      },
+      dellist(row) {
+      var weight = 0
+      var money = 0
+      var moneyDiff = 0
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          if (this.feeDetailsDistributions[i]) {
+            if (this.feeDetailsDistributions[i] == row) {
+              this.feeDetailsDistributions.splice(i, 1)
+              if (this.moneys == '按重量自动分配' ) {
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  weight += this.feeDetailsDistributions[i].inWarehouseWeight
+                }
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.unallocatedAmount)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.unallocatedAmount - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+              
+                }
+              }
+              deloneallocationinfo({ id: row.id }).toPromise().then((response) => {
+                  })
+            }
+          }
+        }
+    },
       getList() {
         getcontract({
           compId:localStorage.getItem('ws-pf_compId'),
@@ -494,6 +697,7 @@
             response.type='保证金'
           }
           this.deptBudgetList=response 
+          this.feeDetailsDistributions = this.deptBudgetList.expenseAllocationInfoList
           if(response.addressUrl){
             var arr=[]
             var srcs=response.addressUrl.split(',')

+ 6 - 2
src/views/profitable/expenseallotaduit.vue

@@ -31,6 +31,10 @@
                 <ws-option label="保证金" value="5" style="color: #8890b1" />
             </ws-select>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouse" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -109,7 +113,7 @@
             </el-table-column>
             <el-table-column v-if='deptBudgetList.expensesPurpose==3' prop="date" label="货源">
                 <template slot-scope="scope">
-                  <ws-select disabled v-model="scope.row.goodsSource" placeholder="选择货源">
+                  <ws-select disabled v-model="scope.row.goodsSource" placeholder="选择货源" style="width: 100%;">
                       <ws-option v-for="item in goodsourcelist" :key="item.id" :label="item.goodsSource" :value="item.id"
                           style="color: #8890b1" />
                   </ws-select>
@@ -175,7 +179,7 @@
       return {
         value: [],
         profitList: [{
-          name: "玉米",
+          name: '玉米',
           count: 2000,
         }],
         mode:'全部分配',

+ 285 - 61
src/views/profitable/expensemanagentedit.vue

@@ -34,6 +34,10 @@
                 <ws-option label="保证金" value="5" style="color: #8890b1" />
             </ws-select>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouse" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -86,9 +90,9 @@
               <el-input disabled class='input50 input_css' placeholder="输入开户支行" v-model="deptBudgetList.bankBranch"></el-input>
             </el-form-item>
         </el-form>
-        <div v-if='deptBudgetList.purpose=="合同费用"&&deptBudgetList.type=="非粮款"||deptBudgetList.purpose=="库点费用"||deptBudgetList.expensesPurpose==2' class='expensetitle'>费用分配</div>
-        <div v-if='deptBudgetList.purpose=="合同费用"&&deptBudgetList.type=="非粮款"||deptBudgetList.purpose=="库点费用"||deptBudgetList.expensesPurpose==2' style='margin:0  auto 10px;width:90%;'>
-            <ws-select v-model="mode" placeholder="费用分配方式" @change="modeselect">
+        <div v-if='(deptBudgetList.purpose=="合同费用"&&deptBudgetList.type=="非粮款"||deptBudgetList.purpose=="库点费用"&&deptBudgetList.storageFeeFlag==0||deptBudgetList.expensesPurpose==2&&deptBudgetList.storageFeeFlag==0)' class='expensetitle'>费用分配</div>
+        <div v-if='(deptBudgetList.purpose=="合同费用"&&deptBudgetList.type=="非粮款"||deptBudgetList.purpose=="库点费用"&&deptBudgetList.storageFeeFlag==0||deptBudgetList.expensesPurpose==2&&deptBudgetList.storageFeeFlag==0)' style='margin:0  auto 10px;width:90%;display: flex;'>
+          <ws-select v-model="mode" placeholder="费用分配方式" @change="modeselect">
           <ws-option v-for="item in modeList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
         </ws-select>
@@ -111,7 +115,21 @@
           <ws-option v-for="item in moneysList" :key="item.value" :label="item.value" :value="item.value"
             style="color: #8890b1" />
         </ws-select>
-        <span v-if='mode!="暂不分配"'>合计分配:{{amount}}元</span>  
+        <div style='width:30%;' v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>
+            <el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
+              start-placeholder="开始日期" value-format='yyyy-MM-dd' end-placeholder="结束日期" :picker-options="pickerOptions"
+              @change="dateChange">
+            </el-date-picker>
+        </div>
+        <!-- && deptBudgetList.flag == "否"  :disabled='disabled'-->
+        <el-button type="primary" @click="queren" v-if='(deptBudgetList.purpose == "库点费用" &&mode != "暂不分配" && deptBudgetList.storageFeeFlag==0)'>确认</el-button>
+        <ws-select v-if='(deptBudgetList.purpose == "库点费用"  &&mode != "暂不分配"&& deptBudgetList.storageFeeFlag==0)'  v-model="goodsSource" placeholder="全部客户" 
+            @change='sourceChange'>
+            <ws-option key="全部客户" label="全部客户" value="全部客户" style="color: #8890b1" />
+            <ws-option v-for="item in customerList" :key="item.goodsSource" :label="item.goodsSource" :value="item.goodsSource"
+              style="color: #8890b1" />
+        </ws-select>
+        <span style="margin-top:5px" v-if='mode!="暂不分配"'>合计分配:{{amount}}元</span>  
         </div>
         <el-table ref="tableref" v-if='deptBudgetList.purpose=="合同费用"&&deptBudgetList.type=="非粮款"&&mode!="暂不分配"||deptBudgetList.purpose=="库点费用"&&mode!="暂不分配"||deptBudgetList.expensesPurpose==2&&mode!="暂不分配"' :data="feeDetailsDistributions" style="width: 90%;margin:0 auto;">
           <el-table-column width="150" v-if='deptBudgetList.purpose=="合同费用"' prop="date" label="仓库名称" min-width="110">
@@ -153,7 +171,15 @@
           <el-table-column v-if='deptBudgetList.purpose=="库点费用"||deptBudgetList.expensesPurpose==2||deptBudgetList.expensesPurpose==1' prop="date" label="货源">
               <template slot-scope="scope">
                 <!-- {{scope.row.goodsourcelist}} -->
-                <el-select class="goodsource" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                <!-- <el-select v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select> -->
+                <el-select style="width: 100%;" v-if="(scope.row.orderId &&confirmFlag==0 && !scope.row.goodsSource)" v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
+                    <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
+                        style="color: #8890b1" />
+                </el-select>
+                <el-select style="width: 100%;" v-else v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row,scope.$index)})">
                     <el-option v-for="item in goodsourcelist[scope.$index]" :key="item.id" :label="item.goodsSource" :value="item.id"
                         style="color: #8890b1" />
                 </el-select>
@@ -192,16 +218,34 @@
 </template>
 <script>
   import WsUpload from '@/components/WsUpload'
-  import {lookexenseinfo,getcontract,getwarehouse,getwarehousingorder,editexenseinfo,deloneallocationinfo} from '@/model/profitable/index'
+  import {lookexenseinfo,getcontract,getwarehouse,getwarehousingorder,editexenseinfo,deloneallocationinfo,getwarehousingorderList} from '@/model/profitable/index'
   export default {
     components: {
       WsUpload,
     },
     data() {
       return {
+        customerList: [],
+        goodsSource: '',
+        value2: '',
+        endDate: '',
+        startDate: '',
+        baseId: '',
+        warehouseName:'',
+        currentPage: 1,
+        pageSize: 10,
+        searchType: '',
+        searchKeyWord: '',
+        goodsName: '',
+        storageFeeFlag:'',
+        //是否按时间筛选标识,1是
+        confirmFlag: 0,
+        datas: [],
+        datas1:[],
+        orderId: '',
         value: [],
         profitList: [{
-          name: "玉米",
+          name: '玉米',
           count: 2000,
         }],
         mode:'全部分配',
@@ -214,16 +258,16 @@
         compId:localStorage.getItem('ws-pf_compId'),
         // dateRange: this.disabledDate(),
         feeDetailsDistributions:[{receiptDocDate:'',inWarehouseWeight:0,distributionMoney:0,warehouseName:'',goodsName:'',goodsSource:'',index:0,}],
-        deptBudgetList:{purpose:"合同费用",type:'粮款'},
+        deptBudgetList:{purpose:'合同费用',type:'粮款'},
         makeWordData: {},
         warehouseList:[],
         contractList:[],
         choosablewareList:[],
         paymentScreenshot:[],
-        goodsourcelist:[[{goodsName: "玉米",
+        goodsourcelist:[[{goodsName: '玉米',
 goodsNameKey: null,
-goodsSource: "张跃文",
-id: "34e710ed3883484798ab37ec4ee9b9cd",
+goodsSource: '张跃文',
+id: '34e710ed3883484798ab37ec4ee9b9cd',
 weight: 4000}]],
         signingDate:'',
         datelist:[],
@@ -248,6 +292,7 @@ weight: 4000}]],
       // this.makeWordData = this.getData(2)
       // this.initCharts()
       // this.getPassYearFormatDate()
+      this.value2 = this.getNowTime()
       this.getList()
     },
      computed: {
@@ -255,19 +300,125 @@ weight: 4000}]],
       amount: function () {
         // `this` 指向 vm 实例
         var num=0
-        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-          num+=Number(this.feeDetailsDistributions[i].distributionMoney)
-        }
-        return num
-      }
+         if (this.feeDetailsDistributions) {
+           for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+             num += Number(this.feeDetailsDistributions[i].distributionMoney)
+           }
+           return num
+         }
+       }
     },
     methods: {
+      sourceChange(e) {
+      if (e == '') {
+        this.goodsSource = '全部客户'
+      } else {
+        this.goodsSource  = e
+      }
+        this.selectOrderList()
+    },
+      getNowTime() {
+      const start = new Date(new Date().getTime() - 3600 * 1000 * 24)
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0] //默认开始时间1天前
+      const end = new Date(new Date().getTime())
+        .toISOString()
+        .replace('T', ' ')
+        .split('.')[0]//默认结束时间今天
+      // console.log([start.split(' '), end])
+      return [start.split(' ')[0], end.split(' ')[0]]
+    },
+      queren() {
+      if (!this.deptBudgetList.amountMoney && this.moneys == '按重量自动分配') {
+        this.$message({
+          message: '请输入金额之后进行操作',
+          type: 'warning',
+        })
+        return
+      }
+      this.confirmFlag = 1
+      this.selectOrderList()
+    },
+    dateChange(e) {
+      this.value2 = e
+    },
+    selectOrderList() {
+      var arr = []
+      var weight = 0
+      var money = 0
+      var moneyDiff = 0
+      this.startDate = this.value2[0]
+      this.endDate = this.value2[1]
+      getwarehousingorderList({
+        compId: localStorage.getItem('ws-pf_compId'),
+        startDate: this.startDate,
+        endDate: this.endDate,
+        baseId: this.deptBudgetList.warehouseId,
+        warehouseName : this.deptBudgetList.warehouseName,
+        currentPage: this.currentPage,
+        pageSize: this.pageSize,
+        searchType: this.searchType,
+        searchKeyWord: this.searchKeyWord,
+        goodsName: this.goodsName,
+        goodsSource: this.goodsSource == '全部客户' ? '' : this.goodsSource
+      })
+        .toPromise()
+        .then((response) => {
+          this.datas = []
+          this.datas1 = []
+          if (this.goodsSource && this.goodsSource != '全部客户') {
+            for (let i = 0; i < response.records.length; i++) {
+              this.datas.push(response.records[i])
+            }
+            for (let z = 0; z < this.datas.length; z++) {
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource, id: '', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+          } else {
+            for (let i = 0; i < response.records.length; i++) {
+              for (let j = 0; j < response.records[i].warehousingOrderList.length; j++) {
+                this.datas.push(response.records[i].warehousingOrderList[j])
+              }
+            }
+            for (let z = 0; z < this.datas.length; z++) {
+              arr.push({ receiptDocDate: this.datas[z].issuingTime, goodsSource: this.datas[z].goodsSource,orderId:this.datas[z].id, id: '', weight: this.datas[z].inWarehouseWeight, goodsName: this.datas[z].goodsName, goodsNameKey: this.datas[z].goodsNameKey })
+            }
+            this.feeDetailsDistributions = arr
+
+            //获取客户
+            this.customerList = this.unique(arr)
+          }
+          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+            this.feeDetailsDistributions[i].inWarehouseWeight = this.feeDetailsDistributions[i].weight
+            weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
+          }
+          if (this.moneys == '按重量自动分配') {
+            for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+              if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+            }
+          }
+        })
+    },
+    unique(arr) {
+      const res = new Map();
+      return arr.filter((arr) => !res.has(arr.goodsSource) && res.set(arr.goodsSource, 1));
+    },
       timeFun(unixtimestamp) {
         var unixtimestamp = new Date(unixtimestamp);
         var year = 1900 + unixtimestamp.getYear();
-        var month = "0" + (unixtimestamp.getMonth() + 1);
-        var date = "0" + unixtimestamp.getDate();
-        return year + "-" + month.substring(month.length - 2, month.length) + "-" +     date.substring(date.length - 2,date.length)      
+        var month = '0' + (unixtimestamp.getMonth() + 1);
+        var date = '0' + unixtimestamp.getDate();
+        return year + '-' + month.substring(month.length - 2, month.length) + '-' +     date.substring(date.length - 2,date.length)      
       },
       selectware(e,index){
         var arr=[]
@@ -283,8 +434,8 @@ weight: 4000}]],
       },
       selectgoodsSource(e,item,index){
         var weight=0
-        console.log(e)
         var money=0
+        var moneyDiff = 0
         if(!this.deptBudgetList.amountMoney&&this.moneys=='按重量自动分配'){
           for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
             if(this.feeDetailsDistributions[i].orderId==e){
@@ -303,17 +454,35 @@ weight: 4000}]],
             this.feeDetailsDistributions[index].inWarehouseWeight=this.goodsourcelist[index][i].weight
             this.feeDetailsDistributions[index].goodsName=this.goodsourcelist[index][i].goodsName
             this.feeDetailsDistributions[index].goodsNameKey=this.goodsourcelist[index][i].goodsNameKey
+            this.feeDetailsDistributions[index].orderId = this.goodsourcelist[index][i].id
             }
         }
-        if(this.moneys=='按重量自动分配'){
-          weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
-              return total + currentValue.inWarehouseWeight;
-          }, 0)
-          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-              this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
-              money+=this.feeDetailsDistributions[i].distributionMoney
-          }
+        // if(this.moneys=='按重量自动分配'){
+        //   weight = this.feeDetailsDistributions.reduce(function (total, currentValue, currentIndex, arr) {
+        //       return total + currentValue.inWarehouseWeight;
+        //   }, 0)
+        //   for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+        //       this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
+        //       money+=this.feeDetailsDistributions[i].distributionMoney
+        //   }
+        // }
+        if (this.moneys == '按重量自动分配') {
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          weight += Number(this.feeDetailsDistributions[i].inWarehouseWeight)
         }
+        for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+          if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+        }
+      }
       },
       selecttime(e,item,index){
         var weight=0
@@ -449,7 +618,7 @@ weight: 4000}]],
             this.deptBudgetList.expenseAllocationInfoList=[]
           }
         }
-        if(this.deptBudgetList.expensesPurpose==2){
+        if(this.deptBudgetList.expensesPurpose==2 || this.deptBudgetList.expensesPurpose==3&&this.storageFeeFlag==0){
           this.deptBudgetList.expenseAllocationInfoList=this.feeDetailsDistributions
         }
          if(this.deptBudgetList.expensesPurpose==1||this.deptBudgetList.expensesPurpose==2){
@@ -460,6 +629,7 @@ weight: 4000}]],
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].orderId==item.orderId&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -482,6 +652,7 @@ weight: 4000}]],
             }else{
               var repetition=data.filter((item,index)=>{
                 return this.feeDetailsDistributions[i].warehouseName==item.warehouseName&&this.feeDetailsDistributions[i].receiptDocDate==item.receiptDocDate
+                && this.feeDetailsDistributions[i].goodsSource == item.goodsSource
               })
               if(repetition.length==0){
                 data.push(this.feeDetailsDistributions[i])
@@ -579,29 +750,80 @@ weight: 4000}]],
         this.feeDetailsDistributions.push({receiptDocDate:'',inWarehouseWeight:0,distributionMoney:0,warehouseName:'',time:0,id:0,weight:0,goodsName:'',goodsSource:'',index:0,   goodsNameKey: null,index:this.feeDetailsDistributions.length})
       },
       dellist(row){
-        if(this.feeDetailsDistributions.length>1){
-          if(row.id==0){
-            this.feeDetailsDistributions.splice(row.index,1)
-          }else{
-            this.feeDetailsDistributions.splice(row.index,1)
-            var data=localStorage.getItem('expensebh')
-            var data1=[]
-            for (let i = 0; i < data.length; i++) {
-              if(data[i].id==row.id){
-                var data1=data.splice(row.i,1)
-              }
-            }
-            if(data1.length>0){
-              localStorage.setItem('expensebh',data1)
-            }else{
-              localStorage.removeItem('expensebh')
-            }
-            
-            deloneallocationinfo({id:row.id}).toPromise().then((response) => {
-            })
-            
+        // var weight=0
+        // var money=0
+        // var moneyDiff = 0
+        // if(this.feeDetailsDistributions.length>1){
+        //   debugger
+        //   if(row.id==0){
+        //     this.feeDetailsDistributions.splice(row.index,1)
+        //   }else{
+        //     this.feeDetailsDistributions.splice(row.index,1)
+        //     var data=localStorage.getItem('expensebh')
+        //     var data1=[]
+        //     for (let i = 0; i < data.length; i++) {
+        //       if(data[i].id==row.id){
+        //         var data1=data.splice(row.i,1)
+               
+        //       }
+        //     }
+        //     if(data1.length>0){
+        //       localStorage.setItem('expensebh',data1)
+        //     }else{
+        //       localStorage.removeItem('expensebh')
+        //     }
+        //     deloneallocationinfo({id:row.id}).toPromise().then((response) => {
+              
+        //     })
             
             
+        //   }
+        var weight = 0
+        var money = 0
+        var moneyDiff = 0
+        if (this.feeDetailsDistributions.length > 1) {
+          if (row.id == 0) {
+            this.feeDetailsDistributions.splice(row.index, 1)
+          } else {
+            for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+              if (this.feeDetailsDistributions[i]) {
+                if (this.feeDetailsDistributions[i] == row) {
+                  this.feeDetailsDistributions.splice(i, 1)
+                  if (this.moneys == '按重量自动分配' ) {
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  weight += this.feeDetailsDistributions[i].inWarehouseWeight
+                }
+                for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+                  if (i != this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = Math.round((this.feeDetailsDistributions[i].inWarehouseWeight / weight) * this.deptBudgetList.amountMoney)
+                if (this.feeDetailsDistributions[i].distributionMoney) {
+                  moneyDiff += Number(this.feeDetailsDistributions[i].distributionMoney)
+                }
+              }
+              if (i == this.feeDetailsDistributions.length - 1) {
+                this.feeDetailsDistributions[i].distributionMoney = this.deptBudgetList.amountMoney - moneyDiff
+              }
+              money = this.feeDetailsDistributions[i].distributionMoney + moneyDiff
+
+                }
+              }
+                  var data = localStorage.getItem('expensebh')
+                  var data1 = []
+                  for (let i = 0; i < data.length; i++) {
+                    if (data[i].id == row.id) {
+                      var data1 = data.splice(row.i, 1)
+                    }
+                  }
+                  if (data1.length > 0) {
+                    localStorage.setItem('expensebh', data1)
+                  } else {
+                    localStorage.removeItem('expensebh')
+                  }
+                  deloneallocationinfo({ id: row.id }).toPromise().then((response) => {
+                  })
+                }
+              }
+            }
           }
         }else{
           this.$message({
@@ -610,17 +832,18 @@ weight: 4000}]],
           })
           return
         }
-        var weight=0
-        var money=0
-        if(this.moneys=='按重量自动分配'){
-          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-          weight+=this.feeDetailsDistributions[i].inWarehouseWeight
-          }
-          for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
-              this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
-              money+=this.feeDetailsDistributions[i].distributionMoney
-          }
-        }
+        // var weight=0
+        // var money=0
+        // if(this.moneys=='按重量自动分配'){
+        //   for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+        //   weight+=this.feeDetailsDistributions[i].inWarehouseWeight
+        //   }
+        //   for (let i = 0; i < this.feeDetailsDistributions.length; i++) {
+        //       this.feeDetailsDistributions[i].distributionMoney=Math.round((this.feeDetailsDistributions[i].inWarehouseWeight/weight)*this.deptBudgetList.amountMoney)
+        //       money+=this.feeDetailsDistributions[i].distributionMoney
+        //   }
+        // } 
+        
       },
       getList() {
         getcontract({
@@ -652,6 +875,7 @@ weight: 4000}]],
             response.type='保证金'
           }
           this.deptBudgetList=response
+          this.feeDetailsDistributions = this.defineComponent.expenseAllocationInfoList
           this.dataList=[]
           if(response.addressUrl){
             var arr=[]

+ 11 - 5
src/views/profitable/expensemanagentlook.vue

@@ -27,6 +27,10 @@
               <span v-if='deptBudgetList.costType==3'>非粮款</span>
               <span v-if='deptBudgetList.costType==5'>保证金</span>
           </el-form-item>
+          <el-form-item label-width='100px' v-if='deptBudgetList.purpose=="库点费用"' label="仓储费" span="1" prop="contractNo" class="readonly">
+            <span v-if='(deptBudgetList.storageFeeFlag==1)'>是</span>
+              <span v-if='(deptBudgetList.storageFeeFlag==0)'>否</span>
+          </el-form-item>
           <el-form-item v-if='deptBudgetList.expensesPurpose==3' label-width='100px' label="仓库名称" span="1" prop="warehouseName" class="readonly">
           {{deptBudgetList.warehouseName}}
           </el-form-item>
@@ -80,8 +84,8 @@
             </el-form-item>
           </el-form>
         </div>
-        <div class="wenzi">车辆详情</div>
-        <el-table :data="deptBudgetList.tranSettlementReportList" style="width: 90%; margin: 20px auto; " ref="warehouseList"  >
+        <div class="wenzi" v-if='deptBudgetList.expensesPurpose==2'>车辆详情</div>
+        <el-table :data="deptBudgetList.tranSettlementReportList" style="width: 90%; margin: 20px auto; " ref="warehouseList" v-if='deptBudgetList.expensesPurpose==2' >
         <el-table-column type="index" label="序号" width="50"></el-table-column>
         <el-table-column class="table_td" prop="contractNo" width="120" label="合同编号"></el-table-column>
         <el-table-column class="table_td" prop="startAddress" width="120" label="发货库"></el-table-column>
@@ -123,7 +127,7 @@
             </template>
             </el-table-column>
           </el-table>
-        <div v-if='deptBudgetList.expensesPurpose==1&&deptBudgetList.costType==3||deptBudgetList.expensesPurpose==2' style='width:90%;margin:10px auto;'>
+        <div v-if='deptBudgetList.expensesPurpose==1&&deptBudgetList.costType==3||deptBudgetList.expensesPurpose==3||deptBudgetList.expensesPurpose==2' style='width:90%;margin:10px auto;'>
           <div style='margin-bottom:20px;'>费用分配</div>
           <!-- <div> -->
           <el-table :data="deptBudgetList.expenseAllocationInfoList">
@@ -153,7 +157,8 @@
             </el-table-column>
             <el-table-column v-if='deptBudgetList.expensesPurpose==3' prop="date" label="货源">
                 <template slot-scope="scope">
-                  <ws-select class="goodsource" disabled v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row)})">
+                  <!-- <ws-select class="goodsource" disabled v-model="scope.row.orderId" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row)})"> -->
+                  <ws-select disabled v-model="scope.row.goodsSource" placeholder="选择货源" @change="((value)=>{selectgoodsSource(value, scope.row)})">
                       <ws-option v-for="item in goodsourcelist" :key="item.id" :label="item.goodsSource" :value="item.id"
                           style="color: #8890b1" />
                   </ws-select>
@@ -191,7 +196,7 @@
       return {
         value: [],
         profitList: [{
-          name: "玉米",
+          name: '玉米',
           count: 2000,
         }],
         deptBudgetList:{},
@@ -228,6 +233,7 @@
         .toPromise()
         .then((response) => {
           this.deptBudgetList=response
+          this.expenseAllocationInfoList = this.deptBudgetList.expenseAllocationInfoList
           this.srcList=[]
           var arr=response.addressUrl.split(',')
           for (let i = 0; i < arr.length; i++) {