# frontend/src/views/home/components/table.vue

#	frontend/src/views/home/tabs/dashboard.vue
This commit is contained in:
sjl
2024-12-17 11:36:02 +08:00
6 changed files with 76 additions and 27 deletions

View File

@@ -62,4 +62,18 @@ export const BindPqDevList = (params: any) => {
// 按照模式查询检测计划(用于首页展示) // 按照模式查询检测计划(用于首页展示)
export const getPlanListByPattern = (params:Plan.ReqPlan) => { export const getPlanListByPattern = (params:Plan.ReqPlan) => {
return http.get(`/adPlan/listByPattern?pattern=${params.pattern}`) return http.get(`/adPlan/listByPattern?pattern=${params.pattern}`)
}
// 导出检测计划
export const exportPlan=(params: Device.ReqPqDevParams)=>{
return http.download(`/adPlan/export`, params)
}
// 下载模板
export const downloadTemplate = () => {
return http.download(`/adPlan/downloadTemplate`)
}
// 导入检测计划
export const importPlan=(params: Device.ReqPqDevParams)=>{
return http.upload(`/adPlan/import`, params)
} }

View File

@@ -48,6 +48,7 @@ import { ElNotification, UploadRequestOptions, UploadRawFile } from "element-plu
export interface ExcelParameterProps { export interface ExcelParameterProps {
title: string; // 标题 title: string; // 标题
showCover?: boolean; // 是否显示”数据覆盖“选项 showCover?: boolean; // 是否显示”数据覆盖“选项
patternId?: string; // 模式ID
fileSize?: number; // 上传文件的大小 fileSize?: number; // 上传文件的大小
fileType?: File.ExcelMimeType[]; // 上传文件的类型 fileType?: File.ExcelMimeType[]; // 上传文件的类型
tempApi?: (params: any) => Promise<any>; // 下载模板的Api tempApi?: (params: any) => Promise<any>; // 下载模板的Api
@@ -84,6 +85,9 @@ const downloadTemp = () => {
const uploadExcel = async (param: UploadRequestOptions) => { const uploadExcel = async (param: UploadRequestOptions) => {
let excelFormData = new FormData(); let excelFormData = new FormData();
excelFormData.append("file", param.file); excelFormData.append("file", param.file);
if(parameter.value.patternId){
excelFormData.append("patternId",parameter.value.patternId)
}
isCover.value && excelFormData.append("isCover", isCover.value as unknown as Blob); isCover.value && excelFormData.append("isCover", isCover.value as unknown as Blob);
await parameter.value.importApi!(excelFormData); await parameter.value.importApi!(excelFormData);
parameter.value.getTableList && parameter.value.getTableList(); parameter.value.getTableList && parameter.value.getTableList();

View File

@@ -379,6 +379,7 @@ const proTable = ref<ProTableInstance>();
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备 const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
const getTableList = async (params: any) => { const getTableList = async (params: any) => {
<<<<<<< HEAD
const checkStateList = ref<any>() const checkStateList = ref<any>()
if(form.value.checkStatus != null){ if(form.value.checkStatus != null){
checkStateList.value = [form.value.checkStatus] checkStateList.value = [form.value.checkStatus]
@@ -391,6 +392,14 @@ const getTableList = async (params: any) => {
'reportState ': form.value.checkReportStatus, 'reportState ': form.value.checkReportStatus,
'name':form.value.search 'name':form.value.search
}); });
=======
debugger
if(props.id) {
// const pqDevList_Result2 = await getBoundPqDevList({'planId': props.id,'checkStateList':[0,1,2]});
// boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[];
return getBoundPqDevList({'planId': props.id,'checkStateList':[0,1,2]});
}
>>>>>>> 07d02307e2507c32fc2b3c8b745b074d7a9bb74d
}; };

View File

@@ -96,12 +96,12 @@
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="已检设备" v-if="tabShow" :style="{ height: tabPaneHeight }"> <!-- <el-tab-pane label="已检设备" v-if="tabShow" :style="{ height: tabPaneHeight }">-->
<!-- 列表数据 --> <!-- &lt;!&ndash; 列表数据 &ndash;&gt;-->
<div class="container_table" :style="{ height: tableHeight }"> <!-- <div class="container_table" :style="{ height: tableHeight }">-->
<Table ref="tableRef2" :id='currentId'></Table> <!-- <Table ref="tableRef2" :id='currentId'></Table>-->
</div> <!-- </div>-->
</el-tab-pane> <!-- </el-tab-pane>-->
</el-tabs> </el-tabs>
</div> </div>
</div> </div>
@@ -272,7 +272,11 @@ const getPieData = async (id: string) => {
currentId.value = id; // 设置当前ID currentId.value = id; // 设置当前ID
//handleCheckFunction(0)//切换左侧树默认css功能是设备检测 //handleCheckFunction(0)//切换左侧树默认css功能是设备检测
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备 const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
<<<<<<< HEAD
const pqDevList_Result2 = await getBoundPqDevList({'planId': id,'checkStateList':[0,1,2,3]}); const pqDevList_Result2 = await getBoundPqDevList({'planId': id,'checkStateList':[0,1,2,3]});
=======
const pqDevList_Result2 = await getBoundPqDevList({'planId': id,'checkStateList':[0,1,2]});
>>>>>>> 07d02307e2507c32fc2b3c8b745b074d7a9bb74d
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]; boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[];
console.log('饼图列',boundPqDevList) console.log('饼图列',boundPqDevList)
// 初始化计数对象 // 初始化计数对象
@@ -398,7 +402,7 @@ const resizeObserver = new ResizeObserver(entries => {
} }
}); });
onMounted(async () => { onBeforeMount(async () => {
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
const reqPlan: Plan.ReqPlan = { const reqPlan: Plan.ReqPlan = {
pattern: patternId, pattern: patternId,
@@ -421,7 +425,15 @@ onMounted(async () => {
code: 0, code: 0,
state: 0 state: 0
}; };
<<<<<<< HEAD
const planList = await getPlanListByPattern(reqPlan); const planList = await getPlanListByPattern(reqPlan);
=======
// debugger;
const planList = await getPlanListByPattern(reqPlan);
if (planList.data[0].children[0]) {
currentId.value = planList.data[0].children[0].id;
}
>>>>>>> 07d02307e2507c32fc2b3c8b745b074d7a9bb74d
if (chartsInfoRef.value) { if (chartsInfoRef.value) {
resizeObserver.observe(chartsInfoRef.value); resizeObserver.observe(chartsInfoRef.value);
} }

View File

@@ -62,18 +62,17 @@ const modeList = [
}, },
]; ];
const handelOpen = async (item: any) => { const handelOpen = async (item: any) => {
await authStore.setShowMenu();
modeStore.setCurrentMode(item.code); // 将模式code存入 store modeStore.setCurrentMode(item.code); // 将模式code存入 store
await authStore.setShowMenu();
return; return;
if (isActive) { // if (isActive) {
router.push({ path: "/static" }); // router.push({ path: "/static" });
} else { // } else {
ElMessage({ // ElMessage({
message: "当前模式未配置", // message: "当前模式未配置",
type: "warning", // type: "warning",
}); // });
} // }
}; };
const handleSelect = (key: string, keyPath: string[]) => { const handleSelect = (key: string, keyPath: string[]) => {
console.log(key, keyPath); console.log(key, keyPath);

View File

@@ -34,14 +34,14 @@
<TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/> <TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/>
<!-- 查看设备绑定 <!-- 查看设备绑定
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> --> <DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> -->
<ImportExcel ref='deviceImportExcel' />
</template> </template>
<script setup lang='tsx' name='useProTable'> <script setup lang='tsx' name='useProTable'>
import ProTable from '@/components/ProTable/index.vue' import ProTable from '@/components/ProTable/index.vue'
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface' import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import { ScaleToOriginal, CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue' import { ScaleToOriginal, CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue'
import {getPlanList,deletePlan } from '@/api/plan/plan.ts' import {getPlanList,deletePlan,exportPlan,downloadTemplate,importPlan } from '@/api/plan/plan.ts'
import { computed, onMounted, reactive, ref } from 'vue' import { computed, onMounted, reactive, ref } from 'vue'
import type { Plan } from '@/api/plan/interface' import type { Plan } from '@/api/plan/interface'
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件 import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
@@ -61,6 +61,9 @@ import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
import { useHandleData } from '@/hooks/useHandleData' import { useHandleData } from '@/hooks/useHandleData'
import { dictTestState,dictReportState,dictResult } from '@/api/plan/planData.ts' import { dictTestState,dictReportState,dictResult } from '@/api/plan/planData.ts'
import {getTestSourceById} from '@/api/device/testSource/index' import {getTestSourceById} from '@/api/device/testSource/index'
import ImportExcel from "@/components/ImportExcel/index.vue";
import {useDownload} from "@/hooks/useDownload";
import {exportPqDev} from "@/api/device/device";
const dictStore = useDictStore() const dictStore = useDictStore()
const openDeviceView = ref() const openDeviceView = ref()
const openSourceView = ref() const openSourceView = ref()
@@ -73,7 +76,8 @@ const testSourcePopup = ref()
const planPopup = ref() const planPopup = ref()
const devTransferPopup = ref() const devTransferPopup = ref()
const modeStore = useModeStore(); const modeStore = useModeStore();
const fileInput = ref<HTMLInputElement | null>(null) // 声明 fileInput
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
const getTableList = async(params: any) => { const getTableList = async(params: any) => {
let newParams = JSON.parse(JSON.stringify(params)) let newParams = JSON.parse(JSON.stringify(params))
@@ -232,11 +236,6 @@ const handleSourceClicked = (id: string) => {
}; };
function openFileDialog() {
if (fileInput.value) {
fileInput.value.click()
}
}
function isVisible(row: Plan.ReqPlan) { function isVisible(row: Plan.ReqPlan) {
@@ -312,11 +311,23 @@ function handleFiles(event: Event) {
// 点击导入按钮 // 点击导入按钮
const importClick = () => { const importClick = () => {
openFileDialog() const params = {
title: '被检设备',
showCover: false,
patternId: dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? '',
tempApi: downloadTemplate,
importApi: importPlan,
getTableList: proTable.value?.getTableList,
}
deviceImportExcel.value?.acceptParams(params)
} }
// 点击导出按钮 // 点击导出按钮
const exportClick = () => { const exportClick = () => {
openFileDialog()
ElMessageBox.confirm('确认导出检测计划?', '温馨提示', { type: 'warning' }).then(() =>{
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
useDownload(exportPlan,'检测计划导出数据', {...proTable.value?.searchParam,pattern:patternId}, false,'.xlsx')
})
} }
// 点击合并按钮 // 点击合并按钮