scorpio před 2 roky
rodič
revize
9d6a5224cf

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

@@ -3,40 +3,60 @@
     <el-button type="primary" @click="show = true">文件上传</el-button>
     <el-dialog
       v-model="show"
-      width="900"
+      width="1200"
       :show-close="false"
       :close-on-click-modal="false"
+      @close="onClose"
     >
       <template #header>
         <div class="full-width flex flex-center flex-justify-between">
           <h4>选择文件</h4>
           <div class="flex flex-center flex-justify-end">
-            <span class="mr-20" style="width: 120px">项目阶段</span>
-            <el-select
-              v-model="stageId"
-              remote
-              filterable
-              clearable
-              placeholder="筛选项目阶段"
-              style="width: 100%"
-            >
-              <el-option
-                v-for="item in stageList"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
+            <div class="flex flex-center" v-show="activeName === '2'">
+              <span class="mr-10">项目阶段:</span>
+              <el-select
+                v-model="stageId"
+                remote
+                filterable
+                clearable
+                placeholder="筛选项目阶段"
+                style="width: 200px"
+                @change="stageChange"
               >
-              </el-option>
-            </el-select>
-            <upload-file class="ml-10" btn-text="本地上传" />
+                <el-option
+                  v-for="item in stageList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                >
+                </el-option>
+              </el-select>
+              <upload-file
+                class="ml-10"
+                btn-text="本地上传"
+                :max="9"
+                v-if="!topFolder"
+                :project-id="projectId"
+                :stage-id="stageId"
+                :parent-id="parentId"
+                @on-success="uploadSuccess"
+              />
+            </div>
+            <el-button
+              type="info"
+              class="ml-10"
+              circle
+              icon="Close"
+              @click="show = false"
+            >
+            </el-button>
           </div>
         </div>
       </template>
-      <div>
-        <div class="flex">
+      <div class="flex flex-justify-start flex-align-start flex-col">
+        <div class="full-width flex">
           <el-tabs
             v-model="activeName"
-            class="demo-tabs"
             tab-position="left"
             @tab-change="tabClick"
           >
@@ -46,13 +66,29 @@
             <el-tab-pane label="合同" name="4"></el-tab-pane>
           </el-tabs>
           <div class="area">
+            <div
+              v-if="activeName === '2'"
+              class="full-width flex flex-center flex-justify-start ml-20"
+            ></div>
             <div class="files">
-              <xtable :data="list" :option="option" />
+              <xtable
+                :data="list"
+                :option="option"
+                :loading="loading"
+                :total="page.total"
+                :max="max"
+                @selected="selected"
+                @row-click="rowClick"
+                @current-change="currentChange"
+              />
             </div>
           </div>
         </div>
-        <div class="full-width flex flex-center flex-justify-between mt-20">
-          <span class="bold">已选择 8/9 项</span>
+        <div
+          class="full-width flex flex-center flex-justify-between"
+          style="margin-top: 80px"
+        >
+          <span class="bold">已选择 {{ selectedList.length }}/9 项</span>
           <div>
             <el-button type="primary" plain @click="show = false"
               >取 消</el-button
@@ -77,6 +113,10 @@ export default {
     projectId: {
       type: String,
       default: ''
+    },
+    max: {
+      type: Number,
+      default: 9
     }
   },
   watch: {
@@ -88,17 +128,38 @@ export default {
         }
       },
       immediate: true
+    },
+    stageId: {
+      handler(val) {
+        if (this.activeName === '2') {
+          this.tabClick()
+        }
+      },
+      immediate: false
     }
   },
   data() {
     return {
       stageId: '',
+      parentId: '',
       stageList: [],
+      topFolder: true,
       show: false,
       activeName: '1',
       list: [],
+      selectedList: [],
+      isLatest: 0,
+      dictKey: '',
+      loading: false,
+      currentRow: null,
+      page: {
+        current: 1,
+        size: 10,
+        total: 0
+      },
       option: {
         showMenu: false,
+        showCheckBox: true,
         column: [
           {
             label: '名称',
@@ -106,20 +167,38 @@ export default {
             display: false
           },
           {
-            label: '上传人2',
+            label: '上传人',
             prop: 'createUserName'
           },
           {
             label: '上传时间',
-            prop: 'createUserName'
+            prop: 'createTime'
           }
         ]
       }
     }
   },
   methods: {
-    tabClick(res) {
-      console.log(this.activeName)
+    tabClick() {
+      this.list.length = 0
+      if (this.activeName === '1') {
+        this.isLatest = 0
+        this.dictKey = ''
+        this.fetchData()
+      } else if (this.activeName === '2') {
+        this.isLatest = 0
+        this.dictKey = ''
+        this.getFolderList()
+      } else if (this.activeName === '3') {
+        this.isLatest = ''
+        this.dictKey = 1
+        this.fetchData()
+      } else {
+        this.isLatest = this.activeName
+        this.isLatest = ''
+        this.dictKey = 2
+        this.fetchData()
+      }
     },
     getStage() {
       this.$api.project
@@ -127,21 +206,111 @@ export default {
         .then(res => {
           if (res.code === 200) {
             this.stageList = res.data
-            this.stageId = this.stageList[0].id
+            const tmp = this.stageList.find(ele => ele.isLastSelect === 1)
+            if (tmp) {
+              this.stageId = tmp.id
+            } else {
+              this.stageId = this.stageList[0].id
+            }
+            console.log(this.stageId)
           }
         })
     },
+    /**
+     * 获取全部文件
+     */
+    getFolderList() {
+      this.loading = true
+      const row = {
+        stageId: this.stageId,
+        dictKey: 1,
+        current: this.page.current,
+        size: this.page.size
+      }
+      this.$api.resource.folderList(row).then(res => {
+        this.loading = false
+        if (res.code === 200) {
+          this.list = res.data.records
+          this.page.total = res.data.total
+        }
+      })
+    },
+    /**
+     * 获取文件夹下面的文件及文件夹
+     * @param row
+     */
+    getFileList(row) {
+      console.log(row)
+      this.topFolder = false
+      const item = {
+        id: row.id,
+        current: this.page.current,
+        size: this.page.size
+      }
+      this.loading = true
+      this.$api.resource.fileList(item).then(res => {
+        this.loading = false
+        if (res.code === 200) {
+          this.list = res.data.records
+          this.page.total = res.data.total
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    },
+    /**
+     * 获取文件
+     */
     fetchData() {
       const data = {
         projectId: this.projectId,
-        stageId: this.stageId,
-        isLatest: 0
+        isLatest: this.isLatest,
+        dictKey: this.dictKey,
+        current: this.page.current,
+        size: this.page.size
       }
+      this.loading = true
       this.$api.resource.filePicker(data).then(res => {
+        this.loading = false
         if (res.code === 200) {
           this.list = res.data.records
+          this.page.total = res.data.total
         }
       })
+    },
+    selected(list) {
+      this.selectedList = list
+    },
+    rowClick(res) {
+      this.currentRow = res
+      const tmp = this.list.find(ele => ele.id === res.id)
+      this.parentId = tmp.id
+      if (tmp && tmp.type !== 2) {
+        tmp.checked = !tmp.checked
+      } else {
+        this.list.length = 0
+        this.getFileList(this.currentRow)
+      }
+    },
+    currentChange(current) {
+      this.page.current = current
+      this.tabClick()
+    },
+    uploadSuccess(res) {
+      this.getFileList(this.currentRow)
+    },
+    /**
+     * 阶段发生改变
+     */
+    stageChange() {
+      this.topFolder = true
+    },
+    onClose() {
+      this.page.current = 1
+      this.selectedList.length = 0
+      this.list.length = 0
+      this.activeName = '1'
+      this.parentId = ''
     }
   }
 }

+ 46 - 6
src/components/upload-file/index.vue

@@ -6,8 +6,9 @@
         v-model:file-list="fileList"
         :headers="headers"
         :data="data"
+        :limit="max"
         :accept="accept"
-        :multiple="multiple"
+        :multiple="max > 1"
         :on-success="success"
         :show-file-list="false"
       >
@@ -17,7 +18,9 @@
     <div class="upload" v-if="drawer">
       <div>
         <div class="full-width flex flex-justify-end">
-          <el-icon @click="drawer = false"><CircleClose /></el-icon>
+          <el-icon @click="drawer = false">
+            <CircleClose />
+          </el-icon>
         </div>
         <div class="mt-20 file-content">
           <div v-for="file in fileList" :key="file.name" class="mb-20">
@@ -50,14 +53,29 @@ export default {
       type: String,
       default: ''
     },
-    multiple: {
-      type: Boolean,
-      default: true
+    max: {
+      type: Number,
+      default: 9
     },
     data: Object,
     action: {
       type: String,
       default: api.uploadPath
+    },
+    projectId: {
+      type: String,
+      required: true,
+      default: ''
+    },
+    stageId: {
+      type: String,
+      required: true,
+      default: ''
+    },
+    parentId: {
+      type: String,
+      required: true,
+      default: ''
     }
   },
   watch: {
@@ -88,8 +106,29 @@ export default {
         this.resultList.push(res.data)
       }
       if (this.resultList.length === this.fileList.length) {
-        this.$emit('on-success', this.resultList)
+        this.drawer = false
+        this.saveFile()
       }
+    },
+    /**
+     * 保存文件
+     */
+    saveFile() {
+      const data = this.resultList.map(e => {
+        return {
+          fileId: e.id,
+          parentId: this.parentId,
+          projectId: this.projectId,
+          stageId: this.stageId
+        }
+      })
+      // fixme 重复文件未处理
+      this.$api.resource.fileSave(data).then(res => {
+        if (res.code === 200) {
+          this.$message.success('文件上传完成')
+          this.$emit('on-success', this.resultList)
+        }
+      })
     }
   }
 }
@@ -108,6 +147,7 @@ export default {
   box-shadow: -2px 2px 20px rgba(0, 0, 0, 0.1);
   padding: 20px;
 }
+
 .file-content {
   height: 280px;
   overflow-y: scroll;

+ 2 - 2
src/layout/left.vue

@@ -20,7 +20,7 @@
               :key="item.name"
             >
               <template #title>
-                <div class="flex flex-center flex-justify-start">
+                <div class="flex flex-center flex-justify-start pointer">
                   <img :src="item.source" style="width: 25px" class="mr-5" />
                   {{ item.name }}
                 </div>
@@ -32,7 +32,7 @@
                 :key="sub.name"
               >
                 <div
-                  class="item flex flex-center flex-justify-start"
+                  class="item flex flex-center flex-justify-start pointer"
                   style="margin-left: 20px"
                   :style="sub.checked ? 'color:#ECAB56' : ''"
                 >

+ 38 - 36
src/views/database/component/list.vue

@@ -9,28 +9,30 @@
       <!--      />-->
       <div class="flex flex-align-center tip mt-10">
         <el-icon class="ml-20" color="#ECAB56">
-          <WarningFilled/>
+          <WarningFilled />
         </el-icon>
         <span class="ml-5">共找到相关资料{{ page.total }}份</span>
       </div>
     </div>
     <div class="crud">
-      <avue-crud ref="crud"
-                 v-model="form"
-                 v-model:page="page"
-                 :before-open="beforeOpen"
-                 :data="data"
-                 :option="option"
-                 :table-loading="loading"
-                 @row-del="rowDel"
-                 @current-change="currentChange"
-                 @size-change="sizeChange"
-                 @refresh-change="refreshChange"
-                 @on-load="onLoad">
+      <avue-crud
+        ref="crud"
+        v-model="form"
+        v-model:page="page"
+        :before-open="beforeOpen"
+        :data="data"
+        :option="option"
+        :table-loading="loading"
+        @row-del="rowDel"
+        @current-change="currentChange"
+        @size-change="sizeChange"
+        @refresh-change="refreshChange"
+        @on-load="onLoad"
+      >
       </avue-crud>
     </div>
     <el-dialog v-model="showInfo" append-to-body width="45%">
-      <dialog-info :id="id"/>
+      <dialog-info :id="id" />
     </el-dialog>
   </div>
 </template>
@@ -40,7 +42,7 @@ import dialogInfo from './dialog_info.vue'
 
 export default {
   name: 'list',
-  components: {dialogInfo},
+  components: { dialogInfo },
   data() {
     return {
       showInfo: false,
@@ -61,17 +63,17 @@ export default {
         index: true,
         align: 'center',
         viewBtn: true,
-        menuWidth: 320,
         dialogClickModal: false,
         column: [
           {
             label: '文件名称',
             prop: 'title',
-            width: 380
+            width: 340
           },
           {
             label: '所属项目',
-            prop: 'projectName'
+            prop: 'projectName',
+            width: 240
           },
           {
             label: '文件格式',
@@ -83,8 +85,10 @@ export default {
           },
           {
             label: '上传时间',
-            prop: 'createTime'
-          }]
+            prop: 'createTime',
+            width: 200
+          }
+        ]
       },
       page: {
         current: 1,
@@ -95,7 +99,7 @@ export default {
     }
   },
   created() {
-    this.$bus.on('serachFile', (res) => {
+    this.$bus.on('serachFile', res => {
       this.onLoad(res)
     })
   },
@@ -103,7 +107,7 @@ export default {
     onLoad(query = {}) {
       this.page.current = this.page.currentPage
       this.page.size = this.page.pageSize
-      const data = {...query, ...this.page}
+      const data = { ...query, ...this.page }
       this.loading = true
       this.$api.database.fileList(data).then(res => {
         this.loading = false
@@ -130,7 +134,7 @@ export default {
       } else if (type === 'edit') {
         this.$router.push({
           path: '/home/details',
-          query: {id: this.form.id, type: '1'}
+          query: { id: this.form.id, type: '1' }
         })
       }
     },
@@ -139,17 +143,16 @@ export default {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
+      }).then(() => {
+        this.$api.database.fileRemove({ ids: row.id }).then(res => {
+          if (res.code === 200) {
+            this.$message.success(res.msg)
+            this.onLoad()
+          } else {
+            this.$message.error(res.msg)
+          }
+        })
       })
-          .then(() => {
-            this.$api.database.fileRemove({ids: row.id}).then(res => {
-              if (res.code === 200) {
-                this.$message.success(res.msg)
-                this.onLoad()
-              } else {
-                this.$message.error(res.msg)
-              }
-            })
-          })
     },
     choise(index) {
       this.active = index
@@ -168,11 +171,10 @@ export default {
 .tip {
   width: 260px;
   height: 32px;
-  background-color: #FBF6ED;
-  color: #ECAB56;
+  background-color: #fbf6ed;
+  color: #ecab56;
   font-weight: 500;
   flex-wrap: nowrap;
   margin-left: 20px;
 }
-
 </style>

+ 1 - 1
src/views/home/component/dash.vue

@@ -5,7 +5,7 @@
         <el-icon class="ml-20" color="#BC002D">
           <WarningFilled />
         </el-icon>
-        <span class="ml-5"
+        <span class="ml-5 font-16"
           >项目总投资额<span class="main-color bold">{{
             num ? Number.parseFloat(num).toLocaleString() : '0'
           }}</span

+ 33 - 4
src/views/resource/component/row1.vue

@@ -2,20 +2,27 @@
   <div class="row full-width">
     <div
       v-if="index === 0"
-      class="flex flex-align-center flex-justify-start full-height"
+      class="flex flex-align-center flex-justify-start full-height padding-left"
     >
+      <el-checkbox
+        v-if="showCheckBox"
+        v-model="info.checked"
+        :disabled="info.type === 2"
+        class="padding-right"
+        @change="rowChecked(row)"
+      />
       <img
-        v-if="row.type === 2"
+        v-if="info.type === 2"
         src="../../../assets/svg/folder/invisible.svg"
       />
       <img v-else src="../../../assets/svg/folder/pdf.svg" />
-      {{ row[column.prop] }}
+      {{ info[column.prop] }}
     </div>
     <div
       v-else
       class="flex flex-align-center flex-center full-height flex-child-average"
     >
-      {{ row[column.prop] }}
+      {{ info[column.prop] }}
     </div>
   </div>
 </template>
@@ -34,6 +41,28 @@ export default {
     index: {
       type: Number,
       default: 0
+    },
+    showCheckBox: {
+      type: Boolean,
+      default: false
+    }
+  },
+  watch: {
+    row: {
+      handler(val) {
+        this.info = val
+      },
+      immediate: true
+    }
+  },
+  data() {
+    return {
+      info: null
+    }
+  },
+  methods: {
+    rowChecked(res) {
+      this.$emit('row-change', res)
     }
   }
 }

+ 52 - 9
src/views/resource/component/xtable.vue

@@ -3,11 +3,11 @@
     <div class="flex flex-center flex-justify-between border-bottom">
       <div v-for="header in headers" :key="header.id" class="mt-20 full-width">
         <div
-          v-if="header.label === '操作' && showMenu"
+          v-if="header.label === '操作'"
           class="padding-top padding-bottom"
           style="width: 280px"
         >
-          {{ header.label }}{{ showMenu }}
+          {{ header.label }}
         </div>
         <div
           v-else
@@ -31,7 +31,7 @@
             class="flex-child-average flex"
           >
             <div
-              v-if="prop.label === '操作' && showMenu"
+              v-if="prop.label === '操作'"
               class="nowrap menu flex flex-center light-blue-bg"
               style="width: 280px"
             >
@@ -50,16 +50,25 @@
                   :row="row"
                   :column="prop"
                   :index="index"
+                  :show-check-box="showCheckBox"
                   @click="rowClick(row)"
                 ></row1>
               </div>
             </div>
           </div>
         </div>
+        <div class="full-width flex flex-center flex-justify-end">
+          <el-pagination
+            layout="prev, pager, next"
+            class="mt-10"
+            :total="total"
+            @current-change="currentChange"
+          />
+        </div>
       </div>
       <div v-else class="mt-20">
         <el-empty v-if="loading === false" description="暂无数据"></el-empty>
-        <el-skeleton v-else :rows="20" animated />
+        <el-skeleton v-else :rows="10" animated />
       </div>
     </div>
   </div>
@@ -75,6 +84,10 @@ export default {
     move
   },
   props: {
+    total: {
+      type: Number,
+      default: 0
+    },
     data: {
       type: Array,
       default: null
@@ -83,6 +96,10 @@ export default {
       type: Object,
       default: null
     },
+    max: {
+      type: Number,
+      default: 9
+    },
     loading: {
       type: Boolean,
       default: false
@@ -95,11 +112,17 @@ export default {
         const menu = {
           label: '操作'
         }
-        console.log(this.option.showMenu)
-        this.showMenu = this.option.showMenu
+        this.showMenu =
+          this.option.showMenu === undefined ? true : this.option.showMenu
+        this.showCheckBox =
+          this.option.showCheckBox === undefined
+            ? false
+            : this.option.showCheckBox
         this.headers = val.column
-        if (this.headers.findIndex(e => e.label === '操作') === -1) {
-          this.headers.push(menu)
+        if (this.showMenu) {
+          if (this.headers.findIndex(e => e.label === '操作') === -1) {
+            this.headers.push(menu)
+          }
         }
       },
       immediate: true
@@ -108,12 +131,32 @@ export default {
   data() {
     return {
       showMenu: true,
-      headers: []
+      showCheckBox: false,
+      headers: [],
+      selectedList: []
     }
   },
   methods: {
+    currentChange(current) {
+      this.$emit('current-change', current)
+    },
     rowClick(row) {
+      if (this.selectedList.length === this.max) {
+        this.$message.error('可选择文件数量最大为' + this.max)
+        return
+      }
       this.$emit('row-click', row)
+      if (row.checked) {
+        const tmps = this.data.filter(ele => ele.checked)
+        tmps.forEach(ele => {
+          if (this.selectedList.findIndex(sub => sub.id === ele.id) === -1) {
+            this.selectedList.push(ele)
+          }
+        })
+      } else {
+        this.selectedList = this.selectedList.filter(ele => ele.id !== row.id)
+      }
+      this.$emit('selected', this.selectedList)
     }
   }
 }

+ 8 - 15
src/views/resource/index.vue

@@ -227,7 +227,13 @@ export default {
         .then(res => {
           if (res.code === 200) {
             this.stage = res.data
-            this.folderInfo.stageId = this.stage[0].id
+
+            const tmp = this.stage.find(ele => ele.isLastSelect === 1)
+            if (tmp) {
+              this.folderInfo.stageId = tmp.id
+            } else {
+              this.folderInfo.stageId = this.stage[0].id
+            }
             this.getFolderList()
           }
         })
@@ -237,20 +243,7 @@ export default {
       this.getFolderList()
     },
     uploadSuccess(files) {
-      const data = files.map(e => {
-        const data = {
-          fileId: e.id,
-          parentId: this.folderInfo.id,
-          projectId: this.folderInfo.projectId,
-          stageId: this.folderInfo.stageId
-        }
-        return Object.assign(e, data)
-      })
-      this.$api.resource.fileSave(data).then(res => {
-        if (res.code === 200) {
-          console.log(res)
-        }
-      })
+      console.log('refresh')
     }
   }
 }