| | |
| | | } |
| | | // ææ¡£å·²åå¨ï¼è¿åæä»¶æ°æ®æµ |
| | | else { |
| | | return res |
| | | return res; |
| | | // const name = Base64.decode(res.headers.get('filename')); |
| | | // const url = window.URL.createObjectURL(res.data); |
| | | // const link = document.createElement('a'); |
| | |
| | | // window.URL.revokeObjectURL(url); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * è·åé®é¢æ´æ¹æ¸
å |
| | | */ |
| | | fetchProbChangeList(option) { |
| | | return $fysp.post(`dataProduct/problemChange?`, option).then((res) => { |
| | | return res.data; |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * è·åé®é¢å¤åæ¸
å |
| | | */ |
| | | fetchProbRecurrence(option) { |
| | | return $fysp.post(`dataProduct/problemRecurrence?`, option).then((res) => { |
| | | return res.data; |
| | | }); |
| | | } |
| | | }; |
| | |
| | | */ |
| | | findScene(scene) { |
| | | return $fysp.post('scense/search', scene).then((res) => res.data); |
| | | }, |
| | | |
| | | importScene(file) { |
| | | return $fysp.post('scense/import', file).then((res) => res.data); |
| | | } |
| | | |
| | | }; |
| | |
| | | ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] |
| | | ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] |
| | | ElButton: typeof import('element-plus/es')['ElButton'] |
| | | ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] |
| | | ElCalendar: typeof import('element-plus/es')['ElCalendar'] |
| | | ElCard: typeof import('element-plus/es')['ElCard'] |
| | | ElCascader: typeof import('element-plus/es')['ElCascader'] |
| | |
| | | ElDialog: typeof import('element-plus/es')['ElDialog'] |
| | | ElDivider: typeof import('element-plus/es')['ElDivider'] |
| | | ElDrawer: typeof import('element-plus/es')['ElDrawer'] |
| | | ElDropdown: typeof import('element-plus/es')['ElDropdown'] |
| | | ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] |
| | | ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] |
| | | ElEmpty: typeof import('element-plus/es')['ElEmpty'] |
| | | ElForm: typeof import('element-plus/es')['ElForm'] |
| | | ElFormItem: typeof import('element-plus/es')['ElFormItem'] |
| | |
| | | ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] |
| | | ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup'] |
| | | ElOption: typeof import('element-plus/es')['ElOption'] |
| | | ElPageHeader: typeof import('element-plus/es')['ElPageHeader'] |
| | | ElPagination: typeof import('element-plus/es')['ElPagination'] |
| | | ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] |
| | | ElPopover: typeof import('element-plus/es')['ElPopover'] |
| | | ElRadio: typeof import('element-plus/es')['ElRadio'] |
| | | ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] |
| | | ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] |
| | | ElRow: typeof import('element-plus/es')['ElRow'] |
| | |
| | | ElTag: typeof import('element-plus/es')['ElTag'] |
| | | ElText: typeof import('element-plus/es')['ElText'] |
| | | ElTooltip: typeof import('element-plus/es')['ElTooltip'] |
| | | ElTransfer: typeof import('element-plus/es')['ElTransfer'] |
| | | ElTree: typeof import('element-plus/es')['ElTree'] |
| | | ElUpload: typeof import('element-plus/es')['ElUpload'] |
| | | Footer: typeof import('./components/core/Footer.vue')['default'] |
| | |
| | | FYBgTaskCard: typeof import('./components/bg-task/FYBgTaskCard.vue')['default'] |
| | | FYBgTaskDialog: typeof import('./components/bg-task/FYBgTaskDialog.vue')['default'] |
| | | FYBgTaskItem: typeof import('./components/bg-task/FYBgTaskItem.vue')['default'] |
| | | FYDownloadTableButton: typeof import('./components/button/FYDownloadTableButton.vue')['default'] |
| | | FYForm: typeof import('./components/form/FYForm.vue')['default'] |
| | | FYImageSelectDialog: typeof import('./components/FYImageSelectDialog.vue')['default'] |
| | | FYInfoSearch: typeof import('./components/search-option/FYInfoSearch.vue')['default'] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-button |
| | | icon="Download" |
| | | type="primary" |
| | | plain |
| | | @click="download" |
| | | :loading="dlLoading" |
| | | >{{ label }}</el-button |
| | | > |
| | | </template> |
| | | <script setup> |
| | | import { ref } from 'vue'; |
| | | import { conversionFromTable } from '@/utils/excel'; |
| | | |
| | | const props = defineProps({ |
| | | // ä¸è½½æä»¶åç§° |
| | | fileName: String, |
| | | // è¡¨æ ¼å
ç´ id |
| | | tableId: String, |
| | | label: { |
| | | type: String, |
| | | default: 'ä¸è½½' |
| | | } |
| | | }); |
| | | |
| | | const dlLoading = ref(false); |
| | | |
| | | function download() { |
| | | dlLoading.value = true; |
| | | conversionFromTable(props.tableId, props.fileName); |
| | | dlLoading.value = false; |
| | | } |
| | | </script> |
| | |
| | | ></FYOptionScene> |
| | | <slot name="left-top"></slot> |
| | | </el-row> |
| | | <!-- <el-row class="right-wrap"> |
| | | <el-col :span="4"> |
| | | <el-button>close</el-button> |
| | | </el-col> |
| | | <el-col :span="20"> |
| | | |
| | | </el-col> |
| | | </el-row> --> |
| | | <el-scrollbar class="right-wrap"> |
| | | <div v-for="s in selectedSceneList" :key="s.guid"> |
| | | <el-checkbox |
| | | v-model="s._checked" |
| | | :label="s.name" |
| | | @change="handleChange" |
| | | @change="handleChange(s)" |
| | | /> |
| | | <!-- <el-text>{{ s.name }}</el-text> --> |
| | | </div> |
| | |
| | | if (nV != oV) { |
| | | clearSceneMarks(); |
| | | createSceneMarks(); |
| | | filterMarkViews(); |
| | | filterMarkViews(true); |
| | | } |
| | | }, |
| | | { immediate: true } |
| | |
| | | watch(scenetype, (nV, oV) => { |
| | | if (nV != oV) { |
| | | clearSceneMarks(); |
| | | filterMarkViews(); |
| | | filterMarkViews(true); |
| | | } |
| | | }); |
| | | |
| | | function handleChange(value) { |
| | | console.log(value); |
| | | |
| | | filterMarkViews(); |
| | | function handleChange(scene) { |
| | | const mv = markViewList.find((v) => { |
| | | return scene.guid == v.getExtData().guid; |
| | | }); |
| | | if (scene._checked) { |
| | | map.add(mv); |
| | | } else { |
| | | map.remove(mv); |
| | | } |
| | | // filterMarkViews(); |
| | | } |
| | | |
| | | function createSceneMarks() { |
| | |
| | | /** |
| | | * çéæéç±»åçåºæ¯ |
| | | */ |
| | | function filterMarkViews() { |
| | | function filterMarkViews(setFitView) { |
| | | onMapMounted(() => { |
| | | if (markViewList.length > 0) { |
| | | map.remove(markViewList); |
| | | } |
| | | if (scenetype.value == undefined) { |
| | | markViewList = allMarkViews; |
| | | } else { |
| | |
| | | } |
| | | markViewList = markViewList.filter((v) => { |
| | | const _index = selectedSceneList.value.findIndex((s) => { |
| | | console.log(s.guid, v.getExtData().guid); |
| | | |
| | | s.guid == v.getExtData().guid; |
| | | return s.guid == v.getExtData().guid && s._checked; |
| | | }); |
| | | return _index != -1; |
| | | }); |
| | | map.add(markViewList); |
| | | setTimeout(() => { |
| | | map.setFitView(markViewList); |
| | | // const list = markViewList.map((v) => { |
| | | // const _extData = v.getExtData(); |
| | | // return [_extData.longitude, _extData.latitude]; |
| | | // }); |
| | | // mapUtil.setBound(list); |
| | | }, 1000); |
| | | if (setFitView) { |
| | | setTimeout(() => { |
| | | map.setFitView(markViewList); |
| | | // const list = markViewList.map((v) => { |
| | | // const _extData = v.getExtData(); |
| | | // return [_extData.longitude, _extData.latitude]; |
| | | // }); |
| | | // mapUtil.setBound(list); |
| | | }, 1000); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | border-radius: 4px; |
| | | padding: 2px 8px; |
| | | max-width: 300px; |
| | | box-shadow: var(--el-box-shadow); |
| | | } |
| | | </style> |
| | |
| | | const MONTH = 'month'; |
| | | const DATE = 'date'; |
| | | const RANGE = 'datetimerange'; |
| | | const RANGE2 = 'daterange'; |
| | | |
| | | export default { |
| | | props: { |
| | |
| | | <slot name="options-expand2"></slot> |
| | | </div> |
| | | <el-table |
| | | id="fyTable" |
| | | v-bind="$attrs" |
| | | ref="tableRef" |
| | | :data="tableData" |
| | | v-loading="loading" |
| | |
| | | :cell-class-name="cellClassName" |
| | | @paste="handlePaste" |
| | | @sort-change="handleSortChange" |
| | | :show-overflow-tooltip="true" |
| | | border |
| | | > |
| | | <slot name="table-column" :size="fontSize"></slot> |
| | |
| | | mounted() { |
| | | this.tableHeight = this.calcTableHeight(); |
| | | this.onSearch(); |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | |
| | | icon: 'DataAnalysis', |
| | | name: 'åºç¡æ°æ®äº§å', |
| | | children: [ |
| | | // { |
| | | // path: '/fysp/data-product/base/ProdScenseInfo', |
| | | // icon: 'Document', |
| | | // name: 'åºæ¯æ¸
å', |
| | | // }, |
| | | // { |
| | | // path: '/fysp/data-product/base/ProdMonitorTaskInfo', |
| | | // icon: 'Document', |
| | | // name: 'ç管æ¸
å', |
| | | // }, |
| | | // { |
| | | // path: '/fysp/data-product/base/ProdTreatmentDeviceInfo', |
| | | // icon: 'Document', |
| | | // name: '鲿²»è®¾å¤æ¸
å', |
| | | // }, |
| | | { |
| | | path: '/fysp/data-product/ProdScenseInfo', |
| | | path: '/fysp/data-product/base/PordProblemRecurrence', |
| | | icon: 'Document', |
| | | name: 'åºæ¯æ¸
å', |
| | | }, |
| | | { |
| | | path: '/fysp/data-product/ProdMonitorTaskInfo', |
| | | icon: 'Document', |
| | | name: 'ç管æ¸
å', |
| | | }, |
| | | { |
| | | path: '/fysp/data-product/ProdTreatmentDeviceInfo', |
| | | icon: 'Document', |
| | | name: '鲿²»è®¾å¤æ¸
å', |
| | | name: 'é®é¢å¤åæ¸
å', |
| | | }, |
| | | ] |
| | | }, |
| | |
| | | { |
| | | // åºç¡äº§å-åºæ¯æ¸
å |
| | | name: 'ProdScenseInfo', |
| | | path: '/fysp/data-product/ProdScenseInfo', |
| | | path: '/fysp/data-product/base/ProdScenseInfo', |
| | | component: () => import('@/views/fysp/data-product/base-data-product/ProdScenseInfo.vue') |
| | | }, |
| | | { |
| | | // åºç¡äº§å-ç管æ¸
å |
| | | name: 'ProdMonitorTaskInfo', |
| | | path: '/fysp/data-product/ProdMonitorTaskInfo', |
| | | path: '/fysp/data-product/base/ProdMonitorTaskInfo', |
| | | component: () => import('@/views/fysp/data-product/base-data-product/ProdMonitorTaskInfo.vue') |
| | | }, |
| | | { |
| | | // åºç¡äº§å-鲿²»è®¾å¤æ¸
å |
| | | name: 'ProdTreatmentDeviceInfo', |
| | | path: '/fysp/data-product/ProdTreatmentDeviceInfo', |
| | | path: '/fysp/data-product/base/ProdTreatmentDeviceInfo', |
| | | component: () => import('@/views/fysp/data-product/base-data-product/ProdTreatmentDeviceInfo.vue') |
| | | }, |
| | | { |
| | | // åºç¡äº§å-é®é¢å¤åæ¸
å |
| | | name: 'PordProblemRecurrence', |
| | | path: '/fysp/data-product/base/PordProblemRecurrence', |
| | | component: () => import('@/views/fysp/data-product/base-data-product/PordProblemRecurrence.vue') |
| | | }, |
| | | |
| | | /**********************************é£ç¾½ç¯å¢***********************************************/ |
| | | { |
| | |
| | | // } |
| | | // } |
| | | // } |
| | | console.log(tables); |
| | | // console.log(tables); |
| | | |
| | | //------æ¾å
¥ä»¥ä¸æ¿å°switchç¶æï¼ä»¥å䏿æ¡ä»£ç ï¼å¦ææ²¡å
éå
ç´ åä¼å½±åå°åè¡¨æ ¼-------------// |
| | | |
| | |
| | | <template> |
| | | <FYTable |
| | | id="fyTable" |
| | | @search="onSearch" |
| | | :data="tableData" |
| | | :pagination="false" |
| | |
| | | </el-descriptions> |
| | | </template> |
| | | <template #buttons> |
| | | <el-button |
| | | icon="Download" |
| | | type="primary" |
| | | plain |
| | | @click="download" |
| | | :loading="dlLoading" |
| | | <FYDownloadTableButton |
| | | label="ä¸è½½æ¸
å" |
| | | table-id="fyTable" |
| | | :file-name="fileName" |
| | | :disabled="downloadDisabled" |
| | | >ä¸è½½æ¸
å</el-button |
| | | > |
| | | ></FYDownloadTableButton> |
| | | </template> |
| | | <template #table-column="{ size }"> |
| | | <el-table-column fixed="left" label="åºå·" width="53"> |
| | |
| | | import evaluateApi from '@/api/fysp/evaluateApi'; |
| | | import problemApi from '@/api/fysp/problemApi'; |
| | | import sceneApi from '@/api/fysp/sceneApi'; |
| | | import { conversionFromTable } from "@/utils/excel"; |
| | | import { envCreditCode } from '@/constants/index'; |
| | | import { useTablePaste } from '@/composables/tablePaste'; |
| | | import { useCloned } from '@vueuse/core'; |
| | | import { useMessageBoxTip } from '@/composables/messageBox'; |
| | | import * as XLSX from 'xlsx'; |
| | | import FileSaver from 'file-saver'; |
| | | |
| | | export default { |
| | | setup() { |
| | |
| | | }); |
| | | return b; |
| | | } |
| | | }, |
| | | fileName() { |
| | | const { locations, scenetype, time } = this.formSearch; |
| | | return `${locations.dName}${dayjs(time).format( |
| | | 'YYYYå¹´MMæ' |
| | | )}èåæ§æ³æ¸
å`; |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | const property = column['property']; |
| | | return row[property] === value; |
| | | }, |
| | | download() { |
| | | // const workbook = XLSX.utils.book_new(); |
| | | // const worksheet = XLSX.utils.json_to_sheet(this.tableData); |
| | | // XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); |
| | | // const excelData = XLSX.write(workbook, { |
| | | // bookType: 'xlsx', |
| | | // type: 'array' |
| | | // }); |
| | | // const blob = new Blob([excelData], { |
| | | // type: 'application/vnd.openxmlformats-officedocumnet.spreadsheetml.sheet' |
| | | // }); |
| | | const { locations, scenetype, time } = this.formSearch; |
| | | const name = `${locations.dName}${dayjs(time).format( |
| | | 'YYYYå¹´MMæ' |
| | | )}èåæ§æ³æ¸
å.xlsx`; |
| | | // FileSaver.saveAs(blob, name); |
| | | conversionFromTable('fyTable', name) |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.addRefreshEvent(this.$refs.tableRef.doLayout); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <FYTable |
| | | id="fyTable" |
| | | @search="onSearch" |
| | | :data="showData" |
| | | :pagination="false" |
| | | ref="tableRef" |
| | | > |
| | | <template #options> |
| | | <!-- åºå¿ --> |
| | | <FYOptionLocation |
| | | :allOption="false" |
| | | :level="3" |
| | | :checkStrictly="false" |
| | | v-model:value="formSearch.locations" |
| | | ></FYOptionLocation> |
| | | <!-- åºæ¯ç±»å --> |
| | | <FYOptionScene |
| | | :allOption="false" |
| | | :type="2" |
| | | v-model:value="formSearch.scenetype" |
| | | ></FYOptionScene> |
| | | <!-- æ¶é´ --> |
| | | <FYOptionTime |
| | | :initValue="false" |
| | | type="daterange" |
| | | v-model:value="formSearch.timeArr" |
| | | style="width: 300px" |
| | | ></FYOptionTime> |
| | | </template> |
| | | |
| | | <template #options-expand> |
| | | <el-radio-group v-model="radio"> |
| | | <el-radio :value="1">æé®é¢åç§°ç»è®¡</el-radio> |
| | | <el-radio :value="2">æé®é¢ç±»åç»è®¡</el-radio> |
| | | </el-radio-group> |
| | | </template> |
| | | <template #buttons> |
| | | <FYDownloadTableButton |
| | | label="ä¸è½½æ¸
å" |
| | | table-id="fyTable" |
| | | :file-name="fileName" |
| | | :disabled="downloadDisabled" |
| | | ></FYDownloadTableButton> |
| | | </template> |
| | | <template #table-column="{ size }"> |
| | | <!-- <el-table-column fixed="left" label="åºå·" width="53"> |
| | | <template #default="{ row }"> |
| | | {{ row.index + 1 }} |
| | | </template> |
| | | </el-table-column> --> |
| | | <el-table-column fixed="left" label="å¯ä¸ç¼å·" width="90" prop="index"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="sceneName" |
| | | :show-overflow-tooltip="true" |
| | | label="åç§°" |
| | | > |
| | | </el-table-column> |
| | | <el-table-column prop="sceneType" label="ç±»å" width="60" /> |
| | | <!-- <el-table-column prop="provinceName" label="ç份" width="90"> |
| | | </el-table-column> |
| | | <el-table-column prop="cityName" label="åå¸" width="90"> |
| | | </el-table-column> --> |
| | | <el-table-column prop="districtName" label="åºå¿" width="90"> |
| | | </el-table-column> |
| | | <el-table-column prop="townName" label="è¡é" width="110"> |
| | | </el-table-column> |
| | | <el-table-column prop="problemType" label="é®é¢ç±»å" width="170"> |
| | | </el-table-column> |
| | | <el-table-column v-if="radio == 1" prop="problemName" label="é®é¢åç§°"> |
| | | </el-table-column> |
| | | <el-table-column prop="proNum" label="é®é¢æ°" width="70"> |
| | | </el-table-column> |
| | | <el-table-column prop="changeNum" label="æ´æ¹æ°" width="70"> |
| | | </el-table-column> |
| | | </template> |
| | | </FYTable> |
| | | </template> |
| | | <script setup> |
| | | import { ref, computed } from 'vue'; |
| | | import dayjs from 'dayjs'; |
| | | import dataproductApi from '@/api/fysp/dataproductApi.js'; |
| | | |
| | | const radio = ref(1); |
| | | const tableRef = ref(null); |
| | | const tableData = ref([]); |
| | | const formSearch = ref({ |
| | | locations: {}, |
| | | scenetype: {}, |
| | | timeArr: [dayjs().add(-1, 'M').date(1).toDate(), dayjs().toDate()] |
| | | }); |
| | | |
| | | const option = computed(() => { |
| | | const { locations, scenetype, timeArr } = formSearch.value; |
| | | return { |
| | | provinceCode: locations.pCode, |
| | | cityCode: locations.cCode, |
| | | districtCode: locations.dCode, |
| | | townCode: locations.tCode, |
| | | startTime: dayjs(timeArr[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: dayjs(timeArr[1]) |
| | | .hour(23) |
| | | .minute(59) |
| | | .second(59) |
| | | .format('YYYY-MM-DD HH:mm:ss'), |
| | | sceneTypeId: scenetype.value |
| | | }; |
| | | }); |
| | | |
| | | const showData = computed(() => { |
| | | let res = []; |
| | | switch (radio.value) { |
| | | case 1: |
| | | res = tableData.value; |
| | | break; |
| | | case 2: |
| | | tableData.value.forEach((tb) => { |
| | | const r = res.find((v) => { |
| | | return v.sceneName == tb.sceneName && v.problemType == tb.problemType; |
| | | }); |
| | | if (r == undefined) { |
| | | res.push({ ...tb }); |
| | | } else { |
| | | r.proNum += tb.proNum; |
| | | r.changeNum += tb.changeNum; |
| | | } |
| | | }); |
| | | break; |
| | | default: |
| | | res = tableData.value; |
| | | break; |
| | | } |
| | | if (tableRef.value) { |
| | | tableRef.value.doLayout(); |
| | | } |
| | | return res; |
| | | }); |
| | | |
| | | const fileName = computed(() => { |
| | | const { locations, scenetype, timeArr } = formSearch.value; |
| | | return `${locations.dName}${dayjs(timeArr[0]).format( |
| | | 'YYYYå¹´MMæDDæ¥' |
| | | )}è³${dayjs(timeArr[1]).format('YYYYå¹´MMæDDæ¥')}${ |
| | | scenetype.label |
| | | }é®é¢å¤åæ¸
å`; |
| | | }); |
| | | |
| | | const downloadDisabled = computed(() => { |
| | | return tableData.value.length == 0; |
| | | }); |
| | | |
| | | function onSearch(page, callback) { |
| | | fetchProbRecurrence().finally(() => callback()); |
| | | } |
| | | |
| | | function fetchProbRecurrence() { |
| | | return dataproductApi.fetchProbRecurrence(option.value).then((res) => { |
| | | tableData.value = res.data; |
| | | }); |
| | | } |
| | | // function handleChange(value) { |
| | | // switch (value) { |
| | | // case 1: |
| | | // break; |
| | | // case 2: |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | </script> |
| | |
| | | <template> |
| | | <el-button disabled icon="Upload" type="success" @click="dialogVisible = true">æ¹é导å
¥</el-button> |
| | | <el-button icon="Upload" type="success" @click="dialogVisible = true" |
| | | >æ¹é导å
¥</el-button |
| | | > |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | title="åºæ¯ä¿¡æ¯æ¹é导å
¥" |
| | |
| | | <el-upload |
| | | class="upload-demo" |
| | | drag |
| | | action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" |
| | | multiple |
| | | :limit="1" |
| | | v-model:file-list="fileList" |
| | | :auto-upload="false" |
| | | accept=".xlsx" |
| | | :on-change="handleChange" |
| | | :on-exceed="handleExceed" |
| | | > |
| | | <el-icon class="el-icon--upload"><upload-filled /></el-icon> |
| | | <div class="el-upload__text">æå¨æä»¶æ<em>ç¹å»ä¸ä¼ </em></div> |
| | | <template #tip> |
| | | <!-- <div class="el-upload__tip">jpg/png files with a size less than 500kb</div> --> |
| | | <el-text type="danger" size="small">{{ errMsg }}</el-text> |
| | | </template> |
| | | </el-upload> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="dialogVisible = false">åæ¶</el-button> |
| | | <el-button type="primary" @click="dialogVisible = false">ç¡®å®</el-button> |
| | | </div> |
| | | <el-row justify="space-between"> |
| | | <el-button type="primary" plain @click="downloadTemplate" |
| | | >ä¸è½½æ¨¡æ¿</el-button |
| | | > |
| | | <div class="dialog-footer"> |
| | | <el-button @click="handleClose">åæ¶</el-button> |
| | | |
| | | <el-button type="primary" @click="uploadFile" :loading="loading" |
| | | >ç¡®å®</el-button |
| | | > |
| | | </div> |
| | | </el-row> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | return { |
| | | dialogVisible: false |
| | | }; |
| | | <script setup> |
| | | import { ref } from 'vue'; |
| | | import sceneApi from '@/api/fysp/sceneApi'; |
| | | import { ElMessage } from 'element-plus'; |
| | | |
| | | const dialogVisible = ref(false); |
| | | const fileList = ref([]); |
| | | const errMsg = ref(''); |
| | | const loading = ref(false); |
| | | |
| | | function handleChange(file) { |
| | | console.log(file); |
| | | const ext = file.name.split('.').pop(); |
| | | if (ext !== 'xlsx') { |
| | | ElMessage.error('请ä¸ä¼ Excelæä»¶'); |
| | | fileList.value.splice(0, 1); |
| | | return; |
| | | } |
| | | }; |
| | | fileList.value = [file]; |
| | | } |
| | | |
| | | function handleExceed(files, fileList) { |
| | | ElMessage.error('æå¤åªè½ä¸ä¼ ä¸ä¸ªæä»¶'); |
| | | } |
| | | |
| | | function uploadFile() { |
| | | if (fileList.value.length === 0) { |
| | | ElMessage.error('请ä¸ä¼ æä»¶'); |
| | | return; |
| | | } |
| | | const formData = new FormData(); |
| | | loading.value = true; |
| | | formData.append('file', fileList.value[0].raw); |
| | | errMsg.value = ''; |
| | | sceneApi |
| | | .importScene(formData) |
| | | .then((res) => { |
| | | dialogVisible.value = false; |
| | | fileList.value = []; |
| | | }) |
| | | .catch((err) => { |
| | | errMsg.value = err; |
| | | }) |
| | | .finally(() => { |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | |
| | | function downloadTemplate() { |
| | | // å建ä¸è½½é¾æ¥ |
| | | const link = document.createElement('a'); |
| | | // 设置publicç®å½ä¸çæä»¶è·¯å¾ |
| | | link.href = '/ç°åºçç®¡åºæ¯ä¿¡æ¯å¯¼å
¥æ¨¡æ¿.xlsx'; |
| | | // 设置ä¸è½½æä»¶å |
| | | link.download = 'ç°åºçç®¡åºæ¯ä¿¡æ¯å¯¼å
¥æ¨¡æ¿.xlsx'; |
| | | // å°é¾æ¥æ·»å å°é¡µé¢ |
| | | document.body.appendChild(link); |
| | | // 触åç¹å»ä¸è½½ |
| | | link.click(); |
| | | // ä¸è½½å®æåç§»é¤é¾æ¥ |
| | | document.body.removeChild(link); |
| | | } |
| | | |
| | | function handleClose() { |
| | | dialogVisible.value = false; |
| | | fileList.value = []; |
| | | errMsg.value = ''; |
| | | } |
| | | </script> |