From 5030e3db57043c43234a95281a22cb7cdb625f4c Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@126.com> Date: Sat, 10 Oct 2020 18:02:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/asset/style/element-ui.scss | 5 +- vue/src/asset/style/index.scss | 5 +- .../component/abstract/Pagination/index.vue | 1 - vue/src/component/form/Search/index.vue | 126 ++++++++------ vue/src/component/form/Search/item.vue | 24 --- vue/src/component/form/ValidateInfo/index.vue | 7 +- vue/src/config/index.js | 3 - vue/src/globalMethod/Guide/main.vue | 6 +- vue/src/globalMethod/Verify/main.vue | 4 +- vue/src/main.js | 4 +- vue/src/mixin/chart/logic.js | 3 +- vue/src/mixin/docTableMixin.js | 31 ++-- vue/src/util/element-ui/elForm.js | 0 vue/src/util/element-ui/elTree.js | 21 +++ vue/src/util/errorLog.js | 15 -- vue/src/util/file.js | 2 +- vue/src/util/secret.js | 3 + vue/src/util/tree.js | 14 -- vue/src/view/app/common/ListPage/index.vue | 38 +++-- vue/src/view/app/login/LoginForm.vue | 6 +- vue/src/view/app/login/RegisterForm.vue | 2 +- vue/src/view/message/manage/EditDialog.vue | 2 +- vue/src/view/message/manage/indexPage.vue | 108 ++++++------ vue/src/view/message/user/MessageStream.vue | 2 +- vue/src/view/purchase/inbound/indexPage.vue | 30 ++-- vue/src/view/purchase/order/indexPage.vue | 38 ++--- vue/src/view/sell/order/indexPage.vue | 38 ++--- vue/src/view/sell/outbound/indexPage.vue | 30 ++-- vue/src/view/stock/current/indexPage.vue | 19 +-- vue/src/view/system/customer/EditDialog.vue | 4 +- vue/src/view/system/customer/indexPage.vue | 123 ++++++++------ .../department/component/EditDialog.vue | 18 +- vue/src/view/system/department/indexPage.vue | 20 ++- vue/src/view/system/menu/indexPage.vue | 6 +- vue/src/view/system/role/EditDialog.vue | 17 +- vue/src/view/system/role/indexPage.vue | 105 +++++++----- vue/src/view/system/supplier/EditDialog.vue | 4 +- vue/src/view/system/supplier/indexPage.vue | 123 ++++++++------ .../view/system/user/component/EditDialog.vue | 13 +- vue/src/view/system/user/indexPage.vue | 157 ++++++++++-------- vue/src/view/userCenter/component/Account.vue | 2 +- 41 files changed, 637 insertions(+), 542 deletions(-) delete mode 100644 vue/src/component/form/Search/item.vue create mode 100644 vue/src/util/element-ui/elForm.js create mode 100644 vue/src/util/element-ui/elTree.js delete mode 100644 vue/src/util/errorLog.js diff --git a/vue/src/asset/style/element-ui.scss b/vue/src/asset/style/element-ui.scss index d7a7d70..1844cb2 100644 --- a/vue/src/asset/style/element-ui.scss +++ b/vue/src/asset/style/element-ui.scss @@ -181,12 +181,15 @@ } .el-pagination { - padding-top: 20px; text-align: right; .el-pagination__editor.el-input { margin: 0 5px; } + + .el-table + & { + padding-top: 20px; + } } .el-scrollbar { diff --git a/vue/src/asset/style/index.scss b/vue/src/asset/style/index.scss index 88cf8b1..9404486 100644 --- a/vue/src/asset/style/index.scss +++ b/vue/src/asset/style/index.scss @@ -1,3 +1,4 @@ +@import "~normalize.css/normalize.css"; @import "./variables"; @import "~element-ui/packages/theme-chalk/src/index"; @import "~@ele/style/index.scss"; @@ -54,7 +55,7 @@ a:hover { &-thumb { width: 6px; - border-radius: 5px; + //border-radius: 5px; background-color: rgba($--color-primary, 0.8); &:hover { @@ -79,6 +80,7 @@ a:hover { align-content: space-between; } + /*----------路由页面的最大高度开始----------*/ $page-header-offsetHeight: $page-header-line-height + #{$page-view-margin * 2}; @@ -112,6 +114,7 @@ $page-header-offsetHeight: $page-header-line-height + #{$page-view-margin * 2}; /*----------路由页面的最大高度结束----------*/ + .table-container { margin-top: 10px; } diff --git a/vue/src/component/abstract/Pagination/index.vue b/vue/src/component/abstract/Pagination/index.vue index 265ef8c..d33d97e 100644 --- a/vue/src/component/abstract/Pagination/index.vue +++ b/vue/src/component/abstract/Pagination/index.vue @@ -19,7 +19,6 @@ export default { current-page={page} page-size={pageSize} total={total} - hide-on-single-page layout="total, prev, pager, next, jumper" {...context.data} /> diff --git a/vue/src/component/form/Search/index.vue b/vue/src/component/form/Search/index.vue index b7ed5af..7668d7a 100644 --- a/vue/src/component/form/Search/index.vue +++ b/vue/src/component/form/Search/index.vue @@ -4,14 +4,11 @@ import {getElementInnerWidth} from '@/util/browser' export default { name: "SearchForm", - provide() { - return { - searchForm: this - } - }, - props: { + model: Object, labelWidth: {type: String, default: '120px'}, + + /*每个宽度下,一行能有多少个控件,需要是24的因数*/ xs: {type: Number, default: 1}, // <768px sm: {type: Number, default: 2}, // >=768px md: {type: Number, default: 3}, // >=998px @@ -20,10 +17,10 @@ export default { data() { return { - showCollapse: false, - collapse: true, - num: 0, - width: 'auto' + showCollapse: false, //是否需要折叠控制 + collapse: true, //是否处于折叠状态,默认折叠 + num: 0, //从第几个控件开始需要隐藏 + span: 8 //24等分下,每个栅格的宽度 } }, @@ -32,6 +29,18 @@ export default { this.collapse = !this.collapse }, + handleSearch() { + this.$emit('search') + }, + + handleReset() { + if (!this.initialModel || !this.model) { + return + } + + this.$emit('reset') + }, + getElementNumInRow() { const vw = getElementInnerWidth(this.$el.parentNode) @@ -43,13 +52,49 @@ export default { resize() { const num = this.getElementNumInRow() - this.num = num - this.width = `${100 / num}%` - this.showCollapse = num < this.$slots.default.length + + this.span = 24 / num + + //考虑后面的按钮组的占位 + this.num = num === 1 ? num : num - 1 + this.showCollapse = this.num < this.$slots.default.length + }, + + renderChildren(children, hide) { + return children.map(child => ( + {child} + )) + }, + + renderAction() { + const ctrl = this.collapse + ? {i: 'el-icon-arrow-down', t: '展开'} + : {i: 'el-icon-arrow-up', t: '收起'} + + return ( +
+ 查 询 + 重 置 + {this.showCollapse && ( + + {ctrl.t} + + + )} +
+ ) } }, mounted() { + //记录初始条件 + this.initialModel = this.model + this.resize() this.resizeObserver = new ResizeObserver(() => this.resize()) this.resizeObserver.observe(this.$el.parentNode) @@ -63,50 +108,24 @@ export default { }, render() { - const slots = this.$slots.default - const collapseChildren = [] - if (this.showCollapse) { - //此处直接对el-row使用v-show会无效 - collapseChildren.push( - -
- - {slots.slice(this.num)} - -
-
- ) - const collapseSlot = this.$scopedSlots.collapse + const slots = this.$slots.default, collapse = this.showCollapse && this.collapse - collapseChildren.push( - collapseSlot ? - collapseSlot({collapse: this.collapse, handle: this.handleCollapse}) - : -
- - {this.collapse ? '展开' : '收起'} - -
- ) - } + const display = collapse ? slots.slice(0, this.num) : slots + const hidden = collapse ? slots.slice(this.num) : [] return ( - {this.num > slots.length ? slots : slots.slice(0, this.num)} + {this.renderChildren(display)} + {this.renderChildren(hidden, true)} + {this.renderAction()} - {this.showCollapse && collapseChildren} ) } @@ -114,8 +133,10 @@ export default { diff --git a/vue/src/component/form/Search/item.vue b/vue/src/component/form/Search/item.vue deleted file mode 100644 index 730bf5f..0000000 --- a/vue/src/component/form/Search/item.vue +++ /dev/null @@ -1,24 +0,0 @@ - diff --git a/vue/src/component/form/ValidateInfo/index.vue b/vue/src/component/form/ValidateInfo/index.vue index df9690b..78fae81 100644 --- a/vue/src/component/form/ValidateInfo/index.vue +++ b/vue/src/component/form/ValidateInfo/index.vue @@ -58,12 +58,7 @@ export default { }, getFormRef() { - let ref = this.form - if (!ref) return - if (typeof ref === 'function') { - ref = ref() - } - return ref + return typeof this.form === 'function' ? this.form() : this.form }, findFormItem(prop) { diff --git a/vue/src/config/index.js b/vue/src/config/index.js index fc0a809..a2689e1 100644 --- a/vue/src/config/index.js +++ b/vue/src/config/index.js @@ -23,9 +23,6 @@ module.exports = { //侧边栏顶上的logo地址 sidebarLogoUrl: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png', - //是否使用错误日志捕捉,暂时没啥用 - errorLog: true, - //路由配置 route: { //路由模式,['hash','history'] diff --git a/vue/src/globalMethod/Guide/main.vue b/vue/src/globalMethod/Guide/main.vue index 6a8804d..25deb3b 100644 --- a/vue/src/globalMethod/Guide/main.vue +++ b/vue/src/globalMethod/Guide/main.vue @@ -122,7 +122,7 @@ export default { if (this.beforeExit) { const result = this.beforeExit(this.hasDone) if (result && result.then) { - result.then(() => this.$_clear()) + result.then(this.$_clear) } else result !== false && this.$_clear() return @@ -138,7 +138,7 @@ export default { if (this.step.onPrevious) { const result = this.step.onPrevious() if (result && result.then) { - result.then(() => this.$_movePrevious()) + result.then(this.$_movePrevious) } else result !== false && this.$_movePrevious() } @@ -152,7 +152,7 @@ export default { if (this.step.onNext) { const result = this.step.onNext() if (result && result.then) { - result.then(() => this.$_moveNext()) + result.then(this.$_moveNext) } else result !== false && this.$_moveNext() } diff --git a/vue/src/globalMethod/Verify/main.vue b/vue/src/globalMethod/Verify/main.vue index 3e82a14..8d75215 100644 --- a/vue/src/globalMethod/Verify/main.vue +++ b/vue/src/globalMethod/Verify/main.vue @@ -140,7 +140,7 @@ export default { }, refresh() { - this.initImage().then(() => this.initCanvas()) + this.initImage().then(this.initCanvas) }, initCanvas() { @@ -322,7 +322,7 @@ export default { }, mounted() { - this.initImage().then(() => this.initCanvas()) + this.refresh() }, } diff --git a/vue/src/main.js b/vue/src/main.js index ed7cab4..ce8e863 100644 --- a/vue/src/main.js +++ b/vue/src/main.js @@ -1,13 +1,11 @@ import Vue from 'vue' -import 'normalize.css/normalize.css' // a modern alternative to CSS resets import Element from 'element-ui' import ElementPersonal from '@ele' -import '@/asset/style/index.scss' // global css +import '@/asset/style/index.scss' import App from '@/App' import store from '@/store' import router from '@/router' import '@/asset/icon' -import '@/util/errorLog' import '@/directive' import filters from './filter' import globalMethod from '@/globalMethod' diff --git a/vue/src/mixin/chart/logic.js b/vue/src/mixin/chart/logic.js index d75ab6f..9b4e147 100644 --- a/vue/src/mixin/chart/logic.js +++ b/vue/src/mixin/chart/logic.js @@ -14,8 +14,7 @@ export default { data() { return { - loading: false, - chart: null + loading: false } }, diff --git a/vue/src/mixin/docTableMixin.js b/vue/src/mixin/docTableMixin.js index ab0bce3..ea450ac 100644 --- a/vue/src/mixin/docTableMixin.js +++ b/vue/src/mixin/docTableMixin.js @@ -1,5 +1,4 @@ import tableMixin from '@/mixin/tablePageMixin' -import SearchFormItem from "@/component/form/Search/item" import LinerProgress from '@/component/LinerProgress' import ListPage from '@/view/app/common/ListPage' import {isEmpty} from "@/util" @@ -35,7 +34,7 @@ export const commonMethods = { export default { mixins: [tableMixin], - components: {SearchFormItem, LinerProgress, ListPage}, + components: {LinerProgress, ListPage}, data() { return { @@ -69,24 +68,26 @@ export default { return auth(this.api.exportExcel.url) }, - buttonGroup() { - return [ - {icon: 'el-icon-search', type: 'primary', e: this.search, content: '查 询'}, - this.canAdd && {icon: 'el-icon-plus', type: 'primary', e: this.add, content: '添 加'}, - {icon: 'el-icon-view', type: 'primary', e: this.see, content: '查 看'}, - this.canUpdate && {icon: 'el-icon-edit', type: 'primary', e: this.edit, content: '编 辑'}, - this.canDel && {icon: 'el-icon-delete', type: 'danger', e: this.del, content: '删 除'}, - this.canExport && {icon: 'el-icon-download', type: 'info', e: this.downloadExcel, content: '导 出'} - ] - }, listPageConfig() { return { - loading: this.config.loading, - tableConfig: { + pageLoading: this.config.operating, + buttons: [ + this.canAdd && {icon: 'el-icon-plus', e: this.add, content: '添 加'}, + {icon: 'el-icon-view', e: this.see, content: '查 看'}, + this.canUpdate && {icon: 'el-icon-edit', e: this.edit, content: '编 辑'}, + this.canDel && {icon: 'el-icon-delete', e: this.del, content: '删 除'}, + this.canExport && {icon: 'el-icon-download', e: this.downloadExcel, content: '导 出'} + ], + dataLoading: this.config.loading, + search: { + props: {model: this.searchForm}, + on: {search: this.search} + }, + table: { props: {data: this.tableData}, on: {'row-click': this.rowClick, 'expand-change': this.getSubList} }, - paginationConfig: { + pagination: { props: {model: this.searchForm}, on: {'current-change': this.pageChange} } diff --git a/vue/src/util/element-ui/elForm.js b/vue/src/util/element-ui/elForm.js new file mode 100644 index 0000000..e69de29 diff --git a/vue/src/util/element-ui/elTree.js b/vue/src/util/element-ui/elTree.js new file mode 100644 index 0000000..13346ae --- /dev/null +++ b/vue/src/util/element-ui/elTree.js @@ -0,0 +1,21 @@ +/** + * @desc el-tree展开折叠控制 + * @param ref el-tree实例 + * @param action 'expand' | 'collapse' + * @param level 展开的节点最大深度,为0时匹配全部节点 + * @param func 自定义展开的函数,传入一个node,优先使用 + */ +export function expandControl(ref, action = 'expand', level = 1, func) { + const handler = function () { + if (typeof func === 'function') { + return node => func(node) + } + + const expand = action === 'expand' + const forAll = level === 0 + + return node => node.expanded = forAll || node.level <= level ? expand : !expand + }() + + ref.store._getAllNodes().forEach(handler) +} diff --git a/vue/src/util/errorLog.js b/vue/src/util/errorLog.js deleted file mode 100644 index 598766b..0000000 --- a/vue/src/util/errorLog.js +++ /dev/null @@ -1,15 +0,0 @@ -import Vue from 'vue' -import {errorLog} from '@/config' - -if (errorLog) { - Vue.config.errorHandler = function (err, vm, info, a) { - //忽略image-viewer错误 - if (err.message === `Cannot read property 'complete' of undefined`) return - /*store.commit('errorLog/ADD_ERROR_LOG', { - err, - info, - url: window.location.href - })*/ - console.error('这是vue捕捉到的异常', err, info) - } -} diff --git a/vue/src/util/file.js b/vue/src/util/file.js index d5edcd4..f24ab4a 100644 --- a/vue/src/util/file.js +++ b/vue/src/util/file.js @@ -63,6 +63,6 @@ export function upload(blob, filename, options = {}) { //自动补全附件链接前缀 export function autoCompleteUrl(url) { if (isEmpty(url)) return '' - if (['http', 'https'].some(i => url.startsWith(i))) return url + if (url.startsWith('http')) return url return fileConfig.storePrefix + url } diff --git a/vue/src/util/secret.js b/vue/src/util/secret.js index ada8f32..73da95b 100644 --- a/vue/src/util/secret.js +++ b/vue/src/util/secret.js @@ -1,4 +1,7 @@ import pako from 'pako' +import md5 from 'js-md5' + +export {md5} export function unzip(b64Data) { let strData = atob(b64Data) diff --git a/vue/src/util/tree.js b/vue/src/util/tree.js index aded145..ec3861a 100644 --- a/vue/src/util/tree.js +++ b/vue/src/util/tree.js @@ -132,20 +132,6 @@ export function calc(node, valueKey = 'value', childrenKey = 'children') { return value } -/** - * el-tree展开收缩 - * 有兴趣的可以研究下怎么平滑展开收缩 - * @param ref el-tree实例 - * @param action expand | collapse - * @param level 展开的节点最大深度,为0时匹配全部节点 - */ -export function elTreeControl(ref, action = 'expand', level = 1) { - ref.store._getAllNodes().forEach(node => { - const value = action === 'expand' - node.expanded = level === 0 || node.level <= level ? value : !value - }) -} - export function getNodeId(arr) { if (!arr) return [] diff --git a/vue/src/view/app/common/ListPage/index.vue b/vue/src/view/app/common/ListPage/index.vue index fd33622..9225339 100644 --- a/vue/src/view/app/common/ListPage/index.vue +++ b/vue/src/view/app/common/ListPage/index.vue @@ -2,18 +2,32 @@ import AbstractTable from "@/component/abstract/Table" import AbstractPagination from "@/component/abstract/Pagination" import SearchForm from "@/component/form/Search" +import {isEmpty} from "@/util" -const renderSearchForm = (h, slot) => { - return slot && {slot()} +const renderSearchForm = (h, config, slot) => { + return slot && {slot()} } const renderButtons = (h, buttons) => { + if (buttons.length > 0 && isEmpty(buttons[0].type)) { + buttons[0].type = 'primary' + } return ( {buttons.map(button => { if (!button) return const {icon, type, content, e} = button - return {content} + return ( + + {content} + + ) })} ) @@ -34,19 +48,23 @@ export default { functional: true, props: { - loading: Boolean, - buttons: {type: Array, default: () => []}, - list: Object + data: Object }, render(h, context) { - const {props: {loading, buttons, list}, scopedSlots} = context + const {props: {data: {pageLoading, buttons, dataLoading, search, table, pagination}}, scopedSlots} = context return ( - - {renderSearchForm(h, scopedSlots.searchForm)} + + {renderSearchForm(h, search, scopedSlots.searchForm)} {renderButtons(h, buttons)} - {renderList(h, {...list, tableColumn: scopedSlots.tableColumn})} + {renderList(h, { + loading: dataLoading, + tableConfig: table, + tableColumn: scopedSlots.tableColumn, + paginationConfig: pagination + })} + {scopedSlots.default && scopedSlots.default()} ) } diff --git a/vue/src/view/app/login/LoginForm.vue b/vue/src/view/app/login/LoginForm.vue index a1d176a..b4e5cf7 100644 --- a/vue/src/view/app/login/LoginForm.vue +++ b/vue/src/view/app/login/LoginForm.vue @@ -54,9 +54,9 @@