yuanchengman il y a 1 an
Parent
commit
05bd34db32

+ 189 - 0
src/views/modules/tech/draw-template-choose.vue

@@ -0,0 +1,189 @@
+<!-- 图库管理 -->
+<template>
+    <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="search()">
+            <el-form-item label="名称">
+                <el-input v-model="dataForm.keyword" placeholder="名称" clearable/>
+            </el-form-item>
+            <el-form-item>
+                <el-button @click="search()">查询</el-button>
+                <el-button type="primary" @click="addSubmit">确认添加</el-button>
+                <el-button type="text" @click="gotoPage">没有找到?去上传</el-button>
+            </el-form-item>
+            </el-form>
+            <el-table
+            :data="dataList"
+            border
+            v-loading="dataListLoading"
+            @selection-change="selectionChangeHandle"
+            style="width: 100%;">
+            <el-table-column type="selection"></el-table-column>
+            <el-table-column
+                label="序号"
+                type="index"
+                width="50"
+                align="center">
+            </el-table-column>
+            <el-table-column
+                prop="drawingCode"
+                header-align="center"
+                align="center"
+                min-width="100"
+                :show-tooltip-when-overflow="true"
+                label="图纸编码">
+            </el-table-column>
+            <el-table-column
+                prop="drawingName"
+                header-align="center"
+                align="center"
+                min-width="120"
+                :show-tooltip-when-overflow="true"
+                label="图纸名称">
+            </el-table-column>
+            <el-table-column
+                prop="drawingNo"
+                header-align="center"
+                align="center"
+                min-width="120"
+                :show-tooltip-when-overflow="true"
+                label="图号">
+            </el-table-column>
+            <el-table-column
+                prop="source"
+                header-align="center"
+                align="center"
+                min-width="200"
+                :show-overflow-tooltip="true"
+                label="来源">
+            </el-table-column>
+            <el-table-column
+                prop="creatorName"
+                header-align="center"
+                align="center"
+                min-width="100"
+                label="上传者">
+            </el-table-column>
+            <el-table-column
+                prop="notes"
+                header-align="center"
+                align="center"
+                min-width="180"
+                :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>
+  
+  <script>
+    import { getDrawList } from '@/api/product'
+    import ProductComponent from '@/views/modules/common/product-component'
+    export default {
+      name: 'draw-template-choose',
+      components: {
+        ProductComponent
+      },
+      data () {
+        return {
+          visible: false,
+          detailVisible: false,
+          dataForm: {
+            keyword: ''
+          },
+          optionsProducts: [],
+          dataList: [],
+          pageIndex: 1,
+          pageSize: 10,
+          totalPage: 0,
+          dataListLoading: false,
+          dataListSelections: []
+        }
+      },
+      created () {
+        this.getDataList()
+      },
+      methods: {
+        init () {
+          this.visible = true
+        },
+        onChose () {
+          this.addOrUpdateVisible = false
+          this.detailVisible = false
+        },
+        // 查询
+        search () {
+          this.pageIndex = 1
+          this.getDataList()
+        },
+        // 获取数据列表
+        getDataList () {
+          this.addOrUpdateVisible = false
+          this.dataListLoading = true
+          let params = {
+            'current': this.pageIndex,
+            'size': this.pageSize,
+            'keyword': this.dataForm.keyword,
+            'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
+            'productId': this.dataForm.productId ? this.dataForm.productId : null
+          }
+          getDrawList(params).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()
+        },
+        // 多选
+        selectionChangeHandle (val) {
+          this.dataListSelections = val
+        },
+        addSubmit () {
+          if (this.dataListSelections.length === 0) {
+            this.$message.warning('请选择')
+            return
+          }
+          this.visible = false
+          this.$emit('addItems', this.dataListSelections)
+        },
+        // 跳转上传图纸页面
+        gotoPage () {
+          this.visible = false
+          this.$router.push('/tech-draw-management')
+        }
+      }
+    }
+  </script>
+  
+  <style scoped>
+  
+  </style>
+  

+ 44 - 42
src/views/modules/tech/product-add-or-update.vue

@@ -110,7 +110,7 @@
       </el-row>
       <el-row>
         <div class="title"><span style="color: red">*</span> 关联图纸</div>
-        <el-table :data="dataForm.drawingList" border style="width: 100%;">
+        <el-table :data="drawingList" border style="width: 100%;">
           <el-table-column label="序号" type="index" width="50" align="center">
           </el-table-column>
           <el-table-column prop="drawingName" header-align="center" align="center" label="图纸名称">
@@ -121,6 +121,11 @@
           </el-table-column>
           <el-table-column prop="notes" header-align="center" align="center" label="备注">
           </el-table-column>
+          <el-table-column header-align="center" align="center" label="操作">
+            <template slot-scope="scope">
+              <el-button type="text" size="small" @click="removeDrawingItem(scope.$index)">移除</el-button>
+            </template>
+          </el-table-column>
         </el-table>
         <el-row style="text-align: center; margin-top: 10px;">
           <el-button v-show="!display" type="primary" icon="el-icon-plus" @click="addDrawingList"></el-button>
@@ -162,12 +167,14 @@
     <!-- </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" />
   </div>
 </template>
 
 <script>
 import templateChose from '../product/template-chose'
 import templateChoseMaterial from '../product/template-chose-material'
+import templateDrawChoose from './draw-template-choose'
 import { getDictList } from '@/api/dict'
 import { getProductDetail } from '@/api/product'
 import UploadComponent from '../common/upload-component-v2'
@@ -178,7 +185,7 @@ import DocComponents from '../common/doc-components'
 
 export default {
   name: 'product-add-or-update',
-  components: { DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial },
+  components: { DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial, templateDrawChoose },
   computed: {
     orgId: {
       get () { return this.$store.state.user.orgId }
@@ -193,6 +200,7 @@ export default {
     return {
       productListVisible: false,
       materialListVisible: false,
+      drawListVisible: false,
       visible: false,
       display: false,
       optionsType: [],
@@ -203,8 +211,11 @@ export default {
       id: 0,
       productDetails: [],
       materialList: [],
+      drawingList: [],
       displayProductList: false,
-      dataForm: {},
+      dataForm: {
+        drawingList: []
+      },
       dataRule: {
         productName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }],
         productSpec: [{ required: true, message: '请输入物料规格', trigger: 'blur' }],
@@ -231,7 +242,9 @@ export default {
       this.listingList = []
       this.stepList = []
       this.logList = []
-      this.dataForm = {}
+      this.dataForm = {
+        drawList: []
+      }
       this.productDetails = []
       this.materialList = []
       // this.optionsTech = []
@@ -291,8 +304,8 @@ export default {
             dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
           }
           // 组合小产品
-          if (data.data.composeProductMaterialList) {
-            data.data.composeProductMaterialList.forEach((item) => {
+          if (data.data.productMaterialList) {
+            data.data.productMaterialList.forEach((item) => {
               this.productDetails.push({
                 ...item,
                 productSpec: item.specifications
@@ -406,43 +419,12 @@ export default {
               })
             })
           }
-          // // 产品配料清单
-          // this.dataForm.productMaterialList = []
-          // if (this.materialList.length > 0) {
-          //   this.materialList.forEach((item) => {
-          //     this.dataForm.productMaterialList.push({
-          //       ...item
-          //     })
-          //   })
-          // }
-          // 产品技术文件
-          let fList = this.fileList
-          if (fList.length > 0) {
-            this.dataForm.attachList = []
-            for (let i = 0; i < fList.length; i++) {
-              this.dataForm.attachList.push({
-                fileName: fList[i].name,
-                url: fList[i].url
-              })
-            }
-          } else {
-            this.$message.error('请上传产品技术文件')
-            return
-          }
-          // 产品配料清单附件
-          let fList2 = this.listingList
-          if (fList2.length > 0) {
-            this.dataForm.listingList = []
-            for (let i = 0; i < fList2.length; i++) {
-              this.dataForm.listingList.push({
-                fileName: fList2[i].name,
-                url: fList2[i].url
-              })
-            }
-          } else {
-            this.$message.error('请上传产品配料清单附件')
+          if (this.drawingList.length <= 0) {
+            this.$message.error('请选择关联图纸')
             return
           }
+          this.dataForm.drawingList = this.drawingList
+
           this.$http({
             url: !this.id ? this.$http.adornUrl(`/biz-service/product/save`) : this.$http.adornUrl(`/biz-service/product/update`),
             method: 'post',
@@ -474,7 +456,27 @@ export default {
     },
     // 添加关联图纸
     addDrawingList () {
-
+      this.drawListVisible = true
+      this.$nextTick(() => {
+        this.$refs.drawList.init()
+      })
+    },
+    addDrawItems (items) {
+      items.forEach((item) => {
+        this.addDrawItem(item)
+      })
+    },
+    addDrawItem (item) {
+      this.drawingList.push({
+        drawingId: item.drawingId,
+        drawingName: item.drawingName,
+        drawingNo: item.drawingNo,
+        source: item.source,
+        notes: item.notes
+      })
+    },
+    removeDrawingItem (index) {
+      this.drawingList.splice(index, 1)
     }
   }
 }