Browse Source

完善各个功能

Limengbo 5 years ago
parent
commit
a545d66c55

BIN
src/assets/head.png


+ 3 - 3
src/layout/components/Navbar.vue

@@ -7,12 +7,12 @@
     <div class="right-menu">
       <el-dropdown class="avatar-container" trigger="click">
         <div class="avatar-wrapper">
-          <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
+          <img src="@/assets/head.png" class="user-avatar">
           <i class="el-icon-caret-bottom" />
         </div>
         <el-dropdown-menu slot="dropdown" class="user-dropdown">
           <el-dropdown-item divided>
-            <span style="display:block;" @click="logout">Log Out</span>
+            <span style="display:block;" @click="logout">退出</span>
           </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
@@ -42,7 +42,7 @@ export default {
     },
     async logout() {
       await this.$store.dispatch('user/logout')
-      this.$router.push(`/login?redirect=${this.$route.fullPath}`)
+      this.$router.push(`/login`)
     }
   }
 }

+ 6 - 5
src/layout/components/Sidebar/index.vue

@@ -38,22 +38,23 @@ export default {
     ]),
     routes() {
       let sidebarArr = [];
-      console.log(this.type)
       if(this.type === '0') {
         sidebarArr = ['设备管理', '安装/维护人员管理', '维护人员分配设备管理', '设备安装']
       }
-      if(this.type === '1') {
+      if(this.type === '1, ' || this.type === '1') {
         sidebarArr = ['设备安装']
       }
-      if(this.type === '2') {
+      if(this.type === '2' || this.type === ' ,2') {
         sidebarArr = ['设备管理']
       }
+      if(this.type === '1,2') {
+        sidebarArr = ['设备管理', '设备安装']
+      }
       this.$router.options.routes.forEach((item, index) => {
-        if (!!item.children) {
+        if (item.children !== undefined) {
           const title = item.children[0].meta.title
           this.$router.options.routes[index].children[0].hidden = true
           if (sidebarArr.indexOf(title) !== -1) {
-            console.log(index)
             this.$router.options.routes[index].children[0].hidden = false
           }
         }

+ 10 - 0
src/store/modules/admin.js

@@ -17,6 +17,16 @@ const mutations = {
     state.deviceData = data
   },
   GET_MODIFIER: (state, data) => {
+    if (data.length > 0) {
+      data.forEach(item => {
+        const length = item.type.length
+        let peopleType = [...item.type]
+        if (length > 2) {
+          peopleType = item.type.split(',')
+        }
+        item.type = peopleType
+      })
+    }
     state.modifierData = data
   },
   GET_Log: (state, data) => {

+ 15 - 12
src/store/modules/user.js

@@ -1,4 +1,4 @@
-import { login, logout, getInfo } from '@/api/user'
+import { login, getInfo } from '@/api/user'
 import { getToken, setToken, removeToken, setType } from '@/utils/auth'
 import { resetRouter } from '@/router'
 
@@ -59,17 +59,20 @@ const actions = {
   },
 
   // user logout
-  logout({ commit, state }) {
-    return new Promise((resolve, reject) => {
-      logout(state.token).then(() => {
-        commit('SET_TOKEN', '')
-        removeToken()
-        resetRouter()
-        resolve()
-      }).catch(error => {
-        reject(error)
-      })
-    })
+  logout({ commit }) {
+    commit('SET_TOKEN', '')
+    removeToken()
+    resetRouter()
+    // return new Promise((resolve, reject) => {
+    //   logout(state.token).then(() => {
+    //     commit('SET_TOKEN', '')
+    //     removeToken()
+    //     resetRouter()
+    //     resolve()
+    //   }).catch(error => {
+    //     reject(error)
+    //   })
+    // })
   },
 
   // remove token

+ 4 - 2
src/views/admin/allocateDevice/index.vue

@@ -38,7 +38,9 @@
         label="人员"
       >
         <template slot-scope="scope">
-          {{ peopleType[scope.row.type] }}
+          <span v-for="(item, index) in scope.row.type" :key="index">
+            {{ peopleTypes[item] }}
+          </span>
         </template>
       </el-table-column>
       <el-table-column
@@ -136,7 +138,7 @@ export default {
       gridTile: '',
       handleType: '',
       title: '',
-      peopleType: ['管理员', '安装员', '维护员'],
+      peopleTypes: ['管理员', '安装员', '维护员'],
       multipleSelection: [],
       okBtn: '确 定',
       dialogFormMoveVisible: false,

+ 5 - 5
src/views/admin/device/index.vue

@@ -27,7 +27,7 @@
         type="date"
         placeholder="选择设备安装日期"
         format="yyyy 年 MM 月 dd 日"
-        value-format="timestamp"
+        value-format="yyyy-MM-dd"
       />
       <el-button type="primary" size="mini" style="float: right;" @click="search">查询</el-button>
     </div>
@@ -175,8 +175,8 @@ export default {
     ...mapGetters(['deviceData'])
   },
   created() {
-    console.log(111, this.type)
-    if (this.type === '2') {
+    console.log(111, this.type.indexOf('2'))
+    if (this.type.indexOf('2') !== -1) {
       this.$store.dispatch('admin/getDeviceData', {
         modifier: this.uid
       })
@@ -192,7 +192,7 @@ export default {
           deviceType: this.deviceType,
           region: this.region,
           address: this.address,
-          gmtCreated: this.gmtCreated,
+          startTime: this.gmtCreated,
           modifier: this.uid
         })
       } else {
@@ -201,7 +201,7 @@ export default {
           deviceType: this.deviceType,
           region: this.region,
           address: this.address,
-          gmtCreated: this.gmtCreated
+          startTime: this.gmtCreated
         })
       }
     },

+ 19 - 7
src/views/admin/installMaintain/index.vue

@@ -46,7 +46,9 @@
         label="人员"
       >
         <template slot-scope="scope">
-          {{ peopleType[scope.row.type] }}
+          <span v-for="(item, index) in scope.row.type" :key="index">
+            {{ peopleTypes[item] }}
+          </span>
         </template>
       </el-table-column>
       <el-table-column
@@ -80,12 +82,13 @@
     <el-dialog :title="title" :visible.sync="dialogFormVisible">
       <el-form ref="form" :model="form" label-width="120px">
         <el-form-item v-for="item in addInput" :key="item.type" :label="item.name" label-width="120px">
-          <el-select v-if="item.select" v-model="form[item.type]" :placeholder="item.select">
+          <el-input v-if="!item.select" v-model="form[item.type]" autocomplete="off" />
+          <el-select  v-else v-for="(peopleItem, index) in item.peopleType" :key="index" v-model="form[item.type][index]" :placeholder="item.select">
             <el-option label="管理员" value="0" />
             <el-option label="安装员" value="1" />
             <el-option label="维护员" value="2" />
+            <el-option label="无" value=" " />
           </el-select>
-          <el-input v-else v-model="form[item.type]" autocomplete="off" />
         </el-form-item>
         <!--
         <el-form-item label="人员名称" label-width="120px">
@@ -164,7 +167,7 @@ export default {
       gridTile: '',
       handleType: '',
       title: '',
-      peopleType: ['管理员', '安装员', '维护员'],
+      peopleTypes: ['管理员', '安装员', '维护员'],
       loginName: '',
       name: '',
       mobile: '',
@@ -221,6 +224,7 @@ export default {
       {
         name: '人员类型',
         type: 'type',
+        peopleType: [' ', ' '],
         select: '请选择人员类型'
       }]
       this.form = {
@@ -228,12 +232,13 @@ export default {
         mobile: '',
         password: '',
         loginName: '',
-        type: ''
+        type: [' ', ' ']
       }
       this.title = '添加人员'
       this.handleType = 'add'
     },
     handleOk() {
+      this.form.type = this.form.type.join(',')
       if (this.handleType === 'add') {
         this.$store.dispatch('admin/addDeviceModifierData', this.form)
       }
@@ -258,21 +263,28 @@ export default {
       })
     },
     handleSet(index, row) {
-      console.log(index, row)
+      const length = row.type.length
+      const peopleType = length >= 2 ? row.type : [...row.type, ' ']
       this.dialogFormVisible = true
       this.addInput = [{
         name: '人员名称',
         type: 'name'
       },
       {
+        name: '手机号码',
+        type: 'mobile'
+      },
+      {
         name: '人员类型',
         type: 'type',
+        peopleType,
         select: '请选择人员类型'
       }]
       this.form = {
         id: row.id,
         name: row.name,
-        type: row.type
+        mobile: row.mobile,
+        type: peopleType
       }
       this.title = '修改人员'
       this.handleType = 'set'

+ 8 - 2
src/views/installer/index.vue

@@ -22,7 +22,7 @@
         <el-input v-model="form.address" />
       </el-form-item>
       <el-form-item label="备注信息" prop="description">
-        <el-input v-model="form.description" />
+        <el-input type="textarea" v-model="form.description" />
       </el-form-item>
       <el-form-item label="安装人员" prop="setter">
         <el-select v-model="form.setter" placeholder="请选择安装人员">
@@ -81,7 +81,7 @@
     </div>
     <el-form v-show="active === 2" ref="formLog" :model="formLog" :rules="rulesLog" label-width="120px" class="demo-ruleForm">
       <el-form-item label="测试报告" prop="description">
-        <el-input v-model="formLog.description" />
+        <el-input type="textarea" v-model="formLog.description" />
       </el-form-item>
       <el-form-item>
         <el-button type="primary" @click="onSubmitLog('formLog')">确定</el-button>
@@ -202,6 +202,12 @@ export default {
     next(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          for (let i = 1; i <= 5; i++) {
+            if (this.ruleForm[`resource${i}`] === '否') {
+              this.$message.error('请先解决问题在安装')
+              return false
+            }
+          }
           this.active++
         } else {
           console.log('error submit!!')

+ 1 - 1
src/views/login/index.vue

@@ -95,7 +95,7 @@ export default {
         if (valid) {
           this.loading = true
           this.$store.dispatch('user/login', this.loginForm).then((data) => {
-            if (data.type === '1') {
+            if (data.type.indexOf('1') !== -1) {
               this.$router.push({ path: this.redirect || '/install/install' })
             } else {
               this.$router.push({ path: this.redirect || '/' })