vue2-client 1.9.87 → 1.9.89

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.
@@ -33,7 +33,17 @@ this.openDialog('xxx', 5, {}, {}, {})
33
33
  - getTableData() 获取全部数据
34
34
  - setTableData(data) 设置表格内数据
35
35
  - Object.assign(this.fixedQueryForm, data) 给查询条件传值
36
+ - getPrimaryData (rows) 返回主表不带别名的数据
37
+ - pushPrimaryData (rows) 把不带主表别名的数据放到数据区
38
+ - setFixedQueryForm (data) 设置固定条件,主表别名不用加
39
+ - update() 让新修改的数据生效
36
40
  - 事件相关
41
+ - 行编辑时,下拉选中处理,function (form,setForm,attr,util,self)
42
+ * form 当前编辑行
43
+ * setForm(form, {})给编辑行设置值
44
+ * attr.selectRows[] 选中的数据
45
+ * util 可以使用的工具方法
46
+ * self x-form-table组件自身
37
47
  - afterSubmit( type(新增/修改/擦和讯), id: (所操作的主键id), form: (请求的表单内容)) 提交后触发
38
48
  - afterQuery( res (查询后数据), querparams (查询参数)) 查询后触发
39
49
  afterDelete( res (删除接口返回数据)) 删除后触发
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.9.87",
3
+ "version": "1.9.89",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -642,10 +642,10 @@ export default {
642
642
  const childModel = item.model
643
643
  const childData = this.$refs[item.model].getTableData()
644
644
  for (let i = 0; i < childData.length; i++) {
645
- childData[i] = this.handleFormKeys(childData[i])
645
+ childData[i] = this.handleFormKeys(childData[i], true)
646
646
  // 外键不需要带表别名,所以此处放到表单处理后赋值
647
647
  if (realForm.id) {
648
- childData[i][item.childTableForeignKeyName] = realForm.id
648
+ childData[i][item.foreignKey] = realForm.id
649
649
  }
650
650
  }
651
651
  realForm[childModel] = childData
@@ -751,7 +751,7 @@ export default {
751
751
  }
752
752
  },
753
753
 
754
- handleFormKeys (form) {
754
+ handleFormKeys (form, mustHandleKey = false) {
755
755
  const realForm = {}
756
756
  for (const key of Object.keys(form)) {
757
757
  const value = form[key]
@@ -764,7 +764,7 @@ export default {
764
764
  }
765
765
  realForm[extraFormKey][realKey] = value
766
766
  } else {
767
- const realKey = this.isHandleFormKey ? this.getRealKey(key) : key
767
+ const realKey = this.isHandleFormKey || mustHandleKey ? this.getRealKey(key, mustHandleKey) : key
768
768
  // 如果发生重名,不覆盖,把key的别名带上
769
769
  if (realForm[realKey]) {
770
770
  realForm[key] = value
@@ -803,8 +803,8 @@ export default {
803
803
  })
804
804
  },
805
805
  // 获取表单字段实际值
806
- getRealKey (key) {
807
- if (this.isHandleFormKey) {
806
+ getRealKey (key, mustHandleKey = false) {
807
+ if (this.isHandleFormKey || mustHandleKey) {
808
808
  return key.substring(key.indexOf('_') + 1)
809
809
  } else {
810
810
  return key
@@ -870,13 +870,16 @@ export default {
870
870
  if (this.childFormData.length > 0) {
871
871
  for (const item of this.childFormData) {
872
872
  const child = this.$refs[item.model]
873
+ // 获取子表别名,以便在条件上添加别名
874
+ const alias = child.realQueryConfig.tableAliasName
873
875
  // 有主键,且主键有值,添加主键条件
874
876
  if (this.primaryKey && this.form[this.primaryKey]) {
875
877
  const foreignKey = item.foreignKey
878
+ const fixedQueryForm = { [alias + '_' + foreignKey]: this.form[this.primaryKey] }
876
879
  if (!child.fixedQueryForm) {
877
- child.fixedQueryForm = { [foreignKey]: this.form[this.primaryKey] }
880
+ child.fixedQueryForm = fixedQueryForm
878
881
  } else {
879
- Object.assign(child.fixedQueryForm, { [foreignKey]: this.form[this.primaryKey] })
882
+ Object.assign(child.fixedQueryForm, fixedQueryForm)
880
883
  }
881
884
  child.refreshTable()
882
885
  }
@@ -75,34 +75,18 @@
75
75
  </div>
76
76
  <div v-if="this.showPagination">
77
77
  <a-divider/>
78
- <div v-if="!simpleMode">
79
- <a-pagination
80
- v-model="pageNum"
81
- style="float: right"
82
- :total="total"
83
- show-less-items
84
- :page-size="pageSize"
85
- :page-size-options="pageSizeOptions"
86
- show-size-changer
87
- @change="pageNumChange"
88
- :showTotal="paginationShowTotal"
89
- @showSizeChange="pageSizeChange">
90
- </a-pagination>
91
- </div>
92
- <div v-else>
93
- <!-- simpleMode页面 -->
94
- <a-pagination
95
- v-model="pageNum"
96
- style="float: right"
97
- :total="total"
98
- :page-size="pageSize"
99
- :class="{'hide-page-numbers': true}"
100
- :page-size-options="pageSizeOptions"
101
- @change="pageNumChange"
102
- :showTotal="paginationShowTotal"
103
- @showSizeChange="pageSizeChange">
104
- </a-pagination>
105
- </div>
78
+ <a-pagination
79
+ v-model="pageNum"
80
+ style="float: right"
81
+ :total="total"
82
+ show-less-items
83
+ :page-size="pageSize"
84
+ :page-size-options="pageSizeOptions"
85
+ show-size-changer
86
+ @change="pageNumChange"
87
+ :showTotal="paginationShowTotal"
88
+ @showSizeChange="pageSizeChange">
89
+ </a-pagination>
106
90
  </div>
107
91
  </div>
108
92
  </template>
@@ -135,11 +119,6 @@ export default {
135
119
  type: Array,
136
120
  default: undefined
137
121
  },
138
- // 是否简易模式
139
- simpleMode: {
140
- type: Boolean,
141
- default: false
142
- },
143
122
  tableColumns: {
144
123
  type: Array,
145
124
  default: undefined
@@ -151,6 +130,11 @@ export default {
151
130
  type: String,
152
131
  default: 'prod'
153
132
  },
133
+ // pageSize参数
134
+ prePageSize: {
135
+ type: Number,
136
+ default: undefined
137
+ },
154
138
  // 初始是否加载数据
155
139
  createdQuery: {
156
140
  type: Boolean,
@@ -175,6 +159,12 @@ export default {
175
159
  total: 0
176
160
  }
177
161
  },
162
+ created () {
163
+ // 根据参数初始化数据值
164
+ if (this.prePageSize) {
165
+ this.pageSize = this.prePageSize
166
+ }
167
+ },
178
168
  mounted () {
179
169
  // 配置初始化
180
170
  if (this.cardConfig) {
@@ -35,21 +35,21 @@
35
35
  @click="emitFunc(attr.inputOnAfterFunc,attr)">
36
36
  {{ attr.inputOnAfterName }}
37
37
  </a-button>
38
- <!-- 状态按钮 -->
39
- <x-status-button
40
- v-else
41
- :states="parseStates(attr.inputOnAfterName, attr.inputOnAfterFunc)"
42
- v-on="generateDynamicEvents(attr.inputOnAfterFunc, attr)"
43
- style="flex: 1; width: auto; min-width: 4rem; max-width: 6rem"
44
- />
45
38
  <!-- 仅可以配置 一个按钮 以及 一个图标插槽 -->
46
39
  <a-button
47
40
  style="width: 2rem; flex-shrink: 0;"
48
- v-if="attr.inputOnAfterIcon"
41
+ v-else-if="attr.inputOnAfterIcon"
49
42
  :type="attr.inputOnAfterIcon && attr.inputOnAfterName ? 'primary' :''"
50
43
  :icon="attr.inputOnAfterIcon || 'question'"
51
44
  @click="emitFunc(attr.inputOnAfterIconFunc,attr)">
52
45
  </a-button>
46
+ <!-- 状态按钮 -->
47
+ <x-status-button
48
+ v-else
49
+ :states="parseStates(attr.inputOnAfterName, attr.inputOnAfterFunc)"
50
+ v-on="generateDynamicEvents(attr.inputOnAfterFunc, attr)"
51
+ style="flex: 1; width: auto; min-width: 4rem; max-width: 6rem"
52
+ />
53
53
  </a-input-group>
54
54
  <a-input-number
55
55
  v-else-if="attr.numberInput && !readOnly"
@@ -518,7 +518,7 @@
518
518
  placement="bottom"
519
519
  trigger="focus"
520
520
  :arrowPointAtCenter="true"
521
- :overlayStyle="{ width: '1000px', height: '600px' }">
521
+ :overlayStyle="{ width: '1000px', height: '30vh' }">
522
522
  <template #content>
523
523
  <x-form-table
524
524
  title="请选择数据"
@@ -138,6 +138,11 @@ export default {
138
138
  XAddReport,
139
139
  XImportExcel
140
140
  },
141
+ provide () {
142
+ return {
143
+ getSelf: () => this,
144
+ }
145
+ },
141
146
  inject: ['getSelectedId', 'getSelectedData', 'getMixinData', 'getOutEnv', 'currUser'],
142
147
  data () {
143
148
  return {
@@ -330,6 +335,56 @@ export default {
330
335
  columnClick (key, value, record) {
331
336
  this.$emit('columnClick', key, value, record)
332
337
  },
338
+
339
+ // 获取主表的数据内容,去掉主表别名
340
+ getPrimaryData (rows) {
341
+ const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
342
+ const prefix = `${alias}_` // 构建前缀
343
+ const result = []
344
+
345
+ // 遍历 rows 的每一项,提取符合条件的数据
346
+ rows.forEach(row => {
347
+ const itemResult = {}
348
+ Object.keys(row).forEach(key => {
349
+ if (key.startsWith(prefix)) {
350
+ const newKey = key.slice(prefix.length) // 去掉前缀
351
+ itemResult[newKey] = row[key] // 添加到结果对象中
352
+ }
353
+ })
354
+ result.push(itemResult) // 将处理后的项添加到结果数组中
355
+ })
356
+
357
+ return result // 返回去掉前缀后的对象数组
358
+ },
359
+
360
+ // 给数据区域添加主表数据,给的数据没有主表别名,放着时添加主表别名
361
+ pushPrimaryData (rows) {
362
+ const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
363
+ const prefix = `${alias}_` // 构建前缀
364
+ const result = rows.map(row => {
365
+ const itemResult = {}
366
+ Object.keys(row).forEach(key => {
367
+ itemResult[prefix + key] = row[key] // 复制原始数据
368
+ })
369
+ return itemResult // 返回添加了主表别名的数据
370
+ })
371
+ // 把结果添加到数据区
372
+ this.getTableData().push(...result)
373
+ },
374
+
375
+ // 设置固定查询条件,主表别名自动带
376
+ setFixedQueryForm (data) {
377
+ const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
378
+ const prefixedData = {}
379
+
380
+ // 为每个键添加主表别名
381
+ Object.keys(data).forEach(key => {
382
+ prefixedData[`${alias}_${key}`] = data[key]
383
+ })
384
+
385
+ Object.assign(this.fixedQueryForm, prefixedData)
386
+ },
387
+
333
388
  importExcelOk () {
334
389
  this.$emit('importExcelOk')
335
390
  },
@@ -378,6 +433,7 @@ export default {
378
433
  this.updateComponents(res, true)
379
434
  }, this.env === 'dev')
380
435
  },
436
+
381
437
  /**
382
438
  * 更新子组件
383
439
  * @param res 参数
@@ -393,6 +449,7 @@ export default {
393
449
  this.$refs.xTable.init({
394
450
  formItems: res.formJson,
395
451
  primaryKey: res.primaryKey,
452
+ attachGrid: res.attachGrid,
396
453
  createdQuery: res.createdQuery,
397
454
  queryParams: setQueryParams ? res : null,
398
455
  tableColumns: res.columnJson,
@@ -648,6 +705,11 @@ export default {
648
705
  getTableData () {
649
706
  return this.$refs.xTable.getTableData()
650
707
  },
708
+ // 在行编辑等情况下,让界面生效
709
+ update () {
710
+ this.getTableData().push(...[])
711
+ },
712
+
651
713
  /**
652
714
  * 设置表格数据
653
715
  */
@@ -40,7 +40,7 @@ export default {
40
40
  data () {
41
41
  return {
42
42
  // 查询配置文件名
43
- queryParamsName: 'ChargeQueryCRUD',
43
+ queryParamsName: 'ceshiCRUD',
44
44
  // 查询配置左侧tree
45
45
  // xTreeConfigName: 'addressType',
46
46
  // 新增表单固定值
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <div class="tag-container">
3
+ <div class="tags-wrapper">
4
+ <a-tag
5
+ v-for="type in types"
6
+ :key="type.value"
7
+ @click="selectType(type.value)"
8
+ class="label-tag"
9
+ :class="{ 'active-tag': selectedType === type.value }"
10
+ >
11
+ {{ type.label }}
12
+ </a-tag>
13
+ </div>
14
+ <div class="underline" :style="underlineStyle"></div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ export default {
20
+ props: {
21
+ value: {
22
+ type: String,
23
+ default: null,
24
+ },
25
+ },
26
+ data () {
27
+ return {
28
+ selectedType: this.value,
29
+ types: null,
30
+ underlineStyle: {
31
+ width: '0',
32
+ left: '0',
33
+ },
34
+ }
35
+ },
36
+ watch: {
37
+ selectedType (newValue) {
38
+ this.$emit('input', newValue)
39
+ this.updateUnderline()
40
+ },
41
+ },
42
+ mounted () {
43
+ this.updateUnderline()
44
+ },
45
+ methods: {
46
+ init (params) {
47
+ const {
48
+ // 配置内容
49
+ options
50
+ } = params
51
+ this.types = options
52
+ },
53
+ selectType (value) {
54
+ this.selectedType = value
55
+ },
56
+ updateUnderline () {
57
+ // 动态更新下划线位置和宽度
58
+ this.$nextTick(() => {
59
+ const activeTag = this.$el.querySelector('.active-tag')
60
+ if (activeTag) {
61
+ const { offsetWidth, offsetLeft } = activeTag
62
+ this.underlineStyle.width = `${offsetWidth}px`
63
+ this.underlineStyle.left = `${offsetLeft}px`
64
+ }
65
+ })
66
+ }
67
+ }
68
+ }
69
+ </script>
70
+
71
+ <style scoped>
72
+ /* 容器样式 */
73
+ .tag-container {
74
+ position: relative;
75
+ display: inline-block;
76
+ width: 100%;
77
+ }
78
+
79
+ .tags-wrapper {
80
+ display: inline-flex; /* 标签紧邻排列 */
81
+ gap: 0; /* 去掉选项之间的空隙 */
82
+ }
83
+
84
+ .label-tag {
85
+ padding: 5px 15px;
86
+ font-size: 16px;
87
+ color: #333;
88
+ background: none;
89
+ cursor: pointer;
90
+ border: none;
91
+ display: inline-block;
92
+ }
93
+
94
+ .label-tag.active-tag {
95
+ color: #333; /* 不变色 */
96
+ font-weight: bold;
97
+ }
98
+
99
+ .underline {
100
+ position: absolute;
101
+ bottom: 0;
102
+ left: 0;
103
+ height: 2px;
104
+ background-color: #1890ff;
105
+ transition: all 0.3s ease; /* 平滑过渡效果 */
106
+ }
107
+ </style>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div>
3
+ <h1>选择标签示例</h1>
4
+ <XLabelSelect
5
+ :options="options"
6
+ v-model="selectedOption"
7
+ label="请选择一个选项"
8
+ />
9
+ <p>选中的选项: {{ selectedOption }}</p>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import XLabelSelect from '@/base-client/components/common/XLabelSelect/XLabelSelect.vue'
15
+
16
+ export default {
17
+ components: {
18
+ XLabelSelect,
19
+ },
20
+ data () {
21
+ return {
22
+ selectedOption: null,
23
+ options: [
24
+ { value: 'option1', label: '选项 1' },
25
+ { value: 'option2', label: '选项 2' },
26
+ { value: 'option3', label: '选项 3' },
27
+ ],
28
+ }
29
+ },
30
+ }
31
+ </script>
32
+
33
+ <style scoped>
34
+ /* 添加样式 */
35
+ </style>
@@ -4,7 +4,7 @@
4
4
  <XReport
5
5
  ref="main"
6
6
  :use-oss-for-img="false"
7
- config-name="medicalRecordCover"
7
+ :config-name="configName"
8
8
  server-name="af-his"
9
9
  :show-img-in-cell="true"
10
10
  :display-only="true"
@@ -31,6 +31,8 @@ export default {
31
31
  },
32
32
  data () {
33
33
  return {
34
+ configName: 'medicalRecordCover'
35
+ // configName: 'physicianOrderEntryCover'
34
36
  }
35
37
  },
36
38
  methods: {
@@ -33,7 +33,7 @@
33
33
  </template>
34
34
  <template v-else-if="cell.type === 'slot'">
35
35
  <template
36
- v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab', 'x-form-group', 'x-report', 'x-buttons', 'x-conversation'].includes(cell.slotType)">
36
+ v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab', 'x-form-group', 'x-report', 'x-buttons', 'x-label-select', 'x-conversation'].includes(cell.slotType)">
37
37
  <component
38
38
  :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
39
39
  :key="cellIndex"
@@ -435,6 +435,7 @@ export default {
435
435
  XTab: () => import('@vue2-client/base-client/components/common/XTab/XTab.vue'),
436
436
  XReport: () => import('@vue2-client/base-client/components/common/XReport/XReport.vue'),
437
437
  XButtons: () => import('@vue2-client/base-client/components/common/XButtons/XButtons.vue'),
438
+ XLabelSelect: () => import('@vue2-client/base-client/components/common/XLabelSelect/XLabelSelect.vue'),
438
439
  XConversation: () => import('@vue2-client/base-client/components/common/XConversation/XConversation.vue'),
439
440
  },
440
441
  props: {
@@ -561,6 +562,7 @@ export default {
561
562
  console.info('给表单赋值', res)
562
563
  this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
563
564
  serviceName: cell.serviceName,
565
+ configName: cell.slotConfig,
564
566
  formItems: res.formJson,
565
567
  showSubmitBtn: !this.isInAModal,
566
568
  businessType: param.businessType || '新增',
@@ -597,6 +599,14 @@ export default {
597
599
  serviceName: cell.serviceName,
598
600
  })
599
601
  }, this.env === 'dev')
602
+ } else if (cell.slotType === 'x-label-select') {
603
+ // 按钮组需要主动调用初始化方法
604
+ getConfigByName(cell.slotConfig, cell.serviceName, (res) => {
605
+ this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
606
+ ...res,
607
+ serviceName: cell.serviceName,
608
+ })
609
+ }, this.env === 'dev')
600
610
  }
601
611
  }
602
612
  if (cell.slotType === 'x-report') {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div v-show="tableColumns.length > 0">
3
3
  <a-row :gutter="48">
4
- <a-col v-show="showLeftOperaBtn">
4
+ <a-col v-show="showLeftOperaBtn" :span="8">
5
5
  <span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
6
6
  <a-space>
7
7
  <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
@@ -72,15 +72,28 @@
72
72
  <a-icon type="dashed" :style="iconStyle"/>
73
73
  {{ button.buttonName }}
74
74
  </a-button>
75
-
76
75
  <a-button v-if="allowedCardMode && !simpleMode" @click="changeViewMode" :type="isTableMode ? '' : 'primary'">
77
76
  看板模式
78
77
  </a-button>
79
78
  <slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
80
79
  </a-space>
80
+
81
81
  </span>
82
82
  </a-col>
83
- <a-col v-show="showRightTools && !simpleMode">
83
+ <a-col :span="8">
84
+ <!-- 头部附加栅格 -->
85
+ <x-report
86
+ v-if="attachGrid"
87
+ :env="env"
88
+ :use-oss-for-img="false"
89
+ :config-name="attachGrid"
90
+ :show-img-in-cell="true"
91
+ :display-only="true"
92
+ :edit-mode="false"
93
+ :show-save-button="false"
94
+ :dont-format="true"/>
95
+ </a-col>
96
+ <a-col v-show="showRightTools && !simpleMode" :span="8">
84
97
  <span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
85
98
  <a-button-group>
86
99
  <slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
@@ -102,7 +115,7 @@
102
115
  </a-col>
103
116
  </a-row>
104
117
  <!-- 如果当前是表格模式 -->
105
- <template v-if="isTableMode && !simpleMode">
118
+ <template v-if="isTableMode">
106
119
  <s-table
107
120
  ref="table"
108
121
  :id="uniqueId"
@@ -114,6 +127,9 @@
114
127
  :rowSelection="rowSelection"
115
128
  :scroll="{ x: scrollXWidth, y: scrollYHeight }"
116
129
  :showPagination="showPagination"
130
+ :hidePagination="simpleMode"
131
+ :showSelected="!simpleMode"
132
+ :pageSize="simpleMode ? 1000 : undefined"
117
133
  :setScrollYHeight="setScrollYHeight"
118
134
  size="default"
119
135
  >
@@ -129,6 +145,7 @@
129
145
  :service-name="serviceName"
130
146
  mode="新增/修改"
131
147
  :env="env"
148
+ @rowChoose="(row, attr, callback) => rowChoose(row, attr, callback, record)"
132
149
  :showLabel="false"
133
150
  :key="'editRow-' + c_index"
134
151
  />
@@ -211,7 +228,8 @@
211
228
  @cardEmit="handleCardEmit"
212
229
  :tableColumns="tableColumns"
213
230
  :card-config="cardModeConfig"
214
- :show-pagination="true"
231
+ :show-pagination="!simpleMode"
232
+ :prePageSize="simpleMode ? 1000 : undefined"
215
233
  :serviceName="serviceName"
216
234
  :card-data="loadData"
217
235
  :env="env"
@@ -267,7 +285,7 @@
267
285
  </template>
268
286
  <script>
269
287
  import { Ellipsis, STable } from '@vue2-client/components'
270
- import { formatDate, getChangedData } from '@vue2-client/utils/util'
288
+ import util, { formatDate, getChangedData, setDataByRealKey } from '@vue2-client/utils/util'
271
289
  import XBadge from '@vue2-client/base-client/components/common/XBadge'
272
290
  import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
273
291
  import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
@@ -279,6 +297,7 @@ import {
279
297
  queryWithResource,
280
298
  remove,
281
299
  asyncRunTask,
300
+ getConfigByNameAsync,
282
301
  editRowSave,
283
302
  runLogic
284
303
  } from '@vue2-client/services/api/common'
@@ -289,6 +308,7 @@ import { executeStrFunction } from '@vue2-client/utils/runEvalFunction'
289
308
  import debounce from 'lodash.debounce'
290
309
  import XDataCard from '@vue2-client/base-client/components/common/XDataCard/XDataCard.vue'
291
310
  import { getRealKeyData } from '@vue2-client/utils/formatter'
311
+ import ReportTableHome from '../../../../pages/report/ReportTableHome.vue'
292
312
 
293
313
  export default {
294
314
  name: 'XTable',
@@ -299,8 +319,11 @@ export default {
299
319
  Ellipsis,
300
320
  XBadge,
301
321
  XImportExcel,
302
- XFormItem
322
+ XFormItem,
323
+ XReport: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue'),
324
+ ReportTableHome
303
325
  },
326
+ inject: ['getSelf'],
304
327
  data () {
305
328
  return {
306
329
  uniqueId: `x-table-${this._uid}`, // 使用 _uid 生成唯一 ID
@@ -318,6 +341,8 @@ export default {
318
341
  rowSelectMode: false,
319
342
  // 行选择模式-允许选中行数量,0:任意数量行,大于0:指定值数量的行
320
343
  allowSelectRowNum: 0,
344
+ // 头部附件的栅格配置名
345
+ attachGrid: '',
321
346
  // 是否展示右侧工具栏
322
347
  showRightTools: true,
323
348
  // 是否展示左边按钮栏
@@ -540,6 +565,29 @@ export default {
540
565
  this.refresh(true)
541
566
  this.$emit('importExcelOk')
542
567
  },
568
+ /**
569
+ * 行选择事件
570
+ * @param row 选中行集合
571
+ * @param attr 表单项属性
572
+ */
573
+ async rowChoose (row, attr, callback, record) {
574
+ // 如果配置了自定义函数
575
+ if (attr.dataChangeFunc) {
576
+ await executeStrFunction(attr.dataChangeFunc, [record, this.setForm, {
577
+ ...attr,
578
+ selectRows: row
579
+ }, util, this.getSelf(), this.mode, runLogic, getConfigByNameAsync])
580
+ } else {
581
+ // 默认填充选中行数据到当前表单
582
+ setDataByRealKey(record, row[0])
583
+ }
584
+ if (callback) {
585
+ callback()
586
+ }
587
+ },
588
+ setForm (record, obj) {
589
+ Object.assign(record, obj)
590
+ },
543
591
  handleResize () {
544
592
  debounce(() => {
545
593
  this.setScrollYHeight({})
@@ -573,6 +621,7 @@ export default {
573
621
  // 查询参数对象, 用于没有对应查询配置文件名时
574
622
  queryParams,
575
623
  tableColumns,
624
+ attachGrid,
576
625
  buttonState,
577
626
  buttonPermissions,
578
627
  editButtonStateData = [],
@@ -625,6 +674,7 @@ export default {
625
674
  if (this.tableColumns.length === 0) {
626
675
  return
627
676
  }
677
+ this.attachGrid = attachGrid
628
678
  this.viewMode = viewMode
629
679
  this.localEditMode = localEditMode
630
680
  this.rowSelectMode = rowSelectMode
@@ -677,6 +727,10 @@ export default {
677
727
  // 加载筛选列完成
678
728
  this.columnSelectLoaded = true
679
729
  this.setQueryForm(form || {})
730
+ // 简易模式,并且是看板模式,默认直接进入看板模式
731
+ if (this.allowedCardMode && this.simpleMode) {
732
+ this.isTableMode = false
733
+ }
680
734
  },
681
735
  // 操作面板按钮渲染
682
736
  buttonRendering (button) {
@@ -73,6 +73,16 @@ export default {
73
73
  type: String | Boolean,
74
74
  default: 'auto'
75
75
  },
76
+ // 是否隐藏翻页,如果隐藏,彻底不显示翻译
77
+ hidePagination: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ // 是否显示表头已选择部分
82
+ showSelected: {
83
+ type: Boolean,
84
+ default: true
85
+ },
76
86
  /**
77
87
  * enable page URI mode
78
88
  *
@@ -371,9 +381,9 @@ export default {
371
381
 
372
382
  return (
373
383
  <div class="table-wrapper">
374
- {showAlert ? this.renderAlert() : null}
384
+ {showAlert && this.showSelected ? this.renderAlert() : null}
375
385
  {table}
376
- {pagination}
386
+ {!this.hidePagination ? pagination : null}
377
387
  </div>
378
388
  )
379
389
  }
@@ -1,124 +1,124 @@
1
- export default {
2
- name: 'ReportTable',
3
- functional: true,
4
- render (h, content) {
5
- if (!content.props.tableData) {
6
- console.log('没有报表数据')
7
- return
8
- }
9
- console.log('content=>', content)
10
- const html = reportCompute(h, content.props.tableData)
11
- console.log('html=>', html)
12
- // 报表整体高度和宽度
13
- const reportClass = `h-${html.h} w-${html.w}`
14
- return (
15
- <div id='ReportTableHome'>
16
- <div id='reportTable' class={reportClass}>
17
- {html.el}
18
- </div>
19
- </div>
20
- )
21
- }
22
- }
23
- /**
24
- * class类生成
25
- * @param w 宽
26
- * @param h 高
27
- * @param l left
28
- * @param t top
29
- * @returns {string}
30
- */
31
- function generClass ({ w = 1, h = 1, l, t }) {
32
- return `w-${w} h-${h} l-${l} t-${t}`
33
- }
34
- /**
35
- * 判断是否是个Number数据
36
- * @param value
37
- * @returns {boolean}
38
- */
39
- function typeNumber (value) {
40
- return Object.prototype.toString.call(value) === '[object Number]'
41
- }
42
- /**
43
- * 判断是否是个object数据
44
- * @param value
45
- * @returns {boolean}
46
- */
47
- function typeObject (value) {
48
- return Object.prototype.toString.call(value) === '[object Object]'
49
- }
50
- /**
51
- * 判断是否是个Array数据
52
- * @param value
53
- * @returns {boolean}
54
- */
55
- function typeArray (value) {
56
- return Object.prototype.toString.call(value) === '[object Array]'
57
- }
58
- /**
59
- * 一行数据转换html函数
60
- * @param h vue的h
61
- * @param row 一行json数据
62
- * @param left 起始left距离
63
- * @param top 起始top距离
64
- * @returns {{el: Array, h: number}}
65
- */
66
- function rowCompute (h, row, left, top) {
67
- if (typeObject(row)) {
68
- const el = []
69
- const keys = Object.keys(row).filter((res) => res !== 'span')
70
- let heigth = 0
71
- for (const key of keys.values()) {
72
- const value = row[key]['value'] ? row[key]['value'] : row[key]
73
- const style = { l: left, t: top + heigth }
74
- style.w = row[key]['span'] ? row[key]['span'] : 1
75
- const nextL = left + style.w
76
- const nextT = top + heigth
77
- const divObject = rowCompute(h, value, nextL, nextT)
78
- el.push(divObject.el)
79
- style.h = divObject.h ? divObject.h : 1
80
- heigth += style.h
81
- const attrs = { class: generClass(style) + ' title' }
82
- const div = <div {...attrs}>{key === 'value' ? value : key}</div>
83
- el.push(div)
84
- }
85
- return { h: heigth, el: el }
86
- } else if (typeArray(row)) {
87
- const el = []
88
- for (const [i, value] of row.entries()) {
89
- const style = { l: (left + i), t: top, w: 1, h: 1 }
90
- const extraClass = typeNumber(value) ? 'bold' : 'title'
91
- const attrs = { class: generClass(style) + ` ${extraClass}` }
92
- const div = <div {...attrs}>{value}</div>
93
- el.push(div)
94
- }
95
- return { h: 1, el: el }
96
- }
97
- }
98
- /**
99
- * 完整报表数据转换html函数
100
- * @param h vue的h
101
- * @param jsonArr json数组
102
- * @returns {{el: Array, h: number}}
103
- */
104
- function reportCompute (h, jsonArr) {
105
- const html = []
106
- let heigth = 0
107
- let width = 0
108
- for (const [index, row] of jsonArr.entries()) {
109
- const rowHtml = rowCompute(h, row, 0, index)
110
- // 取第一行的宽度作为整个报表的宽度
111
- if (index === 0) {
112
- const reg = /w-\d\s/
113
- for (const vNode of rowHtml.el) {
114
- if (!vNode.data || !vNode.data.class) continue
115
- const c = vNode.data.class
116
- const w = c.match(reg)[0].split('-')[1]
117
- width += (w - 0)
118
- }
119
- }
120
- heigth += rowHtml.h
121
- html.push(rowHtml.el)
122
- }
123
- return { el: html, h: heigth, w: width }
124
- }
1
+ export default {
2
+ name: 'ReportTable',
3
+ functional: true,
4
+ render (h, content) {
5
+ if (!content.props.tableData) {
6
+ console.log('没有报表数据')
7
+ return
8
+ }
9
+ console.log('content=>', content)
10
+ const html = reportCompute(h, content.props.tableData)
11
+ console.log('html=>', html)
12
+ // 报表整体高度和宽度
13
+ const reportClass = `h-${html.h} w-${html.w}`
14
+ return (
15
+ <div id='ReportTableHome'>
16
+ <div id='reportTable' class={reportClass}>
17
+ {html.el}
18
+ </div>
19
+ </div>
20
+ )
21
+ }
22
+ }
23
+ /**
24
+ * class类生成
25
+ * @param w 宽
26
+ * @param h 高
27
+ * @param l left
28
+ * @param t top
29
+ * @returns {string}
30
+ */
31
+ function generClass ({ w = 1, h = 1, l, t }) {
32
+ return `w-${w} h-${h} l-${l} t-${t}`
33
+ }
34
+ /**
35
+ * 判断是否是个Number数据
36
+ * @param value
37
+ * @returns {boolean}
38
+ */
39
+ function typeNumber (value) {
40
+ return Object.prototype.toString.call(value) === '[object Number]'
41
+ }
42
+ /**
43
+ * 判断是否是个object数据
44
+ * @param value
45
+ * @returns {boolean}
46
+ */
47
+ function typeObject (value) {
48
+ return Object.prototype.toString.call(value) === '[object Object]'
49
+ }
50
+ /**
51
+ * 判断是否是个Array数据
52
+ * @param value
53
+ * @returns {boolean}
54
+ */
55
+ function typeArray (value) {
56
+ return Object.prototype.toString.call(value) === '[object Array]'
57
+ }
58
+ /**
59
+ * 一行数据转换html函数
60
+ * @param h vue的h
61
+ * @param row 一行json数据
62
+ * @param left 起始left距离
63
+ * @param top 起始top距离
64
+ * @returns {{el: Array, h: number}}
65
+ */
66
+ function rowCompute (h, row, left, top) {
67
+ if (typeObject(row)) {
68
+ const el = []
69
+ const keys = Object.keys(row).filter((res) => res !== 'span')
70
+ let heigth = 0
71
+ for (const key of keys.values()) {
72
+ const value = row[key].value ? row[key].value : row[key]
73
+ const style = { l: left, t: top + heigth }
74
+ style.w = row[key].span ? row[key].span : 1
75
+ const nextL = left + style.w
76
+ const nextT = top + heigth
77
+ const divObject = rowCompute(h, value, nextL, nextT)
78
+ el.push(divObject.el)
79
+ style.h = divObject.h ? divObject.h : 1
80
+ heigth += style.h
81
+ const attrs = { class: generClass(style) + ' title' }
82
+ const div = <div {...attrs}>{key === 'value' ? value : key}</div>
83
+ el.push(div)
84
+ }
85
+ return { h: heigth, el: el }
86
+ } else if (typeArray(row)) {
87
+ const el = []
88
+ for (const [i, value] of row.entries()) {
89
+ const style = { l: (left + i), t: top, w: 1, h: 1 }
90
+ const extraClass = typeNumber(value) ? 'bold' : 'title'
91
+ const attrs = { class: generClass(style) + ` ${extraClass}` }
92
+ const div = <div {...attrs}>{value}</div>
93
+ el.push(div)
94
+ }
95
+ return { h: 1, el: el }
96
+ }
97
+ }
98
+ /**
99
+ * 完整报表数据转换html函数
100
+ * @param h vue的h
101
+ * @param jsonArr json数组
102
+ * @returns {{el: Array, h: number}}
103
+ */
104
+ function reportCompute (h, jsonArr) {
105
+ const html = []
106
+ let heigth = 0
107
+ let width = 0
108
+ for (const [index, row] of jsonArr.entries()) {
109
+ const rowHtml = rowCompute(h, row, 0, index)
110
+ // 取第一行的宽度作为整个报表的宽度
111
+ if (index === 0) {
112
+ const reg = /w-\d\s/
113
+ for (const vNode of rowHtml.el) {
114
+ if (!vNode.data || !vNode.data.class) continue
115
+ const c = vNode.data.class
116
+ const w = c.match(reg)[0].split('-')[1]
117
+ width += (w - 0)
118
+ }
119
+ }
120
+ heigth += rowHtml.h
121
+ html.push(rowHtml.el)
122
+ }
123
+ return { el: html, h: heigth, w: width }
124
+ }
@@ -87,12 +87,13 @@ routerResource.example = {
87
87
  // component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
88
88
  // component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
89
89
  // component: () => import('@vue2-client/base-client/components/common/XReport/XReportDemo.vue'),
90
- component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
90
+ // component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
91
91
  // component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
92
- // component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
92
+ component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
93
93
  // component: () => import('@vue2-client/pages/WorkflowDetail/WorkFlowDemo.vue'),
94
94
  // component: () => import('@vue2-client/base-client/components/common/XConversation/XConversationDemo.vue'),
95
95
  // component: () => import('@vue2-client/base-client/components/common/XButtons/XButtonDemo.vue'),
96
+ // component: () => import('@vue2-client/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue'),
96
97
  meta: {
97
98
  // 菜单中不显示
98
99
  invisible: true,