Commit 56b98c01 by 胡悦

字典管理相关接口完成、操作日志导出

1 parent e4d24655
......@@ -24,8 +24,8 @@
<el-table-column
v-if="hasNum"
align="center"
width="60px"
label="序号"
width="70px"
:label="tableParams.numName || '序号'"
type='index'
:index="index=>index+(page.pageNumber - 1) * page.pageSize + 1"
></el-table-column>
......
......@@ -16,6 +16,7 @@
v-model="formModel[item.prop]"
:type="item.inputType || 'text'"
:placeholder="item.placeholder || '请输入'"
:readonly="item.readonly || false"
></el-input>
</template>
<template v-else-if="item.type === 'select'">
......@@ -40,7 +41,7 @@
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd hh:mm:ss"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</template>
......
import axios from 'axios'
export const Common = {
// 提示框
confirmDialog: (tipData) => {
......@@ -11,5 +12,43 @@ export const Common = {
}).catch(() => {
tipData.errorCallBack ? tipData.errorCallBack() : ''
})
},
/**
* 导出excel
* */
exportExcel: function (options) {
if (!options) {
return false
}
console.log(options.data)
axios({
method: options.method || 'POST',
url: options.url,
params: options.data,
responseType: 'blob',
headers: {
Authorization: localStorage.getItem('token') || ''
}
}).then(response => {
if (!response) {
return
}
let url = window.URL.createObjectURL(new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
}))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', options.fileName || 'excel.xlsx')
document.body.appendChild(link)
link.click()
if (options.success) {
(options.success)()
}
}).catch((error) => {
if (options.errorFunc) {
(options.errorFunc)(error)
}
})
}
}
......@@ -32,8 +32,9 @@
<basic-table
:tableParams="tableParams"
:getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
:searchForm="searchForm"
:hasNum="false"
:hasNum="true"
ref="dictDataTable"
>
<span
......@@ -85,18 +86,21 @@ export default {
data() {
return {
DICTSTATUS: this.$Constants.DICT_STATUS,
searchForm: {},
searchForm: {
name: ''
},
dictDataFormList: [
{
type: 'input',
inputType: 'text',
prop: 'name',
readonly: true,
placeholder: '请输入字典名称'
},
{
type: 'input',
inputType: 'text',
prop: 'type',
prop: 'tag',
placeholder: '请输入字典标签'
},
{
......@@ -115,23 +119,24 @@ export default {
}
],
tableParams: {
numName: '字典编码',
mutiSelectName: 'dictDataData',
mutiSelectUniqueKey: 'id',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableColumns: [
{
label: '字典编码',
prop: 'id'
}, {
// label: '字典编码',
// prop: 'id'
// }, {
label: '字典标签',
prop: 'dictLabel'
}, {
label: '字典键值',
prop: 'dictType'
prop: 'dictValue'
}, {
label: '字典排序',
prop: 'remark'
prop: 'dictSort'
}, {
label: '备注',
prop: 'remark'
......@@ -145,7 +150,7 @@ export default {
}
],
tableOption: {
width: 300,
width: 200,
btnList: [
{
type: 'primary',
......@@ -168,28 +173,42 @@ export default {
enableStatus: true
},
dictDataData: [
{ label: '字典类型:', prop: 'dictType', type: 'input' },
{ label: '字典类型:', prop: 'dictType', type: 'input', readonly: true },
{ label: '字典标签:', prop: 'dictLabel', type: 'input' },
{ label: '字典编码:', prop: 'dictSort', type: 'input' },
// { label: '字典编码:', prop: 'id', type: 'input', readonly: true },
{ label: '字典键值:', prop: 'dictValue', type: 'input' },
{ label: '字典顺序:', prop: 'dictSort', type: 'input' },
{ label: '状态', prop: 'enableStatus', type: 'switch' },
{ label: '备注', prop: 'remark', type: 'input', inputText: 'textarea' }
],
dictDataRules: {
dictType: [{ required: true, message: '请输入字典类型', trigger: blur }],
dictLabel: [{ required: true, message: '请输入字典标签', trigger: blur }],
dictSort: [{ required: true, message: '请输入字典编码', trigger: blur }],
dictValue: [{ required: true, message: '请输入字典键值', trigger: blur }],
dictSort: [{ required: true, message: '请输入字典顺序', trigger: blur }],
dictType: [{ required: true }],
dictLabel: [{ required: true, message: '请输入字典标签', trigger: 'blur' }],
// id: [{ required: true }],
dictValue: [{ required: true, message: '请输入字典键值', trigger: 'blur' }],
dictSort: [{ required: true, message: '请输入字典顺序', trigger: 'blur' }],
enableStatus: [{ required: true }]
}
}
},
mounted() {
console.log(this.$route.params)
this.searchForm.name = this.$route.params.row.dictName
this.dictDataForm.dictType = this.$route.params.row.dictType
},
methods: {
// 重置搜索条件
refresh() {
this.searchForm = {}
this.searchForm = {
name: this.$route.params.row.dictName
}
},
beforeSearchFn() {
return new Promise((resolve, reject) => {
this.searchForm.type = this.$route.params.row.dictType
console.log(this.searchForm)
resolve()
})
},
// 确定
handleConfirm() {
......@@ -199,11 +218,21 @@ export default {
params.enableStatus = this.dictDataForm.enableStatus ? 1 : 2
console.log(params)
let api = addDictData
if (params.id) api = editDictData
if (params.id) {
api = editDictData
}
api(params).then(res => {
console.log(res)
this.handleClose()
this.$refs.dictDataTable.refreshTable()
if (res.code = 200) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.handleClose()
this.$refs.dictDataTable.refreshTable()
} else {
this.$message(res.message)
}
})
} else {
console.log('error')
......@@ -223,6 +252,7 @@ export default {
switch (pType) {
case 'create':
this.handleClose()
break
case 'edit':
this.editEvent(scope)
break
......@@ -237,8 +267,11 @@ export default {
// 编辑触发事件
editEvent(row) {
console.log(row, '------------')
this.dictDataForm = JSON.parse(JSON.stringify(row))
this.dictDataForm.enableStatus = row.enableStatus == 1 ? true : false
delete this.dictDataForm.createdDate
delete this.dictDataForm.isDefault
this.handleClose()
},
// 删除触发事件
......@@ -251,14 +284,19 @@ export default {
type: 'error',
callBack: () => {
const params = {
id: id
dataId: id
}
deleteDictData(params).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.dictDataTable.refreshTable()
if (res.code == 200) {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.dictDataTable.refreshTable()
} else {
this.$message(res.message)
}
})
}
}
......
......@@ -30,6 +30,7 @@
>新增</el-button>
</div>
<basic-table
ref="dictManage"
:tableParams="tableParams"
:getListApi="getListApi"
:searchForm="searchForm"
......@@ -103,18 +104,18 @@ export default {
placeholder: '请选择字典状态',
options: [
{
label: '正常',
label: '启用',
value: 1
}, {
label: '停用',
label: '禁用',
value: 2
}
]
}
],
tableParams: {
mutiSelectName: 'dictionary',
mutiSelectUniqueKey: 'id',
// mutiSelectName: 'dictionary',
// mutiSelectUniqueKey: 'id',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableColumns: [
......@@ -140,7 +141,7 @@ export default {
}
],
tableOption: {
width: 300,
width: 250,
btnList: [
{
type: 'primary',
......@@ -196,8 +197,16 @@ export default {
let api = addDict
if (params.id) api = editDict
api(params).then(res => {
console.log(res)
this.handleClose()
if (res.code == 200) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.$refs.dictManage.refreshTable()
this.handleClose()
} else {
this.$message(res.message)
}
})
} else {
console.log('error')
......@@ -216,16 +225,19 @@ export default {
console.log(pType, scope)
switch (pType) {
case 'create':
this.dictionaryDialogTitle = '新增字典'
this.handleClose()
break
case 'edit':
this.dictionaryDialogTitle = '编辑字典'
this.editEvent(scope)
break
case 'delete':
this.deleteEvent(scope.id)
break
case 'list':
console.log('list')
console.log('list', scope)
this.$router.push({ name: 'dictionaryData', params: { row: scope } })
break
}
},
......@@ -234,6 +246,7 @@ export default {
editEvent(row) {
this.dictionaryForm = JSON.parse(JSON.stringify(row))
this.dictionaryForm.enableStatus = row.enableStatus == 1 ? true : false
delete this.dictionaryForm.createdDate
this.handleClose()
},
// 删除触发事件
......@@ -246,13 +259,18 @@ export default {
type: 'error',
callBack: () => {
const params = {
id: id
typeId: id
}
deleteDict(params).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
if (res.code == 200) {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.dictManage.refreshTable()
} else {
this.$message(res.message)
}
})
}
......
......@@ -66,8 +66,8 @@
>
<div slot="visible-type">
<el-radio-group
@change="radioChange(roleForm.visibleType)"
v-model="roleForm.visibleType"
@change="radioChange(roleForm.roleVisibility)"
v-model="roleForm.roleVisibility"
>
<el-radio
v-for="(child,childIndex) in $Constants.ROLE_VISIBLE"
......@@ -76,9 +76,11 @@
>{{child}}{{childIndex}}</el-radio>
</el-radio-group>
<el-select
v-if="roleForm.visibleType == '2'"
v-model="roleForm.visibleTenant"
v-if="roleForm.roleVisibility == 2"
v-model="roleForm.roleTenants"
placeholder="请选择"
multiple
filterable
>
<el-option
v-for="i in tenantList"
......@@ -175,17 +177,15 @@ export default {
{ label: '角色名称:', prop: 'roleName', type: 'input' },
{ label: '备注:', prop: 'remark', type: 'input' },
{ label: '状态:', prop: 'enableStatus', type: 'switch' },
{ label: '租户可见度:', prop: 'visibleType', type: 'customize', slotName: 'visible-type' },
// { label: '租户可见度:', prop: 'visibleType', type: 'radio', hasSelect: true, children: this.$Constants.ROLE_VISIBLE },
{ label: '数据权限:', prop: 'permissionType', type: 'radio', children: this.$Constants.ROLE_AUTH },
// [{ id: 1, label: '本人' }, { id: 2, label: '本人及下属' }, { id: 3, label: '本部门' }, { id: 4, label: '本部门&下属' }, { id: 5, label: '全部' }]
{ label: '租户可见度:', prop: 'roleVisibility', type: 'customize', slotName: 'visible-type' },
{ label: '数据权限:', prop: 'rolePermissionType', type: 'radio', children: this.$Constants.ROLE_AUTH },
{ label: '菜单权限:', prop: 'menuIdList', type: 'customize', slotName: 'menu-list' }
],
roleRules: {
roleName: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
enableStatus: [{ required: true }],
visibleType: [{ required: true, message: '请选择租户可见度' }],
permissionType: [{ required: true, message: '请选择数据权限' }],
roleVisibility: [{ required: true, message: '请选择租户可见度' }],
rolePermissionType: [{ required: true, message: '请选择数据权限' }],
menuIdList: [{ required: true, validator: checkMenu, trigger: 'blur' }]
},
treedata: [],
......@@ -193,6 +193,7 @@ export default {
}
},
mounted() {
this.getTenantList()
},
methods: {
// 重置搜索条件
......@@ -205,13 +206,22 @@ export default {
console.log(this.roleForm)
this.$refs.roleForm.$children[0].validate((valid) => {
if (valid) {
let params = JSON.parse(JSON.stringify(this.roleForm))
params.enableStatus = this.roleForm.enableStatus ? 1 : 2
// let params = JSON.parse(JSON.stringify(this.roleForm))
let api = addRole
if (params.id) {
let params = {
remark: this.roleForm.remark,
roleName: this.roleForm.roleName,
menuIdList: this.roleForm.menuIdList
}
params.enableStatus = this.roleForm.enableStatus ? 1 : 2
if (this.roleForm.id) {
api = editRole
delete params.maxUser
if (params.roleVisibility != 2) delete params.roleTenants
params.roleId = this.roleForm.id
params.roleVisibility = Number(this.roleForm.roleVisibility)
params.rolePermissionType = Number(this.roleForm.rolePermissionType)
if (params.roleVisibility == 2) {
params.roleTenants = this.roleForm.roleTenants.toString()
}
}
console.log(params)
api(params).then(res => {
......@@ -248,7 +258,6 @@ export default {
menuIdList: []
}
this.getMenuTree()
this.getTenantList()
this.handleClose()
break
case 'edit':
......@@ -266,6 +275,9 @@ export default {
roleInfo({ id: row.id }).then(res => {
this.roleForm = JSON.parse(JSON.stringify(res.data))
this.roleForm.enableStatus = res.data.enableStatus == 1 ? true : false
this.roleForm.roleVisibility = res.data.roleVisibility + ''
this.roleForm.rolePermissionType = res.data.rolePermissionType + ''
this.roleForm.roleTenants = res.data.roleTenants.split(',').map(Number)
this.getMenuTree({ roleId: 1 })
this.handleClose(res.data)
})
......@@ -318,7 +330,7 @@ export default {
},
radioChange(e) {
console.log(e, this.roleForm)
this.$set(this.roleForm, 'visibleType', e)
this.$set(this.roleForm, 'roleVisibility', e)
}
}
}
......
......@@ -232,14 +232,14 @@ export default {
{ label: '岗位:', prop: 'position', type: 'select', options: [{ label: '12121', value: 0 }, { label: 'fasdfas', value: 1 }] }
],
userRules: {
account: [{ required: true, message: '请输入登录名称', trigger: blur }],
departmentName: [{ required: true, message: '请选择部门名称', trigger: blur }],
username: [{ required: true, message: '请输入用户名称', trigger: blur }],
password: [{ required: true, message: '请输入密码', trigger: blur }],
roleId: [{ required: true, message: '请选择角色', trigger: blur }],
phoneNumber: [{ required: true, message: '请输入手机号', trigger: blur }],
account: [{ required: true, message: '请输入登录名称', trigger: 'blur' }],
departmentName: [{ required: true, message: '请选择部门名称', trigger: 'blur' }],
username: [{ required: true, message: '请输入用户名称', trigger: 'blur' }],
roleId: [{ required: true, message: '请选择角色', trigger: 'change' }],
phoneNumber: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
enableStatus: [{ required: true }],
},
addRule: [{ required: true, message: '请输入密码', trigger: 'blur' }],
// 部门弹窗
filterDialogTitle: '选择组织',
filterVisible: false,
......@@ -319,6 +319,15 @@ export default {
this.getRoleList()
},
methods: {
emptyData(params) {
let arr = params
for (let key in arr) {
if (params[key] == null || params[key] == '' || params[key] == []) {
delete params[key]
}
}
return arr
},
// 重置搜索条件
refresh() {
this.searchForm = {}
......@@ -332,10 +341,12 @@ export default {
params.enableStatus = this.userForm.enableStatus ? 1 : 2
delete params.departmentName
delete params.superiorName
delete params.createdDate
this.emptyData(params)
let api = addUser
if (params.id) api = editUser
api(params).then(res => {
if (res.code = '200') {
if (res.code == '200') {
this.$refs.userTable.refreshTable()
this.handleClose()
this.$message({
......@@ -343,7 +354,6 @@ export default {
message: '操作成功!'
})
}
})
} else {
console.log('error')
......@@ -377,15 +387,18 @@ export default {
switch (pType) {
case 'create':
this.userDialogTitle = '新增用户'
this.userRules.password = this.addRule
this.userForm = {
departmentName: '',
superiorName: '',
enableStatus: true
}
this.handleClose()
break
case 'edit':
this.userDialogTitle = '编辑用户'
if (this.userRules.password) delete this.userRules.password
this.editEvent(scope)
break
case 'delete':
......@@ -400,6 +413,7 @@ export default {
this.userDialogTitle = '编辑用户'
this.userForm = JSON.parse(JSON.stringify(res.data))
this.userForm.enableStatus = res.data.enableStatus == 1 ? true : false
console.log(this.userForm)
this.handleClose(res.data)
})
......
......@@ -36,7 +36,7 @@
:searchForm="searchDataForm"
:hasNum="false"
>
<span
<!-- <span
slot="status"
slot-scope="scope"
>
......@@ -46,28 +46,14 @@
>
{{scope.scope.operStatus ? WORKLOGSTATUS[scope.scope.operStatus].split(',')[0] : '--'}}
</span>
</span>
</span> -->
</basic-table>
<basic-dialog
:title="worklogDialogTitle"
:isVisible="worklogVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot>
<rule-form
:ruleForm="worklogForm"
:rules="worklogRules"
:ruleData="worklogData"
ref='worklogForm'
></rule-form>
</slot>
</basic-dialog>
</div>
</div>
</template>
<script>
import { WORKLOG_API } from '@/config/config'
import { getWorkLogList, exportWorkLog } from 'services/worklog';
export default {
data() {
......@@ -83,8 +69,8 @@ export default {
}
],
tableParams: {
mutiSelectName: 'worklog',
mutiSelectUniqueKey: 'id',
// mutiSelectName: 'worklog',
// mutiSelectUniqueKey: 'id',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableColumns: [
......@@ -108,26 +94,15 @@ export default {
prop: 'ip',
}, {
label: '操作状态',
prop: 'operStatus',
addHtml: 'status'
prop: 'result',
// addHtml: 'status'
}, {
label: '创建时间',
prop: 'createdDate'
}
]
},
getListApi: getWorkLogList,
// 弹窗
worklogDialogTitle: '新增字典',
worklogVisible: false,
worklogForm: {},
worklogData: [
{ label: '字典名称:', prop: 'dictName', type: 'input' },
{ label: '字典类型', prop: 'dictType', type: 'input' },
{ label: '状态', prop: 'enableStatus', type: 'switch' },
{ label: '备注', prop: 'remark', type: 'input', inputText: 'textarea' }
],
worklogRules: {}
getListApi: getWorkLogList
}
},
methods: {
......@@ -135,72 +110,27 @@ export default {
this.searchForm = {}
this.searchDataForm = {}
},
// 按钮事件
btnClick(pType, scope) {
console.log(pType, scope)
switch (pType) {
case 'edit':
this.handleClose(scope)
break
case 'delete':
this.deleteEvent(scope.id)
break
case 'list':
console.log('list')
break
}
},
beforeSearchFn() {
return new Promise((resolve, reject) => {
console.log(this.searchForm)
if (this.searchForm.daterange) this.searchDataForm.sDate = this.searchForm.daterange[0]
if (this.searchForm.daterange) this.searchDataForm.eDate = this.searchForm.daterange[1]
resolve()
})
},
// 确定
handleConfirm() {
console.log(this.$refs.worklogForm)
this.$refs.worklogForm.$children[0].validate((valid) => {
if (valid) {
this.handleClose()
if (this.searchForm.daterange) {
this.searchDataForm.sDate = this.searchForm.daterange[0]
this.searchDataForm.eDate = this.searchForm.daterange[1]
} else {
console.log('error')
if (this.searchDataForm.sDate) delete this.searchDataForm.sDate && delete this.searchDataForm.eDate
}
resolve()
})
},
// 取消
handleClose(row) {
console.log(row)
if (!this.worklogVisible && this.$refs.worklogForm) {
this.$refs.worklogForm.$children[0].resetFields()
}
this.worklogVisible = !this.worklogVisible
},
// 删除触发事件
deleteEvent(id) {
const that = this
const tipData = {
that: that,
tipText: '是否删除当前记录',
tipTitle: '提示',
type: 'error',
callBack: () => {
this.$message({
type: 'success',
message: '删除成功!'
})
}
}
this.$Common.confirmDialog(tipData)
},
// 导出列表
exportTable() {
console.log(this.$refs.worklogTable)
const params = this.$refs.worklogTable.page
exportWorkLog(params).then(res => {
this.$Common.exportExcel({
url: WORKLOG_API.WORKLOG_EXPORT,
data: params,
method: 'GET',
fileName: '操作日志.xlsx'
})
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!