vue2-client 1.14.95 → 1.14.97

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.
@@ -1,37 +1,3 @@
1
- {
2
- "config":{
3
- "title":"",
4
- "split":"",
5
- "style":""//TODO 居中方式
6
- },
7
- "content": [
8
- {
9
- "key":"", //单行记录的标识
10
- "style":"",//居中方式
11
- "item": [
12
- {
13
- "type":"",
14
- "key": "",
15
- "value": {},
16
-
17
- "configName":"", // 通过后端获配置单选多选
18
- "button-type":"",
19
-
20
-
21
- }
22
- ]
23
- }
24
- ]
25
- }
26
1
  //常量取值 checkBox多选
27
2
  type [radio,selectionBox,text,input,time,describe,button]
28
3
  style = ['flex-start', 'flex-end', 'center', 'space-between', 'space-around']
29
-
30
- "results": [{
31
- "row_key": "",
32
- "key": "value"
33
- }
34
- ]
35
-
36
-
37
-
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="list-container" style="display: flex;">
3
- <template v-for="(config, index) in configs">
4
- <x-questionnaire-item :fixedQueryForm="conditions[index]" :queryParamsName="config" :ref="el => setItemRef(el, index)" :key="`questionnaire-${index}`"></x-questionnaire-item>
3
+ <template v-for="(config) in configs">
4
+ <x-questionnaire-item :key="config.tmp_key" :fixedQueryForm="conditionsMap[config.tmp_key]" :queryParamsName="config" :ref="el => setItemRef(el, config)" @customizeEvent="customizeEvent"></x-questionnaire-item>
5
5
  </template>
6
6
  </div>
7
7
  </template>
@@ -26,38 +26,66 @@ export default {
26
26
  data () {
27
27
  return {
28
28
  configs: [],
29
- questionnaireItemRefs: [], // 存储子组件实例
30
- conditions: []
29
+ questionnaireItemRefs: new Map(), // 存储子组件实例
30
+ conditionsMap: {}
31
31
  }
32
32
  },
33
33
  methods: {
34
34
  // 获取配置
35
- async getData (queryParamsName, conditions) {
36
- const that = this
35
+ async getData (queryParamsName, conditionData) {
37
36
  getConfigByName(queryParamsName, 'af-his', res => {
38
- if (res.configs) {
39
- that.configs = []
40
- }
41
- for (let i = 0; i < res.configs.length; i++) {
42
- const condition = i < conditions.length ? conditions[i] : {}
43
- that.configs.push(res.configs[i])
44
- that.conditions.push(condition)
45
- }
37
+ // 清空旧数据
38
+ this.configs = []
39
+ this.conditionsMap = { ...this.conditionsMap }
40
+ console.log(res)
41
+ res.configs.forEach(config => {
42
+ this.configs.push(config)
43
+ // 响应式更新条件映射
44
+ this.$set(this.conditionsMap, config.tmp_key,
45
+ conditionData[config.tmp_key] || {}
46
+ )
47
+ })
46
48
  })
47
49
  },
48
- setItemRef (el, index) {
49
- if (el) {
50
- this.questionnaireItemRefs[index] = el // 保存实例
50
+ customizeEvent (data, callback) {
51
+ console.log(this.$listeners)
52
+ if (data.customize.clickEventName && this.$listeners[data.customize.clickEventName]) {
53
+ // 交由父级处理
54
+ this.$emit(data.customize.clickEventName, data.customize, callback)
55
+ } else {
56
+ this.defaultAction(data.customize.clickEventName, data.customize, callback)
51
57
  }
52
58
  },
53
- init (conditions) {
54
- this.getData(this.queryParamsName, conditions)
59
+ defaultAction (clickEventName, item, callback) {
60
+ setTimeout(() => {
61
+ this.$message.warn(`已触发按钮 [${item.key}],注册事件名 [${clickEventName}],未实现事件函数`)
62
+ callback()
63
+ }, 200)
55
64
  },
56
- refreshList (index, condition) {
57
- if (index < this.conditions.length) {
58
- this.conditions[index] = condition
65
+ setItemRef (el, config) {
66
+ if (el) {
67
+ this.questionnaireItemRefs.set(config.tmp_key, el)
68
+ } else {
69
+ this.questionnaireItemRefs.delete(config.tmp_key) // 组件卸载时清理
59
70
  }
60
- }
71
+ },
72
+ async init (conditionData) { // 接收完整条件对象
73
+ await this.getData(this.queryParamsName, conditionData)
74
+ },
75
+ // init (configId, conditions) {
76
+ // this.getData(this.queryParamsName, conditions)
77
+ // // 初始化或更新时
78
+ // this.conditionsMap = {
79
+ // ...this.conditionsMap,
80
+ // [configId]: conditions // 响应式更新
81
+ // }
82
+ // },
83
+ refreshList (tmpKey, condition) {
84
+ // 更新条件映射
85
+ this.$set(this.conditionsMap, tmpKey, condition)
86
+ // 调用子组件刷新
87
+ this.questionnaireItemRefs.get(tmpKey)?.refreshList(condition)
88
+ },
61
89
  },
62
90
  }
63
91
  </script>
@@ -13,7 +13,19 @@ export default {
13
13
  methods: {
14
14
  init () {
15
15
  console.log(this)
16
- this.$refs.questionnaireRef.init([{ id: 10 }, { id: 20 }, { id: 10 }])
16
+ const conditionData = {
17
+ tmp_1: { tmp_id: 1 },
18
+ tmp_2: { tmp_id: 2 },
19
+ tmp_3: { tmp_id: 3 }
20
+ }
21
+ this.$refs.questionnaireRef.init(conditionData)
22
+ },
23
+ save () {
24
+ console.log(this)
25
+ console.log(this.$refs.questionnaireRef.questionnaireItemRefs.get('tmp_1').results)
26
+ },
27
+ refreshList () {
28
+ this.$refs.questionnaireRef.refreshList('tmp_2', { tmp_id: 3 })
17
29
  }
18
30
  }
19
31
  }
@@ -26,9 +38,14 @@ export default {
26
38
  <a-button type="primary" @click="init">
27
39
  初始化
28
40
  </a-button>
41
+ <a-button type="primary" @click="save">
42
+ 保存
43
+ </a-button>
44
+ <a-button type="primary" @click="refreshList">
45
+ 刷新
46
+ </a-button>
29
47
  </div>
30
48
  </template>
31
49
 
32
50
  <style scoped>
33
-
34
51
  </style>
@@ -19,23 +19,23 @@
19
19
  class="row-item"
20
20
  :style="{ justifyContent: getFlexJustify(item.style) }"
21
21
  >
22
- <template v-for="(column, idx) in item.item">
22
+ <template v-for="(column, idx) in item.columns">
23
23
  <template v-if="column.type === 'selectionBox'">
24
- <a-checkbox @change="handleChange($event,column,index)" v-model="column.value" :key="`row-${index}-item-${idx}`" :class="['column-item']"></a-checkbox>
24
+ <a-checkbox @change="handleChange($event,column)" v-model="column.value" :key="`row-${index}-item-${idx}`" :class="['column-item']"></a-checkbox>
25
25
  </template>
26
26
  <template v-else-if="column.type === 'input'">
27
- <a-input @change="handleChange($event,column,index)" :key="`row-${index}-item-${idx}`" :class="['column-item','item-input']" v-model="column.value" />
27
+ <a-input @change="handleChange($event,column)" :key="`row-${index}-item-${idx}`" :class="['column-item','item-input']" v-model="column.value" />
28
28
  </template>
29
29
  <template v-else-if="column.type === 'radio'">
30
30
  <x-radio
31
31
  :class="['column-item']"
32
32
  :key="`row-${index}-item-${idx}`"
33
33
  :queryParamsName="column.configName"
34
- @change="handleChange($event,column,index)">
34
+ @change="handleChange($event,column)">
35
35
  </x-radio>
36
36
  </template>
37
37
  <template v-else-if="column.type === 'time'">
38
- <x-time-select :key="`row-${index}-item-${idx}`" :class="['column-item']" @change="handleChange($event,column,index)" :queryParamsName="column.configName">
38
+ <x-time-select :key="`row-${index}-item-${idx}`" :class="['column-item']" @change="handleChange($event,column)" :queryParamsName="column.configName">
39
39
  </x-time-select>
40
40
  </template>
41
41
  <template v-else-if="column.type === 'text'">
@@ -51,13 +51,13 @@
51
51
  <a-button
52
52
  :class="['column-item']"
53
53
  :key="`row-${index}-item-${idx}`"
54
- :disabled="column.disabled"
55
- :icon="column.icon"
56
- :loading="column.loading"
57
- :type="column.buttonType || 'default'"
54
+ :disabled="column.customize.disabled"
55
+ :icon="column.customize.icon"
56
+ :loading="column.customize.loading"
57
+ :type="column.customize.buttonType || 'default'"
58
58
  @click="handleButtonClick(column)"
59
59
  >
60
- {{ column.label }}
60
+ {{ column.value }}
61
61
  </a-button>
62
62
  </template>
63
63
  <template v-else>
@@ -99,8 +99,8 @@ export default {
99
99
  split: true,
100
100
  header: null
101
101
  },
102
- results: [],
103
- mapping: [] // 行索引 results数据所在的行
102
+ results: {},
103
+ oldFixedQueryForm: null
104
104
  }
105
105
  },
106
106
  created () {
@@ -116,38 +116,33 @@ export default {
116
116
  ...config
117
117
  }
118
118
  runLogic(config.data, param, 'af-his').then(res => {
119
+ console.log('1', res)
119
120
  that.data = res || []
120
121
  // 将又返回值的数据创建到results
121
122
  for (let i = 0; i < res.length; i++) {
122
123
  const fields = res[i]
123
- if (!fields.item) {
124
+ if (!fields.columns) {
124
125
  continue
125
126
  }
126
- const value = {}
127
- let hasValidData = false // 标识是否有有效数据
128
- for (let j = 0; j < fields.item.length; j++) {
129
- const field = fields.item[j]
127
+ console.log('2', fields)
128
+ for (let j = 0; j < fields.columns.length; j++) {
129
+ const field = fields.columns[j]
130
+ console.log('3', field)
131
+ if (this.results[field.config_id]) {
132
+ console.error(`Config_id 冲突: ${field.config_id} 重复,同一个模板中不能有形同的配置项`)
133
+ return
134
+ }
130
135
  if (field.type === 'selectionBox' || field.type === 'input' || field.type === 'radio' || field.type === 'time') {
131
- value[field.key] = field.value
132
- hasValidData = true
136
+ this.results[field.config_id] = { value: field.value, data_id: field.data_id }
133
137
  }
134
- }
135
- if (hasValidData) {
136
- this.mapping.push(this.results.length)
137
- value.row_key = fields.key
138
- this.results.push(value)
139
- } else {
140
- this.mapping.push(undefined)
138
+ console.log(this.results)
141
139
  }
142
140
  }
143
141
  })
144
142
  },
145
143
  refreshList (param) {
146
- // 清空当前数据和映射关系
147
144
  this.data = []
148
- this.results = []
149
- this.mapping = []
150
- this.results = []
145
+ this.results = {}
151
146
  this.getData(this.queryParamsName, param)
152
147
  },
153
148
  // 行数据排量方式
@@ -159,34 +154,21 @@ export default {
159
154
  return validStyles.includes(style) ? style : 'flex-start'
160
155
  },
161
156
  // 数据发生改变--将修改后的值填充到results
162
- handleChange (e, column, rowIndex) {
163
- const resultIndex = this.mapping[rowIndex]
164
- if (resultIndex === undefined) return
157
+ handleChange (e, column) {
165
158
  if (column.type === 'selectionBox') {
166
- this.results[resultIndex][column.key] = e.target.checked
159
+ this.results[column.config_id].value = e.target.checked
167
160
  } else if (column.type === 'input') {
168
- this.results[resultIndex][column.key] = column.value
161
+ this.results[column.config_id].value = column.value
169
162
  } else if (column.type === 'radio' || column.type === 'time') {
170
- this.results[resultIndex][column.key] = e
163
+ this.results[column.config_id].value = e
171
164
  }
172
165
  },
173
166
  handleButtonClick (item) {
174
- item.loading = true
167
+ item.customize.loading = true
175
168
  const callback = () => {
176
- item.loading = false
169
+ item.customize.loading = false
177
170
  }
178
- if (item.clickEventName && this.$listeners[item.clickEventName]) {
179
- // 交由父级处理
180
- this.$emit(item.clickEventName, item, callback)
181
- } else {
182
- this.defaultAction(item.clickEventName, item, callback)
183
- }
184
- },
185
- defaultAction (clickEventName, item, callback) {
186
- setTimeout(() => {
187
- this.$message.warn(`已触发按钮 [${item.key}],注册事件名 [${clickEventName}],未实现事件函数`)
188
- callback()
189
- }, 200)
171
+ this.$emit('customizeEvent', item.customize, callback)
190
172
  }
191
173
  },
192
174
  watch: {
@@ -1,88 +1,88 @@
1
- <template>
2
- <a-row
3
- type="flex"
4
- :gutter="row.gutter || 0"
5
- :align="row.align || 'top'"
6
- :justify="row.justify || 'start'"
7
- >
8
- <a-col
9
- v-for="col in getColumns"
10
- :key="`page-col-${col.id}`"
11
- :span="col.span || 24"
12
- :xs="col.xs"
13
- :sm="col.sm"
14
- :md="col.md"
15
- :lg="col.lg"
16
- :xl="col.xl"
17
- :xxl="col.xxl"
18
- >
19
- <!-- 行类型,递归渲染子行 -->
20
- <template v-if="col.type === 'row'">
21
- <x-page-row-template :template="col.template">
22
- <render-row
23
- v-for="(nestedRow, index) in col.children"
24
- :row="nestedRow"
25
- :key="`nested-row-${col.id}-${index}`"
26
- />
27
- </x-page-row-template>
28
- </template>
29
-
30
- <!-- 组件类型,渲染动态组件 -->
31
- <template v-else>
32
- <x-page-row-template :template="col.template">
33
- <component
34
- :ref="(el) => registerComponentRef(col.id, el)"
35
- :is="resolveComponentType(col.type)"
36
- v-bind="col.props"
37
- >
38
- <!-- 如果组件有子组件,递归渲染子行 -->
39
- <template v-if="col.children && col.children.length">
40
- <!-- 处理纯文本节点 -->
41
- <template v-for="(nestedItem, index) in col.children">
42
- <template v-if="nestedItem.text">{{ nestedItem.text }}</template>
43
- <render-row
44
- v-else
45
- :row="nestedItem"
46
- :key="`comp-child-${col.id}-${index}`"
47
- />
48
- </template>
49
- </template>
50
- </component>
51
- </x-page-row-template>
52
- </template>
53
- </a-col>
54
- </a-row>
55
- </template>
56
-
57
- <script setup>
58
- import { defineProps, inject, computed } from 'vue'
59
- import XPageRowTemplate from './XPageRowTemplate.vue'
60
-
61
- import { resolveComponentType } from './componentTypes'
62
-
63
- // 注入注册组件方法
64
- const registerComponent = inject('registerComponent')
65
-
66
- // 定义属性
67
- const props = defineProps({
68
- row: {
69
- type: Object,
70
- required: true
71
- }
72
- })
73
-
74
- // 获取列数组
75
- const getColumns = computed(() => {
76
- return props.row.type === 'row' ? props.row.children : [props.row]
77
- })
78
-
79
- // 注册组件引用
80
- const registerComponentRef = (id, el) => {
81
- if (el) {
82
- registerComponent(id, el)
83
- }
84
- }
85
- </script>
86
-
87
- <style scoped lang="less">
88
- </style>
1
+ <template>
2
+ <a-row
3
+ type="flex"
4
+ :gutter="row.gutter || 0"
5
+ :align="row.align || 'top'"
6
+ :justify="row.justify || 'start'"
7
+ >
8
+ <a-col
9
+ v-for="col in getColumns"
10
+ :key="`page-col-${col.id}`"
11
+ :span="col.span || 24"
12
+ :xs="col.xs"
13
+ :sm="col.sm"
14
+ :md="col.md"
15
+ :lg="col.lg"
16
+ :xl="col.xl"
17
+ :xxl="col.xxl"
18
+ >
19
+ <!-- 行类型,递归渲染子行 -->
20
+ <template v-if="col.type === 'row'">
21
+ <x-page-row-template :template="col.template">
22
+ <render-row
23
+ v-for="(nestedRow, index) in col.children"
24
+ :row="nestedRow"
25
+ :key="`nested-row-${col.id}-${index}`"
26
+ />
27
+ </x-page-row-template>
28
+ </template>
29
+
30
+ <!-- 组件类型,渲染动态组件 -->
31
+ <template v-else>
32
+ <x-page-row-template :template="col.template">
33
+ <component
34
+ :ref="(el) => registerComponentRef(col.id, el)"
35
+ :is="resolveComponentType(col.type)"
36
+ v-bind="col.props"
37
+ >
38
+ <!-- 如果组件有子组件,递归渲染子行 -->
39
+ <template v-if="col.children && col.children.length">
40
+ <!-- 处理纯文本节点 -->
41
+ <template v-for="(nestedItem, index) in col.children">
42
+ <template v-if="nestedItem.text">{{ nestedItem.text }}</template>
43
+ <render-row
44
+ v-else
45
+ :row="nestedItem"
46
+ :key="`comp-child-${col.id}-${index}`"
47
+ />
48
+ </template>
49
+ </template>
50
+ </component>
51
+ </x-page-row-template>
52
+ </template>
53
+ </a-col>
54
+ </a-row>
55
+ </template>
56
+
57
+ <script setup>
58
+ import { defineProps, inject, computed } from 'vue'
59
+ import XPageRowTemplate from './XPageRowTemplate.vue'
60
+
61
+ import { resolveComponentType } from './componentTypes'
62
+
63
+ // 注入注册组件方法
64
+ const registerComponent = inject('registerComponent')
65
+
66
+ // 定义属性
67
+ const props = defineProps({
68
+ row: {
69
+ type: Object,
70
+ required: true
71
+ }
72
+ })
73
+
74
+ // 获取列数组
75
+ const getColumns = computed(() => {
76
+ return props.row.type === 'row' ? props.row.children : [props.row]
77
+ })
78
+
79
+ // 注册组件引用
80
+ const registerComponentRef = (id, el) => {
81
+ if (el) {
82
+ registerComponent(id, el)
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <style scoped lang="less">
88
+ </style>