修改表格多按钮判断

This commit is contained in:
GGJ
2024-10-31 14:36:09 +08:00
parent 8427a61f4e
commit 9217ae0ae1
4 changed files with 48 additions and 76 deletions

View File

@@ -3,23 +3,13 @@
<Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" /> <Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" />
<!-- switch --> <!-- switch -->
<el-switch <el-switch v-if="field.render == 'switch'" @change="onChangeField" :model-value="fieldValue.toString()"
v-if="field.render == 'switch'" :loading="row.loading" active-value="1" inactive-value="0" />
@change="onChangeField"
:model-value="fieldValue.toString()"
:loading="row.loading"
active-value="1"
inactive-value="0"
/>
<!-- image --> <!-- image -->
<div v-if="field.render == 'image' && fieldValue" class="ba-render-image"> <div v-if="field.render == 'image' && fieldValue" class="ba-render-image">
<el-image <el-image :hide-on-click-modal="true" :preview-teleported="true" :preview-src-list="[fullUrl(fieldValue)]"
:hide-on-click-modal="true" :src="fullUrl(fieldValue)"></el-image>
:preview-teleported="true"
:preview-src-list="[fullUrl(fieldValue)]"
:src="fullUrl(fieldValue)"
></el-image>
</div> </div>
<!-- tag --> <!-- tag -->
@@ -40,54 +30,29 @@
</div> </div>
<!-- customTemplate 自定义模板 --> <!-- customTemplate 自定义模板 -->
<div <div v-if="field.render == 'customTemplate'"
v-if="field.render == 'customTemplate'" v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"></div>
v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"
></div>
<!-- 自定义组件/函数渲染 --> <!-- 自定义组件/函数渲染 -->
<component <component v-if="field.render == 'customRender'" :is="field.customRender" :renderRow="row" :renderField="field"
v-if="field.render == 'customRender'" :renderValue="fieldValue" :renderColumn="column" :renderIndex="index" />
:is="field.customRender"
:renderRow="row"
:renderField="field"
:renderValue="fieldValue"
:renderColumn="column"
:renderIndex="index"
/>
<!-- 按钮组 --> <!-- 按钮组 -->
<div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons"> <div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons">
<template v-for="(btn, idx) in buttons" :key="idx"> <template v-for="(btn, idx) in buttons" :key="idx">
<!-- 常规按钮 --> <!-- 常规按钮 -->
<el-button
link <el-button link v-if="btn.render == 'basicButton'" @click="onButtonClick(btn)" :class="btn.class"
v-if="btn.render == 'basicButton'" class="table-operate" :type="btn.type" :loading="props.row[btn.loading] || props.row.loading || false"
@click="onButtonClick(btn)" v-bind="btn.attr">
:class="btn.class"
class="table-operate"
:type="btn.type"
:loading="props.row.loading || false"
v-bind="btn.attr"
>
<div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div> <div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div>
</el-button> </el-button>
<!-- 带提示信息的按钮 --> <!-- 带提示信息的按钮 -->
<el-tooltip <el-tooltip v-if="btn.render == 'tipButton'" :disabled="btn.title && !btn.disabledTip ? false : true"
v-if="btn.render == 'tipButton'" :content="btn.title" placement="top">
:disabled="btn.title && !btn.disabledTip ? false : true" <el-button link @click="onButtonClick(btn)" :class="btn.class" class="table-operate" :type="btn.type"
:content="btn.title" v-bind="btn.attr">
placement="top"
>
<el-button
link
@click="onButtonClick(btn)"
:class="btn.class"
class="table-operate"
:type="btn.type"
v-bind="btn.attr"
>
<div v-if="btn.text || btn.title" class="table-operate-text"> <div v-if="btn.text || btn.title" class="table-operate-text">
{{ btn.text || btn.title }} {{ btn.text || btn.title }}
</div> </div>
@@ -95,12 +60,8 @@
</el-tooltip> </el-tooltip>
<!-- 带确认框的按钮 --> <!-- 带确认框的按钮 -->
<el-popconfirm <el-popconfirm v-if="btn.render == 'confirmButton'" :disabled="btn.disabled && btn.disabled(row, field)"
v-if="btn.render == 'confirmButton'" v-bind="btn.popconfirm" @confirm="onButtonClick(btn)">
:disabled="btn.disabled && btn.disabled(row, field)"
v-bind="btn.popconfirm"
@confirm="onButtonClick(btn)"
>
<template #reference> <template #reference>
<div style="display: inline-block"> <div style="display: inline-block">
<el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr"> <el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr">
@@ -118,14 +79,9 @@
</el-button> </el-button>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item <el-dropdown-item v-for="item in btn.buttons" :key="item.text" :command="item" :style="{
v-for="item in btn.buttons"
:key="item.text"
:command="item"
:style="{
color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger' color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger'
}" }">
>
{{ item.text }} {{ item.text }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@@ -225,29 +181,36 @@ const handlerCommand = (item: OptButton) => {
.m-10 { .m-10 {
margin: 4px; margin: 4px;
} }
.ba-render-image { .ba-render-image {
text-align: center; text-align: center;
} }
.images-item { .images-item {
width: 50px; width: 50px;
margin: 0 5px; margin: 0 5px;
} }
.el-image { .el-image {
height: 36px; height: 36px;
width: 36px; width: 36px;
} }
.table-operate-text { .table-operate-text {
padding-left: 5px; padding-left: 5px;
font-size: 12px; font-size: 12px;
} }
.table-operate { .table-operate {
padding: 4px 5px; padding: 4px 5px;
height: auto; height: auto;
} }
.cn-render-buttons { .cn-render-buttons {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
.icon { .icon {
font-size: 12px !important; font-size: 12px !important;
// color: var(--ba-bg-color-overlay) !important; // color: var(--ba-bg-color-overlay) !important;
@@ -257,18 +220,22 @@ const handlerCommand = (item: OptButton) => {
.move-button { .move-button {
cursor: move; cursor: move;
} }
.ml-6 { .ml-6 {
display: inline-flex; display: inline-flex;
vertical-align: middle; vertical-align: middle;
margin-left: 6px; margin-left: 6px;
} }
.ml-6+.el-button { .ml-6+.el-button {
margin-left: 6px; margin-left: 6px;
} }
.ba-render-color { .ba-render-color {
height: 25px; height: 25px;
width: 100%; width: 100%;
} }
.cn-render-buttons { .cn-render-buttons {
:deep(.el-button) { :deep(.el-button) {
margin-left: 0; margin-left: 0;

View File

@@ -122,18 +122,19 @@ const tableStore = new TableStore({
type: 'primary', type: 'primary',
icon: 'el-icon-DataLine', icon: 'el-icon-DataLine',
render: 'basicButton', render: 'basicButton',
loading: 'loading1',
disabled: row => { disabled: row => {
return !row.wavePath && row.evtParamTm < 20 return !row.wavePath && row.evtParamTm < 20
}, },
click: async row => { click: async row => {
row.loading = true row.loading1 = true
boxoList.value = row boxoList.value = row
boxoList.value.systemType = 'WX' boxoList.value.systemType = 'WX'
boxoList.value.featureAmplitude = row.evtParamVVaDepth != '-' ? (row.evtParamVVaDepth - 0) : null boxoList.value.featureAmplitude = row.evtParamVVaDepth != '-' ? (row.evtParamVVaDepth - 0) : null
boxoList.value.persistTime = row.evtParamTm != '-' ? (row.evtParamTm - 0) : null boxoList.value.persistTime = row.evtParamTm != '-' ? (row.evtParamTm - 0) : null
await analyseWave(row.id) await analyseWave(row.id)
.then(res => { .then(res => {
row.loading = false row.loading1 = false
if (res != undefined) { if (res != undefined) {
wp.value = res.data wp.value = res.data
view.value = false view.value = false
@@ -141,7 +142,7 @@ const tableStore = new TableStore({
} }
}) })
.catch(() => { .catch(() => {
row.loading = false row.loading1 = false
}) })
} }
}, },
@@ -150,18 +151,19 @@ const tableStore = new TableStore({
title: '波形下载', title: '波形下载',
type: 'primary', type: 'primary',
icon: 'el-icon-Check', icon: 'el-icon-Check',
loading: 'loading2',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
// && row.evtParamTm < 20 // && row.evtParamTm < 20
return !row.wavePath return !row.wavePath
}, },
click: row => { click: row => {
row.loading = true row.loading2 = true
const url = window.location.origin + '/api/cs-harmonic-boot/event/getFileZip?eventId=' + row.id const url = window.location.origin + '/api/cs-harmonic-boot/event/getFileZip?eventId=' + row.id
window.open(url, '_self') window.open(url, '_self')
setTimeout(() => { setTimeout(() => {
ElMessage.success('波形下载成功!') ElMessage.success('波形下载成功!')
row.loading = false row.loading2 = false
}, 1500) }, 1500)
} }
}, },

View File

@@ -83,16 +83,17 @@ const tableStore: any = new TableStore({
type: 'primary', type: 'primary',
icon: 'el-icon-Check', icon: 'el-icon-Check',
render: 'basicButton', render: 'basicButton',
loading:'loading1',
disabled: row => { disabled: row => {
// && row.evtParamTm < 20 // && row.evtParamTm < 20
return !row.wavePath return !row.wavePath
}, },
click: async row => { click: async row => {
row.loading = true row.loading1 = true
await analyseWave(row.id) await analyseWave(row.id)
.then(res => { .then(res => {
row.loading = false row.loading1 = false
if (res != undefined) { if (res != undefined) {
boxoList.value = row boxoList.value = row
boxoList.value.systemType = 'WX' boxoList.value.systemType = 'WX'
@@ -102,7 +103,7 @@ const tableStore: any = new TableStore({
} }
}) })
.catch(() => { .catch(() => {
row.loading = false row.loading1 = false
}) })
isWaveCharts.value = true isWaveCharts.value = true
nextTick(() => { nextTick(() => {
@@ -124,6 +125,7 @@ const tableStore: any = new TableStore({
name: 'edit', name: 'edit',
title: '波形下载', title: '波形下载',
type: 'primary', type: 'primary',
loading:'loading2',
icon: 'el-icon-Check', icon: 'el-icon-Check',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
@@ -131,12 +133,12 @@ const tableStore: any = new TableStore({
return !row.wavePath return !row.wavePath
}, },
click: row => { click: row => {
row.loading = true row.loading2 = true
const url = window.location.origin + '/api/cs-harmonic-boot/event/getFileZip?eventId=' + row.id const url = window.location.origin + '/api/cs-harmonic-boot/event/getFileZip?eventId=' + row.id
window.open(url, '_self') window.open(url, '_self')
setTimeout(() => { setTimeout(() => {
ElMessage.success('波形下载成功!') ElMessage.success('波形下载成功!')
row.loading = false row.loading2 = false
}, 1500) }, 1500)
} }
} }

1
types/table.d.ts vendored
View File

@@ -81,6 +81,7 @@ declare global {
title?: string title?: string
text?: string text?: string
class?: string class?: string
loading?: string
type: ButtonType type: ButtonType
icon: string icon: string
popconfirm?: Partial<Mutable<PopconfirmProps>> popconfirm?: Partial<Mutable<PopconfirmProps>>