vue2-client 1.17.35 → 1.17.37

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,215 +1,215 @@
1
- import { getSystemVersion, METHOD, request } from '@vue2-client/utils/request'
2
- import { ACCESS_TOKEN, V4_ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
3
-
4
- /**
5
- * GET请求
6
- * @param url 请求地址
7
- * @param parameter 路径参数
8
- * @returns {Promise<AxiosResponse<T>>}
9
- */
10
- function get (url, parameter) {
11
- return request(url, METHOD.GET, parameter)
12
- }
13
-
14
- /**
15
- * POST请求
16
- * @param url 请求地址
17
- * @param parameter 请求参数
18
- * @param config
19
- * @returns {Promise<AxiosResponse<T>>}
20
- */
21
- function post (url, parameter, config = {}) {
22
- return request(url, METHOD.POST, parameter, config)
23
- }
24
-
25
- /**
26
- * POST请求
27
- * @param url 请求地址
28
- * @param parameter 请求参数
29
- * @param serviceName
30
- * @param isDev
31
- * @param config
32
- * @returns {Promise<AxiosResponse<T>>}
33
- */
34
- function postByServiceName (url, parameter, serviceName = process.env.VUE_APP_SYSTEM_NAME, isDev, config = {}) {
35
- if (url.startsWith('api/') || url.startsWith('/api/')) {
36
- return request(url, METHOD.POST, parameter, config)
37
- }
38
- let apiPre = '/api/'
39
- if (isDev) {
40
- apiPre = '/devApi/'
41
- }
42
- if (!url.startsWith('/')) {
43
- url = '/' + url
44
- }
45
- url = apiPre + serviceName + url
46
- return request(url, METHOD.POST, parameter, config)
47
- }
48
-
49
- /**
50
- * DELETE请求
51
- * @param url 请求地址
52
- * @param parameter 请求参数
53
- * @param config
54
- * @returns {Promise<AxiosResponse<T>>}
55
- */
56
- function del (url, parameter, config = {}) {
57
- return request(url, METHOD.DELETE, parameter, config)
58
- }
59
-
60
- /**
61
- * PUT请求
62
- * @param url 请求地址
63
- * @param parameter 请求参数
64
- * @param config
65
- * @returns {Promise<AxiosResponse<T>>}
66
- */
67
- function put (url, parameter, config = {}) {
68
- return request(url, METHOD.PUT, parameter, config)
69
- }
70
-
71
- /**
72
- * 封装 EventSource 请求函数
73
- * @param {string} url - 请求地址
74
- * @param {Object} options - 请求选项(包括 method, headers, body 等)
75
- * @param {Function} onDataUpdate - 数据更新回调,每次接收到新的数据都会调用
76
- * @param {Function} onError - 错误处理回调
77
- * @returns {Function} - 用于取消请求的函数
78
- */
79
- function startEventStreamPOST (url, params, headers = {}, onDataUpdate, onError, serviceName = process.env.VUE_APP_SYSTEM_NAME, method = 'GET') {
80
- return startEventStream(url, params, headers, onDataUpdate, onError, serviceName, 'POST')
81
- }
82
- function startEventStream (url, params, headers = {}, onDataUpdate, onError, serviceName = process.env.VUE_APP_SYSTEM_NAME, method = 'GET') {
83
- // let isStopped = false
84
- let isStopped = false
85
- let requestCount = 0
86
-
87
- if (!(url.startsWith('api/') || url.startsWith('/api/') || url.startsWith('http'))) {
88
- if (!url.startsWith('/')) {
89
- url = '/' + url
90
- }
91
- url = '/api/' + serviceName + url
92
- }
93
-
94
- console.log(`[EventStream] 开始新的请求: ${url}`, {
95
- params,
96
- headers,
97
- method
98
- })
99
-
100
- const controller = new AbortController()
101
- const { signal } = controller
102
- const token = localStorage.getItem(ACCESS_TOKEN)
103
- // 增加 V4 登录请求头
104
- if (token) {
105
- const compatible = getSystemVersion()
106
- if (compatible === 'V4') {
107
- // V4 环境则添加 V4请求头
108
- headers[V4_ACCESS_TOKEN] = token
109
- } else {
110
- headers[ACCESS_TOKEN] = token
111
- }
112
- }
113
- fetch(url, {
114
- method: method,
115
- headers: {
116
- ...headers,
117
- Accept: 'text/event-stream',
118
- 'Cache-Control': 'no-cache',
119
- Connection: 'keep-alive'
120
- },
121
- body: JSON.stringify(params),
122
- signal
123
- }).then(response => {
124
- if (!response.ok) {
125
- throw new Error(`HTTP error! status: ${response.status}`)
126
- }
127
-
128
- requestCount++
129
- console.log(`[EventStream] 请求已打开 (第${requestCount}次): ${url}`, {
130
- status: response.status,
131
- statusText: response.statusText
132
- })
133
-
134
- const reader = response.body.getReader()
135
- const decoder = new TextDecoder()
136
- let buffer = ''
137
-
138
- function processStream () {
139
- if (isStopped) {
140
- console.log(`[EventStream] 请求已停止,停止读取流: ${url}`)
141
- return
142
- }
143
-
144
- reader.read().then(({ done, value }) => {
145
- if (done) {
146
- console.log(`[EventStream] 流读取完成: ${url}`)
147
- return
148
- }
149
-
150
- const chunk = decoder.decode(value, { stream: true })
151
- buffer += chunk
152
-
153
- // 处理接收到的数据
154
- const lines = buffer.split('\n')
155
- buffer = lines.pop() // 保留最后一个不完整的行
156
-
157
- let currentEvent = null
158
- let currentData = null
159
-
160
- for (const line of lines) {
161
- if (line.startsWith('event: ')) {
162
- currentEvent = line.slice(7)
163
- } else if (line.startsWith('data: ')) {
164
- currentData = line.slice(6)
165
- try {
166
- const parsedData = JSON.parse(currentData)
167
- if (currentEvent === 'additionalInfo') {
168
- // 触发 additionalInfo 回调
169
- onDataUpdate?.(parsedData, 'additionalInfo')
170
- } else {
171
- // 普通消息数据
172
- onDataUpdate?.(parsedData, 'sourceInfo')
173
- }
174
- } catch (e) {
175
- if (currentEvent === 'sourceInfo') {
176
- // 触发 sourceInfo 回调
177
- onDataUpdate?.(currentData, 'sourceInfo')
178
- } else {
179
- onDataUpdate?.(currentData, 'data')
180
- }
181
- }
182
- // 重置当前事件和数据
183
- currentEvent = null
184
- currentData = null
185
- }
186
- }
187
-
188
- processStream()
189
- }).catch(error => {
190
- console.error(`[EventStream] 流读取错误: ${url}`, error)
191
- if (!isStopped) {
192
- isStopped = true
193
- onError?.(error)
194
- }
195
- })
196
- }
197
-
198
- processStream()
199
- }).catch(error => {
200
- console.error(`[EventStream] 请求错误: ${url}`, error)
201
- if (!isStopped) {
202
- isStopped = true
203
- onError?.(error)
204
- }
205
- })
206
-
207
- // 返回停止函数
208
- return () => {
209
- isStopped = true
210
- controller.abort()
211
- console.log('连接已关闭')
212
- }
213
- }
214
-
215
- export { get, post, del, put, postByServiceName, startEventStream, startEventStreamPOST }
1
+ import { getSystemVersion, METHOD, request } from '@vue2-client/utils/request'
2
+ import { ACCESS_TOKEN, V4_ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
3
+
4
+ /**
5
+ * GET请求
6
+ * @param url 请求地址
7
+ * @param parameter 路径参数
8
+ * @returns {Promise<AxiosResponse<T>>}
9
+ */
10
+ function get (url, parameter) {
11
+ return request(url, METHOD.GET, parameter)
12
+ }
13
+
14
+ /**
15
+ * POST请求
16
+ * @param url 请求地址
17
+ * @param parameter 请求参数
18
+ * @param config
19
+ * @returns {Promise<AxiosResponse<T>>}
20
+ */
21
+ function post (url, parameter, config = {}) {
22
+ return request(url, METHOD.POST, parameter, config)
23
+ }
24
+
25
+ /**
26
+ * POST请求
27
+ * @param url 请求地址
28
+ * @param parameter 请求参数
29
+ * @param serviceName
30
+ * @param isDev
31
+ * @param config
32
+ * @returns {Promise<AxiosResponse<T>>}
33
+ */
34
+ function postByServiceName (url, parameter, serviceName = process.env.VUE_APP_SYSTEM_NAME, isDev, config = {}) {
35
+ if (url.startsWith('api/') || url.startsWith('/api/')) {
36
+ return request(url, METHOD.POST, parameter, config)
37
+ }
38
+ let apiPre = '/api/'
39
+ if (isDev) {
40
+ apiPre = '/devApi/'
41
+ }
42
+ if (!url.startsWith('/')) {
43
+ url = '/' + url
44
+ }
45
+ url = apiPre + serviceName + url
46
+ return request(url, METHOD.POST, parameter, config)
47
+ }
48
+
49
+ /**
50
+ * DELETE请求
51
+ * @param url 请求地址
52
+ * @param parameter 请求参数
53
+ * @param config
54
+ * @returns {Promise<AxiosResponse<T>>}
55
+ */
56
+ function del (url, parameter, config = {}) {
57
+ return request(url, METHOD.DELETE, parameter, config)
58
+ }
59
+
60
+ /**
61
+ * PUT请求
62
+ * @param url 请求地址
63
+ * @param parameter 请求参数
64
+ * @param config
65
+ * @returns {Promise<AxiosResponse<T>>}
66
+ */
67
+ function put (url, parameter, config = {}) {
68
+ return request(url, METHOD.PUT, parameter, config)
69
+ }
70
+
71
+ /**
72
+ * 封装 EventSource 请求函数
73
+ * @param {string} url - 请求地址
74
+ * @param {Object} options - 请求选项(包括 method, headers, body 等)
75
+ * @param {Function} onDataUpdate - 数据更新回调,每次接收到新的数据都会调用
76
+ * @param {Function} onError - 错误处理回调
77
+ * @returns {Function} - 用于取消请求的函数
78
+ */
79
+ function startEventStreamPOST (url, params, headers = {}, onDataUpdate, onError, serviceName = process.env.VUE_APP_SYSTEM_NAME, method = 'GET') {
80
+ return startEventStream(url, params, headers, onDataUpdate, onError, serviceName, 'POST')
81
+ }
82
+ function startEventStream (url, params, headers = {}, onDataUpdate, onError, serviceName = process.env.VUE_APP_SYSTEM_NAME, method = 'GET') {
83
+ // let isStopped = false
84
+ let isStopped = false
85
+ let requestCount = 0
86
+
87
+ if (!(url.startsWith('api/') || url.startsWith('/api/') || url.startsWith('http'))) {
88
+ if (!url.startsWith('/')) {
89
+ url = '/' + url
90
+ }
91
+ url = '/api/' + serviceName + url
92
+ }
93
+
94
+ console.log(`[EventStream] 开始新的请求: ${url}`, {
95
+ params,
96
+ headers,
97
+ method
98
+ })
99
+
100
+ const controller = new AbortController()
101
+ const { signal } = controller
102
+ const token = localStorage.getItem(ACCESS_TOKEN)
103
+ // 增加 V4 登录请求头
104
+ if (token) {
105
+ const compatible = getSystemVersion()
106
+ if (compatible === 'V4') {
107
+ // V4 环境则添加 V4请求头
108
+ headers[V4_ACCESS_TOKEN] = token
109
+ } else {
110
+ headers[ACCESS_TOKEN] = token
111
+ }
112
+ }
113
+ fetch(url, {
114
+ method: method,
115
+ headers: {
116
+ ...headers,
117
+ Accept: 'text/event-stream',
118
+ 'Cache-Control': 'no-cache',
119
+ Connection: 'keep-alive'
120
+ },
121
+ body: JSON.stringify(params),
122
+ signal
123
+ }).then(response => {
124
+ if (!response.ok) {
125
+ throw new Error(`HTTP error! status: ${response.status}`)
126
+ }
127
+
128
+ requestCount++
129
+ console.log(`[EventStream] 请求已打开 (第${requestCount}次): ${url}`, {
130
+ status: response.status,
131
+ statusText: response.statusText
132
+ })
133
+
134
+ const reader = response.body.getReader()
135
+ const decoder = new TextDecoder()
136
+ let buffer = ''
137
+
138
+ function processStream () {
139
+ if (isStopped) {
140
+ console.log(`[EventStream] 请求已停止,停止读取流: ${url}`)
141
+ return
142
+ }
143
+
144
+ reader.read().then(({ done, value }) => {
145
+ if (done) {
146
+ console.log(`[EventStream] 流读取完成: ${url}`)
147
+ return
148
+ }
149
+
150
+ const chunk = decoder.decode(value, { stream: true })
151
+ buffer += chunk
152
+
153
+ // 处理接收到的数据
154
+ const lines = buffer.split('\n')
155
+ buffer = lines.pop() // 保留最后一个不完整的行
156
+
157
+ let currentEvent = null
158
+ let currentData = null
159
+
160
+ for (const line of lines) {
161
+ if (line.startsWith('event: ')) {
162
+ currentEvent = line.slice(7)
163
+ } else if (line.startsWith('data: ')) {
164
+ currentData = line.slice(6)
165
+ try {
166
+ const parsedData = JSON.parse(currentData)
167
+ if (currentEvent === 'additionalInfo') {
168
+ // 触发 additionalInfo 回调
169
+ onDataUpdate?.(parsedData, 'additionalInfo')
170
+ } else {
171
+ // 普通消息数据
172
+ onDataUpdate?.(parsedData, 'sourceInfo')
173
+ }
174
+ } catch (e) {
175
+ if (currentEvent === 'sourceInfo') {
176
+ // 触发 sourceInfo 回调
177
+ onDataUpdate?.(currentData, 'sourceInfo')
178
+ } else {
179
+ onDataUpdate?.(currentData, 'data')
180
+ }
181
+ }
182
+ // 重置当前事件和数据
183
+ currentEvent = null
184
+ currentData = null
185
+ }
186
+ }
187
+
188
+ processStream()
189
+ }).catch(error => {
190
+ console.error(`[EventStream] 流读取错误: ${url}`, error)
191
+ if (!isStopped) {
192
+ isStopped = true
193
+ onError?.(error)
194
+ }
195
+ })
196
+ }
197
+
198
+ processStream()
199
+ }).catch(error => {
200
+ console.error(`[EventStream] 请求错误: ${url}`, error)
201
+ if (!isStopped) {
202
+ isStopped = true
203
+ onError?.(error)
204
+ }
205
+ })
206
+
207
+ // 返回停止函数
208
+ return () => {
209
+ isStopped = true
210
+ controller.abort()
211
+ console.log('连接已关闭')
212
+ }
213
+ }
214
+
215
+ export { get, post, del, put, postByServiceName, startEventStream, startEventStreamPOST }
File without changes
@@ -1,127 +0,0 @@
1
- <template>
2
- <a-card :bordered="false">
3
- <a-tabs default-active-key="1" @change="changeTab">
4
- <a-tab-pane key="1" tab="待办">
5
- <x-form-table
6
- title="站点工单(待办)"
7
- ref="xFormTable"
8
- queryParamsName="teleProcessCRUD"
9
- :fixed-query-form="{
10
- wo_f_department_id: currUser.depids,
11
- }"
12
- serviceName="af-telephone"
13
- @toDeal="toDetail"
14
- @updateInfo="updateInfo"
15
- @transfer="transfer"
16
- @toFinish="toFinish"
17
- >
18
- </x-form-table>
19
- </a-tab-pane>
20
- <a-tab-pane key="2" tab="已办">
21
- <x-form-table
22
- title="站点工单(已办)"
23
- ref="xFormTableDone"
24
- queryParamsName="teleProcessDoneCRUD"
25
- :fixed-query-form="{
26
- wo_f_department_id: currUser.depids,
27
- }"
28
- serviceName="af-telephone"
29
- @action="toView"
30
- @reminder="toReminder"
31
- >
32
- </x-form-table>
33
- </a-tab-pane>
34
- </a-tabs>
35
- <WorkflowDetail
36
- ref="workFlow"
37
- @preClick="preClick"
38
- @success="success"
39
- @nextClick="nextClick"
40
- @x-form-item-emit-func="handleFormItemEvent"
41
- >
42
- </WorkflowDetail>
43
- </a-card>
44
- </template>
45
-
46
- <script>
47
- import WorkflowDetail from '@vue2-client/pages/WorkflowDetail/WorkflowDetail.vue'
48
- import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
49
- import { mapState } from 'vuex'
50
- import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
51
-
52
- export default {
53
- name: 'Telephone',
54
- components: {
55
- XFormTable,
56
- WorkflowDetail,
57
- XAddNativeForm
58
- },
59
- // 透传给子组件的方法(目前XFormTable接了)
60
- provide () {
61
- return {
62
- generalFunction: {}
63
- }
64
- },
65
- data () {
66
- return {
67
- // 当前工单id
68
- currentWorkOrderId: '',
69
- // 提交加载动画
70
- confirmLoading: false,
71
- chargeVisible: false,
72
- // 环节人员信息
73
- chargePerson: {},
74
- chargePersonOptions: [],
75
- transferData: {
76
- optionsValue: '',
77
- remark: ''
78
- },
79
- record: {},
80
- define: {},
81
- // 是否展示催单结案弹窗
82
- showReminder: false,
83
- // 弹窗类型 催单/ 结案
84
- modelType: ''
85
- }
86
- },
87
- computed: {
88
- ...mapState('account', { currUser: 'user' }),
89
- },
90
- methods: {
91
- changeTab (key) {
92
- console.log('切换tab', key)
93
- if (key === '1') {
94
- this.$refs.xFormTable.refreshTable(true)
95
- } else if (key === '2') {
96
- this.$refs.xFormTableDone.refreshTable(true)
97
- }
98
- },
99
- success () {
100
- console.log('完工')
101
- },
102
- toDetail (record) {
103
- // 修改第一步的工单
104
- if (record.ws_f_step_id === 1 && record.w_f_state === 0) {
105
- console.log('进入工单详情')
106
- if (record.w_f_workflow_define_name === '报修单处理流程') {
107
- this.$refs.dealOrUpdate.dealOrUpdate(record, '处理工单')
108
- } else if (record.w_f_workflow_define_name === '投诉单处理流程') {
109
- this.$refs.dealComplaint.dealComplaintOrder(record)
110
- } else if (record.w_f_workflow_define_name === '咨询单处理流程') {
111
- this.$refs.dealConsultation.dealConsultationOrder(record)
112
- } else {
113
- this.$message.warn('未知流程类型')
114
- }
115
- } else {
116
- // 记录流程节点名称
117
- this.currentWorkOrderId = record.wo_id
118
- // 进入流程详情
119
- this.$refs.workFlow.init({
120
- workflowId: record.wo_f_workflow_id,
121
- stepId: record.ws_f_step_id
122
- })
123
- }
124
- },
125
- }
126
- }
127
- </script>