submit.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <el-form-item label="采购员" v-if="taskDefinitionKey == 'purchaseLeader'" prop="technicianId"
  5. style="margin-bottom: 20px" :rules="{
  6. required: true,
  7. message: '请选择',
  8. trigger: 'change'
  9. }">
  10. <el-select v-model="form.technicianId" clearable style="width: 100%" :filterable="true">
  11. <el-option v-for="item in userOptions" @click.native="form.userName = item.name" :key="item.id"
  12. :label="item.name" :value="item.id" />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="审批建议" prop="reason" style="margin-bottom: 20px" :rules="{
  16. required: true,
  17. message: '请选择',
  18. trigger: 'change'
  19. }">
  20. <el-input type="textarea" v-model="form.reason" placeholder="请输入审批建议" />
  21. </el-form-item>
  22. </el-form>
  23. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  24. <el-button icon="el-icon-edit-outline" type="success" size="mini" @click="handleAudit(1)">通过
  25. </el-button>
  26. <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="handleAudit(0)">驳回
  27. </el-button>
  28. </div>
  29. </el-col>
  30. </template>
  31. <script>
  32. import { approveTaskWithVariables } from '@/api/bpm/task';
  33. import { listAllUserBind } from '@/api/system/organization';
  34. import { outsourceAssign, outsourceNotPass } from '@/api/bpm/components/outsourcedWarehousing/index';
  35. // 流程实例的详情页,可用于审批
  36. export default {
  37. name: '',
  38. components: {
  39. },
  40. props: {
  41. businessId: {
  42. default: ''
  43. },
  44. taskId: {
  45. default: ''
  46. },
  47. id: {
  48. default: ''
  49. },
  50. taskDefinitionKey: {
  51. default: ''
  52. }
  53. },
  54. data() {
  55. return {
  56. form: {
  57. technicianId: '',
  58. reason: ''
  59. },
  60. userOptions: []
  61. };
  62. },
  63. created() {
  64. if (this.taskDefinitionKey == 'purchaseLeader')
  65. this.userOptionsFn()
  66. },
  67. methods: {
  68. userOptionsFn() {
  69. this.userOptions = [];
  70. listAllUserBind().then((data) => {
  71. this.userOptions.push(...data);
  72. });
  73. },
  74. async handleAudit(status) {
  75. if (this.taskDefinitionKey == 'purchaseLeader') {
  76. this._approveTaskPurchaseLeader(status)
  77. } else {
  78. this._approveTaskWithVariables(status);
  79. }
  80. },
  81. async _approveTaskWithVariables(status) {
  82. let variables = {
  83. pass: !!status
  84. };
  85. approveTaskWithVariables({
  86. id: this.taskId,
  87. reason: this.form.reason,
  88. variables
  89. }).then((res) => {
  90. if (res.data.code != '-1') {
  91. this.$emit('handleAudit', {
  92. status,
  93. title: status === 0 ? '驳回' : ''
  94. });
  95. }
  96. });
  97. },
  98. async _approveTaskPurchaseLeader(status) {
  99. if (status == 1) {
  100. outsourceAssign({
  101. businessId: this.businessId,
  102. id: this.taskId,
  103. userId: this.form.technicianId,
  104. userName: this.form.userName,
  105. reason: this.form.reason,
  106. pass: true
  107. }).then((res) => {
  108. this.$emit('handleAudit', {
  109. status,
  110. title: ''
  111. });
  112. });
  113. } else if (status == 0) {
  114. outsourceNotPass({
  115. id: this.taskId,
  116. reason: this.form.reason,
  117. pass: false
  118. }).then((res) => {
  119. this.$emit('handleAudit', {
  120. status,
  121. title: '驳回'
  122. });
  123. });
  124. }
  125. },
  126. }
  127. };
  128. </script>
  129. <style lang="scss"></style>