scorpioyq 2 år sedan
förälder
incheckning
4e7f0c942a
2 ändrade filer med 224 tillägg och 41 borttagningar
  1. 45 41
      src/views/home/component/dash.vue
  2. 179 0
      src/views/home/component/summary_dialog.vue

+ 45 - 41
src/views/home/component/dash.vue

@@ -24,6 +24,8 @@
                      @click="diaType = 0"/>
         <base-button class="ml-20 mt-20" icon="el-icon-download" title="数据导出"
                      @click="diaType = 1"/>
+        <base-button class="ml-20 mt-20" type="0" icon="el-icon-download" title="汇总数据导出"
+                     @click="diaType = 2"/>
       </div>
     </div>
     <avue-crud ref="crud"
@@ -121,24 +123,26 @@
       </div>
     </el-dialog>
     <form-dialog :dialogType="diaType" @close="diaType = -1" @export='exportExcel'/>
+    <summary-dialog :dialogType="diaType" @close="diaType = -1"/>
   </div>
 </template>
 
 <script>
 import BaseButton from '../../../components/base-button.vue'
 import permissionStore from '@/store/permission.js'
-import { vaildData } from '@/utils/tools.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 },
-  setup () {
+  components: {BaseButton, formDialog, summaryDialog},
+  setup() {
     const permissions = permissionStore()
-    return { permissions }
+    return {permissions}
   },
-  data () {
+  data() {
     return {
       disable: false,
       showAdd: false,
@@ -249,7 +253,7 @@ export default {
       },
       rules: {
         name: [
-          { required: true, message: '请输入项目名称', trigger: 'blur' }
+          {required: true, message: '请输入项目名称', trigger: 'blur'}
         ],
         projectType: [
           {
@@ -271,7 +275,7 @@ export default {
       queryData: null
     }
   },
-  created () {
+  created() {
     this.getTypeList()
     this.getNumList()
     this.$bus.on('serach', (res) => {
@@ -282,20 +286,20 @@ export default {
     })
   },
   computed: {
-    permissionList () {
+    permissionList() {
       return {
         delBtn: vaildData(this.permissions.permissions.home_del, false)
       }
     }
   },
   methods: {
-    switchTab (item, index) {
+    switchTab(item, index) {
       this.active = index
-      this.onLoad({ projectStage: item.dictKey })
+      this.onLoad({projectStage: item.dictKey})
     },
-    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
@@ -310,11 +314,11 @@ export default {
         this.loading = false
       })
     },
-    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.$alert('功能建设中,尽情期待...', '消息提醒', {
@@ -322,20 +326,20 @@ export default {
         // })
         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
@@ -345,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
@@ -370,7 +374,7 @@ export default {
         }
       })
     },
-    getTotalAmount (data) {
+    getTotalAmount(data) {
       this.$api.project.totalAmount(Object.assign(data, this.query)).then(res => {
         if (res.code === 200) {
           this.num = res.data
@@ -379,17 +383,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
@@ -399,7 +403,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)
@@ -410,7 +414,7 @@ export default {
         })
       })
     },
-    projectSave () {
+    projectSave() {
       if (this.disable) {
         this.$message.error('正在处理,请稍后...')
         return
@@ -434,10 +438,10 @@ export default {
         }
       })
     },
-    exportExcel (res) {
-      const data = Object.assign(this.queryData, { columnName: res })
+    exportExcel(res) {
+      const data = Object.assign(this.queryData, {columnName: res})
       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 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

+ 179 - 0
src/views/home/component/summary_dialog.vue

@@ -0,0 +1,179 @@
+<template>
+  <div>
+    <!--    汇总数据导出-->
+    <el-dialog v-model='showSummary'
+               append-to-body
+               center
+               @close="close"
+               title="汇总数据导出"
+               width="45%">
+      <div class="flex flex-col flex-center">
+        <span
+            class="bold mb-10">共找到符合条件的项目 <span class="blue font-15">8</span> 个,请选择下面的字段信息,系统将对已选项自动进行汇总累加</span>
+        <el-select
+            v-model="keyWords"
+            clearable
+            placeholder="年份筛选"
+            prefix-icon="Search"
+        />
+      </div>
+      <div class="hide-scrollbar full-width mt-15" style="height: 20vh;overflow-x: scroll">
+        <!--        <div v-if='attaches.length === 0' class='full-width flex flex-center '>-->
+        <!--          <el-empty image-size='100'/>-->
+        <!--        </div>-->
+        <div class="flex flex-justify-between flex-center">
+          <span class="bold font-15 grey ml-5 ">字段选择</span>
+        </div>
+        <div class="flex flex-wrap" v-if='selectIndex !== -1'>
+          <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
+               class="flex flex-center padding pointer">
+            <el-checkbox v-model=item.checked :label="item.code" size="large" @change='change(selectIndex,index)'>
+              {{ item.dictValue }}
+            </el-checkbox>
+          </div>
+        </div>
+      </div>
+      <div class="flex flex-center mt-20 mb-5">
+        <base-button title="重置" type="0" icon="Refresh"/>
+        <base-button class="ml-15" title="导出表格" icon="el-icon-download" @click='exportExcel'/>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import BaseButton from "@/components/base-button.vue";
+import uploads from "@/components/uploads.vue";
+
+export default {
+  name: "summary_dialog",
+  components: {BaseButton, uploads},
+  props: {
+    dialogType: {
+      type: String,
+      default: -1
+    }
+  },
+  watch: {
+    dialogType: {
+      handler(val) {
+        if (val === 2) {
+          this.showSummary = true
+          this.getDict('params_type')
+        }
+      },
+      immediate: true
+    }
+  },
+  data() {
+    return {
+      loading: false,
+      active: 0,
+      checked: true,
+      showSummary: false,
+      showExport: false,
+      attaches: [],
+      keyWords: '',
+      code: '',
+      fieldType: [],
+      paramsList: [],
+      checkList: [],
+      selectIndex: -1,
+      resultParams: []
+    }
+  },
+
+  methods: {
+    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 = []
+            return e
+          })
+        }
+      })
+    },
+    close() {
+      this.$emit('close')
+    },
+    upload(res) {
+      console.log(res)
+      this.attaches = res.fileList
+      this.$message.success('操作成功')
+      this.showImport = false
+    },
+    before(files) {
+      console.log(files)
+      this.attaches = files
+    },
+    removeFile(item) {
+      this.attaches = this.attaches.filter(sub => sub.uid !== item.uid)
+    },
+    switchTab(item, index) {
+      this.fieldType[index].isSelect = !this.fieldType[index].isSelect
+      this.selectIndex = index
+      if (this.fieldType[index].params === undefined) {
+        this.$api.params.getListByKey({type: this.fieldType[index].dictKey}).then(res => {
+          if (res.code === 200) {
+            this.fieldType[index].params = res.data.records.map(e => {
+              e.checked = true
+              return e
+            })
+            this.fieldType[index].count = res.data.total
+          }
+        })
+      }
+    },
+    importExcel() {
+      this.$refs.upload.submit()
+    },
+    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 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('未选择任何字段进行导出')
+      }
+    }
+  }
+}
+
+
+</script>
+
+<style lang="scss" scoped>
+.pic {
+  width: 196px;
+  height: 154px;
+  margin-top: -20px;
+}
+
+.box-s {
+  border: 1px solid #AC9A7C;
+  width: 120px;
+  height: 50px;
+  color: #D1A55F;
+}
+
+.box {
+  width: 120px;
+  height: 50px;
+  border: 1px solid transparent;
+  background: #F1F2F7;
+  color: #707070;
+}
+</style>