scorpio 2 лет назад
Родитель
Сommit
6f85d64394

+ 11 - 0
src/api/contract/index.js

@@ -117,5 +117,16 @@ export default {
       'post',
       'json'
     )
+  },
+  /**
+   *  合同相关文件
+   */
+  linkContractFile(params) {
+    return fetch(
+      '/blade-project-manage-v2/contracts-manage/v2/save-files',
+      params,
+      'post',
+      'json'
+    )
   }
 }

+ 25 - 0
src/api/project/index.js

@@ -334,6 +334,31 @@ export default {
       params,
       'post'
     )
+  },
+  /**
+   * 关联文件,前期文件
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  linkFile(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/situation-save-file',
+      params,
+      'post',
+      'json'
+    )
+  },
+  /**
+   * 删除关联文件
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  delLinkFile(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/situation-delete-file',
+      params,
+      'post'
+    )
   }
 }
 

+ 16 - 2
src/api/store/index.js

@@ -29,8 +29,9 @@ export default {
    */
   removeFile(params) {
     return fetch(
-      '/blade-project-manage-v2/project-dispatch/v2/delete-file',
-      params
+      '/blade-project-manage-v2/project-dispatch/v2/storage-delete-file',
+      params,
+      'post'
     )
   },
   /**
@@ -101,5 +102,18 @@ export default {
       '/blade-project-manage-v2/project-dispatch/v2/pre-storage-key-detail',
       params
     )
+  },
+  /**
+   * 关联文件
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  linkFile(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/storage-save-file',
+      params,
+      'post',
+      'json'
+    )
   }
 }

+ 31 - 10
src/components/filepicker/index.vue

@@ -7,13 +7,13 @@
         type="primary"
         icon="Upload"
         @click="show = true"
-        >上传</el-button
-      >
+        >上传
+      </el-button>
       <el-button v-else type="primary" icon="Upload" @click="show = true"
-        >文件上传</el-button
-      >
+        >文件上传
+      </el-button>
     </div>
-    <el-dropdown v-else @command="openFile" class="ml-10">
+    <el-dropdown v-else class="ml-10" @command="commandChange">
       <el-button type="primary">
         文件上传
         <el-icon class="el-icon--right">
@@ -22,7 +22,11 @@
       </el-button>
       <template #dropdown>
         <el-dropdown-menu>
-          <el-dropdown-item v-for="(item, index) in command" :command="index">
+          <el-dropdown-item
+            v-for="(item, index) in command"
+            :key="item.label"
+            :command="item"
+          >
             {{ item.label }}
           </el-dropdown-item>
         </el-dropdown-menu>
@@ -102,9 +106,9 @@
                 @goHome="getFolderList"
               />
               <div class="tips flex flex-center flex-justify-start" v-else>
-                <el-icon class="mr-10" color="#409eff" :size="20"
-                  ><WarningFilled
-                /></el-icon>
+                <el-icon class="mr-10" color="#409eff" :size="20">
+                  <WarningFilled />
+                </el-icon>
                 {{ tips }}
               </div>
             </div>
@@ -156,6 +160,7 @@ export default {
       type: String,
       default: ''
     },
+    extra: Object,
     menuBtn: {
       type: Boolean,
       default: false
@@ -203,6 +208,7 @@ export default {
       dictKey: '',
       loading: false,
       currentRow: null,
+      currentCommand: null,
       page: {
         current: 1,
         size: 10,
@@ -378,9 +384,24 @@ export default {
         console.log('top')
       }
     },
+    /**
+     * 选择
+     */
+    commandChange(res) {
+      this.currentCommand = res
+      this.show = true
+    },
+    /**
+     * 确定
+     */
     submit() {
       this.show = false
-      this.$emit('submit', this.selectedList)
+      this.$emit(
+        'submit',
+        this.selectedList,
+        this.currentCommand ? this.currentCommand : '',
+        this.extra ? this.extra : ''
+      )
     }
   }
 }

+ 13 - 9
src/views/contract/component/info2.vue

@@ -34,7 +34,7 @@
                 form.accountInformationFileList.length === 0
               "
             >
-              <uploads :max="9" @success="uploadSucc" :auto="true" />
+              <filepicker :project-id="info.projectId" />
               <div>
                 <div v-for="item in fileList" :key="item.id">
                   {{ item.originalFileName }}
@@ -52,7 +52,7 @@
             </div>
           </div>
           <div v-else>
-            <uploads :max="9" @success="uploadSucc" :auto="true" />
+            <filepicker :project-id="info.projectId" @submit="uploadSucc" />
             <div>
               <div v-for="item in fileList" :key="item.id">
                 {{ item.originalFileName }}
@@ -71,12 +71,18 @@
 </template>
 
 <script>
-import uploads from '../../../components/uploads.vue'
 import api from '@/api/index.js'
+import filepicker from '@/components/filepicker/index.vue'
 
 export default {
   name: 'info',
-  components: { uploads },
+  components: { filepicker },
+  props: {
+    info: {
+      type: Object,
+      default: null
+    }
+  },
   data() {
     return {
       id: '',
@@ -322,11 +328,9 @@ export default {
         console.log(res)
       })
     },
-    uploadSucc(res) {
-      const tmp = res.fileList.map(ele => {
-        return ele.response.data
-      })
-      this.fileList = this.fileList.concat(tmp)
+    uploadSucc(list) {
+      this.fileList = this.fileList.concat(list)
+      console.log(this.fileList)
       this.form.fileIds = this.fileList.map(ele => ele.id).join(',')
     }
   }

+ 23 - 2
src/views/contract/component/info3.vue

@@ -11,6 +11,13 @@
         v-model="form"
         :before-open="beforeOpen"
       >
+        <template #menu-left>
+          <filepicker
+            v-if="info"
+            :project-id="info.projectId"
+            @submit="submit"
+          />
+        </template>
         <template #menu-right>
           <el-button icon="Refresh" circle @click="getDetail"></el-button>
         </template>
@@ -26,9 +33,13 @@
 
 <script>
 import api from '@/api/index.js'
+import filepicker from '@/components/filepicker/index.vue'
 
 export default {
   name: 'info',
+  components: {
+    filepicker
+  },
   props: {
     info: {
       type: Object,
@@ -59,9 +70,8 @@ export default {
         menuWidth: 220,
         menuBtnTitle: '支付凭证',
         size: 'mini',
-        addBtn: true,
+        addBtn: false,
         delBtn: false,
-        addBtnText: '上传',
         editBtn: true,
         editBtnText: '下载',
         viewBtn: true,
@@ -138,6 +148,17 @@ export default {
         }
       })
       window.open(routeUrl.href, '_blank')
+    },
+    submit(list) {
+      const tmps = list.map(ele => {
+        return { fileId: ele.id, contractId: this.info.id }
+      })
+      this.$api.contract.linkContractFile(tmps).then(res => {
+        if (res.code === 200) {
+          console.log(res)
+          this.getDetail()
+        }
+      })
     }
   }
 }

+ 1 - 10
src/views/contract/index.vue

@@ -54,11 +54,7 @@
       <template #menu-left>
         <div class="flex flex-center">
           <div class="main-color ml-10 mr-20 bold font-15">金额单位:万元</div>
-          <filepicker
-            :project-id="projectId"
-            @submit="selection"
-            :command="command"
-          />
+          <filepicker :project-id="projectId" @submit="selection" />
         </div>
       </template>
     </avue-crud>
@@ -82,11 +78,6 @@ export default {
       projectId: '',
       form: {},
       data: [],
-      command: [
-        {
-          label: '33'
-        }
-      ],
       option: {
         align: 'center',
         menuAlign: 'center',

+ 42 - 24
src/views/home/component/params/params4.vue

@@ -11,8 +11,6 @@
         v-model="form"
         :before-open="beforeOpen"
         @row-del="rowDel"
-        @row-save="rowSave"
-        @row-update="rowUpdate"
       >
         <template #menu-right>
           <div class="full-width">
@@ -24,21 +22,22 @@
           </div>
         </template>
         <template #menu="{ row }">
-          <el-button
-            text
-            type="primary"
-            icon="el-icon-folder-checked"
-            @click="openFolder(row)"
-            >打开文件夹
-          </el-button>
-          <el-button
-            text
-            type="primary"
-            icon="el-icon-view"
-            @click="edit(row)"
-            v-if="detail.can_update"
-            >文号提取
-          </el-button>
+          <div class="flex flex-center">
+            <filepicker
+              :project-id="detail.id"
+              :menu-btn="true"
+              :extra="row"
+              @submit="onSuccess"
+            />
+            <el-button
+              text
+              type="primary"
+              icon="el-icon-view"
+              @click="edit(row)"
+              v-if="detail.can_update"
+              >文号提取
+            </el-button>
+          </div>
         </template>
         <template #file="{ row }">
           <div v-if="row.file">
@@ -78,6 +77,7 @@
 
 <script>
 import api from '@/api/index.js'
+import filepicker from '@/components/filepicker/index.vue'
 
 const defaultData = [
   {
@@ -164,6 +164,9 @@ const defaultData = [
 
 export default {
   name: 'params4',
+  components: {
+    filepicker
+  },
   props: {
     info: {
       type: Object,
@@ -205,9 +208,10 @@ export default {
         menuWidth: 380,
         size: 'mini',
         addBtn: false,
+        editBtn: false,
         viewBtn: true,
         delBtn: true,
-        editBtnText: '上传',
+        detailBtn: false,
         viewBtnText: '预览',
         refreshBtn: false,
         columnBtn: false,
@@ -266,7 +270,6 @@ export default {
      * @param item
      */
     openFolder(item) {
-      console.log(item)
       this.$router.push({
         path: '/home/files',
         query: {
@@ -280,7 +283,6 @@ export default {
      * @param item
      */
     previewFile(item) {
-      console.log(item)
       if (!Object.hasOwn(this.form, 'file')) {
         this.$message.error('暂无文件')
         return
@@ -313,10 +315,9 @@ export default {
       window.open(routeUrl.href, '_blank')
     },
     initFileList(list) {
+      this.data.length = 0
       this.data = defaultData
-      if (list && list.length === 0) {
-        return
-      }
+      console.log(this.data)
       this.data = this.data.map(sub => {
         const tmp = list.filter(ele => ele.type === sub.dispatchType)
         if (tmp && tmp.length > 0) {
@@ -335,7 +336,7 @@ export default {
         type: 'warning'
       }).then(res => {
         if (res === 'confirm') {
-          this.$api.project.fileRemove({ ids: row.pid, type: 3 }).then(res => {
+          this.$api.project.delLinkFile({ ids: row.id }).then(res => {
             if (res.code === 200) {
               this.$message.success(res.msg)
               this.proInfo()
@@ -349,6 +350,23 @@ export default {
     clear() {
       this.currentRow = null
     },
+    onSuccess(list, command, extra) {
+      const tmps = list.map(e => {
+        return {
+          projectId: this.detail.id,
+          fileId: e.fileId,
+          pid: e.id,
+          type: extra.dispatchType
+        }
+      })
+      this.$api.project.linkFile(tmps).then(res => {
+        if (res.code === 200) {
+          this.proInfo()
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    },
     /**
      * 更新文号
      */

+ 62 - 39
src/views/store/component/info3.vue

@@ -16,32 +16,16 @@
         @on-load="onLoad"
       >
         <template #menu-left>
-          <div>
-            <el-dropdown @command="openFile">
-              <el-button type="primary">
-                上传附件
-                <el-icon class="el-icon--right">
-                  <arrow-down />
-                </el-icon>
-              </el-button>
-              <template #dropdown>
-                <el-dropdown-menu>
-                  <el-dropdown-item command="1"
-                    >备案证/可研批复
-                  </el-dropdown-item>
-                  <el-dropdown-item command="2">合同</el-dropdown-item>
-                  <el-dropdown-item command="3">工程量清单</el-dropdown-item>
-                  <el-dropdown-item command="4">现场照片</el-dropdown-item>
-                  <el-dropdown-item command="5"
-                    >项目核实认定表
-                  </el-dropdown-item>
-                  <el-dropdown-item command="6">其他资料</el-dropdown-item>
-                </el-dropdown-menu>
-              </template>
-            </el-dropdown>
-            <el-button type="primary" plain @click="exportFile"
-              >导 出</el-button
-            >
+          <div class="flex flex-center">
+            <filepicker
+              v-if="info"
+              :project-id="info.projectId"
+              :command="command"
+              @submit="onSuccess"
+            />
+            <el-button type="primary" class="ml-10" plain @click="exportFile"
+              >导 出
+            </el-button>
           </div>
         </template>
 
@@ -75,14 +59,6 @@
               @click="downLoad(row)"
               >下 载
             </el-button>
-            <el-button
-              icon="Download"
-              type="primary"
-              size="mini"
-              text
-              @click="openFolder(row)"
-              >打开文件夹
-            </el-button>
             <el-button
               icon="Delete"
               type="primary"
@@ -118,6 +94,8 @@ import { ElMessageBox } from 'element-plus'
 import subInfo from '@/views/store/component/subInfo1.vue'
 import subInfo2 from '@/views/store/component/subInfo2.vue'
 import subInfo3 from '@/views/store/component/subInfo3.vue'
+import filepicker from '@/components/filepicker/index.vue'
+
 export default {
   props: {
     info: {
@@ -125,7 +103,7 @@ export default {
       default: null
     }
   },
-  components: { subInfo, subInfo2, subInfo3 },
+  components: { subInfo, subInfo2, subInfo3, filepicker },
   data() {
     return {
       pid: '',
@@ -136,6 +114,32 @@ export default {
       preList: [],
       form: {},
       data: [],
+      command: [
+        {
+          label: '备案证/可研批复',
+          value: 1
+        },
+        {
+          label: '合同',
+          value: 2
+        },
+        {
+          label: '工程量清单',
+          value: 3
+        },
+        {
+          label: '现场照片',
+          value: 4
+        },
+        {
+          label: '项目核实认定表',
+          value: 5
+        },
+        {
+          label: '其他资料',
+          value: 6
+        }
+      ],
       page: {
         current: 1,
         size: 10
@@ -247,7 +251,11 @@ export default {
      * @param row
      */
     downLoad(row) {
-      window.open(row.url, '_blank')
+      console.log(row)
+      const link = document.createElement('a')
+      link.href = row.url
+      link.download = row.title
+      link.click()
     },
     /**
      * 文件预览
@@ -318,9 +326,7 @@ export default {
       }).then(res => {
         if (res === 'confirm') {
           const data = {
-            id: row.id,
-            projectId: row.projectId,
-            fileId: row.folderId
+            ids: row.id
           }
           this.$api.store.removeFile(data).then(res => {
             if (res.code === 200) {
@@ -352,6 +358,23 @@ export default {
             this.$message.error(res.msg)
           }
         })
+    },
+    onSuccess(list, expand) {
+      const tmps = list.map(e => {
+        return {
+          projectId: this.info.projectId,
+          fileId: e.id,
+          preId: this.pid,
+          type: expand.value
+        }
+      })
+      this.$api.store.linkFile(tmps).then(res => {
+        if (res.code === 200) {
+          this.refreshChange()
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
     }
   }
 }