2024-10-23 20:53:58 +08:00
|
|
|
|
<template>
|
2024-11-06 21:15:49 +08:00
|
|
|
|
<div class='table-box' ref='popupBaseView'>
|
|
|
|
|
|
<ProTable
|
2024-11-14 19:33:33 +08:00
|
|
|
|
ref='proTable'
|
|
|
|
|
|
:columns='columns'
|
|
|
|
|
|
:request-api='getTableList'
|
2024-11-06 21:15:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<!-- :requestApi="getRoleList" -->
|
|
|
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
|
<template #tableHeader='scope'>
|
2024-11-21 10:05:44 +08:00
|
|
|
|
<el-button v-auth.device="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
|
|
|
|
|
<el-button v-auth.device="'export'" type='primary' :icon='Upload' plain @click='downloadFile()'>导出</el-button>
|
|
|
|
|
|
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click='importFile()'>导入</el-button>
|
|
|
|
|
|
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
2024-11-06 21:15:49 +08:00
|
|
|
|
@click='batchDelete(scope.selectedListIds)'>
|
2024-12-04 20:00:04 +08:00
|
|
|
|
删除
|
2024-11-06 21:15:49 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 表格操作 -->
|
|
|
|
|
|
<template #operation='scope'>
|
2024-11-21 10:05:44 +08:00
|
|
|
|
<el-button v-auth.device="'edit'" type='primary' link :icon='EditPen' :model-value="false" @click="openDialog('edit', scope.row)">编辑</el-button>
|
|
|
|
|
|
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</template>
|
2024-11-06 21:07:44 +08:00
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<DevicePopup :refresh-table='proTable?.getTableList' ref='devicePopup' />
|
2024-11-07 15:12:44 +08:00
|
|
|
|
<ImportExcel ref='deviceImportExcel' />
|
2024-11-06 21:15:49 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang='tsx' name='useRole'>
|
|
|
|
|
|
import TimeControl from '@/components/TimeControl/index.vue'
|
2024-11-18 09:02:57 +08:00
|
|
|
|
import { type Device } from '@/api/device/interface/device.ts'
|
2024-11-06 21:15:49 +08:00
|
|
|
|
import { useHandleData } from '@/hooks/useHandleData'
|
|
|
|
|
|
import { useDownload } from '@/hooks/useDownload'
|
|
|
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
|
|
|
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
|
|
|
|
|
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
|
|
|
|
|
|
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
|
2024-11-07 19:25:45 +08:00
|
|
|
|
import { CirclePlus, Delete, EditPen, Download, Upload } from '@element-plus/icons-vue'
|
2024-11-06 21:15:49 +08:00
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2024-11-18 09:02:57 +08:00
|
|
|
|
import { getPqDevList, deletePqDev, exportPqDev, downloadTemplate, importPqDev } from '@/api/device/device/index.ts'
|
2024-11-07 15:13:53 +08:00
|
|
|
|
import { ElMessageBox } from 'element-plus'
|
2024-11-18 16:02:19 +08:00
|
|
|
|
import { computed, reactive, ref } from 'vue'
|
2024-11-21 14:42:26 +08:00
|
|
|
|
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
2024-11-06 21:15:49 +08:00
|
|
|
|
|
2024-11-21 14:42:26 +08:00
|
|
|
|
const modeStore = useModeStore();
|
2024-11-06 21:15:49 +08:00
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
|
// ProTable 实例
|
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
|
const devicePopup = ref()
|
|
|
|
|
|
// 定义包含和排除的单位
|
|
|
|
|
|
|
|
|
|
|
|
const getTableList = (params: any) => {
|
|
|
|
|
|
let newParams = JSON.parse(JSON.stringify(params))
|
2024-11-07 10:24:33 +08:00
|
|
|
|
newParams.searchEndTime = endDate.value
|
|
|
|
|
|
newParams.searchBeginTime = startDate.value
|
2024-11-21 14:42:26 +08:00
|
|
|
|
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
|
|
|
|
|
newParams.pattern = patternId
|
2024-11-06 21:15:49 +08:00
|
|
|
|
return getPqDevList(newParams)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-12 18:56:33 +08:00
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
// 表格配置项
|
|
|
|
|
|
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|
|
|
|
|
{ type: 'selection', fixed: 'left', width: 70 },
|
|
|
|
|
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'name',
|
2024-11-15 16:31:48 +08:00
|
|
|
|
label: '设备名称',
|
2024-11-14 19:33:33 +08:00
|
|
|
|
search: { el: 'input' },
|
2024-11-06 21:15:49 +08:00
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'devType',
|
2024-11-15 16:31:48 +08:00
|
|
|
|
label: '设备类型',
|
2024-11-06 21:15:49 +08:00
|
|
|
|
minWidth: 200,
|
2024-11-15 16:31:48 +08:00
|
|
|
|
enum: dictStore.getDictData('Dev_Type'),
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
2024-11-06 21:15:49 +08:00
|
|
|
|
},
|
2024-11-14 18:26:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'createDate',
|
|
|
|
|
|
label: '生产日期',
|
|
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
search: {
|
2024-11-14 19:33:33 +08:00
|
|
|
|
span: 2,
|
2024-11-14 18:26:34 +08:00
|
|
|
|
render: () => {
|
|
|
|
|
|
return (
|
2024-11-14 19:33:33 +08:00
|
|
|
|
<div class='flx-flex-start'>
|
|
|
|
|
|
<TimeControl
|
|
|
|
|
|
default={'月'}
|
|
|
|
|
|
onUpdate-dates={handleDateChange}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2024-11-14 18:26:34 +08:00
|
|
|
|
)
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-11-06 21:15:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
prop: 'devChns',
|
|
|
|
|
|
label: '设备通道数',
|
|
|
|
|
|
minWidth: 110,
|
2024-11-14 19:33:33 +08:00
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'devVolt',
|
|
|
|
|
|
label: '额定电压(V)',
|
|
|
|
|
|
minWidth: 130,
|
2024-11-14 19:33:33 +08:00
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'devCurr',
|
|
|
|
|
|
label: '额定电流(A)',
|
|
|
|
|
|
minWidth: 130,
|
2024-11-14 19:33:33 +08:00
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'manufacturer',
|
2024-11-11 11:09:20 +08:00
|
|
|
|
label: '生产厂商',
|
2024-11-11 15:40:49 +08:00
|
|
|
|
enum: dictStore.getDictData('Dev_Manufacturers'),
|
2024-11-14 19:33:33 +08:00
|
|
|
|
search: { el: 'select', props: { filterable: true }, order: 1 },
|
2024-11-15 16:31:48 +08:00
|
|
|
|
fieldNames: { label: 'name', value: 'id' },
|
2024-11-06 21:15:49 +08:00
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
},
|
|
|
|
|
|
{ prop: 'operation', label: '操作', fixed: 'right', width: 200 },
|
|
|
|
|
|
])
|
2024-11-06 21:07:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
// 处理日期变化的回调函数
|
|
|
|
|
|
const startDate = ref('')
|
|
|
|
|
|
const endDate = ref('')
|
|
|
|
|
|
const handleDateChange = (startDateTemp: string, endDateTemp: string) => {
|
|
|
|
|
|
startDate.value = startDateTemp
|
|
|
|
|
|
endDate.value = endDateTemp
|
|
|
|
|
|
}
|
|
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
2024-11-21 14:42:26 +08:00
|
|
|
|
devicePopup.value?.open(titleType, row,modeStore.currentMode)
|
2024-11-06 21:07:44 +08:00
|
|
|
|
}
|
2024-11-06 21:15:49 +08:00
|
|
|
|
|
2024-11-18 16:02:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-07 15:13:53 +08:00
|
|
|
|
// 批量删除设备
|
2024-11-06 21:15:49 +08:00
|
|
|
|
const batchDelete = async (id: string[]) => {
|
|
|
|
|
|
await useHandleData(deletePqDev, id, '删除所选设备')
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 15:13:53 +08:00
|
|
|
|
// 删除设备
|
2024-11-06 21:15:49 +08:00
|
|
|
|
const handleDelete = async (params: Device.ResPqDev) => {
|
|
|
|
|
|
await useHandleData(deletePqDev, [params.id], `删除【${params.name}】设备`)
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-07 15:13:53 +08:00
|
|
|
|
// 导出设备
|
2024-11-14 19:24:36 +08:00
|
|
|
|
const downloadFile = async () => {
|
2024-11-14 18:26:34 +08:00
|
|
|
|
// 获取当前的搜索参数
|
|
|
|
|
|
const searchParam = proTable.value?.searchParam || {};
|
|
|
|
|
|
|
|
|
|
|
|
// 将开始时间和结束时间添加到搜索参数中
|
|
|
|
|
|
searchParam.searchBeginTime = startDate.value;
|
|
|
|
|
|
searchParam.searchEndTime = endDate.value;
|
|
|
|
|
|
|
2024-11-14 20:36:54 +08:00
|
|
|
|
ElMessageBox.confirm('确认导出被检设备?', '温馨提示', { type: 'warning' }).then(() =>
|
2024-11-14 18:26:34 +08:00
|
|
|
|
useDownload(exportPqDev,'被检设备导出数据', proTable.value?.searchParam, false,'.xlsx'),
|
2024-11-14 20:49:21 +08:00
|
|
|
|
|
2024-11-07 15:13:53 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//导入设备
|
2024-11-07 16:17:33 +08:00
|
|
|
|
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
2024-11-07 15:12:44 +08:00
|
|
|
|
|
2024-11-14 19:33:33 +08:00
|
|
|
|
const importFile = async () => {
|
2024-11-07 15:12:44 +08:00
|
|
|
|
const params = {
|
2024-11-07 19:24:29 +08:00
|
|
|
|
title: '被检设备',
|
|
|
|
|
|
showCover: false,
|
|
|
|
|
|
tempApi: downloadTemplate,
|
2024-11-07 15:12:44 +08:00
|
|
|
|
importApi: importPqDev,
|
|
|
|
|
|
getTableList: proTable.value?.getTableList,
|
|
|
|
|
|
}
|
|
|
|
|
|
deviceImportExcel.value?.acceptParams(params)
|
2024-11-07 15:13:53 +08:00
|
|
|
|
}
|
2024-11-14 11:34:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-06 21:15:49 +08:00
|
|
|
|
</script>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|