vue2-client 1.18.27 → 1.18.29

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.
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div id="xreport-hosp-demo">
3
+ <a-space style="margin-bottom: 12px;">
4
+ <a-button type="primary" @click="doInit">手动初始化</a-button>
5
+ </a-space>
6
+ <XReport
7
+ ref="reportRef"
8
+ :edit-mode="true"
9
+ :show-save-button="true"
10
+ :show-img-in-cell="false"
11
+ :use-oss-for-img="false"
12
+ server-name="af-his"
13
+ @updateImg="onUpdateImg"/>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup>
18
+ import { ref } from 'vue'
19
+ import XReport from '@vue2-client/base-client/components/common/XReport'
20
+
21
+ const reportRef = ref(null)
22
+
23
+ const payload = {
24
+ arr: [
25
+ { BQ: '病房区', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 },
26
+ { BQ: '感染科', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 },
27
+ { BQ: '骨科病区', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 },
28
+ { BQ: '呼吸科病区', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 },
29
+ { BQ: '急症科病区', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 },
30
+ { BQ: '内科二病区', RY: 0, CY: 0, CW: 0, SW: 0, SS: 0, ZC: 0, ZR: 0, ZY: 0 }
31
+ ]
32
+ }
33
+
34
+ const doInit = async () => {
35
+ if (!reportRef.value || !reportRef.value.init) return
36
+ await reportRef.value.init({
37
+ configName: 'hospitalizationStatsReport',
38
+ configData: payload
39
+ })
40
+ }
41
+
42
+ const onUpdateImg = data => {
43
+ console.warn('updateImg:', data)
44
+ }
45
+ </script>
@@ -519,6 +519,11 @@ export default {
519
519
  return {}
520
520
  }
521
521
  },
522
+ // 行编辑模式自动数据切换自动保存
523
+ autoSave:{
524
+ type: Boolean,
525
+ default: false
526
+ },
522
527
  // 数据只有一页时是否展示分页,true:展示,auto:隐藏
523
528
  showPagination: {
524
529
  type: Boolean,
@@ -687,12 +692,12 @@ export default {
687
692
  })
688
693
  })
689
694
  },
690
- onCancel () {
695
+ onCancel() {
691
696
  }
692
697
  })
693
698
  }
694
699
  },
695
- importExcelOk (data) {
700
+ importExcelOk(data) {
696
701
  this.refresh(true)
697
702
  this.$emit('importExcelOk', data)
698
703
  },
@@ -701,7 +706,7 @@ export default {
701
706
  * @param row 选中行集合
702
707
  * @param attr 表单项属性
703
708
  */
704
- async rowChoose (row, attr, callback, record) {
709
+ async rowChoose(row, attr, callback, record) {
705
710
  // 如果配置了自定义函数
706
711
  if (attr.dataChangeFunc) {
707
712
  await executeStrFunction(attr.dataChangeFunc, [record, this.setForm, {
@@ -716,7 +721,7 @@ export default {
716
721
  callback()
717
722
  }
718
723
  },
719
- setForm (record, obj) {
724
+ setForm(record, obj) {
720
725
  Object.assign(record, obj)
721
726
  this.$forceUpdate()
722
727
  },
@@ -725,7 +730,7 @@ export default {
725
730
  * @param {Number} rowIndex 行索引
726
731
  * @param {String} fieldName 字段名
727
732
  */
728
- focusInput (rowIndex, fieldName) {
733
+ focusInput(rowIndex, fieldName) {
729
734
  this.$nextTick(() => {
730
735
  // 构造 ID:{rowIndex}-{fieldName}input
731
736
  const inputId = `${rowIndex}-${fieldName}input`
@@ -760,16 +765,16 @@ export default {
760
765
  * 处理表单项事件,向外抛出事件供开发者处理
761
766
  * @param {Object} context 增强的上下文数据
762
767
  */
763
- handleFormItemEvent (context) {
764
- const { func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex } = context
768
+ handleFormItemEvent(context) {
769
+ const {func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex} = context
765
770
 
766
771
  // 向外抛出事件,参数顺序:func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex
767
772
  this.$emit('x-form-item-emit-func', func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex)
768
773
  },
769
- handleResize () {
774
+ handleResize() {
770
775
  this.setScrollYHeight({})
771
776
  },
772
- isInAModal () {
777
+ isInAModal() {
773
778
  let parent = this.$parent
774
779
  while (parent) {
775
780
  // 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
@@ -782,7 +787,7 @@ export default {
782
787
  },
783
788
  executeStrFunction,
784
789
  // 切换看板模式和表格模式
785
- changeViewMode () {
790
+ changeViewMode() {
786
791
  this.isTableMode = !this.isTableMode
787
792
  // 看板切换回表格模式 刷新列表
788
793
  this.refresh(true)
@@ -790,7 +795,7 @@ export default {
790
795
  /**
791
796
  * 初始化表格参数
792
797
  */
793
- init (params) {
798
+ init(params) {
794
799
  const {
795
800
  // 查询参数对象, 用于没有对应查询配置文件名时
796
801
  queryParams,
@@ -964,7 +969,7 @@ export default {
964
969
  }
965
970
  },
966
971
  // 操作面板按钮渲染
967
- buttonRendering (button) {
972
+ buttonRendering(button) {
968
973
  if (!this.buttonPermissions) {
969
974
  return true
970
975
  }
@@ -983,7 +988,7 @@ export default {
983
988
  }
984
989
  },
985
990
  // 防止查询多次点击处理
986
- loadTableData (requestParameters) {
991
+ loadTableData(requestParameters) {
987
992
  if (this.queryPromise) {
988
993
  return this.queryPromise
989
994
  }
@@ -996,11 +1001,11 @@ export default {
996
1001
  * 加载表格数据
997
1002
  * @param requestParameters 请求参数
998
1003
  */
999
- async loadTableDataGen (requestParameters) {
1004
+ async loadTableDataGen(requestParameters) {
1000
1005
  let result
1001
1006
  if (this.localEditMode) {
1002
1007
  if (!this.isLocalDataSourceLoadedExternally && requestParameters?.conditionParams && Object.keys(requestParameters?.conditionParams).length > 0) {
1003
- const result = await query(Object.assign(requestParameters, { userId: this.currUser?.id }),
1008
+ const result = await query(Object.assign(requestParameters, {userId: this.currUser?.id}),
1004
1009
  this.serviceName, this.env === 'dev')
1005
1010
  if (result.data) {
1006
1011
  let no = 0
@@ -1018,7 +1023,7 @@ export default {
1018
1023
  })
1019
1024
  })
1020
1025
  } else {
1021
- result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1026
+ result = query(Object.assign(requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1022
1027
  result.then(res => {
1023
1028
  this.totalCount = res.totalCount || 0
1024
1029
 
@@ -1077,11 +1082,11 @@ export default {
1077
1082
  * @param func 事件默认 action
1078
1083
  * @param index 行下标
1079
1084
  */
1080
- action (record, actionType, func = 'action', index) {
1085
+ action(record, actionType, func = 'action', index) {
1081
1086
  this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func, index)
1082
1087
  },
1083
1088
  // 看板点击事件
1084
- handleCardEmit (data, eventName) {
1089
+ handleCardEmit(data, eventName) {
1085
1090
  this.action(data, undefined, eventName)
1086
1091
  },
1087
1092
  /**
@@ -1091,7 +1096,7 @@ export default {
1091
1096
  * @param selectedRows 被选择的列集合
1092
1097
  * @param nativeEvent 原生事件
1093
1098
  */
1094
- onSelect (record, selected, selectedRows, nativeEvent) {
1099
+ onSelect(record, selected, selectedRows, nativeEvent) {
1095
1100
  console.log('onSelect', record, selected, selectedRows)
1096
1101
  if (this.selectRowMode === 'listView') {
1097
1102
  const primaryKeyName = this.primaryKey || this.rowKey
@@ -1110,7 +1115,7 @@ export default {
1110
1115
  * @param selectedRows 被选择的列集合
1111
1116
  * @param changeRows 改变的行集合
1112
1117
  */
1113
- onSelectAll (selected, selectedRows, changeRows) {
1118
+ onSelectAll(selected, selectedRows, changeRows) {
1114
1119
  console.log('onSelectAll', selected, selectedRows, changeRows)
1115
1120
  if (this.selectRowMode === 'listView') {
1116
1121
  if (!selected) {
@@ -1127,7 +1132,7 @@ export default {
1127
1132
  * @param currentPageSelectedKeys 被选择的列Key集合
1128
1133
  * @param currentPageSelectedRows 被选择的列集合
1129
1134
  */
1130
- onSelectChange (currentPageSelectedKeys, currentPageSelectedRows) {
1135
+ onSelectChange(currentPageSelectedKeys, currentPageSelectedRows) {
1131
1136
  if (this.selectRowMode === 'listView' && !this.clearSelectRowAfterQuery) {
1132
1137
  const primaryKeyName = this.primaryKey || this.rowKey
1133
1138
  if (primaryKeyName) {
@@ -1187,13 +1192,13 @@ export default {
1187
1192
  /**
1188
1193
  * 清除表格选中项
1189
1194
  */
1190
- clearRowKeys () {
1195
+ clearRowKeys() {
1191
1196
  this.$refs.table.clearSelected()
1192
1197
  },
1193
1198
  /**
1194
1199
  * 为表格附加查询条件
1195
1200
  */
1196
- setQueryForm (form = {}) {
1201
+ setQueryForm(form = {}) {
1197
1202
  this.form = form
1198
1203
  if (this.createdQuery) {
1199
1204
  this.refresh(true)
@@ -1204,7 +1209,7 @@ export default {
1204
1209
  /**
1205
1210
  * 主动传递条件查询表格
1206
1211
  */
1207
- async queryTable (conditionParams) {
1212
+ async queryTable(conditionParams) {
1208
1213
  // 备份一下 form 这个函数传递的 condition 仅临时用一下
1209
1214
  // 如果要实质修改 form 需要在 x-form 中赋值
1210
1215
  const _from = JSON.parse(JSON.stringify(this.form))
@@ -1217,12 +1222,12 @@ export default {
1217
1222
  * 表格重新加载方法
1218
1223
  * 如果参数为 true, 则强制刷新到第一页
1219
1224
  */
1220
- refresh (bool) {
1225
+ refresh(bool) {
1221
1226
  this.$nextTick(() => {
1222
1227
  this.$refs.table.refresh(bool)
1223
1228
  })
1224
1229
  },
1225
- setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
1230
+ setScrollYHeight({extraHeight = this.extraHeight, id = this.uniqueId, type = ''}) {
1226
1231
  this.$nextTick(() => {
1227
1232
  debounce(() => {
1228
1233
  const curDocument = window?.rawDocument || document
@@ -1278,17 +1283,17 @@ export default {
1278
1283
  /**
1279
1284
  * 获取主键列名称
1280
1285
  */
1281
- getPrimaryKeyName () {
1286
+ getPrimaryKeyName() {
1282
1287
  if (this.primaryKey) {
1283
1288
  return this.primaryKey
1284
1289
  }
1285
1290
  const indexColumn = this.tableColumns.find(i => i?.slotType === 'index')
1286
1291
  return indexColumn ? indexColumn.dataIndex : this.tableColumns[0].dataIndex
1287
1292
  },
1288
- handleExport (type) {
1293
+ handleExport(type) {
1289
1294
  this.$refs.exportExcel.handleExport(type, this.title)
1290
1295
  },
1291
- handlePrint (type) {
1296
+ handlePrint(type) {
1292
1297
  const printData = {
1293
1298
  title: this.title,
1294
1299
  form: this.form,
@@ -1298,7 +1303,7 @@ export default {
1298
1303
  }
1299
1304
  this.$refs.exportExcel.handlePrint(type, printData)
1300
1305
  },
1301
- validateTableAndSyncData (currRow, defaultAppendRowData) {
1306
+ validateTableAndSyncData(currRow, defaultAppendRowData) {
1302
1307
  let isLastRow = false
1303
1308
  if (this.localEditModeDataSource.length === 0) {
1304
1309
  isLastRow = true
@@ -1310,7 +1315,7 @@ export default {
1310
1315
  }
1311
1316
  },
1312
1317
  // 新增业务
1313
- add () {
1318
+ add() {
1314
1319
  if (this.eventState?.customAdd) {
1315
1320
  this.custom('customAdd', {})
1316
1321
  return
@@ -1322,19 +1327,19 @@ export default {
1322
1327
  }
1323
1328
  },
1324
1329
  // 添加业务
1325
- move () {
1330
+ move() {
1326
1331
  this.$emit('move')
1327
1332
  },
1328
1333
  // 通用事件业务
1329
- custom (func) {
1334
+ custom(func) {
1330
1335
  this.$emit('customEvent', func)
1331
1336
  },
1332
1337
  // 编辑业务
1333
- edit (id) {
1338
+ edit(id) {
1334
1339
  this.editLoading = true
1335
1340
  this.getEditData(id).then(modifyModelData => {
1336
1341
  if (this.eventState?.customEdit) {
1337
- this.custom('customEdit', { id, modifyModelData })
1342
+ this.custom('customEdit', {id, modifyModelData})
1338
1343
  return
1339
1344
  }
1340
1345
  this.$emit('edit', modifyModelData)
@@ -1342,7 +1347,7 @@ export default {
1342
1347
  })
1343
1348
  },
1344
1349
  // 行选择业务
1345
- choose () {
1350
+ choose() {
1346
1351
  if (this.isChoose) {
1347
1352
  // 如果配置了自定义函数
1348
1353
  this.$emit('rowChoose', this.selectedRows)
@@ -1351,11 +1356,11 @@ export default {
1351
1356
  }
1352
1357
  },
1353
1358
  // 自定义按钮点击
1354
- editButtonStateDataClick (index) {
1359
+ editButtonStateDataClick(index) {
1355
1360
  this.$emit('editButtonStateDataClick', this.editButtonStateData[index].functionName, this.selectedRows)
1356
1361
  },
1357
1362
  // 获取被编辑的数据
1358
- getEditData (id) {
1363
+ getEditData(id) {
1359
1364
  if (!id) {
1360
1365
  this.selectId = this.selectedRowKeys[0]
1361
1366
  } else {
@@ -1387,11 +1392,11 @@ export default {
1387
1392
  requestParameters.conditionParams[primaryKeyName] = this.selectId
1388
1393
  requestParameters.f_businessid = this.selectId
1389
1394
  return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1390
- return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
1395
+ return {data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files}
1391
1396
  })
1392
1397
  },
1393
1398
  // 删除业务
1394
- deleteItem () {
1399
+ deleteItem() {
1395
1400
  if (this.viewMode) {
1396
1401
  this.$message.info('预览模式禁止删除')
1397
1402
  return
@@ -1436,24 +1441,24 @@ export default {
1436
1441
  }
1437
1442
  })
1438
1443
  },
1439
- onCancel () {
1444
+ onCancel() {
1440
1445
  }
1441
1446
  })
1442
1447
  },
1443
1448
  // 导入业务
1444
- importData () {
1449
+ importData() {
1445
1450
  this.$refs.importExcel.importExcelHandleOpen()
1446
1451
  },
1447
- afterVisibleChange (val) {
1452
+ afterVisibleChange(val) {
1448
1453
  if (val) {
1449
1454
  this.retrieveSummaryData()
1450
1455
  }
1451
1456
  },
1452
- async retrieveSummaryData () {
1457
+ async retrieveSummaryData() {
1453
1458
  const promises = []
1454
1459
 
1455
1460
  if (this.requestParameters.querySummary) {
1456
- const querySummaryPromise = querySummary(Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1461
+ const querySummaryPromise = querySummary(Object.assign(this.requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1457
1462
  .then(res => {
1458
1463
  if (this.compatible === 'V3') {
1459
1464
  res = res.data
@@ -1475,7 +1480,7 @@ export default {
1475
1480
 
1476
1481
  if (this.showCustomSummary) {
1477
1482
  this.customSummaryArray.forEach(item => {
1478
- const runLogicPromise = runLogic(item.source, Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1483
+ const runLogicPromise = runLogic(item.source, Object.assign(this.requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1479
1484
  .then(res => {
1480
1485
  this.summaryData.forEach(summary => {
1481
1486
  if (item.key === summary.key) {
@@ -1501,7 +1506,7 @@ export default {
1501
1506
  await Promise.all(promises)
1502
1507
  return this.summaryData
1503
1508
  },
1504
- sortSummaryData () {
1509
+ sortSummaryData() {
1505
1510
  const result = this.summaryData
1506
1511
  // 过滤出 result 中实际存在的 title,并按照 fieldsArray 的顺序排序
1507
1512
  this.summaryData = [...result].sort((a, b) => {
@@ -1510,7 +1515,7 @@ export default {
1510
1515
  return indexA - indexB
1511
1516
  })
1512
1517
  },
1513
- showDrawer () {
1518
+ showDrawer() {
1514
1519
  if (this.summaryUpdate) {
1515
1520
  this.summaryData.forEach(item => {
1516
1521
  item.loading = true
@@ -1522,15 +1527,15 @@ export default {
1522
1527
  this.$message.warning('请查询后再来查看')
1523
1528
  }
1524
1529
  },
1525
- onClose () {
1530
+ onClose() {
1526
1531
  this.summaryDrawerVisible = false
1527
1532
  },
1528
1533
  // 获取表格内所有数据
1529
- getTableData () {
1534
+ getTableData() {
1530
1535
  return this.$refs.table.localDataSource
1531
1536
  },
1532
1537
  // 设置表格内数据
1533
- setTableData (data) {
1538
+ setTableData(data) {
1534
1539
  if (this.localEditMode) {
1535
1540
  // 本地编辑模式下,需要修改 localEditModeDataSource
1536
1541
  this.localEditModeDataSource = data.map((item, index) => ({
@@ -1550,24 +1555,24 @@ export default {
1550
1555
  }
1551
1556
  },
1552
1557
  // 获取所有本地数据
1553
- getLocalData () {
1558
+ getLocalData() {
1554
1559
  return this.localEditModeDataSource
1555
1560
  },
1556
1561
  // 获取指定rowKey的value的本地数据
1557
- getDataByRowKeyValue (rowKeyValue) {
1562
+ getDataByRowKeyValue(rowKeyValue) {
1558
1563
  return this.getLocalData().find(item => {
1559
1564
  return item[this.rowKey] === rowKeyValue
1560
1565
  })
1561
1566
  },
1562
1567
  // 修改本地数据
1563
- modifyLocalData (rowKeyValue, data) {
1568
+ modifyLocalData(rowKeyValue, data) {
1564
1569
  const modifyItem = this.getDataByRowKeyValue(rowKeyValue)
1565
1570
  if (modifyItem) {
1566
1571
  Object.assign(modifyItem, data)
1567
1572
  }
1568
1573
  },
1569
1574
  // 追加本地数据
1570
- appendLocalData (item) {
1575
+ appendLocalData(item) {
1571
1576
  if (this.localEditModeDataSource.length === 0) {
1572
1577
  item['序号'] = 1
1573
1578
  } else {
@@ -1575,20 +1580,23 @@ export default {
1575
1580
  }
1576
1581
  this.localEditModeDataSource.push(item)
1577
1582
  },
1578
- handleRowClick (record) {
1583
+ handleRowClick(record) {
1579
1584
  this.$emit('rowClick', record)
1580
1585
  },
1581
- handleRowDblClick (record) {
1586
+ handleRowDblClick(record) {
1582
1587
  this.$emit('rowDblClick', record)
1583
1588
  },
1584
- beforeDataChange (record) {
1589
+ beforeDataChange(record) {
1590
+ if (this.isEditMode && this.autoSave) {
1591
+ this.editRowSave()
1592
+ }
1585
1593
  this.$emit('beforeDataChange', record)
1586
1594
  },
1587
- onExpand (expanded, record) {
1595
+ onExpand(expanded, record) {
1588
1596
  this.$emit('expand', expanded, record)
1589
1597
  },
1590
1598
  // 添加新方法处理表格选中状态
1591
- updateTableSelection (selectedKeys) {
1599
+ updateTableSelection(selectedKeys) {
1592
1600
  console.log('selectedKeys', selectedKeys)
1593
1601
  if (!this.$refs.table) {
1594
1602
  return
@@ -1612,7 +1620,7 @@ export default {
1612
1620
  },
1613
1621
 
1614
1622
  // 实际执行更新选中状态的方法
1615
- doUpdateTableSelection (selectedKeys) {
1623
+ doUpdateTableSelection(selectedKeys) {
1616
1624
  const primaryKeyName = this.primaryKey || this.rowKey
1617
1625
 
1618
1626
  // 更新内部选中状态
@@ -1695,7 +1703,8 @@ export default {
1695
1703
  margin: 0;
1696
1704
  }
1697
1705
  }
1698
- .hiddenFunctionalArea{
1706
+
1707
+ .hiddenFunctionalArea {
1699
1708
  display: none;
1700
1709
  }
1701
1710
  </style>
@@ -1,88 +1,88 @@
1
- <template>
2
- <div class="h-chart-test-container">
3
- <h2>HChart 组件测试案例</h2>
4
-
5
- <section class="test-section">
6
- <h3>测试1: 通过 queryParamsName 查询配置(从后端获取配置和数据)</h3>
7
- <div class="chart-wrapper">
8
- <HChart
9
- ref="chart1"
10
- query-params-name="accountsReceivableChart"
11
- :fixed-query-form="{ condition: '1=1', dateRange: '2024-01' }"
12
- service-name="af-his"
13
- @init="handleChartInit"
14
- @dataLoaded="handleDataLoaded"
15
- @error="handleError"
16
- />
17
- </div>
18
- <div class="test-actions">
19
- <a-button @click="refreshChart1">刷新图表</a-button>
20
- <a-button @click="reloadChart1">重新加载(更新查询条件)</a-button>
21
- </div>
22
- </section>
23
-
24
- <section class="test-section">
25
- <h3>测试日志</h3>
26
- <div class="log-container">
27
- <div v-for="(log, index) in logs" :key="index" class="log-item">
28
- <span class="log-time">{{ log.time }}</span>
29
- <span class="log-type" :class="log.type">{{ log.type }}</span>
30
- <span class="log-message">{{ log.message }}</span>
31
- </div>
32
- </div>
33
- <a-button @click="clearLogs">清空日志</a-button>
34
- </section>
35
- </div>
36
- </template>
37
-
38
- <script setup>
39
- import { ref } from 'vue'
40
- import { message } from 'ant-design-vue'
41
- import HChart from './HChart.vue'
42
-
43
- const chart1 = ref(null)
44
-
45
- const logs = ref([])
46
-
47
- const addLog = (type, messageText) => {
48
- logs.value.unshift({
49
- time: new Date().toLocaleTimeString(),
50
- type,
51
- message: typeof messageText === 'object' ? JSON.stringify(messageText, null, 2) : messageText
52
- })
53
- if (logs.value.length > 50) logs.value.pop()
54
- }
55
-
56
- const clearLogs = () => {
57
- logs.value = []
58
- }
59
-
60
- const handleChartInit = (config) => {
61
- addLog('init', `图表初始化: ${config?.title || '未知'}`)
62
- message.success(`图表初始化成功: ${config?.title || '未知'}`)
63
- }
64
-
65
- const handleDataLoaded = (data) => {
66
- addLog('dataLoaded', `数据加载完成,共 ${data?.length || 0} 条`)
67
- console.log('数据加载完成:', data)
68
- }
69
-
70
- const handleError = (error) => {
71
- addLog('error', `错误: ${error?.message || String(error)}`)
72
- message.error(`图表加载错误: ${error?.message || String(error)}`)
73
- }
74
-
75
- const refreshChart1 = () => {
76
- if (!chart1.value) return
77
- chart1.value.refresh()
78
- addLog('action', '刷新图表')
79
- message.info('正在刷新图表...')
80
- }
81
-
82
- const reloadChart1 = () => {
83
- if (!chart1.value) return
84
- chart1.value.reload({ condition: '1=1', dateRange: '2024-02' })
85
- addLog('action', '重新加载图表,更新查询条件')
86
- message.info('正在重新加载图表...')
87
- }
88
- </script>
1
+ <template>
2
+ <div class="h-chart-test-container">
3
+ <h2>HChart 组件测试案例</h2>
4
+
5
+ <section class="test-section">
6
+ <h3>测试1: 通过 queryParamsName 查询配置(从后端获取配置和数据)</h3>
7
+ <div class="chart-wrapper">
8
+ <HChart
9
+ ref="chart1"
10
+ query-params-name="accountsReceivableChart"
11
+ :fixed-query-form="{ condition: '1=1', dateRange: '2024-01' }"
12
+ service-name="af-his"
13
+ @init="handleChartInit"
14
+ @dataLoaded="handleDataLoaded"
15
+ @error="handleError"
16
+ />
17
+ </div>
18
+ <div class="test-actions">
19
+ <a-button @click="refreshChart1">刷新图表</a-button>
20
+ <a-button @click="reloadChart1">重新加载(更新查询条件)</a-button>
21
+ </div>
22
+ </section>
23
+
24
+ <section class="test-section">
25
+ <h3>测试日志</h3>
26
+ <div class="log-container">
27
+ <div v-for="(log, index) in logs" :key="index" class="log-item">
28
+ <span class="log-time">{{ log.time }}</span>
29
+ <span class="log-type" :class="log.type">{{ log.type }}</span>
30
+ <span class="log-message">{{ log.message }}</span>
31
+ </div>
32
+ </div>
33
+ <a-button @click="clearLogs">清空日志</a-button>
34
+ </section>
35
+ </div>
36
+ </template>
37
+
38
+ <script setup>
39
+ import { ref } from 'vue'
40
+ import { message } from 'ant-design-vue'
41
+ import HChart from './HChart.vue'
42
+
43
+ const chart1 = ref(null)
44
+
45
+ const logs = ref([])
46
+
47
+ const addLog = (type, messageText) => {
48
+ logs.value.unshift({
49
+ time: new Date().toLocaleTimeString(),
50
+ type,
51
+ message: typeof messageText === 'object' ? JSON.stringify(messageText, null, 2) : messageText
52
+ })
53
+ if (logs.value.length > 50) logs.value.pop()
54
+ }
55
+
56
+ const clearLogs = () => {
57
+ logs.value = []
58
+ }
59
+
60
+ const handleChartInit = (config) => {
61
+ addLog('init', `图表初始化: ${config?.title || '未知'}`)
62
+ message.success(`图表初始化成功: ${config?.title || '未知'}`)
63
+ }
64
+
65
+ const handleDataLoaded = (data) => {
66
+ addLog('dataLoaded', `数据加载完成,共 ${data?.length || 0} 条`)
67
+ console.log('数据加载完成:', data)
68
+ }
69
+
70
+ const handleError = (error) => {
71
+ addLog('error', `错误: ${error?.message || String(error)}`)
72
+ message.error(`图表加载错误: ${error?.message || String(error)}`)
73
+ }
74
+
75
+ const refreshChart1 = () => {
76
+ if (!chart1.value) return
77
+ chart1.value.refresh()
78
+ addLog('action', '刷新图表')
79
+ message.info('正在刷新图表...')
80
+ }
81
+
82
+ const reloadChart1 = () => {
83
+ if (!chart1.value) return
84
+ chart1.value.reload({ condition: '1=1', dateRange: '2024-02' })
85
+ addLog('action', '重新加载图表,更新查询条件')
86
+ message.info('正在重新加载图表...')
87
+ }
88
+ </script>