init commit & 混料程序模块
This commit is contained in:
155
src/views/modules/sys/dept-add-or-update.vue
Normal file
155
src/views/modules/sys/dept-add-or-update.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
|
||||
<el-form-item prop="name" :label="$t('dept.name')">
|
||||
<el-input v-model="dataForm.name" :placeholder="$t('dept.name')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="parentName" :label="$t('dept.parentName')" class="dept-list">
|
||||
<el-popover v-model="deptListVisible" ref="deptListPopover" placement="bottom-start" trigger="click">
|
||||
<el-tree
|
||||
:data="deptList"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
node-key="id"
|
||||
ref="deptListTree"
|
||||
:highlight-current="true"
|
||||
:expand-on-click-node="false"
|
||||
accordion
|
||||
@current-change="deptListTreeCurrentChangeHandle">
|
||||
</el-tree>
|
||||
</el-popover>
|
||||
<el-input v-model="dataForm.parentName" v-popover:deptListPopover :readonly="true" :placeholder="$t('dept.parentName')">
|
||||
<i
|
||||
v-if="$store.state.user.superAdmin === 1 && dataForm.pid !== '0'"
|
||||
slot="suffix"
|
||||
@click.stop="deptListTreeSetDefaultHandle()"
|
||||
class="el-icon-circle-close el-input__icon">
|
||||
</i>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sort" :label="$t('dept.sort')">
|
||||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" :label="$t('dept.sort')"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/dept/',
|
||||
infoURL: '/sys/dept'
|
||||
},
|
||||
visible: false,
|
||||
deptList: [],
|
||||
deptListVisible: false,
|
||||
dataForm: {
|
||||
id: '',
|
||||
name: '',
|
||||
pid: '',
|
||||
parentName: '',
|
||||
sort: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
parentName: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.getDeptList().then(() => {
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
} else if (this.$store.state.user.superAdmin === 1) {
|
||||
this.deptListTreeSetDefaultHandle()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取部门列表
|
||||
getDeptList () {
|
||||
return this.$http.get('/sys/dept/list').then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.deptList = res.data
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/dept/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
if (this.dataForm.pid === '0') {
|
||||
return this.deptListTreeSetDefaultHandle()
|
||||
}
|
||||
this.$refs.deptListTree.setCurrentKey(this.dataForm.pid)
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 上级部门树, 设置默认值
|
||||
deptListTreeSetDefaultHandle () {
|
||||
this.dataForm.pid = '0'
|
||||
this.dataForm.parentName = this.$t('dept.parentNameDefault')
|
||||
},
|
||||
// 上级部门树, 选中
|
||||
deptListTreeCurrentChangeHandle (data) {
|
||||
this.dataForm.pid = data.id
|
||||
this.dataForm.parentName = data.name
|
||||
this.deptListVisible = false
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dept', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.mod-sys__dept {
|
||||
.dept-list {
|
||||
.el-input__inner,
|
||||
.el-input__suffix {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
119
src/views/modules/sys/dept.vue
Normal file
119
src/views/modules/sys/dept.vue
Normal file
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 14:32:59
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__dept">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
row-key="id"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from "./dept-add-or-update";
|
||||
import i18n from "@/i18n";
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "name",
|
||||
label: i18n.t("dept.name"),
|
||||
},
|
||||
{
|
||||
prop: "parentName",
|
||||
label: i18n.t("dept.parentName"),
|
||||
},
|
||||
{
|
||||
prop: "sort",
|
||||
label: i18n.t("dept.sort"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/dept/list",
|
||||
deleteURL: "/sys/dept",
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
this.$http
|
||||
.get(this.urlOptions.getDataListURL, {
|
||||
params: this.listQuery,
|
||||
})
|
||||
.then(({ data: res }) => {
|
||||
this.dataListLoading = false;
|
||||
if (res.code !== 0) {
|
||||
this.tableData = [];
|
||||
this.listQuery.total = 0;
|
||||
return this.$message.error(res.msg);
|
||||
}
|
||||
this.tableData = res.data;
|
||||
this.listQuery.total = res.data.total;
|
||||
})
|
||||
.catch(() => {
|
||||
this.dataListLoading = false;
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
103
src/views/modules/sys/dict-data-add-or-update.vue
Normal file
103
src/views/modules/sys/dict-data-add-or-update.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
|
||||
<el-form-item prop="dictValue" :label="$t('dict.dictValue')">
|
||||
<el-input v-model="dataForm.dictValue" :placeholder="$t('dict.dictValue')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="dictLabel" :label="$t('dict.dictLabel')">
|
||||
<el-input v-model="dataForm.dictLabel" :placeholder="$t('dict.dictLabel')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sort" :label="$t('dict.sort')">
|
||||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" :label="$t('dict.sort')"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="remark" :label="$t('dict.remark')">
|
||||
<el-input v-model="dataForm.remark" :placeholder="$t('dict.remark')"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/dict/data/',
|
||||
infoURL: '/sys/dict/data'
|
||||
},
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: '',
|
||||
dictTypeId: '',
|
||||
dictLabel: '',
|
||||
dictValue: '',
|
||||
sort: 0,
|
||||
remark: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
dictLabel: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
dictValue: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
sort: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id,dictTypeId) {
|
||||
this.dataForm.id = id || "";
|
||||
this.dataForm.dictTypeId = dictTypeId || "";
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/dict/data/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmitHandle: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dict/data', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
150
src/views/modules/sys/dict-data.vue
Normal file
150
src/views/modules/sys/dict-data.vue
Normal file
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from './dict-data-add-or-update'
|
||||
import i18n from "@/i18n";
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "dictValue",
|
||||
label: i18n.t("dict.dictValue"),
|
||||
},
|
||||
{
|
||||
prop: "dictLabel",
|
||||
label: i18n.t("dict.dictLabel"),
|
||||
},
|
||||
{
|
||||
prop: "sort",
|
||||
label: i18n.t("dict.sort"),
|
||||
},
|
||||
{
|
||||
prop: "remark",
|
||||
label: i18n.t("dict.remark"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("dict.createDate"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/dict/data/page",
|
||||
deleteURL: "/sys/dict/data",
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("dict.dictValue"),
|
||||
placeholder: i18n.t("dict.dictValue"),
|
||||
param: "dictValue",
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("dict.dictLabel"),
|
||||
placeholder: i18n.t("dict.dictLabel"),
|
||||
param: "dictLabel",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
created () {
|
||||
this.listQuery.dictTypeId = this.$route.params.dictTypeId || '0'
|
||||
this.getDataList()
|
||||
},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.dictValue = val.dictValue;
|
||||
this.listQuery.dictLabel = val.dictLabel;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id,this.listQuery.dictTypeId)
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
101
src/views/modules/sys/dict-type-add-or-update.vue
Normal file
101
src/views/modules/sys/dict-type-add-or-update.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
|
||||
<el-form-item prop="dictName" :label="$t('dict.dictName')">
|
||||
<el-input v-model="dataForm.dictName" :placeholder="$t('dict.dictName')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="dictType" :label="$t('dict.dictType')">
|
||||
<el-input v-model="dataForm.dictType" :placeholder="$t('dict.dictType')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sort" :label="$t('dict.sort')">
|
||||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" :label="$t('dict.sort')"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="remark" :label="$t('dict.remark')">
|
||||
<el-input v-model="dataForm.remark" :placeholder="$t('dict.remark')"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/dict/type/',
|
||||
infoURL: '/sys/dict/type'
|
||||
},
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: '',
|
||||
dictName: '',
|
||||
dictType: '',
|
||||
sort: 0,
|
||||
remark: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
dictName: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
dictType: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
sort: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/dict/type/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmitHandle: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dict/type', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
33
src/views/modules/sys/dict-type-to.vue
Normal file
33
src/views/modules/sys/dict-type-to.vue
Normal file
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<span>
|
||||
<el-button type="text" size="small" @click="emitClick">{{ injectData.dictType }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addDynamicRoute } from '@/router'
|
||||
export default {
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 子级
|
||||
emitClick () {
|
||||
// 路由参数
|
||||
const routeParams = {
|
||||
routeName: `${this.$route.name}__${this.injectData.id}`,
|
||||
title: `${this.$route.meta.title} - ${this.injectData.dictType}`,
|
||||
path: 'sys/dict-data',
|
||||
params: {
|
||||
dictTypeId: this.injectData.id
|
||||
}
|
||||
}
|
||||
// 动态路由
|
||||
addDynamicRoute(routeParams, this.$router)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
141
src/views/modules/sys/dict-type.vue
Normal file
141
src/views/modules/sys/dict-type.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from './dict-type-add-or-update'
|
||||
import toDictType from './dict-type-to'
|
||||
import i18n from "@/i18n";
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "dictName",
|
||||
label: i18n.t("dict.dictName"),
|
||||
},
|
||||
{
|
||||
prop: "dictType",
|
||||
label: i18n.t("dict.dictType"),
|
||||
subcomponent: toDictType
|
||||
},
|
||||
{
|
||||
prop: "sort",
|
||||
label: i18n.t("dict.sort"),
|
||||
},
|
||||
{
|
||||
prop: "remark",
|
||||
label: i18n.t("dict.remark"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("dict.createDate"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/dict/type/page",
|
||||
deleteURL: "/sys/dict/type",
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("dict.dictName"),
|
||||
placeholder: i18n.t("dict.dictName"),
|
||||
param: "dictName",
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("dict.dictType"),
|
||||
placeholder: i18n.t("dict.dictType"),
|
||||
param: "dictType",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.dictName = val.dictName;
|
||||
this.listQuery.dictType = val.dictType;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
99
src/views/modules/sys/log-error.vue
Normal file
99
src/views/modules/sys/log-error.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 15:29:06
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
/>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import i18n from "@/i18n";
|
||||
import Cookies from 'js-cookie'
|
||||
import qs from 'qs'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "requestUri",
|
||||
label: i18n.t("logError.requestUri"),
|
||||
},
|
||||
{
|
||||
prop: "requestMethod",
|
||||
label: i18n.t("logError.requestMethod"),
|
||||
},
|
||||
{
|
||||
prop: "requestParams",
|
||||
label: i18n.t("logError.requestParams"),
|
||||
},
|
||||
{
|
||||
prop: "ip",
|
||||
label: i18n.t("logError.ip"),
|
||||
},
|
||||
{
|
||||
prop: "userAgent",
|
||||
label: i18n.t("logError.userAgent"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("logError.createDate"),
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/log/error/page",
|
||||
exportUrl: "/sys/log/error/export",
|
||||
},
|
||||
tableProps,
|
||||
formConfig: [
|
||||
{
|
||||
type: "button",
|
||||
btnName: "导出",
|
||||
name: "export",
|
||||
color: "primary",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "export":
|
||||
this.exportHandle();
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
// 导出
|
||||
exportHandle () {
|
||||
var params = qs.stringify({
|
||||
'token': Cookies.get('token')
|
||||
})
|
||||
window.location.href = `${window.SITE_CONFIG['apiURL']}${this.urlOptions.exportURL}?${params}`
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
121
src/views/modules/sys/log-login.vue
Normal file
121
src/views/modules/sys/log-login.vue
Normal file
@@ -0,0 +1,121 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 15:49:17
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
/>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import i18n from "@/i18n";
|
||||
import sysFilter from '@/filters/sys-filter'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "creatorName",
|
||||
label: i18n.t("logLogin.creatorName"),
|
||||
},
|
||||
{
|
||||
prop: "operation",
|
||||
label: i18n.t("logLogin.operation"),
|
||||
filter: sysFilter('logOperation'),
|
||||
},
|
||||
{
|
||||
prop: "status",
|
||||
label: i18n.t("logLogin.status"),
|
||||
filter: sysFilter('logStatus'),
|
||||
},
|
||||
{
|
||||
prop: "ip",
|
||||
label: i18n.t("logLogin.ip"),
|
||||
},
|
||||
{
|
||||
prop: "userAgent",
|
||||
label: i18n.t("logLogin.userAgent"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("logLogin.createDate"),
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/log/login/page",
|
||||
deleteURL: "/sys/log/login",
|
||||
exportUrl: "/sys/log/login/export",
|
||||
},
|
||||
tableProps,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("logLogin.creatorName"),
|
||||
placeholder: i18n.t("logLogin.creatorName"),
|
||||
param: "creatorName",
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
label: "状态",
|
||||
selectOptions: [
|
||||
{ id: "0", name: i18n.t("logLogin.status0") },
|
||||
{ id: "1", name: i18n.t("logLogin.status1") },
|
||||
{ id: "2", name: i18n.t("logLogin.status2") },
|
||||
],
|
||||
param: "status",
|
||||
defaultSelect: "",
|
||||
onchange: true,
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.creatorName = val.creatorName;
|
||||
this.listQuery.status = val.status;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
127
src/views/modules/sys/log-operation.vue
Normal file
127
src/views/modules/sys/log-operation.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 15:50:27
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
/>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import i18n from "@/i18n";
|
||||
import sysFilter from '@/filters/sys-filter'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "creatorName",
|
||||
label: i18n.t("logOperation.creatorName"),
|
||||
},
|
||||
{
|
||||
prop: "operation",
|
||||
label: i18n.t("logOperation.operation"),
|
||||
},
|
||||
{
|
||||
prop: "requestUri",
|
||||
label: i18n.t("logOperation.requestUri"),
|
||||
},
|
||||
{
|
||||
prop: "requestMethod",
|
||||
label: i18n.t("logOperation.requestMethod"),
|
||||
},
|
||||
{
|
||||
prop: "requestParams",
|
||||
label: i18n.t("logOperation.requestParams"),
|
||||
},
|
||||
{
|
||||
prop: "requestTime",
|
||||
label: i18n.t("logOperation.requestTime"),
|
||||
},
|
||||
{
|
||||
prop: "status",
|
||||
label: i18n.t("logOperation.status"),
|
||||
filter: sysFilter('logStatus'),
|
||||
},
|
||||
{
|
||||
prop: "ip",
|
||||
label: i18n.t("logOperation.ip"),
|
||||
},
|
||||
{
|
||||
prop: "userAgent",
|
||||
label: i18n.t("logOperation.userAgent"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("logOperation.createDate"),
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/log/operation/page",
|
||||
exportUrl: "/sys/log/operation/export",
|
||||
},
|
||||
tableProps,
|
||||
formConfig: [
|
||||
{
|
||||
type: "select",
|
||||
label: "状态",
|
||||
selectOptions: [
|
||||
{ id: "0", name: i18n.t("logOperation.status0") },
|
||||
{ id: "1", name: i18n.t("logOperation.status1") },
|
||||
],
|
||||
param: "status",
|
||||
defaultSelect: "",
|
||||
onchange: true,
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.status = val.status;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
222
src/views/modules/sys/menu-add-or-update.vue
Normal file
222
src/views/modules/sys/menu-add-or-update.vue
Normal file
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
|
||||
<el-form-item prop="type" :label="$t('menu.type')" size="mini">
|
||||
<el-radio-group v-model="dataForm.type" :disabled="!!dataForm.id">
|
||||
<el-radio :label="0">{{ $t('menu.type0') }}</el-radio>
|
||||
<el-radio :label="1">{{ $t('menu.type1') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item prop="name" :label="$t('menu.name')">
|
||||
<el-input v-model="dataForm.name" :placeholder="$t('menu.name')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="parentName" :label="$t('menu.parentName')" class="menu-list">
|
||||
<el-popover v-model="menuListVisible" ref="menuListPopover" placement="bottom-start" trigger="click">
|
||||
<el-tree
|
||||
:data="menuList"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
node-key="id"
|
||||
ref="menuListTree"
|
||||
:highlight-current="true"
|
||||
:expand-on-click-node="false"
|
||||
accordion
|
||||
@current-change="menuListTreeCurrentChangeHandle">
|
||||
</el-tree>
|
||||
</el-popover>
|
||||
<el-input v-model="dataForm.parentName" v-popover:menuListPopover :readonly="true" :placeholder="$t('menu.parentName')">
|
||||
<i v-if="dataForm.pid !== '0'" slot="suffix" @click.stop="deptListTreeSetDefaultHandle()" class="el-icon-circle-close el-input__icon"></i>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dataForm.type === 0" prop="url" :label="$t('menu.url')">
|
||||
<el-input v-model="dataForm.url" :placeholder="$t('menu.url')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sort" :label="$t('menu.sort')">
|
||||
<el-input-number v-model="dataForm.sort" controls-position="right" :min="0" :label="$t('menu.sort')"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="permissions" :label="$t('menu.permissions')">
|
||||
<el-input v-model="dataForm.permissions" :placeholder="$t('menu.permissionsTips')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dataForm.type === 0" prop="icon" :label="$t('menu.icon')" class="icon-list">
|
||||
<el-popover v-model="iconListVisible" ref="iconListPopover" placement="bottom-start" trigger="click" popper-class="mod-sys__menu-icon-popover">
|
||||
<div class="mod-sys__menu-icon-inner">
|
||||
<div class="mod-sys__menu-icon-list">
|
||||
<el-button
|
||||
v-for="(item, index) in iconList"
|
||||
:key="index"
|
||||
@click="iconListCurrentChangeHandle(item)"
|
||||
:class="{ 'is-active': dataForm.icon === item }">
|
||||
<svg class="icon-svg" aria-hidden="true"><use :xlink:href="`#${item}`"></use></svg>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
<el-input v-model="dataForm.icon" v-popover:iconListPopover :readonly="true" :placeholder="$t('menu.icon')"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import { getIconList } from '@/utils'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/menu/',
|
||||
infoURL: '/sys/menu'
|
||||
},
|
||||
visible: false,
|
||||
menuList: [],
|
||||
menuListVisible: false,
|
||||
iconList: [],
|
||||
iconListVisible: false,
|
||||
dataForm: {
|
||||
id: '',
|
||||
type: 0,
|
||||
name: '',
|
||||
pid: '0',
|
||||
parentName: '',
|
||||
url: '',
|
||||
permissions: '',
|
||||
sort: 0,
|
||||
icon: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
parentName: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'dataForm.type' (val) {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.iconList = getIconList()
|
||||
this.dataForm.parentName = this.$t('menu.parentNameDefault')
|
||||
this.getMenuList().then(() => {
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取菜单列表
|
||||
getMenuList () {
|
||||
return this.$http.get('/sys/menu/list?type=0').then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.menuList = res.data
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/menu/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
if (this.dataForm.pid === '0') {
|
||||
return this.deptListTreeSetDefaultHandle()
|
||||
}
|
||||
this.$refs.menuListTree.setCurrentKey(this.dataForm.pid)
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 上级菜单树, 设置默认值
|
||||
deptListTreeSetDefaultHandle () {
|
||||
this.dataForm.pid = '0'
|
||||
this.dataForm.parentName = this.$t('menu.parentNameDefault')
|
||||
},
|
||||
// 上级菜单树, 选中
|
||||
menuListTreeCurrentChangeHandle (data) {
|
||||
this.dataForm.pid = data.id
|
||||
this.dataForm.parentName = data.name
|
||||
this.menuListVisible = false
|
||||
},
|
||||
// 图标, 选中
|
||||
iconListCurrentChangeHandle (icon) {
|
||||
this.dataForm.icon = icon
|
||||
this.iconListVisible = false
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmitHandle: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/menu', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.mod-sys__menu {
|
||||
.menu-list,
|
||||
.icon-list {
|
||||
.el-input__inner,
|
||||
.el-input__suffix {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
&-icon-popover {
|
||||
width: 458px;
|
||||
overflow: hidden;
|
||||
}
|
||||
&-icon-inner {
|
||||
width: 478px;
|
||||
max-height: 258px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
&-icon-list {
|
||||
width: 458px;
|
||||
padding: 0;
|
||||
margin: -8px 0 0 -8px;
|
||||
> .el-button {
|
||||
padding: 8px;
|
||||
margin: 8px 0 0 8px;
|
||||
> span {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
133
src/views/modules/sys/menu.vue
Normal file
133
src/views/modules/sys/menu.vue
Normal file
@@ -0,0 +1,133 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 15:47:14
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__dept">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
row-key="id"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from './menu-add-or-update'
|
||||
import i18n from "@/i18n";
|
||||
import sysFilter from '@/filters/sys-filter'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "name",
|
||||
label: i18n.t("menu.name"),
|
||||
},
|
||||
{
|
||||
prop: "icon",
|
||||
label: i18n.t("menu.icon"),
|
||||
},
|
||||
{
|
||||
prop: "type",
|
||||
label: i18n.t("menu.type"),
|
||||
filter: sysFilter('menuType'),
|
||||
},
|
||||
{
|
||||
prop: "sort",
|
||||
label: i18n.t("menu.sort"),
|
||||
},
|
||||
{
|
||||
prop: "url",
|
||||
label: i18n.t("menu.url"),
|
||||
},
|
||||
{
|
||||
prop: "permissions",
|
||||
label: i18n.t("menu.permissions"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: '/sys/menu/list',
|
||||
deleteURL: '/sys/menu'
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
this.$http
|
||||
.get(this.urlOptions.getDataListURL, {
|
||||
params: this.listQuery,
|
||||
})
|
||||
.then(({ data: res }) => {
|
||||
this.dataListLoading = false;
|
||||
if (res.code !== 0) {
|
||||
this.tableData = [];
|
||||
this.listQuery.total = 0;
|
||||
return this.$message.error(res.msg);
|
||||
}
|
||||
this.tableData = res.data;
|
||||
this.listQuery.total = res.data.total;
|
||||
})
|
||||
.catch(() => {
|
||||
this.dataListLoading = false;
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
101
src/views/modules/sys/params-add-or-update.vue
Normal file
101
src/views/modules/sys/params-add-or-update.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-01-04 10:29:40
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2023-01-05 14:40:11
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
|
||||
<el-form-item prop="paramCode" :label="$t('params.paramCode')">
|
||||
<el-input v-model="dataForm.paramCode" :placeholder="$t('params.paramCode')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="paramValue" :label="$t('params.paramValue')">
|
||||
<el-input v-model="dataForm.paramValue" :placeholder="$t('params.paramValue')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="remark" :label="$t('params.remark')">
|
||||
<el-input v-model="dataForm.remark" :placeholder="$t('params.remark')"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/params/',
|
||||
infoURL: '/sys/params'
|
||||
},
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: '',
|
||||
paramCode: '',
|
||||
paramValue: '',
|
||||
remark: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
paramCode: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
paramValue: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/params/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmitHandle: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/params', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
124
src/views/modules/sys/params.vue
Normal file
124
src/views/modules/sys/params.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from './params-add-or-update'
|
||||
import i18n from "@/i18n";
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "paramCode",
|
||||
label: i18n.t("params.paramCode"),
|
||||
},
|
||||
{
|
||||
prop: "paramValue",
|
||||
label: i18n.t("params.paramValue"),
|
||||
},
|
||||
{
|
||||
prop: "remark",
|
||||
label: i18n.t("params.remark"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/params/page",
|
||||
deleteURL: "/sys/params",
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("params.paramCode"),
|
||||
placeholder: i18n.t("params.paramCode"),
|
||||
param: "paramCode",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.paramCode = val.paramCode;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
148
src/views/modules/sys/role-add-or-update.vue
Normal file
148
src/views/modules/sys/role-add-or-update.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
|
||||
<el-form-item prop="name" :label="$t('role.name')">
|
||||
<el-input v-model="dataForm.name" :placeholder="$t('role.name')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="remark" :label="$t('role.remark')">
|
||||
<el-input v-model="dataForm.remark" :placeholder="$t('role.remark')"></el-input>
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item size="mini" :label="$t('role.menuList')">
|
||||
<el-tree
|
||||
:data="menuList"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
node-key="id"
|
||||
ref="menuListTree"
|
||||
accordion
|
||||
show-checkbox>
|
||||
</el-tree>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item size="mini" :label="$t('role.deptList')">
|
||||
<el-tree
|
||||
:data="deptList"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
node-key="id"
|
||||
ref="deptListTree"
|
||||
accordion
|
||||
show-checkbox>
|
||||
</el-tree>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/role/',
|
||||
infoURL: '/sys/role'
|
||||
},
|
||||
visible: false,
|
||||
menuList: [],
|
||||
deptList: [],
|
||||
dataForm: {
|
||||
id: '',
|
||||
name: '',
|
||||
menuIdList: [],
|
||||
deptIdList: [],
|
||||
remark: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
return {
|
||||
name: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.$refs.menuListTree.setCheckedKeys([])
|
||||
this.$refs.deptListTree.setCheckedKeys([])
|
||||
Promise.all([
|
||||
this.getMenuList(),
|
||||
this.getDeptList()
|
||||
]).then(() => {
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取菜单列表
|
||||
getMenuList () {
|
||||
return this.$http.get('/sys/menu/select').then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.menuList = res.data
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 获取部门列表
|
||||
getDeptList () {
|
||||
return this.$http.get('/sys/dept/list').then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.deptList = res.data
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/role/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data
|
||||
}
|
||||
this.dataForm.menuIdList.forEach(item => this.$refs.menuListTree.setChecked(item, true))
|
||||
this.$refs.deptListTree.setCheckedKeys(this.dataForm.deptIdList)
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmitHandle: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.dataForm.menuIdList = [
|
||||
...this.$refs.menuListTree.getHalfCheckedKeys(),
|
||||
...this.$refs.menuListTree.getCheckedKeys()
|
||||
]
|
||||
this.dataForm.deptIdList = this.$refs.deptListTree.getCheckedKeys()
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/role', this.dataForm).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
124
src/views/modules/sys/role.vue
Normal file
124
src/views/modules/sys/role.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from './role-add-or-update'
|
||||
import i18n from "@/i18n";
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "name",
|
||||
label: i18n.t("role.name"),
|
||||
},
|
||||
{
|
||||
prop: "remark",
|
||||
label: i18n.t("role.remark"),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("role.createDate"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: '/sys/role/page',
|
||||
deleteURL: '/sys/role',
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("role.name"),
|
||||
placeholder: i18n.t("role.name"),
|
||||
param: "name",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.name = val.name;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
213
src/views/modules/sys/user-add-or-update.vue
Normal file
213
src/views/modules/sys/user-add-or-update.vue
Normal file
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
|
||||
<el-form-item prop="username" :label="$t('user.username')">
|
||||
<el-input v-model="dataForm.username" :placeholder="$t('user.username')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="deptName" :label="$t('user.deptName')">
|
||||
<ren-dept-tree v-model="dataForm.deptId" :placeholder="$t('dept.title')" :dept-name.sync="dataForm.deptName"></ren-dept-tree>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password" :label="$t('user.password')" :class="{ 'is-required': !dataForm.id }">
|
||||
<el-input v-model="dataForm.password" type="password" :placeholder="$t('user.password')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="confirmPassword" :label="$t('user.confirmPassword')" :class="{ 'is-required': !dataForm.id }">
|
||||
<el-input v-model="dataForm.confirmPassword" type="password" :placeholder="$t('user.confirmPassword')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="realName" :label="$t('user.realName')">
|
||||
<el-input v-model="dataForm.realName" :placeholder="$t('user.realName')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="gender" :label="$t('user.gender')">
|
||||
<ren-radio-group v-model="dataForm.gender" dict-type="gender"></ren-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item prop="email" :label="$t('user.email')">
|
||||
<el-input v-model="dataForm.email" :placeholder="$t('user.email')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="mobile" :label="$t('user.mobile')">
|
||||
<el-input v-model="dataForm.mobile" :placeholder="$t('user.mobile')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="roleIdList" :label="$t('user.roleIdList')" class="role-list">
|
||||
<el-select v-model="dataForm.roleIdList" multiple :placeholder="$t('user.roleIdList')">
|
||||
<el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="status" :label="$t('user.status')" size="mini">
|
||||
<el-radio-group v-model="dataForm.status">
|
||||
<el-radio :label="0">{{ $t('user.status0') }}</el-radio>
|
||||
<el-radio :label="1">{{ $t('user.status1') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import { isEmail, isMobile } from '@/utils/validate'
|
||||
import basicAdd from '@/mixins/basic-add'
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data () {
|
||||
return {
|
||||
urlOptions: {
|
||||
submitURL: '/sys/user/',
|
||||
infoURL: '/sys/user'
|
||||
},
|
||||
visible: false,
|
||||
roleList: [],
|
||||
roleIdListDefault: [],
|
||||
dataForm: {
|
||||
id: '',
|
||||
username: '',
|
||||
deptId: '',
|
||||
deptName: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
realName: '',
|
||||
gender: 0,
|
||||
email: '',
|
||||
mobile: '',
|
||||
roleIdList: [],
|
||||
status: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataRule () {
|
||||
var validatePassword = (rule, value, callback) => {
|
||||
if (!this.dataForm.id && !/\S/.test(value)) {
|
||||
return callback(new Error(this.$t('validate.required')))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
var validateConfirmPassword = (rule, value, callback) => {
|
||||
if (!this.dataForm.id && !/\S/.test(value)) {
|
||||
return callback(new Error(this.$t('validate.required')))
|
||||
}
|
||||
if (this.dataForm.password !== value) {
|
||||
return callback(new Error(this.$t('user.validate.confirmPassword')))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
var validateEmail = (rule, value, callback) => {
|
||||
if (value && !isEmail(value)) {
|
||||
return callback(new Error(this.$t('validate.format', { 'attr': this.$t('user.email') })))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
var validateMobile = (rule, value, callback) => {
|
||||
if (value && !isMobile(value)) {
|
||||
return callback(new Error(this.$t('validate.format', { 'attr': this.$t('user.mobile') })))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
return {
|
||||
username: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
deptName: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
||||
],
|
||||
password: [
|
||||
{ validator: validatePassword, trigger: 'blur' }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ validator: validateConfirmPassword, trigger: 'blur' }
|
||||
],
|
||||
realName: [
|
||||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
||||
],
|
||||
email: [
|
||||
{ validator: validateEmail, trigger: 'blur' }
|
||||
],
|
||||
mobile: [
|
||||
{ validator: validateMobile, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || "";
|
||||
this.visible = true
|
||||
this.dataForm.deptId = ''
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.roleIdListDefault = []
|
||||
Promise.all([
|
||||
this.getRoleList()
|
||||
]).then(() => {
|
||||
if (this.dataForm.id) {
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取角色列表
|
||||
getRoleList () {
|
||||
return this.$http.get('/sys/role/list').then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.roleList = res.data
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 获取信息
|
||||
getInfo () {
|
||||
this.$http.get(`/sys/user/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.dataForm = {
|
||||
...this.dataForm,
|
||||
...res.data,
|
||||
roleIdList: []
|
||||
}
|
||||
// 角色配置, 区分是否为默认角色
|
||||
for (var i = 0; i < res.data.roleIdList.length; i++) {
|
||||
if (this.roleList.filter(item => item.id === res.data.roleIdList[i])[0]) {
|
||||
this.dataForm.roleIdList.push(res.data.roleIdList[i])
|
||||
continue
|
||||
}
|
||||
this.roleIdListDefault.push(res.data.roleIdList[i])
|
||||
}
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit: debounce(function () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
}
|
||||
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', {
|
||||
...this.dataForm,
|
||||
roleIdList: [
|
||||
...this.dataForm.roleIdList,
|
||||
...this.roleIdListDefault
|
||||
]
|
||||
}).then(({ data: res }) => {
|
||||
if (res.code !== 0) {
|
||||
return this.$message.error(res.msg)
|
||||
}
|
||||
this.$message({
|
||||
message: this.$t('prompt.success'),
|
||||
type: 'success',
|
||||
duration: 500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
}).catch(() => {})
|
||||
})
|
||||
}, 1000, { 'leading': true, 'trailing': false })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.mod-sys__user {
|
||||
.role-list {
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
144
src/views/modules/sys/user.vue
Normal file
144
src/views/modules/sys/user.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="aui-card--fill">
|
||||
<div class="mod-sys__user">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.page"
|
||||
:limit="listQuery.limit"
|
||||
:table-data="tableData"
|
||||
>
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="100"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick"
|
||||
/>
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.limit"
|
||||
:page.sync="listQuery.page"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
>
|
||||
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicPage from "@/mixins/basic-page";
|
||||
import AddOrUpdate from "./user-add-or-update";
|
||||
import i18n from "@/i18n";
|
||||
import sysFilter from '@/filters/sys-filter'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: "username",
|
||||
label: i18n.t("user.username"),
|
||||
},
|
||||
{
|
||||
prop: "deptName",
|
||||
label: i18n.t("user.deptName"),
|
||||
},
|
||||
{
|
||||
prop: "email",
|
||||
label: i18n.t("user.email"),
|
||||
},
|
||||
{
|
||||
prop: "mobile",
|
||||
label: i18n.t("user.mobile"),
|
||||
},
|
||||
{
|
||||
prop: "gender",
|
||||
label: i18n.t("user.gender"),
|
||||
filter: sysFilter('sex'),
|
||||
},
|
||||
{
|
||||
prop: "status",
|
||||
label: i18n.t("user.status"),
|
||||
filter: sysFilter('userStatus'),
|
||||
},
|
||||
{
|
||||
prop: "createDate",
|
||||
label: i18n.t("user.createDate"),
|
||||
},
|
||||
];
|
||||
const tableBtn = [
|
||||
{
|
||||
type: "edit",
|
||||
btnName: "编辑",
|
||||
},
|
||||
{
|
||||
type: "delete",
|
||||
btnName: "删除",
|
||||
},
|
||||
];
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: "/sys/user/page",
|
||||
deleteURL: "/sys/user",
|
||||
exportUrl: "/sys/user/export",
|
||||
},
|
||||
tableProps,
|
||||
tableBtn,
|
||||
formConfig: [
|
||||
{
|
||||
type: "input",
|
||||
label: i18n.t("user.username"),
|
||||
placeholder: i18n.t("user.username"),
|
||||
param: "username",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "查询",
|
||||
name: "search",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
btnName: "新增",
|
||||
name: "add",
|
||||
color: "primary",
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
methods:{
|
||||
//search-bar点击
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case "search":
|
||||
this.listQuery.username = val.username;
|
||||
this.listQuery.page = 1;
|
||||
this.getDataList();
|
||||
break;
|
||||
case "add":
|
||||
this.addOrEditTitle = '新增'
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrUpdateHandle()
|
||||
break;
|
||||
default:
|
||||
console.log(val)
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user