...
|
...
|
@@ -10,9 +10,9 @@ |
10
|
10
|
:showOkBtn="false"
|
11
|
11
|
>
|
12
|
12
|
<div class="w-full h-full" ref="loadingRef">
|
13
|
|
- <!-- <div class="flex justify-end">
|
14
|
|
- <Button @click="handleTemplateDownload" type="link">EXCEL模板下载</Button>
|
15
|
|
- </div> -->
|
|
13
|
+ <div class="flex justify-end">
|
|
14
|
+ <Button @click="handleTemplateDownload" type="link">excel模板下载</Button>
|
|
15
|
+ </div>
|
16
|
16
|
<div class="flex justify-evenly items-center h-50 !w-full">
|
17
|
17
|
<Upload
|
18
|
18
|
accept=".json,"
|
...
|
...
|
@@ -21,7 +21,10 @@ |
21
|
21
|
class="flex justify-center items-center"
|
22
|
22
|
>
|
23
|
23
|
<div class="flex flex-col justify-center items-center">
|
24
|
|
- <img :src="JSONImage" alt="avatar" class="w-20 h-20" />
|
|
24
|
+ <Tooltip>
|
|
25
|
+ <template #title>使用从物模型TSL导出的JSON进行导入</template>
|
|
26
|
+ <img :src="JSONImage" alt="avatar" class="w-20 h-20" />
|
|
27
|
+ </Tooltip>
|
25
|
28
|
</div>
|
26
|
29
|
</Upload>
|
27
|
30
|
<Upload
|
...
|
...
|
@@ -31,7 +34,10 @@ |
31
|
34
|
class="flex justify-center items-center"
|
32
|
35
|
>
|
33
|
36
|
<div class="flex flex-col justify-center items-center">
|
34
|
|
- <img :src="CSVImage" alt="avatar" class="w-20 h-20" />
|
|
37
|
+ <Tooltip>
|
|
38
|
+ <template #title>请使用excel模板编辑之后在进行导入</template>
|
|
39
|
+ <img :src="CSVImage" alt="avatar" class="w-20 h-20" />
|
|
40
|
+ </Tooltip>
|
35
|
41
|
</div>
|
36
|
42
|
</Upload>
|
37
|
43
|
</div>
|
...
|
...
|
@@ -40,7 +46,7 @@ |
40
|
46
|
</template>
|
41
|
47
|
<script lang="ts" setup>
|
42
|
48
|
import { ref, unref } from 'vue';
|
43
|
|
- import { Upload } from 'ant-design-vue';
|
|
49
|
+ import { Upload, Tooltip, Button } from 'ant-design-vue';
|
44
|
50
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
45
|
51
|
import { DeviceRecord } from '/@/api/device/model/deviceModel';
|
46
|
52
|
import { useMessage } from '/@/hooks/web/useMessage';
|
...
|
...
|
@@ -50,6 +56,7 @@ |
50
|
56
|
importModelCategory,
|
51
|
57
|
importModelOfMatter,
|
52
|
58
|
importCsvDeviceProfileId,
|
|
59
|
+ excelExport,
|
53
|
60
|
} from '/@/api/device/modelOfMatter';
|
54
|
61
|
// import XLSX, { CellObject } from 'xlsx';
|
55
|
62
|
import { useLoading } from '/@/components/Loading';
|
...
|
...
|
@@ -162,6 +169,7 @@ |
162
|
169
|
});
|
163
|
170
|
flag && createMessage.info(flag?.message);
|
164
|
171
|
} catch (msg) {
|
|
172
|
+ // eslint-disable-next-line no-console
|
165
|
173
|
console.log(msg, 'msg');
|
166
|
174
|
} finally {
|
167
|
175
|
closeLoading();
|
...
|
...
|
@@ -170,23 +178,23 @@ |
170
|
178
|
}
|
171
|
179
|
};
|
172
|
180
|
|
173
|
|
- // const downloadFile = (data: string, fileName: string, type: string, ext: string) => {
|
174
|
|
- // const blob = new Blob([data], { type: type });
|
175
|
|
- // const objectURL = URL.createObjectURL(blob);
|
176
|
|
- // const element = document.createElement('a');
|
177
|
|
- // element.href = objectURL;
|
178
|
|
- // element.download = `${fileName}.${ext}`;
|
179
|
|
- // element.style.display = 'none';
|
180
|
|
- // document.body.appendChild(element);
|
181
|
|
- // element.click();
|
182
|
|
- // element.remove();
|
183
|
|
- // URL.revokeObjectURL(objectURL);
|
184
|
|
- // };
|
|
181
|
+ const downloadFile = (data: Blob, fileName: string, ext: string) => {
|
|
182
|
+ const objectURL = URL.createObjectURL(data);
|
|
183
|
+ const element = document.createElement('a');
|
|
184
|
+ element.href = objectURL;
|
|
185
|
+ element.download = `${fileName}.${ext}`;
|
|
186
|
+ element.style.display = 'none';
|
|
187
|
+ document.body.appendChild(element);
|
|
188
|
+ element.click();
|
|
189
|
+ element.remove();
|
|
190
|
+ URL.revokeObjectURL(objectURL);
|
|
191
|
+ };
|
185
|
192
|
|
186
|
193
|
// 模板下载
|
187
|
|
- // const handleTemplateDownload = () => {
|
188
|
|
-
|
189
|
|
- // };
|
|
194
|
+ const handleTemplateDownload = async () => {
|
|
195
|
+ const res = await excelExport();
|
|
196
|
+ downloadFile(res, '物模型属性导入模板', 'xls');
|
|
197
|
+ };
|
190
|
198
|
|
191
|
199
|
const handleCancel = () => {
|
192
|
200
|
closeModal();
|
...
|
...
|
|