taskSubmit.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. if (
  114. (this.taskDefinitionKey === 'starter' ||
  115. this.taskDefinitionKey === 'deptLeaderApprove') &&
  116. status === 1
  117. ) {
  118. let res = await this.getTableValue();
  119. if (!res) {
  120. return;
  121. }
  122. console.log('res~~~~', res)
  123. const data = await UpdateInformation(res)
  124. // if (data.code != '0') {
  125. // return;
  126. // }
  127. }
  128. this.loading = true
  129. await this._approveTaskWithVariables(status);
  130. },
  131. async _approveTaskWithVariables(status) {
  132. let variables = {
  133. pass: !!status
  134. };
  135. let API = !!status ? approveTaskWithVariables : rejectTask;
  136. let res = await API({
  137. id: this.taskId,
  138. reason: this.form.reason,
  139. variables
  140. })
  141. if (res.code != '-1') {
  142. this.$emit('handleAudit', {
  143. status,
  144. title: status === 0 ? '驳回' : ''
  145. });
  146. }
  147. this.loading = false
  148. },
  149. selectActionClick(item) {
  150. console.log('selectActionClick', item)
  151. if (item.name == '作废') {
  152. uni.showModal({
  153. title: '提示',
  154. content: '是否确认作废?',
  155. success: (res) => {
  156. if (res.confirm) {
  157. this.loading = true
  158. cancelTask({
  159. taskId: this.taskId,
  160. id: this.id,
  161. reason: this.form.reason,
  162. businessId: this.businessId,
  163. }).then(() => {
  164. if (res.code != '-1') {
  165. this.loading = false
  166. this.$emit('handleAudit', {
  167. title: '作废'
  168. });
  169. }
  170. }).catch(() => {
  171. this.loading = false
  172. this.$message.error("流程作废失败");
  173. });
  174. } else if (res.cancel) {
  175. console.log('用户点击取消');
  176. }
  177. }
  178. });
  179. }
  180. },
  181. getTableValue() {
  182. return new Promise((resolve, reject) => {
  183. this.$emit('getTableValue', async (data) => {
  184. resolve(await data);
  185. });
  186. });
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .btnList {
  193. display: flex;
  194. }
  195. .btnConcel {
  196. margin-top: 20rpx;
  197. }
  198. </style>