Browse Source

merge fix

scorpio 2 years ago
parent
commit
9fac0d8c30

+ 84 - 61
src/views/home/component/dash.vue

@@ -123,28 +123,29 @@
         </el-form>
       </div>
     </el-dialog>
-    <form-dialog :dialogType="diaType" @close="formDialogClose" @export='exportExcel'/>
-    <summary-dialog :dialogType="diaType" :selectNum="selectNum" @close="diaType = -1"/>
+    <form-dialog :dialogType="diaType" @close="formDialogClose" @export='exportExcel' :ids='selectList'/>
+    <summary-dialog :dialogType="diaType" @close="diaType = -1" :select-num='selectList.length'
+                    @export='exportExcelTotal'/>
   </div>
 </template>
 
 <script>
 import BaseButton from '../../../components/base-button.vue'
 import permissionStore from '@/store/permission.js'
-import {vaildData} from '@/utils/tools.js'
 import formDialog from '@/views/home/component/form_dialog.vue'
-import {getLazyList} from '@/api/project/index.js'
+import { getLazyList } from '@/api/project/index.js'
 import summaryDialog from '@/views/home/component/summary_dialog.vue'
 
 export default {
   name: 'dash',
-  components: {BaseButton, formDialog, summaryDialog},
-  setup() {
+  components: { BaseButton, formDialog, summaryDialog },
+  setup () {
     const permissions = permissionStore()
-    return {permissions}
+    return { permissions }
   },
-  data() {
+  data () {
     return {
+      dialogLoading: false,
       disable: false,
       showAdd: false,
       active: 0,
@@ -166,6 +167,7 @@ export default {
         delBtn: true,
         border: true,
         index: true,
+        reserveSelection: true,
         align: 'center',
         viewBtn: true,
         viewBtnText: '详情',
@@ -249,7 +251,7 @@ export default {
       },
       rules: {
         name: [
-          {required: true, message: '请输入项目名称', trigger: 'blur'}
+          { required: true, message: '请输入项目名称', trigger: 'blur' }
         ],
         projectType: [
           {
@@ -271,10 +273,10 @@ export default {
       queryData: null,
       owerQuery: {},
       projectStageQuery: {},
-      selectNum: ''
+      selectList: []
     }
   },
-  created() {
+  created () {
     this.getNumList()
     this.$bus.on('serach', (res, type) => {
       this.owerQuery = res
@@ -285,28 +287,25 @@ export default {
       this.onLoad(Object.assign(this.owerQuery, this.projectStageQuery))
     })
   },
-  computed: {
-    permissionList() {
-      return {
-        delBtn: vaildData(this.permissions.permissions.home_del, false)
-      }
-    }
+  unmounted () {
+    sessionStorage.removeItem('selectList')
   },
   methods: {
-    switchTab(item, index) {
+    switchTab (item, index) {
       this.active = index
-      this.projectStageQuery = {projectStage: item.dictKey}
+      this.projectStageQuery = { projectStage: item.dictKey }
       this.onLoad(Object.assign(this.owerQuery, this.projectStageQuery))
     },
-    onLoad(query = {}) {
+    onLoad (query = {}) {
       this.loading = true
-      const data = {...query, parentId: this.parentId}
+      const data = { ...query, parentId: this.parentId }
       this.queryData = data
       this.$api.project.projectList(this.page.currentPage, this.page.pageSize, data).then(res => {
         this.loading = false
         if (res.code === 200) {
           this.data = res.data.records.map(e => {
             e.projectStage = e.projectStage + ''
+            e.selected = true
             return e
           })
           this.page.total = res.data.total
@@ -315,32 +314,32 @@ export default {
         this.loading = false
       })
     },
-    selectionChange(list) {
-      this.selectNum = list.length
+    selectionChange (list) {
+      this.selectList = list.map(sub => sub.id)
     },
-    beforeOpen(done, type) {
+    beforeOpen (done, type) {
       if (['edit'].includes(type)) {
         this.$router.push({
           path: '/home/details',
-          query: {id: this.form.id, type: '0', ownerId: this.form.createUser}
+          query: { id: this.form.id, type: '0', ownerId: this.form.createUser }
         })
       } else if (type === 'view') {
         this.$router.push({
           path: '/home/pro_detail',
-          query: {id: this.form.id}
+          query: { id: this.form.id }
         })
       }
     },
-    currentChange(currentPage) {
+    currentChange (currentPage) {
       this.page.current = currentPage
     },
-    sizeChange(pageSize) {
+    sizeChange (pageSize) {
       this.page.size = pageSize
     },
-    refreshChange() {
+    refreshChange () {
       this.onLoad()
     },
-    treeLoad(tree, treeNode, resolve) {
+    treeLoad (tree, treeNode, resolve) {
       this.loading = true
       getLazyList(tree.id).then(res => {
         this.loading = false
@@ -350,24 +349,24 @@ export default {
         }))
       })
     },
-    rowDel(row) {
+    rowDel (row) {
       this.$confirm('确定删除选择的项目?', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
       })
-          .then(() => {
-            this.$api.project.projectRemove({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.project.projectRemove({ ids: row.id }).then(res => {
+            if (res.code === 200) {
+              this.$message.success(res.msg)
+              this.onLoad()
+            } else {
+              this.$message.error(res.msg)
+            }
           })
+        })
     },
-    getNumList() {
+    getNumList () {
       this.$api.project.userNunList().then(res => {
         if (res.code === 200) {
           this.numList = res.data.projectStage
@@ -375,17 +374,17 @@ export default {
         }
       })
     },
-    getTypeList() {
-      this.$api.project.typeList({type: 1, size: 999, current: 1}).then(res => {
+    getTypeList () {
+      this.$api.project.typeList({ type: 1, size: 999, current: 1 }).then(res => {
         this.typeList = res.data.records
       })
-      this.$api.common.dicList({code: 'project-tags'}).then(res => {
+      this.$api.common.dicList({ code: 'project-tags' }).then(res => {
         if (res.code === 200) {
           this.tagsList = res.data
         }
       })
     },
-    track(res) {
+    track (res) {
       if (res.isReport === 1) {
         this.$message.error('该项目已经上报')
         return
@@ -395,7 +394,7 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        const data = {id: res.id, isReport: 1}
+        const data = { id: res.id, isReport: 1 }
         this.$api.project.proUpdate(data).then(res => {
           if (res.code === 200) {
             console.log(res)
@@ -406,7 +405,7 @@ export default {
         })
       })
     },
-    projectSave() {
+    projectSave () {
       if (this.disable) {
         this.$message.error('正在处理,请稍后...')
         return
@@ -430,24 +429,48 @@ export default {
         }
       })
     },
-    formDialogClose() {
+    formDialogClose () {
       this.diaType = -1
       this.onLoad()
     },
-    exportExcel(res) {
-      const data = Object.assign(this.queryData, {columnName: res})
+    exportExcel (res) {
+      const data = Object.assign(this.queryData, { columnName: res, projectIds: this.selectList.join(',') })
       this.$api.params.exportResult(data).then(res => {
-        const url = window.URL.createObjectURL(new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'}))
-        const link = document.createElement('a')
-        link.style.display = 'none'
-        link.href = url
-        const excelName = new Date().getTime() + '.xlsx'
-        link.setAttribute('download', excelName)
-        document.body.appendChild(link)
-        link.click()
-        link.remove()
-        this.diaType = -1
-        this.$message.success('导出成功')
+        if (res.code === 200) {
+          const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' }))
+          const link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          const excelName = new Date().getTime() + '.xlsx'
+          link.setAttribute('download', excelName)
+          document.body.appendChild(link)
+          link.click()
+          link.remove()
+          this.diaType = -1
+          this.$message.success('导出成功')
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    },
+    exportExcelTotal (item) {
+      const data = { projectIds: this.selectList.join(',') }
+      this.$api.params.summaryExport(Object.assign(item, data)).then(res => {
+        if (res.code === 200) {
+          const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' }))
+          const link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          const excelName = new Date().getTime() + '.xlsx'
+          link.setAttribute('download', excelName)
+          document.body.appendChild(link)
+          link.click()
+          link.remove()
+          this.diaType = -1
+          this.$message.success('导出成功')
+        } else {
+          this.$message.error(res.msg)
+        }
       })
     }
   }

+ 1 - 0
src/views/home/component/form_dialog.vue

@@ -126,6 +126,7 @@ export default {
         } else {
           this.showExport = false
           this.showImport = false
+          this.loading = false
         }
       },
       immediate: true

+ 44 - 34
src/views/home/component/summary_dialog.vue

@@ -11,11 +11,18 @@
         <span
             class="bold mb-10">共找到符合条件的项目 <span class="blue font-15">{{ selectNum }}</span> 个,请选择下面的字段信息,系统将对已选项自动进行汇总累加</span>
         <el-select
-            v-model="keyWords"
+            v-model="year"
             clearable
             placeholder="年份筛选"
             prefix-icon="Search"
-        />
+        >
+          <el-option
+              v-for="item in yearList"
+              :key="item"
+              :label="item"
+              :value="item"
+          />
+        </el-select>
       </div>
       <div class="hide-scrollbar full-width mt-15" style="height: 20vh;overflow-x: scroll">
         <div class="flex flex-justify-between flex-center">
@@ -24,7 +31,7 @@
         <div class="flex flex-wrap">
           <div v-for="(item,index) in fieldType" :key='item.id'
                class="flex flex-center padding pointer">
-            <el-checkbox v-model=item.checked :label="item.code" size="large" @change='change(index)'>
+            <el-checkbox v-model=item.checked :label="item.code" size="large">
               {{ item.dictValue }}
             </el-checkbox>
           </div>
@@ -39,22 +46,24 @@
 </template>
 
 <script>
-import BaseButton from "@/components/base-button.vue";
-import uploads from "@/components/uploads.vue";
+import BaseButton from '@/components/base-button.vue'
 
 export default {
-  name: "summary_dialog",
-  components: {BaseButton, uploads},
+  name: 'summary_dialog',
+  components: { BaseButton },
   props: {
     dialogType: {
       type: String,
       default: -1
     },
-    selectNum: ''
+    selectNum: {
+      type: Number,
+      default: 0
+    }
   },
   watch: {
     dialogType: {
-      handler(val) {
+      handler (val) {
         if (val === 2) {
           this.showSummary = true
           this.getDict('summary_field')
@@ -63,55 +72,56 @@ export default {
       immediate: true
     }
   },
-  data() {
+  data () {
     return {
+      year: '',
       loading: false,
       checked: true,
       showSummary: false,
       code: '',
       fieldType: [],
+      yearList: []
     }
   },
-
+  created () {
+    this.init()
+  },
   methods: {
-    getDict(code) {
-      this.$api.common.dicList({code}).then(res => {
+    init () {
+      const year = new Date().getFullYear()
+      for (let i = year - 10; i <= year; i++) {
+        this.yearList.push(i)
+      }
+    },
+    getDict (code) {
+      this.$api.common.dicList({ code }).then(res => {
         if (res.code === 200) {
           this.fieldType = res.data.map(e => {
-            e.isSelect = false
-            e.count = 0
-            e.parmas = []
+            e.checked = false
             return e
           })
         }
       })
     },
-    close() {
+    close () {
       this.$emit('close')
     },
-    change(parentIndex, index) {
-      const tmp = this.fieldType[parentIndex].params.filter(e => e.checked)
-      this.fieldType[parentIndex].count = tmp.length
-      for (let i = 0; i < tmp.length; i++) {
-        console.log(tmp[i])
-        this.resultParams.push(tmp[i])
+    exportExcel () {
+      const tmp = this.fieldType.filter(e => e.checked).map(sub => sub.dictKey)
+      if (this.year.length === 0) {
+        this.$message.error('请选择年份')
+        return
       }
-    },
-    exportExcel() {
-      const params = this.fieldType.filter(sub => sub.params).map(sub => sub.params)
-      const tmps = [].concat.apply([], params)
-      const tmpsList = tmps.filter(sub => sub.checked)
-      if (tmpsList && tmpsList.length > 0) {
-        const result = tmpsList.map(sub => sub.code).join(',')
-        this.$emit('export', result)
-      } else {
-        this.$message.error('未选择任何字段进行导出')
+      if (tmp.length === 0) {
+        this.$message.error('请选择要导出的字段')
+        return
       }
+      const data = { dictKey: tmp.join(','), year: this.year }
+      this.$emit('export', data)
     }
   }
 }
 
-
 </script>
 
 <style lang="scss" scoped>