vue2-client 1.18.21 → 1.18.23

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,297 +1,297 @@
1
- <template>
2
- <div class="file-item-group">
3
- <!-- 搜索区域 -->
4
- <div class="search-area">
5
- <a-form-model ref="searchForm" :model="formData" layout="inline">
6
- <a-form-model-item prop="dateRange">
7
- <a-range-picker
8
- v-model="formData.dateRange"
9
- :ranges="dateRanges"
10
- :show-time="{ format: 'HH:mm' }"
11
- format="YYYY-MM-DD HH:mm"
12
- value-format="YYYY-MM-DD HH:mm:ss"
13
- :placeholder="['开始时间', '结束时间']"
14
- @change="handleDateChange"
15
- />
16
- </a-form-model-item>
17
- <a-form-model-item>
18
- <a-button type="primary" :loading="loading" @click="handleSearch">
19
- <a-icon type="search" />查询
20
- </a-button>
21
- </a-form-model-item>
22
- <a-form-model-item v-if="currUser.rolestr.includes('补录附件')">
23
- <a-button type="primary" :loading="loading" @click="showfiles">
24
- <a-icon type="upload" />上传附件
25
- </a-button>
26
- </a-form-model-item>
27
- </a-form-model>
28
- </div>
29
-
30
- <!-- 文件列表区域 -->
31
- <template v-if="Object.keys(groupedFiles).length > 0">
32
- <div class="file-list-container">
33
- <a-spin :spinning="loading">
34
- <template v-for="(group, date) in groupedFiles">
35
- <div :key="date" class="file-group">
36
- <div class="group-header">
37
- <a-icon type="calendar" />
38
- <span class="date-label">{{ formatDate(date) }}</span>
39
- <span class="file-count">({{ group.length }}个文件)</span>
40
- </div>
41
- <file-item
42
- :files="group"
43
- :downloadable="downloadable"
44
- />
45
- </div>
46
- </template>
47
- </a-spin>
48
- </div>
49
- </template>
50
- <template v-else>
51
- <a-empty></a-empty>
52
- </template>
53
- <a-modal
54
- v-model="applyAddFiles"
55
- :footer="null"
56
- :dialog-style="{ top: '5rem' }"
57
- :z-index="1001"
58
- title="附件补录"
59
- :destroyOnClose="true">
60
- <x-add-native-form ref="xForm" @onSubmit="applySubmit"/>
61
- </a-modal>
62
- </div>
63
- </template>
64
-
65
- <script>
66
- import FileItem from './FileItem.vue'
67
- import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
68
- import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
69
- import { postByServiceName } from '@vue2-client/services/api/restTools'
70
- import { mapState } from 'vuex'
71
-
72
- export default {
73
- name: 'FileItemGroup',
74
- components: {
75
- FileItem,
76
- XAddNativeForm
77
- },
78
- props: {
79
- downloadable: {
80
- type: Boolean,
81
- default: true
82
- },
83
- workflowId: {
84
- type: String,
85
- default: ''
86
- }
87
- },
88
- data () {
89
- const now = new Date()
90
- const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
91
- const yesterday = new Date(today)
92
- yesterday.setDate(yesterday.getDate() - 1)
93
- const last7Days = new Date(today)
94
- last7Days.setDate(last7Days.getDate() - 6)
95
- const last30Days = new Date(today)
96
- last30Days.setDate(last30Days.getDate() - 29)
97
-
98
- return {
99
- loading: false,
100
- formData: {
101
- dateRange: []
102
- },
103
- files: [],
104
- applyAddFiles: false,
105
- dateRanges: {
106
- 今天: [today, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)],
107
- 昨天: [yesterday, new Date(yesterday.getTime() + 24 * 60 * 60 * 1000 - 1)],
108
- 最近7天: [last7Days, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)],
109
- 最近30天: [last30Days, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)]
110
- }
111
- }
112
- },
113
- mounted () {
114
- this.handleSearch()
115
- },
116
- computed: {
117
- ...mapState('account', { currUser: 'user' }),
118
- groupedFiles () {
119
- const groups = {}
120
- this.files.forEach(file => {
121
- const originalDate = file.upload_time?.split(' ')[0]
122
-
123
- let displayDate
124
- if (!originalDate || !/^\d{4}-\d{2}-\d{2}$/.test(originalDate)) {
125
- displayDate = '无日期'
126
- } else {
127
- displayDate = originalDate
128
- }
129
-
130
- groups[displayDate] = groups[displayDate] || []
131
- groups[displayDate].push(file)
132
- })
133
-
134
- // 自定义排序:有日期的按日期降序,无日期在最后
135
- return Object.fromEntries(
136
- Object.entries(groups).sort(([dateA], [dateB]) => {
137
- if (dateA === '无日期') return 1
138
- if (dateB === '无日期') return -1
139
- return dateB.localeCompare(dateA)
140
- })
141
- )
142
- }
143
- },
144
- methods: {
145
- handleDateChange (dates) {
146
- this.formData.dateRange = dates
147
- },
148
- handleSearch () {
149
- this.$refs.searchForm.validate(async valid => {
150
- if (valid) {
151
- this.loading = true
152
- let queryDate
153
- if (this.formData.dateRange && this.formData.dateRange.length > 0) {
154
- queryDate = this.formData.dateRange
155
- } else {
156
- queryDate = undefined
157
- }
158
- const callback = (res) => {
159
- console.warn('>>>callback', res)
160
- this.files = res.files
161
- this.loading = false
162
- }
163
- const errorCallback = (e) => {
164
- console.warn('>>>errorCallback', e)
165
- this.$message.error('获取文件列表失败:' + e.getMessage())
166
- this.loading = false
167
- }
168
- this.$emit('search', queryDate, callback, errorCallback)
169
- } else {
170
- this.$message.error('请检查日期选择是否正确')
171
- }
172
- })
173
- },
174
- formatDate (date) {
175
- if (date === '无日期') {
176
- return '无日期'
177
- }
178
- const today = new Date().toISOString().split('T')[0]
179
- const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString().split('T')[0]
180
-
181
- if (date === today) {
182
- return '今天'
183
- } else if (date === yesterday) {
184
- return '昨天'
185
- }
186
-
187
- const [year, month, day] = date.split('-')
188
- return `${year}年${month}月${day}日`
189
- },
190
- showfiles () {
191
- this.applyAddFiles = true
192
- // 获取所有步骤
193
- postByServiceName('/logic/getWorkFlowDefine', {
194
- id: this.workflowId
195
- }).then(res => {
196
- const steps = res.steps
197
- runLogic('getWorkFlowStepState', { workflowId: this.workflowId }, 'af-system').then(
198
- work => {
199
- const stepState = work
200
- console.log('stepState', stepState)
201
- const options = []
202
- stepState.forEach(state => {
203
- steps.forEach(step => {
204
- if (step.name === state.f_name) {
205
- step.properties.form.formJson.forEach(item => {
206
- if (item.type === 'file') {
207
- options.push({
208
- label: step.name,
209
- value: step.name
210
- })
211
- }
212
- })
213
- }
214
- })
215
- })
216
- // 去重操作
217
- const keys = options.filter((option, index, self) =>
218
- index === self.findIndex(opt => opt.value === option.value)
219
- )
220
- this.$nextTick(
221
- () => {
222
- getConfigByName('addApplyFilesForm', 'af-system', (res) => {
223
- res.formJson[0].keys = keys
224
- this.$refs.xForm.init({
225
- businessType: '新增',
226
- title: '附件补录',
227
- ...res
228
- })
229
- })
230
- }
231
- )
232
- }
233
- )
234
- })
235
- },
236
- applySubmit (formData) {
237
- console.log('formData', formData)
238
- formData.workflowId = this.workflowId
239
- runLogic('addApplyFiles', formData, 'af-system').then(
240
- res => {
241
- this.$message.success('附件补录成功')
242
- this.handleSearch()
243
- this.applyAddFiles = false
244
- }
245
- ).catch(() => {
246
- this.applyAddFiles = false
247
- })
248
- }
249
- }
250
- }
251
- </script>
252
-
253
- <style lang="less" scoped>
254
- .file-item-group {
255
- .search-area {
256
- display: flex;
257
- gap: 16px;
258
- margin-bottom: 24px;
259
- padding: 16px;
260
- background: #fff;
261
- border-radius: 8px;
262
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
263
- }
264
-
265
- .file-list-container {
266
- .file-group {
267
- margin-bottom: 24px;
268
-
269
- .group-header {
270
- display: flex;
271
- align-items: center;
272
- margin-bottom: 16px;
273
- padding: 8px 16px;
274
- background: #fafafa;
275
- border-radius: 6px;
276
-
277
- .anticon {
278
- margin-right: 8px;
279
- color: @primary-color;
280
- }
281
-
282
- .date-label {
283
- font-size: 15px;
284
- font-weight: 500;
285
- color: rgba(0, 0, 0, 0.85);
286
- }
287
-
288
- .file-count {
289
- margin-left: 8px;
290
- color: rgba(0, 0, 0, 0.45);
291
- font-size: 13px;
292
- }
293
- }
294
- }
295
- }
296
- }
297
- </style>
1
+ <template>
2
+ <div class="file-item-group">
3
+ <!-- 搜索区域 -->
4
+ <div class="search-area">
5
+ <a-form-model ref="searchForm" :model="formData" layout="inline">
6
+ <a-form-model-item prop="dateRange">
7
+ <a-range-picker
8
+ v-model="formData.dateRange"
9
+ :ranges="dateRanges"
10
+ :show-time="{ format: 'HH:mm' }"
11
+ format="YYYY-MM-DD HH:mm"
12
+ value-format="YYYY-MM-DD HH:mm:ss"
13
+ :placeholder="['开始时间', '结束时间']"
14
+ @change="handleDateChange"
15
+ />
16
+ </a-form-model-item>
17
+ <a-form-model-item>
18
+ <a-button type="primary" :loading="loading" @click="handleSearch">
19
+ <a-icon type="search" />查询
20
+ </a-button>
21
+ </a-form-model-item>
22
+ <a-form-model-item v-if="currUser.rolestr.includes('补录附件')">
23
+ <a-button type="primary" :loading="loading" @click="showfiles">
24
+ <a-icon type="upload" />上传附件
25
+ </a-button>
26
+ </a-form-model-item>
27
+ </a-form-model>
28
+ </div>
29
+
30
+ <!-- 文件列表区域 -->
31
+ <template v-if="Object.keys(groupedFiles).length > 0">
32
+ <div class="file-list-container">
33
+ <a-spin :spinning="loading">
34
+ <template v-for="(group, date) in groupedFiles">
35
+ <div :key="date" class="file-group">
36
+ <div class="group-header">
37
+ <a-icon type="calendar" />
38
+ <span class="date-label">{{ formatDate(date) }}</span>
39
+ <span class="file-count">({{ group.length }}个文件)</span>
40
+ </div>
41
+ <file-item
42
+ :files="group"
43
+ :downloadable="downloadable"
44
+ />
45
+ </div>
46
+ </template>
47
+ </a-spin>
48
+ </div>
49
+ </template>
50
+ <template v-else>
51
+ <a-empty></a-empty>
52
+ </template>
53
+ <a-modal
54
+ v-model="applyAddFiles"
55
+ :footer="null"
56
+ :dialog-style="{ top: '5rem' }"
57
+ :z-index="1001"
58
+ title="附件补录"
59
+ :destroyOnClose="true">
60
+ <x-add-native-form ref="xForm" @onSubmit="applySubmit"/>
61
+ </a-modal>
62
+ </div>
63
+ </template>
64
+
65
+ <script>
66
+ import FileItem from './FileItem.vue'
67
+ import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
68
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
69
+ import { postByServiceName } from '@vue2-client/services/api/restTools'
70
+ import { mapState } from 'vuex'
71
+
72
+ export default {
73
+ name: 'FileItemGroup',
74
+ components: {
75
+ FileItem,
76
+ XAddNativeForm
77
+ },
78
+ props: {
79
+ downloadable: {
80
+ type: Boolean,
81
+ default: true
82
+ },
83
+ workflowId: {
84
+ type: String,
85
+ default: ''
86
+ }
87
+ },
88
+ data () {
89
+ const now = new Date()
90
+ const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
91
+ const yesterday = new Date(today)
92
+ yesterday.setDate(yesterday.getDate() - 1)
93
+ const last7Days = new Date(today)
94
+ last7Days.setDate(last7Days.getDate() - 6)
95
+ const last30Days = new Date(today)
96
+ last30Days.setDate(last30Days.getDate() - 29)
97
+
98
+ return {
99
+ loading: false,
100
+ formData: {
101
+ dateRange: []
102
+ },
103
+ files: [],
104
+ applyAddFiles: false,
105
+ dateRanges: {
106
+ 今天: [today, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)],
107
+ 昨天: [yesterday, new Date(yesterday.getTime() + 24 * 60 * 60 * 1000 - 1)],
108
+ 最近7天: [last7Days, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)],
109
+ 最近30天: [last30Days, new Date(today.getTime() + 24 * 60 * 60 * 1000 - 1)]
110
+ }
111
+ }
112
+ },
113
+ mounted () {
114
+ this.handleSearch()
115
+ },
116
+ computed: {
117
+ ...mapState('account', { currUser: 'user' }),
118
+ groupedFiles () {
119
+ const groups = {}
120
+ this.files.forEach(file => {
121
+ const originalDate = file.upload_time?.split(' ')[0]
122
+
123
+ let displayDate
124
+ if (!originalDate || !/^\d{4}-\d{2}-\d{2}$/.test(originalDate)) {
125
+ displayDate = '无日期'
126
+ } else {
127
+ displayDate = originalDate
128
+ }
129
+
130
+ groups[displayDate] = groups[displayDate] || []
131
+ groups[displayDate].push(file)
132
+ })
133
+
134
+ // 自定义排序:有日期的按日期降序,无日期在最后
135
+ return Object.fromEntries(
136
+ Object.entries(groups).sort(([dateA], [dateB]) => {
137
+ if (dateA === '无日期') return 1
138
+ if (dateB === '无日期') return -1
139
+ return dateB.localeCompare(dateA)
140
+ })
141
+ )
142
+ }
143
+ },
144
+ methods: {
145
+ handleDateChange (dates) {
146
+ this.formData.dateRange = dates
147
+ },
148
+ handleSearch () {
149
+ this.$refs.searchForm.validate(async valid => {
150
+ if (valid) {
151
+ this.loading = true
152
+ let queryDate
153
+ if (this.formData.dateRange && this.formData.dateRange.length > 0) {
154
+ queryDate = this.formData.dateRange
155
+ } else {
156
+ queryDate = undefined
157
+ }
158
+ const callback = (res) => {
159
+ console.warn('>>>callback', res)
160
+ this.files = res.files
161
+ this.loading = false
162
+ }
163
+ const errorCallback = (e) => {
164
+ console.warn('>>>errorCallback', e)
165
+ this.$message.error('获取文件列表失败:' + e.getMessage())
166
+ this.loading = false
167
+ }
168
+ this.$emit('search', queryDate, callback, errorCallback)
169
+ } else {
170
+ this.$message.error('请检查日期选择是否正确')
171
+ }
172
+ })
173
+ },
174
+ formatDate (date) {
175
+ if (date === '无日期') {
176
+ return '无日期'
177
+ }
178
+ const today = new Date().toISOString().split('T')[0]
179
+ const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString().split('T')[0]
180
+
181
+ if (date === today) {
182
+ return '今天'
183
+ } else if (date === yesterday) {
184
+ return '昨天'
185
+ }
186
+
187
+ const [year, month, day] = date.split('-')
188
+ return `${year}年${month}月${day}日`
189
+ },
190
+ showfiles () {
191
+ this.applyAddFiles = true
192
+ // 获取所有步骤
193
+ postByServiceName('/logic/getWorkFlowDefine', {
194
+ id: this.workflowId
195
+ }).then(res => {
196
+ const steps = res.steps
197
+ runLogic('getWorkFlowStepState', { workflowId: this.workflowId }, 'af-system').then(
198
+ work => {
199
+ const stepState = work
200
+ console.log('stepState', stepState)
201
+ const options = []
202
+ stepState.forEach(state => {
203
+ steps.forEach(step => {
204
+ if (step.name === state.f_name) {
205
+ step.properties.form.formJson.forEach(item => {
206
+ if (item.type === 'file') {
207
+ options.push({
208
+ label: step.name,
209
+ value: step.name
210
+ })
211
+ }
212
+ })
213
+ }
214
+ })
215
+ })
216
+ // 去重操作
217
+ const keys = options.filter((option, index, self) =>
218
+ index === self.findIndex(opt => opt.value === option.value)
219
+ )
220
+ this.$nextTick(
221
+ () => {
222
+ getConfigByName('addApplyFilesForm', 'af-system', (res) => {
223
+ res.formJson[0].keys = keys
224
+ this.$refs.xForm.init({
225
+ businessType: '新增',
226
+ title: '附件补录',
227
+ ...res
228
+ })
229
+ })
230
+ }
231
+ )
232
+ }
233
+ )
234
+ })
235
+ },
236
+ applySubmit (formData) {
237
+ console.log('formData', formData)
238
+ formData.workflowId = this.workflowId
239
+ runLogic('addApplyFiles', formData, 'af-system').then(
240
+ res => {
241
+ this.$message.success('附件补录成功')
242
+ this.handleSearch()
243
+ this.applyAddFiles = false
244
+ }
245
+ ).catch(() => {
246
+ this.applyAddFiles = false
247
+ })
248
+ }
249
+ }
250
+ }
251
+ </script>
252
+
253
+ <style lang="less" scoped>
254
+ .file-item-group {
255
+ .search-area {
256
+ display: flex;
257
+ gap: 16px;
258
+ margin-bottom: 24px;
259
+ padding: 16px;
260
+ background: #fff;
261
+ border-radius: 8px;
262
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
263
+ }
264
+
265
+ .file-list-container {
266
+ .file-group {
267
+ margin-bottom: 24px;
268
+
269
+ .group-header {
270
+ display: flex;
271
+ align-items: center;
272
+ margin-bottom: 16px;
273
+ padding: 8px 16px;
274
+ background: #fafafa;
275
+ border-radius: 6px;
276
+
277
+ .anticon {
278
+ margin-right: 8px;
279
+ color: @primary-color;
280
+ }
281
+
282
+ .date-label {
283
+ font-size: 15px;
284
+ font-weight: 500;
285
+ color: rgba(0, 0, 0, 0.85);
286
+ }
287
+
288
+ .file-count {
289
+ margin-left: 8px;
290
+ color: rgba(0, 0, 0, 0.45);
291
+ font-size: 13px;
292
+ }
293
+ }
294
+ }
295
+ }
296
+ }
297
+ </style>