Browse Source

明细添加字段设置功能封装开发

master
安虹睿 1 year ago
parent
commit
8a4cdb9531
  1. 65
      Code/Fe/src/components/commonTabel-drawer/index.vue
  2. 5
      Code/Fe/src/components/commonTabel-drawer/style/index.scss
  3. 47
      Code/Fe/src/components/rowDrop/index.vue
  4. 15
      Code/Fe/src/mixins/TableHeaderMixins.js
  5. 23
      Code/Fe/src/mixins/TableMixins.js
  6. 25
      Code/Fe/src/mixins/mixins.js
  7. 5
      Code/Fe/src/utils/defaultButtons.js
  8. 1
      Code/Fe/src/views/interfaceBoard/TestSchool.vue

65
Code/Fe/src/components/commonTabel-drawer/index.vue

@ -66,29 +66,42 @@
:propsData="propsData" :propsData="propsData"
> >
</curren-descriptions> </curren-descriptions>
<!-- todo-new 代码整理-->
<div
class="currenTabel-drawer-mx-header"
v-if="scope.value == 'mx' && (showDetailColumnsSet || showDetailFilters)"
>
<el-button
v-if="showDetailColumnsSet"
class="rowDropNotHideItem"
@click="columnsSettingHandle()"
>字段设置</el-button>
<!-- <el-button
type="primary"
v-if="showDetailFilters"
@click="detailFiltersHandle()"
>筛选</el-button> -->
</div>
<!-- 字段设置弹窗 -->
<rowDrop <rowDrop
@radio="rowDrop" @radio="rowDrop"
:tableColumns="tableColumns" :tableColumns="tableColumns"
:visible="rowDropVisible" :visible="rowDropVisible"
@closeRowDrop="closeRowDrop" @closeRowDrop="closeRowDrop"
:source="'detail_api'"
:innerMaxHeight="'calc(90vh - 400px)'"
></rowDrop> ></rowDrop>
<!-- currenTableDetails 组件 明细中带分页功能 --> <!-- currenTableDetails 组件 明细中带分页功能 -->
<!-- 字段设置弹窗 -->
<!-- <div
class="mx-header"
v-if="scope.value == 'mx'"
>
<el-button @click="columnsSettingHandle()">字段设置</el-button>
</div> -->
<umyTable <umyTable
v-if="scope.value == 'mx'" v-if="scope.value == 'mx'"
:isUpdate="isUpdate"
:tableBorder="true" :tableBorder="true"
:tableData="propsData.details" :tableData="propsData.details"
:propsData="propsData" :propsData="propsData"
:tableColumns="tableColumns" :tableColumns="tableColumns"
:selectionTable="selectionTable" :selectionTable="selectionTable"
:requiredRules="false" :requiredRules="false"
:setUTableHeight="260" :setUTableHeight="showDetailColumnsSet ? 305 : 260"
@sortChange="sortChange" @sortChange="sortChange"
@handleSelectionChange="handleSelectionChange" @handleSelectionChange="handleSelectionChange"
@inlineDialog="inlineDialog" @inlineDialog="inlineDialog"
@ -189,6 +202,7 @@ import currenTabs from "@/components/currenTabs"
import currenTable from "@/components/currenTable" import currenTable from "@/components/currenTable"
import pagination from "@/components/Pagination" import pagination from "@/components/Pagination"
import rowDrop from "@/components/rowDrop/index.vue" import rowDrop from "@/components/rowDrop/index.vue"
import { getParentNode } from '@/utils'
export default { export default {
name: 'currenTabel-drawer', name: 'currenTabel-drawer',
components: { components: {
@ -200,6 +214,16 @@ export default {
rowDrop rowDrop
}, },
props: { props: {
// -
showDetailColumnsSet:{
type: Boolean,
default: true
},
// -
showDetailFilters:{
type: Boolean,
default: true
},
title: { title: {
type: Array, type: Array,
default: () => { default: () => {
@ -343,9 +367,22 @@ export default {
}, },
}, },
mounted () { mounted () {
//
document.addEventListener('click',(e)=>{
if(!this.rowDropVisible)return
let _class = "rowDropNotHideItem"
let _hasParent = getParentNode(e.target,_class)
let _current_class = e.target._prevClass || e.target.className
let _hasCurrent = _current_class ? String(_current_class).includes(_class) : false
if(!_hasParent && !_hasCurrent){
this.closeRowDrop()
}
})
}, },
data () { data () {
return { return {
// table key
isUpdate: false,
// - // -
rowDropVisible: false, rowDropVisible: false,
otherData:[], // tabs otherData:[], // tabs
@ -369,13 +406,17 @@ export default {
} }
}, },
methods: { methods: {
rowDrop(data) { rowDrop(data,type) {
this.$emit('rowDrop',data) this.$emit('rowDrop',data,type)
// this.isUpdate = !this.isUpdate this.isUpdate = !this.isUpdate
}, },
// // -
columnsSettingHandle(){ columnsSettingHandle(){
this.rowDropVisible = !this.rowDropVisible this.rowDropVisible = !this.rowDropVisible
},
// -
detailFiltersHandle(){
}, },
// //
closeRowDrop() { closeRowDrop() {

5
Code/Fe/src/components/commonTabel-drawer/style/index.scss

@ -120,3 +120,8 @@
::v-deep .el-tabs__nav-wrap::after{ ::v-deep .el-tabs__nav-wrap::after{
content: unset !important; content: unset !important;
} }
.currenTabel-drawer-mx-header{
text-align: right;
padding: 0 10px 10px 0;
}

47
Code/Fe/src/components/rowDrop/index.vue

@ -15,7 +15,7 @@
<i class="el-icon-success icon" v-if="allSeletType == 'NoSelect'" style="color:#999" ></i> <i class="el-icon-success icon" v-if="allSeletType == 'NoSelect'" style="color:#999" ></i>
全选 全选
</div> </div>
<transition-group class="transition-wrapper" name="sort"> <transition-group class="transition-wrapper" :style="{maxHeight:innerMaxHeight}" name="sort">
<div <div
v-for="(item,index) in dataList" v-for="(item,index) in dataList"
:key='index+item.label' :key='index+item.label'
@ -65,18 +65,27 @@ export default {
} }
}, },
props: { props: {
visible: { innerMaxHeight:{
type: Boolean, type:String,
default: () => { default:'calc(90vh - 280px)'
return false },
} visible: {
}, type: Boolean,
tableColumns: { default: () => {
type: Array, return false
default: () => { }
return []; },
}, tableColumns: {
}, type: Array,
default: () => {
return [];
},
},
// list_api detail_api detailPage_api list detail detailPage
source:{
type:String,
default:'list_api'
}
}, },
mounted() { mounted() {
this.historyTableColumns = JSON.parse(JSON.stringify(this.tableColumns)) this.historyTableColumns = JSON.parse(JSON.stringify(this.tableColumns))
@ -92,8 +101,8 @@ export default {
cancelButtonClass:'rowDropNotHideItem' cancelButtonClass:'rowDropNotHideItem'
}).then(() => { }).then(() => {
// set this.$store.getters.name.userName // set this.$store.getters.name.userName
localStorage.setItem('tableColumns_' + this.userName + '_' + this.$route.name, JSON.stringify([])) localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify([]))
localStorage.removeItem('tableColumns_' + this.userName + '_' + this.$route.name) localStorage.removeItem('file_Columns_' + this.source + '_' +this.userName + '_' + this.$route.name)
// let _resetCol = this.$isTableColumns[this.$route.name] // let _resetCol = this.$isTableColumns[this.$route.name]
let _resetCol = this.historyTableColumns let _resetCol = this.historyTableColumns
_resetCol.forEach(item => { _resetCol.forEach(item => {
@ -101,7 +110,7 @@ export default {
}) })
this.dataList = _resetCol this.dataList = _resetCol
this.initSelectSta() this.initSelectSta()
this.$emit('radio',_resetCol) this.$emit('radio',_resetCol,this.source)
this.close() this.close()
}).catch(() => { }).catch(() => {
@ -121,9 +130,9 @@ export default {
}, },
save () { save () {
this.$forceUpdate() this.$forceUpdate()
this.$emit('radio',this.dataList) this.$emit('radio',this.dataList,this.source)
// + // +
localStorage.setItem('tableColumns_' + this.userName + '_' + this.$route.name, JSON.stringify(this.dataList)) localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify(this.dataList))
}, },
dragstart(value) { dragstart(value) {
this.oldData = value this.oldData = value
@ -194,7 +203,7 @@ $paddingSize:20px;
} }
.transition-wrapper { .transition-wrapper {
display: block; display: block;
max-height: calc(90vh - 280px); // max-height: calc(90vh - 280px);
overflow: auto; overflow: auto;
padding: 0 0 $paddingSize $paddingSize; padding: 0 0 $paddingSize $paddingSize;

15
Code/Fe/src/mixins/TableHeaderMixins.js

@ -297,9 +297,18 @@ export const TableHeaderMixins = {
}); });
} }
}, },
// 表头字段设置 /**
rowDrop(data) { * 表头字段设置
this.tableColumns = data * @param {*} data 数据
* @param {*} type 设置来源
* list_api: 表头来自api的列表 detail_api: 表头来自api列表的明细
* list: 表头固定的列表 detail: 表头固定列表的明细
*/
rowDrop(data,type) {
if(!type || type == 'list_api'){ this.apiColumns_Table = data }
if(type && type == 'detail_api'){ this.apiColumns_DetailsTable = data }
if(type && type == 'list'){ this.tableColumns = data }
if(type && type == 'detail'){ this.detailsTableColumns = data }
} }
} }
} }

23
Code/Fe/src/mixins/TableMixins.js

@ -38,10 +38,6 @@ export const tableMixins = {
tableDataDetails:[], tableDataDetails:[],
//默认tag //默认tag
firstTabs:'xq', firstTabs:'xq',
// api的表头原始数据
apiColumns_Table_copy:null,
apiColumns_DesTions_copy:null,
apiColumns_DetailsTable_copy:null,
// api的表头数据 // api的表头数据
apiColumns_Table:null, apiColumns_Table:null,
apiColumns_DesTions:null, apiColumns_DesTions:null,
@ -54,29 +50,14 @@ export const tableMixins = {
operationButtonsTable:[{label:'查看详情',name:'info'}] operationButtonsTable:[{label:'查看详情',name:'info'}]
} }
}, },
mounted() {
// 用于api表头的字段设置监听同步
window.addEventListener('setItemEvent', (item) => {
if (item.key.indexOf('tableColumns') > -1) {
if(JSON.parse(item.newValue).length <= 0){
this.apiColumns_Table = this.apiColumns_Table_copy[this.$route.name]
}else{
this.apiColumns_Table = JSON.parse(item.newValue)
}
}
})
},
methods: { methods: {
// 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题 // 获取通过api的表头数据,不可以在初始化处理,因为接口返回问题
initApiColumns(tableColumns_api,tabsDesTions_api,detailsTableColumns_api){ initApiColumns(tableColumns_api,tabsDesTions_api,detailsTableColumns_api){
// 复制一份原始数据(目的:字段设置恢复)
this.apiColumns_Table_copy = JSON.parse(JSON.stringify(tableColumns_api))
this.apiColumns_DesTions_copy = JSON.parse(JSON.stringify(tabsDesTions_api))
this.apiColumns_DetailsTable_copy = JSON.parse(JSON.stringify(detailsTableColumns_api))
// 赋值表头数据 // 赋值表头数据
this.apiColumns_Table = this.initTableColumns(tableColumns_api[this.$route.name]) this.apiColumns_Table = this.initTableColumns(tableColumns_api[this.$route.name])
this.apiColumns_DesTions = tabsDesTions_api[this.$route.name] this.apiColumns_DesTions = tabsDesTions_api[this.$route.name]
this.apiColumns_DetailsTable = detailsTableColumns_api[this.$route.name] this.apiColumns_DetailsTable = this.initTableColumns(detailsTableColumns_api[this.$route.name],'detail_api')
}, },
//渲染数据 //渲染数据
paging(callback) { paging(callback) {

25
Code/Fe/src/mixins/mixins.js

@ -54,11 +54,12 @@ export const mixins = {
}, },
methods: { methods: {
// 结合默认及缓存中的列表tableColumns数据做初始化 // 结合默认及缓存中的列表tableColumns数据做初始化
initTableColumns(){ initTableColumns(columnsData,type){
let _list_defalut = columnsData ? columnsData : this.$isTableColumns[this.$route.name] let _list_defalut = columnsData ? columnsData : this.$isTableColumns[this.$route.name]
let _type = type ? type : 'list_api'
if(!_list_defalut)return if(!_list_defalut)return
let _local = localStorage.getItem('tableColumns_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name) let _local = localStorage.getItem('file_Columns_' + _type + '_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name)
let _list_local = JSON.parse(localStorage.getItem('tableColumns_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name)) let _list_local = JSON.parse(localStorage.getItem('file_Columns_' + _type + '_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name))
let _new_list = [] //格式化后的数据 let _new_list = [] //格式化后的数据
// 如果没有缓存则直接为默认值 // 如果没有缓存则直接为默认值
if(!_local){ if(!_local){
@ -71,14 +72,16 @@ export const mixins = {
else{ else{
// 先处理缓存数据,设置索引 // 先处理缓存数据,设置索引
let _locals = {} let _locals = {}
_list_local.forEach((localItem,index) => { if(_list_local){
localItem.itemIndex = index _list_local.forEach((localItem,index) => {
if(localItem.showProp && typeof localItem.showProp == 'string'){ localItem.itemIndex = index
_locals[localItem.showProp] = localItem if(localItem.showProp && typeof localItem.showProp == 'string'){
}else{ _locals[localItem.showProp] = localItem
_locals[localItem.prop] = localItem }else{
} _locals[localItem.prop] = localItem
}) }
})
}
// 将缓存与默认设置合并,索引同步 // 将缓存与默认设置合并,索引同步
let _number = 0 let _number = 0
_list_defalut.forEach((defalutItem) => { _list_defalut.forEach((defalutItem) => {

5
Code/Fe/src/utils/defaultButtons.js

@ -40,9 +40,10 @@ export function defaultExportBtn(option) {
} }
// 字段设置 // 字段设置
export function defaultFieldSettingBtn(option) { export function defaultFieldSettingBtn(option,source) {
let _source = source ? source : 'list_api'
// todo:监听已经配置过的字段按钮更改状态特殊显示 // todo:监听已经配置过的字段按钮更改状态特殊显示
let _local = localStorage.getItem('tableColumns_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name) let _local = localStorage.getItem('file_Columns_' + _source + '_' + JSON.parse(localStorage.getItem('currentUserInfo')).userName + '_' + this.$route.name)
let _type = '' let _type = ''
let _num = 0 let _num = 0
if(_local){ if(_local){

1
Code/Fe/src/views/interfaceBoard/TestSchool.vue

@ -28,6 +28,7 @@
></tablePagination> ></tablePagination>
<curren-Drawer <curren-Drawer
:title="apiColumns_DesTions" :title="apiColumns_DesTions"
@rowDrop="rowDrop"
:tableColumns="apiColumns_DetailsTable" :tableColumns="apiColumns_DetailsTable"
:tabsDesTions="apiColumns_DesTions" :tabsDesTions="apiColumns_DesTions"
:DrawerLoading="Loading.DrawerLoading" :DrawerLoading="Loading.DrawerLoading"

Loading…
Cancel
Save