Blame view

src/views/system/workflowSettingManageList.vue 10.6 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
03f63ab4   wuxw   优化到商户信息
2
3
4
5
    <div class="workflow-setting-container">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-card>
fe758814   wuxw   报表功能测试完成
6
            <div slot="header" class="flex justify-between">
03f63ab4   wuxw   优化到商户信息
7
8
              <span>{{ $t('workflowSettingManage.title') }}</span>
            </div>
fe758814   wuxw   报表功能测试完成
9
            <el-form label-width="120px" class="text-left">
03f63ab4   wuxw   优化到商户信息
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
              <el-form-item :label="$t('workflowSettingManage.flowName')">
                <el-input v-model="workflowSettingInfo.flowName"
                  :placeholder="$t('workflowSettingManage.flowNamePlaceholder')" disabled />
              </el-form-item>
  
              <el-form-item :label="$t('workflowSettingManage.description')">
                <el-input v-model="workflowSettingInfo.describle" type="textarea"
                  :placeholder="$t('workflowSettingManage.descriptionPlaceholder')" :rows="3" />
              </el-form-item>
  
              <el-form-item :label="$t('workflowSettingManage.submitterEnd')">
                <el-select v-model="workflowSettingInfo.startNodeFinish" style="width:100%"
                  :placeholder="$t('workflowSettingManage.submitterEndPlaceholder')">
                  <el-option :label="$t('workflowSettingManage.yes')" value="Y" />
                  <el-option :label="$t('workflowSettingManage.no')" value="N" />
                </el-select>
              </el-form-item>
  
              <el-form-item :label="$t('workflowSettingManage.flowSteps')">
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
29
                <div class="step-actions margin-bottom">
03f63ab4   wuxw   优化到商户信息
30
31
32
33
34
35
36
37
38
39
40
41
42
                  <el-button type="primary" @click="addWorkflowStep">
                    {{ $t('workflowSettingManage.addStep') }}
                  </el-button>
                </div>
  
                <div v-for="(item, index) in workflowSettingInfo.steps" :key="index" class="step-item">
                  <div class="step-header">
                    <span>{{ $t('workflowSettingManage.step') }} {{ index + 1 }}</span>
  
                    <el-button type="text" @click="chooseStaff(item)">
                      {{ item.staffId ? item.staffName : $t('workflowSettingManage.selectStaff') }}
                    </el-button>
  
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                    <div class="radio-group">
                      <label class="radio-item">
                        <input
                          type="radio"
                          :name="`step-type-${index}`"
                          value="2"
                          v-model="item.type"
                          @change="chooseType(item)"
                        />
                        <span>{{ $t('workflowSettingManage.normalFlow') }}</span>
                      </label>
                      <label class="radio-item" v-if="index !== 0">
                        <input
                          type="radio"
                          :name="`step-type-${index}`"
                          value="1"
                          v-model="item.type"
                          @change="chooseType(item)"
                        />
                        <span>{{ $t('workflowSettingManage.countersign') }}</span>
                      </label>
                    </div>
03f63ab4   wuxw   优化到商户信息
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  
                    <el-button type="text" @click="deleteStep(item)">
                      {{ $t('workflowSettingManage.deleteStep') }}
                    </el-button>
  
                    <el-button v-if="item.type == 1" type="text" @click="addStaff(item)">
                      {{ $t('workflowSettingManage.addStaff') }}
                    </el-button>
                  </div>
  
                  <div v-for="(subItem, subIndex) in item.subStaff" :key="subIndex" class="sub-staff-item">
                    <el-button type="text" @click="chooseStaff(subItem)">
                      {{ subItem.staffId ? subItem.staffName : $t('workflowSettingManage.selectStaff') }}
                    </el-button>
  
                    <el-button type="text" @click="deleteStaff(item, subItem)">
                      {{ $t('workflowSettingManage.deleteStaff') }}
                    </el-button>
                  </div>
                </div>
              </el-form-item>
            </el-form>
  
            <div class="form-actions">
              <el-button type="primary" @click="saveWorkflowSettingInfo">
                {{ $t('common.submit') }}
              </el-button>
              <el-button type="warning" @click="_goBack">
                {{ $t('common.back') }}
              </el-button>
            </div>
          </el-card>
        </el-col>
      </el-row>
  
      <el-row :gutter="20" class="mt-20">
        <el-col :span="24">
          <el-card>
fe758814   wuxw   报表功能测试完成
103
            <div slot="header" class="flex justify-between">
03f63ab4   wuxw   优化到商户信息
104
105
106
107
108
109
110
111
112
113
114
115
116
              <span>{{ $t('workflowSettingManage.instructions') }}</span>
            </div>
            <div v-if="workflowSettingInfo.flowType === '70007'">
              <p>1. {{ $t('workflowSettingManage.instruction1') }}</p>
              <p>2. {{ $t('workflowSettingManage.instruction2') }}</p>
              <p>3. {{ $t('workflowSettingManage.instruction3') }}</p>
              <p>4. {{ $t('workflowSettingManage.instruction4') }}</p>
            </div>
            <!-- 其他流程类型的说明类似 -->
          </el-card>
        </el-col>
      </el-row>
  
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
117
      <select-staff ref="selectStaff"  @selectStaff="handleStaffSelected"/>
03f63ab4   wuxw   优化到商户信息
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import SelectStaff from '@/components/staff/SelectStaff'
  import {
    getWorkflowSteps,
    updateWorkflow
  } from '@/api/system/workflowSettingManageApi'
  
  export default {
    name: 'WorkflowSettingManageList',
    components: {
      SelectStaff
    },
    data() {
      return {
        communityId: '',
        workflowSettingInfo: {
          flowId: '',
          flowName: '',
          flowType: '',
          describle: '',
          startNodeFinish: 'Y',
          steps: []
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
144
145
        },
        currentSelectTarget: null
03f63ab4   wuxw   优化到商户信息
146
147
148
149
150
151
152
      }
    },
    created() {
      this.communityId = getCommunityId()
      this._initWorkflowSettingInfo()
    },
    methods: {
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
153
154
155
156
      generateId() {
        return `id-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`
      },
  
03f63ab4   wuxw   优化到商户信息
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
      async _initWorkflowSettingInfo() {
        const flowId = this.$route.query.flowId
  
        if (!flowId) {
          this.$message.error(this.$t('workflowSettingManage.invalidOperation'))
          this.$router.go(-1)
          return
        }
  
        this.workflowSettingInfo.flowId = flowId
        this.workflowSettingInfo.flowName = this.$route.query.flowName
        this.workflowSettingInfo.flowType = this.$route.query.flowType
        this.workflowSettingInfo.startNodeFinish = this.$route.query.startNodeFinish || 'Y'
  
        try {
          const { data } = await getWorkflowSteps({
            communityId: this.communityId,
            flowId
          })
          this._freshResStep(data)
        } catch (error) {
          this.$message.error(error.message)
        }
      },
  
      _freshResStep(data) {
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
        if (!data) {
          this.workflowSettingInfo.steps = []
          return
        }
  
        this.workflowSettingInfo.describle = data.describle || ''
        if (data.startNodeFinish) {
          this.workflowSettingInfo.startNodeFinish = data.startNodeFinish
        }
  
        const workflowSteps = Array.isArray(data.workflowSteps) ? data.workflowSteps : []
        const steps = workflowSteps.map((step, index) => {
          const staffList = Array.isArray(step.workflowStepStaffs) ? step.workflowStepStaffs : []
          const mainStaff = staffList[0] || {}
  
          const subStaff = staffList.slice(1).map(staff => ({
            id: staff.id || this.generateId(),
            staffId: staff.staffId || staff.userId || '',
            staffName: staff.staffName || staff.userName || staff.name || '',
            staffRole: staff.staffRole || ''
          }))
  
          return {
            seq: index,
            staffId: mainStaff.staffId || mainStaff.userId || '',
            staffName: mainStaff.staffName || mainStaff.userName || mainStaff.name || '',
            staffRole: mainStaff.staffRole || '',
            type: String(step.type || '2'),
            subStaff
          }
        })
  
        this.workflowSettingInfo.steps = steps
03f63ab4   wuxw   优化到商户信息
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
      },
  
      addWorkflowStep() {
        const step = {
          seq: this.workflowSettingInfo.steps.length,
          staffId: '',
          staffName: '',
          type: '2',
          subStaff: []
        }
        this.workflowSettingInfo.steps.push(step)
      },
  
      chooseStaff(item) {
        item.from = this._getStaffFromType()
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
231
232
        this.currentSelectTarget = item
        this.$refs.selectStaff.open()
03f63ab4   wuxw   优化到商户信息
233
234
235
      },
  
      _getStaffFromType() {
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
236
237
238
239
240
241
242
243
        const type = this.workflowSettingInfo.flowType
        if (['30003', '40004', '70007', '80008'].includes(type)) {
          return 'purchase'
        }
        if (['50005', '60006'].includes(type)) {
          return 'contract'
        }
        return ''
03f63ab4   wuxw   优化到商户信息
244
245
246
247
248
249
250
251
252
253
254
255
256
257
      },
  
      _goBack() {
        this.$router.go(-1)
      },
  
      deleteStep(step) {
        this.workflowSettingInfo.steps = this.workflowSettingInfo.steps.filter(
          s => s.seq !== step.seq
        )
      },
  
      addStaff(step) {
        step.subStaff.push({
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
258
          id: this.generateId(),
03f63ab4   wuxw   优化到商户信息
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
          staffId: '',
          staffName: '',
          staffRole: '1001'
        })
      },
  
      deleteStaff(step, subStaff) {
        step.subStaff = step.subStaff.filter(s => s.id !== subStaff.id)
      },
  
      chooseType(item) {
        if (item.type === '1') {
          item.subStaff = []
        }
      },
  
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
275
276
277
278
279
280
281
282
283
284
285
      handleStaffSelected(staff) {
        if (!this.currentSelectTarget) {
          return
        }
        const target = this.currentSelectTarget
        this.$set(target, 'staffId', staff.staffId || staff.userId || '')
        this.$set(target, 'staffName', staff.staffName || staff.userName || staff.name || '')
        if (staff.staffRole) {
          this.$set(target, 'staffRole', staff.staffRole)
        }
        this.currentSelectTarget = null
03f63ab4   wuxw   优化到商户信息
286
287
288
289
290
291
292
293
      },
  
      async saveWorkflowSettingInfo() {
        try {
          await updateWorkflow({
            ...this.workflowSettingInfo,
            communityId: this.communityId
          })
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
294
          this.$message.success(this.$t('common.operationSuccess'))
03f63ab4   wuxw   优化到商户信息
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
          this._goBack()
        } catch (error) {
          this.$message.error(error.message)
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .workflow-setting-container {
    padding: 20px;
  
    .step-item {
      margin-bottom: 20px;
      padding: 15px;
      border: 1px solid #ebeef5;
      border-radius: 4px;
  
      .step-header {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
  
        >* {
          margin-right: 15px;
        }
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
  
        .radio-group {
          display: inline-flex;
          align-items: center;
          margin-right: 15px;
  
          .radio-item {
            display: inline-flex;
            align-items: center;
            margin-right: 12px;
  
            input {
              margin-right: 4px;
            }
          }
        }
03f63ab4   wuxw   优化到商户信息
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
      }
  
      .sub-staff-item {
        margin-left: 40px;
        margin-bottom: 10px;
  
        >* {
          margin-right: 15px;
        }
      }
    }
  
    .form-actions {
      text-align: right;
      margin-top: 20px;
    }
  
    .mt-20 {
      margin-top: 20px;
    }
  }
  </style>