flame-plus 0.1.26 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flame-plus",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "private": false,
5
5
  "description": "基于 element-plus 的组件库",
6
6
  "main": "packages/index.ts",
@@ -10,7 +10,7 @@
10
10
  <slot :name="`search-${searchSlot}`" :prop="prop" :formModel="formModel"></slot>
11
11
  </template>
12
12
  </flmSearch>
13
- <flmToolbar class="page-toolbar" :config="reportPageConfig.toolbar" @toolbarClick="toolbarClick" />
13
+ <flmToolbar v-if="isDialog==false" class="page-toolbar" :config="reportPageConfig.toolbar" @toolbarClick="toolbarClick" />
14
14
  <flmTable
15
15
  class="page-table"
16
16
  :config="reportPageConfig.table"
@@ -67,7 +67,7 @@
67
67
  </template>
68
68
 
69
69
  <script lang="ts" setup>
70
- import { ref, Ref, computed, onMounted } from 'vue'
70
+ import { ref, Ref, computed, onMounted,toRaw } from 'vue'
71
71
  import { ElMessage, ElMessageBox } from 'element-plus'
72
72
  import {
73
73
  flmForm,
@@ -76,21 +76,26 @@ import {
76
76
  flmTable,
77
77
  flmPagination,
78
78
  flmDialog
79
- } from '@/components'
79
+ } from '../../index'
80
80
  import {
81
81
  FormItemConfig,
82
82
  FormConfig,
83
83
  TableColumnConfig,
84
84
  ReportPageSetting,
85
- } from '@/model/flmComponentConfig'
85
+ } from '../../../model/flmComponentConfig'
86
86
  import { isValidKey } from '../../../utils'
87
87
  import request from '@/plugins/request'
88
+ import { is } from '@babel/types'
88
89
 
89
90
  const props = defineProps({
90
91
  // 表名
91
92
  tableName: {
92
93
  type: String,
93
94
  required: true
95
+ },
96
+ isDialog:{
97
+ type:Boolean,
98
+ default:false,
94
99
  }
95
100
  })
96
101
 
@@ -156,14 +161,21 @@ const queryPageSetting = () => {
156
161
  const reportPageSetting: ReportPageSetting = items
157
162
  reportPageSetting.table['height'] = tableHeight()
158
163
  reportPageSetting.table['max-height'] = tableHeight()
159
- reportPageSetting.tableAction.buttons.length && reportPageSetting.table.columns?.push({
164
+ if(props.isDialog==false) {
165
+ reportPageSetting.tableAction.buttons.length && reportPageSetting.table.columns?.push({
160
166
  prop: 'tableAction',
161
167
  label: '操作',
162
168
  isSlot: true,
169
+ align: 'center',
170
+ 'header-align':'center',
163
171
  fixed: 'right',
164
- 'min-width': '200px'
172
+ 'min-width': '200px',
173
+ 'width': '200px'
165
174
  })
175
+ }
176
+
166
177
  reportPageConfig.value = reportPageSetting
178
+ isLoaded.value =true;
167
179
  queryPageData()
168
180
  })
169
181
  }
@@ -187,7 +199,6 @@ const queryPageData = () => {
187
199
  .then(({ items, total }: any) => {
188
200
  reportPageConfig.value.table.data = items
189
201
  reportPageConfig.value.pagination['total'] = total
190
- isLoaded.value = true
191
202
  })
192
203
  }
193
204
 
@@ -207,16 +218,15 @@ const searchSubmit = (event: object) => {
207
218
  const toolbarClick = (event: string) => {
208
219
  isValidKey(event, pageDefaultEvent)
209
220
  ? pageDefaultEvent[event]()
210
- : emit('customEvent', event)
221
+ : emit('customEvent', {event,data:{}})
211
222
  }
212
223
 
213
224
  // 表格操作栏点击
214
225
  const tableActionClick = (event: string, scope: any) => {
215
226
  isValidKey(event, pageDefaultEvent)
216
227
  ? pageDefaultEvent[event](scope)
217
- : emit('customEvent', { event, scope })
228
+ : emit('customEvent', { event,data: toRaw(scope.row) })
218
229
  }
219
-
220
230
  // 表格操作
221
231
  const tableEvent: Record<string, (event?: any) => void> = {
222
232
  // 表格勾选项变化
@@ -246,7 +256,7 @@ const pageDefaultEvent: Record<string, (event?: any) => void> = {
246
256
  openReadDialog:(scope: any) => {
247
257
  request.flameApi.singleSearch({
248
258
  tableName: safeTableName.value,
249
- data: { key: scope.row.flame_id }
259
+ data: { key: scope.row.flame_id ,ref_level:1}
250
260
  })
251
261
  .then(({ items }: any) => {
252
262
  reportPageConfig.value.readForm['model'] = items
@@ -288,6 +298,63 @@ const pageDefaultEvent: Record<string, (event?: any) => void> = {
288
298
  pageDefaultEvent.closeAddDialog()
289
299
  })
290
300
  },
301
+ // 页面导入
302
+ pageImport:() => {
303
+ const inputFile: any = document.createElement('input')
304
+ inputFile.type = 'file'
305
+ inputFile.style.display = 'none'
306
+ document.body.appendChild(inputFile)
307
+ inputFile.click()
308
+ inputFile.addEventListener('change', () => {
309
+ const file = inputFile.files[0]
310
+ var fileType = file.name.substring(file.name.lastIndexOf('.') + 1)
311
+ if (!['xls', 'xlsx', 'et'].includes(fileType)) {
312
+ ElMessage.warning('请上传 xls、xlsx、et 格式的文件!')
313
+ document.body.removeChild(inputFile)
314
+ return false
315
+ }
316
+ const formData = new FormData()
317
+ formData.append("file", file)
318
+ request.flameAxios({
319
+ headers: { 'Content-Type': 'multipart/form-data' },
320
+ method: 'post',
321
+ url: `/resource-service/upload_file?source=mongo&token=${request.token}`,
322
+ data: formData
323
+ })
324
+ .then(({ key: code }: any) => {
325
+ request.flameRequest({
326
+ tableName: safeTableName.value,
327
+ flameMethod: 'importfile',
328
+ data: { code }
329
+ })
330
+ .then((res: any) => {
331
+ if(res.result){
332
+ ElMessage.success('导入成功!')
333
+ pageRefresh()
334
+ }
335
+ else{
336
+ ElMessage.error(res.message)
337
+ }
338
+ })
339
+ })
340
+ .finally(() => document.body.removeChild(inputFile))
341
+ })
342
+ },
343
+ // 页面导出
344
+ pageExport:() => {
345
+ request.flameApi.exportFile({
346
+ tableName: safeTableName.value,
347
+ data: {
348
+ conditions: searchParams.value,
349
+ ref_level: 1,
350
+ order_by: "flame_id DESC"
351
+ }
352
+ })
353
+ .then(({ items }: any) => {
354
+ window.open(items.download_url)
355
+ ElMessage.success('导出成功')
356
+ })
357
+ },
291
358
  // 页面删除
292
359
  pageDelete:(scope: any) => {
293
360
  ElMessageBox.confirm(