vue2-client 1.12.97 → 1.12.99

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": "vue2-client",
3
- "version": "1.12.97",
3
+ "version": "1.12.99",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -63,6 +63,7 @@
63
63
  :countVisible="false"
64
64
  :env="env"
65
65
  @listClick="listClick"
66
+ @click="click"
66
67
  />
67
68
  </template>
68
69
  </a-collapse-panel>
@@ -134,6 +135,9 @@ export default {
134
135
  listClick (data) {
135
136
  this.$emit('listClick', data)
136
137
  },
138
+ click (data) {
139
+ this.$emit('click', data)
140
+ },
137
141
  getConfigByName (componentName) {
138
142
  const refKey = `dynamicComponent_${componentName}`
139
143
  return this.$refs[refKey]
@@ -25,7 +25,7 @@
25
25
  </template>
26
26
  <template v-else-if="cell.type === 'slot'">
27
27
  <template
28
- 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', 'x-check-list', 'x-cardSet', 'x-collapse','x-h-descriptions', 'x-sidebar', 'x-list','x-input','x-time-line', 'x-radio','x-calendar', 'x-time-select'].includes(cell.slotType)">
28
+ 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', 'x-check-list', 'x-cardSet', 'x-collapse','x-h-descriptions', 'x-sidebar', 'x-list','x-input','x-time-line', 'x-radio','x-calendar', 'x-time-select' ,'x-checkbox'].includes(cell.slotType)">
29
29
  <component
30
30
  :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
31
31
  :key="cellIndex"
@@ -60,7 +60,7 @@
60
60
  </template>
61
61
  <template v-else-if="cell.type === 'slot'">
62
62
  <template
63
- 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', 'x-check-list', 'x-cardSet', 'x-collapse', 'x-h-descriptions', 'x-sidebar', 'x-list','x-input','x-time-line', 'x-radio','x-calendar', 'x-time-select'].includes(cell.slotType)">
63
+ 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', 'x-check-list', 'x-cardSet', 'x-collapse', 'x-h-descriptions', 'x-sidebar', 'x-list','x-input','x-time-line', 'x-radio','x-calendar', 'x-time-select','x-checkbox'].includes(cell.slotType)">
64
64
  <component
65
65
  :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
66
66
  :key="cellIndex"
@@ -114,7 +114,8 @@ export default {
114
114
  XTimeLine: () => import('@vue2-client/base-client/components/common/XTimeline/XTimeline.vue'),
115
115
  XRadio: () => import('@vue2-client/base-client/components/his/XRadio/XRadio.vue'),
116
116
  XCalendar: () => import('@vue2-client/base-client/components/common/XCalendar/XCalendar.vue'),
117
- XTimeSelect: () => import('@vue2-client/base-client/components/his/XTimeSelect/XTimeSelect.vue')
117
+ XTimeSelect: () => import('@vue2-client/base-client/components/his/XTimeSelect/XTimeSelect.vue'),
118
+ XCheckbox: () => import('@vue2-client/base-client/components/his/XCheckbox/XCheckbox.vue'),
118
119
  },
119
120
  props: {
120
121
  // 每一行的配置
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <div class="x-checkbox-container">
3
+ <a-checkbox-group v-model="innerValue" @change="onChange" class="x-checkbox-group">
4
+ <div v-for="item in data" :key="item.value" class="x-checkbox-item-container">
5
+ <a-checkbox :value="item.value" class="x-checkbox-item">
6
+ {{ item.label }}
7
+ </a-checkbox>
8
+ </div>
9
+ </a-checkbox-group>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import { getConfigByName } from '@vue2-client/services/api/common'
15
+ import { Checkbox } from 'ant-design-vue'
16
+
17
+ export default {
18
+ name: 'XCheckbox',
19
+ components: {
20
+ ACheckboxGroup: Checkbox.Group,
21
+ ACheckbox: Checkbox
22
+ },
23
+ props: {
24
+ queryParamsName: {
25
+ type: Object,
26
+ default: null
27
+ },
28
+ value: {
29
+ type: Array,
30
+ default: () => []
31
+ }
32
+ },
33
+ data () {
34
+ return {
35
+ data: [],
36
+ innerValue: [],
37
+ config: null
38
+ }
39
+ },
40
+ created () {
41
+ this.getData(this.queryParamsName)
42
+ },
43
+ watch: {
44
+ value: {
45
+ handler (val) {
46
+ this.innerValue = val
47
+ },
48
+ deep: true
49
+ }
50
+ },
51
+ emits: ['change', 'init'],
52
+ methods: {
53
+ async getData (data) {
54
+ getConfigByName(data, 'af-his', res => {
55
+ // 1. 加载选项
56
+ if (res.checkbox && Array.isArray(res.checkbox)) {
57
+ this.data = res.checkbox
58
+ // 2. 初始化默认值(优先级: 配置defaultValue > 空数组)
59
+ if (res.defaultValue !== undefined && Array.isArray(res.defaultValue)) {
60
+ this.innerValue = res.defaultValue
61
+ }
62
+ // 3. 触发初始化事件
63
+ this.$emit('init', {
64
+ config: res,
65
+ options: this.data,
66
+ value: this.innerValue
67
+ })
68
+ } else {
69
+ this.$message.error('配置错误,checkbox字段不是数组')
70
+ }
71
+ })
72
+ },
73
+ onChange (checkedValues) {
74
+ this.innerValue = checkedValues
75
+ this.$emit('change', checkedValues)
76
+ }
77
+ }
78
+ }
79
+ </script>
80
+
81
+ <style scoped>
82
+ .x-checkbox-container {
83
+ display: flex;
84
+ flex-direction: column;
85
+ }
86
+
87
+ .x-checkbox-group {
88
+ display: flex;
89
+ justify-content: space-around;
90
+ }
91
+
92
+ .x-checkbox-item-container {
93
+ flex: 1;
94
+ display: flex;
95
+ flex-direction: column;
96
+ align-items: center;
97
+ text-align: center;
98
+ padding: 0 8px;
99
+ box-sizing: border-box;
100
+ }
101
+
102
+ .x-checkbox-item {
103
+ margin-bottom: 8px;
104
+ }
105
+ </style>
@@ -0,0 +1,254 @@
1
+ # XCheckbox
2
+
3
+ 基于配置的多选框组件,支持从配置中动态加载选项和默认值。
4
+
5
+ ## 何时使用
6
+
7
+ 当需要一个通过配置动态加载的多选控件时使用,特别是选项需要从后端获取的场景。
8
+
9
+ ## 引用方式
10
+
11
+ ```javascript
12
+ import XCheckbox from '@vue2-client/base-client/components/his/XCheckbox/XCheckbox'
13
+
14
+ export default {
15
+ components: {
16
+ XCheckbox
17
+ }
18
+ }
19
+ ```
20
+
21
+ ## 代码演示
22
+
23
+ ```html
24
+ <x-checkbox
25
+ :queryParamsName="checkboxConfigName"
26
+ v-model="selectedValues"
27
+ @change="handleChange"
28
+ @init="handleInit">
29
+ </x-checkbox>
30
+ ```
31
+
32
+ ## API
33
+
34
+ | 参数 | 说明 | 类型 | 默认值 |
35
+ |------|------|------|------|
36
+ | queryParamsName | 查询配置名称 | String/Object | null |
37
+ | value (v-model) | 当前选中值数组 | Array | [] |
38
+
39
+ ### 事件
40
+
41
+ | 事件名 | 说明 | 回调参数 |
42
+ |------|------|------|
43
+ | change | 选项变化时的回调 | function(checkedValues: array) |
44
+ | init | 组件初始化完成时的回调 | function({config, options, value}) |
45
+
46
+ ## 配置说明
47
+
48
+ 组件通过 `queryParamsName` 从后端获取配置,配置格式如下:
49
+
50
+ ```json
51
+ {
52
+ "checkbox": [
53
+ {
54
+ "label": "选项A",
55
+ "value": 1
56
+ },
57
+ {
58
+ "label": "选项B",
59
+ "value": 2
60
+ },
61
+ {
62
+ "label": "选项C",
63
+ "value": 3
64
+ }
65
+ ],
66
+ "defaultValue": [1, 2]
67
+ }
68
+ ```
69
+
70
+ ## 配置示例
71
+
72
+ ### 基本配置
73
+
74
+ ```json
75
+ {
76
+ "checkbox": [
77
+ {
78
+ "label": "全部",
79
+ "value": "all"
80
+ },
81
+ {
82
+ "label": "已过期",
83
+ "value": "expired"
84
+ },
85
+ {
86
+ "label": "30天内",
87
+ "value": "30days"
88
+ },
89
+ {
90
+ "label": "90天内",
91
+ "value": "90days"
92
+ }
93
+ ],
94
+ "defaultValue": ["all"]
95
+ }
96
+ ```
97
+
98
+ ### 带禁用选项的配置
99
+
100
+ ```json
101
+ {
102
+ "checkbox": [
103
+ {
104
+ "label": "选项A",
105
+ "value": "a",
106
+ "disabled": false
107
+ },
108
+ {
109
+ "label": "选项B",
110
+ "value": "b",
111
+ "disabled": true
112
+ },
113
+ {
114
+ "label": "选项C",
115
+ "value": "c",
116
+ "disabled": false
117
+ }
118
+ ],
119
+ "defaultValue": ["a"]
120
+ }
121
+ ```
122
+
123
+ ## 使用示例
124
+
125
+ ### 1. 基础使用
126
+
127
+ ```html
128
+ <template>
129
+ <x-checkbox
130
+ :queryParamsName="'MyCheckboxConfig'"
131
+ v-model="selectedValues"
132
+ @change="onChange"
133
+ />
134
+ </template>
135
+
136
+ <script>
137
+ export default {
138
+ data() {
139
+ return {
140
+ selectedValues: []
141
+ }
142
+ },
143
+ methods: {
144
+ onChange(checkedValues) {
145
+ console.log('选中的值:', checkedValues)
146
+ }
147
+ }
148
+ }
149
+ </script>
150
+ ```
151
+
152
+ ### 2. 带初始值的使用
153
+
154
+ ```html
155
+ <template>
156
+ <x-checkbox
157
+ :queryParamsName="checkboxConfig"
158
+ v-model="selectedValues"
159
+ @change="onChange"
160
+ @init="onInit"
161
+ />
162
+ </template>
163
+
164
+ <script>
165
+ export default {
166
+ data() {
167
+ return {
168
+ selectedValues: ['a', 'b'],
169
+ checkboxConfig: {
170
+ checkbox: [
171
+ { label: '选项A', value: 'a' },
172
+ { label: '选项B', value: 'b' },
173
+ { label: '选项C', value: 'c' }
174
+ ],
175
+ defaultValue: ['a', 'b']
176
+ }
177
+ }
178
+ },
179
+ methods: {
180
+ onChange(checkedValues) {
181
+ console.log('选中的值:', checkedValues)
182
+ },
183
+ onInit({ config, options, value }) {
184
+ console.log('组件初始化完成', { config, options, value })
185
+ }
186
+ }
187
+ }
188
+ </script>
189
+ ```
190
+
191
+ ## 注意事项
192
+
193
+ 1. 如果配置中有 `defaultValue`,组件将默认选中这些值
194
+ 2. `defaultValue` 必须是数组类型
195
+ 3. 选项的 `value` 值必须是唯一的
196
+ 4. 可以通过 `v-model` 或 `value` 属性从外部控制选中值
197
+ 5. 组件会自动处理选项的禁用状态
198
+ 6. 所有的事件回调都会返回选中值的数组
199
+
200
+ ## 常见问题解答(FAQ)
201
+
202
+ ### 1. 如何设置默认选中的选项?
203
+
204
+ 可以通过配置中的 `defaultValue` 字段设置:
205
+ ```json
206
+ {
207
+ "defaultValue": ["value1", "value2"]
208
+ }
209
+ ```
210
+
211
+ 或者通过 v-model 绑定:
212
+ ```html
213
+ <x-checkbox v-model="selectedValues"></x-checkbox>
214
+ ```
215
+
216
+ ```javascript
217
+ export default {
218
+ data() {
219
+ return {
220
+ selectedValues: ["value1", "value2"]
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ ### 2. 如何禁用某些选项?
227
+
228
+ 在选项配置中添加 `disabled` 属性:
229
+ ```json
230
+ {
231
+ "checkbox": [
232
+ {
233
+ "label": "选项A",
234
+ "value": "a",
235
+ "disabled": true
236
+ }
237
+ ]
238
+ }
239
+ ```
240
+
241
+ ### 3. 如何获取选中的值?
242
+
243
+ 可以通过 `change` 事件或 `v-model` 获取:
244
+ ```html
245
+ <x-checkbox v-model="selectedValues" @change="onChange"></x-checkbox>
246
+ ```
247
+
248
+ ```javascript
249
+ methods: {
250
+ onChange(checkedValues) {
251
+ console.log('当前选中的值:', checkedValues)
252
+ }
253
+ }
254
+ ```
@@ -57,7 +57,7 @@ export default {
57
57
  this.getData(this.queryParamsName)
58
58
  },
59
59
  click (index) {
60
- this.$emit('click', this.data[index + 1])
60
+ this.$emit('click', this.data[index])
61
61
  },
62
62
  getIconStyle (item) {
63
63
  return item.picture
@@ -53,7 +53,7 @@ export default {
53
53
  methods: {
54
54
  async getfusetypes () {
55
55
  this.fusetypes = [{ label: '全部', value: '' }]
56
- const res = await post('/api/af-revenue/singleTable_OrderBy', {
56
+ const res = await post('/api/af-revenue/sql/singleTable_OrderBy', {
57
57
  data: {
58
58
  items: 'fusetype',
59
59
  tablename: 't_files',