wui-components-v2 1.0.85 → 1.0.87

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.
@@ -4,6 +4,8 @@ import { useRouter } from 'uni-mini-router'
4
4
  import { onLoad } from '@dcloudio/uni-app'
5
5
  import type { ClassEditConfigs, Entities, Fields, Groups, rowActions } from '../../type'
6
6
  import ActionPopup from '../action-popup/action-popup.vue'
7
+ import { actionDataSave } from '../../api/page'
8
+ import { useGlobalToast } from '../../composables/useGlobalToast'
7
9
 
8
10
  defineOptions({
9
11
  name: 'CardBotomButtons',
@@ -18,6 +20,7 @@ const props = defineProps<{
18
20
  ractions?: rowActions[]
19
21
  zpaging?: any
20
22
  }>()
23
+ const toast = useGlobalToast()
21
24
  const pageType = ref('')
22
25
  onLoad((option: any) => {
23
26
  pageType.value = option.type || ''
@@ -52,15 +55,27 @@ function edit() {
52
55
  const actionItem = ref<Groups>()
53
56
  const actionItemShow = ref(false)
54
57
  // 打开action弹框
55
- function action(subitem: rowActions) {
58
+ async function action(subitem: rowActions) {
56
59
  console.log(subitem)
57
- actionItem.value = {
58
- ...props.item,
59
- fields: subitem.writes,
60
- id: subitem.id,
60
+ if (subitem.writes.length) {
61
+ actionItem.value = {
62
+ ...props.item,
63
+ fields: subitem.writes,
64
+ id: subitem.id,
65
+ }
66
+ actionItemShow.value = true
67
+ }
68
+ else {
69
+ try {
70
+ await actionDataSave(subitem.id, props.code, {})
71
+ props.zpaging.reload()
72
+ toast.success({ msg: '操作成功!' })
73
+ }
74
+ catch (error: any) {
75
+ toast.error(error)
76
+ console.log(error)
77
+ }
61
78
  }
62
- actionItemShow.value = true
63
- // router.push(`/pages/edit-page/index?sourceId=${subitem.id}&id=${props.code}&title=${subitem.title}&pageType=`)
64
79
  }
65
80
 
66
81
  // 跳转raction页面
@@ -2,6 +2,7 @@
2
2
  import { computed, defineOptions, defineProps } from 'vue'
3
3
  import type { Columns, Entities } from '../../type'
4
4
  import { downloadFile, formatItemData } from '../../utils'
5
+ import ControlTypeSupportor from '../../utils/control-type-supportor'
5
6
 
6
7
  defineOptions({
7
8
  name: 'LabelValue',
@@ -23,6 +24,10 @@ function splitUrlStr(str: string) {
23
24
  return '暂无文件'
24
25
  }
25
26
  }
27
+
28
+ function isControlType(item: Columns): string {
29
+ return ControlTypeSupportor.getControlType({ ...item, disabled: false, defaultValue: '', transDefaultValue: '', required: false }, props.data.fieldMap[item.sourceId])
30
+ }
26
31
  </script>
27
32
 
28
33
  <template>
@@ -30,24 +35,28 @@ function splitUrlStr(str: string) {
30
35
  <view class="mr-2 w-20 p-1 text-gray-500 dark:text-white">
31
36
  {{ item.title }}:
32
37
  </view>
33
- <view v-if="item.controlType === 'file' || item.extControlType === 'file' || item.extControlType === 'relfile'" class="flex-1 text-gray-800 dark:text-white">
34
- <wd-img v-if="data.fieldMap[item.sourceId]" enable-preview :width="100" :height="100" :src="formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType)">
35
- <template #error>
36
- <view class="error-wrap">
37
- <wd-button type="text" @click="downloadFile(formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType))">
38
- {{ splitUrlStr(formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType)) || '' }}
39
- </wd-button>
40
- </view>
41
- </template>
42
- <template #loading>
43
- <view class="loading-wrap">
44
- <wd-loading />
45
- </view>
46
- </template>
47
- </wd-img>
38
+ <view v-if="isControlType(item) === 'file' || isControlType(item) === 'relfile'" class="flex-1 text-gray-800 dark:text-white">
39
+ <view v-if="data.fieldMap[item.sourceId]">
40
+ <view v-for="(url, uindex) in formatItemData(data.fieldMap[item.sourceId], isControlType(item))" :key="uindex">
41
+ <wd-img enable-preview :width="100" :height="100" :src="url">
42
+ <template #error>
43
+ <view class="error-wrap">
44
+ <wd-button type="text" @click="downloadFile(url)">
45
+ {{ splitUrlStr(url) || '' }}
46
+ </wd-button>
47
+ </view>
48
+ </template>
49
+ <template #loading>
50
+ <view class="loading-wrap">
51
+ <wd-loading />
52
+ </view>
53
+ </template>
54
+ </wd-img>
55
+ </view>
56
+ </view>
48
57
  </view>
49
58
  <view v-else class="flex flex-1 items-center text-gray-800 dark:text-white">
50
- {{ formatItemData(data.fieldMap[item.sourceId], item.extControlType || item.controlType) }}
59
+ {{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
51
60
  </view>
52
61
  </view>
53
62
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
@@ -131,6 +131,10 @@ ControlTypeSupportor.getControlType = function (fieldConfig: Fields, fieldValue?
131
131
  if (!!fieldValue && typeof (fieldValue) == 'string' && !fieldValue.includes('@R@') && itemType === 'relselect' && fieldValue.includes('download-files/')) {
132
132
  itemType = 'file'
133
133
  }
134
+
135
+ if (fieldValue && Array.isArray(fieldValue) && itemType === 'relselect' && fieldValue[0].includes('valid')) {
136
+ itemType = 'file'
137
+ }
134
138
  return itemType
135
139
  }
136
140
 
package/utils/index.ts CHANGED
@@ -42,11 +42,19 @@ export function formatItemData(data: any, type: string) {
42
42
  // 判断是否为JSON文件
43
43
  if (typeof data === 'string') {
44
44
  const a = JSON.parse(data)
45
- return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
46
- // return {
47
- // url: `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
48
- // name: a.base.fileName,
49
- // }
45
+ return [`${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`]
46
+ }
47
+ else if (Array.isArray(data)) {
48
+ return data.map((item) => {
49
+ if (item.includes('@R@')) {
50
+ const a = JSON.parse(item.split('@R@')[1])
51
+ return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
52
+ }
53
+ else {
54
+ const a = JSON.parse(item)
55
+ return `${baseUrl}/v3/files${a.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}&name=${a.base.fileName || ''}`
56
+ }
57
+ })
50
58
  }
51
59
  else {
52
60
  return data.url