taskSubmit.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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="userName" required>
  6. <u--input clearable placeholder="请选择" border="surround" v-model="form.userName"
  7. @click.native="showTechnicianPicker"></u--input>
  8. </u-form-item>
  9. <u-form-item label="审批建议" prop="reason" required>
  10. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  11. v-model="form.reason"></u--textarea>
  12. </u-form-item>
  13. </u--form>
  14. <view>
  15. <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
  16. text="通过" @click="handleAudit(1)">
  17. </u-button>
  18. <u-button style="width: 100%;" :loading='loading' type="error" icon="close" text="驳回"
  19. @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
  20. </view>
  21. <u-picker itemHeight='60' :show="technicianShow" visibleItemCount='10' :columns="userOptions" keyName="name"
  22. @confirm='selectTechnicianInfo' @cancel='technicianShow = false' title='选择负责人'></u-picker>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. approveTaskWithVariables,
  28. AssignPurchasePlanUserAPI
  29. } from '@/api/wt/index.js'
  30. import {
  31. listAllUserBind
  32. } from '@/api/common.js'
  33. export default {
  34. name: 'taskSubmit',
  35. props: {
  36. businessId: {
  37. default: ''
  38. },
  39. taskId: {
  40. default: ''
  41. },
  42. id: {
  43. default: ''
  44. },
  45. taskDefinitionKey: {
  46. default: ''
  47. }
  48. },
  49. data() {
  50. return {
  51. loading: false,
  52. technicianShow: false,
  53. userOptions: [],
  54. form: {
  55. userId: '',
  56. userName: '',
  57. reason: '',
  58. },
  59. rules: {
  60. reason: {
  61. type: 'string',
  62. required: true,
  63. message: '请输入审批建议',
  64. trigger: 'blur'
  65. },
  66. userName: {
  67. type: 'string',
  68. required: true,
  69. message: '请选择负责人',
  70. trigger: ['blur','change']
  71. },
  72. }
  73. }
  74. },
  75. mounted() {
  76. this.$refs.uForm.setRules(this.rules)
  77. this.getUserOptions()
  78. },
  79. methods: {
  80. async getUserOptions() {
  81. const data = await listAllUserBind()
  82. this.userOptions.push(data)
  83. this.$comfi
  84. },
  85. showTechnicianPicker(val) {
  86. if (val.target.nodeName == 'I') {
  87. this.form.userId = ''
  88. this.form.userName = ''
  89. return
  90. }
  91. this.technicianShow = true
  92. },
  93. selectTechnicianInfo(e) {
  94. this.form.userId = e.value[0]?.id
  95. this.form.userName = e.value[0]?.name
  96. this.technicianShow = false
  97. },
  98. async handleAudit(status) {
  99. if (!!status) await this.$refs.uForm.validate()
  100. await AssignPurchasePlanUserAPI({
  101. userId: this.form.userId,
  102. userName: this.form.userName,
  103. id: this.taskId,
  104. reason: this.form.reason,
  105. businessId: this.businessId
  106. })
  107. this.loading = true
  108. await this._approveTaskWithVariables(status);
  109. },
  110. async _approveTaskWithVariables(status) {
  111. let variables = {
  112. pass: !!status
  113. };
  114. let res = await approveTaskWithVariables({
  115. id: this.taskId,
  116. reason: this.form.reason,
  117. variables
  118. })
  119. if (res.code != '-1') {
  120. this.$emit('handleAudit', {
  121. status,
  122. title: status === 0 ? '驳回' : ''
  123. });
  124. }
  125. this.loading = false
  126. },
  127. getTableValue() {
  128. return new Promise((resolve, reject) => {
  129. this.$emit('getTableValue', async (data) => {
  130. resolve(await data);
  131. });
  132. });
  133. }
  134. }
  135. }
  136. </script>
  137. <style>
  138. </style>