2024-08-26 20:05:04 +08:00
|
|
|
|
<template>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
<div class='table-box'>
|
|
|
|
|
|
<ProTable
|
|
|
|
|
|
ref='proTable'
|
|
|
|
|
|
:columns='columns'
|
2024-11-21 14:42:26 +08:00
|
|
|
|
:request-api="getTableList"
|
2024-10-23 20:53:58 +08:00
|
|
|
|
>
|
2024-10-31 08:51:30 +08:00
|
|
|
|
<!-- :data='testScriptData' 如果要显示静态数据,就切换该配置 -->
|
2024-10-23 20:53:58 +08:00
|
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
|
<template #tableHeader='scope'>
|
2024-11-20 15:13:50 +08:00
|
|
|
|
<el-button v-auth.testScript="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
2024-12-04 19:54:56 +08:00
|
|
|
|
<el-button v-auth.testScript="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
2024-11-19 16:30:03 +08:00
|
|
|
|
@click='batchDelete(scope.selectedListIds)'>
|
2024-10-24 13:24:54 +08:00
|
|
|
|
批量删除
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 表格操作 -->
|
|
|
|
|
|
<template #operation='scope'>
|
2024-11-21 10:05:44 +08:00
|
|
|
|
<el-button v-auth.testScript="'edit'" type='primary' link :icon='EditPen' :model-value="false" @click="openDialog('edit', scope.row)">编辑</el-button>
|
|
|
|
|
|
<el-button v-auth.testScript="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
2024-11-20 15:13:50 +08:00
|
|
|
|
<el-button v-auth.testScript="'upgrade'" type='primary' v-if="scope.row.type !== 1" link :icon='Share' @click='updateType(scope.row)'>升级</el-button>
|
2024-11-19 16:30:03 +08:00
|
|
|
|
</template>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|
|
|
|
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
2024-11-21 14:42:26 +08:00
|
|
|
|
<ComparisonPopup :refresh-table='proTable?.getTableList' ref='comparisonPopup' />
|
|
|
|
|
|
<TestScriptPopup :refresh-table='proTable?.getTableList' ref='testScriptPopup' />
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|
2024-08-26 20:05:04 +08:00
|
|
|
|
</template>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|
|
|
|
|
|
<script setup lang='tsx' name='useRole'>
|
2024-11-18 16:02:19 +08:00
|
|
|
|
import { type TestScript } from '@/api/device/interface/testScript'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import { useHandleData } from '@/hooks/useHandleData'
|
|
|
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
2024-11-18 16:02:19 +08:00
|
|
|
|
import type{ ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
2024-11-19 16:30:03 +08:00
|
|
|
|
import { CirclePlus, Delete, EditPen, Share } from '@element-plus/icons-vue'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2024-11-21 14:42:26 +08:00
|
|
|
|
import ComparisonPopup from './components/comparisonPopup.vue'
|
|
|
|
|
|
import TestScriptPopup from './components/testScriptPopup.vue'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import {
|
2024-11-19 16:30:03 +08:00
|
|
|
|
getPqScriptList,updatePqScript,deletePqScript,
|
2024-11-18 16:02:19 +08:00
|
|
|
|
} from '@/api/device/testScript/index'
|
2024-11-21 15:51:53 +08:00
|
|
|
|
import { computed, reactive, ref } from 'vue'
|
2024-11-21 14:42:26 +08:00
|
|
|
|
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
|
|
|
|
|
const comparisonPopup = ref()
|
|
|
|
|
|
const testScriptPopup = ref()
|
|
|
|
|
|
const modeStore = useModeStore();
|
2024-10-23 20:53:58 +08:00
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
|
|
2024-11-21 14:42:26 +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 getPqScriptList(newParams)
|
|
|
|
|
|
}
|
2024-11-18 16:02:19 +08:00
|
|
|
|
|
2024-10-23 20:53:58 +08:00
|
|
|
|
// ProTable 实例
|
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
|
|
2024-11-21 15:51:53 +08:00
|
|
|
|
const showValueSearch = computed(() => {
|
|
|
|
|
|
if(modeStore.currentMode == '比对式'){
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-23 20:53:58 +08:00
|
|
|
|
// 表格配置项
|
2024-11-19 16:30:03 +08:00
|
|
|
|
const columns = reactive<ColumnProps<TestScript.ResTestScript>[]>([
|
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: '名称',
|
|
|
|
|
|
minWidth: 350,
|
2024-11-21 14:42:26 +08:00
|
|
|
|
search: {el:'input'}
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-10-31 08:51:30 +08:00
|
|
|
|
prop: 'standardName',
|
|
|
|
|
|
label: '参照标准名称',
|
|
|
|
|
|
minWidth: 150,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'standardTime',
|
2024-11-21 10:05:44 +08:00
|
|
|
|
label: '标准推行年份',
|
2024-10-31 08:51:30 +08:00
|
|
|
|
minWidth: 150,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'valueType',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '值类型',
|
2024-11-19 16:30:03 +08:00
|
|
|
|
enum: dictStore.getDictData('Script_Value_Type'),
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
2024-11-21 15:51:53 +08:00
|
|
|
|
search: showValueSearch.value ? { el: 'select' } : undefined,
|
2024-10-23 20:53:58 +08:00
|
|
|
|
minWidth: 150,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-10-31 08:51:30 +08:00
|
|
|
|
prop: 'type',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '模板类型',
|
|
|
|
|
|
minWidth: 150,
|
2024-11-19 16:30:03 +08:00
|
|
|
|
render: scope => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<el-tag type={scope.row.type ? 'success' : 'primary'} > {scope.row.type ? '模版' : '脚本'} </el-tag>
|
|
|
|
|
|
)
|
|
|
|
|
|
},
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
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-19 16:30:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> = {}) => {
|
2024-11-21 14:42:26 +08:00
|
|
|
|
if(modeStore.currentMode == '比对式'){
|
2024-12-04 19:54:56 +08:00
|
|
|
|
//comparisonPopup.value?.open(titleType, row)
|
2024-11-21 14:42:26 +08:00
|
|
|
|
}else{
|
2024-12-04 19:54:56 +08:00
|
|
|
|
//testScriptPopup.value?.open(titleType, row)
|
2024-11-21 14:42:26 +08:00
|
|
|
|
}
|
2024-11-19 16:30:03 +08:00
|
|
|
|
|
2024-11-21 14:42:26 +08:00
|
|
|
|
|
2024-11-19 16:30:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量删除设备
|
|
|
|
|
|
const batchDelete = async (id: string[]) => {
|
|
|
|
|
|
await useHandleData(deletePqScript, id, '删除所选脚本')
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除设备
|
|
|
|
|
|
const handleDelete = async (params: TestScript.ResTestScript) => {
|
|
|
|
|
|
await useHandleData(deletePqScript, [params.id], `删除【${params.name}】脚本`)
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 升级为模版
|
|
|
|
|
|
const updateType = async (params: TestScript.ResTestScript) => {
|
|
|
|
|
|
await useHandleData(updatePqScript, params, `升级【${params.name}】为模版`)
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 20:05:04 +08:00
|
|
|
|
</script>
|