From 45fbd9d1e4f63c6e43512d9d532d491367cc55ee Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期四, 21 十二月 2023 08:43:04 +0800
Subject: [PATCH] 修复弹窗bug

---
 config/env.development.js                     |    4 +-
 src/views/Admin/msgReview.vue                 |    2 
 src/util/validate.js                          |    2 
 src/views/Admin/Report.vue                    |    5 +-
 src/views/Admin/components/userMod.vue        |    8 ++-
 src/views/Admin/reactionManage.vue            |    2 
 src/directive/preventReclick.js               |   17 ++++++++
 src/views/Admin/components/pwdMod.vue         |    6 ++-
 src/views/Admin/release.vue                   |    5 +-
 src/util/request.js                           |    2 
 src/views/Login.vue                           |    3 +
 src/views/Admin/components/msgEditMod.vue     |    2 
 src/views/Admin/list.vue                      |    7 ++-
 src/directive/index.js                        |   12 ++++++
 src/main.js                                   |    4 +-
 src/views/Admin/massSend.vue                  |    2 
 src/views/Admin/sameLevel.vue                 |    2 
 src/views/Admin/userManage.vue                |    3 -
 src/views/Home.vue                            |    2 
 src/views/Admin/components/addressUserMod.vue |    2 
 src/components/Home/Dynamic.vue               |    6 ++
 src/views/Admin/notice.vue                    |    2 
 src/util/debounce.js                          |   14 +++++++
 23 files changed, 84 insertions(+), 30 deletions(-)

diff --git a/config/env.development.js b/config/env.development.js
index 5d585a8..76322d4 100644
--- a/config/env.development.js
+++ b/config/env.development.js
@@ -1,5 +1,5 @@
 module.exports = {
     NODE_ENV: "development",
-    baseUrl: 'http://192.168.0.41:8086',
+    baseUrl: 'http://192.168.0.47:8086',
     // baseUrl: 'http://121.239.169.30:13001',
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/src/components/Home/Dynamic.vue b/src/components/Home/Dynamic.vue
index 6a98088..613496f 100644
--- a/src/components/Home/Dynamic.vue
+++ b/src/components/Home/Dynamic.vue
@@ -48,7 +48,11 @@
       const t = this
       const res = await getResponseRecord(this.search)
       if(res.data.code == 100){
-        t.lists = res.data.data
+        if(res.data.data && res.data.data.length>0){
+          t.lists = res.data.data
+        }else{
+          t.lists = []
+        }
       }else{
         this.$message.error(res.data.msg)
       }
diff --git a/src/directive/index.js b/src/directive/index.js
new file mode 100644
index 0000000..4d13e1c
--- /dev/null
+++ b/src/directive/index.js
@@ -0,0 +1,12 @@
+import preventReClick from './preventReclick'
+
+const install = function(Vue) {
+    Vue.directive('preventReClick', preventReClick)
+}
+
+if (window.Vue) {
+    window['preventReClick'] = preventReClick
+    Vue.use(install); // eslint-disable-line
+}
+
+export default install
\ No newline at end of file
diff --git a/src/directive/preventReclick.js b/src/directive/preventReclick.js
new file mode 100644
index 0000000..044306f
--- /dev/null
+++ b/src/directive/preventReclick.js
@@ -0,0 +1,17 @@
+// 自定义指令防止按钮重复点击 v-preventReClick
+export default {
+    inserted(el, binding, vnode) {
+        el.addEventListener('click', () => {
+            // 是否可见
+            if (!el.disabled) {
+                el.disabled = true
+                el.style.display = 'none'
+                setTimeout(() => {
+                    el.disabled = false
+                    el.style.display = ''
+                }, binding.value || 1500)
+                // 不设置默认则为1500
+            }
+        })
+    },
+}
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index c241380..e9c9133 100644
--- a/src/main.js
+++ b/src/main.js
@@ -5,13 +5,13 @@
 import './util/AntDesign'
 import 'ant-design-vue/dist/antd.css'
 import moment from 'moment'
-
 //设置组件默认中文
 import 'moment/locale/zh-cn';
 import '@/util/permission'
 import {message,Modal} from "ant-design-vue";
 moment.locale('zh-cn');
-
+import prevent from './directive/index'//你的文件路径
+Vue.use(prevent)
 Vue.config.productionTip = false
 
 Vue.filter('filterTime', (value) => {
diff --git a/src/util/debounce.js b/src/util/debounce.js
new file mode 100644
index 0000000..a6781c7
--- /dev/null
+++ b/src/util/debounce.js
@@ -0,0 +1,14 @@
+export function debounce(func, delay) {
+  let timeoutId;
+
+  return function() {
+    const context = this;
+    const args = arguments;
+
+    clearTimeout(timeoutId);
+
+    timeoutId = setTimeout(function() {
+      func.apply(context, args);
+    }, delay);
+  };
+}
\ No newline at end of file
diff --git a/src/util/request.js b/src/util/request.js
index 74f0b2f..965afa7 100644
--- a/src/util/request.js
+++ b/src/util/request.js
@@ -61,7 +61,7 @@
         if (error.message.indexOf('timeout') != -1) {
             message.error('网络超时');
             setTimeout(() => {
-                Session.clear();
+                Session.clear()
                 window.location.href = '/';
             }, 1000);
         } else if (error.message == 'Network Error') {
diff --git a/src/util/validate.js b/src/util/validate.js
index ec9b9bc..71e4366 100644
--- a/src/util/validate.js
+++ b/src/util/validate.js
@@ -280,7 +280,7 @@
     // 弱:纯数字,纯字母,纯特殊字符
     if (/^(?:\d+|[a-zA-Z]+|[!@#$%^&\.*]+){6,16}$/.test(val)) v = '弱';
     // 中:字母+数字,字母+特殊字符,数字+特殊字符
-    if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '中';
+    if ( /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val) ) v = '中';
     // 强:字母+数字+特殊字符
     if (/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*]{6,16}$/.test(val)) v = '强';
     // 返回结果
diff --git a/src/views/Admin/Report.vue b/src/views/Admin/Report.vue
index 2da5dca..5ba70d7 100644
--- a/src/views/Admin/Report.vue
+++ b/src/views/Admin/Report.vue
@@ -30,7 +30,7 @@
             />
           </a-col>
           <a-col :span="6">
-            <a-button type="primary" @click="searchData()">查询</a-button>
+            <a-button type="primary" @click="searchData()" v-preventReClick="1500">查询</a-button>
             <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>
           </a-col>
         </a-row>
@@ -59,7 +59,7 @@
           </a-tag>
         </template>
         <template #operation="text, record, index">
-          <a-button type="primary" v-if="record.reviewStatus == 2" @click="confirmPost(record.id)">确认发布</a-button>
+          <a-button type="primary" v-if="record.reviewStatus == 2" @click="confirmPost(record.id)" v-preventReClick="1500">确认发布</a-button>
           <a-button type="link" @click="openMod('view',record)">查看信息详情</a-button>
           <a-button class="del" type="link" @click="delData(record.id)">删除</a-button>
           <a-button v-if="record.reviewStatus == 1 || record.reviewStatus == 3" @click="openMod('edit',record)">修改</a-button>
@@ -180,6 +180,7 @@
   },
   methods:{
     async getData(){
+      console.log(111)
       const t = this
       const res = await getReviewRecord(this.search)
       if(res.data.code == 100){
diff --git a/src/views/Admin/components/addressUserMod.vue b/src/views/Admin/components/addressUserMod.vue
index 9d0cc3f..ede1bf7 100644
--- a/src/views/Admin/components/addressUserMod.vue
+++ b/src/views/Admin/components/addressUserMod.vue
@@ -13,7 +13,7 @@
   >
     <a-form-model ref="ruleForm" :rules="rules" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :colon="false">
       <a-form-model-item label="姓名" prop="name">
-        <a-input v-model="form.name"/>
+        <a-input v-model.trim="form.name"/>
       </a-form-model-item>
       <a-form-model-item label="手机号码" prop="phone">
         <a-input v-model="form.phone"/>
diff --git a/src/views/Admin/components/msgEditMod.vue b/src/views/Admin/components/msgEditMod.vue
index e4484df..7db7432 100644
--- a/src/views/Admin/components/msgEditMod.vue
+++ b/src/views/Admin/components/msgEditMod.vue
@@ -169,7 +169,7 @@
             </a-button>
           </a-col>
           <a-col :span="12" style="text-align: right" v-if="title=='信息修改'">
-            <a-button type="primary" style="min-width: 140px;margin-right: 12px" @click="confirmSend(4)" :disabled="userInfo.role.id==1?true:false">
+            <a-button type="primary" style="min-width: 140px;margin-right: 12px" @click="confirmSend(4)" :disabled="userInfo.role.id==1?true:false" v-preventReClick="1500">
               确认并提交审核
             </a-button>
           </a-col>
diff --git a/src/views/Admin/components/pwdMod.vue b/src/views/Admin/components/pwdMod.vue
index 3725c90..1309cad 100644
--- a/src/views/Admin/components/pwdMod.vue
+++ b/src/views/Admin/components/pwdMod.vue
@@ -12,7 +12,7 @@
       :afterClose="clearMod"
   >
     <a-form-model ref="ruleForm" :rules="rules" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :colon="false">
-      <a-form-model-item label="原密码" prop="oldPwd">
+      <a-form-model-item label="原密码" prop="oldPwd" v-if="form.uid == id">
 <!--        <a-input v-model="form.oldPwd"/>-->
         <a-input-password v-model="form.oldPwd" placeholder="请输入原密码" />
       </a-form-model-item>
@@ -31,7 +31,7 @@
 import {verifyPasswordPowerful, verifyPhone, verifyTelPhone} from "@/util/validate";
 import { updatePwd } from '@/api/user'
 import {loginOut} from "@/api/login";
-import {Session} from "@/util/storage";
+import {getUserInfo, Session} from "@/util/storage";
 export default {
   name: 'pwdMod',
   data () {
@@ -67,6 +67,7 @@
         newPwd: '',
         reNewPwd: ''
       },
+      id: getUserInfo().uid,
       rules: {
         // oldPwd: [{ required: true, validator: validatePwd, trigger: 'blur'}],
         // newPwd: [{ required: true, validator: validatePwd, trigger: 'blur'}],
@@ -79,6 +80,7 @@
   },
   created() {
     const t = this
+    console.log(t.id,t.form.uid,'id')
   },
   methods:{
     clearMod(){
diff --git a/src/views/Admin/components/userMod.vue b/src/views/Admin/components/userMod.vue
index 31c38b3..2352c64 100644
--- a/src/views/Admin/components/userMod.vue
+++ b/src/views/Admin/components/userMod.vue
@@ -13,13 +13,13 @@
   >
     <a-form-model ref="ruleForm" :rules="rules" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :colon="false">
       <a-form-model-item label="姓名" prop="realName">
-        <a-input v-model="form.realName"/>
+        <a-input v-model.trim="form.realName"/>
       </a-form-model-item>
       <a-form-model-item label="手机号码" prop="phone">
-        <a-input v-model="form.phone"/>
+        <a-input v-model.trim="form.phone"/>
       </a-form-model-item>
       <a-form-model-item label="用户名" prop="name">
-        <a-input v-model="form.name"/>
+        <a-input v-model.trim="form.name"/>
       </a-form-model-item>
       <a-form-model-item label="密码" v-if="title== '新增用户'" prop="pwd">
         <a-input v-model="form.pwd"/>
@@ -276,6 +276,8 @@
             this.$message.error('单位层级和所属地区不匹配,请重新选择')
             return
           }
+          // this.form.realName = this.form.realName.trim()
+          // this.form.name = this.form.name.trim()
           if(this.title == '新增用户'){
             const { id,...data } = this.form
             addUser(data).then((res)=>{
diff --git a/src/views/Admin/list.vue b/src/views/Admin/list.vue
index d296879..0c5efea 100644
--- a/src/views/Admin/list.vue
+++ b/src/views/Admin/list.vue
@@ -30,7 +30,7 @@
             />
           </a-col>
           <a-col :span="6">
-            <a-button type="primary" @click="searchData">查询</a-button>
+            <a-button type="primary" @click="searchData" v-preventReClick="1000">查询</a-button>
             <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>
           </a-col>
         </a-row>
@@ -104,6 +104,7 @@
 import axios from "axios";
 import Cookies from "js-cookie";
 import {getUserInfo} from "@/util/storage";
+import {debounce} from "@/util/debounce";
 
   export default {
     name: 'list',
@@ -226,7 +227,7 @@
       t.getData()
     },
     methods: {
-      async getData(){
+      getData: debounce(async function(){
         const t = this
         const res = await getMsgRecord(this.search)
         if(res.data.code == 100){
@@ -235,7 +236,7 @@
         }else{
           this.$message.error(res.data.msg)
         }
-      },
+      },1000),
 
       onPageChange(page, pageSize) {
         const t= this
diff --git a/src/views/Admin/massSend.vue b/src/views/Admin/massSend.vue
index 5e6ed56..dd37f9e 100644
--- a/src/views/Admin/massSend.vue
+++ b/src/views/Admin/massSend.vue
@@ -163,7 +163,7 @@
 <!--				</a-select>-->
 <!--      </div>-->
       <div style="display: flex;justify-content: right">
-        <a-button type="primary" style="width: 250px;" @click="confirmSend()" :disabled="userInfo.role.id==1?true:false">
+        <a-button type="primary" style="width: 250px;" @click="confirmSend()" :disabled="userInfo.role.id==1?true:false" v-preventReClick="1500">
           确认发送
         </a-button>
       </div>
diff --git a/src/views/Admin/msgReview.vue b/src/views/Admin/msgReview.vue
index ac89646..c48a9f3 100644
--- a/src/views/Admin/msgReview.vue
+++ b/src/views/Admin/msgReview.vue
@@ -30,7 +30,7 @@
             />
           </a-col>
           <a-col :span="4">
-            <a-button type="primary" @click="getData">查询</a-button>
+            <a-button type="primary" @click="getData" v-preventReClick="1500">查询</a-button>
             <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>
           </a-col>
         </a-row>
diff --git a/src/views/Admin/notice.vue b/src/views/Admin/notice.vue
index 69b8c10..259af39 100644
--- a/src/views/Admin/notice.vue
+++ b/src/views/Admin/notice.vue
@@ -130,7 +130,7 @@
 						</a-form-model-item>
 					</a-col>
 					<a-col :span="12" style="text-align: right">
-						<a-button type="primary" style="width: 250px;" @click="confirmSend()"
+						<a-button type="primary" style="width: 250px;" @click="confirmSend()" v-preventReClick="1500"
 							:disabled="userInfo.role.id==1?true:false">
 							确认并提交审核
 						</a-button>
diff --git a/src/views/Admin/reactionManage.vue b/src/views/Admin/reactionManage.vue
index 20c776e..bdb6780 100644
--- a/src/views/Admin/reactionManage.vue
+++ b/src/views/Admin/reactionManage.vue
@@ -22,7 +22,7 @@
             {{ getRiskName(type) }}
         </template>
         <template #action="action,row">
-          <a-button type="link" @click="editData('edit',row)">编辑</a-button>
+          <a-button type="link" @click="editData('edit',row)" v-preventReClick="1500">编辑</a-button>
           <a-button type="link" class="delBtn" @click="delData(row)">删除</a-button>
         </template>
       </a-table>
diff --git a/src/views/Admin/release.vue b/src/views/Admin/release.vue
index e01b309..5443cc8 100644
--- a/src/views/Admin/release.vue
+++ b/src/views/Admin/release.vue
@@ -83,6 +83,7 @@
 import axios from "axios";
 import Cookies from "js-cookie";
 import {getUserInfo} from "@/util/storage";
+import {debounce} from "@/util/debounce";
   const columns = [{
 			title: '序号',
 			dataIndex: 'index',
@@ -200,7 +201,7 @@
       t.getData()
     },
 		methods: {
-      async getData(){
+      getData: debounce(async function(){
         const t = this
         const res = await getPublishRecord(this.search)
         if(res.data.code == 100){
@@ -209,7 +210,7 @@
         }else{
           this.$message.error(res.data.msg)
         }
-      },
+      },1000),
 
       openList(id){
         const t = this
diff --git a/src/views/Admin/sameLevel.vue b/src/views/Admin/sameLevel.vue
index aa1738d..14db0ed 100644
--- a/src/views/Admin/sameLevel.vue
+++ b/src/views/Admin/sameLevel.vue
@@ -13,7 +13,7 @@
             <a-cascader :options="areaData" v-model="areaVal" placeholder="所属区域" expandTrigger="hover" :fieldNames="fieldNames" changeOnSelect @change="onChange" style="width: 100%"/>
           </a-col>
           <a-col :span="6">
-            <a-button type="primary" @click="getUserList">查询</a-button>
+            <a-button type="primary" @click="getUserList" v-preventReClick="1500">查询</a-button>
             <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>
           </a-col>
         </a-row>
diff --git a/src/views/Admin/userManage.vue b/src/views/Admin/userManage.vue
index 87f8b2b..5a207b6 100644
--- a/src/views/Admin/userManage.vue
+++ b/src/views/Admin/userManage.vue
@@ -10,7 +10,7 @@
             <a-cascader :options="areaData" v-model="areaVal" placeholder="行政规划" expandTrigger="hover" :fieldNames="fieldNames" changeOnSelect @change="onChange" style="width: 100%"/>
           </a-col>
           <a-col :span="4">
-            <a-select v-model="search.searchParams.unittype" placeholder="监管层级" style="width: 100%">
+            <a-select v-model="search.searchParams.unittype" placeholder="监管层级" style="width: 100%" clearable>
               <a-select-option :value="1">
                 省级
               </a-select-option>
@@ -172,7 +172,6 @@
   created() {
     const t = this
     t.unittype = getUserInfo().unittype
-    console.log(t.unittype,'unit')
     t.getUserList()
     t.getDistrictInfo()
   },
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 16dd879..145fe60 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -36,7 +36,7 @@
 					  <router-view ref="tabContent"></router-view>
           </keep-alive>
 					<div style="height: 30px;text-align: center;line-height: 30px">
-            技术支持:中国科学院
+            技术支持:技术保障部
           </div>
 				</a-layout-content>
 			</a-layout>
diff --git a/src/views/Login.vue b/src/views/Login.vue
index 588b32d..44925d8 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -91,11 +91,12 @@
           size="large"
           @click="handleSubmit"
           :loading="isLoading"
+          v-preventReClick="1500"
         >
           登录
         </a-button>
       </a-form-item>
-	  <center><p>技术支持:中国科学院</p></center>
+	  <center><p>技术支持:技术保障部</p></center>
     </a-form-model>
   </div>
   </div>

--
Gitblit v1.9.2