This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
@import (reference) '~@/assets/style/extend.less';
|
||||
|
||||
.yo-query-bar {
|
||||
margin-bottom: @padding-md;
|
||||
}
|
||||
|
||||
.yo-action-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
margin-bottom: @padding-md;
|
||||
|
||||
&--actions {
|
||||
|
||||
>.ant-btn,
|
||||
>.ant-btn-group {
|
||||
|
||||
+.ant-btn,
|
||||
+.ant-btn-group {
|
||||
margin-left: @padding-xs;
|
||||
@@ -17,16 +22,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table {
|
||||
background-color: @white;
|
||||
|
||||
.yo-action-bar {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-small {
|
||||
>.ant-table-content {
|
||||
>.ant-table-body {
|
||||
margin: 0;
|
||||
|
||||
>table {
|
||||
>.ant-table-thead {
|
||||
>tr {
|
||||
@@ -39,6 +48,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-thead {
|
||||
>tr {
|
||||
>th {
|
||||
@@ -46,15 +56,20 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.yo-table {
|
||||
.border-right-none {
|
||||
border-right-width: 0;
|
||||
.border-right-none() {
|
||||
border-right-width: 0 !important;
|
||||
|
||||
&:last-child {
|
||||
border-right-width: 1px;
|
||||
border-right-width: 1px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-content {
|
||||
>.ant-table-body {
|
||||
.ant-table-body {
|
||||
overflow-x: auto !important;
|
||||
|
||||
>table {
|
||||
>.ant-table-thead {
|
||||
>tr {
|
||||
@@ -63,6 +78,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
>.ant-table-tbody {
|
||||
>tr {
|
||||
>td {
|
||||
@@ -72,19 +88,82 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-fixed-left {
|
||||
.ant-table-thead {
|
||||
>tr {
|
||||
>th {
|
||||
border-right-width: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-tbody {
|
||||
>tr {
|
||||
>td {
|
||||
border-right-width: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-fixed-right {
|
||||
.ant-table-fixed {
|
||||
border-left-width: 0 !important;
|
||||
}
|
||||
|
||||
.ant-table-thead {
|
||||
>tr {
|
||||
>th {
|
||||
.border-right-none();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-table-tbody {
|
||||
>tr {
|
||||
>td {
|
||||
.border-right-none();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.yo-table-actions {
|
||||
display: inline-block;
|
||||
|
||||
vertical-align: middle;
|
||||
|
||||
&--inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
height: 18px;
|
||||
|
||||
>a {
|
||||
color: darken(@primary-color, 20%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.yo-table--column-setting {
|
||||
width: 240px;
|
||||
|
||||
.ant-dropdown-menu-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.anticon-pushpin {
|
||||
color: darken(@white, 40%);
|
||||
transition: @animation-duration-slow;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.yo-table--fixed {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ axios.defaults.baseURL = '/api'
|
||||
*/
|
||||
import urls from './requests'
|
||||
|
||||
const initInstance = function () {
|
||||
const initInstance = () => {
|
||||
const instance = axios
|
||||
.create({
|
||||
headers: {
|
||||
@@ -40,6 +40,27 @@ const initInstance = function () {
|
||||
return instance
|
||||
}
|
||||
|
||||
const errorNotification = ({ code, message }) => {
|
||||
switch (message.constructor) {
|
||||
case Array:
|
||||
message.map(p => {
|
||||
app.$notification.error({
|
||||
duration: 0,
|
||||
message: p.field,
|
||||
description: p.messages.join('/'),
|
||||
})
|
||||
})
|
||||
break
|
||||
default:
|
||||
app.$notification.error({
|
||||
duration: 0,
|
||||
message: code || '错误',
|
||||
description: message,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const api = {}
|
||||
|
||||
for (let key in urls) {
|
||||
@@ -75,24 +96,22 @@ for (let key in urls) {
|
||||
return new Promise((reslove, reject) => {
|
||||
api[`${key}Wait`](params)
|
||||
.then(({ data }) => {
|
||||
reslove(data)
|
||||
if ([status.BadRequest].indexOf(data.code) >= 0) {
|
||||
errorNotification(data)
|
||||
reject(data)
|
||||
} else {
|
||||
reslove(data)
|
||||
}
|
||||
})
|
||||
.catch(({ response: { data } }) => {
|
||||
const { code, message } = data
|
||||
app.$notification.error({
|
||||
duration: 0,
|
||||
message: code,
|
||||
description: message,
|
||||
})
|
||||
|
||||
// if (process.env.VUE_APP_NODE_ENV === 'development') {
|
||||
// app.$notification.open({
|
||||
// message: '错误',
|
||||
// description: '发生错误,请联系管理员',
|
||||
// });
|
||||
// } else {
|
||||
// reject(err, urls[key])
|
||||
// }
|
||||
if (process.env.VUE_APP_NODE_ENV === 'development') {
|
||||
errorNotification({
|
||||
message: '发生错误,请联系管理员'
|
||||
})
|
||||
} else {
|
||||
errorNotification(data)
|
||||
reject(data)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ const authByJson = (auth, permissions) => {
|
||||
export const auth = (auth) => {
|
||||
|
||||
const { info } = app.global
|
||||
const permissions = info.permissions
|
||||
|
||||
if (!info) {
|
||||
return false
|
||||
@@ -140,6 +139,8 @@ export const auth = (auth) => {
|
||||
return true
|
||||
}
|
||||
|
||||
const permissions = info.permissions
|
||||
|
||||
let flag = false
|
||||
|
||||
if (auth) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<a-dropdown :trigger="['click']" placement="bottomRight" v-model="visible">
|
||||
<a-button>显示列</a-button>
|
||||
<a-menu @click="() => { return false; }" class="yo-table--column-setting" slot="overlay">
|
||||
<a-menu-item>
|
||||
<a-checkbox :checked="checkedAll" :indeterminate="halfChecked" @change="onCheckAll">全选</a-checkbox>
|
||||
</a-menu-item>
|
||||
<a-menu-divider />
|
||||
<a-menu-item :key="column.dataIndex || column.key" v-for="column in columns">
|
||||
<a-checkbox :checked="!column.hidden" @change="(e) => onCheck(column, e)">{{column.title}}</a-checkbox>
|
||||
<a-icon
|
||||
:class="{ 'yo-table--fixed': column.fixed }"
|
||||
@click="onFixed(column)"
|
||||
type="pushpin"
|
||||
/>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
columns: {
|
||||
type: Array,
|
||||
require: true,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
||||
checkedAll: true,
|
||||
halfChecked: false,
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.onHalfCheck();
|
||||
},
|
||||
|
||||
methods: {
|
||||
onHalfCheck() {
|
||||
this.halfChecked = this.columns.filter((p) => p.hidden).length > 0;
|
||||
},
|
||||
|
||||
onCheck(column, e) {
|
||||
this.$set(column, 'hidden', !e.target.checked);
|
||||
this.onHalfCheck();
|
||||
},
|
||||
|
||||
onCheckAll(e) {
|
||||
this.columns.forEach((column) => {
|
||||
this.$set(column, 'hidden', !e.target.checked);
|
||||
});
|
||||
this.checkedAll = e.target.checked;
|
||||
},
|
||||
|
||||
onFixed(column) {
|
||||
this.$set(column, 'fixed', !column.fixed);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,4 +1,5 @@
|
||||
import { template } from "lodash";
|
||||
// 列设置用jsx实现起来较为困难
|
||||
import ColumnSetting from './column'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -39,7 +40,9 @@ export default {
|
||||
sorter: {
|
||||
sortField: '',
|
||||
sortOrder: '',
|
||||
}
|
||||
},
|
||||
|
||||
columnSettingVisible: false
|
||||
};
|
||||
},
|
||||
|
||||
@@ -49,6 +52,37 @@ export default {
|
||||
|
||||
methods: {
|
||||
|
||||
renderColumnSetting() {
|
||||
|
||||
const props = {
|
||||
visible: this.columnSettingVisible,
|
||||
placement: 'bottomRight'
|
||||
}
|
||||
|
||||
const on = {
|
||||
visibleChange: (visible) => {
|
||||
this.columnSettingVisible = visible
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<a-dropdown {...{ props, on }}>
|
||||
<a-button onClick={() => this.columnSettingVisible = true}>设置列</a-button>
|
||||
<a-menu slot="overlay" onClick={() => { return false }}>
|
||||
{
|
||||
this.columns.map(column => {
|
||||
return (
|
||||
<a-menu-item key={column.dataIndex || column.key}>
|
||||
<a-checkbox checked={column.hidden} onChange={() => { column.hidden = !column.hidden }}>{column.title}</a-checkbox>
|
||||
</a-menu-item>
|
||||
)
|
||||
})
|
||||
}
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
)
|
||||
},
|
||||
|
||||
onLoading() {
|
||||
this.loading = {
|
||||
indicator: <a-icon type="loading" spin />
|
||||
@@ -74,7 +108,7 @@ export default {
|
||||
},
|
||||
|
||||
onReloadData(refresh = false) {
|
||||
if (refresh) {
|
||||
if (refresh && refresh.constructor === Boolean) {
|
||||
this.pagination.current = this.pageNo
|
||||
this.pagination.pageSize = this.pageSize
|
||||
}
|
||||
@@ -93,22 +127,37 @@ export default {
|
||||
loading: this.loading,
|
||||
pagination: this.pagination,
|
||||
dataSource: this.data,
|
||||
columns: this.columns,
|
||||
columns: this.columns.filter(p => !p.hidden),
|
||||
bordered: true,
|
||||
size: 'middle',
|
||||
rowKey: record => record.id
|
||||
rowKey: record => record.id,
|
||||
scroll: { x: 'max-content' }
|
||||
}
|
||||
|
||||
const on = {
|
||||
change: this.onTableChange
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
<a-alert type="error" closable>
|
||||
<template slot="message">后端没有排序参数</template>
|
||||
<a-alert type="warning" closable>
|
||||
<template slot="message">
|
||||
后端没有排序参数
|
||||
<br />
|
||||
字段固定应该遵循左侧固定到最左,右侧固定到最右(此逻辑难以实现)
|
||||
</template>
|
||||
</a-alert>
|
||||
<br />
|
||||
<div class="yo-action-bar">
|
||||
<div class="yo-action-bar--actions">
|
||||
{this.$scopedSlots.operator && this.$scopedSlots.operator()}
|
||||
</div>
|
||||
<div class="yo-action-bar--actions">
|
||||
<a-button-group>
|
||||
<a-button onClick={this.onReloadData}>刷新</a-button>
|
||||
<ColumnSetting {...{ props: { columns: this.columns } }} />
|
||||
</a-button-group>
|
||||
</div>
|
||||
</div>
|
||||
<a-table class="yo-table" {...{ props, on, scopedSlots: { ...this.$scopedSlots } }}>
|
||||
{Object.keys(this.$slots).map((name) => (
|
||||
<template slot={name}>{this.$slots[name]}</template>
|
||||
|
||||
@@ -37,6 +37,7 @@ export default {
|
||||
|
||||
this.loadData().then((res) => {
|
||||
const data = this.generateKey(res)
|
||||
this.list = []
|
||||
this.generateList(data)
|
||||
if (this.defaultExpandedKeys) {
|
||||
this.expandedKeys = this.list.map(p => p.key)
|
||||
|
||||
@@ -68,6 +68,14 @@ const app = new Vue({
|
||||
* 可通过this.$root.global调用
|
||||
*/
|
||||
global: {
|
||||
|
||||
defaultWindow: [{
|
||||
title: '首页',
|
||||
path: '/home',
|
||||
icon: 'home',
|
||||
closable: false,
|
||||
}],
|
||||
|
||||
/**
|
||||
* 用于存储用户信息
|
||||
*/
|
||||
|
||||
@@ -42,16 +42,18 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysAppAdd(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysAppAdd(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('新增成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -45,16 +45,18 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysAppEdit(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('新增成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysAppEdit(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -22,11 +22,9 @@
|
||||
</Auth>
|
||||
|
||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
||||
<div class="yo-action-bar" slot="title">
|
||||
<div class="yo-action-bar--actions">
|
||||
<a-button @click="onOpen('add-form')">新增应用</a-button>
|
||||
</div>
|
||||
</div>
|
||||
<Auth auth="sysApp:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增应用</a-button>
|
||||
</Auth>
|
||||
<span slot="active" slot-scope="text, record">
|
||||
{{ bindCodeValue(text, 'yes_or_no') }}
|
||||
<Auth auth="sysApp:setAsDefault" v-if="record.active == 'N'">
|
||||
@@ -101,14 +99,6 @@ export default {
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: '200px',
|
||||
dataIndex: 'action',
|
||||
scopedSlots: {
|
||||
customRender: 'action',
|
||||
},
|
||||
},
|
||||
],
|
||||
codes: [
|
||||
{
|
||||
@@ -124,6 +114,19 @@ export default {
|
||||
},
|
||||
created() {
|
||||
this.onLoadCodes();
|
||||
|
||||
const flag = this.$auth({
|
||||
sysApp: [['edit'], ['delete']],
|
||||
});
|
||||
|
||||
if (flag) {
|
||||
this.columns.push({
|
||||
title: '操作',
|
||||
width: '150px',
|
||||
dataIndex: 'action',
|
||||
scopedSlots: { customRender: 'action' },
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
@@ -187,27 +190,25 @@ export default {
|
||||
this.$refs[formName].onOpen(record);
|
||||
},
|
||||
|
||||
onResult(success, message, successMessage) {
|
||||
onResult(success, successMessage) {
|
||||
if (success) {
|
||||
this.$message.success(successMessage);
|
||||
this.onReloadData();
|
||||
} else {
|
||||
this.$refs.table.onLoaded();
|
||||
this.$message.error(message);
|
||||
}
|
||||
this.$refs.table.onLoaded();
|
||||
},
|
||||
|
||||
onSetDefault(record) {
|
||||
this.$refs.table.onLoading();
|
||||
this.$api.sysAppSetAsDefault({ id: record.id }).then(({ success, message }) => {
|
||||
this.onResult(success, message, '设置成功');
|
||||
this.$api.sysAppSetAsDefault({ id: record.id }).then(({ success }) => {
|
||||
this.onResult(success, '设置成功');
|
||||
});
|
||||
},
|
||||
|
||||
onDelete(record) {
|
||||
this.$refs.table.onLoading();
|
||||
this.$api.sysAppDelete(record).then(({ success, message }) => {
|
||||
this.onResult(success, message, '删除成功');
|
||||
this.$api.sysAppDelete(record).then(({ success }) => {
|
||||
this.onResult(success, '删除成功');
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@cancel="onCancel"
|
||||
@ok="onOk"
|
||||
class="yo-modal-form"
|
||||
title="新增应用"
|
||||
title="新增机构"
|
||||
>
|
||||
<FormBody ref="form-body" />
|
||||
</a-modal>
|
||||
@@ -25,13 +25,27 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
formBody() {
|
||||
return this.$refs['form-body'];
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 必要的方法
|
||||
* 从外部调用打开本窗口
|
||||
*/
|
||||
onOpen() {
|
||||
onOpen(record, orgId) {
|
||||
this.visible = true;
|
||||
this.$nextTick(async () => {
|
||||
await this.formBody.onInit();
|
||||
|
||||
// 获取外部选中的部门id
|
||||
this.formBody.onFillData({
|
||||
pid: orgId,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -42,16 +56,18 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysAppAdd(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysOrgAdd(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('新增成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@cancel="onCancel"
|
||||
@ok="onOk"
|
||||
class="yo-modal-form"
|
||||
title="编辑应用"
|
||||
title="编辑机构"
|
||||
>
|
||||
<FormBody ref="form-body" />
|
||||
</a-modal>
|
||||
@@ -32,7 +32,8 @@ export default {
|
||||
*/
|
||||
onOpen(record) {
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(async () => {
|
||||
await this.$refs['form-body'].onInit();
|
||||
this.$refs['form-body'].onFillData(record);
|
||||
});
|
||||
},
|
||||
@@ -45,16 +46,18 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysAppEdit(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('新增成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysOrgEdit(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,38 +1,52 @@
|
||||
<template>
|
||||
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item label="机构名称" prop="name">
|
||||
<a-input placeholder="请输入机构名称" v-model="form.name" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="唯一编码" prop="code">
|
||||
<a-input placeholder="请输入唯一编码" v-model="form.code" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="排序" prop="sort">
|
||||
<a-input-number
|
||||
:max="1000"
|
||||
:min="0"
|
||||
class="w-100-p"
|
||||
placeholder="请输入排序"
|
||||
v-model="form.sort"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="备注">
|
||||
<a-input placeholder="请输入备注" v-model="form.remark" />
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
<a-spin :spinning="loading">
|
||||
<a-icon slot="indicator" spin type="loading" />
|
||||
<div class="yo-form-group">
|
||||
<a-form-model-item has-feedback label="机构名称" prop="name">
|
||||
<a-input placeholder="请输入机构名称" v-model="form.name" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item has-feedback label="唯一编码" prop="code">
|
||||
<a-input placeholder="请输入唯一编码" v-model="form.code" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item has-feedback label="上级机构" prop="pid">
|
||||
<a-tree-select
|
||||
:tree-data="orgData"
|
||||
placeholder="请选择上级机构"
|
||||
tree-default-expand-all
|
||||
v-model="form.pid"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="排序" prop="sort">
|
||||
<a-input-number
|
||||
:max="1000"
|
||||
:min="0"
|
||||
class="w-100-p"
|
||||
placeholder="请输入排序"
|
||||
v-model="form.sort"
|
||||
/>
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="备注">
|
||||
<a-textarea placeholder="请输入备注" v-model="form.remark" />
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-spin>
|
||||
</a-form-model>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
active: 'N',
|
||||
},
|
||||
form: {},
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入机构名称' }],
|
||||
code: [{ required: true, message: '请输入唯一编码' }],
|
||||
pid: [{ required: true, message: '请选择上级机构' }],
|
||||
},
|
||||
|
||||
loading: false,
|
||||
|
||||
orgData: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@@ -61,6 +75,22 @@ export default {
|
||||
this.$refs.form.resetFields();
|
||||
}, 300);
|
||||
},
|
||||
|
||||
async onInit() {
|
||||
this.loading = true;
|
||||
this.orgData = await this.onLoadOrgData();
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
onLoadOrgData() {
|
||||
return this.$api.getOrgTree().then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onChangeExtData(value, record, type) {
|
||||
record[type] = value;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,9 +1,14 @@
|
||||
<template>
|
||||
<yo-tree-layout :load-data="loadTreeData" @select="onSelect" default-expanded-keys>
|
||||
<yo-tree-layout
|
||||
:load-data="loadTreeData"
|
||||
@select="onSelect"
|
||||
default-expanded-keys
|
||||
ref="tree-layout"
|
||||
>
|
||||
<container>
|
||||
<br />
|
||||
<a-card :bordered="false">
|
||||
<Auth auth="sysUser:page">
|
||||
<Auth auth="sysOrg:page">
|
||||
<div class="yo-query-bar">
|
||||
<a-form-model :model="query" layout="inline">
|
||||
<a-form-model-item label="机构名称">
|
||||
@@ -19,6 +24,9 @@
|
||||
</div>
|
||||
|
||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
||||
<Auth auth="sysOrg:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增机构</a-button>
|
||||
</Auth>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<yo-table-actions>
|
||||
<Auth auth="sysOrg:edit">
|
||||
@@ -58,14 +66,17 @@ export default {
|
||||
columns: [
|
||||
{
|
||||
title: '机构名称',
|
||||
width: '400px',
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: '唯一编码',
|
||||
width: '200px',
|
||||
dataIndex: 'code',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
width: '80px',
|
||||
dataIndex: 'sort',
|
||||
},
|
||||
{
|
||||
@@ -147,6 +158,7 @@ export default {
|
||||
*/
|
||||
onReloadData() {
|
||||
this.$refs.table.onReloadData();
|
||||
this.$refs['tree-layout'].onReloadData();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -158,12 +170,13 @@ export default {
|
||||
},
|
||||
|
||||
onDelete(record) {
|
||||
this.$api.sysOrgDelete(record).then(({ success, message }) => {
|
||||
this.$api.sysOrgDelete(record).then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('删除成功');
|
||||
this.onReloadData();
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
if (this.query['pid'] == record.id) {
|
||||
delete this.query.pid;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -41,16 +41,19 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysRoleAdd(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysRoleAdd(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -45,16 +45,19 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysRoleEdit(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysRoleEdit(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<container>
|
||||
<br />
|
||||
<a-card :bordered="false">
|
||||
<Auth auth="sysApp:page">
|
||||
<Auth auth="sysRole:page">
|
||||
<div class="yo-query-bar">
|
||||
<a-form-model :model="query" layout="inline">
|
||||
<a-form-model-item label="角色名称">
|
||||
@@ -22,35 +22,33 @@
|
||||
</Auth>
|
||||
|
||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
||||
<div class="yo-action-bar" slot="title">
|
||||
<div class="yo-action-bar--actions">
|
||||
<a-button @click="onOpen('add-form')">新建角色</a-button>
|
||||
</div>
|
||||
</div>
|
||||
<Auth auth="sysRole:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新建角色</a-button>
|
||||
</Auth>
|
||||
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<yo-table-actions>
|
||||
<Auth auth="sysApp:edit">
|
||||
<Auth auth="sysRole:edit">
|
||||
<a @click="onOpen('edit-form', record)">编辑</a>
|
||||
</Auth>
|
||||
<Auth auth="sysApp:delete">
|
||||
<Auth auth="sysRole:delete">
|
||||
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
|
||||
<a>删除</a>
|
||||
</a-popconfirm>
|
||||
</Auth>
|
||||
<Auth :auth="{ sysApp: [['grantMenu'], ['grantData']] }">
|
||||
<Auth :auth="{ sysRole: [['grantMenu'], ['grantData']] }">
|
||||
<a-dropdown>
|
||||
<a class="ant-dropdown-link">
|
||||
授权
|
||||
<a-icon type="down" />
|
||||
</a>
|
||||
<a-menu slot="overlay">
|
||||
<Auth auth="sysApp:grantMenu">
|
||||
<Auth auth="sysRole:grantMenu">
|
||||
<a-menu-item>
|
||||
<a @click="$refs.roleMenuForm.roleMenu(record)">授权菜单</a>
|
||||
</a-menu-item>
|
||||
</Auth>
|
||||
<Auth auth="sysApp:grantData">
|
||||
<Auth auth="sysRole:grantData">
|
||||
<a-menu-item>
|
||||
<a @click="$refs.roleOrgForm.roleOrg(record)">授权数据</a>
|
||||
</a-menu-item>
|
||||
@@ -108,9 +106,7 @@ export default {
|
||||
],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
// this.onLoadCodes();
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
/**
|
||||
* 必要的方法
|
||||
@@ -143,29 +139,6 @@ export default {
|
||||
this.$refs.table.onReloadData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 加载字典数据时的必要方法
|
||||
*/
|
||||
// onLoadCodes() {
|
||||
// this.$api
|
||||
// .$queue([
|
||||
// this.$api.sysDictTypeDropDownWait({ code: "yes_or_no" }),
|
||||
// this.$api.sysDictTypeDropDownWait({ code: "common_status" }),
|
||||
// ])
|
||||
// .then(([yesOrNo, commonStatus]) => {
|
||||
// this.codes.find((p) => p.code === "yes_or_no").values = yesOrNo.data;
|
||||
// this.codes.find((p) => p.code === "common_status").values =
|
||||
// commonStatus.data;
|
||||
// });
|
||||
// },
|
||||
bindCodeValue(code, name) {
|
||||
const c = this.codes.find((p) => p.code == name).values.find((p) => p.code == code);
|
||||
if (c) {
|
||||
return c.value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 有编辑新增功能的必要方法
|
||||
* 从列表页调用窗口的打开方法
|
||||
@@ -174,27 +147,18 @@ export default {
|
||||
this.$refs[formName].onOpen(record);
|
||||
},
|
||||
|
||||
onResult(success, message, successMessage) {
|
||||
onResult(success, successMessage) {
|
||||
if (success) {
|
||||
this.$message.success(successMessage);
|
||||
this.onReloadData();
|
||||
} else {
|
||||
this.$refs.table.onLoaded();
|
||||
this.$message.error(message);
|
||||
}
|
||||
},
|
||||
|
||||
onSetDefault(record) {
|
||||
this.$refs.table.onLoading();
|
||||
this.$api.sysAppSetAsDefault({ id: record.id }).then(({ success, message }) => {
|
||||
this.onResult(success, message, '设置成功');
|
||||
});
|
||||
this.$refs.table.onLoaded();
|
||||
},
|
||||
|
||||
onDelete(record) {
|
||||
this.$refs.table.onLoading();
|
||||
this.$api.sysRoleDel(record).then(({ success, message }) => {
|
||||
this.onResult(success, message, '删除成功');
|
||||
this.onResult(success, '删除成功');
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -59,16 +59,18 @@ export default {
|
||||
this.formBody.onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysUserAdd(this.formBody.form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysUserAdd(this.formBody.form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('新增成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -46,16 +46,18 @@ export default {
|
||||
this.$refs['form-body'].onValidate((valid) => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true;
|
||||
this.$api.sysUserEdit(this.$refs['form-body'].form).then(({ success, message }) => {
|
||||
this.confirmLoading = false;
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
} else {
|
||||
this.$message.error(message);
|
||||
}
|
||||
});
|
||||
this.$api
|
||||
.sysUserEdit(this.$refs['form-body'].form)
|
||||
.then(({ success }) => {
|
||||
if (success) {
|
||||
this.$message.success('编辑成功');
|
||||
this.onCancel();
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
this.confirmLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -45,11 +45,9 @@
|
||||
</Auth>
|
||||
|
||||
<yo-table :columns="columns" :load-data="loadData" ref="table">
|
||||
<div class="yo-action-bar" slot="title">
|
||||
<div class="yo-action-bar--actions">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增用户</a-button>
|
||||
</div>
|
||||
</div>
|
||||
<Auth auth="sysUser:add" slot="operator">
|
||||
<a-button @click="onOpen('add-form')" icon="plus">新增用户</a-button>
|
||||
</Auth>
|
||||
<span slot="sex" slot-scope="text">{{ bindCodeValue(text, 'sex') }}</span>
|
||||
<span slot="status" slot-scope="text, record">
|
||||
{{ bindCodeValue(text, 'common_status') }}
|
||||
|
||||
@@ -89,7 +89,10 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
mounted() {
|
||||
Vue.prototype.openContentWindow = this.onOpenContentWindow;
|
||||
Vue.prototype.closeContentWindow = this.onCloseContentWindow;
|
||||
|
||||
this.nav.loading = true;
|
||||
|
||||
this.$api.getLoginUser().then(({ data }) => {
|
||||
@@ -102,18 +105,10 @@ export default {
|
||||
this.menus = data.menus;
|
||||
this.serializeMenu();
|
||||
this.nav.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
mounted() {
|
||||
Vue.prototype.openContentWindow = this.onOpenContentWindow;
|
||||
Vue.prototype.closeContentWindow = this.onCloseContentWindow;
|
||||
|
||||
this.onOpenContentWindow({
|
||||
title: '首页',
|
||||
path: '/home',
|
||||
icon: 'home',
|
||||
closable: false,
|
||||
this.$root.global.defaultWindow.map((options) => {
|
||||
this.onOpenContentWindow(options);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user