|
|
|
@ -2,7 +2,7 @@ |
|
|
|
import {ref, computed, onMounted, nextTick} from 'vue'; |
|
|
|
import {ElMessage, ElMessageBox} from 'element-plus'; |
|
|
|
import {Delete, Back, Search} from '@element-plus/icons-vue'; |
|
|
|
import {getVirtualUnitTreeList, addVirtualUnit, delVirtualUnit} from '@/api/efcode/virtualUnit'; |
|
|
|
import {getVirtualUnitTreeList, addVirtualUnit, delVirtualUnit, updateVirtualUnit} from '@/api/efcode/virtualUnit'; |
|
|
|
import type {VirtualUnitVo, VirtualUnitForm} from '@/api/efcode/virtualUnit/types'; |
|
|
|
import SrzDeptFullLoadTree from '@/views/efcode/components/srz-dept-full-load-tree.vue'; |
|
|
|
|
|
|
|
@ -142,6 +142,30 @@ const tableRowClassName = ({row}: { row: TreeTableRow }) => { |
|
|
|
return ''; |
|
|
|
}; |
|
|
|
|
|
|
|
/** 下拉选择是/否字段变更 */ |
|
|
|
const handleFieldChange = async (row: TreeTableRow, field: 'virIncludeStatistics' | 'virIncludeSearch' | 'virShowAtBusiness', newValue: string) => { |
|
|
|
const oldValue = newValue === '是' ? '否' : '是'; |
|
|
|
try { |
|
|
|
await updateVirtualUnit({ virId: row.virId, [field]: newValue }); |
|
|
|
} catch (e: any) { |
|
|
|
row[field] = oldValue; |
|
|
|
ElMessage.error(e.message || '更新失败'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/** 自定义排序变更 */ |
|
|
|
let custOrderTimer: ReturnType<typeof setTimeout> | null = null; |
|
|
|
const handleCustOrderChange = (row: TreeTableRow) => { |
|
|
|
if (custOrderTimer) clearTimeout(custOrderTimer); |
|
|
|
custOrderTimer = setTimeout(async () => { |
|
|
|
try { |
|
|
|
await updateVirtualUnit({ virId: row.virId, custOrderNum: row.custOrderNum ?? 0 }); |
|
|
|
} catch (e: any) { |
|
|
|
ElMessage.error(e.message || '更新排序失败'); |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}; |
|
|
|
|
|
|
|
/** 删除虚拟单位节点 */ |
|
|
|
const handleDelete = async (row: TreeTableRow) => { |
|
|
|
if (row.children && row.children.length > 0) { |
|
|
|
@ -305,19 +329,64 @@ onMounted(() => { |
|
|
|
<span v-html="highlightName(row.virName)"></span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="virIncludeStatistics" label="统计" width="60" align="center"> |
|
|
|
<el-table-column prop="virIncludeStatistics" label="统计" width="100" align="center"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<el-radio-group |
|
|
|
v-if="selectedVirNode?.virId === row.virId" |
|
|
|
v-model="row.virIncludeStatistics" |
|
|
|
size="small" |
|
|
|
@change="(val: string) => handleFieldChange(row, 'virIncludeStatistics', val)" |
|
|
|
@click.stop |
|
|
|
> |
|
|
|
<el-radio-button value="是">是</el-radio-button> |
|
|
|
<el-radio-button value="否">否</el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
<span v-else :class="{ 'cell-red': row.virIncludeStatistics === '否' }">{{ row.virIncludeStatistics }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="virIncludeSearch" label="查询" width="100" align="center"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<span :class="{ 'cell-red': row.virIncludeStatistics === '否' }">{{ row.virIncludeStatistics }}</span> |
|
|
|
<el-radio-group |
|
|
|
v-if="selectedVirNode?.virId === row.virId" |
|
|
|
v-model="row.virIncludeSearch" |
|
|
|
size="small" |
|
|
|
@change="(val: string) => handleFieldChange(row, 'virIncludeSearch', val)" |
|
|
|
@click.stop |
|
|
|
> |
|
|
|
<el-radio-button value="是">是</el-radio-button> |
|
|
|
<el-radio-button value="否">否</el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
<span v-else :class="{ 'cell-red': row.virIncludeSearch === '否' }">{{ row.virIncludeSearch }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="virIncludeSearch" label="查询" width="60" align="center"> |
|
|
|
<el-table-column prop="virShowAtBusiness" label="业务" width="100" align="center"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<span :class="{ 'cell-red': row.virIncludeSearch === '否' }">{{ row.virIncludeSearch }}</span> |
|
|
|
<el-radio-group |
|
|
|
v-if="selectedVirNode?.virId === row.virId" |
|
|
|
v-model="row.virShowAtBusiness" |
|
|
|
size="small" |
|
|
|
@change="(val: string) => handleFieldChange(row, 'virShowAtBusiness', val)" |
|
|
|
@click.stop |
|
|
|
> |
|
|
|
<el-radio-button value="是">是</el-radio-button> |
|
|
|
<el-radio-button value="否">否</el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
<span v-else :class="{ 'cell-red': row.virShowAtBusiness === '否' }">{{ row.virShowAtBusiness }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="virShowAtBusiness" label="业务" width="60" align="center"> |
|
|
|
<el-table-column prop="custOrderNum" label="自定义排序" width="100" align="center"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<span :class="{ 'cell-red': row.virShowAtBusiness === '否' }">{{ row.virShowAtBusiness }}</span> |
|
|
|
<el-input-number |
|
|
|
v-if="selectedVirNode?.virId === row.virId" |
|
|
|
v-model="row.custOrderNum" |
|
|
|
:min="0" |
|
|
|
:controls="false" |
|
|
|
size="small" |
|
|
|
style="width: 70px;" |
|
|
|
@change="handleCustOrderChange(row)" |
|
|
|
@click.stop |
|
|
|
/> |
|
|
|
<span v-else>{{ row.custOrderNum ?? 0 }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作" width="70" align="center" fixed="right"> |
|
|
|
@ -435,6 +504,12 @@ onMounted(() => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
:deep(.el-table__row:hover) { |
|
|
|
td.el-table__cell { |
|
|
|
background-color: var(--el-color-primary-light-9) !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
:deep(.selected-row) { |
|
|
|
td.el-table__cell { |
|
|
|
background-color: var(--el-color-primary-light-7) !important; |
|
|
|
@ -452,6 +527,14 @@ onMounted(() => { |
|
|
|
font-weight: bold; |
|
|
|
} |
|
|
|
|
|
|
|
:deep(.el-radio-group) { |
|
|
|
flex-wrap: nowrap; |
|
|
|
} |
|
|
|
|
|
|
|
:deep(.el-radio-button__inner) { |
|
|
|
padding: 4px 8px; |
|
|
|
} |
|
|
|
|
|
|
|
:deep(.search-match) { |
|
|
|
color: #f56c6c; |
|
|
|
font-weight: bold; |
|
|
|
|