Browse Source

feature(OMS前端):oms前端字段更改及文件上传调用

yanglingling 1 year ago
parent
commit
c989eedefb

+ 9 - 1
src/views/work/train/sale/components/details.vue

@@ -40,7 +40,15 @@
           {{ detailsForm.trainSummary }}
         </el-descriptions-item>
         <el-descriptions-item v-if="detailsForm.nextStep != ''" label="下一步工作计划">
-          {{ detailsForm.nextStep }}
+          <el-link
+            :key="detailsForm.nextStep"
+            class="link"
+            :href="detailsForm.nextStep"
+            target="_blank"
+            type="primary"
+            :underline="false">
+            下一步工作计划
+          </el-link>
         </el-descriptions-item>
       </el-descriptions>
       <template #footer>

+ 68 - 2
src/views/work/train/sale/components/finish.vue

@@ -19,7 +19,18 @@
         </el-col>
         <el-col :span="24">
           <el-form-item label="下一步工作计划" prop="nextStep">
-            <el-input v-model="form.nextStep" :rows="2" type="textarea" />
+            <el-upload
+              ref="uploadRef"
+              action="#"
+              :before-upload="
+                (file) => {
+                  return beforeAvatarUpload(file)
+                }
+              "
+              :http-request="uploadRequest"
+              :limit="1">
+              <el-button size="mini" type="primary">点击上传</el-button>
+            </el-upload>
           </el-form-item>
         </el-col>
       </el-row>
@@ -33,11 +44,24 @@
 
 <script>
   import Api from '@/api/work/trainSale'
+  import axios from 'axios'
+  import asyncUploadFile from '@/utils/uploadajax'
 
   export default {
     name: 'WorkOrderFeedback',
     data() {
       return {
+        fileList: [],
+        fileSettings: {
+          // 文件配置信息
+          fileSize: 52428800,
+          fileTypes: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.txt',
+          pictureSize: 52428800,
+          pictureTypes: '.jpg,.jpeg,.gif,.png,.jfif,.txt',
+          types: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.mp4,.txt',
+          videoSize: 104857600,
+          videoType: '.mp4',
+        },
         form: {
           orderId: undefined,
           explainDuration: undefined,
@@ -49,13 +73,53 @@
           explainDuration: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
           questionRecord: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
           trainSummary: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
-          nextStep: [{ required: true, message: '不能为空', trigger: ['blur', 'change'] }],
         },
         dialogFormVisible: false,
       }
     },
     mounted() {},
     methods: {
+      // 上传附件
+      beforeAvatarUpload(file) {
+        let flag1 = file.size < this.fileSettings.fileSize
+        if (!flag1) {
+          this.$message.warning('文件过大,请重新选择!')
+          return false
+        }
+        let flag2 = this.fileSettings.fileTypes.split(',').includes('.' + file.name.split('.').pop())
+        if (!flag2) {
+          this.$message.warning('文件类型不符合,请重新选择!')
+          return false
+        }
+        return true
+      },
+      // 上传
+      uploadRequest(option) {
+        let _this = this
+        let url = process.env.VUE_APP_UPLOAD_WEED
+        axios
+          .post(url)
+          .then(function (res) {
+            if (res.data && res.data.fid && res.data.fid !== '') {
+              option.action = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
+              asyncUploadFile(option).then(() => {
+                _this.form.fileName = option.file.name
+                _this.form.fileUrl = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}` // 资料存储url
+              })
+            } else {
+              _this.$message({
+                type: 'warning',
+                message: '未上传成功!请刷新界面重新上传!',
+              })
+            }
+          })
+          .catch(function () {
+            _this.$message({
+              type: 'warning',
+              message: '未上传成功!请重新上传!',
+            })
+          })
+      },
       showEdit(row) {
         this.form = {
           applyId: row.id,
@@ -74,6 +138,8 @@
       save() {
         this.$refs['form'].validate(async (valid) => {
           if (valid) {
+            console.log(this.form)
+            this.form.nextStep = this.form.fileUrl
             const { msg } = await Api.doAddSummary(this.form)
             this.$baseMessage(msg, 'success', 'vab-hey-message-success')
             this.$emit('fetch-data')