[update] 完善系统

This commit is contained in:
danshihao
2024-04-09 19:45:46 +08:00
parent 8d33b4532e
commit 46d9540b66
14 changed files with 449 additions and 58 deletions
@@ -50,7 +50,7 @@
size="middle"
bordered
rowKey="id"
:scroll="{x: true,y:200}"
:scroll="{x: true,y:280}"
:columns="userInfo.columns"
:dataSource="userInfo.dataSource"
:pagination="userInfo.ipagination"
@@ -61,9 +61,19 @@
<div class="table-text">{{ text || text === 0 ? text : global.emptyLine }}</div>
</a-tooltip>
</template>
<template slot="userType" slot-scope="text, record">
<a-tooltip>
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<div class="table-text"
:class="{
'tag-blue': record.userType === userType.admin.value,
'tag-cyan': record.userType === userType.common.value
}">{{ text || text === 0 ? text : global.emptyLine }}</div>
</a-tooltip>
</template>
<span slot="action" slot-scope="text, record, index" class="operation-btns">
<a class="primary" @click="handleChangeStatus(record, index)">编辑</a>
<a class="danger" @click="handleDelete(record, index)">删除</a>
<a class="primary" @click="handleEditUser(record, index)">编辑</a>
<a class="danger" @click="handleDeleteUser(record, index)">删除</a>
</span>
</a-table>
</common-card>
@@ -133,7 +143,7 @@
size="middle"
bordered
rowKey="id"
:scroll="{x: true,y:200}"
:scroll="{x: true,y:360}"
:columns="communicationLog.columns"
:dataSource="communicationLog.dataSource"
:pagination="communicationLog.ipagination"
@@ -152,20 +162,24 @@
</common-card>
</a-col>
</a-row>
<!-- 用户信息编辑 -->
<user-info-modal ref="userInfoModal" @ok="loadUserList"/>
</a-spin>
</template>
<script>
import CommonCard from '@comp/CommonCard'
import { addUserInfo, getSysSetting, getUserPage, saveSysSetting } from '@api/systemOverview'
import { dataAcquisitionCycle, dataAcquisitionProtocol } from '@/enums/commonEnums'
import { addUserInfo, delUserInfo, getSysSetting, getUserPage, saveSysSetting } from '@api/systemOverview'
import { dataAcquisitionCycle, dataAcquisitionProtocol, userType } from '@/enums/commonEnums'
import { getRSAPublicKey } from '@/utils/encryption'
import { JSEncrypt } from 'jsencrypt'
import UserInfoModal from '@views/systemOverview/systemSettings/modules/UserInfoModal'
export default {
name: 'SystemSettings',
components: { CommonCard },
components: { UserInfoModal, CommonCard },
data () {
return {
userType,
loading: false,
// 系统设置表单
sysSettingForm: this.$form.createForm(this),
@@ -210,11 +224,11 @@ export default {
scopedSlots: { customRender: 'text' }
},
{
dataIndex: 'roleTxt',
dataIndex: 'userType_dictText',
title: '用户类别',
align: 'center',
width: '20%',
scopedSlots: { customRender: 'text' }
scopedSlots: { customRender: 'userType' }
},
{
dataIndex: 'orgCodeTxt',
@@ -238,7 +252,7 @@ export default {
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' 共' + total + '条'
return '共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
@@ -254,28 +268,94 @@ export default {
communicationLog: {
columns: [
{
dataIndex: 'deviceStatus_dictText',
dataIndex: 'time',
title: '时间',
align: 'center',
width: '20%',
width: '30%',
scopedSlots: { customRender: 'text' }
},
{
dataIndex: 'deviceName',
dataIndex: 'msgType',
title: '消息类型',
align: 'center',
width: '20%',
width: '30%',
scopedSlots: { customRender: 'text' }
},
{
dataIndex: 'deviceSn',
dataIndex: 'msgContent',
title: '消息内容',
align: 'center',
width: '20%',
width: '40%',
scopedSlots: { customRender: 'text' }
}
],
dataSource: []
dataSource: [
{
id: '1',
time: '2024-3-15 13:55:26',
msgType: 'Host-》Device',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '2',
time: '2024-3-15 13:55:26',
msgType: 'Device-》Host',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '3',
time: '2024-3-15 13:55:26',
msgType: 'Host-》Device',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '4',
time: '2024-3-15 13:55:26',
msgType: 'Device-》Host',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '5',
time: '2024-3-15 13:55:26',
msgType: 'Host-》Device',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '6',
time: '2024-3-15 13:55:26',
msgType: 'Device-》Host',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '7',
time: '2024-3-15 13:55:26',
msgType: 'Host-》Device',
msgContent: '01 03 00 00 00 05 89 C5'
},
{
id: '8',
time: '2024-3-15 13:55:26',
msgType: 'Device-》Host',
msgContent: '01 03 00 00 00 05 89 C5'
}
],
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['1', '10', '20', '30'],
showTotal: (total, range) => {
return '共' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
/* 排序参数 */
isorter: {
column: 'createTime',
order: 'desc'
}
},
// 公钥
rsaPublicKey: '',
@@ -361,11 +441,12 @@ export default {
this.userInfo.loading = false
})
},
handleUserInfoTableChange () {
console.log()
handleUserInfoTableChange (pagination) {
this.userInfo.ipagination = pagination
this.loadUserList()
},
handleCommunicationLogTableChange () {
console.log()
handleCommunicationLogTableChange (pagination) {
this.communicationLog.ipagination = pagination
},
// 添加用户
async handleAddUser () {
@@ -406,6 +487,34 @@ export default {
} else {
callback(new Error('您的手机号码格式不正确'))
}
},
// 编辑用户
handleEditUser (record) {
// this.$refs.userInfoModal.edit(record)
},
// 删除用户
handleDeleteUser (record) {
const { id } = record
this.$confirm({
title: '确认删除',
content: '确定要删除此条数据吗?',
onOk: () => {
delUserInfo({ id }).then((res) => {
if (res.success) {
this.$message.success(res.message)
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
if (this.userInfo.ipagination.current > 1 && ((this.userInfo.ipagination.current - 1) * this.userInfo.ipagination.pageSize) + 1 === this.userInfo.ipagination.total) {
this.userInfo.ipagination.current -= 1
}
this.loadData()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loadUserList()
})
}
})
}
}
}