From 77f47db65eea4a0e2eccccaf3f145fd5b4956d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8C=E6=B5=B7?= <963808678@qq.com> Date: Mon, 17 Apr 2023 14:03:28 +0800 Subject: [PATCH] 4/17 --- src/components/Table/index.js | 291 +++++++++------- .../detail/components/textareaView.vue | 46 +-- src/views/main/BookingLedger/detail/index.vue | 314 +++++++++++------- .../detail/modules/mailingInfo.vue | 218 +++++++----- .../list/components/textareaView.vue | 46 +-- src/views/main/BookingLedger/list/index.vue | 19 +- 6 files changed, 560 insertions(+), 374 deletions(-) diff --git a/src/components/Table/index.js b/src/components/Table/index.js index fc40843..33f75c5 100644 --- a/src/components/Table/index.js +++ b/src/components/Table/index.js @@ -7,9 +7,10 @@ import './index.less' export default { components: { - draggable, columnSetting + draggable, + columnSetting }, - data () { + data() { return { needTotalList: [], @@ -49,9 +50,9 @@ export default { type: String, default: 'middle' }, - scroll:{ - type:Object, - default:() => ({ y: '50vh'}) + scroll: { + type: Object, + default: () => ({ y: '50vh' }) }, alert: { type: [Object, Boolean], @@ -85,72 +86,72 @@ export default { }, extraTool: { type: Array, - default: () => ([]) + default: () => [] } }), watch: { - 'localPagination.current' (val) { - this.pageURI && this.$router.push({ - ...this.$route, - name: this.$route.name, - params: Object.assign({}, this.$route.params, { - pageNo: val + 'localPagination.current'(val) { + this.pageURI && + this.$router.push({ + ...this.$route, + name: this.$route.name, + params: Object.assign({}, this.$route.params, { + pageNo: val + }) }) - }) }, - pageNum (val) { + pageNum(val) { Object.assign(this.localPagination, { current: val }) }, - pageSize (val) { + pageSize(val) { Object.assign(this.localPagination, { pageSize: val }) }, - showSizeChanger (val) { + showSizeChanger(val) { Object.assign(this.localPagination, { showSizeChanger: val }) } }, - created () { + created() { const { pageNo } = this.$route.params - const localPageNum = this.pageURI && (pageNo && parseInt(pageNo)) || this.pageNum - this.localPagination = ['auto', true].includes(this.showPagination) && Object.assign({}, this.localPagination, { - current: localPageNum, - pageSize: this.pageSize, - showSizeChanger: this.showSizeChanger, - //pageSizeOptions: ['10', '20', '30', '40', '50'], //分页选项 - showTotal: (total, range) => { - return range[0] + '-' + range[1] + '共' + total + '条' - } - }) || false + const localPageNum = (this.pageURI && pageNo && parseInt(pageNo)) || this.pageNum + this.localPagination = + (['auto', true].includes(this.showPagination) && + Object.assign({}, this.localPagination, { + current: localPageNum, + pageSize: this.pageSize, + showSizeChanger: this.showSizeChanger, + //pageSizeOptions: ['10', '20', '30', '40', '50'], //分页选项 + showTotal: (total, range) => { + return range[0] + '-' + range[1] + '共' + total + '条' + } + })) || + false this.needTotalList = this.initTotalList(this.columns) this.loadData() // this.columnsSetting = this.columns //记录选择显示的列,以当前路由为key - - - this.columnsSetting = [] - let cacheColumns=this.$ls.get(this.$route.path); - if(cacheColumns && cacheColumns.length>0){ - this.columnsSetting=cacheColumns; + let cacheColumns = this.$ls.get(this.$route.path) + if (cacheColumns && cacheColumns.length > 0) { + this.columnsSetting = cacheColumns - this.columns.forEach((item,index,arr)=>{ - let temp=this.columnsSetting.find(m=>m.dataIndex==item.dataIndex); + this.columns.forEach((item, index, arr) => { + let temp = this.columnsSetting.find(m => m.dataIndex == item.dataIndex) //如果存在 - if(temp){ - arr[index].checked=temp.checked; + if (temp) { + arr[index].checked = temp.checked } }) - + + this.columnsSetting = this.columns + } else { this.columnsSetting = this.columns - } - else{ - this.columnsSetting = this.columns } }, methods: { @@ -159,10 +160,15 @@ export default { * 如果参数为 true, 则强制刷新到第一页 * @param Boolean bool */ - refresh (bool = false) { - bool && (this.localPagination = Object.assign({}, { - current: 1, pageSize: this.pageSize - })) + refresh(bool = false) { + bool && + (this.localPagination = Object.assign( + {}, + { + current: 1, + pageSize: this.pageSize + } + )) this.loadData() }, /** @@ -171,22 +177,30 @@ export default { * @param {Object} filters 过滤条件 * @param {Object} sorter 排序条件 */ - loadData (pagination, filters, sorter) { + loadData(pagination, filters, sorter) { this.localLoading = true - const parameter = Object.assign({ - pageNo: (pagination && pagination.current) || - this.showPagination && this.localPagination.current || this.pageNum, - pageSize: (pagination && pagination.pageSize) || - this.showPagination && this.localPagination.pageSize || this.pageSize - }, - (sorter && sorter.field && { - sortField: sorter.field - }) || {}, - (sorter && sorter.order && { - sortOrder: sorter.order - }) || {}, { - ...filters - } + const parameter = Object.assign( + { + pageNo: + (pagination && pagination.current) || (this.showPagination && this.localPagination.current) || this.pageNum, + pageSize: + (pagination && pagination.pageSize) || + (this.showPagination && this.localPagination.pageSize) || + this.pageSize + }, + (sorter && + sorter.field && { + sortField: sorter.field + }) || + {}, + (sorter && + sorter.order && { + sortOrder: sorter.order + }) || + {}, + { + ...filters + } ) const result = this.data(parameter) // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data @@ -197,13 +211,15 @@ export default { this.localLoading = false return } - this.localPagination = this.showPagination && Object.assign({}, this.localPagination, { - current: r.pageNo, // pageNo, // 返回结果中的当前分页数 - total: r.totalRows, // totalCount, // 返回结果中的总记录数 - showSizeChanger: this.showSizeChanger, - pageSize: (pagination && pagination.pageSize) || - this.localPagination.pageSize - }) || false + this.localPagination = + (this.showPagination && + Object.assign({}, this.localPagination, { + current: r.pageNo, // pageNo, // 返回结果中的当前分页数 + total: r.totalRows, // totalCount, // 返回结果中的总记录数 + showSizeChanger: this.showSizeChanger, + pageSize: (pagination && pagination.pageSize) || this.localPagination.pageSize + })) || + false // 后端数据rows为null保存修复 if (r.rows == null) { r.rows = [] @@ -218,27 +234,32 @@ export default { // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小 // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能 try { - if ((['auto', true].includes(this.showPagination) && r.totalCount <= (r.totalPage * this.localPagination.pageSize))) { + if ( + ['auto', true].includes(this.showPagination) && + r.totalCount <= r.totalPage * this.localPagination.pageSize + ) { this.localPagination.hideOnSinglePage = true } } catch (e) { this.localPagination = false } - this.localDataSource = this.showPagination? r.rows:r // 返回结果中的数组数据 + this.localDataSource = this.showPagination ? r.rows : r // 返回结果中的数组数据 this.localLoading = false }) } }, - initTotalList (columns) { + initTotalList(columns) { const totalList = [] - columns && columns instanceof Array && columns.forEach(column => { - if (column.needTotal) { - totalList.push({ - ...column, - total: 0 - }) - } - }) + columns && + columns instanceof Array && + columns.forEach(column => { + if (column.needTotal) { + totalList.push({ + ...column, + total: 0 + }) + } + }) return totalList }, /** @@ -246,7 +267,7 @@ export default { * @param selectedRowKeys * @param selectedRows */ - updateSelect (selectedRowKeys, selectedRows) { + updateSelect(selectedRowKeys, selectedRows) { this.selectedRows = selectedRows this.selectedRowKeys = selectedRowKeys const list = this.needTotalList @@ -263,7 +284,7 @@ export default { /** * 清空 table 已选中项 */ - clearSelected () { + clearSelected() { if (this.rowSelection) { this.rowSelection.onChange([], []) this.updateSelect([], []) @@ -274,31 +295,40 @@ export default { * @param callback * @returns {*} */ - renderClear (callback) { + renderClear(callback) { if (this.selectedRowKeys.length <= 0) return null return ( - { - callback() - this.clearSelected() - }}>清空 + { + callback() + this.clearSelected() + }} + > + 清空 + ) }, - renderAlert () { + renderAlert() { // 绘制统计列数据 // eslint-disable-next-line no-unused-vars - const needTotalItems = this.needTotalList.map((item) => { - return ( - {item.title}总计 {!item.customRender ? item.total : item.customRender(item.total)} - ) + const needTotalItems = this.needTotalList.map(item => { + return ( + + {item.title}总计{' '} + {!item.customRender ? item.total : item.customRender(item.total)} + + ) }) // 绘制 清空 按钮 // eslint-disable-next-line no-unused-vars - const clearItem = (typeof this.alert.clear === 'boolean' && this.alert.clear) ? ( - this.renderClear(this.clearSelected) - ) : (this.alert !== null && typeof this.alert.clear === 'function') ? ( - this.renderClear(this.alert.clear) - ) : null + const clearItem = + typeof this.alert.clear === 'boolean' && this.alert.clear + ? this.renderClear(this.clearSelected) + : this.alert !== null && typeof this.alert.clear === 'function' + ? this.renderClear(this.alert.clear) + : null // 绘制 alert 组件 // 统一先去除alert组件 @@ -317,7 +347,7 @@ export default { this.columnsSetting = val this.$ls.set(this.$route.path, val) }, - renderHeader () { + renderHeader() { let tools = [ { icon: 'reload', @@ -342,8 +372,7 @@ export default { ) }, - onClick: () => { - } + onClick: () => {} }, { icon: 'setting', @@ -353,8 +382,7 @@ export default { //return return }, - onClick: () => { - } + onClick: () => {} } ] if (this.extraTool.length) { @@ -363,29 +391,25 @@ export default { return (
-
- {this.$scopedSlots.operator && this.$scopedSlots.operator()} -
+
{this.$scopedSlots.operator && this.$scopedSlots.operator()}
- { - tools.map(tool => { - if (tool.isDropdown) { - return ( - - - - - { tool.menu() } - - ) - } + {tools.map(tool => { + if (tool.isDropdown) { return ( - - - + + + + + {tool.menu()} + ) - }) - } + } + return ( + + + + ) + })}
) @@ -401,10 +425,15 @@ export default { } }, - render () { + render() { let props = {} const localKeys = Object.keys(this.$data) - const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert + const showAlert = + (typeof this.alert === 'object' && + this.alert !== null && + this.alert.show && + typeof this.rowSelection.selectedRowKeys !== 'undefined') || + this.alert Object.keys(T.props).forEach(k => { const localKey = `local${k.substring(0, 1).toUpperCase()}${k.substring(1)}` @@ -441,16 +470,24 @@ export default { return props[k] }) const table = ( - { this.$emit('expand', expanded, record) } }> - { Object.keys(this.$slots).map(name => ()) } + { + this.$emit('expand', expanded, record) + }} + > + {Object.keys(this.$slots).map(name => ( + + ))} ) return (
- { this.renderHeader() } - { showAlert ? this.renderAlert() : null } - { table } + {this.renderHeader()} + {showAlert ? this.renderAlert() : null} + {table}
) } diff --git a/src/views/main/BookingLedger/detail/components/textareaView.vue b/src/views/main/BookingLedger/detail/components/textareaView.vue index 731f6a6..8868ddd 100644 --- a/src/views/main/BookingLedger/detail/components/textareaView.vue +++ b/src/views/main/BookingLedger/detail/components/textareaView.vue @@ -9,7 +9,7 @@