同步会议室

master
lion 1 week ago
parent 0b6f341392
commit 77b33be4a7

@ -5,6 +5,7 @@ const getters = {
avatar: state => state.user.avatar,
name: state => state.user.name,
roles: state => state.user.roles,
roleNames: state => state.user.roleNames,
permission_routes: state => state.permission.routes
}
export default getters

@ -1,7 +1,7 @@
import {
login,
logout,
getInfo,
getInfo,
loginMsg
} from '@/api/user'
import {
@ -18,7 +18,8 @@ const getDefaultState = () => {
token: getToken(),
name: '',
avatar: '',
roles: []
roles: [],
roleNames: []
}
}
@ -39,6 +40,9 @@ const mutations = {
},
SET_ROLES: (state, roles) => {
state.roles = roles
},
SET_ROLE_NAMES: (state, roleNames) => {
state.roleNames = roleNames
}
}
@ -68,7 +72,7 @@ const actions = {
reject(error)
})
})
},
},
loginMsg({
commit
}, userInfo) {
@ -106,15 +110,17 @@ const actions = {
if (!response) {
reject('身份验证失败请重新登录')
}
response["roles"] = ["admin"];
const roleNames = (response.roles || []).map(role => {
return typeof role === 'string' ? role : role.name
}).filter(Boolean)
response.roles = ['admin']
const {
roles,
name,
avatar
} = response
commit('SET_ROLE_NAMES', roleNames)
commit('SET_ROLES', roles)
commit('SET_NAME', name)
commit('SET_AVATAR', avatar)
@ -159,4 +165,4 @@ export default {
state,
mutations,
actions
}
}

@ -154,27 +154,41 @@
</div>
</template>
<!-- <template v-slot:door>
<div class="xy-table-item">
<template v-if="isSystemAdmin" v-slot:door>
<div class="xy-table-item technical-field">
<div class="xy-table-item-label" style="font-weight: bold;">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>第三方门禁信息技术填写
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>门禁信息door
</div>
<div class="xy-table-item-content">
<div>{{form.door}}</div>
<el-input
v-model="form.door"
type="textarea"
:rows="8"
placeholder="请输入达实门禁 JSON例如包含 doorName 字段"
clearable
style="width: 100%;">
</el-input>
</div>
</div>
</template>
<template v-slot:room>
<div class="xy-table-item">
<template v-if="isSystemAdmin" v-slot:room>
<div class="xy-table-item technical-field">
<div class="xy-table-item-label" style="font-weight: bold;">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>第三方会议室信息技术人员填写
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>会议室信息room
</div>
<div class="xy-table-item-content">
<div>{{form.room}}</div>
<el-input
v-model="form.room"
type="textarea"
:rows="8"
placeholder="请输入爱预约会议室 JSON例如包含 code、address 字段"
clearable
style="width: 100%;">
</el-input>
</div>
</div>
</template> -->
</template>
</xy-dialog>
</div>
@ -182,6 +196,7 @@
<script>
import myMixins from "@/mixin/selectMixin.js";
import { mapGetters } from 'vuex'
import {
show,
save
@ -192,6 +207,12 @@
export default {
mixins: [myMixins],
components: {},
computed: {
...mapGetters(['roleNames']),
isSystemAdmin() {
return (this.roleNames || []).includes('系统管理员')
}
},
data() {
return {
isShow: false,
@ -209,12 +230,9 @@
status: 1,
use_student: 1,
show_front:0,
// dateRange: ['09:00','17:30'],
file_ids: [],
// start_time:'09:00',
// end_time:'17:30',
// door:'',
// room:''
door: '',
room: ''
},
action: `${process.env.VUE_APP_UPLOAD_API}`,
types_options:[],
@ -242,14 +260,28 @@
})
this.types_options = res.data
},
changeDateRange(e) {
console.log(e)
if (e) {
this.form.start_time = e[0]
this.form.end_time = e[1]
} else {
this.form.start_time = ''
this.form.end_time = ''
formatJsonField(value) {
if (!value) {
return ''
}
if (typeof value === 'object') {
return JSON.stringify(value, null, 2)
}
try {
return JSON.stringify(JSON.parse(value), null, 2)
} catch (error) {
return value
}
},
normalizeJsonField(value, label) {
if (value === null || value === undefined || value === '') {
return ''
}
try {
return JSON.stringify(JSON.parse(value))
} catch (error) {
this.$message.error(`${label} JSON 格式不正确`)
return null
}
},
uploadSuccesspublic(response, file, fileList) {
@ -275,9 +307,25 @@
})
}
this.form.file_ids = _files
save({
const payload = {
...this.form
}).then(res => {
}
if (this.isSystemAdmin) {
const door = this.normalizeJsonField(this.form.door, '门禁信息')
if (door === null) {
return
}
const room = this.normalizeJsonField(this.form.room, '会议室信息')
if (room === null) {
return
}
payload.door = door
payload.room = room
} else {
delete payload.door
delete payload.room
}
save(payload).then(res => {
this.$message({
type: 'success',
message: '保存预约场地成功'
@ -298,9 +346,8 @@
this.form.status = res.status ? res.status : 0
// this.form.use_student = res.use_student ? res.use_student : 0
this.form.show_front = res.show_front ? res.show_front : 0
// this.form.dateRange = res.start_time?[res.start_time,res.end_time]:['','']
// this.form.door = res.door?JSON.parse(res.door):''
// this.form.room = res.room?JSON.parse(res.room):''
this.form.door = this.isSystemAdmin ? this.formatJsonField(res.door) : ''
this.form.room = this.isSystemAdmin ? this.formatJsonField(res.room) : ''
})
},
@ -327,10 +374,9 @@
status: 1,
use_student: 1,
show_front:0,
// dateRange: ['09:00','17:30'],
file_ids: [],
// start_time:'09:00',
// end_time:'17:30'
door: '',
room: ''
}
this.$refs['dialog'].reset()
}
@ -341,7 +387,8 @@
</script>
<style scoped lang="scss">
::v-deep .file_ids{
::v-deep .file_ids,
::v-deep .technical-field {
flex-basis: 100%;
}
</style>

Loading…
Cancel
Save