scorpio 2 jaren geleden
bovenliggende
commit
8aba6fea79

+ 15 - 0
src/api/dispatch/index.js

@@ -32,5 +32,20 @@ export default {
       'post',
       'json'
     )
+  },
+  /**
+   * 项目调度,打包导出
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  exportFile(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/export',
+      params,
+      'get',
+      'form',
+      {},
+      'blob'
+    )
   }
 }

+ 6 - 0
src/layout/left.vue

@@ -93,9 +93,14 @@ export default {
           'data-type',
           item.children[0].remark ? item.children[0].remark : 'project'
         )
+        this.$bus.emit(
+          'navChange',
+          item.remark ? item.children[0].remark : 'project'
+        )
       } else {
         this.$router.push(item.path)
         localStorage.setItem('data-type', item.remark ? item.remark : 'project')
+        this.$bus.emit('navChange', item.remark ? item.remark : 'project')
       }
       const menu = { active: this.active, subActive: this.subActive }
       localStorage.setItem('index', JSON.stringify(menu))
@@ -106,6 +111,7 @@ export default {
       this.$router.push(item.path)
       const menu = { active: this.active, subActive: this.subActive }
       localStorage.setItem('index', JSON.stringify(menu))
+      this.$bus.emit('navChange', item.remark ? item.remark : 'project')
     }
   }
 }

+ 18 - 3
src/layout/top.vue

@@ -1,6 +1,13 @@
 <template>
   <div>
-    <el-row class="flex flex-align-center flex-justify-between top">
+    <el-row
+      class="flex flex-align-center flex-justify-between top"
+      :style="
+        dataType === 'project'
+          ? 'background-color:white'
+          : 'background-color:#fcf0f0'
+      "
+    >
       <el-col :span="12">
         <div class="flex flex-justify-start flex-align-center padding">
           <img class="ml-10" src="../assets/svg/top.svg" />
@@ -71,6 +78,7 @@ export default {
   },
   data() {
     return {
+      dataType: 'project',
       showImage: false,
       imgList: [],
       show: false,
@@ -106,7 +114,15 @@ export default {
       resultCount: 0
     }
   },
-  created() {},
+  created() {
+    const tmp = localStorage.getItem('data-type')
+    if (tmp) {
+      this.dataType = tmp
+    }
+    this.$bus.on('navChange', res => {
+      this.dataType = res
+    })
+  },
   methods: {
     dropDown(res) {
       if (res === 'info') {
@@ -241,7 +257,6 @@ export default {
 .top {
   height: 60px;
   z-index: 1;
-  background-color: white;
   top: 0;
   left: 200px;
   right: 0;

+ 2 - 2
src/page/login.vue

@@ -262,6 +262,8 @@ export default {
         this.code = res.image
         this.header = res.key
       })
+      const menu = { active: 0, subActive: 0 }
+      localStorage.setItem('index', JSON.stringify(menu))
     },
     submint() {
       this.$refs.loginForm.validate(res => {
@@ -370,8 +372,6 @@ export default {
                 clearInterval(this.time)
                 setToken(res.access_token)
                 this.getInfo()
-                const menu = { active: 0, subActive: 0 }
-                localStorage.setItem('index', JSON.stringify(menu))
                 this.$router.replace('/')
               }
             })

+ 138 - 27
src/views/home/component/dispatch.vue

@@ -9,7 +9,12 @@
         <div class="flex flex-center flex-justify-between mt-20">
           <span class="bold font-18 main-color">进度描述</span>
           <div class="flex flex-center">
-            <base-button type="0" title="批量导出" icon="upload" />
+            <base-button
+              type="0"
+              title="批量导出"
+              icon="upload"
+              @click="exportFile"
+            />
             <base-button
               class="ml-10"
               :title="btnTitle"
@@ -41,8 +46,8 @@
           :option="option"
           :table-loading="loading"
           class="curd"
+          :before-open="beforeOpen"
           @row-del="rowDel"
-          @on-load="onLoad"
         >
           <template #menu="{ row }">
             <el-button icon="Upload" type="primary" text @click="openFile(row)">
@@ -52,10 +57,24 @@
               text
               type="primary"
               icon="Download"
-              @click="projectReport(row)"
+              @click="fileDownload(row)"
               >下载
             </el-button>
           </template>
+          <template #menu-right>
+            <div class="full-width">
+              <el-button
+                icon="el-icon-refresh"
+                circle
+                @click="detail"
+              ></el-button>
+            </div>
+          </template>
+          <template #isuploaded="{ row }">
+            <div>
+              {{ row.isUploaded === 1 ? '已上传' : '' }}
+            </div>
+          </template>
         </avue-crud>
       </div>
       <!------现场图片------>
@@ -63,7 +82,16 @@
         <div class="flex flex-center flex-justify-between mt-20">
           <span class="bold font-18 main-color">施工现场图</span>
           <div class="flex flex-center">
-            <base-button type="0" title="上传" icon="upload" />
+            <base-button
+              type="0"
+              title="上传"
+              icon="upload"
+              @click="
+                openFile({
+                  dispatchType: 4
+                })
+              "
+            />
           </div>
         </div>
         <div class="mt-20">
@@ -132,11 +160,7 @@ export default {
       progress: '',
       info: null,
       loading: false,
-      srcList: [
-        'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
-        'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
-        'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg'
-      ],
+      srcList: [],
       data: [
         {
           fileName: '支付情况表',
@@ -177,11 +201,12 @@ export default {
           },
           {
             label: '上传状态',
-            prop: 'year'
+            prop: 'isUploaded',
+            slot: true
           },
           {
             label: '上传时间',
-            prop: 'year'
+            prop: 'createTime'
           }
         ]
       },
@@ -194,6 +219,21 @@ export default {
   },
   methods: {
     detail() {
+      this.data = [
+        {
+          fileName: '支付情况表',
+          dispatchType: 1
+        },
+        {
+          fileName: '工程完工月报表',
+          dispatchType: 2
+        },
+        {
+          fileName: '工程量清单',
+          dispatchType: 3
+        }
+      ]
+      this.srcList.length = 0
       const data = {
         projectId: this.projectId,
         year: this.year,
@@ -209,7 +249,18 @@ export default {
       })
       this.$api.dispatch.homeFile(data).then(res => {
         if (res.code === 200) {
-          console.log(res)
+          const tmp = res.data
+          this.data = this.data.map(sub => {
+            const item = tmp.find(ele => ele.type === sub.dispatchType)
+            if (item) {
+              sub = Object.assign(sub, item)
+            }
+            return sub
+          })
+          const img = tmp.find(ele => ele.type === 4)
+          if (img) {
+            this.srcList = img.fileFolders.map(ele => ele.url)
+          }
         } else {
           this.$message.error(res.msg)
         }
@@ -225,7 +276,8 @@ export default {
           projectId: this.projectId,
           year: this.year,
           month: this.month,
-          processDescribe: this.progress
+          processDescribe: this.progress,
+          id: this.info ? this.info.id : ''
         }
         this.$api.dispatch.saveOrUpdate(data).then(res => {
           if (res.code === 200) {
@@ -238,25 +290,49 @@ export default {
       }
       this.btnTitle = this.btnTitle === '编辑' ? '保存' : '编辑'
     },
+    beforeOpen(done, type) {
+      if (type === 'view') {
+        this.previewFile(this.form.fileIds)
+      } else if (type === 'edit') {
+        console.log(this.form)
+        this.$router.push({
+          path: '/home/files',
+          query: {
+            id: this.form.fileFolders[0].parentId,
+            projectId: this.projectId
+          }
+        })
+      } else {
+        done()
+      }
+    },
+    previewFile(id) {
+      if (id.length === 0) {
+        return
+      }
+      const routeData = this.$router.resolve({
+        path: '/home/file_detail',
+        query: { id }
+      })
+      window.open(routeData.href, '_blank')
+    },
     rowDel(row, index, done) {
       this.$confirm('确定将选择数据删除?', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
-      })
-        .then(() => {
-          return this.$api.inspect.remove({ ids: row.id })
-        })
-        .then(() => {
-          this.$message({
-            type: 'success',
-            message: '操作成功!'
+      }).then(() => {
+        this.$api.project
+          .fileRemove({ ids: row.fileIds, type: 2 })
+          .then(res => {
+            if (res.code === 200) {
+              this.$message.success(res.msg)
+              this.detail()
+            } else {
+              this.$message.error(res.msg)
+            }
           })
-          // 数据回调进行刷新
-          done(row)
-          this.onLoad()
-        })
-        .catch(() => {})
+      })
     },
     openFile(row) {
       const routeUrl = this.$router.resolve({
@@ -264,10 +340,45 @@ export default {
         query: {
           id: this.projectId,
           dispatchType: row.dispatchType,
-          type: 1
+          type: 2,
+          year: this.year,
+          month: this.month
         }
       })
       window.open(routeUrl.href, '_blank')
+    },
+    fileDownload(res) {
+      window.open(res.fileFolders[0].url)
+    },
+    exportFile() {
+      this.$message.success('开始下载,请稍后...')
+      const data = {
+        projectId: this.projectId,
+        year: this.year,
+        month: this.month
+      }
+      this.$api.dispatch.exportFile(data).then(res => {
+        if (Object.hasOwn(res, 'code')) {
+          this.$message.error(res.msg)
+          return
+        }
+        this.download(res)
+      })
+    },
+    download(res) {
+      const url = window.URL.createObjectURL(
+        new Blob([res], { type: 'application/octet-stream;charset=UTF-8' })
+      )
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const excelName = this.year + '年' + this.month + '月.zip'
+      link.setAttribute('download', excelName)
+      document.body.appendChild(link)
+      link.click()
+      link.remove()
+      this.diaType = -1
+      this.$message.success('导出成功')
     }
   }
 }

+ 15 - 2
src/views/home/component/folder_list.vue

@@ -252,6 +252,7 @@ export default {
   },
   data() {
     return {
+      dispatchParams: null,
       taskShow: false,
       show: false,
       updateShow: false,
@@ -285,7 +286,15 @@ export default {
       currentFolders: []
     }
   },
-  created() {},
+  created() {
+    const dispatchType = this.$route.query.dispatchType
+    if (dispatchType) {
+      this.dispatchParams = {
+        projectId: this.$route.query.id,
+        ...this.$route.query
+      }
+    }
+  },
   methods: {
     sendTask(item) {
       const index = this.currentFolders.findIndex(sub => sub.id === item.id)
@@ -383,7 +392,11 @@ export default {
       })
     },
     addFile() {
-      this.$api.project.fileAdd(this.fileList).then(res => {
+      let data = { files: this.fileList }
+      if (this.dispatchParams) {
+        data = Object.assign(data, this.dispatchParams)
+      }
+      this.$api.project.fileAdd(data).then(res => {
         if (res.code === 200) {
           this.show = false
           this.$bus.emit('reFolder')

+ 1 - 1
src/views/home/pro_detail.vue

@@ -68,7 +68,7 @@ import inspect1 from '@/views/home/component/inspect/Inspect1.vue'
 import dispatch from '@/views/home/component/dispatch.vue'
 
 export default {
-  name: 'pro_detail',
+  name: '项目详情',
   components: {
     BasicContainer,
     proLeft,