Jelajahi Sumber

履职任务管理日期条件

jiawuxian 2 tahun lalu
induk
melakukan
0f9765086b
3 mengubah file dengan 97 tambahan dan 37 penghapusan
  1. 64 0
      src/plugins/date.js
  2. 13 13
      src/plugins/index.js
  3. 20 24
      src/views/resumption/taskManager/index.vue

+ 64 - 0
src/plugins/date.js

@@ -0,0 +1,64 @@
+import Vue from "vue";
+import dayjs from "dayjs";
+
+// 默认中文
+require("dayjs/locale/zh-cn");
+dayjs.locale("zh-cn");
+
+Vue.prototype.$date = dayjs;
+Vue.filter("date", function(value) {
+    return value && dayjs(value).format("YYYY-MM-DD");
+});
+
+Vue.filter("dateTime", function(value, format = "YYYY-MM-DD HH:mm:ss") {
+    if ((value + "").length == 10) {
+        value *= 1000;
+    }
+    return value && dayjs(value).format(format);
+});
+const week = "周一、周二、周三、周四、周五、周六、周曰".split("、");
+Vue.filter("week", function(v) {
+    return week[v];
+});
+
+Vue.prototype.$dateRange = {
+    //
+    startToEnd: (unit) => {
+        const v = [
+            dayjs()
+                .startOf(unit)
+                .toDate(),
+            dayjs()
+                .endOf(unit)
+                .toDate()
+        ];
+        return v;
+    },
+
+    //
+    before: (days) => {
+        return [
+            dayjs()
+                .add(days, "day")
+                .startOf("d")
+                .toDate(),
+            dayjs()
+                .endOf("d")
+                .toDate()
+        ];
+    },
+
+    //
+    yesterday: (days) => {
+        return [
+            dayjs()
+                .add(days, "day")
+                .startOf("d")
+                .toDate(),
+            dayjs()
+                .add(days, "day")
+                .endOf("d")
+                .toDate()
+        ];
+    }
+};

+ 13 - 13
src/plugins/index.js

@@ -1,20 +1,20 @@
-import tab from './tab'
-import auth from './auth'
-import cache from './cache'
-import modal from './modal'
-import download from './download'
-
+import tab from "./tab";
+import auth from "./auth";
+import cache from "./cache";
+import modal from "./modal";
+import download from "./download";
+import "./date";
 export default {
   install(Vue) {
     // 页签操作
-    Vue.prototype.$tab = tab
+    Vue.prototype.$tab = tab;
     // 认证对象
-    Vue.prototype.$auth = auth
+    Vue.prototype.$auth = auth;
     // 缓存对象
-    Vue.prototype.$cache = cache
+    Vue.prototype.$cache = cache;
     // 模态框对象
-    Vue.prototype.$modal = modal
+    Vue.prototype.$modal = modal;
     // 下载文件
-    Vue.prototype.$download = download
-  }
-}
+    Vue.prototype.$download = download;
+  },
+};

+ 20 - 24
src/views/resumption/taskManager/index.vue

@@ -360,8 +360,8 @@
           >
             <template slot-scope="r">
               <span>
-                <i class="circle" :style="statusColor(r.row.status,true)" />
-                <label :style="statusColor(r.row.status,false)">
+                <i class="circle" :style="statusColor(r.row.status, true)" />
+                <label :style="statusColor(r.row.status, false)">
                   {{
                     getLabel(dict.type.resumption_status, r.row.status)
                   }}</label
@@ -383,13 +383,13 @@
               <el-button
                 type="text"
                 @click="showDetail(r.row)"
-                v-show="r.row.status != 2 || r.row.status != 3"
+                v-show="r.row.status == 2 || r.row.status == 3"
                 >查看</el-button
               >
               <el-button
                 type="text"
                 @click="showscanRecord(r.row)"
-                v-show="r.row.status != 2 || r.row.status != 3"
+                v-show="r.row.status == 2 || r.row.status == 3"
                 >扫描记录</el-button
               >
             </template>
@@ -753,29 +753,29 @@ export default {
       if (this.queryParams.executeCycle == 3) {
         if (!this.week) this.week = new Date();
 
-        let oneDayLong = 24 * 60 * 60 * 1000;
-        let c_day = this.week.getDay();
-        let monday = this.week - (c_day == 0 ? 6 : c_day - 1) * oneDayLong;
-        let sunday = this.week + (c_day == 0 ? 0 : 7 - c_day) * oneDayLong;
-
-        this.weekStart = `${monday.getYear()}-${monday.getMonth()}-${monday.getDate()}`;
-        this.weekEnd = `${sunday.getYear()}-${sunday.getMonth()}-${sunday.getDate()}`;
-        // this.weekChanged();
+        this.updateWeekDateRange(this.week);
       }
       this.resetRangeParam();
       this.loadPlanList();
       this.loadRoles();
     },
-
     weekChanged() {
-      var date = this.$moment(this.week).isoWeekday(1);
-      this.weekStart = date.weekday(1).format("YYYY-MM-DD");
-      this.weekEnd = date.weekday(7).format("YYYY-MM-DD");
+      this.updateWeekDateRange(this.week);
       this.resetRangeParam();
     },
     monthChanged() {
       this.resetRangeParam();
     },
+    updateWeekDateRange(week) {
+      let oneDayLong = 24 * 60 * 60 * 1000;
+      let c_day = week.getDay();
+      this.weekStart = new Date(
+        week.valueOf() - (c_day == 0 ? 6 : c_day - 1) * oneDayLong
+      );
+      this.weekEnd = new Date(
+        week.valueOf() + (c_day == 0 ? 0 : 7 - c_day) * oneDayLong
+      );
+    },
     async resetRangeParam() {
       if (this.queryParams.executeCycle == 5) {
         let yearSval = this.yearS.getFullYear();
@@ -959,10 +959,7 @@ export default {
           this.queryParams.range = [new Date(sMDate), new Date(eMData)];
         }
       } else if (this.queryParams.executeCycle == 3) {
-        this.queryParams.range = [
-          new Date(this.weekStart),
-          new Date(this.weekEnd),
-        ];
+        this.queryParams.range = [this.weekStart, this.weekEnd];
       } else if (
         this.queryParams.executeCycle === 1 ||
         this.queryParams.executeCycle == 2
@@ -970,7 +967,7 @@ export default {
         this.queryParams.range = this.$dateRange.before(0);
       }
     },
-    statusColor(status,isBackground) {
+    statusColor(status, isBackground) {
       let color = "";
       switch (status) {
         case "1":
@@ -987,12 +984,11 @@ export default {
           break;
       }
 
-      if(isBackground){
+      if (isBackground) {
         return "background-color:" + color;
-      }else{
+      } else {
         return "color:" + color;
       }
-      
     },
   },
   async mounted() {