From 55c9d726f32f068ef2cf91a0d1a1fe9b9370b639 Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: 星期五, 28 十月 2022 17:15:52 +0800
Subject: [PATCH] 新增有效期限

---
 src/views/enterprise/userinfo.vue |   76 ++++++++++++++
 src/api/user.js                   |   11 ++
 src/views/login/index.vue         |  199 +++++++++++++++++++++++++++++++++------
 3 files changed, 251 insertions(+), 35 deletions(-)

diff --git a/src/api/user.js b/src/api/user.js
index 444ad7d..e279b89 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -155,3 +155,14 @@
     params: params || {}
   })
 }
+
+export function updateDeadline(data) {
+    return request({
+        headers: {
+            'Authorization': getToken()
+        },
+        url: process.env.BASE_API + '/jiangWai/deadline/set ',
+        method: 'post',
+        data
+    })
+}
diff --git a/src/views/enterprise/userinfo.vue b/src/views/enterprise/userinfo.vue
index 6d17063..447d8bd 100644
--- a/src/views/enterprise/userinfo.vue
+++ b/src/views/enterprise/userinfo.vue
@@ -117,10 +117,15 @@
             <span>{{ scope.row.lastmodifieddate | parseTime('{y}-{m}-{d}') }}</span>
           </template>
         </el-table-column>
+      <el-table-column label="账户有效期" prop="deadline" align="center" sortable="custom">
+          <template slot-scope="scope">
+              <span>{{ scope.row.deadline }}</span>
+          </template>
+      </el-table-column>
         <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
           <template slot-scope="scope">
             <el-button type="text" @click="showEditHandle(scope.row)">编辑</el-button>
-<!--            <el-button :disabled="disableRole(scope.row)" type="text" align="center" @click="showAssignRole(scope.row)">分配角色</el-button>-->
+            <el-button v-if="scope.row.companyid !=null" type="text" @click="showEditDeadline(scope.row)">修改有效期</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -238,16 +243,35 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="dialogUserRoleFormVisible = false">取消</el-button>
-        <el-button type="primary" @click="assignUserRoleHandle">确认</el-button>
+        <el-button type="primary" @click="assignUserRoleHandle()">确认</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog title="修改有效期" :visible.sync="dialogDeadlineVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="700px">
+        <el-form ref="deadlineForm" :rules="deadlineFormRules" :model="deadlineForm" label-position="right" label-width="100px" style="margin-left:50px;width:500px;" element-loading-text="保存中...">
+            <el-form-item label="有效期:" prop="deadline">
+                <el-date-picker
+                    v-model.trim="deadlineForm.deadline"
+                    type="date"
+                    format="yyyy 年 MM 月 dd 日"
+                    value-format="yyyy-MM-dd"
+                    placeholder="选择有效期">
+                </el-date-picker>
+            </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+            <el-button @click="dialogDeadlineVisible = false">取消</el-button>
+            <el-button type="primary" @click="editDeadline()">确认</el-button>
+        </div>
+    </el-dialog>
+
     <div style="clear: both;"/>
   </div>
 </template>
 
 <script>
 import { mapGetters } from 'vuex'
-import { enterpriseUserList, createUser, deleteUser, updateUser, importDistrict,getDistrict,getDistrictByName,updateUserRole} from '@/api/user'
+import { enterpriseUserList, createUser, deleteUser, updateUser, importDistrict,getDistrict,getDistrictByName,updateUserRole,updateDeadline} from '@/api/user'
 import { checkBtnPermission } from '@/utils/permission'
 import { roleList } from '@/api/role'
 import { parseTime, computePageCount, parseUserType } from '@/utils'
@@ -365,11 +389,16 @@
         town: '',
         community: '',
         type:'',
-        job:'',
+        job:''
       },
+        deadlineForm:{
+          uid: '',
+          deadline: ''
+        },
       importDialogFormVisible: false,
       importDisabled: false,
       dialogFormVisible: false,
+      dialogDeadlineVisible: false,
       dialogStatus: '',
       dataFormRules: {
         name: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
@@ -378,6 +407,9 @@
         confirmPassword: [{ required: true, message: '确认密码不能为空', trigger: 'blur' }],
         type: [{ required: true, message: '用户类型不能为空', trigger: 'blur' }]
       },
+        deadlineFormRules: {
+            deadline: [{ required: true, message: '有效期不能为空', trigger: 'blur' }]
+        },
       provinceList:[],
       cityList:[],
       areaList:[],
@@ -551,6 +583,12 @@
       this.townList = []
       this.communityList = []
     },
+      resetDeadlineForm(){
+        this.deadlineForm = {
+            uid: '',
+            deadline: ''
+        }
+      },
     showCreateHandle() {
       this.resetDataForm()
       this.dialogStatus = 'create'
@@ -687,6 +725,36 @@
       })
 
     },
+
+    showEditDeadline(row){
+        this.resetDeadlineForm()
+        this.deadlineForm.uid = row.id
+        this.dialogDeadlineVisible = true
+    },
+
+    editDeadline(){
+        const t = this
+        this.$refs['deadlineForm'].validate((valid) => {
+            if (valid) {
+                const params = this.deadlineForm
+                console.log(params,'params')
+                updateDeadline(params).then(response => {
+                    const res = response.data
+                    if (res.code == 200) {
+                        t.dialogDeadlineVisible = false
+                        t.$message({
+                            message: '有效期修改成功',
+                            type: 'success'
+                        })
+                        t.getUserList()
+                    } else {
+                        parseError({ error: res.message, vm: t })
+                    }
+                })
+            }
+        })
+    },
+
     passwordChangeEvent: function(value) {
       if (this.dataForm.password != value) {
         parseError({ error: '密码输入不一致', vm: this })
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index e2a3bf2..94867c3 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -11,6 +11,44 @@
                 />
             </div>
         </div>
+
+      <el-dialog
+          title="账户到期提醒"
+          :visible.sync="dialogTip"
+          :close-on-click-modal="false"
+          width="40%"
+          top="30vh"
+          :show-close="false"
+          center>
+          <div style="text-indent: 28px;line-height: 1.5">
+              <div style="margin-bottom: 10px">尊敬的烟花爆竹生产、经营厂家,您的账户免费使用权限即将过期,为不影响您的正常使用,请于{{ deadline }}之前缴(续)费,逾期未缴费您的账户将不能继续登录使用。</div>
+              <div style="margin-bottom: 10px">系统年度技术服务费人民币1800元,点击下方“去缴费”即可进行缴(续)费操作。</div>
+              <div>感谢您的配合!</div>
+          </div>
+          <span slot="footer" class="dialog-footer">
+            <el-button @click="holdOn()">再等等</el-button>
+            <el-button type="primary" @click="toPay()">去缴费</el-button>
+          </span>
+      </el-dialog>
+      <el-dialog
+          title="缴(续)费须知"
+          :visible.sync="dialogPay"
+          :close-on-click-modal="false"
+          width="40%"
+          top="30vh"
+          @closed="isLogin()"
+          center>
+          <div class="payTip">
+              <div>
+                  <h2>付款方式:</h2>
+                  <span>苏州国科鸿宇智能科技有限公司</span>纳税人识别号:91320594MA1YCQQ60E<br/>开户行:中国银行股份有限公司苏州独墅湖支行<br/>账号:517073268476<br/>地址:苏州工业园区若水路398号D0313<br/>联系电话:0512-62872586
+              </div>
+              <div class="payInfo">
+                  <h3>提醒:</h3>
+                  请您在完成付款之后,联系<br/>0512-62872586 田老师<br/>为您的账户进行续期,为您开具发票。
+              </div>
+          </div>
+      </el-dialog>
       <div class="bottom-container">
         <span class="bottom-container_title">中国科学院苏州纳米技术与纳米仿生研究所监制</span>
       </div>
@@ -34,14 +72,18 @@
   data() {
     return {
       websocket:'',
-      url:process.env.BASE_API.replace("http","ws").replace("https","wss"),
+      url: process.env.BASE_API.replace("http","ws").replace("https","wss"),
       action: 'login',
       screenWidth: '',
       screenHeight: '',
       logincontainer: 'login-container',
       isSafe: process.env.isSafe,
       titleName: '新疆维吾尔自治区烟花爆竹流向管理信息实名登记系统',
-      safeLoginTitle: '新疆维吾尔自治区烟花爆竹流向管理信息实名登记系统'
+      safeLoginTitle: '新疆维吾尔自治区烟花爆竹流向管理信息实名登记系统',
+      dialogTip: false,
+      dialogPay: false,
+      deadline: '',
+      isOverTime: true
     }
   },
   watch: {
@@ -74,7 +116,27 @@
         this.logincontainer = 'login-container'
       }
     },
-    handleLogin(loginForm) {
+    holdOn(){
+        const t = this
+        if(!t.isOverTime){
+            // 加载菜单
+            initRouter(t)
+            t.$router.replace('/enterprise/basic')
+        }
+        t.dialogTip = false
+    },
+    toPay(){
+        this.dialogPay = true
+    },
+      isLogin(){
+          const t = this
+          if(!t.isOverTime){
+              // 加载菜单
+              initRouter(t)
+              t.$router.replace('/enterprise/basic')
+          }
+      },
+      handleLogin(loginForm) {
       const _this = this
       _this.$refs.getdata.submitLoading = false
       _this.loading = true
@@ -85,34 +147,83 @@
           if (res.code == 200) {
             _this.loading = false
             const data = res.result
-            if (data.type != 1 && data.type != 2) {
-              if (!data.roles || data.roles.length == 0) {
-                // 验证返回的roles是否是一个非空数组
-                _this.$store.commit('SET_ROLES', [])
-                parseError({
-                  error: '该用户没有权限登录,请联系所配置管理员分配角色',
-                  vm: _this
-                })
-                // reject('用户未分配角色,没有权限登录')
-                return
-              }
+            if(data.deadline && data.deadline != null){
+                const deadline = data.deadline;
+                console.log('判断时间')
+                const date = new Date(deadline);
+                console.log(date.getTime(),Date.now(),'对比')
+                if(date.getTime() < Date.now()){
+                    console.log("过期")
+                    _this.isOverTime = true
+                    _this.dialogTip = true
+                    return
+                }else{
+                    _this.isOverTime = false
+                    if (data.type != 1 && data.type != 2) {
+                        if (!data.roles || data.roles.length == 0) {
+                            // 验证返回的roles是否是一个非空数组
+                            _this.$store.commit('SET_ROLES', [])
+                            parseError({
+                                error: '该用户没有权限登录,请联系所配置管理员分配角色',
+                                vm: _this
+                            })
+                            // reject('用户未分配角色,没有权限登录')
+                            return
+                        }
+                    }
+                    this._initConnect(data.id)
+                    _this.$store.commit('SET_ROLES', data.roles)
+                    Cookies.set('roles', JSON.stringify(data.roles))
+                    setToken(data.token)
+                    Cookies.set('roleType',data.roleType)
+                    Cookies.set('isSupervision',data.companyid)
+                    Cookies.set('company',data.company)
+                    Cookies.set('userName', data.username)
+                    Cookies.set('name', data.username)
+                    Cookies.set('userId', data.id)
+                    Cookies.set('token_expired_at', data.tokenexpired)
+                    _this.$store.commit('SET_NAME', data.username)
+                    _this.$store.commit('SET_USER_TYPE', data.type)
+                    const nTime = date.getTime() - Date.now();
+                    console.log('还剩' + Math.floor(nTime / 86400000))
+                    if(Math.floor(nTime / 86400000)>30){
+                        // 加载菜单
+                        initRouter(_this)
+                        _this.$router.replace('/enterprise/basic')
+                    }else{
+                        this.dialogTip = true
+                    }
+                }
+            }else{
+                if (data.type != 1 && data.type != 2) {
+                    if (!data.roles || data.roles.length == 0) {
+                        // 验证返回的roles是否是一个非空数组
+                        _this.$store.commit('SET_ROLES', [])
+                        parseError({
+                            error: '该用户没有权限登录,请联系所配置管理员分配角色',
+                            vm: _this
+                        })
+                        // reject('用户未分配角色,没有权限登录')
+                        return
+                    }
+                }
+                this._initConnect(data.id)
+                _this.$store.commit('SET_ROLES', data.roles)
+                Cookies.set('roles', JSON.stringify(data.roles))
+                setToken(data.token)
+                Cookies.set('roleType',data.roleType)
+                Cookies.set('isSupervision',data.companyid)
+                Cookies.set('company',data.company)
+                Cookies.set('userName', data.username)
+                Cookies.set('name', data.username)
+                Cookies.set('userId', data.id)
+                Cookies.set('token_expired_at', data.tokenexpired)
+                _this.$store.commit('SET_NAME', data.username)
+                _this.$store.commit('SET_USER_TYPE', data.type)
+                // 加载菜单
+                initRouter(_this)
+                _this.$router.replace('/enterprise/basic')
             }
-            this._initConnect(data.id)
-            _this.$store.commit('SET_ROLES', data.roles)
-            Cookies.set('roles', JSON.stringify(data.roles))
-            setToken(data.token)
-            Cookies.set('roleType',data.roleType)
-            Cookies.set('isSupervision',data.companyid)
-            Cookies.set('company',data.company)
-            Cookies.set('userName', data.username)
-            Cookies.set('name', data.username)
-            Cookies.set('userId', data.id)
-            Cookies.set('token_expired_at', data.tokenexpired)
-            _this.$store.commit('SET_NAME', data.username)
-            _this.$store.commit('SET_USER_TYPE', data.type)
-            // 加载菜单
-            initRouter(_this)
-           _this.$router.replace('/enterprise/basic')
           } else {
             _this.$message({
               showClose: true,
@@ -323,7 +434,33 @@
           line-height: 20px;
       }
   }
-
+    .payTip{
+        div{
+            line-height: 1.5;
+            h2{
+                margin-top: 0;
+                margin-bottom: 6px;
+            }
+            span{
+                font-size: 16px;
+                font-weight: bolder;
+                display: block;
+            }
+        }
+        .payInfo{
+            line-height: 1.8;
+            margin-top: 15px;
+            width: 100%;
+            padding: 2% 4%;
+            box-sizing: border-box;
+            background: #ffebb2;
+            border-radius: 8px;
+            h3{
+                margin-top: 0;
+                margin-bottom: 6px;
+            }
+        }
+    }
 }
 
 .login-container-1 {

--
Gitblit v1.9.2