Browse Source

bugfix: 160

chrislee 1 year ago
parent
commit
349f9b64c1

+ 1 - 1
src/views/modules/common/product-component.vue

@@ -40,7 +40,7 @@
       return {
         value: '',
         current: 1,
-        size: 10,
+        size: 100,
         name: '',
         options: [],
         loading: false,

+ 10 - 19
src/views/modules/tech-manage/material-tech-add-or-update.vue

@@ -20,21 +20,7 @@
         </el-col>
         <el-col :span="8">
           <el-form-item label="物料名称" prop="productId">
-            <el-select
-              v-model="dataForm.productId"
-              placeholder="请选择"
-              filterable
-              remote
-              clearable
-            >
-              <el-option
-                v-for="item in materialList"
-                :key="item.materialId"
-                :label="item.materialName"
-                :value="item.materialId"
-              >
-              </el-option>
-            </el-select>
+            <product-component v-model="dataForm.productId" :product-id="dataForm.productId" @productSelected="prodSelected"/>
           </el-form-item>
         </el-col>
         <el-col :span="8">
@@ -78,9 +64,10 @@
 <script>
 import UploadComponent from '../common/upload-component'
 import { getMaterialList, getMaterialTechDetail } from '@/api/material'
+import ProductComponent from '@/views/modules/common/product-component'
 export default {
   name: 'material-tech-add-or-update',
-  components: { UploadComponent },
+  components: { ProductComponent, UploadComponent },
   data () {
     return {
       id: 0,
@@ -97,11 +84,11 @@ export default {
         optionCode: [
           { required: true, message: '请输入方案编码', trigger: 'blur' }
         ],
-        materialName: [
-          { required: true, message: '请输入物料名称', trigger: 'blur' }
-        ],
         optionName: [
           { required: true, message: '请输入方案名称', trigger: 'blur' }
+        ],
+        productId: [
+          { required: true, message: '请选择物料', trigger: 'change' }
         ]
       }
     }
@@ -152,6 +139,10 @@ export default {
         }
       })
     },
+    prodSelected (item) {
+      this.dataForm.productId = item.value
+      this.dataForm.materialName = item.label
+    },
     dataFormSubmit () {
       this.$refs['dataForm'].validate((valid) => {
         if (valid) {

+ 21 - 94
src/views/modules/tech-manage/material-tech-detail.vue

@@ -4,24 +4,26 @@
     <div style="margin-left: 20px; margin-right: 20px">
       <e-desc title="基本信息" column="3">
         <e-desc-item label="方案编码">{{ dataForm.optionCode }}</e-desc-item>
-        <e-desc-item label="物料名称">{{ dataForm.materialName }}</e-desc-item>
+        <e-desc-item label="物料名称">{{ dataForm.productName }}</e-desc-item>
         <e-desc-item label="方案名称">{{ dataForm.optionName }}</e-desc-item>
         <e-desc-item label="备注说明" span="3">{{
           dataForm.remark
         }}</e-desc-item>
       </e-desc>
       <e-desc title="附件">
-        <upload-component
-          :display="true"
-          :display-title="false"
-          :accept="'*'"
-          :file-obj-list="fileList"
-        />
+        <e-desc-item span="2" label="附件">
+          <div v-for="(item, index) in dataForm.attachList" style="display: inline">
+            <span v-if="index > 0">,</span>
+            <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
+          </div>
+        </e-desc-item>
       </e-desc>
     </div>
     <span slot="footer" class="dialog-footer">
       <el-button @click="onChose">返回</el-button>
     </span>
+    <!-- 文件预览 -->
+    <preview-component v-if="previewVisible" ref="preview"/>
   </div>
 </template>
 
@@ -29,61 +31,30 @@
 import EDesc from '../common/e-desc'
 import EDescItem from '../common/e-desc-item'
 import UploadComponent from '../common/upload-component'
-import { getMaterialList, getMaterialTechDetail } from '@/api/material'
+import { getMaterialTechDetail } from '@/api/material'
+import PreviewComponent from '@/views/modules/common/preview-component'
 export default {
   name: 'material-tech-detail',
-  components: { UploadComponent, EDesc, EDescItem },
+  components: { PreviewComponent, UploadComponent, EDesc, EDescItem },
   data () {
     return {
       id: 0,
       isEdit: false,
-      dataForm: {
-        optionCode: '',
-        productId: '',
-        optionName: '',
-        remark: ''
-      },
-      fileList: [],
-      materialList: [],
-      dataRule: {
-        optionCode: [
-          { required: true, message: '请输入方案编码', trigger: 'blur' }
-        ],
-        materialName: [
-          { required: true, message: '请输入物料名称', trigger: 'blur' }
-        ],
-        optionName: [
-          { required: true, message: '请输入方案名称', trigger: 'blur' }
-        ]
-      }
+      previewVisible: false,
+      dataForm: { }
     }
   },
-  created () {},
   methods: {
     onChose () {
       this.$emit('onChose')
     },
-    async init (id, display) {
+    async init (id) {
       this.id = id || 0
-      this.fileList = []
-      this.materialList = []
-
-      await this.getMaterialList()
-
       if (!id) return
 
       await getMaterialTechDetail(id).then(({ data }) => {
         if (data && data.code === '200') {
-          this.dataForm.productId = data.data.productId
-          let marterial = this.materialList.find(
-            (t) => t.materialId === data.data.productId
-          )
-          if (marterial) {
-            this.dataForm.materialName = marterial.materialName
-          }
-          this.dataForm.optionCode = data.data.optionCode
-          this.dataForm.optionName = data.data.optionName
-          this.dataForm.remark = data.data.remark
+          this.dataForm = data.data
 
           // 附件
           if (data.data.attachList) {
@@ -98,55 +69,11 @@ export default {
         }
       })
     },
-    async getMaterialList () {
-      await getMaterialList().then(({ data }) => {
-        if (data && data.code === '200') {
-          this.materialList = data.data.records
-        }
-      })
-    },
-    dataFormSubmit () {
-      this.$refs['dataForm'].validate((valid) => {
-        if (valid) {
-          // 物料技术文件
-          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.id
-              ? this.$http.adornUrl(`/biz-service/pro-technology-option/save`)
-              : this.$http.adornUrl(
-                  `/biz-service/pro-technology-option/update`
-                ),
-            method: 'post',
-            data: this.$http.adornData({ ...this.dataForm, orgId: this.orgId })
-          }).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)
-            }
-          })
-        }
+    // 预览
+    previewFile (fileName, url) {
+      this.previewVisible = true
+      this.$nextTick(() => {
+        this.$refs.preview.init(fileName, url)
       })
     }
   }

+ 8 - 10
src/views/modules/tech-manage/material-tech.vue

@@ -22,15 +22,7 @@
           </el-date-picker>
         </el-form-item>
         <el-form-item label="物料">
-          <el-select v-model="dataForm.productId" filterable remote clearable placeholder="请选择">
-            <el-option
-                v-for="item in materialList"
-                :key="item.materialId"
-                :label="item.materialName"
-                :value="item.materialId"
-              >
-            </el-option>
-          </el-select>
+          <product-component v-model="dataForm.productId" :product-id="dataForm.productId" @productSelected="prodSelected"/>
         </el-form-item>
         <el-form-item>
           <el-button @click="search()">查询</el-button>
@@ -74,7 +66,7 @@
         >
         </el-table-column>
         <el-table-column
-          prop="materialName"
+          prop="productName"
           header-align="center"
           align="center"
           min-width="120"
@@ -191,9 +183,11 @@ import Detail from './material-tech-detail'
 import NoteChange from './material-tech-note-change'
 import AttachDetail from '../common/attach-detail'
 import { getMaterialList } from '@/api/material'
+import ProductComponent from '@/views/modules/common/product-component'
 export default {
   name: 'material-tech',
   components: {
+    ProductComponent,
     AddOrUpdate,
     Detail,
     NoteChange,
@@ -306,6 +300,10 @@ export default {
       this.$nextTick(() => {
         this.$refs.attachDetail.init(attachList)
       })
+    },
+    prodSelected (item) {
+      this.dataForm.productId = item.value
+      this.dataForm.materialName = item.label
     }
   }
 }