Blame view

src/components/resource/allocationAuditDiv.vue 4.65 KB
19bafb73   wuxw   v1.9 优化采购相关bug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
144
145
146
  <template>
    <el-card  width="50%" >
      <el-form ref="form" :model="formData" label-width="120px">
        <el-form-item :label="$t('auditDiv.action')" prop="auditCode">
          <el-select v-model="formData.auditCode" :placeholder="$t('auditDiv.pleaseSelect')" style="width: 100%">
            <el-option value="" disabled :label="$t('auditDiv.pleaseSelect')"></el-option>
            <el-option v-if="nextAudit.next || nextAudit.exit" value="1100" :label="$t('auditDiv.agree')"></el-option>
            <el-option v-if="nextAudit.back" value="1200" :label="$t('auditDiv.return')"></el-option>
            <el-option v-if="nextAudit.backIndex" value="1400" :label="$t('auditDiv.returnToSubmitter')"></el-option>
            <el-option value="1300" :label="$t('auditDiv.transfer')"></el-option>
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('auditDiv.workOrderDescription')" prop="auditMessage">
          <el-input type="textarea" :placeholder="$t('auditDiv.requiredDescription')" v-model="formData.auditMessage"
            :rows="4"></el-input>
        </el-form-item>
  
        <el-form-item v-if="(formData.auditCode === '1100' && nextAudit.assignee === '-2') || formData.auditCode === '1300'"
          :label="$t('auditDiv.nextHandler')" prop="staffName">
          <el-input v-model="formData.staffName" :placeholder="$t('auditDiv.requiredNextHandler')" disabled
            style="width: calc(100% - 100px); margin-right: 10px;"></el-input>
          <el-button @click="chooseStaff">
            <i class="el-icon-search"></i>
            {{ $t('auditDiv.select') }}
          </el-button>
        </el-form-item>
      </el-form>
  
      <div  class="dialog-footer">
        <el-button type="primary" @click="handleSubmit">{{ $t('common.submit') }}</el-button>
      </div>
      <select-staff ref="selectStaff" @selectStaff="handleStaffChange"></select-staff>
    </el-card>
  </template>
  
  <script>
  import { queryNextDealUser,auditAllocationStoreOrder } from '@/api/resource/purchaseApplyDetailApi'
  import SelectStaff from '@/components/staff/SelectStaff'
  
  export default {
    name: 'AllocationAuditDiv',
    components: {
      SelectStaff
    },
    data() {
      return {
        visible: false,
        formData: {
          auditCode: '',
          auditMessage: '',
          staffId: '',
          staffName: '',
          taskId: '',
          flowId: '',
          id: ''
        },
        nextAudit: {},
        createUserId: ''
      }
    },
    methods: {
      open(data) {
        this.formData.taskId = data.taskId
        this.formData.flowId = data.flowId
        this.formData.id = data.id
        this.createUserId = data.createUserId
        this.loadNextAuditPerson()
      },
      async loadNextAuditPerson() {
        try {
          const params = {
            taskId: this.formData.taskId,
            startUserId: this.createUserId
          }
          const res = await queryNextDealUser(params)
          if (res.code == '0') {
            this.nextAudit = res.data[0]
          }
        } catch (error) {
          console.error('获取下一处理人失败:', error)
        }
      },
      chooseStaff() {
        this.$refs.selectStaff.open({
          from: 'purchase',
          call: (staff) => {
            this.formData.staffId = staff.staffId
            this.formData.staffName = staff.staffName
          }
        })
      },
      async handleSubmit() {
        if (!this.formData.auditCode) {
          this.$message.warning(this.$t('auditDiv.pleaseSelectStatus'))
          return
        }
        if (!this.formData.auditMessage) {
          this.$message.warning(this.$t('auditDiv.pleaseFillDescription'))
          return
        }
        if (this.formData.auditCode !== '1200' &&
          this.formData.auditCode !== '1400' &&
          !this.formData.staffId) {
          this.$message.warning(this.$t('auditDiv.pleaseSelectNextHandler'))
          return
        }
  
        if (this.nextAudit.assignee !== '-2') {
          this.formData.staffId = this.nextAudit.assignee
        }
  
        try {
          const res = await auditAllocationStoreOrder(this.formData)
          if (res.code == 0) {
            this.$message.success(this.$t('common.submitSuccess'))
            this.$router.go(-1)
            this.$emit('success')
          } else {
            this.$message.error(res.msg)
          }
        } catch (error) {
          console.error('提交审核失败:', error)
          this.$message.error(this.$t('auditDiv.submitFailed'))
        }
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.formData = {
          auditCode: '',
          auditMessage: '',
          staffId: '',
          staffName: '',
          taskId: '',
          flowId: '',
          id: ''
        }
        this.nextAudit = {}
      },
      handleStaffChange(staff) {
        this.formData.staffId = staff.staffId
        this.formData.staffName = staff.staffName
      }
    }
  }
  </script>