| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <template>
- <view class="">
- <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
- labelWidth='140rpx'>
- <u-form-item label="审批建议" prop="reason" required>
- <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
- v-model="form.reason"></u--textarea>
- </u-form-item>
- </u--form>
- <view>
- <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
- text="通过" @click="handleAudit(1)">
- </u-button>
- <u-button style="width: 100%;margin-bottom: 10rpx;" :loading='loading' type="error" icon="close" text="驳回"
- @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
- <u-button style="width: 100%;margin-bottom: 10rpx;" :loading='loading' type="info" icon="close" text="作废"
- @click="handleCancel()"></u-button>
- </view>
- </view>
- </template>
- <script>
- import {
- approveTaskWithVariables,
- rejectTask,
- cancelTask,
- } from '@/api/wt/index.js'
- export default {
- name: 'taskSubmit',
- props: {
- businessId: {
- default: ''
- },
- taskId: {
- default: ''
- },
- id: {
- default: ''
- },
- taskDefinitionKey: {
- default: ''
- }
- },
- data() {
- return {
- loading: false,
- form: {
- technicianId: '',
- reason: '',
- },
- rules: {
- reason: {
- type: 'string',
- required: true,
- message: '请输入审批建议',
- trigger: 'blur'
- }
- }
- }
- },
- mounted() {
- this.$refs.uForm.setRules(this.rules)
- },
- methods: {
- async handleAudit(status) {
- if (!!status) await this.$refs.uForm.validate()
- this.loading = true
- await this._approveTaskWithVariables(status);
- },
- async _approveTaskWithVariables(status) {
- let variables = {
- pass: !!status
- };
- const requestApi = status == 1 ? approveTaskWithVariables : rejectTask
- // console.log('variables~~~', variables)
- try {
- let res = await requestApi({
- id: this.taskId,
- reason: this.form.reason,
- variables
- })
- // console.log('res~~~', res)
- this.loading = false
- if (res.code != '-1') {
- this.$emit('handleAudit', {
- status,
- title: status === 0 ? '驳回' : ''
- });
- }
- } catch (error) {
- console.log('error~~~', error)
- this.loading = false
- }
-
- },
- handleCancel() {
- uni.showModal({
- title: '提示',
- content: '是否确认作废?',
- success: (res) => {
- if (res.confirm) {
- this.loading = true
- cancelTask({
- taskId: this.taskId,
- id: this.id,
- reason: this.form.reason,
- businessId: this.businessId,
- }).then(() => {
- if (res.code != '-1') {
- this.loading = false
- this.$emit('handleAudit', {
- title: '作废'
- });
- }
- }).catch(() => {
- this.loading = false
- this.$message.error("流程作废失败");
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- getTableValue() {
- return new Promise((resolve, reject) => {
- this.$emit('getTableValue', async (data) => {
- resolve(await data);
- });
- });
- }
- }
- }
- </script>
- <style>
- </style>
|