w-ui-v1 1.0.24 → 1.0.26
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/index.ts +7 -1
- package/package.json +1 -1
- package/utils/apis/pageConfig.ts +28 -0
- package/utils/http.ts +0 -1
- package/w-add/w-add.vue +15 -118
- package/w-card/utils/utils.ts +155 -90
- package/w-card/w-card.vue +115 -53
- package/w-detail/w-detail.vue +106 -129
- package/w-edit/w-edit.vue +253 -0
- package/w-form-control/w-form-control.vue +125 -0
- package/w-form-message-box/w-form-message-box.vue +106 -0
- package/w-menu/w-menu.vue +44 -25
- package/w-search/w-search.vue +70 -67
- package/w-select-picker/w-select-picker-old.vue +461 -0
- package/w-select-picker/w-select-picker.vue +429 -397
- package/w-table/w-selectTable.vue +33 -14
- package/w-table/w-table.vue +22 -14
package/index.ts
CHANGED
|
@@ -9,6 +9,9 @@ import wDetail from './w-detail/w-detail.vue'
|
|
|
9
9
|
import wAdd from './w-add/w-add.vue'
|
|
10
10
|
import WSearch from './w-search/w-search.vue'
|
|
11
11
|
import WUser from './w-user/w-user.vue'
|
|
12
|
+
import wEdit from './w-edit/w-edit.vue'
|
|
13
|
+
import wSelectTable from './w-table/w-selectTable.vue'
|
|
14
|
+
import WFormMessageBox from './w-form-message-box/w-form-message-box.vue'
|
|
12
15
|
const coms: any[] = [
|
|
13
16
|
wTest,
|
|
14
17
|
wLogin,
|
|
@@ -19,7 +22,10 @@ const coms: any[] = [
|
|
|
19
22
|
wDetail,
|
|
20
23
|
wAdd,
|
|
21
24
|
WSearch,
|
|
22
|
-
WUser
|
|
25
|
+
WUser,
|
|
26
|
+
wEdit,
|
|
27
|
+
wSelectTable,
|
|
28
|
+
WFormMessageBox
|
|
23
29
|
]
|
|
24
30
|
// 批量组件注册
|
|
25
31
|
function install(Vue: App) {
|
package/package.json
CHANGED
package/utils/apis/pageConfig.ts
CHANGED
|
@@ -45,6 +45,13 @@ export function detailPageData(sourceId: string,code: string) {
|
|
|
45
45
|
})
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
//编辑页面详细配置
|
|
49
|
+
export function editPageConfig(sourceId: string,code: string) {
|
|
50
|
+
return request({
|
|
51
|
+
url: `/v3/dtmpl/config?sourceId=${sourceId}&code=${code}`,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
|
|
49
56
|
// 获取页面数据key
|
|
50
57
|
export function getPageKey(sourceId: string, query: string='') {
|
|
@@ -75,3 +82,24 @@ export function getEnum(mstrucIds:string) {
|
|
|
75
82
|
data: mstrucIds
|
|
76
83
|
})
|
|
77
84
|
}
|
|
85
|
+
|
|
86
|
+
//删除
|
|
87
|
+
export function deletePageData(sourceId: string,code: string) {
|
|
88
|
+
return request({
|
|
89
|
+
url: `/v3/ltmpl/data?sourceId=${sourceId}&codes=${code}`,
|
|
90
|
+
method: 'DELETE',
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//自定义按钮提交
|
|
95
|
+
export function customButtonSave(sourceId: string,codes:string, data: any) {
|
|
96
|
+
return request({
|
|
97
|
+
url: `/v3/action`,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
data:{
|
|
100
|
+
sourceId,
|
|
101
|
+
codes,
|
|
102
|
+
...data
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
package/utils/http.ts
CHANGED
|
@@ -24,7 +24,6 @@ export default function request(options: any): Promise<any> {
|
|
|
24
24
|
responseType: 'json',
|
|
25
25
|
// #endif
|
|
26
26
|
success: (res: any) => {
|
|
27
|
-
console.log('request', res)
|
|
28
27
|
// 判断状态
|
|
29
28
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
30
29
|
if(res.data.message==='权限不足或没有资源'){
|
package/w-add/w-add.vue
CHANGED
|
@@ -3,48 +3,14 @@
|
|
|
3
3
|
<view v-if="loading" style="height: 100px;display: flex;justify-content: center;align-items: center;">
|
|
4
4
|
<wd-loading />
|
|
5
5
|
</view>
|
|
6
|
-
<
|
|
6
|
+
<view v-else>
|
|
7
|
+
<wd-collapse v-model="value" >
|
|
7
8
|
<wd-collapse-item :title="item.title" :name="item.id" v-for="(item, index) in pageConf.groups" :key="index">
|
|
8
9
|
<view
|
|
9
10
|
v-if="item.type === 'fieldGroup'">
|
|
10
11
|
<wd-form ref="form" :model="model">
|
|
11
12
|
<wd-cell-group v-for="(subItem, subIndex) in item.fields" :key="subIndex">
|
|
12
|
-
|
|
13
|
-
<wd-input v-if="subItem.extControlType === 'text'" :disabled="subItem.disabled"
|
|
14
|
-
:label="subItem.title" label-width="100px" :prop="subItem.id" clearable
|
|
15
|
-
v-model="model[subItem.id]"
|
|
16
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
17
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
18
|
-
<wd-picker v-if="subItem.extControlType === 'select'" :disabled="subItem.disabled"
|
|
19
|
-
:label="subItem.title" label-width="100px" :prop="subItem.id" clearable
|
|
20
|
-
v-model="model[subItem.id]"
|
|
21
|
-
:placeholder="subItem.disabled ? '无需输入' : `请选择${subItem.title}`"
|
|
22
|
-
:rules="[{ required: subItem.required, message: `请选择${subItem.title}` }]"
|
|
23
|
-
:columns="Enumcolumn[subItem.mstrucId]" />
|
|
24
|
-
<wd-textarea auto-height v-if="subItem.extControlType === 'textarea'"
|
|
25
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
26
|
-
:prop="subItem.id" clearable v-model="model[subItem.id]"
|
|
27
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
28
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
29
|
-
<wd-input
|
|
30
|
-
v-if="subItem.extControlType === 'decimal' || subItem.extControlType === 'int'"
|
|
31
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
32
|
-
:prop="subItem.id" clearable v-model="model[subItem.id]" type="number"
|
|
33
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
34
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
35
|
-
<wd-calendar v-if="subItem.extControlType === 'datetime'" :disabled="subItem.disabled"
|
|
36
|
-
:label="subItem.title" label-width="100px" :prop="subItem.id" clearable
|
|
37
|
-
v-model="model[subItem.id]" type="datetime"
|
|
38
|
-
:placeholder="subItem.disabled ? '无需输入' : `请选择${subItem.title}`"
|
|
39
|
-
:rules="[{ required: subItem.required, message: `请选择${subItem.title}` }]" />
|
|
40
|
-
<wSelectPicker @confirm="wSelectPickerconfirm" :prop="subItem.id"
|
|
41
|
-
v-if="subItem.extControlType === 'relselect'" v-model="model[subItem.id]"
|
|
42
|
-
:disabled="subItem.disabled" :label="subItem.title" type="radio"
|
|
43
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
44
|
-
:source-id="subItem.sourceId" clearable filterable
|
|
45
|
-
:rules="[{ required: subItem.required, message: `请选择${subItem.title}` }]" />
|
|
46
|
-
</view>
|
|
47
|
-
|
|
13
|
+
<wFromControl :subItem="subItem" :model="model" :Enumcolumn="Enumcolumn" v-model:model-value="model[subItem.id]"/>
|
|
48
14
|
</wd-cell-group>
|
|
49
15
|
|
|
50
16
|
</wd-form>
|
|
@@ -68,42 +34,7 @@
|
|
|
68
34
|
</template>
|
|
69
35
|
<wd-form :ref="item.id" :model="PItem">
|
|
70
36
|
<wd-cell-group v-for="(subItem, subIndex) in item.fields" :key="subIndex">
|
|
71
|
-
<
|
|
72
|
-
<wd-input v-if="subItem.extControlType === 'text'" :disabled="subItem.disabled"
|
|
73
|
-
:label="subItem.title" label-width="100px" :prop="subItem.id" clearable
|
|
74
|
-
v-model="PItem[subItem.id]"
|
|
75
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
76
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
77
|
-
<wd-picker v-if="subItem.extControlType === 'select'"
|
|
78
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
79
|
-
:prop="subItem.id" clearable v-model="PItem[subItem.id]"
|
|
80
|
-
:placeholder="subItem.disabled ? '无需输入' : `请选择${subItem.title}`"
|
|
81
|
-
:rules="[{ required: subItem.required, message: `请选择${subItem.title}` }]"
|
|
82
|
-
:columns="Enumcolumn[subItem.mstrucId]" />
|
|
83
|
-
<wd-textarea auto-height v-if="subItem.extControlType === 'textarea'"
|
|
84
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
85
|
-
:prop="subItem.id" clearable v-model="PItem[subItem.id]"
|
|
86
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
87
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
88
|
-
<wd-input
|
|
89
|
-
v-if="subItem.extControlType === 'decimal' || subItem.extControlType === 'int'"
|
|
90
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
91
|
-
:prop="subItem.id" clearable v-model="model[subItem.id]" type="number"
|
|
92
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
93
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
94
|
-
<wd-calendar v-if="subItem.extControlType === 'datetime'"
|
|
95
|
-
:disabled="subItem.disabled" :label="subItem.title" label-width="100px"
|
|
96
|
-
:prop="subItem.id" clearable v-model="model[subItem.id]" type="number"
|
|
97
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
98
|
-
:rules="[{ required: subItem.required, message: `请填写${subItem.title}` }]" />
|
|
99
|
-
<wSelectPicker :prop="subItem.id" v-if="subItem.extControlType === 'relselect'"
|
|
100
|
-
v-model="model[subItem.id]" :disabled="subItem.disabled"
|
|
101
|
-
:label="subItem.title" type="radio"
|
|
102
|
-
:placeholder="subItem.disabled ? '无需输入' : `请输入${subItem.title}`"
|
|
103
|
-
:source-id="subItem.sourceId" clearable filterable
|
|
104
|
-
:rules="[{ required: subItem.required, message: `请选择${subItem.title}` }]" />
|
|
105
|
-
</view>
|
|
106
|
-
|
|
37
|
+
<wFromControl :subItem="subItem" :model="PItem" :Enumcolumn="Enumcolumn" v-model:model-value="PItem[subItem.id]"/>
|
|
107
38
|
</wd-cell-group>
|
|
108
39
|
|
|
109
40
|
</wd-form>
|
|
@@ -125,23 +56,14 @@
|
|
|
125
56
|
<view class="footer-button">
|
|
126
57
|
<wd-button block @click="handleSubmit" icon="save">保存</wd-button>
|
|
127
58
|
</view>
|
|
59
|
+
</view>
|
|
128
60
|
<wd-message-box />
|
|
129
|
-
<wd-popup safe-area-inset-bottom position="right" v-model="showSelectRow" custom-style="width: 100vw;">
|
|
130
|
-
<WSelectTable :sourceId="pointSourceId">
|
|
131
|
-
<template #close>
|
|
132
|
-
<view style="display: flex;justify-content: flex-end;">
|
|
133
|
-
<wd-button type="icon" icon="close" @click="showSelectRow = false"></wd-button>
|
|
134
|
-
</view>
|
|
135
|
-
|
|
136
|
-
</template>
|
|
137
|
-
</WSelectTable>
|
|
138
|
-
</wd-popup>
|
|
139
61
|
<wd-toast />
|
|
140
62
|
</view>
|
|
141
63
|
</template>
|
|
142
64
|
|
|
143
65
|
<script setup lang="ts">
|
|
144
|
-
import
|
|
66
|
+
import wFromControl from '../w-form-control/w-form-control.vue'
|
|
145
67
|
import WSelectTable from '../w-table/w-selectTable.vue';
|
|
146
68
|
import { onLoad } from '@dcloudio/uni-app'
|
|
147
69
|
import { ref, defineProps, reactive } from 'vue';
|
|
@@ -151,7 +73,6 @@ import {
|
|
|
151
73
|
addPageDataSave
|
|
152
74
|
} from '../utils/apis/pageConfig'
|
|
153
75
|
import { useMessage } from 'wot-design-uni'
|
|
154
|
-
import dayjs from 'dayjs/esm/index'
|
|
155
76
|
import { useToast } from 'wot-design-uni'
|
|
156
77
|
const toast = useToast()
|
|
157
78
|
const message = useMessage()
|
|
@@ -170,10 +91,12 @@ const pageConf = ref({ groups: [] })
|
|
|
170
91
|
const form = ref()//基本数据表单
|
|
171
92
|
//表单数据
|
|
172
93
|
const model = ref({})
|
|
94
|
+
const modelsRef={
|
|
95
|
+
|
|
96
|
+
}
|
|
173
97
|
const loading = ref(false)
|
|
174
98
|
const value = ref([])
|
|
175
99
|
const Enumcolumn = ref({})
|
|
176
|
-
const showSelectRow = ref(false)
|
|
177
100
|
const pointSourceId = ref('')
|
|
178
101
|
onLoad((option: any) => {
|
|
179
102
|
sourceId.value = props.sourceId || option.sourceId
|
|
@@ -197,6 +120,7 @@ function getPageConfig() {
|
|
|
197
120
|
relation[item.id] = t
|
|
198
121
|
}
|
|
199
122
|
if (item.type === 'fieldGroup') {
|
|
123
|
+
|
|
200
124
|
item.fields.forEach((subItem: any) => {
|
|
201
125
|
if (subItem.extControlType === 'datetime') {
|
|
202
126
|
fieldGroup[subItem.id] = null
|
|
@@ -232,20 +156,9 @@ async function getEnumer() {
|
|
|
232
156
|
Enumcolumn.value = res.data?.enumMap || {}
|
|
233
157
|
}
|
|
234
158
|
|
|
235
|
-
//wSelectPicker组件确定事件
|
|
236
|
-
const wSelectPickerconfirmData = ref([])//暂存wSelectPicker组件选中的数据
|
|
237
|
-
const wSelectPickerconfirm = (e) => {
|
|
238
|
-
console.log(e)
|
|
239
|
-
if (Array.isArray(e.selectedItems)) {
|
|
240
|
-
wSelectPickerconfirmData.value.push(...e.selectedItems)
|
|
241
|
-
} else {
|
|
242
|
-
wSelectPickerconfirmData.value.push(e.selectedItems)
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
159
|
|
|
246
160
|
//保存
|
|
247
161
|
async function handleSubmit() {
|
|
248
|
-
|
|
249
162
|
form.value[0]
|
|
250
163
|
.validate()
|
|
251
164
|
.then(async ({ valid, errors }) => {
|
|
@@ -254,27 +167,9 @@ async function handleSubmit() {
|
|
|
254
167
|
message: '保存中...',
|
|
255
168
|
duration: 0
|
|
256
169
|
})
|
|
257
|
-
|
|
258
|
-
pageConf.value.groups?.forEach((item: any) => {
|
|
259
|
-
item.fields?.forEach((subItem: any) => {
|
|
260
|
-
switch (subItem.extControlType) {
|
|
261
|
-
case 'relselect':
|
|
262
|
-
let t = wSelectPickerconfirmData.value.find((sItem: any) => {
|
|
263
|
-
return sItem.value === model.value[subItem.id]
|
|
264
|
-
})
|
|
265
|
-
newModel[subItem.id] = `${t.value}@R@${t.label}`
|
|
266
|
-
break
|
|
267
|
-
case 'datetime':
|
|
268
|
-
newModel[subItem.id] = model.value[subItem.id] ? dayjs(model.value[subItem.id]).format('YYYY-MM-DD HH:mm:ss') : ''
|
|
269
|
-
break
|
|
270
|
-
default:
|
|
271
|
-
newModel[subItem.id] = model.value[subItem.id]
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
});
|
|
275
|
-
console.log(newModel)
|
|
170
|
+
|
|
276
171
|
try {
|
|
277
|
-
const res = await addPageDataSave(sourceId.value,
|
|
172
|
+
const res = await addPageDataSave(sourceId.value, model.value)
|
|
278
173
|
if (res.data.status==='success'){
|
|
279
174
|
toast.success("保存成功")
|
|
280
175
|
uni.navigateBack()
|
|
@@ -298,7 +193,9 @@ async function handleSubmit() {
|
|
|
298
193
|
//选择数据
|
|
299
194
|
function selectrow(item: any) {
|
|
300
195
|
pointSourceId.value = item.pointSourceId
|
|
301
|
-
|
|
196
|
+
uni.navigateTo({
|
|
197
|
+
url: `/pages/selectTable/selectTable?sourceId=${pointSourceId.value}`
|
|
198
|
+
})
|
|
302
199
|
}
|
|
303
200
|
|
|
304
201
|
//新加一行
|
package/w-card/utils/utils.ts
CHANGED
|
@@ -1,107 +1,172 @@
|
|
|
1
1
|
const hydrocarbonProgramToken = uni.getStorageSync('hydrocarbonProgramToken') || ''
|
|
2
2
|
const token = uni.getStorageSync('token') || ''
|
|
3
|
-
|
|
3
|
+
const baseUrl = uni.getStorageSync('baseUrl') || '/'
|
|
4
4
|
// 单项数据转换
|
|
5
5
|
export function getValue(content: any, title: any): any {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return formatTime(content)
|
|
21
|
-
}
|
|
6
|
+
// 判断title 是否为字符串
|
|
7
|
+
if (typeof title === 'string') {
|
|
8
|
+
// 判断title 是否有 '时间'字符
|
|
9
|
+
if (title.includes('时间')) {
|
|
10
|
+
// 判断是否为数组
|
|
11
|
+
if (Array.isArray(content)) {
|
|
12
|
+
const newArr = content.map((item) => {
|
|
13
|
+
return formatTime(splitString(item))
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// 数组转换为字符串
|
|
17
|
+
return newArr.join(',')
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// 判断是否为数组
|
|
26
|
-
if (Array.isArray(content)) {
|
|
27
|
-
const newArr = content.map((item) => {
|
|
28
|
-
return splitString(item)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// 数组转换为字符串
|
|
32
|
-
return newArr.join(',')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 判断是否为JSON字符串
|
|
36
|
-
if (typeof content === 'string' && content.startsWith('{') && content.endsWith('}')) {
|
|
37
|
-
// 解析JSON字符串
|
|
38
|
-
const obj = JSON.parse(content)
|
|
39
|
-
|
|
40
|
-
// 图片链接
|
|
41
|
-
if (obj.base?.path && (obj.base?.type.includes('jpg') || obj.base?.type.includes('png')||obj.base?.type.includes('jpeg'))) {
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
45
|
-
type: '图片',
|
|
46
|
-
}
|
|
19
|
+
else {
|
|
20
|
+
return formatTime(content)
|
|
47
21
|
}
|
|
48
|
-
|
|
49
|
-
//文件链接
|
|
50
|
-
if (obj.base?.path && (obj.base?.type.includes('docx') )) {
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
54
|
-
name:obj.base.fileName,
|
|
55
|
-
type: '文件',
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
22
|
}
|
|
61
|
-
|
|
62
|
-
// 根据content中 "@R@" 分割字符串,取最后一项
|
|
63
|
-
return splitString(content)
|
|
64
23
|
}
|
|
65
24
|
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
25
|
+
// 判断是否为数组
|
|
26
|
+
if (Array.isArray(content)) {
|
|
27
|
+
const newArr = content.map((item) => {
|
|
28
|
+
return splitString(item)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// 数组转换为字符串
|
|
32
|
+
return newArr.join(',')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 判断是否为JSON字符串
|
|
36
|
+
if (typeof content === 'string' && content.startsWith('{') && content.endsWith('}')) {
|
|
37
|
+
// 解析JSON字符串
|
|
38
|
+
const obj = JSON.parse(content)
|
|
39
|
+
|
|
40
|
+
// 图片链接
|
|
41
|
+
if (obj.base?.path && (obj.base?.type.includes('jpg') || obj.base?.type.includes('png') || obj.base?.type.includes('jpeg'))) {
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
45
|
+
type: '图片',
|
|
46
|
+
}
|
|
72
47
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
48
|
+
|
|
49
|
+
//文件链接
|
|
50
|
+
if (obj.base?.path && (obj.base?.type.includes('docx')|| obj.base?.type.includes('txt'))) {
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
54
|
+
name: obj.base.fileName,
|
|
55
|
+
type: '文件',
|
|
81
56
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
57
|
+
}
|
|
58
|
+
//判断音频链接
|
|
59
|
+
if (obj.base?.path && (obj.base?.type.includes('wav'))) {
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
url: `${baseUrl}/v3/files${obj.base.path}?@token=${token}&@programToken=${hydrocarbonProgramToken}`,
|
|
63
|
+
name: obj.base.fileName,
|
|
64
|
+
type: '音频',
|
|
65
|
+
author:uni.getStorageSync('userInfo').name
|
|
85
66
|
}
|
|
86
67
|
}
|
|
87
|
-
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 根据content中 "@R@" 分割字符串,取最后一项
|
|
73
|
+
return splitString(content)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 根据 "@R@" 分割字符串,取最后一项
|
|
77
|
+
function splitString(str: string) {
|
|
78
|
+
// 判断是否为字符串类型
|
|
79
|
+
if (typeof str !== 'string') {
|
|
80
|
+
// 如果不是字符串类型,直接返回
|
|
88
81
|
return str
|
|
89
82
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
|
|
84
|
+
if (str) {
|
|
85
|
+
// 判断是否有 "@R@"
|
|
86
|
+
if (str.includes('@R@')) {
|
|
87
|
+
// 分割字符串
|
|
88
|
+
const splitStr = str.split('@R@')
|
|
89
|
+
// 返回分割后的数组的最后一项
|
|
90
|
+
return splitStr[splitStr.length - 1]
|
|
96
91
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// 格式化时间
|
|
101
|
-
function formatTime(str: string) {
|
|
102
|
-
if (typeof str === 'string') {
|
|
103
|
-
// 去掉小数点
|
|
104
|
-
return str.split('.')[0]
|
|
92
|
+
else {
|
|
93
|
+
// 返回原字符串
|
|
94
|
+
return str
|
|
105
95
|
}
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
}
|
|
97
|
+
// 返回原字符串
|
|
98
|
+
return str
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 判断字符串中是否存在'y'字符
|
|
102
|
+
export function hasY(str: string) {
|
|
103
|
+
// 判断是否为字符串
|
|
104
|
+
if (typeof str === 'string') {
|
|
105
|
+
return str.includes('y')
|
|
106
|
+
}
|
|
107
|
+
return false
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 格式化时间
|
|
111
|
+
function formatTime(str: string) {
|
|
112
|
+
if (typeof str === 'string') {
|
|
113
|
+
// 去掉小数点
|
|
114
|
+
return str.split('.')[0]
|
|
115
|
+
}
|
|
116
|
+
return str
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//下载文件
|
|
120
|
+
export const downloadFile = (url: any) => {
|
|
121
|
+
uni.downloadFile({
|
|
122
|
+
url: url, // 文件的网络地址
|
|
123
|
+
success: (res) => {
|
|
124
|
+
if (res.statusCode === 200) {
|
|
125
|
+
console.log('下载成功', res.tempFilePath);
|
|
126
|
+
// 打开文件(如PDF、Word等)
|
|
127
|
+
uni.openDocument({
|
|
128
|
+
filePath: res.tempFilePath,
|
|
129
|
+
showMenu: true,
|
|
130
|
+
success: () => console.log('打开文件成功')
|
|
131
|
+
});
|
|
132
|
+
// // 将临时文件保存到本地
|
|
133
|
+
// uni.saveFile({
|
|
134
|
+
// tempFilePath: res.tempFilePath,
|
|
135
|
+
// success: (saveRes) => {
|
|
136
|
+
// console.log('文件保存成功', saveRes.savedFilePath);
|
|
137
|
+
// const savedFilePath = saveRes.savedFilePath; // 保存后的路径
|
|
138
|
+
// // 打开文件(如PDF、Word等)
|
|
139
|
+
// uni.openDocument({
|
|
140
|
+
// filePath: savedFilePath,
|
|
141
|
+
// success: () => console.log('打开文件成功')
|
|
142
|
+
// });
|
|
143
|
+
// uni.showToast({
|
|
144
|
+
// title: '文件保存成功',
|
|
145
|
+
// icon: 'success'
|
|
146
|
+
// });
|
|
147
|
+
// },
|
|
148
|
+
// fail: (saveErr) => {
|
|
149
|
+
// console.error('文件保存失败', saveErr);
|
|
150
|
+
// uni.showToast({
|
|
151
|
+
// title: '文件保存失败',
|
|
152
|
+
// icon: 'none'
|
|
153
|
+
// });
|
|
154
|
+
// }
|
|
155
|
+
// });
|
|
156
|
+
} else {
|
|
157
|
+
console.error('下载失败', res);
|
|
158
|
+
uni.showToast({
|
|
159
|
+
title: '下载失败',
|
|
160
|
+
icon: 'none'
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
fail: (err) => {
|
|
165
|
+
console.error('下载失败', err);
|
|
166
|
+
uni.showToast({
|
|
167
|
+
title: '下载失败',
|
|
168
|
+
icon: 'none'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|