Merge branch 'main' of http://192.168.1.22:3000/Web/admin-govern
This commit is contained in:
@@ -1,24 +1,44 @@
|
||||
<template>
|
||||
<div :style="{ height: typeof props.height === 'string' ? props.height : tableStore.table.height }">
|
||||
<vxe-table ref="tableRef" height="auto" :key="key" :data="tableStore.table.data"
|
||||
v-loading="tableStore.table.loading" v-bind="Object.assign({}, defaultAttribute, $attrs)"
|
||||
@checkbox-all="selectChangeEvent" @checkbox-change="selectChangeEvent" :showOverflow="showOverflow"
|
||||
:sort-config="{ remote: true }" @sort-change="handleSortChange">
|
||||
<vxe-table
|
||||
ref="tableRef"
|
||||
height="auto"
|
||||
:key="key"
|
||||
:data="tableStore.table.data"
|
||||
v-loading="tableStore.table.loading"
|
||||
v-bind="Object.assign({}, defaultAttribute, $attrs)"
|
||||
@checkbox-all="selectChangeEvent"
|
||||
@checkbox-change="selectChangeEvent"
|
||||
:showOverflow="showOverflow"
|
||||
:sort-config="{ remote: true }"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
<!-- Column 组件内部是 el-table-column -->
|
||||
<template v-if="isGroup">
|
||||
<GroupColumn :column="tableStore.table.column" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<Column :attr="item" :key="key + '-column'" v-for="(item, key) in tableStore.table.column"
|
||||
:tree-node="item.treeNode">
|
||||
<Column
|
||||
:attr="item"
|
||||
:key="key + '-column'"
|
||||
v-for="(item, key) in tableStore.table.column"
|
||||
:tree-node="item.treeNode"
|
||||
>
|
||||
<!-- tableStore 预设的列 render 方案 -->
|
||||
<template v-if="item.render" #default="scope">
|
||||
<FieldRender :field="item" :row="scope.row" :column="scope.column" :index="scope.rowIndex" :key="key +
|
||||
'-' +
|
||||
item.render +
|
||||
'-' +
|
||||
(item.field ? '-' + item.field + '-' + scope.row[item.field] : '')
|
||||
" />
|
||||
<FieldRender
|
||||
:field="item"
|
||||
:row="scope.row"
|
||||
:column="scope.column"
|
||||
:index="scope.rowIndex"
|
||||
:key="
|
||||
key +
|
||||
'-' +
|
||||
item.render +
|
||||
'-' +
|
||||
(item.field ? '-' + item.field + '-' + scope.row[item.field] : '')
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
</Column>
|
||||
</template>
|
||||
@@ -27,11 +47,16 @@
|
||||
</div>
|
||||
|
||||
<div v-if="tableStore.showPage" class="table-pagination">
|
||||
<el-pagination :currentPage="tableStore.table.params!.pageNum" :page-size="tableStore.table.params!.pageSize"
|
||||
:page-sizes="pageSizes" background
|
||||
<el-pagination
|
||||
:currentPage="tableStore.table.params!.pageNum"
|
||||
:page-size="tableStore.table.params!.pageSize"
|
||||
:page-sizes="pageSizes"
|
||||
background
|
||||
:layout="config.layout.shrink ? 'prev, next, jumper' : 'sizes,total, ->, prev, pager, next, jumper'"
|
||||
:total="tableStore.table.total" @size-change="onTableSizeChange"
|
||||
@current-change="onTableCurrentChange"></el-pagination>
|
||||
:total="tableStore.table.total"
|
||||
@size-change="onTableSizeChange"
|
||||
@current-change="onTableCurrentChange"
|
||||
></el-pagination>
|
||||
</div>
|
||||
<slot name="footer"></slot>
|
||||
</template>
|
||||
@@ -125,6 +150,7 @@ watch(
|
||||
() => tableStore.table.allFlag,
|
||||
newVal => {
|
||||
if (tableStore.table.allFlag) {
|
||||
console.log('🚀 ~ tableStore.table.allData:', tableStore.table.allData)
|
||||
|
||||
tableRef.value?.exportData({
|
||||
filename: tableStore.exportName || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || '', // 文件名字
|
||||
|
||||
@@ -18,6 +18,7 @@ interface TableStoreParams {
|
||||
publicHeight?: number //计算高度
|
||||
resetCallback?: () => void // 重置
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
exportProcessingData?: () => void //导出处理数据
|
||||
beforeSearchFun?: () => void // 接口调用前的回调
|
||||
}
|
||||
|
||||
@@ -47,6 +48,7 @@ export default class TableStore {
|
||||
column: [],
|
||||
loadCallback: null,
|
||||
resetCallback: null,
|
||||
exportProcessingData: null,
|
||||
beforeSearchFun: null,
|
||||
height: '',
|
||||
publicHeight: 0
|
||||
@@ -64,6 +66,7 @@ export default class TableStore {
|
||||
this.table.publicHeight = options.publicHeight || 0
|
||||
this.table.resetCallback = options.resetCallback || null
|
||||
this.table.loadCallback = options.loadCallback || null
|
||||
this.table.exportProcessingData = options.exportProcessingData || null
|
||||
this.table.beforeSearchFun = options.beforeSearchFun || null
|
||||
Object.assign(this.table.params, options.params)
|
||||
this.table.height = mainHeight(20 + (this.showPage ? 58 : 0) + this.table.publicHeight).height as string
|
||||
@@ -187,26 +190,21 @@ export default class TableStore {
|
||||
[
|
||||
'export',
|
||||
() => {
|
||||
ElMessage({
|
||||
message: '正在导出,请稍等...',
|
||||
type: 'info',
|
||||
duration: 1000
|
||||
})
|
||||
// this.index()
|
||||
let params = { ...this.table.params, pageNum: 1, pageSize: this.table.total }
|
||||
setTimeout(() => {
|
||||
createAxios(
|
||||
Object.assign(
|
||||
{
|
||||
url: this.url,
|
||||
method: this.method
|
||||
},
|
||||
requestPayload(this.method, params, this.paramsPOST)
|
||||
)
|
||||
).then(res => {
|
||||
this.table.allData = filtration(res.data.records || res.data)
|
||||
this.table.allFlag = data.showAllFlag || true
|
||||
})
|
||||
}, 1500)
|
||||
createAxios(
|
||||
Object.assign(
|
||||
{
|
||||
url: this.url,
|
||||
method: this.method
|
||||
},
|
||||
requestPayload(this.method, params, this.paramsPOST)
|
||||
)
|
||||
).then(res => {
|
||||
this.table.allData = filtration(res.data.records || res.data)
|
||||
this.table.exportProcessingData && this.table.exportProcessingData()
|
||||
this.table.allFlag = data.showAllFlag || true
|
||||
})
|
||||
}
|
||||
]
|
||||
])
|
||||
|
||||
@@ -150,6 +150,8 @@ const checkChange = (data: any) => {
|
||||
updateRoleMenu({
|
||||
id: menuListId.value,
|
||||
idList: treeRef.value.treeRef.getCheckedNodes(false, true).map((node: any) => node.id)
|
||||
}).then(() => {
|
||||
ElMessage.success('操作成功!')
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@ const tableStore = new TableStore({
|
||||
fixed: 'right',
|
||||
render: 'tag',
|
||||
custom: {
|
||||
功能调试: 'warning',
|
||||
出厂调试: 'warning',
|
||||
正式投运: 'success'
|
||||
2: 'warning',
|
||||
3: 'warning',
|
||||
4: 'success'
|
||||
},
|
||||
replaceValue: {
|
||||
功能调试: '功能调试',
|
||||
出厂调试: '出厂调试',
|
||||
正式投运: '正式投运'
|
||||
2: '功能调试',
|
||||
3: '出厂调试',
|
||||
4: '正式投运'
|
||||
},
|
||||
minWidth: 80
|
||||
},
|
||||
@@ -142,11 +142,14 @@ const tableStore = new TableStore({
|
||||
{ title: '完整性(%)', fixed: 'right', width: 100, field: 'integrity', sortable: true }
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data.forEach(item => {
|
||||
exportProcessingData: () => {
|
||||
tableStore.table.allData = tableStore.table.allData.filter(item => {
|
||||
item.process = item.process == 2 ? '功能调试' : item.process == 3 ? '出厂调试' : '正式投运'
|
||||
return item
|
||||
})
|
||||
|
||||
console.log('🚀 ~ tableStore.table.allData:', tableStore.table.allData)
|
||||
},
|
||||
loadCallback: () => {
|
||||
let name = tableStore.table.params.name
|
||||
let data = tableStore.table.copyData.filter(item => {
|
||||
// 处理latestTime默认值
|
||||
@@ -182,7 +185,10 @@ const exportTab = () => {
|
||||
sheetName: 'Sheet1',
|
||||
type: 'xlsx', //导出文件类型 xlsx 和 csv
|
||||
useStyle: true,
|
||||
data: tableStore.table.copyData, // 数据源 // 过滤那个字段导出
|
||||
data: tableStore.table.copyData.filter(item => {
|
||||
item.process = item.process == 2 ? '功能调试' : item.process == 3 ? '出厂调试' : '正式投运'
|
||||
return item
|
||||
}), // 数据源 // 过滤那个字段导出
|
||||
columnFilterMethod: function (column: any) {
|
||||
return !(
|
||||
column.column.title === undefined ||
|
||||
|
||||
@@ -107,8 +107,8 @@ const editd = (e: any) => {
|
||||
}
|
||||
// 设计
|
||||
const Aclick = (e: any) => {
|
||||
// window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`)
|
||||
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`)
|
||||
// window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`)
|
||||
|
||||
}
|
||||
// 删除
|
||||
@@ -143,8 +143,8 @@ const deleted = (e: any) => {
|
||||
}
|
||||
|
||||
const imgData = (e: any) => {
|
||||
// window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`)
|
||||
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`)
|
||||
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`)
|
||||
// window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`)
|
||||
|
||||
}
|
||||
|
||||
|
||||
22
types/table.d.ts
vendored
22
types/table.d.ts
vendored
@@ -8,8 +8,8 @@ declare global {
|
||||
interface CnTable {
|
||||
ref: VxeTableInstance | null
|
||||
data: TableRow[] | any
|
||||
copyData: TableRow[] | any
|
||||
allData: TableRow[] | any
|
||||
filename: any
|
||||
allFlag: Boolean
|
||||
// 前端分页数据
|
||||
webPagingData: TableRow[][]
|
||||
@@ -29,6 +29,7 @@ declare global {
|
||||
loadCallback: (() => void) | null
|
||||
resetCallback: (() => void) | null
|
||||
beforeSearchFun: (() => void) | null
|
||||
exportProcessingData: (() => void) | null
|
||||
height: string
|
||||
publicHeight: number
|
||||
}
|
||||
@@ -50,6 +51,7 @@ declare global {
|
||||
| 'buttons'
|
||||
| 'slot'
|
||||
| 'customTemplate'
|
||||
| 'renderFormatter'
|
||||
| 'customRender'
|
||||
// 默认值
|
||||
default?: any
|
||||
@@ -59,14 +61,15 @@ declare global {
|
||||
custom?: any
|
||||
// 值替换数据,如{open: '开'}
|
||||
replaceValue?: any
|
||||
effect?: any
|
||||
// 时间格式化
|
||||
timeFormat?: string
|
||||
// 开关控制
|
||||
onChangeField?: (row: TableRow, value: any) => void
|
||||
activeValue?: string
|
||||
inactiveValue?: string
|
||||
activeText?: string
|
||||
inactiveText?: string
|
||||
// 开关控制
|
||||
onChangeField?: (row: TableRow, value: any) => void
|
||||
activeValue?: string
|
||||
inactiveValue?: string
|
||||
activeText?: string
|
||||
inactiveText?: string
|
||||
// 自定义组件/函数渲染
|
||||
customRender?: string | Component
|
||||
// 使用了 render 属性时,渲染前对字段值的预处理方法,请返回新值
|
||||
@@ -80,6 +83,8 @@ declare global {
|
||||
index: number
|
||||
) => string
|
||||
children?: TableColumn[]
|
||||
property?: string
|
||||
clickable?: boolean // 是否可点击
|
||||
}
|
||||
|
||||
/* 表格右侧操作按钮 */
|
||||
@@ -90,15 +95,16 @@ declare global {
|
||||
title?: string
|
||||
text?: string
|
||||
class?: string
|
||||
loading?: string
|
||||
type: ButtonType
|
||||
icon: string
|
||||
popconfirm?: Partial<Mutable<PopconfirmProps>>
|
||||
disabledTip?: boolean
|
||||
// 自定义点击事件
|
||||
click?: (row: TableRow, field: TableColumn) => void
|
||||
|
||||
// 按钮是否禁用,请返回布尔值
|
||||
disabled?: (row: TableRow, field: TableColumn) => boolean
|
||||
showDisabled?: (row: TableRow, field: TableColumn) => boolean
|
||||
// 自定义el-button属性
|
||||
attr?: Partial<Mutable<ButtonProps>>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user