vue2-client 1.9.67 → 1.9.69

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.
@@ -31,6 +31,7 @@ this.openDialog('xxx', 5, {}, {}, {})
31
31
  - refreshTable 重新查询
32
32
  - clearRowKeys 清除选中的行
33
33
  - getTableData() 获取全部数据
34
+ - Object.assign(this.fixedQueryForm, data) 给查询条件传值
34
35
  - 事件相关
35
36
  - afterSubmit( type(新增/修改/擦和讯), id: (所操作的主键id), form: (请求的表单内容)) 提交后触发
36
37
  - afterQuery( res (查询后数据), querparams (查询参数)) 查询后触发
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.9.67",
3
+ "version": "1.9.69",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -8,7 +8,7 @@
8
8
  <a-badge v-else color="#D9D9D9" :text="!isExternalText ? dictionary.text: null"/>
9
9
  <span v-if="isExternalText">{{ dictionary.text }}</span>
10
10
  </div>
11
- <div v-else-if="dictionary">
11
+ <div v-else-if="dictionary" :class="{data_card: dataCard}">
12
12
  <!-- 徽标为none时 -->
13
13
  {{ dictionary.text }}
14
14
  </div>
@@ -46,6 +46,11 @@ export default {
46
46
  isExternalText: {
47
47
  type: Boolean,
48
48
  required: false
49
+ },
50
+ // 是否在看板模式下显示
51
+ dataCard: {
52
+ type: Boolean,
53
+ default: false
49
54
  }
50
55
  },
51
56
  computed: {},
@@ -83,4 +88,7 @@ export default {
83
88
  </script>
84
89
 
85
90
  <style lang="less" scoped>
91
+ .data_card {
92
+ display: inline;
93
+ }
86
94
  </style>
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <div>
3
- <x-buttons></x-buttons>
3
+ <x-buttons ref="xButtons"></x-buttons>
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script>
8
8
  import XButtons from './XButtons.vue'
9
+ import { getConfigByName } from '@/services/api/common'
9
10
 
10
11
  export default {
11
12
  name: 'XButtonDemo',
@@ -13,9 +14,14 @@
13
14
  XButtons
14
15
  },
15
16
  data () {
16
- return {
17
- configName: 'drugInventAuditTab'
18
- }
17
+ return {}
18
+ },
19
+ mounted () {
20
+ getConfigByName('testButtonGroup', 'af-his', res => {
21
+ this.$refs.xButtons.init({
22
+ renderConfig: res
23
+ })
24
+ }, true)
19
25
  },
20
26
  methods: {},
21
27
  }
@@ -1,145 +1,66 @@
1
1
  <template>
2
2
  <div class="x-buttons">
3
- <a-button-group>
3
+ <a-button-group v-if="loading">
4
4
  <a-button
5
- v-for="(button, index) in config"
6
- :key="index"
5
+ v-for="(button) in renderConfig"
6
+ :key="button.key"
7
+ :ref="'buttonGroup-' + button.key"
7
8
  :type="button.type || 'default'"
8
- :danger="button.danger"
9
9
  :disabled="button.disabled"
10
- :ghost="button.ghost"
11
- :href="button.href"
12
- :html-type="button.htmlType"
13
10
  :icon="button.icon"
14
11
  :loading="button.loading"
15
- :shape="button.shape"
16
- :size="button.size"
17
- :target="button.target"
18
- @click="handleButtonClick(index)"
12
+ @click="handleButtonClick(button)"
19
13
  >
20
14
  {{ button.label }}
21
15
  </a-button>
22
16
  </a-button-group>
17
+ <a-spin :spinning="!loading" />
23
18
  </div>
24
19
  </template>
25
20
 
26
21
  <script>
27
- import { Button, Icon as AIcon } from 'ant-design-vue'
28
- import { getConfigByName } from '@vue2-client/services/api/common'
29
-
30
22
  export default {
31
23
  name: 'XButtons',
32
- components: {
33
- 'a-button': Button,
34
- 'a-icon': AIcon,
35
- },
36
- props: {
37
- configName: {
38
- type: String,
39
- default: undefined
40
- }
41
- },
24
+ components: {},
25
+ props: {},
42
26
  data () {
43
27
  return {
44
- // 配置
45
- config: [
46
- {
47
- label: 'Primary Button',
48
- type: 'primary',
49
- icon: 'rocket',
50
- disabled: false,
51
- loading: false,
52
- danger: false,
53
- ghost: false,
54
- href: '',
55
- htmlType: 'button',
56
- shape: 'default',
57
- size: 'middle',
58
- target: '',
59
- onClick: () => {}
60
- },
61
- {
62
- label: 'Danger Button',
63
- type: 'default',
64
- icon: 'fire',
65
- disabled: false,
66
- loading: false,
67
- danger: true,
68
- ghost: false,
69
- href: '',
70
- htmlType: 'button',
71
- shape: 'default',
72
- size: 'middle',
73
- target: '',
74
- onClick: () => {}
75
- },
76
- {
77
- label: 'Ghost Button',
78
- type: 'ghost',
79
- icon: 'ghost',
80
- disabled: false,
81
- loading: false,
82
- danger: false,
83
- ghost: true,
84
- href: '',
85
- htmlType: 'button',
86
- shape: 'default',
87
- size: 'middle',
88
- target: '',
89
- onClick: () => {}
90
- },
91
- {
92
- label: 'Dashed Button',
93
- type: 'dashed',
94
- icon: 'ellipsis',
95
- disabled: false,
96
- loading: false,
97
- danger: false,
98
- ghost: false,
99
- href: '',
100
- htmlType: 'button',
101
- shape: 'default',
102
- size: 'middle',
103
- target: '',
104
- onClick: () => {}
105
- },
106
- {
107
- label: 'Link Button',
108
- type: 'link',
109
- icon: 'link',
110
- disabled: false,
111
- loading: false,
112
- danger: false,
113
- ghost: false,
114
- href: '#',
115
- htmlType: 'button',
116
- shape: 'default',
117
- size: 'middle',
118
- target: '_blank',
119
- onClick: () => {}
120
- }
121
- ],
28
+ // 组件加载状态
29
+ loading: false,
30
+ // 配置内容
31
+ renderConfig: undefined
122
32
  }
123
33
  },
124
34
  methods: {
125
- handleButtonClick (index) {
126
- // 在这里处理点击事件,或者 emit 一个事件到父组件
127
- this.$emit('button-click', this.config[index])
35
+ /**
36
+ * 初始化按钮组参数
37
+ */
38
+ init (params) {
39
+ const {
40
+ // 配置内容
41
+ value
42
+ } = params
43
+ this.renderConfig = value
44
+ this.loading = true
128
45
  },
129
- },
130
- watch: {
131
- configName: {
132
- deep: true,
133
- immediate: true,
134
- handler (val) {
135
- console.log('>>>>点击按钮进入')
136
- if (val) {
137
- getConfigByName(this.configName, undefined, res => {
138
- this.config = res.data || this.config
139
- })
140
- }
46
+ handleButtonClick (item) {
47
+ item.loading = true
48
+ const callback = () => {
49
+ item.loading = false
50
+ }
51
+ if (item.clickEventName && this.$listeners[item.clickEventName]) {
52
+ // 交由父级处理
53
+ this.$emit(item.clickEventName, item, callback)
54
+ } else {
55
+ this.defaultAction(item.clickEventName, item, callback)
141
56
  }
57
+ },
58
+ defaultAction (clickEventName, item, callback) {
59
+ setTimeout(() => {
60
+ this.$message.warn(`已触发按钮 [${item.key}],注册事件名 [${clickEventName}],未实现事件函数`)
61
+ callback()
62
+ }, 200)
142
63
  }
143
- },
64
+ }
144
65
  }
145
66
  </script>
@@ -0,0 +1,61 @@
1
+ # XButtons
2
+
3
+ 通用按钮组控件
4
+
5
+
6
+ ## 何时使用
7
+
8
+ 当需要一个通用按钮组时
9
+
10
+
11
+ 引用方式:
12
+
13
+ ```javascript
14
+ import XButtons from '@vue2-client/base-client/components/XButtons/XButtons'
15
+
16
+ export default {
17
+ components: {
18
+ XButtons
19
+ }
20
+ }
21
+ ```
22
+
23
+
24
+
25
+ ## 代码演示
26
+
27
+ ```html
28
+ <template>
29
+ <div>
30
+ <x-buttons ref="xButtons"></x-buttons>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ import XButtons from './XButtons.vue'
36
+ import { getConfigByName } from '@/services/api/common'
37
+
38
+ export default {
39
+ name: 'XButtonDemo',
40
+ components: {
41
+ XButtons
42
+ },
43
+ data () {
44
+ return {}
45
+ },
46
+ mounted () {
47
+ getConfigByName('testButtonGroup', 'af-his', res => {
48
+ this.$refs.xButtons.init({
49
+ renderConfig: res
50
+ })
51
+ }, true)
52
+ },
53
+ methods: {},
54
+ }
55
+ </script>
56
+ ```
57
+
58
+ ## API
59
+
60
+ | 参数 | 说明 | 类型 | 默认值 |
61
+ |-----------|--------------------------|---------|------|
@@ -20,6 +20,22 @@
20
20
  </div>
21
21
  <div class="progress-num">{{ card[item.key] * 100 }}%</div>
22
22
  </template>
23
+ <template v-else-if="item.type === 'custom' && tableColumns">
24
+ <!-- 根据 tableColumns 显示自定义内容 -->
25
+ <span v-for="column in tableColumns" v-if="column.dataIndex === item.key" :key="column.dataIndex">
26
+ <template v-if="column.slotType === 'badge'">
27
+ <x-badge
28
+ :service-name="serviceName"
29
+ :env="env"
30
+ :dataCard="true"
31
+ :badge-key="column.slotKeyMap"
32
+ :value="card[item.key]"/>
33
+ </template>
34
+ <template v-else>
35
+ <slot :name="column.slots.customRender">{{ card[item.key] }}</slot>
36
+ </template>
37
+ </span>
38
+ </template>
23
39
  <template v-else>
24
40
  <span class="body-item-value">{{ card[item.key] }}</span>
25
41
  </template>
@@ -92,9 +108,13 @@
92
108
  </template>
93
109
 
94
110
  <script>
111
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
95
112
 
96
113
  export default {
97
114
  name: 'XDataCard',
115
+ components: {
116
+ XBadge,
117
+ },
98
118
  props: {
99
119
  // 卡片数据更新方法
100
120
  cardData: {
@@ -123,6 +143,18 @@ export default {
123
143
  tableColumns: {
124
144
  type: Array,
125
145
  default: undefined
146
+ },
147
+ // 服务名称
148
+ serviceName: undefined,
149
+ // 当前环境
150
+ env: {
151
+ type: String,
152
+ default: 'prod'
153
+ },
154
+ // 初始是否加载数据
155
+ createdQuery: {
156
+ type: Boolean,
157
+ default: true
126
158
  }
127
159
  },
128
160
  data () {
@@ -194,7 +226,9 @@ export default {
194
226
 
195
227
  // 数据初始化
196
228
  if (this.cardData) {
197
- this.loadData()
229
+ if (this.createdQuery) {
230
+ this.loadData()
231
+ }
198
232
  } else {
199
233
  this.data = {
200
234
  one: '无数据',
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div :style="{marginBottom: !visible ? '12px':''}">
3
- <div v-show="visible && realJsonData.length > 0" class="table-page-search-wrapper">
3
+ <div v-if="visible && realJsonData.length > 0" class="table-page-search-wrapper">
4
4
  <a-form-model
5
5
  v-if="loaded"
6
6
  ref="form"
@@ -88,6 +88,7 @@
88
88
  <script>
89
89
  // 转PDF用
90
90
  import HtmlToPdf from '@vue2-client/utils/htmlToPDF'
91
+ import { mapState } from 'vuex'
91
92
  import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
92
93
  import XReportDesign from './XReportDesign.vue'
93
94
  import { printElement } from './print'
@@ -262,7 +263,8 @@ export default {
262
263
  registerComponent: this.registerComponent,
263
264
  getComponentByName: this.getComponentByName,
264
265
  getParentComponentByName: this.getComponentByName,
265
- getConfigByName: getConfigByName
266
+ getConfigByName: getConfigByName,
267
+ currUser: this.currUser
266
268
  }
267
269
  },
268
270
  methods: {
@@ -925,6 +927,9 @@ export default {
925
927
  }, this.env === 'dev')
926
928
  }
927
929
  },
930
+ computed: {
931
+ ...mapState('account', { currUser: 'user' })
932
+ },
928
933
  mounted () {
929
934
  // 如果外界传来了registerMap,我们将本VM对象注册到map中
930
935
  if (this.registerMap !== undefined) {
@@ -15,7 +15,7 @@
15
15
  <!-- 插槽渲染 -->
16
16
  <template v-if="cell.type === 'slot'">
17
17
  <template
18
- v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab', 'x-form-group', 'x-report'].includes(cell.slotType)">
18
+ v-if="['x-form-table','x-add-native-form','x-tree-pro', 'x-his-editor', 'x-tab', 'x-form-group', 'x-report', 'x-buttons'].includes(cell.slotType)">
19
19
  <component
20
20
  :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
21
21
  :key="cellIndex"
@@ -415,7 +415,8 @@ export default {
415
415
  XTreePro: () => import('@vue2-client/base-client/components/common/XTree/XTreePro.vue'),
416
416
  XHisEditor: () => import('@vue2-client/base-client/components/his/XHisEditor/XHisEditor.vue'),
417
417
  XTab: () => import('@vue2-client/base-client/components/common/XTab/XTab.vue'),
418
- XReport: () => import('@vue2-client/base-client/components/common/XReport/XReport.vue')
418
+ XReport: () => import('@vue2-client/base-client/components/common/XReport/XReport.vue'),
419
+ XButtons: () => import('@vue2-client/base-client/components/common/XButtons/XButtons.vue')
419
420
  },
420
421
  props: {
421
422
  // 每一行的配置
@@ -567,6 +568,14 @@ export default {
567
568
  showLeftTab: true,
568
569
  })
569
570
  }, this.env === 'dev')
571
+ } else if (cell.slotType === 'x-buttons') {
572
+ // 按钮组需要主动调用初始化方法
573
+ getConfigByName(cell.slotConfig, cell.serviceName, (res) => {
574
+ this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
575
+ ...res,
576
+ serviceName: cell.serviceName,
577
+ })
578
+ }, this.env === 'dev')
570
579
  }
571
580
  }
572
581
  if (cell.slotType === 'x-report') {
@@ -212,7 +212,10 @@
212
212
  :tableColumns="tableColumns"
213
213
  :card-config="cardModeConfig"
214
214
  :show-pagination="true"
215
+ :serviceName="serviceName"
215
216
  :card-data="loadData"
217
+ :env="env"
218
+ :createdQuery="createdQuery"
216
219
  :simple-mode="simpleMode"/>
217
220
  </template>
218
221
  <!-- 上传文件 -->
@@ -673,7 +676,7 @@ export default {
673
676
  this.scrollXWidth = totalWidth
674
677
  // 加载筛选列完成
675
678
  this.columnSelectLoaded = true
676
- this.setQueryForm(form || {}, createdQuery)
679
+ this.setQueryForm(form || {})
677
680
  },
678
681
  // 操作面板按钮渲染
679
682
  buttonRendering (button) {
@@ -763,9 +766,9 @@ export default {
763
766
  /**
764
767
  * 为表格附加查询条件
765
768
  */
766
- setQueryForm (form = {}, createdQuery = true) {
769
+ setQueryForm (form = {}) {
767
770
  this.form = form
768
- if (createdQuery) {
771
+ if (this.createdQuery) {
769
772
  this.refresh(true)
770
773
  }
771
774
  },
@@ -89,6 +89,7 @@ routerResource.example = {
89
89
  // component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
90
90
  // component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
91
91
  // component: () => import('@vue2-client/pages/WorkflowDetail/WorkFlowDemo.vue'),
92
+ // component: () => import('@vue2-client/base-client/components/common/XButtons/XButtonDemo.vue'),
92
93
  meta: {
93
94
  // 菜单中不显示
94
95
  invisible: true,