vue2-client 1.14.50 → 1.14.52

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,223 +1,275 @@
1
- <template>
2
- <div class="timeline" ref="timelineContent" style="white-space: nowrap; overflow-x: auto">
3
- <a-steps
4
- :current="currentStepId"
5
- :initial="1">
6
- <template #progressDot="{index}">
7
- <span v-if="!changeAble" class="step-label in-steps"><i :class="['step-icon', getStepIconColor(index)]"></i></span>
8
- <span v-else :key="displayStepId" :class="['step-icon-filled digital', getStepIconColor(index)]">
9
- <a-icon v-if="index < currentStepId || state" type="check-circle" theme="filled" :class="['step-icon-filled icon', getStepIconColor(index)]" />
10
- <span v-else :class="['step-icon-filled digital', getStepIconColor(index)]">{{ index }}</span>
11
- </span>
12
- </template>
13
- <a-step
14
- v-for="item in steps"
15
- :key="item.id"
16
- class="step-item"
17
- :class="{ 'next-step-overdue': item.id === currentStepId - 1 && isOverdue }"
18
- @click.stop="onStepClick(item.id)"
19
- >
20
- <template #title>
21
- <h3 v-if="item.name">{{ item.name }}</h3>
22
- </template>
23
- <template #description>
24
- <div>
25
- <p v-if="item.handler">负责人:
26
- <trim-text-tail :text="item.handler" :length="14"/>
27
- </p>
28
- <p v-if="item.date">填报时间:{{ formatDate(item.date, 'yyyy-MM-dd hh:mm') }}</p>
29
- <p v-if="item.deadline" :class="{ 'text-red': item.id === currentStepId && isOverdue }">截止时间:{{ formatDate(item.deadline, 'yyyy-MM-dd hh:mm') }}</p>
30
- <p v-if="item.note">备注:
31
- <trim-text-tail :text="item.note" :length="15"/>
32
- </p>
33
- </div>
34
- </template>
35
- </a-step>
36
- </a-steps>
37
- </div>
38
- </template>
39
-
40
- <script>
41
- import { formatDate } from '@vue2-client/utils/util'
42
- import TrimTextTail from './TrimTextTail'
43
-
44
- export default {
45
- components: { TrimTextTail },
46
- name: 'WorkFlowTimeline',
47
- props: {
48
- workflowId: {
49
- type: String,
50
- required: true
51
- },
52
- currentStepId: {
53
- type: Number,
54
- required: false,
55
- default: 1
56
- },
57
- activeStepId: {
58
- type: Number,
59
- required: false,
60
- default: 1
61
- },
62
- state: {
63
- type: [Boolean, Number],
64
- required: false,
65
- default: false
66
- },
67
- steps: {
68
- type: Array,
69
- required: true
70
- },
71
- changeAble: {
72
- type: Boolean,
73
- required: false,
74
- default: false
75
- }
76
- },
77
- data () {
78
- return {
79
- // 当前显示的步骤 id
80
- displayStepId: 1,
81
- // 当前任务是否逾期
82
- isOverdue: false
83
- }
84
- },
85
- mounted () {
86
- this.init()
87
- const timelineContent = this.$refs.timelineContent
88
- timelineContent.onmousewheel = function (e) {
89
- timelineContent.scrollLeft -= e.wheelDelta
90
- e.preventDefault()
91
- }
92
- },
93
- beforeDestroy () {
94
- this.$refs.timelineContent.onmousewheel = null
95
- },
96
- methods: {
97
- init () {
98
- this.displayStepId = this.activeStepId
99
- const deadline = this.steps.find(step => step.id === this.currentStepId).deadline
100
- this.isOverdue = !this.state && this.formatDate(new Date(), 'yyyy-MM-dd hh:mm') > deadline
101
- this.$emit('activeStep', this.displayStepId)
102
- },
103
- // 判断id是否为流程中最后一个
104
- isLastStep (stepId) {
105
- return stepId >= this.steps.length
106
- },
107
- // 动态展示时间线节点颜色
108
- getStepIconColor (stepId) {
109
- if (this.changeAble && stepId === this.displayStepId) {
110
- return 'yellow'
111
- } else if (!this.changeAble && stepId === this.currentStepId) {
112
- return this.state ? 'blue' : 'green'
113
- }
114
- if (stepId < this.currentStepId || this.state) {
115
- return 'blue'
116
- }
117
- if (stepId === this.currentStepId) {
118
- return this.isOverdue ? 'red' : 'blue'
119
- }
120
- return 'gray'
121
- },
122
- onStepClick (stepId) {
123
- if (!this.changeAble || stepId === this.displayStepId) {
124
- return
125
- }
126
- if (stepId > this.currentStepId) {
127
- return this.$message.info('您要访问的步骤超出了当前进度!')
128
- }
129
- this.$emit('activeStep', stepId)
130
- this.displayStepId = stepId
131
- },
132
- formatDate,
133
- },
134
- watch: {
135
- activeStepId: function (newVal) {
136
- this.displayStepId = newVal
137
- }
138
- }
139
- }
140
- </script>
141
-
142
- <style lang="less" scoped>
143
- .timeline {
144
- /deep/ .ant-steps-dot {
145
- margin-bottom: 6px;
146
- .ant-steps-item-tail {
147
- top: 7px;
148
- margin-left: 106px;
149
- width: calc(100% - 23px);
150
- }
151
- .ant-steps-item-icon {
152
- margin-left: 90px;
153
- }
154
- .ant-steps-item-content {
155
- width: 200px;
156
- margin-top: 24px;
157
- .ant-steps-item-description {
158
- text-align: left;
159
- margin: 6px 0 0 60px;
160
- p:not(:last-child) {
161
- margin-bottom: 4px;
162
- }
163
- }
164
- }
165
- &.ant-steps {
166
- padding-top: 8px;
167
- }
168
- }
169
- @red: rgb(255, 77, 79);
170
- .step-icon-filled {
171
- position: absolute;
172
- top: -2px;
173
- left: -6px;
174
- @blue: rgb(24, 144, 255);
175
- @yellow: rgb(255, 164, 39);
176
- @gray: rgb(191, 191, 191);
177
- &.digital {
178
- width: 28px;
179
- line-height: 28px;
180
- border-radius: 50%;
181
- color: #ffffff;
182
- &.blue {
183
- background: @blue;
184
- }
185
- &.yellow {
186
- background: @yellow;
187
- }
188
- &.gray {
189
- background: @gray;
190
- }
191
- &.red {
192
- background: @red;
193
- }
194
- }
195
- &.icon {
196
- font-size: 28px;
197
- &.blue {
198
- color: @blue;
199
- }
200
- &.yellow {
201
- color: @yellow;
202
- }
203
- &.gray {
204
- color: @gray;
205
- }
206
- }
207
- }
208
- .step-item {
209
- cursor: pointer;
210
- &:hover p {
211
- color: rgba(0, 0, 0, 0.7);
212
- }
213
- .text-red {
214
- color: @red !important;
215
- }
216
- }
217
- .next-step-overdue {
218
- /deep/ .ant-steps-item-tail::after {
219
- background: @red;
220
- }
221
- }
222
- }
223
- </style>
1
+ <template>
2
+ <div class="timeline" ref="timelineContent" style="white-space: nowrap; overflow-x: auto">
3
+ <a-steps
4
+ :current="currentStepId"
5
+ :initial="1">
6
+ <template #progressDot="{index}">
7
+ <span v-if="!changeAble" class="step-label in-steps"><i :class="['step-icon', getStepIconColor(index)]"></i></span>
8
+ <span v-else :key="displayStepId" :class="['step-icon-filled digital', getStepIconColor(index)]">
9
+ <a-icon v-if="index < currentStepId || state" type="check-circle" theme="filled" :class="['step-icon-filled icon', getStepIconColor(index)]" />
10
+ <span v-else :class="['step-icon-filled digital', getStepIconColor(index)]">{{ index }}</span>
11
+ </span>
12
+ </template>
13
+ <a-step
14
+ v-for="item in steps"
15
+ :key="item.id"
16
+ class="step-item"
17
+ @click.stop="onStepClick(item.id)"
18
+ >
19
+ <template #title>
20
+ <h3 v-if="item.name">{{ item.name }}</h3>
21
+ </template>
22
+ <template #description>
23
+ <div>
24
+ <p v-if="item.handler">负责人:
25
+ <trim-text-tail :text="item.handler" :length="14"/>
26
+ </p>
27
+ <p v-if="item.date">填报时间:{{ formatDate(item.date, 'yyyy-MM-dd hh:mm') }}</p>
28
+ <p v-if="item.deadline" :class="{ 'text-red': item.id === currentStepId && isOverdue }">截止时间:{{ formatDate(item.deadline, 'yyyy-MM-dd hh:mm') }}</p>
29
+ <p v-if="item.note">备注:
30
+ <trim-text-tail :text="item.note" :length="15"/>
31
+ </p>
32
+ </div>
33
+ </template>
34
+ </a-step>
35
+ </a-steps>
36
+ </div>
37
+ </template>
38
+
39
+ <script>
40
+ import { formatDate } from '@vue2-client/utils/util'
41
+ import TrimTextTail from './TrimTextTail'
42
+
43
+ export default {
44
+ components: { TrimTextTail },
45
+ name: 'WorkFlowTimeline',
46
+ props: {
47
+ workflowId: {
48
+ type: String,
49
+ required: true
50
+ },
51
+ currentStepId: {
52
+ type: Number,
53
+ required: false,
54
+ default: 1
55
+ },
56
+ activeStepId: {
57
+ type: Number,
58
+ required: false,
59
+ default: 1
60
+ },
61
+ state: {
62
+ type: [Boolean, Number],
63
+ required: false,
64
+ default: false
65
+ },
66
+ steps: {
67
+ type: Array,
68
+ required: true
69
+ },
70
+ changeAble: {
71
+ type: Boolean,
72
+ required: false,
73
+ default: false
74
+ }
75
+ },
76
+ data () {
77
+ return {
78
+ // 当前显示的步骤 id
79
+ displayStepId: 1,
80
+ // 当前任务是否逾期
81
+ isOverdue: false
82
+ }
83
+ },
84
+ mounted () {
85
+ this.init()
86
+ const timelineContent = this.$refs.timelineContent
87
+ timelineContent.onmousewheel = function (e) {
88
+ timelineContent.scrollLeft -= e.wheelDelta
89
+ e.preventDefault()
90
+ }
91
+ },
92
+ beforeDestroy () {
93
+ this.$refs.timelineContent.onmousewheel = null
94
+ },
95
+ methods: {
96
+ init () {
97
+ this.displayStepId = this.activeStepId
98
+ const deadline = this.steps.find(step => step.id === this.currentStepId).deadline
99
+ this.isOverdue = !this.state && this.formatDate(new Date(), 'yyyy-MM-dd hh:mm') > deadline
100
+ this.$emit('activeStep', this.displayStepId)
101
+ },
102
+ // 判断id是否为流程中最后一个
103
+ isLastStep (stepId) {
104
+ return stepId >= this.steps.length
105
+ },
106
+ // 动态展示时间线节点颜色
107
+ getStepIconColor (stepId) {
108
+ if (this.changeAble && stepId === this.displayStepId) {
109
+ return 'yellow'
110
+ } else if (!this.changeAble && stepId === this.currentStepId) {
111
+ return this.state ? 'blue' : 'green'
112
+ }
113
+ if (stepId < this.currentStepId || this.state) {
114
+ return 'blue'
115
+ }
116
+ if (stepId === this.currentStepId) {
117
+ return this.isOverdue ? 'red' : 'blue'
118
+ }
119
+ return 'gray'
120
+ },
121
+ onStepClick (stepId) {
122
+ if (!this.changeAble || stepId === this.displayStepId) {
123
+ return
124
+ }
125
+ if (stepId > this.currentStepId) {
126
+ return this.$message.warn('请先完成当前步骤')
127
+ }
128
+ this.$emit('activeStep', stepId)
129
+ this.displayStepId = stepId
130
+ },
131
+ formatDate,
132
+ },
133
+ watch: {
134
+ activeStepId: function (newVal) {
135
+ this.displayStepId = newVal
136
+ }
137
+ }
138
+ }
139
+ </script>
140
+
141
+ <style lang="less" scoped>
142
+ .timeline {
143
+ /deep/ .ant-steps-dot {
144
+ margin-bottom: 6px;
145
+ .ant-steps-item-tail {
146
+ top: 7px;
147
+ margin-left: 106px;
148
+ width: calc(100% - 23px);
149
+ }
150
+ .ant-steps-item-icon {
151
+ margin-left: 90px;
152
+ width: 8px;
153
+ height: 8px;
154
+ line-height: 8px;
155
+ }
156
+ .ant-steps-item-content {
157
+ min-width: 200px;
158
+ margin-top: 24px;
159
+ .ant-steps-item-description {
160
+ text-align: left;
161
+ margin: 6px 0 0 0;
162
+ background: #fff;
163
+ border-radius: 4px;
164
+ padding: 12px;
165
+ position: relative;
166
+
167
+ &::before {
168
+ content: '';
169
+ position: absolute;
170
+ top: 0;
171
+ left: 0;
172
+ right: 0;
173
+ height: 1px;
174
+ background: repeating-linear-gradient(
175
+ to right,
176
+ #e8e8e8 0px,
177
+ #e8e8e8 4px,
178
+ transparent 4px,
179
+ transparent 8px
180
+ );
181
+ }
182
+
183
+ p {
184
+ position: relative;
185
+ padding: 8px 0;
186
+ margin: 0;
187
+ font-size: 13px;
188
+ color: #595959;
189
+ line-height: 1.5;
190
+ white-space: nowrap;
191
+ overflow: visible;
192
+
193
+ &:not(:last-child) {
194
+ border-bottom: 1px dashed #f0f0f0;
195
+ }
196
+
197
+ &:last-child {
198
+ padding-bottom: 0;
199
+ }
200
+
201
+ &:first-child {
202
+ padding-top: 0;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ &.ant-steps {
208
+ padding-top: 8px;
209
+ }
210
+ }
211
+ /deep/ .ant-steps-item-title {
212
+ font-size: 14px;
213
+ }
214
+ @red: rgb(255, 77, 79);
215
+ .step-icon-filled {
216
+ position: absolute;
217
+ top: -2px;
218
+ left: -6px;
219
+ @blue: rgb(24, 144, 255);
220
+ @yellow: rgb(255, 164, 39);
221
+ @gray: rgb(191, 191, 191);
222
+ &.digital {
223
+ width: 28px;
224
+ line-height: 28px;
225
+ border-radius: 50%;
226
+ color: #ffffff;
227
+ &.blue {
228
+ background: @blue;
229
+ }
230
+ &.yellow {
231
+ background: @yellow;
232
+ }
233
+ &.gray {
234
+ background: @gray;
235
+ }
236
+ &.red {
237
+ background: @red;
238
+ }
239
+ }
240
+ &.icon {
241
+ font-size: 28px;
242
+ &.blue {
243
+ color: @blue;
244
+ }
245
+ &.yellow {
246
+ color: @yellow;
247
+ }
248
+ &.gray {
249
+ color: @gray;
250
+ }
251
+ }
252
+ }
253
+ .step-item {
254
+ cursor: pointer;
255
+ &:hover {
256
+ .ant-steps-item-description {
257
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
258
+ transform: translateY(-1px);
259
+ transition: all 0.3s ease;
260
+ }
261
+ p {
262
+ color: #262626;
263
+ }
264
+ }
265
+ .text-red {
266
+ color: @red !important;
267
+ }
268
+ }
269
+ .next-step-overdue {
270
+ /deep/ .ant-steps-item-tail::after {
271
+ background: @red;
272
+ }
273
+ }
274
+ }
275
+ </style>