Ver código fonte

图库管理

chris 3 anos atrás
pai
commit
1e1bd8a27f

+ 8 - 0
src/api/product.js

@@ -34,3 +34,11 @@ export function getDrawList (params) {
     params: params
   })
 }
+
+// 图纸详情
+export function getDrawingDetail (id) {
+  return request({
+    url: request.adornUrl(`/biz-service/drawing/info/${id}`),
+    method: 'get'
+  })
+}

+ 1 - 0
src/views/modules/cus/communicate-add-or-update.vue

@@ -284,6 +284,7 @@
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
+            // 添加附件
             let fList = this.fileList
             // console.log('fileList = ' + fList)
             if (fList.length > 0) {

+ 88 - 400
src/views/modules/tech/draw-add-or-update.vue

@@ -6,222 +6,37 @@
         :close-on-click-modal="false"
         :visible.sync="visible">
         <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="productName">
-                <el-input v-model="dataForm.productName" :disabled="display" placeholder="产品名称"></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8" style="padding-left: 20px">
-              <el-form-item label="产品规格" prop="productSpec">
-                <el-input v-model="dataForm.productSpec" :disabled="display" placeholder="产品规格"></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8" style="padding-left: 20px">
-              <el-form-item label="产品类别" prop="productType">
-                <el-select
-                  v-model="dataForm.productType"
-                  :disabled="display"
-                  remote
-                  placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsType"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row class="my-row">
-            <el-col :span="8">
-              <el-form-item label="产品来源" prop="source">
-                <el-input v-if="display" v-model="dataForm.sourceName" disabled></el-input>
-                <el-select v-else
-                  v-model="dataForm.source"
-                  :disabled="display"
-                           filterable
-                  remote
-                           :remote-method="remoteCusList"
-                  placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsSource"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="8" style="padding-left: 20px">
-              <el-form-item label="产品工艺" prop="techId">
-                <el-input v-if="display" v-model="dataForm.techName" disabled></el-input>
-                <el-select v-else
-                  v-model="dataForm.techId"
-                  :disabled="display"
-                           filterable
-                  remote
-                           :remote-method="remoteTech"
-                  placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsTech"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row class="my-row">
-            <el-form-item label="产品图纸" prop="drawingIdList">
-              <el-upload v-if="display"
-                class="upload-demo"
-                ref="upload"
-                :multiple="true"
-                action="#"
-                accept="image/jpeg,image/gif,image/png"
-                :on-preview="handlePreview"
-                :file-list="fileList"
-                :auto-upload="false">
-              </el-upload>
-              <el-select v-else
-                v-model="dataForm.drawingIdList"
-                :disabled="display"
-                         filterable
-                         multiple
-                         remote
-                         :remote-method="remoteDraw"
-                placeholder="请选择">
-                <el-option
-                  v-for="item in optionsDraw"
-                  :key="item.code"
-                  :label="item.value"
-                  :value="item.code">
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-row>
-          <el-row class="my-row">
-            <el-form-item label="备注" prop="notes">
-              <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注"></el-input>
-            </el-form-item>
-          </el-row>
-          <el-row class="my-row">
-            <el-form-item label="是否组合产品" prop="displayProductList">
-              <el-switch
-                v-model="dataForm.displayProductList"
-                :disabled="display"
-                active-color="#13ce66"
-                inactive-color="#ff4949"
-                active-text="是"
-                inactive-text="否">
-              </el-switch>
-            </el-form-item>
-          </el-row>
-          <el-row v-if="dataForm.displayProductList">
-            <div class="title"><span style="color: red">*</span> 组合小产品</div>
-            <el-table
-              :data="productDetails"
-              border
-              style="width: 100%;">
-              <el-table-column
-                label="序号"
-                type="index"
-                width="50"
-                align="center">
-              </el-table-column>
-              <el-table-column
-                prop="productName"
-                header-align="center"
-                align="center"
-                label="产品名称">
-              </el-table-column>
-              <el-table-column
-                prop="productSpec"
-                header-align="center"
-                align="center"
-                label="规格">
-              </el-table-column>
-              <el-table-column
-                prop="cnt"
-                header-align="center"
-                align="center"
-                label="数量"
-                width="170">
-                <template slot-scope="scope">
-                  <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;"/>
-                </template>
-              </el-table-column>
-              <el-table-column
-                prop="unitName"
-                header-align="center"
-                align="center"
-                label="单位">
-              </el-table-column>
-              <el-table-column
-                prop="notes"
-                header-align="center"
-                align="center"
-                label="备注">
-              </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="addProduct"></el-button>
-            </el-row>
-          </el-row>
-          <el-row>
-            <div class="title"><span style="color: red">*</span> 产品配料清单</div>
-            <el-table
-              :data="materialList"
-              border
-              style="width: 100%;">
-              <el-table-column
-                label="序号"
-                type="index"
-                width="50"
-                align="center">
-              </el-table-column>
-              <el-table-column
-                prop="materialName"
-                header-align="center"
-                align="center"
-                label="物品名称">
-              </el-table-column>
-              <el-table-column
-                prop="specifications"
-                header-align="center"
-                align="center"
-                label="规格">
-              </el-table-column>
-              <el-table-column
-                prop="cnt"
-                header-align="center"
-                align="center"
-                label="数量"
-                width="170">
-                <template slot-scope="scope">
-                  <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;"/>
-                </template>
-              </el-table-column>
-              <el-table-column
-                prop="unitName"
-                header-align="center"
-                align="center"
-                label="单位">
-              </el-table-column>
-              <el-table-column
-                prop="notes"
-                header-align="center"
-                align="center"
-                label="备注">
-              </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="addMaterial"></el-button>
-            </el-row>
-          </el-row>
+          <el-form-item label="图纸编码" prop="drawingCode">
+            <el-input v-model="dataForm.drawingCode" :disabled="display || !id" placeholder="系统自动生成,无需填写"></el-input>
+          </el-form-item>
+          <el-form-item label="图纸名称" prop="drawingName">
+            <el-input v-model="dataForm.drawingName" :disabled="display" placeholder="图纸名称"></el-input>
+          </el-form-item>
+          <el-form-item label="图纸来源" prop="source">
+            <el-input v-model="dataForm.source" :disabled="display" placeholder="图纸来源"></el-input>
+          </el-form-item>
+          <el-form-item label="备注" prop="notes">
+            <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注"></el-input>
+          </el-form-item>
+          <el-form-item label="图纸" prop="attachList">
+            <el-upload
+               class="upload-demo"
+               ref="upload"
+               :multiple="true"
+               action="#"
+               accept="image/jpeg,image/gif,image/png"
+               :on-preview="handlePreview"
+               :on-remove="handleRemove"
+               :on-change="handleChange"
+               :file-list="fileList"
+               :limit="5"
+               :on-exceed="handleExceed"
+               :auto-upload="false">
+              <el-button slot="trigger" size="small" type="primary" v-show="!display">选取文件</el-button>
+              <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload" v-show="!display">开始上传</el-button>
+              <div slot="tip" class="el-upload__tip" v-show="!display">只能上传jpg/png文件,最多5张图片,且每张图片不超过10M</div>
+            </el-upload>
+          </el-form-item>
         </el-form>
         <span slot="footer" class="dialog-footer">
           <el-button @click="visible = false">取消</el-button>
@@ -232,61 +47,41 @@
       <el-dialog title="图片预览" :visible.sync="previewVisible" width="50%">
         <img :src="previewPath" :alt="previewName" style="width:100%;height:100%" />
       </el-dialog>
-      <template-chose v-if="productListVisible" ref="productList" @addItem="addProductItem" />
-      <templateChoseMaterial v-if="materialListVisible" ref="materialList" @addItem="addMaterialItem"/>
     </div>
 </template>
 
 <script>
-  import templateChose from '../product/template-chose'
-  import templateChoseMaterial from '../product/template-chose-material'
-  import { getDictList } from '@/api/dict'
-  import { getProductDetail, getTechList, getDrawList } from '@/api/product'
-  import { uploadUrl, downloadUrl } from '@/api/file'
-  import { getCusList } from '@/api/cus'
+  import { getDrawingDetail } from '@/api/product'
+  import { uploadUrl, downloadUrl, uploadFiles } from '@/api/file'
 
   export default {
-    name: 'draw-add-or-update',
-    components: {templateChose, templateChoseMaterial},
+    name: 'add-or-update',
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }
       }
     },
-    watch: {
-      'dataForm.isCompose' (value) {
-        this.dataForm.displayProductList = value === '1'
-      }
-    },
+    // watch: {
+    //   'dataForm.isCompose' (value) {
+    //     this.dataForm.displayProductList = value === '1'
+    //   }
+    // },
     data () {
       return {
-        productListVisible: false,
-        materialListVisible: false,
         visible: false,
         display: false,
-        optionsType: [],
-        optionsTech: [],
-        optionsSource: [],
-        optionsDraw: [],
         fileList: [],
         dataList: [],
         id: 0,
-        productDetails: [],
-        materialList: [],
-        dataForm: {
-          displayProductList: false
-        },
+        dataForm: {},
         uploadUrl: uploadUrl,
         previewPath: '',
         previewName: '',
         previewVisible: false,
+        optionsProducts: [],
         dataRule: {
-          productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
-          productSpec: [{ required: true, message: '产品规格不能为空', trigger: 'blur' }],
-          productType: [{ required: true, message: '产品类别不能为空', trigger: 'change' }],
-          source: [{ required: true, message: '产品来源不能为空', trigger: 'change' }],
-          techId: [{ required: true, message: '产品工艺不能为空', trigger: 'change' }],
-          drawingIdList: [{ required: true, message: '产品图纸不能为空', trigger: 'change' }]
+          drawingName: [{ required: true, message: '图纸名称不能为空', trigger: 'blur' }],
+          source: [{ required: true, message: '图纸来源不能为空', trigger: 'blur' }]
         }
       }
     },
@@ -302,154 +97,60 @@
         this.visible = true
         this.id = id || 0
         this.display = display
-        // 获取产品类别
-        await getDictList({type: 'product_type'}).then(({data}) => {
-          if (data) {
-            this.optionsType = data
-          }
-        })
-        // 产品工艺
         if (!id) return
-        await getProductDetail(this.id).then(({data}) => {
+        await getDrawingDetail(this.id).then(({data}) => {
           if (data && data.code === '200') {
             this.dataForm = data.data
-            // 组合小产品
-            data.data.composeProductMaterialList.forEach((item) => {
-              this.productDetails.push(item)
-            })
-            // 产品配料清单
-            data.data.productMaterialList.forEach((item) => {
-              this.materialList.push(item)
-            })
-            // 产品来源
-            if (data.data.source) {
-              this.optionsSource = [{
-                code: data.data.source,
-                value: data.data.sourceName
-              }]
-            }
-            // 产品工艺
-            if (data.data.techId) {
-              this.optionsTech = [{
-                code: data.data.techId,
-                value: data.data.techName
-              }]
-            }
-            // 产品图纸
-            if (data.data.proDrawings) {
-              this.dataForm.drawingIdList = []
-              data.data.proDrawings.forEach((item) => {
-                if (item.attachList) {
-                  item.attachList.forEach((item1) => {
-                    this.fileList.push({
-                      name: item1.fileName,
-                      url: item1.url,
-                      id: item1.url
-                    })
-                  })
-                }
-                this.optionsDraw.push({
-                  code: item.drawingId,
-                  value: item.drawingName
+            // 图纸
+            if (data.data.attachList) {
+              data.data.attachList.forEach((item) => {
+                this.fileList.push({
+                  name: item.fileName,
+                  url: item.url,
+                  id: item.url
                 })
-                this.dataForm.drawingIdList.push(item.drawingId)
               })
             }
           }
         })
       },
-      handlePreview (file) {
-        if (file && file.url) {
-          // 获取文件路径
-          this.previewPath = downloadUrl + file.url
-          this.previewName = file.name
-          this.previewVisible = true
-        }
-      },
-      // 产品来源(客户)列表
-      async remoteCusList (query) {
-        if (!query) {
-          query = ''
-        }
-        await getCusList({'customerName': query}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsSource = []
-            data.data.records.forEach((item) => {
-              this.optionsSource.push({
-                code: item.customerId,
-                value: item.customerName
-              })
-            })
-          }
-        }
-      )
-      },
-      // 产品工艺
-      async remoteTech (query) {
-        if (!query) {
-          query = ''
+      submitUpload () {
+        // this.$refs.upload.submit()
+        if (this.fileList.length === 0) {
+          return this.$message.warning('请选取文件后再上传')
         }
-        await getTechList().then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsTech = []
-            data.data.records.forEach((item) => {
-              this.optionsTech.push({
-                code: item.customerId,
-                value: item.customerName
-              })
-            })
-          }
+        const formData = new FormData()
+        this.fileList.forEach((file) => {
+          formData.append('file', file.raw)
         })
-      },
-      // 图纸
-      async remoteDraw (query) {
-        if (!query) {
-          query = ''
-        }
-        await getDrawList({'keyword': query}).then(({data}) => {
+        uploadFiles(formData).then(({data}) => {
           if (data && data.code === '200') {
-            this.optionsDraw = []
-            data.data.records.forEach((item) => {
-              this.optionsDraw.push({
-                code: item.drawingId,
-                value: item.drawingName
-              })
+            data.data.forEach((item) => {
+              let fileData = this.fileList.find((file) => file.name === item.originFileName)
+              fileData.url = item.fileUrl
             })
+            this.$message.success('上传成功')
+          } else {
+            this.$message.error('上传失败')
           }
         })
       },
-      // 添加组合产品
-      addProduct () {
-        this.productListVisible = true
-        this.$nextTick(() => {
-          this.$refs.productList.init()
-        })
+      handleRemove (file, fileList) {
+        this.fileList = fileList
       },
-      addProductItem (item) {
-        this.productDetails.push({
-          productId: item.productId,
-          productName: item.productName,
-          productSpec: item.productSpec,
-          cnt: 1,
-          unitName: item.unitName,
-          notes: item.notes
-        })
+      handlePreview (file) {
+        if (file && file.url) {
+          // 获取文件路径
+          this.previewPath = downloadUrl + file.url
+          this.previewName = file.name
+          this.previewVisible = true
+        }
       },
-      addMaterial () {
-        this.materialListVisible = true
-        this.$nextTick(() => {
-          this.$refs.materialList.init()
-        })
+      handleChange (file, fileList) {
+        this.fileList = fileList
       },
-      addMaterialItem (item) {
-        this.materialList.push({
-          materialId: item.materialId,
-          materialName: item.materialName,
-          specifications: item.specifications,
-          cnt: item.cnt,
-          unitName: item.unitName,
-          notes: item.notes
-        })
+      handleExceed (files, fileList) {
+        this.$message.warning(`当前限制选择 5 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
       },
       validateField (type) {
         this.$refs.dataForm.validateField(type)
@@ -458,32 +159,19 @@
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
-            // 组合小产品
-            this.dataForm.composeProductMaterialList = []
-            const b1 = this.dataForm.displayProductList
-            this.dataForm.isCompose = b1 === true ? '1' : '0'
-            if (this.dataForm.isCompose === '1' && this.productDetails.length > 0) {
-              this.productDetails.forEach((item) => {
-                this.dataForm.composeProductMaterialList.push({
-                  cnt: item.cnt,
-                  materialId: item.productId,
-                  notes: item.notes
+            // 添加附件
+            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
                 })
-              })
-            }
-            // 产品配料清单
-            this.dataForm.productMaterialList = []
-            if (this.materialList.length > 0) {
-              this.materialList.forEach((item) => {
-                this.dataForm.productMaterialList.push({
-                  cnt: item.cnt,
-                  materialId: item.materialId,
-                  notes: item.notes
-                })
-              })
+              }
             }
             this.$http({
-              url: this.$http.adornUrl(`/biz-service/product/save`),
+              url: this.$http.adornUrl(`/biz-service/drawing/save`),
               method: 'post',
               data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
             }).then(({data}) => {

+ 3 - 37
src/views/modules/tech/draw-management.vue

@@ -3,7 +3,7 @@
   <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-input v-model="dataForm.keyword" placeholder="名称" clearable/>
       </el-form-item>
       <el-form-item label="创建日期">
         <el-date-picker
@@ -15,22 +15,6 @@
           end-placeholder="结束日期">
         </el-date-picker>
       </el-form-item>
-      <el-form-item label="对应产品">
-        <el-select
-          v-model="dataForm.productId"
-          filterable
-          clearable
-          remote
-          :remote-method="remoteProducts"
-          placeholder="请选择">
-          <el-option
-            v-for="item in optionsProducts"
-            :key="item.code"
-            :label="item.value"
-            :value="item.code">
-          </el-option>
-        </el-select>
-      </el-form-item>
       <el-form-item>
         <el-button @click="search()">查询</el-button>
         <el-button type="primary" @click="addOrUpdateHandle(0, false)">上传图纸</el-button>
@@ -125,10 +109,10 @@
 
 <script>
   import AddOrUpdate from './draw-add-or-update'
-  import { getDrawList, getProductList } from '@/api/product'
+  import { getDrawList } from '@/api/product'
   export default {
     name: 'draw-management',
-    comments: {
+    components: {
       AddOrUpdate
     },
     data () {
@@ -228,24 +212,6 @@
             }
           })
         }).catch(() => {})
-      },
-      async remoteProducts (query) {
-        if (!query) return
-        let params = {
-          'productName': query
-        }
-        await getProductList(params).then(({data}) => {
-          this.optionsProducts = []
-          if (data && data.code === '200') {
-            data.data.records.forEach((item) => {
-              this.optionsProducts.push({
-                code: item.productId,
-                value: item.productName,
-                id: item.productId
-              })
-            })
-          }
-        })
       }
     }
   }

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

@@ -286,7 +286,7 @@
           productType: [{ required: true, message: '产品类别不能为空', trigger: 'change' }],
           source: [{ required: true, message: '产品来源不能为空', trigger: 'change' }],
           techId: [{ required: true, message: '产品工艺不能为空', trigger: 'change' }],
-          drawingIdList: [{ required: true, message: '产品图纸不能为空', trigger: 'change' }]
+          drawingIdList: [{ required: true, message: '产品图纸不能为空', trigger: 'blur' }]
         }
       }
     },