vue2-client 1.15.3 → 1.15.5

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.15.3",
3
+ "version": "1.15.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -200,10 +200,19 @@ export default {
200
200
  return { id: null, name: 'Guest' }
201
201
  },
202
202
  },
203
- // 父组件API(通用),对象参数,可给里面任意塞父组件的方法
204
- parentAPI: {
203
+
204
+ /**
205
+ * 祖先组件注入的自定义函数对象
206
+ * 此对象包含祖先组件通过provide/inject机制注入的各种自定义函数
207
+ * 子组件可以通过this.generalFunction来访问这些函数
208
+ * 使用示例:
209
+ * - this.generalFunction.handleCustomEvent(data)
210
+ * - this.generalFunction.submitForm(formData)
211
+ * - this.generalFunction.validateData(data)
212
+ */
213
+ generalFunction: {
205
214
  default: () => {
206
- console.warn('getParentsThis is not provided.')
215
+ console.warn('generalFunction is not provided.')
207
216
  return null
208
217
  }
209
218
  }
@@ -380,6 +389,18 @@ export default {
380
389
  default: () => {
381
390
  return {}
382
391
  }
392
+ },
393
+ /**
394
+ * 额外数据对象
395
+ * 类型:Object
396
+ * 默认值:返回一个空对象
397
+ * 用途:用于传递组件需要的额外数据参数
398
+ */
399
+ extraData: {
400
+ type: Object,
401
+ default: () => {
402
+ return {}
403
+ }
383
404
  }
384
405
  },
385
406
  watch: {
@@ -26,6 +26,7 @@
26
26
  :config-name="tab.slotConfig"
27
27
  :env="env"
28
28
  v-bind="compProp"
29
+ :extra-data="extraData"
29
30
  />
30
31
  </a-tab-pane>
31
32
  </a-tabs>
@@ -14,9 +14,9 @@ export default {
14
14
  init () {
15
15
  console.log(this)
16
16
  const conditionData = {
17
- tmp_1: { tmp_id: 1 },
18
- tmp_2: { tmp_id: 2 },
19
- tmp_3: { tmp_id: 3 }
17
+ tmp_1: { tmp_id: 1, data_id: 17 },
18
+ tmp_2: { tmp_id: 2, data_id: 17 },
19
+ tmp_3: { tmp_id: 3, data_id: 17 }
20
20
  }
21
21
  this.$refs.questionnaireRef.init(conditionData)
22
22
  },
@@ -29,13 +29,14 @@
29
29
  <template v-else-if="column.type === 'radio'">
30
30
  <x-radio
31
31
  :class="['column-item']"
32
+ :value="column.value"
32
33
  :key="`row-${index}-item-${idx}`"
33
34
  :queryParamsName="column.configName"
34
35
  @change="handleChange($event,column)">
35
36
  </x-radio>
36
37
  </template>
37
38
  <template v-else-if="column.type === 'time'">
38
- <x-time-select :key="`row-${index}-item-${idx}`" :class="['column-item']" @change="handleChange($event,column)" :queryParamsName="column.configName">
39
+ <x-time-select :key="`row-${index}-item-${idx}`" :value="column.value" :class="['column-item']" @change="handleChange($event,column)" :queryParamsName="column.configName">
39
40
  </x-time-select>
40
41
  </template>
41
42
  <template v-else-if="column.type === 'text'">
@@ -112,9 +113,7 @@ export default {
112
113
  async getData (config, param) {
113
114
  const that = this
114
115
  that.config = { ...that.config, ...config }
115
- console.log(param)
116
116
  runLogic(config.data, param, 'af-his').then(res => {
117
- that.data = res || []
118
117
  that.results = {}
119
118
  // 将又返回值的数据创建到results
120
119
  for (let i = 0; i < res.length; i++) {
@@ -130,12 +129,28 @@ export default {
130
129
  console.error(`Config_id 冲突: ${field.config_id} 重复,同一个模板中不能有形同的配置项`)
131
130
  return
132
131
  }
133
- if (field.type === 'selectionBox' || field.type === 'input' || field.type === 'radio' || field.type === 'time') {
134
- this.results[field.config_id] = { value: field.value, data_id: field.data_id }
132
+ let value_
133
+ if (field.type === 'selectionBox') {
134
+ value_ = field.value === 'true' // 将字符串转为布尔值
135
+ } else if (field.type === 'radio') {
136
+ value_ = parseInt(field.value) || 0
137
+ } else if (field.type === 'time') {
138
+ value_ = field.value ? JSON.parse(field.value) : []
139
+ } else {
140
+ value_ = field.value
141
+ }
142
+ // 将符合条件的字段存入results
143
+ if (['selectionBox', 'input', 'radio', 'time'].includes(field.type)) {
144
+ this.results[field.config_id] = {
145
+ value: value_,
146
+ data_id: field.data_id
147
+ }
135
148
  }
149
+ field.value = value_
136
150
  console.log(this.results)
137
151
  }
138
152
  }
153
+ that.data = res || []
139
154
  })
140
155
  },
141
156
  refreshList (param) {
@@ -151,6 +166,7 @@ export default {
151
166
  },
152
167
  // 数据发生改变--将修改后的值填充到results
153
168
  handleChange (e, column) {
169
+ console.log('数据发生改变:', e, column)
154
170
  if (column.type === 'selectionBox') {
155
171
  this.results[column.config_id].value = e.target.checked
156
172
  } else if (column.type === 'input') {
@@ -68,7 +68,9 @@ export default {
68
68
  }
69
69
  }
70
70
  // 3. 初始化默认值(优先级: 配置defaultValue > 第一个选项)
71
- if (res.defaultValue !== undefined && res.defaultValue !== null) {
71
+ if (this.value !== undefined && this.value !== null) {
72
+ this.innerValue = this.value // 优先使用外部传入的 value
73
+ } else if (res.defaultValue !== undefined && res.defaultValue !== null) {
72
74
  // 使用配置中的defaultValue
73
75
  this.innerValue = res.defaultValue
74
76
  } else if (this.data.length > 0) {
@@ -16,6 +16,7 @@
16
16
  </div>
17
17
  <div v-if="type === 'date'" class="picker-wrapper">
18
18
  <a-date-picker
19
+ :value="dateRange"
19
20
  :format="format"
20
21
  :disabled="disabled"
21
22
  :allowClear="allowClear"
@@ -66,25 +67,32 @@ export default {
66
67
  watch: {
67
68
  value: {
68
69
  handler (newVal) {
69
- if (newVal && newVal.length === 2) {
70
- this.dateRange = [
71
- newVal[0] ? moment(newVal[0]) : null,
72
- newVal[1] ? moment(newVal[1]) : null
73
- ]
74
- } else if (newVal && this.type === 'date' && newVal.length === 1) {
75
- this.dateRange = [newVal[0] ? moment(newVal[0]) : null]
76
- } else {
77
- this.dateRange = []
78
- }
70
+ this.convertValueToMoment(newVal)
79
71
  },
80
72
  immediate: true,
81
73
  deep: true
74
+ },
75
+ type () {
76
+ this.convertValueToMoment(this.value)
82
77
  }
78
+
83
79
  },
84
80
  created () {
85
81
  this.getData(this.queryParamsName)
86
82
  },
87
83
  methods: {
84
+ convertValueToMoment (value) {
85
+ if (this.type === 'range' && value?.length === 2) {
86
+ this.dateRange = [
87
+ value[0] ? moment(value[0]) : null,
88
+ value[1] ? moment(value[1]) : null
89
+ ]
90
+ } else if (this.type === 'date' && value?.length === 1) {
91
+ this.dateRange = [value[0] ? moment(value[0]) : null]
92
+ } else {
93
+ this.dateRange = []
94
+ }
95
+ },
88
96
  handleDateChange (dates, dateStrings) {
89
97
  this.dateRange = dates
90
98
  console.warn(dateStrings)
@@ -92,12 +100,13 @@ export default {
92
100
  },
93
101
  async getData (data) {
94
102
  getConfigByName(data, 'af-his', res => {
95
- if (['date', 'range'].includes(res.type)) {
96
- this.type = res.type
97
- }
98
- if (res.label !== undefined) {
99
- this.label = res.label
100
- }
103
+ if (['date', 'range'].includes(res.type)) {
104
+ this.type = res.type
105
+ }
106
+ if (res.label !== undefined) {
107
+ this.label = res.label
108
+ }
109
+ this.convertValueToMoment(this.value)
101
110
  })
102
111
  }
103
112
  }
@@ -70,7 +70,7 @@ export default {
70
70
  },
71
71
  provide () {
72
72
  return {
73
- parentAPI: {
73
+ generalFunction: {
74
74
  setCancel: this.setCancel,
75
75
  }
76
76
  }