Commit 2754da66541500e9a85f169e226d2514c57d500c
Merge branch 'fix/DEFECT-1775' into 'main_dev'
fix:产品物模型导入添加注释和excel模板 See merge request yunteng/thingskit-front!1035
Showing
5 changed files
with
43 additions
and
54 deletions
@@ -24,6 +24,7 @@ enum ModelOfMatter { | @@ -24,6 +24,7 @@ enum ModelOfMatter { | ||
24 | CATEGORY_EXPORT = '/things_model/categoryGetExport', | 24 | CATEGORY_EXPORT = '/things_model/categoryGetExport', |
25 | 25 | ||
26 | IMPORT_CSV = '/things_model/csvImport', | 26 | IMPORT_CSV = '/things_model/csvImport', |
27 | + EXCEL_EXPORT = '/things_model/downloadTemplate', | ||
27 | } | 28 | } |
28 | 29 | ||
29 | export const getModelList = ( | 30 | export const getModelList = ( |
@@ -169,3 +170,13 @@ export const importCsvDeviceProfileId = (params: { | @@ -169,3 +170,13 @@ export const importCsvDeviceProfileId = (params: { | ||
169 | params: params.file, | 170 | params: params.file, |
170 | }); | 171 | }); |
171 | }; | 172 | }; |
173 | + | ||
174 | +/** | ||
175 | + * 物模型excel导出模板 | ||
176 | + */ | ||
177 | +export const excelExport = () => { | ||
178 | + return defHttp.get({ | ||
179 | + url: `${ModelOfMatter.EXCEL_EXPORT}`, | ||
180 | + responseType: 'blob', | ||
181 | + }); | ||
182 | +}; |
@@ -97,7 +97,6 @@ | @@ -97,7 +97,6 @@ | ||
97 | // 状态->编辑 | 97 | // 状态->编辑 |
98 | const handleSwitch = async (e: any, record: any) => { | 98 | const handleSwitch = async (e: any, record: any) => { |
99 | switchLoading.value = true; | 99 | switchLoading.value = true; |
100 | - console.log(e, record); | ||
101 | await deviceProfileCategory({ ...record, status: e }); | 100 | await deviceProfileCategory({ ...record, status: e }); |
102 | switchLoading.value = false; | 101 | switchLoading.value = false; |
103 | createMessage.success('操作成功'); | 102 | createMessage.success('操作成功'); |
@@ -185,7 +184,6 @@ | @@ -185,7 +184,6 @@ | ||
185 | </template> | 184 | </template> |
186 | </BasicTable> | 185 | </BasicTable> |
187 | <classModal @register="registerModal" @handleReload="handleReload" /> | 186 | <classModal @register="registerModal" @handleReload="handleReload" /> |
188 | - <!-- <physicalModel @register="registerDetailDrawer" :record /> --> | ||
189 | <BasicDrawer title="物模型" @register="registerDetailDrawer" width="60%" destroy-on-close> | 187 | <BasicDrawer title="物模型" @register="registerDetailDrawer" width="60%" destroy-on-close> |
190 | <PhysicalModelManagementStep :record="registerDetailRecord" /> | 188 | <PhysicalModelManagementStep :record="registerDetailRecord" /> |
191 | </BasicDrawer> | 189 | </BasicDrawer> |
@@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
10 | :showOkBtn="false" | 10 | :showOkBtn="false" |
11 | > | 11 | > |
12 | <div class="w-full h-full" ref="loadingRef"> | 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 | <div class="flex justify-evenly items-center h-50 !w-full"> | 16 | <div class="flex justify-evenly items-center h-50 !w-full"> |
17 | <Upload | 17 | <Upload |
18 | accept=".json," | 18 | accept=".json," |
@@ -21,7 +21,10 @@ | @@ -21,7 +21,10 @@ | ||
21 | class="flex justify-center items-center" | 21 | class="flex justify-center items-center" |
22 | > | 22 | > |
23 | <div class="flex flex-col justify-center items-center"> | 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 | </div> | 28 | </div> |
26 | </Upload> | 29 | </Upload> |
27 | <Upload | 30 | <Upload |
@@ -31,7 +34,10 @@ | @@ -31,7 +34,10 @@ | ||
31 | class="flex justify-center items-center" | 34 | class="flex justify-center items-center" |
32 | > | 35 | > |
33 | <div class="flex flex-col justify-center items-center"> | 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 | </div> | 41 | </div> |
36 | </Upload> | 42 | </Upload> |
37 | </div> | 43 | </div> |
@@ -40,7 +46,7 @@ | @@ -40,7 +46,7 @@ | ||
40 | </template> | 46 | </template> |
41 | <script lang="ts" setup> | 47 | <script lang="ts" setup> |
42 | import { ref, unref } from 'vue'; | 48 | import { ref, unref } from 'vue'; |
43 | - import { Upload } from 'ant-design-vue'; | 49 | + import { Upload, Tooltip, Button } from 'ant-design-vue'; |
44 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 50 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
45 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 51 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
46 | import { useMessage } from '/@/hooks/web/useMessage'; | 52 | import { useMessage } from '/@/hooks/web/useMessage'; |
@@ -50,6 +56,7 @@ | @@ -50,6 +56,7 @@ | ||
50 | importModelCategory, | 56 | importModelCategory, |
51 | importModelOfMatter, | 57 | importModelOfMatter, |
52 | importCsvDeviceProfileId, | 58 | importCsvDeviceProfileId, |
59 | + excelExport, | ||
53 | } from '/@/api/device/modelOfMatter'; | 60 | } from '/@/api/device/modelOfMatter'; |
54 | // import XLSX, { CellObject } from 'xlsx'; | 61 | // import XLSX, { CellObject } from 'xlsx'; |
55 | import { useLoading } from '/@/components/Loading'; | 62 | import { useLoading } from '/@/components/Loading'; |
@@ -162,6 +169,7 @@ | @@ -162,6 +169,7 @@ | ||
162 | }); | 169 | }); |
163 | flag && createMessage.info(flag?.message); | 170 | flag && createMessage.info(flag?.message); |
164 | } catch (msg) { | 171 | } catch (msg) { |
172 | + // eslint-disable-next-line no-console | ||
165 | console.log(msg, 'msg'); | 173 | console.log(msg, 'msg'); |
166 | } finally { | 174 | } finally { |
167 | closeLoading(); | 175 | closeLoading(); |
@@ -170,23 +178,23 @@ | @@ -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 | const handleCancel = () => { | 199 | const handleCancel = () => { |
192 | closeModal(); | 200 | closeModal(); |
@@ -75,35 +75,6 @@ export const columnsDrawer: BasicColumn[] = [ | @@ -75,35 +75,6 @@ export const columnsDrawer: BasicColumn[] = [ | ||
75 | }, | 75 | }, |
76 | ellipsis: true, | 76 | ellipsis: true, |
77 | }, | 77 | }, |
78 | - // { | ||
79 | - // title: '事件类型', | ||
80 | - // dataIndex: 'eventType', | ||
81 | - // customRender({ text }) { | ||
82 | - // return h( | ||
83 | - // Tag, | ||
84 | - // { | ||
85 | - // color: EventTypeColor[text as EventType], | ||
86 | - // }, | ||
87 | - // () => EventTypeName[text as EventType] | ||
88 | - // ); | ||
89 | - // }, | ||
90 | - // ellipsis: true, | ||
91 | - // }, | ||
92 | - // { | ||
93 | - // title: '状态', | ||
94 | - // dataIndex: 'status', | ||
95 | - // width: 100, | ||
96 | - // customRender: (value: Record<'text', number>) => { | ||
97 | - // const { text } = value; | ||
98 | - // return h( | ||
99 | - // Tag, | ||
100 | - // { | ||
101 | - // color: text ? 'green' : 'red', | ||
102 | - // }, | ||
103 | - // () => (text ? '已发布' : '待发布') | ||
104 | - // ); | ||
105 | - // }, | ||
106 | - // }, | ||
107 | ]; | 78 | ]; |
108 | 79 | ||
109 | export const searchFormSchema: FormSchema[] = [ | 80 | export const searchFormSchema: FormSchema[] = [ |
@@ -121,7 +92,6 @@ export const searchFormSchema: FormSchema[] = [ | @@ -121,7 +92,6 @@ export const searchFormSchema: FormSchema[] = [ | ||
121 | labelField: 'itemText', | 92 | labelField: 'itemText', |
122 | valueField: 'itemValue', | 93 | valueField: 'itemValue', |
123 | placeholder: '请选择领域', | 94 | placeholder: '请选择领域', |
124 | - // getPopupContainer: () => document.body, | ||
125 | }; | 95 | }; |
126 | }, | 96 | }, |
127 | }, | 97 | }, |
@@ -186,7 +186,9 @@ | @@ -186,7 +186,9 @@ | ||
186 | selectType: props.record.ifShowClass ? 'category' : undefined, | 186 | selectType: props.record.ifShowClass ? 'category' : undefined, |
187 | }); | 187 | }); |
188 | }, | 188 | }, |
189 | - columns: physicalColumn, | 189 | + columns: props.record.ifShowClass |
190 | + ? physicalColumn.filter((item) => item.dataIndex !== 'status') | ||
191 | + : physicalColumn, | ||
190 | showIndexColumn: false, | 192 | showIndexColumn: false, |
191 | clickToRowSelect: false, | 193 | clickToRowSelect: false, |
192 | showTableSetting: true, | 194 | showTableSetting: true, |