scorpio 2 years ago
parent
commit
3d5e0ec5cc
3 changed files with 162 additions and 140 deletions
  1. 60 49
      src/views/home/component/dispatch.vue
  2. 75 71
      src/views/home/component/pro_left.vue
  3. 27 20
      src/views/home/pro_detail.vue

+ 60 - 49
src/views/home/component/dispatch.vue

@@ -1,22 +1,24 @@
 <template>
   <basic-container>
     <div class="flex flex-col padding-left" style="width: 95%">
-      <div class="text-left grey-6 font-18 bold">2023年1月项目进度信息填报</div>
+      <div class="text-left grey-6 font-18 bold">
+        {{ year }}年{{ month }}月项目进度信息填报
+      </div>
       <!------进度描述------>
       <div>
         <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 class="ml-10" title="编辑" icon="upload"/>
+            <base-button type="0" title="批量导出" icon="upload" />
+            <base-button class="ml-10" title="编辑" icon="upload" />
           </div>
         </div>
         <div class="mt-20">
           <el-input
-              v-model="progress"
-              :rows="10"
-              type="textarea"
-              placeholder="填写项目进度信息"
+            v-model="progress"
+            :rows="10"
+            type="textarea"
+            placeholder="填写项目进度信息"
           />
         </div>
       </div>
@@ -26,33 +28,27 @@
           <span class="bold font-18 main-color">相关文件</span>
         </div>
         <avue-crud
-            ref="crud"
-            v-model="form"
-            v-model:page="page"
-            :data="data"
-            :option="option"
-            :table-loading="loading"
-            class="curd"
-            @row-del="rowDel"
-            @on-load="onLoad"
+          ref="crud"
+          v-model="form"
+          v-model:page="page"
+          :data="data"
+          :option="option"
+          :table-loading="loading"
+          class="curd"
+          @row-del="rowDel"
+          @on-load="onLoad"
         >
           <template #menu="{ row }">
-            <el-button
-                icon="Upload"
-                type="primary"
-                text
-                @click="report(row)"
-            >
+            <el-button icon="Upload" type="primary" text @click="openFile(row)">
               上传
             </el-button>
             <el-button
-                text
-                type="primary"
-                icon="Download"
-                @click="projectReport(row)"
-            >下载
-            </el-button
-            >
+              text
+              type="primary"
+              icon="Download"
+              @click="projectReport(row)"
+              >下载
+            </el-button>
           </template>
         </avue-crud>
       </div>
@@ -61,13 +57,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" />
           </div>
         </div>
         <div class="mt-20">
           <el-carousel :interval="4000" type="card" height="200px">
-            <el-carousel-item v-for="item in 6" :key="item">
-            </el-carousel-item>
+            <el-carousel-item v-for="item in 6" :key="item"> </el-carousel-item>
           </el-carousel>
         </div>
       </div>
@@ -81,9 +76,20 @@ import baseButton from '@/components/base-button.vue'
 
 export default {
   name: 'dispatch',
-  components: {BasicContainer, baseButton},
+  components: { BasicContainer, baseButton },
+  props: {
+    year: {
+      type: Number,
+      default: 0
+    },
+    month: {
+      type: Number,
+      default: 0
+    }
+  },
   data() {
     return {
+      projectId: '',
       progress: '',
       loading: false,
       data: [
@@ -95,7 +101,7 @@ export default {
         },
         {
           fileName: '工程量清单'
-        },
+        }
       ],
       form: {},
       option: {
@@ -119,16 +125,16 @@ export default {
         column: [
           {
             label: '文件名称',
-            prop: 'fileName',
+            prop: 'fileName'
           },
           {
             label: '上传状态',
-            prop: 'year',
+            prop: 'year'
           },
           {
             label: '上传时间',
-            prop: 'year',
-          },
+            prop: 'year'
+          }
         ]
       },
       images: []
@@ -140,18 +146,23 @@ export default {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
-      }).then(() => {
-        return this.$api.inspect.remove({ids: row.id})
-      }).then(() => {
-        this.$message({
-          type: 'success',
-          message: '操作成功!'
-        })
-        // 数据回调进行刷新
-        done(row)
-        this.onLoad()
-      }).catch(() => {
       })
+        .then(() => {
+          return this.$api.inspect.remove({ ids: row.id })
+        })
+        .then(() => {
+          this.$message({
+            type: 'success',
+            message: '操作成功!'
+          })
+          // 数据回调进行刷新
+          done(row)
+          this.onLoad()
+        })
+        .catch(() => {})
+    },
+    openFile(row) {
+      console.log(row)
     }
   }
 }

+ 75 - 71
src/views/home/component/pro_left.vue

@@ -1,33 +1,33 @@
 <template>
   <div>
     <div
-        class="white-bg top full-height flex flex-col hide-scrollbar"
-        style="overflow-y: auto"
+      class="white-bg top full-height flex flex-col hide-scrollbar"
+      style="overflow-y: auto"
     >
       <div class="flex flex-col flex-center mt-15 padding">
         <span class="font-15 bold mb-10">{{ data.name }}</span>
         <span class="font-15 bold mt-5" style="color: #787c90"
-        >项目总投资额</span
+          >项目总投资额</span
         >
         <span class="mt-5 font-15 bold main-color"
-        >{{
+          >{{
             data.total_amount ? data.total_amount.toLocaleString() : '0'
           }}万元</span
         >
         <div class="flex flex-center mt-10">
           <!--          <span class="bold mr-15" style="color:#787C90;">{{ currentSituation.dictValue }}</span>-->
           <el-select
-              v-model="keyWords"
-              class="bold"
-              :placeholder="currentSituation.dictValue"
-              size="small"
-              @change="result"
+            v-model="keyWords"
+            class="bold"
+            :placeholder="currentSituation.dictValue"
+            size="small"
+            @change="result"
           >
             <el-option
-                v-for="item in dicList"
-                :key="item.dictKey"
-                :label="item.dictValue"
-                :value="item.dictKey"
+              v-for="item in dicList"
+              :key="item.dictKey"
+              :label="item.dictValue"
+              :value="item.dictKey"
             >
             </el-option>
           </el-select>
@@ -35,46 +35,48 @@
         <el-divider></el-divider>
         <div class="flex flex-center full-width">
           <span class="title pointer" @click="showRelation = !showRelation"
-          >已关联子项目<span class="bold blue font-16">{{ data.lot }}</span
-          >个</span
+            >已关联子项目<span class="bold blue font-16">{{ data.lot }}</span
+            >个</span
           >
         </div>
       </div>
       <div
-          class="flex flex-center flex-justify-between flex-col mt-15 hide-scrollbar"
-          style="height: 55vh; overflow-x: auto"
+        class="flex flex-center flex-justify-between flex-col mt-15 hide-scrollbar"
+        style="height: 55vh; overflow-x: auto"
       >
         <div v-if="dicList1 && dicList1.length > 0">
           <div
-              class="flex flex-center grey-9 font-15 bold pointer"
-              :class="active === index ? 'box-s' : 'box'"
-              v-for="(item, index) in dicList1"
-              :key="item.id"
-              @click="change(index)"
+            class="flex flex-center grey-9 font-15 bold pointer"
+            :class="active === index ? 'box-s' : 'box'"
+            v-for="(item, index) in dicList1"
+            :key="item.id"
+            @click="change(index)"
           >
             {{ item.dictValue }}
           </div>
         </div>
         <div v-else>
           <div>
-            <el-select v-model="year" placeholder="选择年份"
-                       clearable
-                       @change="yearSelect"
+            <el-select
+              v-model="year"
+              placeholder="选择年份"
+              clearable
+              @change="yearSelect"
             >
               <el-option
-                  v-for="item in years"
-                  :key="item.value"
-                  :label="item.value"
-                  :value="item.value"
+                v-for="item in years"
+                :key="item.value"
+                :label="item.value"
+                :value="item.value"
               />
             </el-select>
           </div>
           <div
-              class="flex flex-center grey-9 font-15 bold pointer mt-5"
-              :class="active === index ? 'box-s' : 'box'"
-              v-for="(item, index) in month"
-              :key="item"
-              @click="change(index)"
+            class="flex flex-center grey-9 font-15 bold pointer mt-5"
+            :class="active === index ? 'box-s' : 'box'"
+            v-for="(item, index) in month"
+            :key="item"
+            @click="change(index)"
           >
             {{ item.value }}
           </div>
@@ -82,10 +84,10 @@
       </div>
     </div>
     <pro-relation
-        :showRelation="showRelation"
-        :projectId="data.id"
-        @close="showRelation = false"
-        @success="updateLot"
+      :showRelation="showRelation"
+      :projectId="data.id"
+      @close="showRelation = false"
+      @success="updateLot"
     />
   </div>
 </template>
@@ -96,7 +98,7 @@ import month from '@/views/home/component/month.vue'
 
 export default {
   name: 'pro_left',
-  components: {proRelation, month},
+  components: { proRelation, month },
   props: {
     data: Object,
     code: {
@@ -116,7 +118,12 @@ export default {
     code: {
       handler(val) {
         if (val) {
-          this.getDic(val)
+          if (val !== 'project_dispatch') {
+            this.getDic(val)
+          } else {
+            this.dicList1.length = 0
+            this.initYear()
+          }
         }
       },
       immediate: false
@@ -124,6 +131,7 @@ export default {
   },
   data() {
     return {
+      keyWords: '',
       height: 0,
       dicList: [],
       dicList1: [],
@@ -181,32 +189,10 @@ export default {
         {
           value: '12月',
           index: 11
-        },
-      ],
-      year: '',
-      years: [
-        {
-          value: 2023
-        },
-        {
-          value: 2022
-        },
-        {
-          value: 2021
-        },
-        {
-          value: 2020
-        },
-        {
-          value: 2019
-        },
-        {
-          value: 2018
-        },
-        {
-          value: 2017
         }
       ],
+      year: '',
+      years: []
     }
   },
   created() {
@@ -215,11 +201,23 @@ export default {
     this.onScroll()
   },
   methods: {
-    get onScroll(event) {
+    initYear() {
+      this.years.length = 0
+      this.year = new Date().getFullYear()
+      for (let i = 2017; i <= this.year; i++) {
+        const item = { label: i, value: i }
+        this.years.push(item)
+      }
+      this.years.reverse()
+      if (this.dicList1 && this.dicList1.length === 0) {
+        this.active = new Date().getMonth()
+      }
+    },
+    onScroll() {
       this.$bus.on('scorll', e => {
         const scrollTop = e.target.scrollTop
         const index = this.scorllTopList.findIndex(
-            e => scrollTop >= e.start && scrollTop < e.end
+          e => scrollTop >= e.start && scrollTop < e.end
         )
         this.active = index
         if (e.target.scrollTop === 0) {
@@ -228,12 +226,12 @@ export default {
       })
     },
     getDic(code) {
-      this.$api.common.dicList({code}).then(res => {
+      this.$api.common.dicList({ code }).then(res => {
         if (res.code === 200) {
           if (code === 'project-situation') {
             this.dicList = res.data
             const local = this.dicList.filter(
-                e => e.dictKey === this.projectStage
+              e => e.dictKey === this.projectStage
             )
             if (local.length > 0) {
               this.currentSituation = local[0]
@@ -243,12 +241,13 @@ export default {
             this.resultList = this.dicList1
             this.$emit('success', this.resultList)
             this.scorllTopList = []
+            this.active = 0
             setTimeout(() => {
               for (let i = 0; i < this.resultList.length; i++) {
                 const start =
-                    i === 0 ? 0 : document.getElementById('header' + i).offsetTop
+                  i === 0 ? 0 : document.getElementById('header' + i).offsetTop
                 const end = document.getElementById(
-                    'header' + (i + 1)
+                  'header' + (i + 1)
                 ).offsetTop
                 const data = {
                   index: i,
@@ -269,7 +268,7 @@ export default {
       this.$emit('typeChange1')
     },
     result(item) {
-      const data = {id: this.data.id, project_stage: Number.parseInt(item)}
+      const data = { id: this.data.id, project_stage: Number.parseInt(item) }
       this.$api.project.proUpdate(data).then(res => {
         if (res.code === 200) {
           this.$message.success(res.msg)
@@ -289,6 +288,11 @@ export default {
     },
     yearSelect(res) {
       this.year = res
+      if (this.year !== new Date().getFullYear()) {
+        this.active = 0
+        this.change(0)
+      }
+      this.$emit('year', this.year)
     }
   }
 }

+ 27 - 20
src/views/home/pro_detail.vue

@@ -2,10 +2,11 @@
   <div class="flex flex-justify-start">
     <div class="full-height">
       <pro-left
-          :data="data"
-          :code="code"
-          @success="listSucc"
-          @change="changeIndex"
+        :data="data"
+        :code="code"
+        @success="listSucc"
+        @change="changeIndex"
+        @year="changeYear"
       />
     </div>
     <div style="margin-left: 300px" class="full-width" ref="content">
@@ -22,25 +23,25 @@
       <div v-if="currentTab.value === 1">
         <basic-container v-for="(item, index) in resultList" :key="item.id">
           <div class="full-width padding-top" :id="`header` + (index + 1)">
-            <params1 v-if="item.dictKey === '1'" :info="item" :detail="data"/>
-            <params2 v-if="item.dictKey === '2'" :info="item" :detail="data"/>
-            <params7 v-if="item.dictKey === '3'" :info="item" :detail="data"/>
-            <params4 v-if="item.dictKey === '4'" :info="item" :detail="data"/>
-            <params5 v-if="item.dictKey === '5'" :info="item" :detail="data"/>
-            <params6 v-if="item.dictKey === '6'" :info="item" :detail="data"/>
+            <params1 v-if="item.dictKey === '1'" :info="item" :detail="data" />
+            <params2 v-if="item.dictKey === '2'" :info="item" :detail="data" />
+            <params7 v-if="item.dictKey === '3'" :info="item" :detail="data" />
+            <params4 v-if="item.dictKey === '4'" :info="item" :detail="data" />
+            <params5 v-if="item.dictKey === '5'" :info="item" :detail="data" />
+            <params6 v-if="item.dictKey === '6'" :info="item" :detail="data" />
           </div>
         </basic-container>
       </div>
       <div v-else-if="currentTab.value === 2">
         <basic-container v-for="(item, index) in resultList" :key="item.id">
           <div class="full-width" :id="`header` + (index + 1)">
-            <inspect1 :info="item"/>
+            <inspect1 :info="item" />
           </div>
         </basic-container>
       </div>
       <div v-else-if="currentTab.value === 3">
         <div class="full-width">
-          <dispatch/>
+          <dispatch :year="year" :month="month" />
         </div>
       </div>
     </div>
@@ -86,15 +87,17 @@ export default {
       id: '',
       data: {},
       tabs: [
-        {name: '项目信息管理', value: 1, code: 'params_type'},
-        {name: '项目督查情况', value: 2, code: 'inspect_type'},
-        {name: '项目调度', value: 3, code: 'project_dispatch'}
+        { name: '项目信息管理', value: 1, code: 'params_type' },
+        { name: '项目督查情况', value: 2, code: 'inspect_type' },
+        { name: '项目调度', value: 3, code: 'project_dispatch' }
         // { name: '项目数据明细管理', value: 3 }
       ],
       currentTab: null,
       resultList: [],
       code: 'params_type',
-      url: ''
+      url: '',
+      year: new Date().getFullYear(),
+      month: new Date().getMonth() + 1
     }
   },
   created() {
@@ -115,6 +118,9 @@ export default {
     }, 1500)
   },
   methods: {
+    changeYear(year) {
+      this.year = year
+    },
     change(res, index) {
       this.currentTab = res
       this.code = this.currentTab.code
@@ -133,10 +139,11 @@ export default {
       this.resultList = list
     },
     changeIndex(index) {
-      // window.location.hash = '#header' + (index + 1)
-      document.getElementById('header' + (index + 1)).scrollIntoView()
-      // this.$nextTick(() => {
-      // })
+      if (this.code !== 'project_dispatch') {
+        document.getElementById('header' + (index + 1)).scrollIntoView()
+      } else {
+        this.month = index + 1
+      }
     }
   }
 }