Browse Source

日期格式修改, 超过反馈时间限制操作

liuYb 4 years ago
parent
commit
4906f12d78
2 changed files with 26 additions and 39 deletions
  1. 4 4
      src/views/data/UploadLink.vue
  2. 22 35
      src/views/data/UploadLink/sonUploadLink.vue

+ 4 - 4
src/views/data/UploadLink.vue

@@ -36,7 +36,7 @@
             >
               <td v-if="flag">{{ index + 1 }}</td>
 
-              <td>{{ obj.publishDate }}</td>
+              <td>{{ (obj.publishDate || '').replace(RegExp('-', 'g'), '/') }}</td>
               <!-- 发布日期 -->
               <td>{{ obj.informationName }}</td>
               <!-- 资料名称 -->
@@ -71,7 +71,7 @@
                 {{ obj.id ? "已反馈" : "未反馈" }}
               </td>
               <!-- 反馈状态  未定-->
-              <td>{{ obj.endDate }}</td>
+              <td>{{ (obj.endDate || '').replace(RegExp('-', 'g'), '/') }}</td>
               <!-- 反馈截止日期 -->
               <td>{{ obj.mediaTitle }}</td>
               <!-- 稿件标题 -->
@@ -451,7 +451,7 @@ export default {
               this.$set(this.tableData, i, data[j]);
             }
             //修改素材时间显示格式
-            let len = this.tableData.length;
+           /*  let len = this.tableData.length;
             for (let i = 0; i < len; i++) {
               let newValue = "";
               let temp = this.tableData[i].publishDate;
@@ -469,7 +469,7 @@ export default {
               } else {
                 this.$set(this.tableData[i], "publishDate", newValue);
               }
-            }
+            } */
             //console.log(this.tableData);
           }
         })

+ 22 - 35
src/views/data/UploadLink/sonUploadLink.vue

@@ -26,7 +26,7 @@
           >
             <td v-if="flag">{{ index + 1 }}</td>
 
-            <td>{{ obj.publishDate }}</td>
+            <td>{{ (obj.publishDate || '').replace(RegExp('-', 'g'), '/') }}</td>
             <!-- 发布日期 -->
             <td>{{ obj.informationName }}</td>
             <!-- 资料名称 -->
@@ -61,7 +61,7 @@
               {{ obj.id ? "已反馈" : "未反馈" }}
             </td>
             <!-- 反馈状态  未定-->
-            <td>{{ obj.endDate }}</td>
+            <td>{{ (obj.endDate || '').replace(RegExp('-', 'g'), '/') }}</td>
             <!-- 反馈截止日期 -->
             <td>{{ obj.mediaTitle }}</td>
             <!-- 稿件标题 -->
@@ -70,7 +70,7 @@
             </td>
             <!-- 链接 -->
 
-            <td class="operationStyle" style="cursor: pointer">
+            <td class="operationStyle" style="cursor: pointer" v-if="+((obj.endDate || '').replace(RegExp('-', 'g'), '')) - nowDate >= 0">
               <span @click="toggleModal(index)">编辑</span>
               <!-- :class="showItemOperation" -->
               <span @click="toggleModal2(index)">删除</span>
@@ -180,6 +180,8 @@ export default {
       accountId: '',
       informationName: this.$route.query.informationName || "",
       ziliaoId: this.$route.query.id || "",
+
+      nowDate: '',//反馈截止时间
     };
   },
   computed: {
@@ -198,6 +200,19 @@ export default {
     },
   },
   methods: {
+    getNowDate: function() {
+      let data = new Date();
+      let year = data.getFullYear();
+      let month = data.getMonth() + 1;
+      let day = data.getDate();
+      if (month < 10) {
+        month = "0" + month;
+      } else {
+        month = month + "";
+      }
+      this.nowDate = +(year + month + day);
+      console.log(this.nowDate);
+    },
     /*toggleModal:点击编辑后弹窗; toggleModal2:点击删除后弹窗; toggleModal3:点击导入后弹窗;  */
     toggleModal: function (i) {
       this.showModal = !this.showModal;
@@ -294,22 +309,6 @@ export default {
             for (let i = 0, j = 0; j < data.length; i++, j++) {
               this.$set(this.tableData, i, data[j]);
             }
-
-            //修改素材时间显示格式
-            let len = this.tableData.length;
-            for (let i = 0; i < len; i++) {
-              let newValue = "";
-              let temp = this.tableData[i].publishDate;
-              if (this.tableData[i].publishDate.length >= 10) {
-                newValue =
-                  temp.slice(0, 4) +
-                  "/" +
-                  temp.slice(5, 7) +
-                  "/" +
-                  temp.slice(8, 10);
-                this.$set(this.tableData[i], "publishDate", newValue);
-              }
-            }
           }
         })
         .catch((err) => {
@@ -337,21 +336,6 @@ export default {
             for (let i = 0, j = 0; j < data.length; i++, j++) {
               this.$set(this.tableData, i, data[j]);
             }
-            //修改素材时间显示格式
-            let len = this.tableData.length;
-            for (let i = 0; i < len; i++) {
-              let newValue = "";
-              let temp = this.tableData[i].publishDate;
-              if (this.tableData[i].publishDate.length >= 10) {
-                newValue =
-                  temp.slice(0, 4) +
-                  "/" +
-                  temp.slice(5, 7) +
-                  "/" +
-                  temp.slice(8, 10);
-                this.$set(this.tableData[i], "publishDate", newValue);
-              }
-            }
           }
         })
         .catch((err) => {
@@ -369,12 +353,15 @@ export default {
     console.log(userId);
     if (userId) {
       this.accountId = userId;
+      this.getDataList();
     } else {
       this.accountId = "";
+      this.getDataList();
     }
+    this.getNowDate();
   },
   created() {
-    this.getDataList();
+    
   },
 };
 </script>