浏览代码

BOM:关联物料

chris 1 年之前
父节点
当前提交
bac1241ede

+ 35 - 49
src/views/modules/tech/product-add-or-update.vue

@@ -110,10 +110,14 @@
 <!--        </el-col>-->
 <!--      </el-row>-->
       <el-row>
-        <el-form-item label="关联物料" prop="materialId">
-          <el-input v-model="dataForm.materialId" :disabled="display" placeholder="请选择物料"></el-input>
-          <el-button @click="selectMaterial">选择</el-button>
-        </el-form-item>
+        <el-col :span="8">
+          <el-form-item label="关联物料" prop="materialCode">
+            <el-input v-model.lazy="material.materialCode" disabled placeholder="请选择物料"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="margin-left: 20px">
+          <el-button @click="selectMaterial" type="primary">选择</el-button>
+        </el-col>
       </el-row>
       <el-row>
         <el-col>
@@ -122,13 +126,6 @@
           </el-form-item>
         </el-col>
       </el-row>
-<!--      <el-row>-->
-<!--        <el-col>-->
-<!--          <el-form-item label="关重件" prop="importance">-->
-<!--            <el-input v-model="dataForm.importance" :disabled="display" placeholder="" type="textarea"></el-input>-->
-<!--          </el-form-item>-->
-<!--        </el-col>-->
-<!--      </el-row>-->
       <el-row class="my-row">
         <el-col :span="8">
           <el-form-item label="简图" prop="attachList2">
@@ -213,8 +210,8 @@
     </span>
     <!-- </el-dialog> -->
     <template-chose v-if="productListVisible" ref="productList" @addItems="addProductItems" />
-    <templateChoseMaterial v-if="materialListVisible" ref="materialList" @addItems="addMaterialItems" />
     <template-draw-choose v-if="drawListVisible" ref="drawList" @addItems="addDrawItems" />
+    <stock-dialog v-if="materialCompVisible" ref="stockList" @addItem="addStockItem"/>
   </div>
 </template>
 
@@ -229,24 +226,19 @@ import { dealStepData, dealStepLogs } from '@/api/util'
 import CusComponent from '../common/cus-component'
 import DrawComponents from '../common/draw-components'
 import DocComponents from '../common/doc-components'
+import stockDialog from '../warehouse/stock-dialog.vue'
 
 export default {
   name: 'product-add-or-update',
-  components: { DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial, templateDrawChoose },
+  components: { DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial, templateDrawChoose, stockDialog },
   computed: {
     orgId: {
       get () { return this.$store.state.user.orgId }
     }
   },
-  // watch: {
-  //   'dataForm.isCompose' (value) {
-  //     this.dataForm.displayProductList = value === '1'
-  //   }
-  // },
   data () {
     return {
       productListVisible: false,
-      materialListVisible: false,
       drawListVisible: false,
       materialCompVisible: false,
       visible: false,
@@ -256,13 +248,17 @@ export default {
         {code: '1', value: '是'},
         {code: '0', value: '否'}
       ],
-      // optionsTech: [],
       fileList: [],
       listingList: [],
       dataList: [],
       id: 0,
       productDetails: [],
       materialList: [],
+      // 对应物料
+      material: {
+        'materialId': 0,
+        'materialCode': ''
+      },
       drawingList: [],
       displayProductList: false,
       dataForm: {
@@ -349,15 +345,18 @@ export default {
 
           // 物料图纸
           this.drawingList = data.data.proDrawings || []
+
+          // 关联物料
+          this.material = {
+            materialId: data.data.materialId,
+            materialCode: data.data.materialCode
+          }
         }
       })
     },
     uploadSuccess (fileList) {
       this.fileList = fileList
     },
-    uploadSuccess2 (fileList2) {
-      this.listingList = fileList2
-    },
     // 添加组合物料
     addProduct () {
       this.productListVisible = true
@@ -382,24 +381,6 @@ export default {
     deleteProductHandle (productId) {
       this.productDetails.splice(this.productDetails.findIndex((item) => item.productId === productId), 1)
     },
-    addMaterial () {
-      this.materialListVisible = true
-      this.$nextTick(() => {
-        this.$refs.materialList.init()
-      })
-    },
-    addMaterialItems (items) {
-      this.materialList = []
-      items.forEach((item) => {
-        this.addMaterialItem(item)
-      })
-    },
-    addMaterialItem (item) {
-      this.materialList.push({
-        ...item,
-        cnt: 0
-      })
-    },
     validateField (type) {
       this.$refs.dataForm.validateField(type)
     },
@@ -407,6 +388,11 @@ export default {
     dataFormSubmit () {
       this.$refs['dataForm'].validate((valid) => {
         if (valid) {
+          // 对应物料
+          if (this.material || this.material.materialId !== 0) {
+            this.dataForm.materialId = this.material.materialId
+            this.dataForm.materialCode = this.material.materialCode
+          }
           // 组合小物料
           this.dataForm.childrenIdList = []
           const b1 = this.displayProductList
@@ -441,11 +427,7 @@ export default {
         }
       })
     },
-    docSelectChange (val) {
-      // console.log(val)
-      this.dataForm.docIdList = val
-    },
-    // 添加关联图纸
+// 添加关联图纸
     addDrawingList () {
       this.drawListVisible = true
       this.$nextTick(() => {
@@ -472,9 +454,13 @@ export default {
     // 选择物料
     selectMaterial () {
       this.materialCompVisible = true
-      // this.$nextTick(() => {
-      //   this.$refs.materialComp.init()
-      // })
+      this.$nextTick(() => {
+        this.$refs.stockList.init()
+      })
+    },
+    // 添加物料到 dataForm
+    addStockItem (item) {
+      this.material = item
     }
   }
 }

+ 2 - 0
src/views/modules/tech/product-detail.vue

@@ -45,6 +45,8 @@
 
         <e-desc-item label="表面处理" span="3">{{dataForm.surfaceTreatment}}</e-desc-item>
 
+        <e-desc-item label="关联物料" span="3">{{dataForm.materialCode}}</e-desc-item>
+
         <e-desc-item label="备注" span="3">{{dataForm.notes}}</e-desc-item>
 
         <e-desc-item label="关重件" span="3">{{dataForm.importance}}</e-desc-item>

+ 268 - 21
src/views/modules/warehouse/stock-dialog.vue

@@ -1,40 +1,287 @@
 <template>
-  <el-dialog
-    title="选择物料"
-    width="70%"
-    :close-on-click-modal="false"
-    :visible.sync="visible"
-    @close="onChose"
-  >
-  <div class="stock">
-
-  </div>
-    <span slot="footer">
-        <el-button @click="onChose">返回</el-button>
-    </span>
+  <el-dialog title="选择物料"
+             width="70%"
+             :close-on-click-modal="false"
+             :visible.sync="visible">
+    <div class="draw-management">
+      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
+        <el-form-item label="名称">
+          <el-input v-model="dataForm.materialName" placeholder="请输入名称" clearable/>
+        </el-form-item>
+        <el-form-item label="类别">
+          <el-cascader
+            v-model="selectedCateIds"
+            :options="optionsCate"
+            :props="{ expandTrigger: 'hover'}"
+            :show-all-levels="true"
+            popper-class="my-cascader"
+            clearable
+          >
+          </el-cascader>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="getDataList()">查询</el-button>
+          <el-button type="primary" @click="addSubmit">确认添加</el-button>
+        </el-form-item>
+      </el-form>
+      <el-table
+        ref="stockList"
+        :data="dataList"
+        border
+        v-loading="dataListLoading"
+        @selection-change="selectionChangeHandle"
+        @current-change="currentSelectHandle"
+        style="width: 100%;">
+        <el-table-column
+          type="selection"
+          header-align="center"
+          align="center"
+          width="50">
+        </el-table-column>
+        <el-table-column
+          label="序号"
+          type="index"
+          width="50"
+          align="center">
+        </el-table-column>
+        <el-table-column
+          prop="materialCode"
+          header-align="center"
+          align="center"
+          min-width="180"
+          :show-tooltip-when-overflow="true"
+          label="编码">
+        </el-table-column>
+        <el-table-column
+          prop="categoryName"
+          header-align="center"
+          align="center"
+          width="120"
+          :show-tooltip-when-overflow="true"
+          label="类别">
+        </el-table-column>
+        <el-table-column
+          prop="materialName"
+          header-align="center"
+          align="center"
+          width="120"
+          :show-overflow-tooltip="true"
+          label="名称">
+        </el-table-column>
+        <el-table-column
+          prop="specifications"
+          header-align="center"
+          align="center"
+          width="140"
+          :show-overflow-tooltip="true"
+          label="规格">
+        </el-table-column>
+        <el-table-column
+          prop="isInventory"
+          header-align="center"
+          align="center"
+          :formatter="formatState"
+          label="状态">
+        </el-table-column>
+        <el-table-column
+          prop="lockCnt"
+          header-align="center"
+          align="center"
+          label="锁库数量">
+        </el-table-column>
+        <el-table-column
+          prop="unitName"
+          header-align="center"
+          align="center"
+          label="单位">
+        </el-table-column>
+        <el-table-column
+          prop="cnt"
+          header-align="center"
+          align="center"
+          label="库存">
+        </el-table-column>
+        <el-table-column
+          prop="safeQuantity"
+          header-align="center"
+          align="center"
+          label="安全库存">
+        </el-table-column>
+        <el-table-column
+          prop="amount"
+          header-align="center"
+          align="center"
+          label="金额">
+        </el-table-column>
+        <el-table-column
+          prop="shelveName"
+          header-align="center"
+          align="center"
+          width="140"
+          :show-overflow-tooltip="true"
+          label="存放货架">
+        </el-table-column>
+        <el-table-column
+          prop="notes"
+          header-align="center"
+          align="center"
+          width="160"
+          :show-overflow-tooltip="true"
+          label="备注">
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        @size-change="sizeChangeHandle"
+        @current-change="currentChangeHandle"
+        :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageSize"
+        :total="totalPage"
+        layout="total, sizes, prev, pager, next, jumper">
+      </el-pagination>
+    </div>
   </el-dialog>
 </template>
 
+<stock-details v-if="detailVisible" ref="details" @onChose="onChose"/>
+<stock-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"/>
+
 <script>
+import StockDetails from './stock-details'
+import StockAddOrUpdate from './stock-add-or-update'
+import NoticeChangeSetting from './stock-notice-change-setting'
 export default {
-  name: 'stock-dialog',
-  components: {},
+  name: 'stock',
+  components: {
+    StockAddOrUpdate,
+    StockDetails,
+    NoticeChangeSetting
+  },
   data () {
     return {
-      visible: false
+      visible: false,
+      dataForm: {
+        materialName: ''
+      },
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      dataListSelections: [],
+      detailVisible: false,
+      addOrUpdateVisible: false,
+      optionsCate: [], // 类别
+      selectedCateIds: []
     }
   },
+  activated () {
+    this.getCate()
+    this.getDataList()
+  },
   methods: {
+    async init () {
+      this.visible = true
+      this.getDataList()
+    },
     onChose () {
+      this.addOrUpdateVisible = false
+      this.detailVisible = false
+    },
+    // 获取类别
+    getCate () {
+      this.$http({
+        url: this.$http.adornUrl('/biz-service/stock-mg-ctl/listCategory'),
+        method: 'get'
+      }).then(({data}) => {
+        if (data && data.code === '200') {
+          this.optionsCate = data.data
+        }
+      })
+    },
+    // 获取数据列表
+    getDataList () {
+      this.dataListLoading = true
+      this.$http({
+        url: this.$http.adornUrl('/biz-service/stock-mg-ctl/list'),
+        method: 'get',
+        params: this.$http.adornParams({
+          'current': this.pageIndex,
+          'size': this.pageSize,
+          'materialName': this.dataForm.materialName,
+          'materialTypeId': this.selectedCateIds ? this.selectedCateIds[this.selectedCateIds.length - 1] : ''
+        })
+      }).then(({data}) => {
+        if (data && data.code === '200') {
+          this.dataList = data.data.records
+          this.totalPage = Number(data.data.total)
+        } else {
+          this.dataList = []
+          this.totalPage = 0
+        }
+        this.dataListLoading = false
+      })
+    },
+    // 每页数
+    sizeChangeHandle (val) {
+      this.pageSize = val
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 当前页
+    currentChangeHandle (val) {
+      this.pageIndex = val
+      this.getDataList()
+    },
+    currentSelectHandle (val) {
+      this.$refs.stockList.toggleRowSelection(val)
+    },
+    // 多选变单选
+    selectionChangeHandle (val) {
+      if (val.length > 1) {
+        this.$refs.stockList.clearSelection()
+        this.$refs.stockList.toggleRowSelection(val[val.length - 1])
+      }
+      this.dataListSelections = val[val.length - 1]
+    },
+    details (id) {
+      this.detailVisible = true
+      this.$nextTick(() => {
+        this.$refs.details.init(id)
+      })
+    },
+    // 新增、修改
+    addOrUpdateHandle (id) {
+      this.addOrUpdateVisible = true
+      this.$nextTick(() => {
+        this.$refs.addOrUpdate.init(id)
+      })
+    },
+    // 转换属性“状态”
+    formatState (row) {
+      if (row.isInventory && Number(row.isInventory) === 1 && row.lockCnt && Number(row.lockCnt) > 0) {
+        return '盘点中'
+      } else if (row.isInventory && Number(row.isInventory) === 1) {
+        return '盘点中'
+      } else if (row.lockCnt && Number(row.lockCnt) > 0) {
+        return '锁定中'
+      } else {
+        return '正常'
+      }
+    },
+    // 处理添加
+    addSubmit () {
+      if (this.dataListSelections.length === 0) {
+        this.$message.warning('请选择')
+        return
+      }
       this.visible = false
+      this.$emit('addItem', this.dataListSelections)
     }
   }
 }
 </script>
 
-<style scoped lang="scss">
-/deep/ .my-row .super-flow__node {
-  width: 180px;
-  height: 80px;
-}
+<style scoped>
+
 </style>