Ver código fonte

物料领取表增加仓库名称-warehouseName

zhujindu 1 ano atrás
pai
commit
cf769eb586
1 arquivos alterados com 132 adições e 113 exclusões
  1. 132 113
      src/views/my/material.vue

+ 132 - 113
src/views/my/material.vue

@@ -2,9 +2,9 @@
   <div class="bgcolor">
     <div class="navBarTOP">
       <!--        顶部条-->
-      <van-nav-bar class="navBar" :title="title"   left-arrow @click-left="onClickLeft">
+      <van-nav-bar class="navBar" :title="title" left-arrow @click-left="onClickLeft">
         <template #right>
-          <span style="color:#0057ba;"  @click="editorFn">保存</span>
+          <span style="color: #0057ba" @click="editorFn">保存</span>
         </template>
       </van-nav-bar>
     </div>
@@ -14,28 +14,41 @@
     <div class="lineGrey"></div>
     <div class="lineGrey"></div>
     <!--        主体内容-->
-    <div class="container" style="width: 100%; margin: 0 auto;">
-      <el-table :data="list" border class="table-headermd table-headermdw" style="width: 100%" :span-method="objectSpanMethod">
-        <el-table-column label="物料类型" prop="materialTypeName">
+    <div class="container" style="width: 100%; margin: 0 auto">
+      <el-table
+        :data="list"
+        border
+        class="table-headermd table-headermdw"
+        style="width: 100%"
+        :span-method="objectSpanMethod">
+        <el-table-column label="物料类型" prop="materialTypeName" align="center">
           <template slot-scope="scope">
-            <span class="tipTitle" @click="tipTitle(scope.row.materialTypeName)">{{ scope.row.materialTypeName }}</span>
+            <span class="tipTitle" @click="tipTitle(scope.row.materialTypeName)">
+              {{ scope.row.materialTypeName }}
+            </span>
           </template>
         </el-table-column>
-        <el-table-column label="物料名称" prop="materialDataName">
+        <el-table-column label="物料名称" prop="materialDataName" align="center">
           <template slot-scope="scope">
-            <span class="tipTitle" @click="tipTitle(scope.row.materialDataName)">{{ scope.row.materialDataName }}</span>
+            <span class="tipTitle" @click="tipTitle(scope.row.materialDataName)">
+              {{ scope.row.materialDataName }}
+            </span>
           </template>
         </el-table-column>
-        <el-table-column prop="inventoryNum" label="总库存" />
-        <el-table-column prop="myInventoryNum" label="我的库存" />
-        <el-table-column class="t-center" prop="inventoryNumArray">
-          <template slot="header"> <span>{{titles}}</span><span class="xing">*</span> </template>
+        <el-table-column prop="warehouseName" label="仓库名称" align="center" />
+        <el-table-column prop="inventoryNum" label="总库存" align="center" />
+        <el-table-column prop="myInventoryNum" label="我的库存" align="center" width="50px" />
+        <el-table-column class="t-center" prop="inventoryNumArray" align="center" width="80px">
+          <template slot="header">
+            <span>{{ titles }}</span>
+            <span class="xing">*</span>
+          </template>
           <template slot-scope="scope">
-            <van-field v-model="scope.row.inventoryNumArray"
-                placeholder="请输入"
-                type="number"
-                @input="inputblurs(scope.row.inventoryNumArray, scope.$index, '1')"
-            />
+            <van-field
+              v-model="scope.row.inventoryNumArray"
+              placeholder="请输入"
+              type="number"
+              @input="inputblurs(scope.row.inventoryNumArray, scope.$index, '1')" />
           </template>
         </el-table-column>
       </el-table>
@@ -44,58 +57,61 @@
 </template>
 
 <script>
-import {addMaterialInventory, getReceiveList} from "@/api/inventory";
+import { addMaterialInventory, getReceiveList } from '@/api/inventory';
 export default {
   data() {
     return {
-      disabled:false,
+      disabled: false,
       list: [],
       loading: false,
       finished: false,
       pageSize: 12,
       pageNum: 1,
-      tabVal:'1',
-      validFlag:"",
-      titles:"领取量",
-      title:"物料信息",
+      tabVal: '1',
+      validFlag: '',
+      titles: '领取量',
+      title: '物料信息',
       fromValue: {
         pageSize: 12,
         pageNum: 1,
-      }
-    }
+      },
+    };
   },
   created() {
-    this.getReceiveList()
+    this.getReceiveList();
   },
   watch: {
     $route(to, from) {
-      if (to.path == "/material") {
-        this.getReceiveList()
+      if (to.path == '/material') {
+        this.getReceiveList();
       }
-    }
+    },
   },
   methods: {
     inputblurs(val, index, num) {
-      if(this.$route.query.tabVal=="B"){
-      if ((val + '').trim() == '') {
-        this.list[index].inventoryNumArray = '';
-      } else {
-        if (Number(val) > 10000 || Number(val) <= 0) {
-          this.$toast('请输入大于0并且小于10000的整数');
-          this.list[index].inventoryNumArray = '';
-        } else if (this.list[index].inventoryNumArray == '') {
-          this.list[index].inventoryNumArray = '';
-          this.$toast('请输入使用量');
-        } else if (Number(val) > Number(this.list[index].myInventoryNum)) {
-          this.$toast('请输入小于等于我的存量');
+      if (this.$route.query.tabVal == 'B') {
+        if ((val + '').trim() == '') {
           this.list[index].inventoryNumArray = '';
         } else {
-          this.list[index].inventoryNumArray = val.replace(/[^\d.]/g, ''); //清除"数字"和"."以外的字符
-          this.list[index].inventoryNumArray = val.replace(/^\./g, ''); //验证第一个字符是数字
-          this.list[index].inventoryNumArray = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '');
+          if (Number(val) > 10000 || Number(val) <= 0) {
+            this.$toast('请输入大于0并且小于10000的整数');
+            this.list[index].inventoryNumArray = '';
+          } else if (this.list[index].inventoryNumArray == '') {
+            this.list[index].inventoryNumArray = '';
+            this.$toast('请输入使用量');
+          } else if (Number(val) > Number(this.list[index].myInventoryNum)) {
+            this.$toast('请输入小于等于我的存量');
+            this.list[index].inventoryNumArray = '';
+          } else {
+            this.list[index].inventoryNumArray = val.replace(/[^\d.]/g, ''); //清除"数字"和"."以外的字符
+            this.list[index].inventoryNumArray = val.replace(/^\./g, ''); //验证第一个字符是数字
+            this.list[index].inventoryNumArray = val
+              .replace('.', '$#$')
+              .replace(/\./g, '')
+              .replace('$#$', '');
+          }
         }
-      }
-      }else{
+      } else {
         if ((val + '').trim() == '') {
           this.list[index].inventoryNumArray = '';
         } else {
@@ -111,75 +127,78 @@ export default {
           } else {
             this.list[index].inventoryNumArray = val.replace(/[^\d.]/g, ''); //清除"数字"和"."以外的字符
             this.list[index].inventoryNumArray = val.replace(/^\./g, ''); //验证第一个字符是数字
-            this.list[index].inventoryNumArray = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '');
+            this.list[index].inventoryNumArray = val
+              .replace('.', '$#$')
+              .replace(/\./g, '')
+              .replace('$#$', '');
           }
         }
       }
     },
-    editorFn(){
+    editorFn() {
       let loading1 = this.$toast.loading({
         duration: 0,
         message: '加载中...',
         forbidClick: true,
       });
-      var inventoryIdArray=[]
-      var inventoryNumArray=[]
-      for(var i=0;i<this.list.length;i++){
-        if(this.list[i].inventoryNumArray!=""&&this.list[i].inventoryNumArray!=null){
-          inventoryIdArray.push(this.list[i].inventoryId)
-          inventoryNumArray.push(this.list[i].inventoryNumArray)
+      var inventoryIdArray = [];
+      var inventoryNumArray = [];
+      for (var i = 0; i < this.list.length; i++) {
+        if (this.list[i].inventoryNumArray != '' && this.list[i].inventoryNumArray != null) {
+          inventoryIdArray.push(this.list[i].inventoryId);
+          inventoryNumArray.push(this.list[i].inventoryNumArray);
         }
       }
-      var changeType=2
-      if(this.$route.query.tabVal=="B"){
-        changeType=5
+      var changeType = 2;
+      if (this.$route.query.tabVal == 'B') {
+        changeType = 5;
       }
-      var formData={
-        inventoryIdArray:inventoryIdArray,
-        changeType:changeType,
-        inventoryNumArray:inventoryNumArray,
-        userId:localStorage.getItem("userId")
-      }
-      addMaterialInventory(formData).then(
-          res=>{
-            loading1.clear()
-            if(res.code==200){
-              this.$dialog.alert({
-                title: '系统提示',
-                message: "保存成功,返回我的库存"
-              }).then(res=>{
-                this.$router.go(-1)
-              })
-            }else{
-              this.$toast(res.msg);
-            }
-          }
-      )
+      var formData = {
+        inventoryIdArray: inventoryIdArray,
+        changeType: changeType,
+        inventoryNumArray: inventoryNumArray,
+        userId: localStorage.getItem('userId'),
+      };
+      addMaterialInventory(formData).then((res) => {
+        loading1.clear();
+        if (res.code == 200) {
+          this.$dialog
+            .alert({
+              title: '系统提示',
+              message: '保存成功,返回我的库存',
+            })
+            .then((res) => {
+              this.$router.go(-1);
+            });
+        } else {
+          this.$toast(res.msg);
+        }
+      });
     },
     objectSpanMethod({ row, column, rowIndex, columnIndex }) {
-      const cellValue = row[column.property]
-      if (cellValue && ["materialTypeName"].includes(column.property)) {
-        const prevRow = this.list[rowIndex - 1]
-        let nextRow = this.list[rowIndex + 1]
+      const cellValue = row[column.property];
+      if (cellValue && ['materialTypeName'].includes(column.property)) {
+        const prevRow = this.list[rowIndex - 1];
+        let nextRow = this.list[rowIndex + 1];
         if (prevRow && prevRow[column.property] === cellValue) {
-          return { rowspan: 0, colspan: 0 }
+          return { rowspan: 0, colspan: 0 };
         } else {
-          let countRowspan = 1
+          let countRowspan = 1;
           while (nextRow && nextRow[column.property] === cellValue) {
-            nextRow = this.list[++countRowspan + rowIndex]
+            nextRow = this.list[++countRowspan + rowIndex];
           }
           if (countRowspan > 1) {
-            return { rowspan: countRowspan, colspan: 1 }
+            return { rowspan: countRowspan, colspan: 1 };
           }
         }
       }
     },
     getReceiveList() {
-      this.title="领取物料"
-      this.titles="领取量"
-      if(this.$route.query.tabVal=="B"){
-        this.title="退回物料"
-        this.titles="退回量"
+      this.title = '领取物料';
+      this.titles = '领取量';
+      if (this.$route.query.tabVal == 'B') {
+        this.title = '退回物料';
+        this.titles = '退回量';
       }
       if (this.refreshing) {
         this.list = [];
@@ -190,43 +209,43 @@ export default {
         message: '加载中...',
         forbidClick: true,
       });
-      var fromValue=this.fromValue
-      fromValue.pageNum=this.pageNum
-      fromValue.pageSize=this.pageSize
-      fromValue.inventoryLyUserId=localStorage.getItem("userId")
-      getReceiveList(fromValue).then(res => {
-        loading1.clear()
-        this.disabled=false;
+      var fromValue = this.fromValue;
+      fromValue.pageNum = this.pageNum;
+      fromValue.pageSize = this.pageSize;
+      fromValue.inventoryLyUserId = localStorage.getItem('userId');
+      getReceiveList(fromValue).then((res) => {
+        loading1.clear();
+        this.disabled = false;
         if (res.code == 200) {
           this.loading = false;
 
-          this.list = res.rows
+          this.list = res.rows;
         } else {
-          this.$toast.fail(res.msg)
+          this.$toast.fail(res.msg);
         }
-      })
+      });
     },
     storeDetailFn(id) {
       this.$router.push({
-        path: "/storeDetail",
-        query: {id: id}
-      })
+        path: '/storeDetail',
+        query: { id: id },
+      });
     },
     onClickRight() {
-      this.$router.push("/storeAdd")
+      this.$router.push('/storeAdd');
     },
     onClickLeft() {
-      this.$router.go(-1)
+      this.$router.go(-1);
     },
     onSearch() {
-      window.scrollTo(0, 0)
-      this.pageNum = 1
-      this.list = []
+      window.scrollTo(0, 0);
+      this.pageNum = 1;
+      this.list = [];
       this.finished = true;
-      this.onLoad()
+      this.onLoad();
     },
-  }
-}
+  },
+};
 </script>
 <style lang="scss" scoped>
 .bgcolor {
@@ -338,4 +357,4 @@ export default {
 .formLabel .mobile-input {
   border: 0 !important;
 }
-</style>
+</style>