浏览代码

'自定义日期'

zhangyu 4 年之前
父节点
当前提交
b79aacceb1
共有 1 个文件被更改,包括 63 次插入30 次删除
  1. 63 30
      src/views/equipmentFacilities/OtherMatters.vue

+ 63 - 30
src/views/equipmentFacilities/OtherMatters.vue

@@ -76,9 +76,8 @@
         <div class="sbss">
           <h1 class="title">处理日期</h1>
           <div class="system-btn-container">
-            <div class="system-btn" v-for="(item, index) in fillinList" :key="index">
-              <van-button class="m-btn" :class="item.active" @click="changeFillinDate(item)">{{ item.text }}
-              </van-button>
+            <div class="system-btn" :class="item.text === '自定义'?'self-btn':''" v-for="(item, index) in fillinList" :key="index">
+              <van-button class="m-btn" :class="item.active" @click="changeFillinDate(item)">{{ item.text }}</van-button>
             </div>
           </div>
         </div>
@@ -87,9 +86,8 @@
         <div class="sbss">
           <h1 class="title">记录日期</h1>
           <div class="system-btn-container">
-            <div class="system-btn" v-for="(item, index) in acceptanceList" :key="index">
-              <van-button class="m-btn" :class="item.active" @click="changeAcceptanceDate(item)">{{ item.text }}
-              </van-button>
+            <div class="system-btn" :class="item.text === '自定义'?'self-btn':''" v-for="(item, index) in acceptanceList" :key="index">
+              <van-button class="m-btn" :class="item.active" @click="changeAcceptanceDate(item)">{{ item.text }}</van-button>
             </div>
           </div>
         </div>
@@ -100,8 +98,8 @@
         </div>
       </div>
     </van-popup>
-    <van-calendar v-model="showHandleDate" type="range" @confirm="onConfirmHandleDate" />
-    <van-calendar v-model="showCreateDate" type="range" @confirm="onConfirmCreateDate" />
+    <van-calendar color="#025baa" v-model="showHandleDate" :min-date="minDate" type="range" @confirm="onConfirmHandleDate" />
+    <van-calendar color="#025baa" v-model="showCreateDate" :min-date="minDate" type="range" @confirm="onConfirmCreateDate" />
   </div>
 </template>
 <script>
@@ -139,24 +137,29 @@ export default {
       size: 10, //每页条数
       fillinList: [
         { text: "全部", value: 0, active: "active" },
-        { text: "30天", value: 1, active: "" },
-        { text: "3个月", value: 2, active: "" },
-        { text: "6个月", value: 3, active: "" },
-        { text: "1年", value: 4, active: "" },
-        { text: "自定义", value: 5, active: "" },
+        { text: "15天", value: 1, active: "" },
+        { text: "30天", value: 2, active: "" },
+        { text: "3个月", value: 3, active: "" },
+        { text: "6个月", value: 4, active: "" },
+        { text: "1年", value: 5, active: "" },
+        { text: "自定义", value: 6, active: "" },
       ],
       acceptanceList: [
         { text: "全部", value: 0, active: "active" },
-        { text: "30天", value: 1, active: "" },
-        { text: "3个月", value: 2, active: "" },
-        { text: "6个月", value: 3, active: "" },
-        { text: "1年", value: 4, active: "" },
-        { text: "自定义", value: 5, active: "" },
+        { text: "15天", value: 1, active: "" },
+        { text: "30天", value: 2, active: "" },
+        { text: "3个月", value: 3, active: "" },
+        { text: "6个月", value: 4, active: "" },
+        { text: "1年", value: 5, active: "" },
+        { text: "自定义", value: 6, active: "" },
       ],
+      minDate: new Date(1988, 0, 1),
       fillinDate: 0,
       acceptanceDate: 0,
       showHandleDate: false,
       showCreateDate: false,
+      handleDate: "",
+      CreateDate: "",
     };
   },
   props: {},
@@ -193,28 +196,33 @@ export default {
       }
       //处理日期
       switch (this.fillinDate) {
-        // 30
+        // 15
         case 1:
+          getParams.handledateStartDate = moment() .subtract(15, "days").format("YYYYMMDD000000");
+          getParams.handledateEndDate = moment().format("YYYYMMDD000000");
+          break;
+        // 30天
+        case 2:
           getParams.handledateStartDate = moment() .subtract(30, "days").format("YYYYMMDD000000");
           getParams.handledateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 3个月
-        case 2:
+        case 3:
           getParams.handledateStartDate = moment() .subtract(3, "months").format("YYYYMMDD000000");
           getParams.handledateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 6个月
-        case 3:
+        case 4:
           getParams.handledateStartDate = moment() .subtract(3, "months").format("YYYYMMDD000000");
           getParams.handledateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 一年
-        case 4:
+        case 5:
           getParams.handledateStartDate = moment() .subtract(1, "years").format("YYYYMMDD000000");
           getParams.handledateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 自定义
-        case 5:
+        case 6:
           getParams.handledateStartDate = moment() .subtract(1, "years").format("YYYYMMDD000000");
           getParams.handledateEndDate = moment().format("YYYYMMDD000000");
           break;
@@ -224,28 +232,33 @@ export default {
       }
       //记录日期
       switch (this.acceptanceDate) {
-        // 30
+        // 15
         case 1:
+          getParams.createdateStartDate = moment().subtract(15, "days").format("YYYYMMDD000000");
+          getParams.createdateEndDate = moment().format("YYYYMMDD000000");
+          break;
+        // 30天
+        case 2:
           getParams.createdateStartDate = moment().subtract(30, "days").format("YYYYMMDD000000");
           getParams.createdateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 3个月
-        case 2:
+        case 3:
           getParams.createdateStartDate = moment().subtract(3, "months").format("YYYYMMDD000000");
           getParams.createdateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 6个月
-        case 3:
+        case 4:
           getParams.createdateStartDate = moment().subtract(6, "months").format("YYYYMMDD000000");
           getParams.createdateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 一年
-        case 4:
+        case 5:
           getParams.createdateStartDate = moment().subtract(1, "years").format("YYYYMMDD000000");
           getParams.createdateEndDate = moment().format("YYYYMMDD000000");
           break;
         // 一年
-        case 5:
+        case 6:
           getParams.createdateStartDate = moment().subtract(1, "years").format("YYYYMMDD000000");
           getParams.createdateEndDate = moment().format("YYYYMMDD000000");
           break;
@@ -298,7 +311,7 @@ export default {
           item.active = "active";
         }
       });
-      if(data.value === 5) {
+      if(data.text === '自定义') {
         this.showHandleDate = true;
       }
     },
@@ -311,10 +324,13 @@ export default {
           item.active = "active";
         }
       });
-      if(data.value === 5) {
+      if(data.text === '自定义') {
         this.showCreateDate = true;
       }
     },
+    formatDate(date) {
+      return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
+    },
     // 自定义填报日期
     onConfirmHandleDate(date) {
       console.log(date)
@@ -325,6 +341,7 @@ export default {
     onConfirmCreateDate(date) {
       console.log(date)
       const [start, end] = date;
+      console.log()
       this.showCreateDate = false;
     },
     /**
@@ -605,6 +622,22 @@ export default {
               padding: 0 !important;
             }
           }
+          .self-btn {
+            width: 100% !important;
+            min-width: 100% !important;
+            max-width: 100% !important;
+            height: 50px;
+            box-sizing: border-box;
+            padding: 5px 10px 5px 0;
+          }
+          .m-btn {
+              width: 100%;
+              height: 32px !important;
+              text-align: center;
+              background: #eff0f1;
+              border-radius: 2px;
+              padding: 0 !important;
+            }
         }
         .active {
           background-color: #025baa !important;