浏览代码

技术工艺-产品管理

liqianyi 3 年之前
父节点
当前提交
4d0f21f1de

+ 127 - 0
src/views/modules/common/doc-components.vue

@@ -0,0 +1,127 @@
+<template>
+    <div>
+      <el-select
+        v-model="value"
+        ref="select"
+        placeholder="请选择"
+        clearable
+        filterable
+        remote
+        multiple
+        :disabled="disabled"
+        :remote-method="remoteMethod"
+        @change="onChange"
+        @focus="cancelReadOnly"
+        @hook:mounted="cancelReadOnly"
+        @visible-change="cancelReadOnly">
+        <el-option
+          v-for="item in options"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value">
+        </el-option>
+        <el-option v-if="noMore" label="加载更多" disabled style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
+      </el-select>
+    </div>
+</template>
+
+<script>
+  export default {
+    name: 'doc-components',
+    props: {
+      docIds: {
+        type: Array,
+        default: () => []
+      },
+      disabled: {
+        type: Boolean,
+        default: false
+      }
+    },
+    data () {
+      return {
+        value: [],
+        current: 1,
+        size: 10,
+        name: '',
+        options: [],
+        loading: false,
+        noMore: false
+      }
+    },
+    watch: {
+      docIds (value) {
+        this.value = value
+      }
+    },
+    mounted () {
+      this.init()
+    },
+    methods: {
+      async init () {
+        this.getList()
+      },
+      remoteMethod (query) {
+        this.options = []
+        this.current = 1
+        this.name = query
+        this.getList()
+      },
+      getList () {
+        this.$http({
+          url: this.$http.adornUrl(`/file-service/document-ctl/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'fileName': this.name
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            if (this.current > data.data.pages) {
+              return
+            }
+            this.noMore = data.data.records.length >= 10
+            data.data.records.forEach(item => {
+              this.options.push({
+                label: item.fileName,
+                value: item.docId,
+                fileType: item.fileType,
+                url: item.url
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        this.$emit('change', item)
+      },
+      cancelReadOnly (onOff) {
+        this.$nextTick(() => {
+          if (!onOff) {
+            const input = this.$refs.select.$el.querySelector('.el-input__inner')
+            const timer = setTimeout(() => {
+              input.removeAttribute('readonly')
+              clearTimeout(timer)
+            }, 200)
+          }
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+.el-select{
+  width: 100%;
+}
+</style>

+ 2 - 1
src/views/modules/common/upload-component.vue

@@ -15,7 +15,8 @@
           :file-list="fileList"
           :limit="limit"
           :on-exceed="handleExceed"
-          :auto-upload="false">
+          :auto-upload="false"
+          style="margin-top: 10px; margin-left: 10px">
           <el-button v-show="!display" slot="trigger" size="small" type="primary">选取文件</el-button>
           <el-button v-show="!display" style="margin-left: 10px;" size="small" type="success" @click="submitUpload">开始上传</el-button>
         </el-upload>

+ 41 - 3
src/views/modules/tech/product-add-or-update.vue

@@ -60,13 +60,21 @@
                 <cus-component v-model="dataForm.source" :cus-id.sync="dataForm.source"></cus-component>
               </el-form-item>
             </el-col>
-            <el-col :span="16">
+            <el-col :span="8">
               <el-form-item label="产品图纸" prop="drawingIdList">
                 <draw-components v-model="dataForm.drawingIdList" :draw-ids="dataForm.drawingIdList" @change='receiverChange'></draw-components>
               </el-form-item>
             </el-col>
+            <el-col :span="8">
+              <el-form-item label="所需文件资料" prop="docIdList">
+                <doc-components v-model="dataForm.docIdList" :doc-ids="dataForm.docIdList" @change='docSelectChange'/>
+              </el-form-item>
+            </el-col>
           </el-row>
           <el-row class="my-row">
+            <upload-component :title="'产品技术文件(多选)'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
+          </el-row>
+          <el-row class="my-row" style="margin-top: 20px">
             <el-form-item label="备注" prop="notes">
               <el-input type="textarea" v-model="dataForm.notes" :disabled="display"></el-input>
             </el-form-item>
@@ -199,10 +207,11 @@
   import { dealStepData, dealStepLogs } from '@/api/util'
   import CusComponent from '../common/cus-component'
   import DrawComponents from '../common/draw-components'
+  import DocComponents from '../common/doc-components'
 
-  export default {
+export default {
     name: 'product-add-or-update',
-    components: {DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial},
+    components: {DocComponents, DrawComponents, CusComponent, UploadComponent, templateChose, templateChoseMaterial},
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }
@@ -233,6 +242,7 @@
           productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
           productSpec: [{ required: true, message: '产品规格不能为空', trigger: 'blur' }],
           productType: [{ required: true, message: '产品类别不能为空', trigger: 'change' }],
+          docIdList: [{ required: true, message: '所需文件资料不能为空', trigger: 'change' }],
           source: [{ required: true, message: '产品来源不能为空', trigger: 'change' }],
           drawingIdList: [{ required: true, message: '产品图纸不能为空', trigger: 'blur' }]
         },
@@ -267,6 +277,16 @@
         await getProductDetail(this.id).then(({data}) => {
           if (data && data.code === '200') {
             this.dataForm = data.data
+            // 附件
+            if (data.data.attachList) {
+              data.data.attachList.forEach((item) => {
+                this.fileList.push({
+                  name: item.fileName,
+                  url: item.url,
+                  id: item.url
+                })
+              })
+            }
             // 流程图展示
             if (data.data.workFlowBusinessExt) {
               dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
@@ -395,6 +415,20 @@
                 })
               })
             }
+            // 产品技术文件
+            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
+            }
             this.$http({
               url: this.$http.adornUrl(`/biz-service/product/save`),
               method: 'post',
@@ -419,6 +453,10 @@
       },
       receiverChange (val) {
         this.dataForm.drawingIdList = val
+      },
+      docSelectChange (val) {
+        console.log(val)
+        this.dataForm.docIdList = val
       }
     }
   }