taskSubmit.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="">
  3. <!-- 未开发核价管理手机端 -->
  4. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
  5. labelWidth='140rpx'>
  6. <u-form-item label="负责人" prop="userName" required>
  7. <u--input clearable placeholder="请选择" border="surround" v-model="form.userName"
  8. @click.native="showTechnicianPicker"></u--input>
  9. </u-form-item>
  10. <u-form-item label="审批建议" prop="reason" required>
  11. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  12. v-model="form.reason"></u--textarea>
  13. </u-form-item>
  14. </u--form>
  15. <view>
  16. <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
  17. text="通过" @click="handleAudit(1)">
  18. </u-button>
  19. <u-button style="width: 100%;" :loading='loading' type="error" icon="close" text="驳回"
  20. @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
  21. </view>
  22. <u-picker itemHeight='60' :show="technicianShow" visibleItemCount='10' :columns="userOptions" keyName="name"
  23. @confirm='selectTechnicianInfo' @cancel='technicianShow = false' title='选择负责人'></u-picker>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. approveTaskWithVariables,
  29. AssignPurchasePlanUserAPI
  30. } from '@/api/wt/index.js'
  31. import {
  32. listAllUserBind
  33. } from '@/api/common.js'
  34. export default {
  35. name: 'taskSubmit',
  36. props: {
  37. businessId: {
  38. default: ''
  39. },
  40. taskId: {
  41. default: ''
  42. },
  43. id: {
  44. default: ''
  45. },
  46. taskDefinitionKey: {
  47. default: ''
  48. }
  49. },
  50. data() {
  51. return {
  52. loading: false,
  53. technicianShow: false,
  54. userOptions: [],
  55. form: {
  56. userId: '',
  57. userName: '',
  58. reason: '',
  59. },
  60. rules: {
  61. reason: {
  62. type: 'string',
  63. required: true,
  64. message: '请输入审批建议',
  65. trigger: 'blur'
  66. },
  67. userName: {
  68. type: 'string',
  69. required: true,
  70. message: '请选择负责人',
  71. trigger: ['blur','change']
  72. },
  73. }
  74. }
  75. },
  76. mounted() {
  77. this.$refs.uForm.setRules(this.rules)
  78. this.getUserOptions()
  79. },
  80. methods: {
  81. async getUserOptions() {
  82. const data = await listAllUserBind()
  83. this.userOptions.push(data)
  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>