检测源
This commit is contained in:
@@ -8,22 +8,22 @@
|
||||
<!-- :data='testSourceData' 如果要显示静态数据,就切换该配置-->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus' >新增</el-button>
|
||||
<el-button type='primary' :icon='Download' plain >导出数据</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
|
||||
<el-button v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button v-auth.testSource="'batchDelete'" type='danger' :icon='Delete'
|
||||
plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='View' >查看</el-button>
|
||||
<el-button type='primary' link :icon='EditPen' >编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' >删除</el-button>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
<TestSourcePopup :refresh-table='proTable?.getTableList' ref='testSourcePopup' />
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='useRole'>
|
||||
@@ -33,23 +33,30 @@
|
||||
import { useAuthButtons } from '@/hooks/useAuthButtons'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import type{ ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import TestSourcePopup from './components/testSourcePopup.vue'
|
||||
import {
|
||||
getTestSourceList,
|
||||
getTestSourceList,deleteTestSource,
|
||||
} from '@/api/device/testSource/index'
|
||||
import { reactive, ref } from 'vue'
|
||||
|
||||
import { reactive, ref } from 'vue'
|
||||
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
const testSourcePopup = ref()
|
||||
const dictStore = useDictStore()
|
||||
|
||||
// const testSourceData = testSourceDataList
|
||||
const modeStore = useModeStore();
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<TestSource.TestSourceBO>[]>([
|
||||
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
@@ -61,22 +68,41 @@ import { reactive, ref } from 'vue'
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
enum: dictStore.getDictData('testSourceDevType'),
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
enum: dictStore.getDictData('PqSource_Dev_Type'),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 220,
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '源类型',
|
||||
enum: dictStore.getDictData('testSourceType'),
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
enum: dictStore.getDictData('Pq_Source_Type'),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
|
||||
])
|
||||
|
||||
|
||||
// 打开 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()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user