Blame view

src/components/resource/auditDiv.vue 4.63 KB
1cad66ad   wuxw   完成采购申请
1
  <template>
19bafb73   wuxw   v1.9 优化采购相关bug
2
    <el-card  width="50%" >
1cad66ad   wuxw   完成采购申请
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
      <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>
  
19bafb73   wuxw   v1.9 优化采购相关bug
30
      <div  class="dialog-footer">
1cad66ad   wuxw   完成采购申请
31
        <el-button type="primary" @click="handleSubmit">{{ $t('common.submit') }}</el-button>
19bafb73   wuxw   v1.9 优化采购相关bug
32
33
34
      </div>
      <select-staff ref="selectStaff" @selectStaff="handleStaffChange"></select-staff>
    </el-card>
1cad66ad   wuxw   完成采购申请
35
36
37
38
  </template>
  
  <script>
  import { queryNextDealUser,auditApplyOrder } from '@/api/resource/purchaseApplyDetailApi'
19bafb73   wuxw   v1.9 优化采购相关bug
39
  import SelectStaff from '@/components/staff/SelectStaff'
1cad66ad   wuxw   完成采购申请
40
41
42
43
  
  export default {
    name: 'AuditDiv',
    components: {
19bafb73   wuxw   v1.9 优化采购相关bug
44
      SelectStaff
1cad66ad   wuxw   完成采购申请
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    },
    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
1cad66ad   wuxw   完成采购申请
68
69
70
71
72
73
74
75
76
        this.loadNextAuditPerson()
      },
      async loadNextAuditPerson() {
        try {
          const params = {
            taskId: this.formData.taskId,
            startUserId: this.createUserId
          }
          const res = await queryNextDealUser(params)
19bafb73   wuxw   v1.9 优化采购相关bug
77
          if (res.code == '0') {
1cad66ad   wuxw   完成采购申请
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
            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 auditApplyOrder(this.formData)
          if (res.code === 0) {
            this.$message.success(this.$t('auditDiv.submitSuccess'))
19bafb73   wuxw   v1.9 优化采购相关bug
117
            this.$router.go(-1)
1cad66ad   wuxw   完成采购申请
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
            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 = {}
19bafb73   wuxw   v1.9 优化采购相关bug
139
140
141
142
      },
      handleStaffChange(staff) {
        this.formData.staffId = staff.staffId
        this.formData.staffName = staff.staffName
1cad66ad   wuxw   完成采购申请
143
144
145
146
      }
    }
  }
  </script>