gjy преди 3 години
родител
ревизия
01d5ed4303
променени са 2 файла, в които са добавени 284 реда и са изтрити 90 реда
  1. 21 9
      src/views/houseSelfCollect/acquisitionManagement.vue
  2. 263 81
      src/views/houseSelfCollect/acquisitionManagementAdd.vue

+ 21 - 9
src/views/houseSelfCollect/acquisitionManagement.vue

@@ -7,7 +7,7 @@
           <el-option v-for="item in warehouseList" :key="item.id" :label="item.warehouseName" :value="item.id">
           </el-option>
         </el-select>
-        <el-checkbox v-model="checked" @change="allowEdit" :disabled="userJurisdiction">允许手动编辑重量</el-checkbox>
+        <el-checkbox v-model="checked" @change="allowEdit" :disabled="!userJurisdiction">允许手动编辑重量</el-checkbox>
       </div>
       <el-button type="primary" @click="newAcquisition('','','新增')">新增</el-button>
     </div>
@@ -31,7 +31,7 @@
         </el-table-column>
         <el-table-column prop="waterBase" label="基准水分(%)"></el-table-column>
         <el-table-column prop="deductWeight" label="扣重比"></el-table-column>
-        <el-table-column prop="saleLimit" label="销量上线"></el-table-column>
+        <el-table-column prop="saleLimit" label="销量上限(年/吨)"></el-table-column>
         <el-table-column prop="dryGrainPrice" label="干粮收购价"></el-table-column>
 
         <el-table-column prop="status" label="状态"></el-table-column>
@@ -39,8 +39,9 @@
         <el-table-column label="操作" width="300">
           <template slot-scope="scope">
             <el-button size="mini" @click="newAcquisition(scope.$index, scope.row,'查看')">查看</el-button>
-            <el-button size="mini" @click="newAcquisition(scope.$index, scope.row,'编辑')">编辑</el-button>
-            <el-button size="mini" type="danger" @click="delRow(scope.$index, scope.row)">删除</el-button>
+            <el-button v-if="scope.row.status!='审核中'" size="mini" @click="newAcquisition(scope.$index, scope.row,'编辑')">编辑</el-button>
+            <el-button v-if="scope.row.status=='审核中'" size="mini" :disabled="!userJurisdiction" @click="newAcquisition(scope.$index, scope.row,'编辑')">审核中</el-button>
+            <el-button size="mini" :disabled="!userJurisdiction" type="danger" @click="delRow(scope.$index, scope.row)">删除</el-button>
             <el-button size="mini" @click="print(scope.$index, scope.row)">打印</el-button>
           </template>
         </el-table-column>
@@ -104,7 +105,7 @@
 
     },
     methods: {
-      getUserJurisdiction(){debugger
+      getUserJurisdiction(){
         let userJurisdiction = getHp('acquisitionManagement.acquisition.allow')
       },
       handleSizeChange(val) {
@@ -152,11 +153,17 @@
             }
             break
           case '编辑':
+          _query = {
+            data: JSON.stringify(row),
+            type: type,
+             goodsNameList: this.goodsNameList
+          }
             break
           case "查看":
             _query = {
               data: JSON.stringify(row),
-              type: type
+              type: type,
+              goodsNameList: this.goodsNameList
             }
             break
           default:
@@ -172,10 +179,12 @@
         selectWarehouseSelf({
           compId: this.compId,
           personCharge: this.accountName,
-        }).toPromise().then((response) => {debugger
+        }).toPromise().then((response) => {
           console.log(response)
           this.warehouseList = response
-          this.warehouseList.unshift({warehouseName:response[0].flag})
+          if(this.userJurisdiction){
+            this.warehouseList.unshift({warehouseName:response[0].flag})
+          }
           console.log(this.warehouseList)
           this.selectVal = this.warehouseList[0].id
           if (this.warehouseList[0].allowEdit == 1) {
@@ -189,7 +198,7 @@
         })
       },
       //获取列表数据
-      getList() {debugger
+      getList() {
         getPurchasePrice({
           currentPage: this.currentPage,
           pageSize: this.pageSize,
@@ -257,6 +266,9 @@
           localStorage.setItem('pricePrintList', JSON.stringify(response.detailPrints));
           window.location.href = "../../../static/print.html?name=" + row.goodsName
         })
+      },
+      validate(){
+
       }
     },
   }

+ 263 - 81
src/views/houseSelfCollect/acquisitionManagementAdd.vue

@@ -14,7 +14,7 @@
         <div class="row1">
           <div class="grid-content">
             <el-form-item label="货名">
-              <el-select v-model="selectVal" placeholder="请选择" @change="goodsChange">
+              <el-select v-model="selectVal" placeholder="请选择" @change="goodsChange" :disabled="!isEdit">
                 <el-option v-for="item in goodnameList" :key="item.constValue" :label="item.constValue"
                   :value="item.constValue">
                 </el-option>
@@ -58,7 +58,7 @@
       <el-row class="row3">
         <div class="top">
           <div class="title">粮价设置</div>
-          <el-button class="btn" @click="newSetPrice" :disabled="!isEdit">新增</el-button>
+          <el-button v-if="priceList.length<4" class="btn" @click="newSetPrice" :disabled="!isEdit">新增</el-button>
         </div>
         <div class="content" v-for="(item,index) in priceList" :key="index">
           <div class="top">
@@ -114,8 +114,12 @@
             </div>
           </div>
         </div>
+<<<<<<< HEAD
 
         <el-button class="submit" @click="submit">提交</el-button>
+=======
+        <el-button class="submit" @click="submit">{{submitName}}</el-button>
+>>>>>>> 36835dba2e0d5c5d1a483acfb7a9034512eebdd9
       </el-row>
     </el-main>
     <el-main v-show="!isCountShow">
@@ -138,14 +142,25 @@
           </el-table-column>
         </el-table>
       </div>
+<<<<<<< HEAD
       <el-button class="submit" @click="closeCount">关闭</el-button>
+=======
+      <div class="bottom-btn">
+        <div v-if="">当前价格尚未通过审核,建议审核通过后进行打印</div>
+        <el-button class="submit" @click="closeCount">关闭</el-button>
+        <el-button class="submit" @click="print">打印</el-button>
+      </div>
+
+
+>>>>>>> 36835dba2e0d5c5d1a483acfb7a9034512eebdd9
     </el-main>
   </el-container>
 </template>
 <script>
   import {
     purchasePriceAdd,
-    purchasePriceLook
+    purchasePriceLook,
+    purchasePriceEdit
   } from '@/model/houseSelfCollect/index'
   export default {
 
@@ -160,35 +175,7 @@
         selectVal: "",
         goodnameList: [],
         tableData: [],
-        // tableData: [{
-        //   waterMin: '10',
-        //   waterMax: '20',
-        //   price1: '30',
-        //   price2: '30',
-        //   price3: '30',
-        //   priceOther: '30',
-        // }, {
-        //   waterMin: '11',
-        //   waterMax: '20',
-        //   price1: '30',
-        //   price2: '30',
-        //   price3: '30',
-        //   priceOther: '30',
-        // }, {
-        //   waterMin: '12',
-        //   waterMax: '20',
-        //   price1: '30',
-        //   price2: '30',
-        //   price3: '30',
-        //   priceOther: '30',
-        // }, {
-        //   waterMin: '13',
-        //   waterMax: '20',
-        //   price1: '30',
-        //   price2: '30',
-        //   price3: '30',
-        //   priceOther: '30',
-        // }],
+        submitName: "提交",
         isCountShow: true,
         priceList: [{
           index: 0,
@@ -249,56 +236,86 @@
       }
     },
     activated() {
+      // 货名
+      let _goodsNameList = []
+      _goodsNameList = this.$route.query.goodsNameList
+      packList({
+          constId: 'CON2'
+        })
+        .toPromise()
+        .then((response) => {
+          debugger
+          let _list = []
+          for (let i = 0; i < response.length; i++) {
+            let _isAll = true
+            for (let j = 0; j < _goodsNameList.length; j++) {
+              if (response[i].constValue != _goodsNameList[j]) {
+                if (j == _goodsNameList.length - 1 && _isAll) {
+                  _list.push(response[i])
+                }
+              } else {
+                _isAll = false
+              }
+            }
+          }
+          this.goodnameList = _list
+          this.selectVal = _list[0].constValue
+        })
       switch (this.$route.query.type) {
         case "新增":
-          let _goodsNameList = []
+          this.submitName = "提交"
           this.baseInfoForm.warehouseId = this.$route.query.warehouseId
           this.baseInfoForm.warehouseName = this.$route.query.warehouseName
           this.baseInfoForm.compId = this.$route.query.compId
           this.type = this.$route.query.type
           console.log(this.baseInfoForm)
-          _goodsNameList = this.$route.query.goodsNameList
+
           this.priceList[0].detailList[0].water = this.baseInfoForm.waterMin
           this.priceList[0].detailList[2].water = this.baseInfoForm.waterBase
           this.priceList[0].detailList[4].water = this.baseInfoForm.waterMax
-          // 货名
-          packList({
-              constId: 'CON2'
-            })
-            .toPromise()
-            .then((response) => {
-              let _list = []
-              for (let i = 0; i < response.length; i++) {
-                let _isAll = true
-                for (let j = 0; j < _goodsNameList.length; j++) {
-                  if (response[i].constValue != _goodsNameList[j]) {
-                    if (j == _goodsNameList.length - 1 && _isAll) {
-                      _list.push(response[i])
-                    }
-                  } else {
-                    _isAll = false
-                  }
-                }
-              }
-              this.goodnameList = _list
-              this.selectVal = _list[0].constValue
-            })
+          this.isEdit = true
+          this.priceList = [{
+            index: 0,
+            checkList: [],
+            basicUnitPrice: "",
+            detailList: [{
+                type: 1,
+                name: "干粮",
+                water: "",
+                isWrite: false
+              },
+              {
+                type: 4,
+                jfprice: ""
+              },
+              {
+                type: 2,
+                name: "基准",
+                water: '',
+                isWrite: false
+              },
+              {
+                type: 4,
+                jfprice: ""
+              },
+              {
+                type: 3,
+                name: "上限",
+                water: '',
+                isWrite: false
+              },
+            ],
+          }]
           break;
         case "编辑":
+          // this.isEdit = false;
+          this.submitName = "提交"
+          this.getData()
           break;
         case "查看":
           this.isEdit = false;
-          this.type = this.$route.query.type
-          this.baseInfoForm = JSON.parse(this.$route.query.data)
-          purchasePriceLook({
-            id: this.baseInfoForm.id
-          }).toPromise().then((response) => {
-            console.log(response)
-            this.baseInfoForm = response
-            //构造查看priceList数据
-            this.priceList = []
-            this.makeLookPriceList()
-          })
+          this.submitName = "计算"
+          this.getData()
           break;
         default:
           break
@@ -310,6 +327,26 @@
 
     },
     methods: {
+<<<<<<< HEAD
+=======
+      // 查看/编辑获取数据
+      getData() {
+        this.type = this.$route.query.type
+        this.baseInfoForm = JSON.parse(this.$route.query.data)
+        purchasePriceLook({
+          id: this.baseInfoForm.id
+        }).toPromise().then((response) => {
+          console.log(response)
+          this.baseInfoForm = response
+          //构造查看priceList数据
+          this.priceList = []
+          this.makeLookPriceList()
+        })
+      },
+      goodsChange(e) {
+        console.log(e)
+      },
+>>>>>>> 36835dba2e0d5c5d1a483acfb7a9034512eebdd9
       changeBaseWater(val) {
         console.log('val', val)
         for (let i = 0; i < this.priceList.length; i++) {
@@ -467,6 +504,7 @@
       },
       // 删除价格组
       delSetPrice(item, index) {
+        let that = this
         this.$confirm(
             '确认删除本组设置?',
             '提示', {
@@ -476,7 +514,14 @@
             }
           )
           .then(() => {
-            this.priceList.splice(index, 1)
+            if (that.priceList.length == 1) {
+              that.$message({
+                message: '至少保留一组粮价设置',
+                type: 'warning'
+              });
+            } else {
+              that.priceList.splice(index, 1)
+            }
           })
           .catch(() => {
             return false
@@ -526,24 +571,160 @@
       },
       //打印
       print() {},
+      validate() {
+        let that = this
+        function _baseWaterValidate(min, max, saveNum, point, type) {
+          let _val1 = parseFloat(that.baseInfoForm.waterBase)
+          let _pointVal1 = _val1.toString().split(".")[1]
+          let _tobeVal1 = _val1 % saveNum
+          if (type == "waterBase") {
+            if (_val1 < max && _val1 > min && _pointVal1 < point && _tobeVal1 == 0) {
+              return false
+            }
+          }
+          if (type == "deductWeight") {
+            if (_val1 < max && _val1 > min && _pointVal1 < point) {
+              return false
+            }
+          }
+          if (type == "saleLimit") {
+
+            if (_val1 < max && _val1 > min && Number.isInteger(this.baseInfoForm.saleLimit)) {
+              return false
+            }
+          }
+          return true
+        }
+        if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase") || this.baseInfoForm.waterBase == '') {
+          if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase")) {
+            that.$message.error('水分基准输入错误,最多保留1位小数,基准水分须可被0.5整除!');
+          } else {
+            this.$message.error('基准水分不能为空!');
+          }
+          return false
+        }
+        if (_baseWaterValidate(0, 2, 2, '', 'deductWeight') || this.baseInfoForm.deductWeight == '') {
+          if (_baseWaterValidate(0, 2, 2, '', 'deductWeight')) {
+            that.$message.error('扣重比输入错误!');
+          } else {
+            this.$message.error('扣重比不能为空!');
+          }
+          return false
+        }
+        if (_baseWaterValidate(0, 1000, 4, '', 'deductWeight') || this.baseInfoForm.dryGrainPrice == '') {
+          if (_baseWaterValidate(0, 1000, 4, '', 'deductWeight')) {
+            that.$message.error('干粮收购价输入错误!');
+          } else {
+            this.$message.error('干粮收购价格不能为空!');
+          }
+          return false
+        }
+
+        if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase") || this.baseInfoForm.waterMin == '') {
+          if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase")) {
+            that.$message.error('干粮水分输入错误!');
+          } else {
+            this.$message.error('干粮水分不能为空!');
+          }
+          return false
+        }
+        if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase") || this.baseInfoForm.waterMax == '') {
+          if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase")) {
+            that.$message.error('水分上限输入错误!');
+          } else {
+            this.$message.error('水分上限不能为空!');
+          }
+          return false
+        }
+        if (_baseWaterValidate(100, 100000, '', '', "saleLimit") || this.baseInfoForm.saleLimit == '') {
+          if (_baseWaterValidate(100, 100000, '', '', "saleLimit")) {
+            that.$message.error('销售上限输入错误!');
+          } else {
+            this.$message.error('销售上限不能为空!');
+          }
+          return false
+        }
+        console.log(this.priceList.length)
+        if (this.priceList.length != 4) {
+          this.$message.error('粮价设置为4个等级!');
+          return false
+        }
+        for (let i = 0; i < this.priceList.length; i++) {
+          let _item = this.priceList[i]
+          if (_baseWaterValidate(0, 50, 2, '', "deductWeight") || _item.basicUnitPrice == '') {
+            if (_baseWaterValidate(0, 50, 2, '', "deductWeight")) {
+              that.$message.error('基准单价输入错误!');
+            } else {
+              this.$message.error('基准单价不能为空!');
+            }
+            return false
+          }
+          if (_item.checkList.length == 0) {
+            this.$message.error('等级不能为空!');
+            return false
+          }
+          for (let j = 0; j < _item.detailList.length; j++) {
+            let _item1 = _item.detailList[j]
+            if (_item1.type == 4) {
+              if (_baseWaterValidate(0, 100, 3, '', 'deductWeight') || _item1.jfprice == "") {
+                if (_baseWaterValidate(0, 100, 3, '', 'deductWeight')) {
+                  that.$message.error('降幅输入错误!');
+                } else {
+                  this.$message.error('降幅价格不能为空!');
+                }
+                return false
+              }
+            } else {
+              if (_baseWaterValidate(0, 100, 1, 0.5, "waterBase") || _item1.water == "") {
+                if (_baseWaterValidate(1, 100, 1, 0.5, "waterBase")) {
+                  that.$message.error('分界值输入错误!');
+                } else {
+                  this.$message.error('分界水分不能为空!');
+                }
+                return false
+              }
+            }
+          }
+        }
+        return true
+      },
       // 提交
       submit() {
-        this.isCountShow = false
-        this.makeTableList()
-        this.makePriceDataList()
-        this.baseInfoForm.goodsName = this.selectVal
-        // purchasePriceAdd(this.baseInfoForm).toPromise().then((response) => {
-        //   console.log(response)
-        //   this.tableData = response.records
-        // })
+        debugger
+        let isValidate = this.validate()
+        if (isValidate) {
+          this.makeTableList()
+          this.makePriceDataList()
+          this.baseInfoForm.goodsName = this.selectVal
+          switch (this.$route.query.type) {
+            case "查看":
+              this.isCountShow = false;
+              break;
+            case "新增":
+              purchasePriceAdd(this.baseInfoForm).toPromise().then((response) => {
+                console.log(response)
+                // this.tableData = response.records
+
+                this.isCountShow = false
+              })
+              break;
+            case "编辑":
+              purchasePriceEdit(this.baseInfoForm).toPromise().then((response) => {
+                console.log(response)
+                // this.tableData = response.records
+                this.isCountShow = false
+              })
+              break;
+          }
+        }
       },
       // 关闭
       closeCount() {
         this.isCountShow = true
-        // this.splitPriceList = []
-        // this.$router.push({
-        //   name: 'acquisitionManagement',
-        // })
+        this.splitPriceList = []
+        this.$router.push({
+          name: 'acquisitionManagement',
+        })
       },
       //处理价格表格数据
       makeTableList() {
@@ -719,6 +900,7 @@
       },
       // 构造查看粮价设置数据
       makeLookPriceList() {
+        debugger
         this.selectVal = this.baseInfoForm.goodsName
         let _priceList = this.baseInfoForm.details
         let _checkList = []
@@ -747,7 +929,7 @@
                 water: _detailList[k],
                 isWrite: false
               }
-            } else if (_detailList[k] == this.baseInfoForm.waterMax) {
+            } else if (_detailList[k] == this.baseInfoForm.waterBase) {
               _obj = {
                 type: 2,
                 name: "基准",