ddy-process-h5 1.0.1-beta.7 → 1.0.1-rc.1
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/README.md +466 -0
- package/package.json +1 -1
- package/v2/ddy-process-h5.js +2281 -2288
- package/v2/ddy-process-h5.umd.cjs +12 -12
- package/v2/style.css +1 -1
- package/v2.7/ddy-process-h5.js +2383 -2390
- package/v2.7/ddy-process-h5.umd.cjs +12 -12
- package/v2.7/style.css +1 -1
- package/v3/ddy-process-h5.js +2415 -2417
- package/v3/ddy-process-h5.umd.cjs +12 -12
- package/v3/style.css +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,472 @@
|
|
|
1
1
|
# ddy-process-h5
|
|
2
2
|
|
|
3
3
|
> App 端 流程、附件上传、附件列表、送审插件
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
## bladex 新流程用法
|
|
7
|
+
|
|
8
|
+
第1步:安装新流程插件:`npm install ddy-process-h5 -D`
|
|
9
|
+
|
|
10
|
+
第2步:修改接口请求的文件,比如request.js,获取bladex的token
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
// request.js
|
|
14
|
+
import axios from 'axios';
|
|
15
|
+
import errorCode from './errorCode';
|
|
16
|
+
import { tansParams } from './top';
|
|
17
|
+
import JSONbig from "json-bigint";
|
|
18
|
+
import { checkIsAppleDevice ,checkIsHarmonyOS } from './common.js'
|
|
19
|
+
|
|
20
|
+
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8';
|
|
21
|
+
const opts = {
|
|
22
|
+
baseURL: '/' + process.env.VUE_APP_BASE_API,
|
|
23
|
+
timeout: 999999999,
|
|
24
|
+
errorTip: true,
|
|
25
|
+
transformResponse: [function (data) {
|
|
26
|
+
if (typeof data === 'string') {
|
|
27
|
+
try {
|
|
28
|
+
data = JSONbig.parse(data);
|
|
29
|
+
} catch (e) { console.log(e) }
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
opts.headers = {
|
|
35
|
+
'X-Tag': process.env.VUE_APP_TAG
|
|
36
|
+
};
|
|
37
|
+
const service = axios.create(opts);
|
|
38
|
+
|
|
39
|
+
// 🆘获取bladex token
|
|
40
|
+
const loginByToken = (grant_type = 'top_token', Authorization = 'Basic c2FiZXIzOnNhYmVyM19zZWNyZXQ=') => {
|
|
41
|
+
return service({
|
|
42
|
+
url: '/bladex/blade-auth/oauth/token',
|
|
43
|
+
method: 'post',
|
|
44
|
+
headers: {
|
|
45
|
+
// 'blade-auth': '',
|
|
46
|
+
'Authorization': Authorization,
|
|
47
|
+
},
|
|
48
|
+
params: {
|
|
49
|
+
grant_type: grant_type,
|
|
50
|
+
top_token: uni.getStorageSync('token'),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
service.interceptors.request.use(
|
|
56
|
+
async (config) => {
|
|
57
|
+
// const isToken = (config.headers || {}).isToken === false;
|
|
58
|
+
// if (getToken() && !isToken) {
|
|
59
|
+
// config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
60
|
+
// }
|
|
61
|
+
let advice = ''
|
|
62
|
+
if (checkIsAppleDevice()) {
|
|
63
|
+
advice = 3;
|
|
64
|
+
} else if (checkIsHarmonyOS()) {
|
|
65
|
+
advice = 4;
|
|
66
|
+
} else {
|
|
67
|
+
advice = 2;
|
|
68
|
+
}
|
|
69
|
+
/* 请求之前拦截器。可以使用async await 做异步操作 */
|
|
70
|
+
let token = uni.getStorageSync('token');
|
|
71
|
+
console.log('token',token)
|
|
72
|
+
// 🆘bladex token接口,做一下拦截
|
|
73
|
+
if (config.url.includes('/blade-auth/oauth/token')) {
|
|
74
|
+
return config
|
|
75
|
+
}
|
|
76
|
+
if (config.url === '/auth/login') {
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
// 🆘非bladex接口,做一下拦截
|
|
80
|
+
// console.log(config.url, 'config', config.url.includes('/bladex/'))
|
|
81
|
+
if (!config.url.includes('/bladex/')) {
|
|
82
|
+
|
|
83
|
+
config.headers['advice'] = advice;
|
|
84
|
+
config.headers['Authorization'] = 'Bearer ' + token; // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
85
|
+
config.headers['subjectId'] = uni.getStorageSync('subjectId')
|
|
86
|
+
config.errorTip = config.params?.errorTip != undefined || !config.data?.errorTip ? config.params?.errorTip || config.data?.errorTip : true
|
|
87
|
+
|
|
88
|
+
if (config.method === 'get' && config.params) {
|
|
89
|
+
let url = config.url + '?' + tansParams(config.params);
|
|
90
|
+
url = url.slice(0, -1);
|
|
91
|
+
config.params = {};
|
|
92
|
+
config.url = url;
|
|
93
|
+
}
|
|
94
|
+
return config;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 🆘新流程bladex的接口
|
|
98
|
+
const tokenv2 = localStorage.getItem('tokenv2');
|
|
99
|
+
// console.log(config.url, tokenv2, 'tokenv2')
|
|
100
|
+
config.headers['blade-requested-with'] = 'BladeHttpRequest'
|
|
101
|
+
config.headers['Authorization'] = 'Basic c2FiZXIzOnNhYmVyM19zZWNyZXQ='
|
|
102
|
+
if (false && tokenv2) {
|
|
103
|
+
config.headers['blade-auth'] = 'bearer ' + tokenv2;
|
|
104
|
+
} else {
|
|
105
|
+
const myToken = await loginByToken();
|
|
106
|
+
// console.log(myToken.access_token, 'my')
|
|
107
|
+
localStorage.setItem('tokenv2', (myToken || {}).access_token);
|
|
108
|
+
config.headers['blade-auth'] = 'bearer ' + myToken.access_token;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return config;
|
|
112
|
+
},
|
|
113
|
+
(error) => {
|
|
114
|
+
Promise.reject(error);
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// 响应拦截器
|
|
119
|
+
service.interceptors.response.use(
|
|
120
|
+
(response) => {
|
|
121
|
+
if (Object.prototype.toString.call(response.data) === '[object Blob]') {
|
|
122
|
+
return response;
|
|
123
|
+
}
|
|
124
|
+
const { data, config } = response;
|
|
125
|
+
let code;
|
|
126
|
+
let success
|
|
127
|
+
// 🆘兼容bladex的返回结果,top-ui和bladex项目的返回结构不一致,需要处理
|
|
128
|
+
if (response.data.code) {
|
|
129
|
+
code = data.code
|
|
130
|
+
success = data.success
|
|
131
|
+
} else {
|
|
132
|
+
code = response.status
|
|
133
|
+
success = code == 200 ? true : false
|
|
134
|
+
}
|
|
135
|
+
const message = response.data.msg || errorCode[code] || errorCode['default'];
|
|
136
|
+
// 增加失败判断
|
|
137
|
+
data.fail = code !== 200 && success !== true;
|
|
138
|
+
|
|
139
|
+
if (code === 401) {
|
|
140
|
+
uni.showToast({
|
|
141
|
+
icon: 'none',
|
|
142
|
+
title: '请退出后重新打开'
|
|
143
|
+
});
|
|
144
|
+
return data;
|
|
145
|
+
} else if (code !== 200 && code !== '0' && config.errorTip) {
|
|
146
|
+
|
|
147
|
+
uni.showToast({
|
|
148
|
+
icon: 'none',
|
|
149
|
+
title: message
|
|
150
|
+
});
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
return data;
|
|
154
|
+
},
|
|
155
|
+
(error) => {
|
|
156
|
+
let { message, response } = error;
|
|
157
|
+
// 🆘bladex错误拦截处理,top-ui和bladex项目的返回结构不一致,需要处理
|
|
158
|
+
if (response && response.data && (response.data.message || response.data.msg)) {
|
|
159
|
+
message = response.data.message || response.data.msg
|
|
160
|
+
} else if (message === 'Network Error') {
|
|
161
|
+
message = '后端接口连接异常';
|
|
162
|
+
} else if (message.includes('timeout')) {
|
|
163
|
+
message = '系统接口请求超时';
|
|
164
|
+
} else if (message.includes('Request failed with status code')) {
|
|
165
|
+
message = '系统接口' + message.substr(message.length - 3) + '异常';
|
|
166
|
+
}
|
|
167
|
+
uni.showToast({
|
|
168
|
+
icon: 'none',
|
|
169
|
+
title: message
|
|
170
|
+
});
|
|
171
|
+
// if (config.errorTip) {
|
|
172
|
+
// Message({
|
|
173
|
+
// message: message,
|
|
174
|
+
// type: 'error',
|
|
175
|
+
// duration: 5 * 1000
|
|
176
|
+
// });
|
|
177
|
+
// }
|
|
178
|
+
return Promise.reject(error);
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
export default service;
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
第3步:引入组件,对于发起和审批流程,应该也和以前一致,只需要替换包名即可
|
|
187
|
+
|
|
188
|
+
```vue
|
|
189
|
+
<template>
|
|
190
|
+
<TopProcess
|
|
191
|
+
:processInstId="formData.processInstId"
|
|
192
|
+
:processDefId="formData.processDefId"
|
|
193
|
+
:formData="formData"
|
|
194
|
+
:appId="appId"
|
|
195
|
+
:uid="formData.uid"
|
|
196
|
+
:request="request"
|
|
197
|
+
:tapList="tapList"
|
|
198
|
+
:endFunction="endFunction"
|
|
199
|
+
:beforeFunction="beforeFunction"
|
|
200
|
+
:restartData="restartData"
|
|
201
|
+
:selfBtn="selfBtn"
|
|
202
|
+
:isQuickReply="true"
|
|
203
|
+
:isMsg="true"
|
|
204
|
+
:isView="false"
|
|
205
|
+
:isRequire="true"
|
|
206
|
+
>
|
|
207
|
+
<!-- :isDocument="true" -->
|
|
208
|
+
<!-- :isAdditional="true" -->
|
|
209
|
+
<!-- :getVars="getVars" -->
|
|
210
|
+
<template #default>
|
|
211
|
+
<div>
|
|
212
|
+
<!-- 操作按钮 -->
|
|
213
|
+
<button @click="onSubmit" class="btns-common cmf-btn">提交</button>
|
|
214
|
+
<TopSumbitPopup :visible.sync="actionVisible" ref="actionPop" :request="request" :businessSubjectId="formData.subjectId" :businessDeptId="formData.deptId"
|
|
215
|
+
appId="com.awspaas.user.apps.leave" :id="processBusinessKey" :businessType="businessType" :isSelectFirst="false"
|
|
216
|
+
:todoParameter="todoParameter" :title="title" :resubmit="resubmit" :extraParams="{...formData, ...vars, businessDeptId: formData.deptId}"
|
|
217
|
+
:beforeFunction="saveFn" :manual="true" @successFn="back"></TopSumbitPopup>
|
|
218
|
+
</div>
|
|
219
|
+
</template>
|
|
220
|
+
<template #attch>attch</template>
|
|
221
|
+
<template #fsList>fsList</template>
|
|
222
|
+
<template #documentPage>documentPage</template>
|
|
223
|
+
<!-- <template #completeSlot>completeSlot</template> -->
|
|
224
|
+
<template v-slot:btn="data">
|
|
225
|
+
<div>123{{ data.data.status }}</div>
|
|
226
|
+
</template>
|
|
227
|
+
</TopProcess>
|
|
228
|
+
</template>
|
|
229
|
+
<script>
|
|
230
|
+
import { TopProcess, TopSumbitPopup } from "@/packages/index.js";
|
|
231
|
+
import request from "@/assets/js/request";
|
|
232
|
+
import { defineComponent } from "vue-demi";
|
|
233
|
+
import { setToken, setSubject, setProject } from "@/assets/js/auth";
|
|
234
|
+
// import departPerson from "@/packages/checked-pick-app";
|
|
235
|
+
// import { TopProcess } from "ddy-process-h5";
|
|
236
|
+
export default {
|
|
237
|
+
data() {
|
|
238
|
+
return {
|
|
239
|
+
// http://localhost:1027/#/pages/apply/ask-for-leave/process?token=536d5915-762c-4689-81b6-78c6291799b3&subjectId=9f13a9c9c400fa6e6228848ce1f131ee&bizId=70364f045d17457f8145841da5d4a63c
|
|
240
|
+
actionVisible: false,
|
|
241
|
+
businessType: '9',
|
|
242
|
+
processBusinessKey: '',
|
|
243
|
+
todoParameter: {},
|
|
244
|
+
title: '请假申请',
|
|
245
|
+
// 是否重新提交
|
|
246
|
+
resubmit: false,
|
|
247
|
+
vars: {
|
|
248
|
+
title: '陈松松' + '发起了日常请假,请你审批',
|
|
249
|
+
name: '请假申请',
|
|
250
|
+
businessType: '9',
|
|
251
|
+
deptId: '',
|
|
252
|
+
},
|
|
253
|
+
formData: {
|
|
254
|
+
deptId: '',
|
|
255
|
+
businessKey: "74efb9a48dc176806e1185b8ce9845e8",
|
|
256
|
+
processInstId: "bladex-ad12dd3e-7757-11f0-97a7-000c291b8d5e",
|
|
257
|
+
processDefId: "obj_5402fe691cad48b3ae39da0699d53be1",
|
|
258
|
+
title: "测试",
|
|
259
|
+
subjectId: "3a4ef115e32c85a78239e3f5f76b9637",
|
|
260
|
+
tel: "15107910151",
|
|
261
|
+
userId: "8c7d012761a680dff78b19e10e794c99",
|
|
262
|
+
userName: "刘博文",
|
|
263
|
+
uid: "3712fea770669effdf95ac56c6f1f846",
|
|
264
|
+
},
|
|
265
|
+
appId: "com.awspaas.user.apps.recevie.document",
|
|
266
|
+
isView: false,
|
|
267
|
+
info: {},
|
|
268
|
+
bizId: "",
|
|
269
|
+
style: {
|
|
270
|
+
color: "#333",
|
|
271
|
+
disableColor: "#F7F6F6",
|
|
272
|
+
},
|
|
273
|
+
param: {
|
|
274
|
+
realStartTime: "",
|
|
275
|
+
realEndTime: "",
|
|
276
|
+
estimateHours: 0,
|
|
277
|
+
estimateMinutes: 0,
|
|
278
|
+
},
|
|
279
|
+
realDays: "",
|
|
280
|
+
timeLoading: false,
|
|
281
|
+
processIDS: "",
|
|
282
|
+
request: request,
|
|
283
|
+
// 选人组件
|
|
284
|
+
visible: false,
|
|
285
|
+
entity: {
|
|
286
|
+
source: "0",
|
|
287
|
+
type: "5",
|
|
288
|
+
request: this.request, //'http://59.53.91.231:2100' 0002
|
|
289
|
+
businessId: "0003",
|
|
290
|
+
codeType: [1, 2, 3], // 可选类型 1-主体 2-部门 3-人员
|
|
291
|
+
multiple: true, // 是否多选
|
|
292
|
+
},
|
|
293
|
+
tapList: [
|
|
294
|
+
{
|
|
295
|
+
label: "附件",
|
|
296
|
+
key: "attch",
|
|
297
|
+
type: "slot",
|
|
298
|
+
sort: 2,
|
|
299
|
+
slot: "attch",
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
label: "分送记录",
|
|
303
|
+
key: "fsList",
|
|
304
|
+
type: "slot",
|
|
305
|
+
slot: "fsList",
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
label: "正文",
|
|
309
|
+
key: "documentPage",
|
|
310
|
+
type: "slot",
|
|
311
|
+
sort: 3,
|
|
312
|
+
slot: "documentPage",
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
restartData: {
|
|
316
|
+
businessType: "4",
|
|
317
|
+
title: "测试送审",
|
|
318
|
+
showType: "all",
|
|
319
|
+
processName: "",
|
|
320
|
+
},
|
|
321
|
+
selfBtn: [
|
|
322
|
+
{
|
|
323
|
+
name: "测试",
|
|
324
|
+
type: "danger",
|
|
325
|
+
click: () => {
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "测试2",
|
|
330
|
+
type: "default",
|
|
331
|
+
click: () => {
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
userData: false,
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
components: {
|
|
339
|
+
TopSumbitPopup,
|
|
340
|
+
/* topProcess, */
|
|
341
|
+
TopProcess,
|
|
342
|
+
// departPerson,
|
|
343
|
+
},
|
|
344
|
+
onLoad(e) {
|
|
345
|
+
this.bizId = e.bizId;
|
|
346
|
+
this.getInfo();
|
|
347
|
+
|
|
348
|
+
this.processIDS = e.processId;
|
|
349
|
+
},
|
|
350
|
+
mounted() {
|
|
351
|
+
setToken("37538643-c934-4563-946f-d6dbc7f13388");
|
|
352
|
+
// 7369abf4-e2b4-44d0-87b2-7c46a444d3b5
|
|
353
|
+
// da6bab4f-fa42-4730-b0fe-c5e022123c0c
|
|
354
|
+
setSubject("9f13a9c9c400fa6e6228848ce1f131ee");
|
|
355
|
+
/* setProject("4b23dd7dcb9cf7cb548fbd087ce9d748"); */
|
|
356
|
+
|
|
357
|
+
console.log(this.request, 'res')
|
|
358
|
+
this.entity.request = this.request
|
|
359
|
+
|
|
360
|
+
},
|
|
361
|
+
methods: {
|
|
362
|
+
// 回调
|
|
363
|
+
handleCallback(data) {
|
|
364
|
+
console.log(data, 'data')
|
|
365
|
+
},
|
|
366
|
+
// 发起流程
|
|
367
|
+
onSubmit() {
|
|
368
|
+
this.actionVisible = true
|
|
369
|
+
},
|
|
370
|
+
// 保存
|
|
371
|
+
saveFn() {
|
|
372
|
+
// this.processBusinessKey = data.businessKey
|
|
373
|
+
// this.title = data.title
|
|
374
|
+
// this.businessType = data.businessType
|
|
375
|
+
this.$nextTick(() => {
|
|
376
|
+
this.$refs.actionPop.handleSongshen()
|
|
377
|
+
})
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
// 流程完成后 回调
|
|
381
|
+
back() {
|
|
382
|
+
console.log('back')
|
|
383
|
+
},
|
|
384
|
+
// 发起流程
|
|
385
|
+
getVars() {
|
|
386
|
+
return true;
|
|
387
|
+
},
|
|
388
|
+
endFunction(val) {
|
|
389
|
+
/* location.reload(); */
|
|
390
|
+
},
|
|
391
|
+
async beforeFunction() {
|
|
392
|
+
let res = await this.request.get("/app/user/info");
|
|
393
|
+
if (res.code === 200) {
|
|
394
|
+
return true
|
|
395
|
+
} else {
|
|
396
|
+
return false
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// return false
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
};
|
|
403
|
+
</script>
|
|
404
|
+
<style lang="scss">
|
|
405
|
+
* {
|
|
406
|
+
margin: 0;
|
|
407
|
+
padding: 0;
|
|
408
|
+
}
|
|
409
|
+
#app {
|
|
410
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
411
|
+
-webkit-font-smoothing: antialiased;
|
|
412
|
+
-moz-osx-font-smoothing: grayscale;
|
|
413
|
+
text-align: center;
|
|
414
|
+
color: #2c3e50;
|
|
415
|
+
width: 100vw;
|
|
416
|
+
height: 100vh;
|
|
417
|
+
}
|
|
418
|
+
.info-box {
|
|
419
|
+
background-color: #fff;
|
|
420
|
+
padding: 10px;
|
|
421
|
+
.info {
|
|
422
|
+
display: flex;
|
|
423
|
+
justify-content: space-between;
|
|
424
|
+
font-size: 14px;
|
|
425
|
+
margin-bottom: 10px;
|
|
426
|
+
b {
|
|
427
|
+
font-weight: 400;
|
|
428
|
+
color: #959595;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
.time-info {
|
|
432
|
+
background-color: #f6f6f6;
|
|
433
|
+
padding: 10px;
|
|
434
|
+
border-radius: 10px;
|
|
435
|
+
margin-bottom: 10px;
|
|
436
|
+
div {
|
|
437
|
+
margin-bottom: 10px;
|
|
438
|
+
font-size: 14px;
|
|
439
|
+
display: flex;
|
|
440
|
+
justify-content: space-between;
|
|
441
|
+
i {
|
|
442
|
+
color: #000;
|
|
443
|
+
font-style: normal;
|
|
444
|
+
font-weight: bold;
|
|
445
|
+
}
|
|
446
|
+
em {
|
|
447
|
+
font-style: normal;
|
|
448
|
+
font-size: 12px;
|
|
449
|
+
color: #4e87d4;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
::v-deep .uni-date-x--border {
|
|
455
|
+
border: none;
|
|
456
|
+
}
|
|
457
|
+
em {
|
|
458
|
+
font-style: normal;
|
|
459
|
+
font-size: 12px;
|
|
460
|
+
color: #4e87d4;
|
|
461
|
+
}
|
|
462
|
+
.ren-title {
|
|
463
|
+
font-weight: bold;
|
|
464
|
+
font-size: 16px;
|
|
465
|
+
margin-bottom: 18px;
|
|
466
|
+
}
|
|
467
|
+
</style>
|
|
468
|
+
|
|
469
|
+
```
|
|
4
470
|
|
|
5
471
|
## 安装
|
|
6
472
|
|