taskSubmit.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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="reason" required>
  7. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  8. v-model="form.reason"></u--textarea>
  9. </u-form-item>
  10. </u--form>
  11. <!-- <view>
  12. <u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
  13. text="通过" @click="handleAudit(1)">
  14. </u-button>
  15. <u-button style="width: 100%;" :loading='loading' type="error" icon="close" text="驳回"
  16. @click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
  17. </view> -->
  18. <view class="btnList">
  19. <u-button style="width: 45%;margin-bottom: 10rpx;" :loading='loading' type="success" text="通过"
  20. @click="handleAudit(1)">
  21. </u-button>
  22. <u-button style="width: 45%;" :loading='loading' type="error" text="驳回" @click="handleAudit(0)"></u-button>
  23. </view>
  24. <view class="btnConcel">
  25. <u-button @click="showAction = true">更多</u-button>
  26. </view>
  27. <u-action-sheet :actions="actionList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="更多操作" :show="showAction" @close="showAction = false" @select="selectActionClick"></u-action-sheet>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. approveTaskWithVariables,
  33. AssignPurchasePlanUserAPI,
  34. rejectTask,
  35. cancelTask
  36. } from '@/api/wt/index.js'
  37. import { UpdateInformation } from '@/api/purchasingManage/inquiryManage'
  38. import {
  39. listAllUserBind
  40. } from '@/api/common.js'
  41. export default {
  42. name: 'taskSubmit',
  43. props: {
  44. businessId: {
  45. default: ''
  46. },
  47. taskId: {
  48. default: ''
  49. },
  50. id: {
  51. default: ''
  52. },
  53. taskDefinitionKey: {
  54. default: ''
  55. }
  56. },
  57. data() {
  58. return {
  59. showAction: false,
  60. loading: false,
  61. technicianShow: false,
  62. userOptions: [],
  63. form: {
  64. userId: '',
  65. userName: '',
  66. reason: '',
  67. },
  68. actionList: [{
  69. name: '作废',
  70. fontSize: '28',
  71. color: '#ffaa7f'
  72. }],
  73. rules: {
  74. reason: {
  75. type: 'string',
  76. required: true,
  77. message: '请输入审批建议',
  78. trigger: 'blur'
  79. },
  80. userName: {
  81. type: 'string',
  82. required: true,
  83. message: '请选择负责人',
  84. trigger: ['blur','change']
  85. },
  86. }
  87. }
  88. },
  89. mounted() {
  90. this.$refs.uForm.setRules(this.rules)
  91. // this.getUserOptions()
  92. },
  93. methods: {
  94. async getUserOptions() {
  95. const data = await listAllUserBind()
  96. this.userOptions.push(data)
  97. },
  98. showTechnicianPicker(val) {
  99. if (val.target.nodeName == 'I') {
  100. this.form.userId = ''
  101. this.form.userName = ''
  102. return
  103. }
  104. this.technicianShow = true
  105. },
  106. selectTechnicianInfo(e) {
  107. this.form.userId = e.value[0]?.id
  108. this.form.userName = e.value[0]?.name
  109. this.technicianShow = false
  110. },
  111. async handleAudit(status) {
  112. if (!!status) await this.$refs.uForm.validate()
  113. let res = await this.getTableValue();
  114. console.log('res~~~~', res)
  115. const data = await UpdateInformation(res)
  116. // if (data.code != '0') {
  117. // return;
  118. // }
  119. this.loading = true
  120. await this._approveTaskWithVariables(status);
  121. },
  122. async _approveTaskWithVariables(status) {
  123. let variables = {
  124. pass: !!status
  125. };
  126. let API = !!status ? approveTaskWithVariables : rejectTask;
  127. let res = await API({
  128. id: this.taskId,
  129. reason: this.form.reason,
  130. variables
  131. })
  132. if (res.code != '-1') {
  133. this.$emit('handleAudit', {
  134. status,
  135. title: status === 0 ? '驳回' : ''
  136. });
  137. }
  138. this.loading = false
  139. },
  140. selectActionClick(item) {
  141. console.log('selectActionClick', item)
  142. if (item.name == '作废') {
  143. uni.showModal({
  144. title: '提示',
  145. content: '是否确认作废?',
  146. success: (res) => {
  147. if (res.confirm) {
  148. this.loading = true
  149. cancelTask({
  150. taskId: this.taskId,
  151. id: this.id,
  152. reason: this.form.reason,
  153. businessId: this.businessId,
  154. }).then(() => {
  155. if (res.code != '-1') {
  156. this.loading = false
  157. this.$emit('handleAudit', {
  158. title: '作废'
  159. });
  160. }
  161. }).catch(() => {
  162. this.loading = false
  163. this.$message.error("流程作废失败");
  164. });
  165. } else if (res.cancel) {
  166. console.log('用户点击取消');
  167. }
  168. }
  169. });
  170. }
  171. },
  172. getTableValue() {
  173. return new Promise((resolve, reject) => {
  174. this.$emit('getTableValue', async (data) => {
  175. resolve(await data);
  176. });
  177. });
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .btnList {
  184. display: flex;
  185. }
  186. .btnConcel {
  187. margin-top: 20rpx;
  188. }
  189. </style>