2024-10-23 20:53:58 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class='table-box'>
|
|
|
|
|
|
<ProTable
|
|
|
|
|
|
ref='proTable'
|
|
|
|
|
|
:columns='columns'
|
2024-10-31 08:51:30 +08:00
|
|
|
|
:request-api="getTableList"
|
2024-10-23 20:53:58 +08:00
|
|
|
|
>
|
2024-10-31 08:51:30 +08:00
|
|
|
|
<!-- :data='testSourceData' 如果要显示静态数据,就切换该配置-->
|
2024-10-23 20:53:58 +08:00
|
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
|
<template #tableHeader='scope'>
|
2024-11-28 14:30:49 +08:00
|
|
|
|
<el-button v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
2024-12-04 19:54:56 +08:00
|
|
|
|
<el-button v-auth.testSource="'delete'" type='danger' :icon='Delete'
|
2024-11-28 14:30:49 +08:00
|
|
|
|
plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
|
2024-12-04 20:00:04 +08:00
|
|
|
|
删除
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 表格操作 -->
|
|
|
|
|
|
<template #operation='scope'>
|
2024-11-28 14:30:49 +08:00
|
|
|
|
<el-button v-auth.testSource="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
|
|
|
|
|
<el-button v-auth.testSource="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
2024-11-28 14:30:49 +08:00
|
|
|
|
<TestSourcePopup :refresh-table='proTable?.getTableList' ref='testSourcePopup' />
|
|
|
|
|
|
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang='tsx' name='useRole'>
|
2024-11-26 15:41:20 +08:00
|
|
|
|
import { type TestSource } from '@/api/device/interface/testSource'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import { useHandleData } from '@/hooks/useHandleData'
|
|
|
|
|
|
import { useDownload } from '@/hooks/useDownload'
|
|
|
|
|
|
import { useAuthButtons } from '@/hooks/useAuthButtons'
|
|
|
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
|
|
|
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
2024-11-28 14:30:49 +08:00
|
|
|
|
import type{ ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2024-11-28 14:30:49 +08:00
|
|
|
|
import TestSourcePopup from './components/testSourcePopup.vue'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import {
|
2024-11-28 14:30:49 +08:00
|
|
|
|
getTestSourceList,deleteTestSource,
|
2024-11-26 15:41:20 +08:00
|
|
|
|
} from '@/api/device/testSource/index'
|
2024-11-28 14:30:49 +08:00
|
|
|
|
import { reactive, ref } from 'vue'
|
|
|
|
|
|
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
|
|
|
|
|
const testSourcePopup = ref()
|
2024-10-23 20:53:58 +08:00
|
|
|
|
const dictStore = useDictStore()
|
2024-11-28 14:30:49 +08:00
|
|
|
|
const modeStore = useModeStore();
|
2024-10-23 20:53:58 +08:00
|
|
|
|
// ProTable 实例
|
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
|
|
2024-11-28 14:30:49 +08:00
|
|
|
|
const getTableList = (params: any) => {
|
|
|
|
|
|
let newParams = JSON.parse(JSON.stringify(params))
|
|
|
|
|
|
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
|
|
|
|
|
newParams.pattern = patternId
|
|
|
|
|
|
return getTestSourceList(newParams)
|
|
|
|
|
|
}
|
2024-10-31 08:51:30 +08:00
|
|
|
|
|
2024-10-23 20:53:58 +08:00
|
|
|
|
// 表格配置项
|
2024-11-28 14:30:49 +08:00
|
|
|
|
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
|
2024-10-23 20:53:58 +08:00
|
|
|
|
{ type: 'selection', fixed: 'left', width: 70 },
|
|
|
|
|
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
|
|
|
|
|
{
|
2024-10-31 08:51:30 +08:00
|
|
|
|
prop: 'name',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '名称',
|
|
|
|
|
|
search: { el: 'input' },
|
|
|
|
|
|
minWidth: 180,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-10-31 08:51:30 +08:00
|
|
|
|
prop: 'devType',
|
2024-12-05 09:55:35 +08:00
|
|
|
|
label: '设备类型',
|
2024-12-02 08:50:21 +08:00
|
|
|
|
enum: dictStore.getDictData('S_Dev_Type_'+dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.code),
|
2024-11-28 14:30:49 +08:00
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
2024-10-24 09:59:31 +08:00
|
|
|
|
search: { el: 'select' },
|
2024-10-23 20:53:58 +08:00
|
|
|
|
minWidth: 220,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-10-31 08:51:30 +08:00
|
|
|
|
prop: 'type',
|
2024-12-05 09:55:35 +08:00
|
|
|
|
label: '检测源类型',
|
2024-11-28 14:30:49 +08:00
|
|
|
|
enum: dictStore.getDictData('Pq_Source_Type'),
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
2024-10-24 09:59:31 +08:00
|
|
|
|
search: { el: 'select' },
|
2024-10-23 20:53:58 +08:00
|
|
|
|
minWidth: 150,
|
|
|
|
|
|
},
|
2024-11-14 18:26:34 +08:00
|
|
|
|
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
|
2024-10-23 20:53:58 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
2024-11-28 14:30:49 +08:00
|
|
|
|
|
|
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<TestSource.ResTestSource> = {}) => {
|
|
|
|
|
|
testSourcePopup.value?.open(titleType, row,modeStore.currentMode)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量删除设备
|
|
|
|
|
|
const batchDelete = async (id: string[]) => {
|
|
|
|
|
|
await useHandleData(deleteTestSource, id, '删除所选检测源')
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除设备
|
|
|
|
|
|
const handleDelete = async (params: TestSource.ResTestSource) => {
|
|
|
|
|
|
await useHandleData(deleteTestSource, [params.id], `删除【${params.name}】检测源`)
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|