瀏覽代碼

Merge remote-tracking branch 'origin/master'

liqianyi 1 年之前
父節點
當前提交
1a7840ecb8
共有 2 個文件被更改,包括 180 次插入1 次删除
  1. 166 0
      src/views/modules/warehouse/stock-add.vue
  2. 14 1
      src/views/modules/warehouse/stock.vue

+ 166 - 0
src/views/modules/warehouse/stock-add.vue

@@ -0,0 +1,166 @@
+<template>
+  <div>
+      <div class="my-title">新增</div>
+      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
+        <el-row class="my-row">
+          <el-col :span="8">
+            <el-form-item label="名称" prop="materialName">
+              <el-input v-model="dataForm.materialName" placeholder="物品(零件)名称" ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="类别" prop="materialTypeId">
+              <material-type-component v-model="dataForm.materialTypeId" :type-id.sync="dataForm.materialTypeId"></material-type-component>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="规格" prop="specifications">
+              <el-input v-model="dataForm.specifications" placeholder="物品(零件)规格" ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row class="my-row">
+          <el-col :span="8">
+            <el-form-item label="数量" prop="cnt">
+              <el-input-number v-model="dataForm.cnt" :min="0" placeholder="物品(零件)数量" ></el-input-number>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="单价" prop="price">
+              <el-input-number v-model="dataForm.price" :precision="2" :step="0.1" :min="0.0" placeholder="物品(零件)单价" ></el-input-number>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="金额" prop="amount">
+              <el-input :value="!id?(dataForm.price * dataForm.cnt):dataForm.amount" :disabled="true" placeholder="物品(零件)总金额"></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row class="my-row">
+          <el-col :span="8">
+            <el-form-item label="单位" prop="unitName">
+              <el-input v-model="dataForm.unitName" placeholder="单位" ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="存放仓库" prop="warehouseId">
+              <warehouse-select ref="warehouse" v-model:warehouse-id="dataForm.warehouseId" @select="warehouseChanged"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="存放货架" prop="shelveId">
+              <shelve-select ref="shelve" v-model="dataForm.shelveId" :warehouse-id.sync="dataForm.warehouseId" :shelve-id.sync="dataForm.shelveId"/>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row class="my-row">
+          <el-col :span="8">
+            <el-form-item label="安全库存" prop="safeQuantity">
+              <el-input-number v-model="dataForm.safeQuantity" :min="0" placeholder="安全库存"></el-input-number>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row class="my-row">
+          <el-col :span="24">
+            <el-form-item label="备注" prop="notes">
+              <el-input type="textarea" v-model="dataForm.notes" placeholder="备注" ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="onChose">取消</el-button>
+        <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
+      </span>
+  </div>
+</template>
+
+<script>
+import WarehouseSelect from './warehouse-select'
+import ShelveSelect from './shelve-select'
+import UserComponent from '../common/user-component'
+import MaterialTypeComponent from '@/views/modules/common/material-type-component.vue'
+export default {
+  name: 'stock-add',
+  components: {MaterialTypeComponent, UserComponent, ShelveSelect, WarehouseSelect},
+  data () {
+    return {
+      visible: false,
+      dictType: 'material_type',
+      id: 0,
+      dataForm: {
+        materialId: 0,
+        materialCode: '',
+        materialName: '',
+        materialTypeId: '',
+        cateId: '',
+        specifications: '',
+        unitName: '',
+        cnt: '',
+        price: '',
+        amount: '',
+        warehouseId: '',
+        shelveId: '',
+        shelveName: '',
+        notes: ''
+      },
+      dataRule: {
+        materialName: [{ required: true, message: '物品(零件)名称不能为空', trigger: 'blur' }],
+        specifications: [{ required: true, message: '规格不能为空', trigger: 'blur' }],
+        materialTypeId: [{ required: true, message: '类别不能为空', trigger: 'blur' }],
+        cnt: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
+        price: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
+        unitName: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
+        safeQuantity: [{ required: true, message: '安全库存不能为空', trigger: 'blur' }]
+      }
+    }
+  },
+  methods: {
+    onChose () {
+      this.$emit('onChose')
+    },
+    async init (id) {
+      this.visible = true
+      this.id = id || 0
+      this.dataForm = {}
+    },
+      // 表单提交
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/materialSave`),
+            method: 'post',
+            data: this.$http.adornData(this.dataForm)
+          }).then(({data}) => {
+            if (data && data.code === '200') {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                onClose: () => {
+                  this.onChose()
+                  this.$emit('refreshDataList')
+                }
+              })
+            } else {
+              this.$message.error(data.msg)
+            }
+          })
+        }
+      })
+    },
+    validateField (type) {
+      this.$refs.dataForm.validateField(type)
+    },
+    warehouseChanged (item) {
+      this.dataForm.warehouseId = item
+      this.$refs.shelve.init(item, this.dataForm.shelveId)
+    }
+  }
+}
+</script>
+
+<style scoped>{
+}
+</style>

+ 14 - 1
src/views/modules/warehouse/stock.vue

@@ -1,7 +1,7 @@
 <!-- 库存管理 -->
 <template>
     <div class="stock">
-      <template v-if="!detailVisible && !addOrUpdateVisible && !noticeChangeAttachVisible">
+      <template v-if="!detailVisible && !addOrUpdateVisible && !noticeChangeAttachVisible && !addVisible">
         <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
           <el-form-item label="名称">
             <el-input v-model="dataForm.materialName" placeholder="请输入名称" clearable/>
@@ -19,6 +19,7 @@
           </el-form-item>
           <el-form-item>
             <el-button @click="getDataList()">查询</el-button>
+            <el-button v-if="isAuth('wh:stock-mg-ctl:material-save')" type="primary" @click="addHandle()">新增</el-button>
 <!--            <el-button v-if="isAuth('wh:stockmanagement:exported')" type="primary" @click="exportExcel()">导出Excel</el-button>-->
             <el-button v-if="isAuth('wh:stockmanagement:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">库存更改通知设置</el-button>
           </el-form-item>
@@ -148,6 +149,7 @@
           layout="total, sizes, prev, pager, next, jumper">
         </el-pagination>
       </template>
+      <stock-add v-if="addVisible" ref="add" @refreshDataList="getDataList" @onChose="onChose"/>
       <stock-details v-if="detailVisible" ref="details" @onChose="onChose"/>
       <stock-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"/>
       <notice-change-setting v-if="noticeChangeAttachVisible" ref="noticeChangeSetting" @onChose="onChose"/>
@@ -159,9 +161,11 @@
   import StockAddOrUpdate from './stock-add-or-update'
   import NoticeChangeSetting from './stock-notice-change-setting'
   import Vue from 'vue'
+  import StockAdd from '@/views/modules/warehouse/stock-add.vue'
 export default {
     name: 'stock',
     components: {
+      StockAdd,
       StockAddOrUpdate,
       StockDetails,
       NoticeChangeSetting
@@ -178,6 +182,7 @@ export default {
         dataListLoading: false,
         dataListSelections: [],
         detailVisible: false,
+        addVisible: false,
         addOrUpdateVisible: false,
         noticeChangeAttachVisible: false,
         optionsCate: [], // 类别
@@ -193,6 +198,7 @@ export default {
         this.addOrUpdateVisible = false
         this.detailVisible = false
         this.noticeChangeAttachVisible = false
+        this.addVisible = false
       },
       // 获取类别
       getCate () {
@@ -265,6 +271,13 @@ export default {
           this.$refs.details.init(id)
         })
       },
+      // 新增
+      addHandle () {
+        this.addVisible = true
+        this.$nextTick(() => {
+          this.$refs.add.init()
+        })
+      },
       // 新增、修改
       addOrUpdateHandle (id) {
         this.addOrUpdateVisible = true