fix:修改按钮位置及样式 #31

Open
xiaojinfei wants to merge 2 commits from dev-xjf into master
  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) { export function downloadByData(data: BlobPart, filename: string, mime?: string, bom?: BlobPart) {
const blobData = typeof bom !== 'undefined' ? [bom, data] : [data] const blobData = typeof bom !== 'undefined' ? [bom, data] : [data]
const blob = new Blob(blobData, { type: mime || 'application/octet-stream' }) 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 blobURL = window.URL.createObjectURL(blob)
const tempLink = document.createElement('a') 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格式!') createMessage.warning('导入文件只能是 xls、xlsx格式!')
fileList.value = [] fileList.value = []
console.log(fileList) console.log(fileList)
@ -74,7 +75,7 @@ function handleDrop(e: DragEvent) {
async function importPointTemplate() { async function importPointTemplate() {
const data = await importTemplate() const data = await importTemplate()
downloadByData(data, 'EXA测点导入模板.xlsx') downloadByData(data, 'EXA测点导入模板.csv')
} }
async function handleSubmit() { async function handleSubmit() {
@ -138,7 +139,7 @@ async function handleSubmit() {
@register="registerCreateBatchModal" @ok="handleSubmit" @register="registerCreateBatchModal" @ok="handleSubmit"
> >
<UploadDragger <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" @change="handleChange" @drop="handleDrop"
> >
<p class="ant-upload-drag-icon"> <p class="ant-upload-drag-icon">
@ -148,7 +149,7 @@ async function handleSubmit() {
点击或拖拽到此区域实现上传 点击或拖拽到此区域实现上传
</p> </p>
<p class="ant-upload-hint"> <p class="ant-upload-hint">
只支持上传单个excel文件,请尽量根据模板上传 只支持上传单个csv文件,请尽量根据模板上传
</p> </p>
</UploadDragger> </UploadDragger>
<Divider><span style="color: #0B55A4;cursor: pointer" @click="importPointTemplate">下载模板</span></Divider> <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, immediate: true,
columns, columns,
formConfig: { formConfig: {
labelWidth: 120, labelWidth: 80,
schemas: searchFormSchema, schemas: searchFormSchema,
showResetButton: false, showResetButton: false,
actionColOptions: { actionColOptions: {
@ -96,6 +96,8 @@ const countData = ref<countObj>()
onMounted(async () => { onMounted(async () => {
countData.value = await getInstantCount() countData.value = await getInstantCount()
console.log(countData.value) console.log(countData.value)
const { setFieldsValue } = getForm()
await setFieldsValue({ system: null })
getNow() getNow()
}) })
async function getTableData(type) { async function getTableData(type) {

80
src/views/run/instant/instant.data.ts

@ -1,8 +1,11 @@
import moment from 'moment' import moment from 'moment'
import { left } from 'inquirer/lib/utils/readline' import { left } from 'inquirer/lib/utils/readline'
import { ref } from 'vue'
import type { BasicColumn, FormSchema } from '@/components/Table' import type { BasicColumn, FormSchema } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { getModelVersionList } from '@/api/alert/run/model/index' 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[] = [ 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[] = [ 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: '模型实例名称', label: '模型实例名称',
field: 'mpName', field: 'mpName',
component: 'Input', component: 'Input',
labelWidth: 120,
defaultValue: '', defaultValue: '',
required: true, colProps: { span: 5 },
colProps: { span: 8 },
}, },
{ {
label: '状态1', label: '状态1',

Loading…
Cancel
Save