scorpio 2 years ago
parent
commit
f971eae668

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

@@ -173,19 +173,19 @@
 import BaseButton from '../../../components/base-button.vue'
 import permissionStore from '@/store/permission.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'
-import {useStore} from '@/store/user.js'
+import { useStore } from '@/store/user.js'
 
 export default {
   name: 'dash',
-  components: {BaseButton, formDialog, summaryDialog},
-  setup() {
+  components: { BaseButton, formDialog, summaryDialog },
+  setup () {
     const permissions = permissionStore()
     const user = useStore()
-    return {permissions, user}
+    return { permissions, user }
   },
-  data() {
+  data () {
     return {
       dialogLoading: false,
       disable: false,
@@ -329,7 +329,7 @@ export default {
       },
       rules: {
         name: [
-          {required: true, message: '请输入项目名称', trigger: 'blur'}
+          { required: true, message: '请输入项目名称', trigger: 'blur' }
         ],
         projectType: [
           {
@@ -354,7 +354,7 @@ export default {
       selectList: []
     }
   },
-  created() {
+  created () {
     const index = this.option.column.findIndex(sub => sub.prop === 'lot')
     console.log(index)
     if (this.user.info.viewStage === 1) {
@@ -374,18 +374,18 @@ export default {
     this.getTypeList()
     this.getNumList()
   },
-  unmounted() {
+  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
       console.log(query.projectStage)
       this.$api.project.projectList(this.page.currentPage, this.page.pageSize, data).then(res => {
@@ -402,32 +402,32 @@ export default {
         this.loading = false
       })
     },
-    selectionChange(list) {
+    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, projectStage: this.form.project_stage}
+          query: { id: this.form.id, projectStage: this.form.project_stage }
         })
       }
     },
-    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
@@ -437,24 +437,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(data) {
+    getNumList (data) {
       this.$api.project.userNunList(data).then(res => {
         if (res.code === 200) {
           this.numList = res.data.projectStage
@@ -462,17 +462,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
@@ -482,7 +482,7 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        const data = {id: res.id, is_report: 1}
+        const data = { id: res.id, is_report: 1 }
         this.$api.project.proUpdate(data).then(res => {
           if (res.code === 200) {
             this.onLoad()
@@ -493,7 +493,7 @@ export default {
         })
       })
     },
-    projectSave() {
+    projectSave () {
       if (this.disable) {
         this.$message.error('正在处理,请稍后...')
         return
@@ -517,12 +517,11 @@ export default {
         }
       })
     },
-    formDialogClose() {
+    formDialogClose () {
       this.diaType = -1
-      this.onLoad()
     },
-    exportExcel(res) {
-      const data = Object.assign(this.queryData, {columnName: res, projectIds: this.selectList.join(',')})
+    exportExcel (res) {
+      const data = Object.assign(this.queryData, { columnName: res, projectIds: this.selectList.join(',') })
       this.$api.params.exportResult(data).then(res => {
         if (res.hasOwnProperty('code')) {
           this.$message.error(res.msg)
@@ -531,8 +530,8 @@ export default {
         this.download(res)
       })
     },
-    exportExcelTotal(item) {
-      const data = {...this.queryData, projectIds: this.selectList.join(',')}
+    exportExcelTotal (item) {
+      const data = { ...this.queryData, projectIds: this.selectList.join(',') }
       this.$api.params.summaryExport(Object.assign(item, data)).then(res => {
         if (res.hasOwnProperty('code')) {
           this.$message.error(res.msg)
@@ -541,8 +540,8 @@ export default {
         this.download(res)
       })
     },
-    download(res) {
-      const url = window.URL.createObjectURL(new Blob([res], {type: 'application/vnd.ms-excel'}))
+    download (res) {
+      const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel' }))
       const link = document.createElement('a')
       link.style.display = 'none'
       link.href = url

+ 15 - 6
src/views/home/component/form_dialog.vue

@@ -151,12 +151,14 @@
             <el-button icon='el-icon-delete' class='ml-20' type='primary' plain @click='resetKey'>清 空</el-button>
           </div>
         </div>
-        <div class="flex flex-wrap" v-if='selectIndex !== -1' style="height: 300px;overflow-x: scroll">
-          <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
-               class="flex  padding pointer">
-            <el-checkbox v-model=item.checked :label="item.code" size="large" @change='change(selectIndex,index)'>
-              {{ item.dictValue }}
-            </el-checkbox>
+        <div style="height: 320px;overflow-x: scroll" v-if='selectIndex !== -1'>
+          <div class="flex flex-wrap "  >
+            <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
+                 class="pointer item" style='height: 30px'>
+              <el-checkbox v-model='item.checked' :label="item.code" size="large" @change='change(selectIndex,index)'>
+                {{ item.dictValue }}
+              </el-checkbox>
+            </div>
           </div>
         </div>
         <el-empty v-else description='点击上方按钮,选择字段'/>
@@ -515,6 +517,13 @@ export default {
   color: #D1A55F;
 }
 
+.item {
+  display: block;
+  border-radius: 3px;
+  padding: 4px 10px;
+  margin: 4px;
+}
+
 .box {
   width: 120px;
   height: 50px;

+ 13 - 12
src/views/home/component/summary_dialog.vue

@@ -50,7 +50,7 @@ import BaseButton from '@/components/base-button.vue'
 
 export default {
   name: 'summary_dialog',
-  components: {BaseButton},
+  components: { BaseButton },
   props: {
     dialogType: {
       type: String,
@@ -63,7 +63,7 @@ export default {
   },
   watch: {
     dialogType: {
-      handler(val) {
+      handler (val) {
         if (val === 2) {
           this.showSummary = true
           this.getDict('summary_field')
@@ -74,7 +74,7 @@ export default {
       immediate: true
     }
   },
-  data() {
+  data () {
     return {
       year: '',
       loading: false,
@@ -85,18 +85,19 @@ export default {
       yearList: []
     }
   },
-  created() {
+  created () {
     this.init()
   },
   methods: {
-    init() {
+    init () {
       const year = new Date().getFullYear()
-      for (let i = year - 10; i <= year; i++) {
-        this.yearList.push(i)
+      for (let i = 0; i <= year - 2018; i++) {
+        const res = Number.parseInt(year) - i
+        this.yearList.push(res)
       }
     },
-    getDict(code) {
-      this.$api.common.dicList({code}).then(res => {
+    getDict (code) {
+      this.$api.common.dicList({ code }).then(res => {
         if (res.code === 200) {
           this.fieldType = res.data.map(e => {
             e.checked = true
@@ -105,10 +106,10 @@ export default {
         }
       })
     },
-    close() {
+    close () {
       this.$emit('close')
     },
-    exportExcel() {
+    exportExcel () {
       const tmp = this.fieldType.filter(e => e.checked).map(sub => sub.dictKey)
       if (this.year.length === 0) {
         this.$message.error('请选择年份')
@@ -118,7 +119,7 @@ export default {
         this.$message.error('请选择要导出的字段')
         return
       }
-      const data = {columnName: tmp.join(','), year: this.year}
+      const data = { columnName: tmp.join(','), year: this.year }
       this.$emit('export', data)
     }
   }