2024-10-23 20:53:58 +08:00
|
|
|
|
<template>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
<div class='table-box' ref='popupBaseView'>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
<ProTable
|
|
|
|
|
|
ref='proTable'
|
|
|
|
|
|
:columns='columns'
|
2024-11-06 21:07:44 +08:00
|
|
|
|
:init-param="initParam"
|
2024-11-06 20:31:07 +08:00
|
|
|
|
:request-api='getPqDevList'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
>
|
|
|
|
|
|
<!-- :requestApi="getRoleList" -->
|
|
|
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
|
|
|
<template #tableHeader='scope'>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
|
|
|
|
|
<el-button type='primary' :icon='Download' plain @click='downloadFile()'>批量导出</el-button>
|
|
|
|
|
|
<el-button type='primary' :icon='Upload' plain @click='importFile()'>批量导入</el-button>
|
|
|
|
|
|
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected' @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-06 20:31:07 +08:00
|
|
|
|
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
|
|
|
|
|
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
<DevicePopup :refresh-table='proTable?.getTableList' ref='devicePopup'/>
|
2024-10-23 20:53:58 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang='tsx' name='useRole'>
|
2024-11-06 20:31:07 +08:00
|
|
|
|
import TimeControl from '@/components/TimeControl/index.vue'
|
|
|
|
|
|
import { type Device } from '@/api/device/interface'
|
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-06 20:31:07 +08:00
|
|
|
|
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
|
|
|
|
|
|
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
|
|
|
|
|
import deviceDataList from '@/api/device/deviceData'
|
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
2024-11-06 20:31:07 +08:00
|
|
|
|
import {getPqDevList,deletePqDev,exportPqDev,importPqDev} from '@/api/device/device.ts'
|
|
|
|
|
|
import { reactive, ref } from 'vue'
|
2024-10-23 20:53:58 +08:00
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
|
// ProTable 实例
|
|
|
|
|
|
const proTable = ref<ProTableInstance>()
|
2024-11-06 20:31:07 +08:00
|
|
|
|
const devicePopup = ref()
|
|
|
|
|
|
// 定义包含和排除的单位
|
|
|
|
|
|
const includedUnits = ['日', '周', '月', '自定义']; // 可以根据需要包含的单位
|
|
|
|
|
|
const excludedUnits = ['季度','年']; // 要排除的单位
|
|
|
|
|
|
const defaultUnits = '日'; // 默认的单位
|
2024-11-06 21:07:44 +08:00
|
|
|
|
|
2024-10-23 20:53:58 +08:00
|
|
|
|
// 表格配置项
|
2024-11-06 20:31:07 +08:00
|
|
|
|
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
2024-10-23 20:53:58 +08:00
|
|
|
|
{ type: 'selection', fixed: 'left', width: 70 },
|
|
|
|
|
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'name',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '名称',
|
|
|
|
|
|
search: { el: 'input' },
|
2024-11-06 20:31:07 +08:00
|
|
|
|
minWidth: 200,
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'devType',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '类型',
|
2024-11-06 20:31:07 +08:00
|
|
|
|
enum: dictStore.getDictData('High_Cate'),
|
|
|
|
|
|
search: { el: 'select', props: { filterable: true } },
|
|
|
|
|
|
fieldNames: { label: 'name', value: 'code' },
|
|
|
|
|
|
minWidth: 200,
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'devChns',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '设备通道数',
|
2024-11-06 20:31:07 +08:00
|
|
|
|
minWidth: 110,
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'devVolt',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '额定电压(V)',
|
|
|
|
|
|
minWidth: 130,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'devCurr',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '额定电流(A)',
|
|
|
|
|
|
minWidth: 130,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2024-11-06 20:31:07 +08:00
|
|
|
|
prop: 'manufacturer',
|
2024-10-23 20:53:58 +08:00
|
|
|
|
label: '制作厂商',
|
2024-11-06 20:31:07 +08:00
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
prop: 'createDate',
|
|
|
|
|
|
label: '生产日期',
|
|
|
|
|
|
minWidth: 200,
|
|
|
|
|
|
search: {
|
|
|
|
|
|
span: 2,
|
|
|
|
|
|
render: () => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div class='flx-flex-start'>
|
|
|
|
|
|
<TimeControl
|
|
|
|
|
|
include={includedUnits}
|
|
|
|
|
|
exclude={excludedUnits}
|
|
|
|
|
|
default={defaultUnits}
|
2024-11-06 21:07:44 +08:00
|
|
|
|
onUpdate-dates={handleDateChange}
|
2024-11-06 20:31:07 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-10-23 20:53:58 +08:00
|
|
|
|
},
|
2024-11-06 20:31:07 +08:00
|
|
|
|
{ prop: 'operation', label: '操作', fixed: 'right', width: 200 },
|
2024-10-23 20:53:58 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
2024-11-06 21:07:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理日期变化的回调函数
|
|
|
|
|
|
const handleDateChange = (startDate: Date, endDate: Date) => {
|
|
|
|
|
|
console.log('Start Date:', startDate)
|
|
|
|
|
|
console.log('End Date:', endDate)
|
|
|
|
|
|
// 这里可以添加更多的逻辑处理
|
|
|
|
|
|
}
|
2024-11-06 20:31:07 +08:00
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
|
|
|
|
const openDialog = (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
|
|
|
|
|
devicePopup.value?.open(titleType, row)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 批量删除字典类型
|
|
|
|
|
|
const batchDelete = async (id: string[]) => {
|
|
|
|
|
|
await useHandleData(deletePqDev, id, '删除所选设备')
|
|
|
|
|
|
proTable.value?.clearSelection()
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除字典类型
|
|
|
|
|
|
const handleDelete = async (params: Device.ResPqDev) => {
|
|
|
|
|
|
await useHandleData(deletePqDev, [params.id], `删除【${params.name}】设备`)
|
|
|
|
|
|
proTable.value?.getTableList()
|
|
|
|
|
|
}
|
2024-10-23 20:53:58 +08:00
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|