taskSubmit.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. }
  55. },
  56. mounted() {
  57. this.$refs.uForm.setRules(this.rules)
  58. },
  59. methods: {
  60. async handleAudit(status) {
  61. if (!!status) await this.$refs.uForm.validate()
  62. this.loading = true
  63. await this._approveTaskWithVariables(status);
  64. },
  65. async _approveTaskWithVariables(status) {
  66. let variables = {
  67. pass: !!status
  68. };
  69. let res = await approveTaskWithVariables({
  70. id: this.taskId,
  71. reason: this.form.reason,
  72. variables
  73. })
  74. if (res.code != '-1') {
  75. this.$emit('handleAudit', {
  76. status,
  77. title: status === 0 ? '驳回' : ''
  78. });
  79. }
  80. this.loading = false
  81. },
  82. getTableValue() {
  83. return new Promise((resolve, reject) => {
  84. this.$emit('getTableValue', async (data) => {
  85. resolve(await data);
  86. });
  87. });
  88. }
  89. }
  90. }
  91. </script>
  92. <style>
  93. </style>