taskSubmit.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. getWarehouseListByIdsAPI
  23. } from '@/api/wt/index.js'
  24. export default {
  25. name: 'taskSubmit',
  26. props: {
  27. businessId: {
  28. default: ''
  29. },
  30. taskId: {
  31. default: ''
  32. },
  33. id: {
  34. default: ''
  35. },
  36. taskDefinitionKey: {
  37. default: ''
  38. }
  39. },
  40. data() {
  41. return {
  42. loading: false,
  43. form: {
  44. technicianId: '',
  45. reason: '',
  46. },
  47. rules: {
  48. reason: {
  49. type: 'string',
  50. required: true,
  51. message: '请输入审批建议',
  52. trigger: 'blur'
  53. }
  54. },
  55. tabOptions: [{
  56. key: 'deptLeaderApprove',
  57. permissionType: 'view',
  58. name: '部门主管审批',
  59. }],
  60. }
  61. },
  62. mounted() {
  63. this.$refs.uForm.setRules(this.rules)
  64. },
  65. methods: {
  66. async handleAudit(status) {
  67. if (!!status) await this.$refs.uForm.validate()
  68. let storemanIds = []
  69. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  70. let form = await this.getTableValue();
  71. let ids = form.productList.map((item) => item.warehouseId);
  72. let data = await getWarehouseListByIdsAPI(ids || []);
  73. storemanIds = data.map((item) => item.ownerId) || [];
  74. }
  75. if (!storemanIds.length) return uni.$u.toast('未配置仓管人员,请检查')
  76. this.loading = true
  77. await this._approveTaskWithVariables(status, Array.from(new Set(storemanIds)).toString());
  78. },
  79. async _approveTaskWithVariables(status,storemanIds='') {
  80. let variables = {
  81. pass: !!status,
  82. storemanIds
  83. };
  84. let res = await approveTaskWithVariables({
  85. id: this.taskId,
  86. reason: this.form.reason,
  87. variables
  88. })
  89. if (res.code != '-1') {
  90. this.$emit('handleAudit', {
  91. status,
  92. title: status === 0 ? '驳回' : ''
  93. });
  94. }
  95. this.loading = false
  96. },
  97. getTableValue() {
  98. return new Promise((resolve, reject) => {
  99. this.$emit('getTableValue', async (data) => {
  100. resolve(await data);
  101. });
  102. });
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. </style>