Compare commits

...

2 Commits

Author SHA1 Message Date
肖晋飞 a2a5fc9efa fix:将excel改为csv 1 week ago
肖晋飞 7b6f54edf3 fix:增加机组、系统、子系统筛选条件 1 week ago
  1. 1
      src/utils/file/download.ts
  2. 13
      src/views/exa/config/CreateBatchModal.vue
  3. 4
      src/views/run/instant/index.vue
  4. 80
      src/views/run/instant/instant.data.ts

1
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')

13
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"
>
<UploadDragger
v-model:fileList="fileList" :max-count="1" accept=".xlsx,.xls" :multiple="false" :before-upload="beforeUpload"
v-model:fileList="fileList" :max-count="1" accept=".csv" :multiple="false" :before-upload="beforeUpload"
@change="handleChange" @drop="handleDrop"
>
<p class="ant-upload-drag-icon">
@ -148,7 +149,7 @@ async function handleSubmit() {
点击或拖拽到此区域实现上传
</p>
<p class="ant-upload-hint">
只支持上传单个excel文件,请尽量根据模板上传
只支持上传单个csv文件,请尽量根据模板上传
</p>
</UploadDragger>
<Divider><span style="color: #0B55A4;cursor: pointer" @click="importPointTemplate">下载模板</span></Divider>

4
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<countObj>()
onMounted(async () => {
countData.value = await getInstantCount()
console.log(countData.value)
const { setFieldsValue } = getForm()
await setFieldsValue({ system: null })
getNow()
})
async function getTableData(type) {

80
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<any>([])
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',

Loading…
Cancel
Save