Преглед на файлове

采购详情根据采购类型查询全部商品

lizhenhao преди 2 години
родител
ревизия
c8bb229dca

+ 7 - 0
src/api/materialManagement/MaterialManagementService.js

@@ -44,4 +44,11 @@ export default class MaterialManagementService {
       responseType: 'blob'
     })
   }
+  findTradeByTypeId (typeId) {
+    return request({
+      url: '/material/management/findTradeByTypeId',
+      method: 'get',
+      params: {typeId: typeId}
+    })
+  }
 }

+ 79 - 15
src/views/modules/materialManagement/purchase/PurchaseForm.vue

@@ -126,7 +126,21 @@
           </vxe-table-column>
           <vxe-table-column align="center" field="tradeName" title="商品名称" :edit-render="{}" :rules="[]">
             <template v-slot:edit="scope">
-              <el-input @change="ifSameValue" v-model="scope.row.tradeName"></el-input>
+<!--              <el-input @change="ifSameValue" v-model="scope.row.tradeName"></el-input>-->
+              <vxe-pulldown ref="xDown1" transfer>
+                <template #default>
+                  <vxe-input v-model="scope.row.tradeName" placeholder="请输入商品名称" maxlength="64"
+                             @focus="focusEvent1(scope.row)"
+                             @input="keyupEvent1(scope.row)"></vxe-input>
+                </template>
+                <template #dropdown>
+                  <div class="my-dropdown1">
+                    <div class="list-item1" v-for="item in scope.row.tradeNameData" :key="item.id" @click="selectEvent1(scope.row, item)">
+                      <span>{{ item.tradeName }}</span>
+                    </div>
+                  </div>
+                </template>
+              </vxe-pulldown>
             </template>
           </vxe-table-column>
           <vxe-table-column align="center" field="supplierName" title="供应商" :edit-render="{}" :rules="[{required: true, message:'请选择供应商', trigger:'blur'}]">
@@ -276,6 +290,7 @@
   import MaterialTypePullForm from '../info/MaterialTypePullForm'
   import UserPullForm from '@/views/modules/finance/invoice/UserPullForm'
   import SupplierService from '@/api/materialManagement/SupplierService'
+  import WareHouseService from '@/api/materialManagement/WareHouseService'
   export default {
     data () {
       return {
@@ -288,6 +303,9 @@
           ],
           procurementType: [
             {required: true, message: '采购类型不能为空'}
+          ],
+          tradeName: [
+            {required: true, message: '商品名称不能为空'}
           ]
         },
         title: '',
@@ -333,11 +351,13 @@
     userService: null,
     commonApi: null,
     supplierService: null,
+    wareHouseService: null,
     created () {
       this.materialManagementService = new MaterialManagementService()
       this.userService = new UserService()
       this.commonApi = new CommonApi()
       this.supplierService = new SupplierService()
+      this.wareHouseService = new WareHouseService()
     },
     props: {
       businessId: {
@@ -651,6 +671,24 @@
                   this.loading = false
                   return
                 }
+                if (this.commonJS.isEmpty(this.inputForm.detailInfos[j].tradeName)) {
+                  this.$message.error('采购详情第' + k + '行请填写商品名称')
+                  this.loading = false
+                  return
+                }
+              }
+              for (let j = 0; j < i; j++) {
+                for (let k = j + 1; k < i; k++) {
+                  if (this.inputForm.detailInfos[j].procurementType === this.inputForm.detailInfos[k].procurementType) { // 如果采购类型相同
+                    if (this.inputForm.detailInfos[j].tradeName === this.inputForm.detailInfos[k].tradeName) { // 如果商品名称相同
+                      if (this.inputForm.detailInfos[j].supplierName === this.inputForm.detailInfos[k].supplierName) {
+                        this.$message.warning(`采购详情中,同种采购类型、同一供应商的商品名称只能输入一条`)
+                        this.loading = false
+                        throw new Error('采购详情中,同种采购类型、同一供应商的商品名称只能输入一条')
+                      }
+                    }
+                  }
+                }
               }
             }
             this.inputForm.files = this.$refs.uploadComponent.getDataList()
@@ -861,19 +899,6 @@
       getProgramForType (rows) {
         this.inputForm.detailInfos[this.indexRow].procurementTypeId = rows.id
         this.inputForm.detailInfos[this.indexRow].procurementType = rows.name
-        let i = this.inputForm.detailInfos.length
-        for (let j = 0; j < i; j++) {
-          for (let k = j + 1; k < i; k++) {
-            if (this.inputForm.detailInfos[j].procurementTypeId === this.inputForm.detailInfos[k].procurementTypeId) {
-              if (this.commonJS.isNotEmpty(this.inputForm.detailInfos[j].tradeName) &&
-                this.commonJS.isNotEmpty(this.inputForm.detailInfos[k].tradeName) && this.inputForm.detailInfos[j].tradeName === this.inputForm.detailInfos[k].tradeName) {
-                // parseFloat(item.account).toFixed(2)
-                this.inputForm.detailInfos.splice(k, 1)
-                this.$message.warning(`同种采购类型的商品名称只能输入一条信息!`)
-              }
-            }
-          }
-        }
         this.indexRow = ''
         this.$forceUpdate()
       },
@@ -958,13 +983,52 @@
           this.tablePage4.total = data.total
           this.loading4 = false
         })
+      },
+      focusEvent1 (row) {
+        row.tradeNameList = []
+        row.tradeNameData = []
+        if (this.commonJS.isNotEmpty(row.procurementTypeId)) {
+          this.materialManagementService.findTradeByTypeId(row.procurementTypeId).then(({data}) => {
+            row.tradeNameList = JSON.parse(JSON.stringify(data))
+            row.tradeNameData = JSON.parse(JSON.stringify(data))
+            this.$refs.xDown1.showPanel()
+          }).catch(() => {
+            this.$refs.xDown1.showPanel()
+          })
+        } else {
+          this.$refs.xDown1.showPanel()
+        }
+      },
+      keyupEvent1 (row) {
+        row.tradeNameData = this.commonJS.isNotEmpty(row.tradeName) ? row.tradeNameList.filter(item => item.tradeName.indexOf(row.tradeName) > -1) : row.tradeNameList
+      },
+      selectEvent1 (row, item) {
+        row.tradeName = item.tradeName
+        this.$refs.xDown1.hidePanel()
       }
     }
   }
 </script>
-<style>
+<style scoped>
   .el-divider__text {
     font-size: 16px;
     font-weight: bold;
   }
+
+  /*.my-dropdown1、.list-item1、.list-item1:hover  为商品名称下拉选择框样式*/
+  .my-dropdown1 {
+    height: 155px;
+    overflow: auto;
+    border-radius: 4px;
+    border: 1px solid #dcdfe6;
+    background-color: #fff;
+  }
+  .list-item1 {
+    line-height: 30px;
+    text-align: center;
+    border-bottom: #c4c7cc73 1px solid;
+  }
+  .list-item1:hover {
+    background-color: #f5f7fa;
+  }
 </style>

+ 20 - 12
src/views/modules/materialManagement/wareHouse/WareHouseAddForm.vue

@@ -728,7 +728,7 @@
                   this.loading = false
                   return
                 }
-                if (this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierName)) {
+                if (this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierName) || this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierId)) {
                   this.$message.error('入库详情第' + k + '行请选择供应商')
                   this.loading = false
                   return
@@ -747,14 +747,14 @@
               }
               for (let j = 0; j < i; j++) {
                 for (let k = j + 1; k < i; k++) {
-                  if (this.inputForm.wareHouse[j].wareHouseTypeId === this.inputForm.wareHouse[k].wareHouseTypeId) {
-                    if (this.commonJS.isNotEmpty(this.inputForm.wareHouse[j].tradeName) &&
-                      this.commonJS.isNotEmpty(this.inputForm.wareHouse[k].tradeName) && this.inputForm.wareHouse[j].tradeName === this.inputForm.wareHouse[k].tradeName) {
-                      // parseFloat(item.account).toFixed(2)
-                      // this.inputForm.wareHouse.splice(k, 1)
-                      this.$message.warning(`入库详情中,同种入库类型的商品名称只能输入一条信息`)
-                      this.loading = false
-                      throw new Error('入库详情中,同种入库类型的商品名称只能输入一条信息')
+                  if (this.inputForm.wareHouse[j].wareHouseTypeId === this.inputForm.wareHouse[k].wareHouseTypeId) { // 如果入库类型相同
+                    if (this.inputForm.wareHouse[j].tradeName === this.inputForm.wareHouse[k].tradeName) { // 如果商品名称相同
+                      // 这里直接通过判断供应商的id是否相等,因为入库只允许选择供应商,不允许手填
+                      if (this.inputForm.wareHouse[j].supplierId === this.inputForm.wareHouse[k].supplierId) {
+                        this.$message.warning(`入库详情中,同种入库类型、同一供应商的商品名称只能输入一条`)
+                        this.loading = false
+                        throw new Error('入库详情中,同种入库类型、同一供应商的商品名称只能输入一条')
+                      }
                     }
                   }
                 }
@@ -849,9 +849,17 @@
           tradePrice: this.inputForm.detailInfos[index].tradePrice,
           company: this.inputForm.detailInfos[index].company,
           priceSum: this.inputForm.detailInfos[index].priceSum,
-          supplierId: this.inputForm.detailInfos[index].supplierId,
-          supplierName: this.inputForm.detailInfos[index].supplierName,
-          isSupplier: this.inputForm.detailInfos[index].isSupplier
+          supplierId: '',
+          supplierName: '',
+          isSupplier: ''
+        }
+        if (this.commonJS.isNotEmpty(this.inputForm.detailInfos[index].supplierId) &&
+          this.commonJS.isNotEmpty(this.inputForm.detailInfos[index].isSupplier) &&
+          this.inputForm.detailInfos[index].isSupplier === '2'
+        ) {
+          param.supplierId = this.inputForm.detailInfos[index].supplierId
+          param.supplierName = this.inputForm.detailInfos[index].supplierName
+          param.isSupplier = this.inputForm.detailInfos[index].isSupplier
         }
         this.inputForm.wareHouse.push(param)
       },

+ 9 - 8
src/views/modules/materialManagement/wareHouse/WareHouseUpdateForm.vue

@@ -707,7 +707,7 @@
                 this.inputForm.functionFlag = ''
                 return
               }
-              if (this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierName)) {
+              if (this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierName) || this.commonJS.isEmpty(this.inputForm.wareHouse[j].supplierId)) {
                 this.$message.error('入库详情第' + k + '行请选择供应商')
                 this.loading = false
                 this.inputForm.functionFlag = ''
@@ -726,15 +726,16 @@
                 return
               }
             }
-            // 查询入库详情中是否有 入库类型相同并且商品名称也相同的
             for (let j = 0; j < i; j++) {
               for (let k = j + 1; k < i; k++) {
-                if (this.inputForm.wareHouse[j].wareHouseTypeId === this.inputForm.wareHouse[k].wareHouseTypeId) {
-                  if (this.commonJS.isNotEmpty(this.inputForm.wareHouse[j].tradeName) &&
-                    this.commonJS.isNotEmpty(this.inputForm.wareHouse[k].tradeName) && this.inputForm.wareHouse[j].tradeName === this.inputForm.wareHouse[k].tradeName) {
-                    this.$message.warning(`入库详情中,同种入库类型的商品名称只能输入一条信息`)
-                    this.loading = false
-                    throw new Error('入库详情中,同种入库类型的商品名称只能输入一条信息')
+                if (this.inputForm.wareHouse[j].wareHouseTypeId === this.inputForm.wareHouse[k].wareHouseTypeId) { // 如果入库类型相同
+                  if (this.inputForm.wareHouse[j].tradeName === this.inputForm.wareHouse[k].tradeName) { // 如果商品名称相同
+                    // 这里直接通过判断供应商的id是否相等,因为入库只允许选择供应商,不允许手填
+                    if (this.inputForm.wareHouse[j].supplierId === this.inputForm.wareHouse[k].supplierId) {
+                      this.$message.warning(`入库详情中,同种入库类型、同一供应商的商品名称只能输入一条`)
+                      this.loading = false
+                      throw new Error('入库详情中,同种入库类型、同一供应商的商品名称只能输入一条')
+                    }
                   }
                 }
               }