taskSubmit.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="">
  3. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
  4. labelWidth='140rpx'>
  5. <u-form-item label="审批建议" prop="reason" required>
  6. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  7. v-model="form.reason"></u--textarea>
  8. </u-form-item>
  9. </u--form>
  10. <view>
  11. <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
  12. text="通过" @click="handleAudit(1)">
  13. </u-button>
  14. <u-button style="width: 100%;" :loading='loading' type="error" icon="close" text="驳回"
  15. @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. approveTaskWithVariables
  22. } from '@/api/wt/index.js'
  23. export default {
  24. name: 'taskSubmit',
  25. props: {
  26. businessId: {
  27. default: ''
  28. },
  29. taskId: {
  30. default: ''
  31. },
  32. id: {
  33. default: ''
  34. },
  35. taskDefinitionKey: {
  36. default: ''
  37. }
  38. },
  39. data() {
  40. return {
  41. loading: false,
  42. form: {
  43. technicianId: '',
  44. reason: '',
  45. },
  46. rules: {
  47. reason: {
  48. type: 'string',
  49. required: true,
  50. message: '请输入审批建议',
  51. trigger: 'blur'
  52. }
  53. },
  54. tabOptions: [{
  55. key: 'starter',
  56. permissionType: 'update',
  57. name: '发起人申请'
  58. },
  59. {
  60. key: 'deptLeaderApprove',
  61. permissionType: 'view',
  62. name: '部门主管审批'
  63. },
  64. {
  65. key: 'financeApprove',
  66. permissionType: 'update',
  67. name: '财务审批'
  68. },
  69. ],
  70. }
  71. },
  72. mounted() {
  73. this.$refs.uForm.setRules(this.rules)
  74. },
  75. methods: {
  76. async handleAudit(status) {
  77. if (!!status) await this.$refs.uForm.validate()
  78. this.loading = true
  79. let permissionType = this.tabOptions.find(item => item.key == this.taskDefinitionKey)?.permissionType
  80. if (!!status && permissionType === 'update') {
  81. const id = await this.getTableValue();
  82. this.loading = false
  83. if (typeof id !== 'string') return
  84. }
  85. await this._approveTaskWithVariables(status);
  86. },
  87. async _approveTaskWithVariables(status) {
  88. let variables = {
  89. pass: !!status
  90. };
  91. let res = await approveTaskWithVariables({
  92. id: this.taskId,
  93. reason: this.form.reason,
  94. variables
  95. })
  96. if (res.code != '-1') {
  97. this.$emit('handleAudit', {
  98. status,
  99. title: status === 0 ? '驳回' : ''
  100. });
  101. }
  102. this.loading = false
  103. },
  104. getTableValue() {
  105. return new Promise((resolve, reject) => {
  106. this.$emit('getTableValue', async (data) => {
  107. resolve(await data);
  108. });
  109. });
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. </style>