浏览代码

问题修改

suxinf 4 年之前
父节点
当前提交
4c885bfdb9

+ 9 - 6
src/App.vue

@@ -10,10 +10,13 @@
         <Routerbanner :isManufacturer="isManufacturer" />
       </div>
       <div class="router_view">
-        <router-view
-          :isManufacturer="isManufacturer"
-          :isLoading="loadingFlag"
-        ></router-view>
+        <keep-alive exclude="dishes">
+          <router-view
+            :isManufacturer="isManufacturer"
+            :isLoading="loadingFlag"
+            :key="this.$route.path"
+          ></router-view>
+        </keep-alive>
       </div>
     </div>
     <div v-if="!loadingFlag">
@@ -143,7 +146,7 @@ export default {
         sessionStorage.setItem("userNameAccount", "L0M14_MM");
         this.userAccount = "L0M14_MM";
       } else {
-        if (this.$route.path !== "/loading")
+        if (this.$route.path === "/loading")
           this.$router.replace({ path: "/inforList" });
         localStorage.setItem("userId", 2002);
         sessionStorage.setItem("userNameAccount", "L0210_MM");
@@ -161,7 +164,7 @@ export default {
   created() {
      this.loadingFlag = true;
      this.getData(); // 线上打开
-    //this.localTest();// 本地调试打开
+    // this.localTest();// 本地调试打开
   },
 };
 </script>

+ 2 - 0
src/views/data/InforList.vue

@@ -419,6 +419,8 @@ export default {
     }
   },
   mounted() {
+  },
+  activated() {
     this.userId = localStorage.getItem("userId");
     this.getNowDate();
     const req = {

+ 3 - 1
src/views/data/UploadLink.vue

@@ -730,6 +730,8 @@ export default {
     },
   },
   mounted() {
+  },
+  activated() {
     this.getNowDate();
     let localUserId = localStorage.getItem("userId");
     if (localUserId) {
@@ -746,7 +748,7 @@ export default {
     };
     this.getDataList(config);
     //this.testRequest(config);
-  },
+  }
 };
 </script>
 

+ 3 - 1
src/views/data/UploadRecord.vue

@@ -221,13 +221,15 @@ export default {
     },
   },
   created() {
+  },
+  activated() {
     let res = {
       page: 1,
       rows: this.pageSize,
       asc: this.asc,
     };
     this.getFirmsUploadList(res);
-  },
+  }
 };
 </script>
 

+ 13 - 13
src/views/notification/changShang.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="notice_changShang">
-    <div v-if="isFather()">
+    <div v-if="isFather">
       <div style="color: #80808059; border: 1px solid"></div>
       <button @click="announce()">发布公告</button>
       <div class="tableD">
@@ -61,7 +61,9 @@
         <p>共{{ totalPage }}页,共{{ sum }}条数据</p>
       </div>
     </div>
-    <router-view></router-view>
+    <keep-alive exclude="dishes">
+      <router-view :key="this.$route.path"></router-view>
+    </keep-alive>
   </div>
 </template>
 
@@ -87,7 +89,6 @@ export default {
         {
           name: "删除",
           function: (obj) => {
-            console.log(obj.id);
             this.delNotice(obj.id)
           },
         },
@@ -117,20 +118,23 @@ export default {
     totalPage() {
       return Math.ceil(this.sum / this.pageSize);
     },
+    isFather: function () {
+      return this.$route.path === '/changShang';
+    },
   },
   methods: {
     goDetailPage(param){
       this.$router.push({
         path: "/changShang/itemDetail",
         query: {
-          id:param.id,
-          agentId:0
+          id:param.id
         },
       });
     },
     // 获取某一页面的数据,展示在表格
     changePage: function (page) {
       this.currentPage = page;
+      this.getDataList()
     },
     // 点击上一页,下一页,首页,尾页
     jumpPage: function (item) {
@@ -148,20 +152,15 @@ export default {
           this.currentPage = this.totalPage;
           break;
       }
+      this.getDataList()
     },
     //编辑
     edit: function (config) {
-      console.log(config);
-      config.area = ['北区'];
-      config.content = `<div>TEST</div>`;
       this.$router.push({
         path: "/changShang/editPage",
         query: config,
       });
     },
-    isFather: function () {
-      return this.$route.path === '/changShang';
-    },
     getDataList: function () {
       axiosPhp({
         method: "post",
@@ -201,7 +200,6 @@ export default {
     },
     /* 发布公告 */
     announce: function () {
-      console.log(' 发布公告')
       this.$router.push({
         path: "/changShang/editPage",
         query: {
@@ -209,7 +207,7 @@ export default {
           content:``,
           id:'',
           files:[],
-          area:["全区"]
+          area:"全区"
         },
       });
     },
@@ -217,6 +215,8 @@ export default {
   created() {
   },
   mounted() {
+  },
+  activated() {
     this.getDataList()
   }
 };

+ 2 - 2
src/views/notification/detail/itemDetail.vue

@@ -1,7 +1,8 @@
 <template>
   <div class="notice_jingXiaoshang_detail">
     <div class="titleBox">
-        <div class="titleStyle">【{{contentData.title}}】{{contentData.addtime}}</div>
+        <!-- <div class="titleStyle">【{{contentData.title}}】{{contentData.addtime}}</div> -->
+        <div class="titleStyle">{{contentData.title}}</div>
         <span @click="backToPre()">返回上一级</span>
     </div>
     <div style=" border: 1px solid  #ccc"></div>
@@ -74,7 +75,6 @@ export default {
     created() {},
     mounted() {
         this.contentData = this.$route.query;
-        console.log(this.contentData)
         this.getDetailInfo(this.contentData)
     }
 };

+ 141 - 77
src/views/notification/editPage/editPage.vue

@@ -3,7 +3,15 @@
     <form>
       <div class="Line Line1">
         <span>标题:</span>
-        <input type="text"  v-model="contentParam.title"/>
+        <input
+          type="text"
+          v-model="contentParam.title"
+          @focus="hideTip"
+          @blur="checkName"
+        />
+        <p v-show="tipFlag" style="margin-left: 88px; color: red">
+          {{ tipText }}
+        </p>
       </div>
       <div class="Line Line2">
         <span>类型:</span>
@@ -39,16 +47,16 @@
         <div style="clear: both; display: block"></div>
       </div>
 
-
       <div class="uploadFile">
         <p class="title">附件:</p>
-        <label for="fileInput" @change="getFileInfo($event)">添加附件
-          <input type="file" name="fileName" id="fileInput" multiple/>
+        <label for="fileInput" @change="getFileInfo($event)"
+          >添加附件
+          <input type="file" name="fileName" id="fileInput" multiple />
         </label>
         <div class="fileDes">
-          <p v-for="(item, index) in contentParam.files" :key="index"
-          >{{ item.file_name || item.name}}
-            <span class="deleteFile" @click="deleteFile(index,item)">×</span>
+          <p v-for="(item, index) in contentParam.files" :key="index">
+            {{ item.file_name || item.name }}
+            <span class="deleteFile" @click="deleteFile(index, item)">×</span>
           </p>
         </div>
       </div>
@@ -58,9 +66,9 @@
       <button @click="backToPre()">返回</button>
     </div>
     <TipModal
-            :tipFlag="tipModalFlag"
-            :tipText="tipModalText"
-            @close_tip_modal="closeTipModal"
+      :tipFlag="tipModalFlag"
+      :tipText="tipModalText"
+      @close_tip_modal="closeTipModal"
     />
     <Loading v-if="uploading"></Loading>
   </div>
@@ -111,17 +119,20 @@ import {
   // CodeView,
 } from "element-tiptap";
 import TipModal from "../../../components/TipModal";
-import Loading from "../../data/components/UploadLoading"
+import Loading from "../../data/components/UploadLoading";
 import helpButton from "../custom_extensions/helpButton/index";
 import CodeView from "../custom_extensions/CodeView/index";
 import { php_url } from "../../../config/env";
 import axiosPhp from "axios";
 export default {
-  components: {TipModal,Loading},
+  components: { TipModal, Loading },
   data() {
     return {
-      noticeTitle:'',
+      tipFlag: false,
+      tipText: "",
+      noticeTitle: "",
       InfoType: "",
+      title: this.$route.query && this.$route.query.title,
       areaList: ["全区", "北区", "南区", "东区"], // 按区域添加
       extensions: [
         // new Preview(),
@@ -167,67 +178,71 @@ export default {
         new History(),
         new helpButton({ bubble: false }),
       ],
-      content:'',
-      unifiedUrl:'/lexus_php/api/',
+      content: "",
+      unifiedUrl: "/lexus_php/api/",
       fileDes: [], // 上传的文件名,
-      file:[],
+      file: [],
       tipModalFlag: false,
       tipModalText: "",
       uploading: false,
-      contentParam:{
-      },
-      noticeId:'',
-      delFileIds:[],
-      editFileLength:''
+      contentParam: {},
+      noticeId: "",
+      delFileIds: [],
+      editFileLength: "",
+      allDataNameList: [],
     };
   },
   computed: {},
   methods: {
-    addNotice(id){
-      let requestURL,paramData;
-      if(id){ //编辑
-        requestURL = 'notice_update.php';
-        paramData = new FormData();
-        paramData.append("title", this.contentParam.title);
-        paramData.append("area", this.contentParam.area);
-        paramData.append("content", this.contentParam.content);
-        paramData.append("id", id);
-        console.log(this.delFileIds.length);
-        if(this.delFileIds.length){
-          let delFileStr = this.delFileIds.join(',');
-          paramData.append("del_file_ids", delFileStr);
-        }
-        if(this.contentParam.files.length === 0){
-          paramData.append("file_num", '0');
-        }else {
-          let count = 0;
-          let len = this.file.length;
-          this.file.forEach((item) => {
-            count++;
-            paramData.append("file" + count, item);
-          });
-          paramData.append("file_num", len);
-        }
-      }
-      else { //新增
-        requestURL = 'notice_add.php';
-        paramData = new FormData();
-        paramData.append("title", this.contentParam.title);
-        paramData.append("area", this.contentParam.area);
-        paramData.append("content", this.contentParam.content);
-        if(this.file.length === 0){
-          paramData.append("file_num", '0');
-        }else {
-          let count = 0;
-          let len = this.file.length;
-          this.file.forEach((item) => {
-            count++;
-            paramData.append("file" + count, item);
-          });
-          paramData.append("file_num", len);
+    addNotice(id) {
+      let requestURL, paramData;
+      this.checkName();
+      if (!this.tipFlag) {
+        if (id) {
+          //编辑
+          requestURL = "notice_update.php";
+          paramData = new FormData();
+          paramData.append("title", this.contentParam.title);
+          paramData.append("area", this.contentParam.area);
+          paramData.append("content", this.contentParam.content);
+          paramData.append("id", id);
+          console.log(this.delFileIds);
+          console.log(this.delFileIds.length);
+          if (this.delFileIds.length) {
+            let delFileStr = this.delFileIds.join(",");
+            paramData.append("del_file_ids", delFileStr);
+          }
+          if (this.contentParam.files && this.contentParam.files.length === 0) {
+            paramData.append("file_num", "0");
+          } else {
+            let count = 0;
+            let len = this.file.length;
+            this.file.forEach((item) => {
+              count++;
+              paramData.append("file" + count, item);
+            });
+            paramData.append("file_num", len);
+          }
+        } else {
+          //新增
+          requestURL = "notice_add.php";
+          paramData = new FormData();
+          paramData.append("title", this.contentParam.title);
+          paramData.append("area", this.contentParam.area);
+          paramData.append("content", this.contentParam.content);
+          if (this.file.length === 0) {
+            paramData.append("file_num", "0");
+          } else {
+            let count = 0;
+            let len = this.file.length;
+            this.file.forEach((item) => {
+              count++;
+              paramData.append("file" + count, item);
+            });
+            paramData.append("file_num", len);
+          }
         }
-      }
-       this.uploading = true;
+        this.uploading = true;
         axiosPhp({
           url: php_url + this.unifiedUrl + requestURL,
           method: "post",
@@ -240,20 +255,20 @@ export default {
           .then((res) => {
             this.uploading = false;
             if (res.data.code === 200) {
-                this.tipModalFlag = true;
-              if(id){
+              this.tipModalFlag = true;
+              if (id) {
                 this.tipModalText = "更新成功!";
-              }else {
+              } else {
                 this.tipModalText = "新增成功!";
               }
-            }else {
+            } else {
               alert(res.data.message);
             }
           })
           .catch((err) => {
             alert(err);
           });
-
+      }
     },
     // 关闭提示框
     closeTipModal: function () {
@@ -269,13 +284,12 @@ export default {
       });
     },
     // 删除文件
-    deleteFile: function(i,item) {
-      if(this.noticeId && (this.editFileLength > this.delFileIds.length)){
+    deleteFile: function (i, item) {
+      if (this.noticeId && this.editFileLength > this.delFileIds.length) {
         this.delFileIds.push(item.file_id);
       }
       this.file.splice(i, 1);
       this.contentParam.files.splice(i, 1);
-      console.log(this.delFileIds.length,this.contentParam.files.length,this.editFileLength)
     },
     // 保证多选框东区和其他的多选框互斥
     clickCheckbox(i) {
@@ -295,12 +309,62 @@ export default {
         query: {},
       });
     },
+    // 转地区的格式
+    areaToList() {
+      this.contentParam = this.$route.query || {};
+      const areaList = this.contentParam.area.split(",");
+      this.contentParam.area = areaList;
+    },
+    getDataList: function (data = {}) {
+      axiosPhp({
+        method: "post",
+        url: php_url + this.unifiedUrl + "notice_list.php",
+        data,
+      })
+        .then((res) => {
+          if (res.data.code === 200) {
+            res.data.data.forEach((element) => {
+              if(element.title !==this.title){
+                this.allDataNameList.push(element.title);
+              }
+            });
+          }
+        })
+        .catch((err) => {
+          console.log(err);
+        });
+    },
+    // 名字不重复,隐藏提示
+    hideTip: function () {
+      this.tipText = "资料名称不能重复,请重新输入";
+      this.tipFlag = false;
+    },
+    // 检查名字是否重复 失去焦点判断
+    checkName: function () {
+      // 去前后空格
+      this.contentParam.title = this.contentParam.title.replace(
+        /(^\s*)|(\s*$)/g,
+        ""
+      );
+      let include = this.allDataNameList.indexOf(this.contentParam.title);
+      if (!this.contentParam.title) {
+        this.tipText = "资料名不能为空";
+        this.tipFlag = true;
+        return;
+      } else if (include >= 0) {
+        this.tipText = "资料名称不能重复,请重新输入";
+        this.tipFlag = true;
+        return;
+      }
+    },
   },
   mounted() {
-    this.contentParam = this.$route.query;
+    this.getDataList();
+    this.areaToList();
     this.noticeId = this.contentParam.id;
-    this.editFileLength = this.contentParam.files.length;
-    console.log(this.contentParam)
+    if (this.contentParam.files) {
+      this.editFileLength = this.contentParam.files.length;
+    }
   },
   created() {},
 };
@@ -395,7 +459,7 @@ export default {
   display: flex;
   margin-top: 35px;
   min-height: 100px;
-  .title{
+  .title {
     margin-right: 8px;
     height: 20px;
     line-height: 20px;

+ 30 - 61
src/views/notification/jingXiaoshang.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="notice_jingXiaoShang">
-    <div v-if="isFather()">
+    <div v-if="isFather">
       <div class="topTab">
         <span>通知公告</span>
       </div>
@@ -17,96 +17,65 @@
           v-for="(obj, index) in contentData"
           :key="index"
           class="itemBox"
-          @click="toDetail(obj)"
+          :class="{ unread_message: obj.read_time === 0 }"
+          @click="toDetail(obj.id)"
         >
           <div class="lineItem1">
             <span class="dotStyle"></span>
-            <div :class="{ unread_message: obj.unread === 1 }">
-              [{{ obj.info }}]
-            </div>
-          </div>
-          <div :class="{ unread_message: obj.unread === 1 }">
-            【{{ obj.title || "" }}】
-          </div>
-          <div :class="{ unread_message: obj.unread === 1 }">
-            {{ obj.content }}
-          </div>
-          <div :class="{ unread_message: obj.unread === 1 }">
-            {{ obj.time }}
+            <div ><span>·</span>[重要通知]</div>
           </div>
+          <div>{{ obj.title || "-" }}</div>
+          <div v-html="obj.content"></div>
+          <div>{{ (obj.update_time || obj.addtime || '').slice(0, -8) }}</div>
         </div>
       </div>
     </div>
-    <router-view></router-view>
+    <keep-alive>
+      <router-view></router-view>
+    </keep-alive>
   </div>
 </template>
 
 <script>
-  import { php_url } from "../../config/env";
-  import axiosPhp from "axios";
+import { php_url } from "../../config/env";
+import axiosPhp from "axios";
 export default {
   components: {},
   data() {
     return {
-      unifiedUrl:'/lexus_php/api/',
-      contentData: [
-        {
-          unread: 0,
-          info: "重要通知",
-          title: "经销商分享",
-          content:'2020年12月线索相关数据明细已上线',
-          time: "2021/05/01",
-        },
-        {
-          unread: 1,
-          info: "重要通知",
-          title: "经销商分享",
-          content:'2020年12月线索相关数据明细已上线',
-          time: "2021/05/01",
-        },
-        {
-          unread: 0,
-          info: "重要通知",
-          title: "经销商分享",
-          content:'2020年12月线索相关数据明细已上线',
-          time: "2021/05/01",
-        },
-      ],
+      contentData: [],
       agentId:localStorage.getItem('userId')
     };
   },
-  computed: {},
+  computed: {
+    isFather: function () {
+      return this.$route.path === '/jingXiaoshang';
+    }
+  },
   methods: {
     /* 跳转通知详情 */
     /* F:\Lexus\Lexus-media\src\views\notification\detail\itemDetail.vue */
-    toDetail: function () {
+    toDetail: function (id) {
       this.$router.push({
         path: "/changShang/itemDetail",
         query: {
-          id:'7',
+          id,
           agentId:this.agentId
         },
       });
     },
-    isFather: function () {
-      console.log(this.$route.path, this.$route.path.length)
-      return this.$route.path === '/jingXiaoshang';
-    },
     getDataList: function () {
       axiosPhp({
         method: "post",
-        url: php_url + this.unifiedUrl + "notice_list_agent.php",
+        url: php_url + "/lexus_php/api/notice_list_agent.php",
         data: {
-          Page: this.currentPage,
-          Rows: this.pageSize,
           agentId:this.agentId
         },
       })
         .then((res) => {
-          console.log(res)
           if (res.data.code === 200) {
             this.sum = res.data.count;
-            // this.tableData = res.data.data;
+            this.contentData = res.data.data
           }
         })
         .catch((err) => {
@@ -116,27 +85,26 @@ export default {
   },
   created() {},
   mounted() {
+  },
+  activated() {
     this.getDataList()
   }
 };
 </script>
 
-<style scoped lang="less">
+<style lang="less">
+.notice_jingXiaoShang{
 .unread_message {
   color: red;
+  *{
+    color: red!important;;
+  }
 }
 .lineItem1 {
   display: flex;
   justify-content: center;
   align-items: center;
 }
-.dotStyle {
-  width: 2px;
-  height: 2px;
-  border: 1px solid black;
-  border-radius: 2px;
-  background-color: black;
-}
 .noticeContent {
   position: relative;
   top: 30px;
@@ -161,4 +129,5 @@ export default {
   margin-left: 16px;
   color: white;
 }
+}
 </style>