From 7504c9b75ced45889e75cde4a13fbc2736236823 Mon Sep 17 00:00:00 2001 From: ky_sunl Date: Tue, 20 Apr 2021 02:57:07 +0000 Subject: [PATCH] --- .../src/assets/style/lib/table.less | 87 ++++++++++++++++++- .../src/common/api/index.js | 53 +++++++---- .../src/components/authorized/index.js | 3 +- .../src/components/yoTable/column.vue | 64 ++++++++++++++ .../src/components/yoTable/index.js | 65 ++++++++++++-- .../src/components/yoTreeLayout/index.js | 1 + Api/Ewide.Core/Ewide.Core.Web.Src/src/main.js | 8 ++ .../src/pages/system/app/addForm.vue | 22 ++--- .../src/pages/system/app/editForm.vue | 22 ++--- .../src/pages/system/app/index.vue | 43 ++++----- .../src/pages/system/org/addForm.vue | 40 ++++++--- .../src/pages/system/org/editForm.vue | 27 +++--- .../src/pages/system/org/form.vue | 76 +++++++++++----- .../src/pages/system/org/index.vue | 23 +++-- .../src/pages/system/role/addForm.vue | 23 ++--- .../src/pages/system/role/editForm.vue | 23 ++--- .../src/pages/system/role/index.vue | 62 +++---------- .../src/pages/system/user/addForm.vue | 22 ++--- .../src/pages/system/user/editForm.vue | 22 ++--- .../src/pages/system/user/index.vue | 8 +- .../src/views/main/index.vue | 19 ++-- 21 files changed, 484 insertions(+), 229 deletions(-) create mode 100644 Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/column.vue diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/assets/style/lib/table.less b/Api/Ewide.Core/Ewide.Core.Web.Src/src/assets/style/lib/table.less index f5b8b2b..10ffedb 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/assets/style/lib/table.less +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/assets/style/lib/table.less @@ -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); + } +} \ No newline at end of file diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/common/api/index.js b/Api/Ewide.Core/Ewide.Core.Web.Src/src/common/api/index.js index 2abd397..eac6bda 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/common/api/index.js +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/common/api/index.js @@ -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) + } }) }) } diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/authorized/index.js b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/authorized/index.js index 417851c..aa1a55b 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/authorized/index.js +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/authorized/index.js @@ -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) { diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/column.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/column.vue new file mode 100644 index 0000000..104c6bf --- /dev/null +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/column.vue @@ -0,0 +1,64 @@ + + \ No newline at end of file diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/index.js b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/index.js index 64072b3..c3264d5 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/index.js +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTable/index.js @@ -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 ( + + this.columnSettingVisible = true}>设置列 + { return false }}> + { + this.columns.map(column => { + return ( + + { column.hidden = !column.hidden }}>{column.title} + + ) + }) + } + + + ) + }, + onLoading() { this.loading = { indicator: @@ -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 (
- - + +
+
+
+ {this.$scopedSlots.operator && this.$scopedSlots.operator()} +
+
+ + 刷新 + + +
+
{Object.keys(this.$slots).map((name) => ( diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTreeLayout/index.js b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTreeLayout/index.js index 31d4be0..f3b7c31 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTreeLayout/index.js +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/components/yoTreeLayout/index.js @@ -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) diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/main.js b/Api/Ewide.Core/Ewide.Core.Web.Src/src/main.js index a97461f..f1d1387 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/main.js +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/main.js @@ -68,6 +68,14 @@ const app = new Vue({ * 可通过this.$root.global调用 */ global: { + + defaultWindow: [{ + title: '首页', + path: '/home', + icon: 'home', + closable: false, + }], + /** * 用于存储用户信息 */ diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/addForm.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/addForm.vue index 8002997..2d1ce72 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/addForm.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/addForm.vue @@ -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; + }); } }); }, diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/editForm.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/editForm.vue index 3f917c2..76f613d 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/editForm.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/editForm.vue @@ -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; + }); } }); }, diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/index.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/index.vue index 4907057..b5f5991 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/index.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/app/index.vue @@ -22,11 +22,9 @@ -
-
- 新增应用 -
-
+ + 新增应用 + {{ bindCodeValue(text, 'yes_or_no') }} @@ -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, '删除成功'); }); }, }, diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/addForm.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/addForm.vue index 8002997..af133ac 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/addForm.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/addForm.vue @@ -5,7 +5,7 @@ @cancel="onCancel" @ok="onOk" class="yo-modal-form" - title="新增应用" + title="新增机构" > @@ -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; + }); } }); }, diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/editForm.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/editForm.vue index 3f917c2..0220671 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/editForm.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/editForm.vue @@ -5,7 +5,7 @@ @cancel="onCancel" @ok="onOk" class="yo-modal-form" - title="编辑应用" + title="编辑机构" > @@ -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; + }); } }); }, diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/form.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/form.vue index 2600cee..7f2ccba 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/form.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/form.vue @@ -1,38 +1,52 @@ \ No newline at end of file diff --git a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/index.vue b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/index.vue index 41ba1c1..baa4946 100644 --- a/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/index.vue +++ b/Api/Ewide.Core/Ewide.Core.Web.Src/src/pages/system/org/index.vue @@ -1,9 +1,14 @@