taskSubmit.vue 4.7 KB

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