wui-components-v2 1.1.66 → 1.1.68

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.
@@ -61,19 +61,22 @@ function edit() {
61
61
  const sourceData = props.item.classEditConfigs.find((item: ClassEditConfigs) => {
62
62
  return item.preposes[0].transDefaultValue.includes(props.data.fieldMap[item.preposes[0].sourceId])
63
63
  })
64
- router.push(`/pages/edit-page/index?sourceId=${sourceData?.id || props.sourceId}&id=${props.code}&title=${props.item.title}&pageType=${props.pageType}&addEvent=${props.addEvent}`)
65
- }
66
- else {
67
- router.push(`/pages/edit-page/index?sourceId=${props.sourceId}&id=${props.code}&title=${props.item.title}&pageType=${props.pageType}&addEvent=${props.addEvent}`)
64
+ router.push(
65
+ `/pages/edit-page/index?sourceId=${sourceData?.id || props.sourceId}&id=${props.code}&title=${props.item.title}&pageType=${props.pageType}&addEvent=${props.addEvent}`
66
+ )
67
+ } else {
68
+ router.push(
69
+ `/pages/edit-page/index?sourceId=${props.sourceId}&id=${props.code}&title=${props.item.title}&pageType=${props.pageType}&addEvent=${props.addEvent}`
70
+ )
68
71
  }
69
72
  }
70
73
 
71
74
  const actionItem = ref<Groups>()
72
- const actionItemShow = ref(false)// rowActions输入弹框开关
73
- const showMoreButn = ref(false)// 更多按钮开关
75
+ const actionItemShow = ref(false) // rowActions输入弹框开关
76
+ const showMoreButn = ref(false) // 更多按钮开关
74
77
  // 打开rowActions弹框
75
78
  async function action(subitem: rowActions) {
76
- console.log(subitem)
79
+ console.log(subitem, 2222222222222222)
77
80
  if (subitem.writes.length) {
78
81
  actionItem.value = {
79
82
  ...props.item,
@@ -81,14 +84,12 @@ async function action(subitem: rowActions) {
81
84
  id: subitem.id,
82
85
  }
83
86
  actionItemShow.value = true
84
- }
85
- else {
87
+ } else {
86
88
  try {
87
89
  await actionDataSave(subitem.id, props.code, {})
88
90
  props.zpaging.reload()
89
91
  toast.success({ msg: '操作成功!' })
90
- }
91
- catch (error: any) {
92
+ } catch (error: any) {
92
93
  toast.error(error)
93
94
  console.log(error)
94
95
  }
@@ -97,7 +98,9 @@ async function action(subitem: rowActions) {
97
98
 
98
99
  // 跳转raction页面
99
100
  function raction(subitem: rowActions) {
100
- router.push(`/pages/list/index?sourceId=${subitem.id}&mainCode=${props.code}&title=${subitem.title}&pageType=${props.pageType}`)
101
+ router.push(
102
+ `/pages/list/index?sourceId=${subitem.id}&mainCode=${props.code}&title=${subitem.title}&pageType=${props.pageType}`
103
+ )
101
104
  }
102
105
 
103
106
  // 跳转详情页面
@@ -121,7 +124,10 @@ function isShowAction(item: rowActions) {
121
124
  }
122
125
 
123
126
  function isControlType(item: Columns): string {
124
- return ControlTypeSupportor.getControlType({ ...item, hidden: false, disabled: false, defaultValue: '', transDefaultValue: '', required: false }, props.data.fieldMap[item.sourceId])
127
+ return ControlTypeSupportor.getControlType(
128
+ { ...item, hidden: false, disabled: false, defaultValue: '', transDefaultValue: '', required: false },
129
+ props.data.fieldMap[item.sourceId]
130
+ )
125
131
  }
126
132
 
127
133
  // 删除
@@ -137,15 +143,12 @@ function del() {
137
143
  toast.success({ msg: '删除成功!' })
138
144
  }
139
145
  message.close()
140
- }
141
- catch (error) {
146
+ } catch (error) {
142
147
  console.log(error)
143
- }
144
- finally {
148
+ } finally {
145
149
  resolve(true)
146
150
  }
147
151
  },
148
-
149
152
  })
150
153
  }
151
154
 
@@ -157,7 +160,7 @@ interface Morebutns extends Omit<rowActions, ''> {
157
160
  const morebutns = computed(() => {
158
161
  let buts: Morebutns[] = []
159
162
  if (props.rowActions) {
160
- buts = anctions.value.map((item) => {
163
+ buts = anctions.value.map(item => {
161
164
  return {
162
165
  actionType: 'rowActions',
163
166
  name: item.title,
@@ -167,26 +170,24 @@ const morebutns = computed(() => {
167
170
  }
168
171
  if (props.ractions) {
169
172
  buts = buts.concat(
170
- ractions.value.map((item) => {
173
+ ractions.value.map(item => {
171
174
  return {
172
175
  actionType: 'ractions',
173
176
  name: item.title,
174
177
  ...item,
175
178
  }
176
- }),
177
-
179
+ })
178
180
  )
179
181
  }
180
182
  if (props.actions) {
181
183
  buts = buts.concat(
182
- actions.value.map((item) => {
184
+ actions.value.map(item => {
183
185
  return {
184
186
  actionType: 'rowActions',
185
187
  name: item.title,
186
188
  ...item,
187
189
  }
188
- }),
189
-
190
+ })
190
191
  )
191
192
  }
192
193
  return buts
@@ -199,6 +200,9 @@ function closeMoreButn() {
199
200
 
200
201
  // 点击更多按钮
201
202
  function select({ item }: { item: any }) {
203
+ if (item.title.includes('评价') && item.actionType === 'rowActions') {
204
+ return action(item)
205
+ }
202
206
  message.confirm({
203
207
  msg: `确定${item.title}操作吗?`,
204
208
  title: '提示',
@@ -212,6 +216,7 @@ function select({ item }: { item: any }) {
212
216
  },
213
217
  })
214
218
  }
219
+ console.log(props, '3333333333333')
215
220
  </script>
216
221
 
217
222
  <template>
@@ -227,28 +232,46 @@ function select({ item }: { item: any }) {
227
232
  </wd-button>
228
233
  </view> -->
229
234
  <view>
230
- <wd-button v-if="morebutns.length > 3" size="small" type="info" @click="() => { showMoreButn = true }">
235
+ <wd-button
236
+ v-if="morebutns.length > 3"
237
+ size="small"
238
+ type="info"
239
+ @click="
240
+ () => {
241
+ showMoreButn = true
242
+ }
243
+ "
244
+ >
231
245
  更多
232
246
  </wd-button>
233
247
  <view v-else class="flex gap-2 flex-wrap">
234
- <wd-button v-for="subitem in morebutns" :key="subitem.id" plain size="small" @click="() => { select({ item: subitem }) }">
248
+ <wd-button
249
+ v-for="subitem in morebutns"
250
+ :key="subitem.id"
251
+ plain
252
+ size="small"
253
+ @click="
254
+ () => {
255
+ select({ item: subitem })
256
+ }
257
+ "
258
+ >
235
259
  {{ subitem.title }}
236
260
  </wd-button>
237
261
  </view>
238
262
  </view>
239
263
 
240
- <wd-button v-if="props.item.buttons.includes('dtmplEdit')" size="small" @click="edit()">
241
- 编辑
242
- </wd-button>
243
- <wd-button v-if="props.item.buttons.includes('detail')" size="small" type="info" @click="detail()">
244
- 详情
245
- </wd-button>
264
+ <wd-button v-if="props.item.buttons.includes('dtmplEdit')" size="small" @click="edit()">编辑</wd-button>
265
+ <wd-button v-if="props.item.buttons.includes('detail')" size="small" type="info" @click="detail()">详情</wd-button>
246
266
  <wd-button v-if="props.item.buttons.includes('singleDelete')" size="small" type="danger" @click="del()">
247
267
  删除
248
268
  </wd-button>
249
269
  <ActionPopup
250
- v-model:show="actionItemShow" :enum-column="props.enumColumn" :zpaging="props.zpaging"
251
- :field-group="actionItem" :code="props.code"
270
+ v-model:show="actionItemShow"
271
+ :enum-column="props.enumColumn"
272
+ :zpaging="props.zpaging"
273
+ :field-group="actionItem"
274
+ :code="props.code"
252
275
  />
253
276
  <!-- 更多按钮 -->
254
277
  <wd-action-sheet v-model="showMoreButn" :actions="morebutns" @close="closeMoreButn" @select="select" />
@@ -0,0 +1,192 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+ import { onLoad } from '@dcloudio/uni-app'
4
+ import { detailPageConfig, detailPageData, pageConfig as OperationPageConfig, actionDataSave } from '../../api/page'
5
+ import type { Entities, Groups, dtmplConfig, rowActions } from '../../type'
6
+ import LabelValue from '../label-value/label-value.vue'
7
+ import ActionPopup from '../action-popup/action-popup.vue'
8
+ import { useGlobalToast } from '../../composables/useGlobalToast'
9
+
10
+ defineOptions({
11
+ name: 'EvaluationPage',
12
+ })
13
+ const toast = useGlobalToast()
14
+ const sourceId = ref('')
15
+ const id = ref('')
16
+ const title = ref('')
17
+ const pageConfig = ref<dtmplConfig>({
18
+ id: '',
19
+ title: '',
20
+ groups: [],
21
+ entity: {} as any,
22
+ buttons: [],
23
+ })
24
+ const data = ref<Entities>({
25
+ code: '',
26
+ fieldMap: {},
27
+ arrayMap: {},
28
+ })
29
+ const groups = ref<Groups>({
30
+ id: '',
31
+ buttons: ['detail'],
32
+ fields: [],
33
+ title: '',
34
+ type: '',
35
+ pointSourceId: '',
36
+ mstrucId: '',
37
+ relationNames: [],
38
+ readOnly: false,
39
+ displayConfig: [],
40
+ })
41
+ const loading = ref(false)
42
+ // 折叠面板
43
+ const collapses = ref()
44
+ // 评价操作配置
45
+ const evaluationActions = ref<rowActions[]>([])
46
+ onLoad((option: any) => {
47
+ sourceId.value = option.sourceId
48
+ id.value = option.id
49
+ // #ifdef MP-WEIXIN
50
+ const q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
51
+ const sc: any = getQueryParams(q)
52
+ sourceId.value = sc.sourceId || option.sourceId
53
+ id.value = sc.id || option.id
54
+ // #endif
55
+ title.value = option.title
56
+ uni.setNavigationBarTitle({
57
+ title: `${option.title}`,
58
+ })
59
+ getPageConfig()
60
+ })
61
+
62
+ // 将 URL 中问号后面的参数转换为对象
63
+ function getQueryParams(url: string) {
64
+ // 获取问号后面的部分
65
+ const queryString = url.split('?')[1]
66
+
67
+ if (!queryString) {
68
+ return {}
69
+ }
70
+
71
+ // 将参数字符串分割成键值对数组
72
+ const pairs = queryString.split('&')
73
+
74
+ // 创建结果对象
75
+ const result: { [key: string]: string } = {}
76
+
77
+ // 遍历键值对
78
+ pairs.forEach(pair => {
79
+ const [key, value] = pair.split('=')
80
+ // 解码URI组件并添加到结果对象
81
+ result[decodeURIComponent(key)] = decodeURIComponent(value || '')
82
+ })
83
+
84
+ return result
85
+ }
86
+
87
+ // 获取页面配置
88
+ async function getPageConfig() {
89
+ try {
90
+ loading.value = true
91
+ const res = await detailPageConfig(sourceId.value)
92
+ // 初始化折叠面板
93
+ if (res.dtmplConfig) {
94
+ uni.setNavigationBarTitle({
95
+ title: `${res.dtmplConfig.title}`,
96
+ })
97
+ pageConfig.value = res.dtmplConfig
98
+ collapses.value = pageConfig.value.groups.map((item: Groups) => {
99
+ return item.id
100
+ })
101
+ getDetailData()
102
+ getOperationPageConfig()
103
+ }
104
+ } catch (error) {
105
+ console.log(error)
106
+ loading.value = false
107
+ }
108
+ }
109
+
110
+ // 获取详情数据
111
+ async function getDetailData() {
112
+ try {
113
+ const res = await detailPageData(sourceId.value, id.value)
114
+ data.value = res.entity
115
+ loading.value = false
116
+ } catch (error) {
117
+ loading.value = false
118
+ console.log(error)
119
+ }
120
+ }
121
+ async function getOperationPageConfig() {
122
+ try {
123
+ const res: any = await OperationPageConfig(sourceId.value)
124
+ // 筛选出评价相关的操作
125
+ if (res.ltmplConfig?.rowActions) {
126
+ evaluationActions.value = res.ltmplConfig.rowActions.filter((item: rowActions) => item.title.includes('评价'))
127
+ }
128
+ console.log(res, '222222222')
129
+ } catch (error) {
130
+ console.log(error)
131
+ }
132
+ }
133
+
134
+ const actionItemShow = ref(false)
135
+ const actionItem = ref<Groups>()
136
+ const code = ref('')
137
+ const enumColumn = ref()
138
+ // 模拟 zpaging 对象,用于 ActionPopup 刷新
139
+ const mockZpaging = {
140
+ reload: () => getDetailData(),
141
+ }
142
+
143
+ // 评价按钮点击事件 - 迁移自 card-botom-buttons 的 select action 功能
144
+ async function handleEvaluationClick() {
145
+ if (evaluationActions.value.length === 0) {
146
+ toast.error({ msg: '未找到评价操作配置' })
147
+ return
148
+ }
149
+ // 取第一个评价操作
150
+ const subitem = evaluationActions.value[0]
151
+ if (subitem.writes.length) {
152
+ actionItem.value = {
153
+ ...groups.value,
154
+ fields: subitem.writes,
155
+ id: subitem.id,
156
+ }
157
+ code.value = id.value
158
+ actionItemShow.value = true
159
+ } else {
160
+ try {
161
+ await actionDataSave(subitem.id, id.value, {})
162
+ toast.success({ msg: '评价成功!' })
163
+ } catch (error: any) {
164
+ toast.error(error)
165
+ console.log(error)
166
+ }
167
+ }
168
+ }
169
+ </script>
170
+
171
+ <template>
172
+ <view class="p-4">
173
+ <view v-if="loading" class="flex justify-center p-3">
174
+ <wd-loading />
175
+ </view>
176
+ <view v-else>
177
+ <view v-for="(group, index) in pageConfig.groups" :key="group.id" :title="group.title" :name="group.id">
178
+ <view class="text-sm space-y-3">
179
+ <LabelValue :index="index" :exhibit-data="group.fields" :data="data" />
180
+ </view>
181
+ </view>
182
+ </view>
183
+ <wd-button type="primary" class="mt-4 w-full" @click="handleEvaluationClick">评价</wd-button>
184
+ <ActionPopup
185
+ v-model:show="actionItemShow"
186
+ :enum-column="enumColumn"
187
+ :zpaging="mockZpaging"
188
+ :field-group="actionItem"
189
+ :code="code"
190
+ />
191
+ </view>
192
+ </template>