Browse Source

库存:修改

chris 3 năm trước cách đây
mục cha
commit
0c509352d7

+ 138 - 0
src/views/modules/warehouse/stock-add-or-update.vue

@@ -0,0 +1,138 @@
+<template>
+  <el-dialog
+    :title="!dataForm.id ? '新增' : '修改'"
+    :close-on-click-modal="false"
+    :visible.sync="visible">
+    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
+<!--      <el-form-item label="编码" prop="code">-->
+<!--        <el-input v-model="dataForm.code" placeholder="编码"></el-input>-->
+<!--      </el-form-item>-->
+      <el-form-item label="名称" prop="materialName">
+        <el-input v-model="dataForm.materialName" placeholder="名称"></el-input>
+      </el-form-item>
+      <el-form-item label="类别" prop="materialTypeId">
+        <el-input v-model="dataForm.materialTypeId" placeholder="类别"></el-input>
+      </el-form-item>
+      <el-form-item label="规格" prop="specifications">
+        <el-input v-model="dataForm.specifications" placeholder="规格"></el-input>
+      </el-form-item>
+      <el-form-item label="单位" prop="unitName">
+        <el-input v-model="dataForm.unitName" placeholder="单位"></el-input>
+      </el-form-item>
+      <el-form-item label="数量" prop="cnt">
+        <el-input-number v-model="dataForm.cnt" :min="0" placeholder="数量"></el-input-number>
+      </el-form-item>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="visible = false">取消</el-button>
+      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+  export default {
+    name: 'stock-add-or-update',
+    data () {
+      return {
+        visible: false,
+        dataForm: {
+          materialId: 0,
+          materialCode: '',
+          materialName: '',
+          materialTypeId: '',
+          specifications: '',
+          unitName: '',
+          cnt: '',
+          price: '',
+          amount: '',
+          warehouseId: '',
+          shelveId: '',
+          shelveName: '',
+          notes: ''
+        },
+        dataRule: {
+        }
+      }
+    },
+    methods: {
+      init (id) {
+        this.dataForm.materialId = id || 0
+        if (this.dataForm.materialId) {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/info/${this.dataForm.materialId}`),
+            method: 'get',
+            params: this.$http.adornParams()
+          }).then(({data}) => {
+            if (data.code === '200') {
+              this.visible = true
+              this.dataForm.materialId = data.data.materialId
+              this.dataForm.materialName = data.data.materialName
+              this.dataForm.materialTypeId = data.data.materialTypeId
+              this.dataForm.specifications = data.data.specifications
+              this.dataForm.unitName = data.data.unitName
+              this.dataForm.cnt = data.data.cnt
+              this.dataForm.price = data.data.price
+              this.dataForm.amount = data.data.amount
+              this.dataForm.warehouseId = data.data.warehouseId
+              this.dataForm.shelveName = data.data.shelveName
+              this.dataForm.notes = data.data.notes
+            } else {
+              this.$message.error(data.msg)
+            }
+          })
+        }
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.$http({
+              url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/${!this.dataForm.materialId ? 'save' : 'update'}`),
+              method: !this.dataForm.materialId ? 'post' : 'put',
+              data: this.$http.adornData(!this.dataForm.materialId ? {
+                'materialName': this.dataForm.materialName
+              } : {
+                'materialId': this.dataForm.materialId,
+                'materialName': this.dataForm.materialName,
+                'amount': this.dataForm.amount,
+                'cateId': this.dataForm.materialTypeId,
+                'materialTypeId': this.dataForm.materialTypeId,
+                'cnt': this.dataForm.cnt,
+                'materialCode': this.dataForm.materialCode,
+                'notes': this.dataForm.notes,
+                'price': this.dataForm.price,
+                'shelveId': this.dataForm.shelveId,
+                'specifications': this.dataForm.specifications,
+                'unitName': this.dataForm.unitName,
+                'warehouseId': this.dataForm.warehouseId,
+                'updaterId': this.$store.state.user.id
+              })
+            }).then(({data}) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.visible = false
+                    this.$emit('refreshDataList')
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+          }
+        })
+      },
+      validateField (type) {
+        this.$refs.dataForm.validateField(type)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 4 - 4
src/views/modules/warehouse/stock-details.vue

@@ -59,15 +59,15 @@
     },
     methods: {
       init (id) {
-        this.dataForm.id = id || 0
-        if (this.dataForm.id) {
-          // this.dataForm.materialName = 'test'
+        this.dataForm.materialId = id || 0
+        if (this.dataForm.materialId) {
           this.$http({
-            url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/info/${this.dataForm.id}`),
+            url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/info/${this.dataForm.materialId}`),
             method: 'get',
             params: this.$http.adornParams()
           }).then(({data}) => {
             if (data.code === '200') {
+              this.dataForm = {}
               this.visible = true
               this.dataForm.materialId = data.data.materialId
               this.dataForm.materialName = data.data.materialName

+ 13 - 3
src/views/modules/warehouse/stock.vue

@@ -65,7 +65,7 @@
           label="单位">
         </el-table-column>
         <el-table-column
-          prop="-"
+          prop="cnt"
           header-align="center"
           align="center"
           label="库存">
@@ -129,14 +129,16 @@
         layout="total, sizes, prev, pager, next, jumper">
       </el-pagination>
       <stock-details v-if="detailVisible" ref="details"/>
+      <stock-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"/>
     </div>
 </template>
 
 <script>
   import StockDetails from './stock-details'
+  import StockAddOrUpdate from './stock-add-or-update'
   export default {
     name: 'stock',
-    components: {StockDetails},
+    components: {StockAddOrUpdate, StockDetails},
     data () {
       return {
         dataForm: {
@@ -148,7 +150,8 @@
         totalPage: 0,
         dataListLoading: false,
         dataListSelections: [],
-        detailVisible: false
+        detailVisible: false,
+        addOrUpdateVisible: false
       }
     },
     activated () {
@@ -197,6 +200,13 @@
         this.$nextTick(() => {
           this.$refs.details.init(id)
         })
+      },
+      // 新增、修改
+      addOrUpdateHandle (id) {
+        this.addOrUpdateVisible = true
+        this.$nextTick(() => {
+          this.$refs.addOrUpdate.init(id)
+        })
       }
     }
   }