diff --git a/src/utils/file/download.ts b/src/utils/file/download.ts index cc73179..dbf8b82 100644 --- a/src/utils/file/download.ts +++ b/src/utils/file/download.ts @@ -36,6 +36,7 @@ export function downloadByBase64(buf: string, filename: string, mime?: string, b export function downloadByData(data: BlobPart, filename: string, mime?: string, bom?: BlobPart) { const blobData = typeof bom !== 'undefined' ? [bom, data] : [data] const blob = new Blob(blobData, { type: mime || 'application/octet-stream' }) + // const blob = new Blob(blobData, { type: 'text/csv;charset=utf-8' }) const blobURL = window.URL.createObjectURL(blob) const tempLink = document.createElement('a') diff --git a/src/views/exa/config/CreateBatchModal.vue b/src/views/exa/config/CreateBatchModal.vue index bc3a2f0..d7c6957 100644 --- a/src/views/exa/config/CreateBatchModal.vue +++ b/src/views/exa/config/CreateBatchModal.vue @@ -40,11 +40,12 @@ function beforeUpload(file) { // 判断上传文件格式 - const extension = file.name.split('.')[1] === 'xls' + const extension = file.name.split('.')[1] === 'csv' - const extension2 = file.name.split('.')[1] === 'xlsx' + // const extension2 = file.name.split('.')[1] === 'csv' - if (!extension && !extension2) { + // if (!extension && !extension2) { + if (!extension) { createMessage.warning('导入文件只能是 xls、xlsx格式!') fileList.value = [] console.log(fileList) @@ -74,7 +75,7 @@ function handleDrop(e: DragEvent) { async function importPointTemplate() { const data = await importTemplate() - downloadByData(data, 'EXA测点导入模板.xlsx') + downloadByData(data, 'EXA测点导入模板.csv') } async function handleSubmit() { @@ -138,7 +139,7 @@ async function handleSubmit() { @register="registerCreateBatchModal" @ok="handleSubmit" >

@@ -148,7 +149,7 @@ async function handleSubmit() { 点击或拖拽到此区域实现上传

- 只支持上传单个excel文件,请尽量根据模板上传 + 只支持上传单个csv文件,请尽量根据模板上传

下载模板 diff --git a/src/views/run/instant/index.vue b/src/views/run/instant/index.vue index fe79a93..dad4936 100644 --- a/src/views/run/instant/index.vue +++ b/src/views/run/instant/index.vue @@ -31,7 +31,7 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] immediate: true, columns, formConfig: { - labelWidth: 120, + labelWidth: 80, schemas: searchFormSchema, showResetButton: false, actionColOptions: { @@ -96,6 +96,8 @@ const countData = ref() onMounted(async () => { countData.value = await getInstantCount() console.log(countData.value) + const { setFieldsValue } = getForm() + await setFieldsValue({ system: null }) getNow() }) async function getTableData(type) { diff --git a/src/views/run/instant/instant.data.ts b/src/views/run/instant/instant.data.ts index 54656ad..321dbb0 100644 --- a/src/views/run/instant/instant.data.ts +++ b/src/views/run/instant/instant.data.ts @@ -1,8 +1,11 @@ import moment from 'moment' import { left } from 'inquirer/lib/utils/readline' +import { ref } from 'vue' import type { BasicColumn, FormSchema } from '@/components/Table' import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { getModelVersionList } from '@/api/alert/run/model/index' +import { optionListApi, subSystemListApi } from '@/api/alert/model/select' +import type { systemSelectParams } from '@/api/alert/model/model/optionsModel' export const columns: BasicColumn[] = [ { @@ -90,14 +93,87 @@ export const columns: BasicColumn[] = [ ] +const optionList = await optionListApi() + +const systemOptions = ref([]) +systemOptions.value = optionList.systems export const searchFormSchema: FormSchema[] = [ + { + label: '机组', + field: 'unit', + component: 'Select', + defaultValue: optionList.units[0].id || null, + colProps: { span: 4 }, + + componentProps: ({ schema, tableAction, formActionType, formModel }) => { + return { + // xxxx props + allowClear: false, + placeholder: '请选择机组', + options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })), + onChange: async (e: any) => { + // const { reload } = tableAction + // reload() + // or + console.log(e) + const param: systemSelectParams = { + unitId: e, + typeId: formModel.type, + } + systemOptions.value = await subSystemListApi(param) + formModel.system = systemOptions.value[0].id + }, + } + }, + }, + { + label: '系统', + field: 'type', + component: 'Select', + defaultValue: optionList.types[0].id || null, + colProps: { span: 4 }, + componentProps: ({ formModel }) => { + return { + allowClear: false, + placeholder: '请选择系统', + options: optionList.types.map(type => ({ value: type.id, label: type.name })), + onChange: async (e: any) => { + // const { reload } = tableAction + // reload() + // or + console.log(e) + const param: systemSelectParams = { + unitId: formModel.unit, + typeId: e, + } + systemOptions.value = await subSystemListApi(param) + }, + } + }, + }, + { + label: '子系统', + field: 'system', + component: 'Select', + defaultValue: systemOptions.value[0].id || null, + colProps: { span: 4 }, + componentProps: () => { + return { + allowClear: false, + placeholder: '请选择子系统', + options: systemOptions.value.map(system => ({ value: system.id, label: system.name })), + } + }, + }, + { label: '模型实例名称', field: 'mpName', component: 'Input', + labelWidth: 120, + defaultValue: '', - required: true, - colProps: { span: 8 }, + colProps: { span: 5 }, }, { label: '状态1',