submit.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <el-form-item label="审批建议" style="margin-bottom: 20px">
  5. <el-input
  6. type="textarea"
  7. v-model="form.reason"
  8. placeholder="请输入审批建议"
  9. />
  10. </el-form-item>
  11. </el-form>
  12. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  13. <el-button
  14. icon="el-icon-edit-outline"
  15. type="success"
  16. size="mini"
  17. v-click-once
  18. @click="handleAudit(1)"
  19. v-if="!['storeManagerApprove'].includes(taskDefinitionKey)"
  20. >通过
  21. </el-button>
  22. <el-button
  23. icon="el-icon-circle-close"
  24. type="danger"
  25. size="mini"
  26. v-click-once
  27. @click="rejectTask(0)"
  28. >驳回
  29. </el-button>
  30. <!-- <el-button
  31. icon="el-icon-circle-close"
  32. type="danger"
  33. size="mini"
  34. @click="handleBackList"
  35. >退回
  36. </el-button> -->
  37. <!-- <el-button
  38. icon="el-icon-circle-close"
  39. type="danger"
  40. size="mini"
  41. @click="handleAudit(0)"
  42. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  43. >不通过
  44. </el-button>
  45. <el-button
  46. icon="el-icon-edit-outline"
  47. type="primary"
  48. size="mini"
  49. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  50. @click="handleUpdateAssignee"
  51. >转办
  52. </el-button> -->
  53. </div>
  54. </el-col>
  55. </template>
  56. <script>
  57. import {
  58. approveTaskWithVariables,
  59. rejectTask,
  60. cancelTask
  61. } from '@/api/bpm/task';
  62. import {
  63. generateReport,
  64. updateData
  65. } from '@/api/bpm/components/qualityReportApproval/qualityReportApproval';
  66. import dayjs from 'dayjs';
  67. // 流程实例的详情页,可用于审批
  68. export default {
  69. name: '',
  70. components: {},
  71. props: {
  72. businessId: {
  73. default: ''
  74. },
  75. taskId: {
  76. default: ''
  77. },
  78. id: {
  79. default: ''
  80. },
  81. taskDefinitionKey: {
  82. default: ''
  83. },
  84. businessType: {
  85. default: ''
  86. }
  87. },
  88. data() {
  89. return {
  90. form: {
  91. reason: '同意'
  92. },
  93. isSaveLoading: false
  94. };
  95. },
  96. created() {},
  97. methods: {
  98. /** 处理转办审批人 */
  99. handleUpdateAssignee() {
  100. this.$emit('handleUpdateAssignee');
  101. },
  102. /** 退回 */
  103. handleBackList() {
  104. this.$emit('handleBackList');
  105. },
  106. async handleAudit(status) {
  107. if (
  108. this.businessType?.includes('检测报告单') ||
  109. this.businessType?.includes('不良品处置')
  110. ) {
  111. const data = await this.getTableValue();
  112. if (data == 'isNodisposeType') {
  113. this.$message.warning('有不良品未处置,请检查!');
  114. return;
  115. }
  116. if (this.businessType?.includes('检测报告单')) {
  117. await generateReport(data);
  118. } else {
  119. let userInfo = this.$store.state.user.info;
  120. console.log(data, 'data');
  121. data.contentText.basicInfoData.remarks.push({
  122. department: userInfo?.groupName,
  123. opinion: this.form.reason,
  124. sign: userInfo?.name,
  125. date: dayjs().format('YYYY-MM-DD')
  126. });
  127. await updateData({
  128. ...data.unqualifiedProducts,
  129. contentText: data.contentText
  130. });
  131. }
  132. }
  133. // return;
  134. let API = !!status ? approveTaskWithVariables : rejectTask;
  135. await API({
  136. id: this.taskId,
  137. reason: this.form.reason,
  138. variables: {
  139. // userId: userInfo?.id,
  140. pass: !!status
  141. }
  142. }).then((res) => {
  143. if (res.data.code == 0) {
  144. this.$emit('handleAudit', {
  145. status,
  146. title: status === 0 ? '驳回' : ''
  147. });
  148. }
  149. });
  150. },
  151. async rejectTask(status) {
  152. await rejectTask({
  153. id: this.taskId,
  154. reason: this.form.reason,
  155. variables: {
  156. pass: !!status
  157. }
  158. });
  159. this.$emit('handleAudit', {
  160. status,
  161. title: status === 0 ? '驳回' : ''
  162. });
  163. },
  164. getTableValue() {
  165. return new Promise((resolve, reject) => {
  166. this.$emit('getTableValue', async (data) => {
  167. resolve(await data);
  168. });
  169. });
  170. },
  171. //更多
  172. handleCommand(command) {
  173. if (command === 'cancel') {
  174. this.$confirm('是否确认作废?', {
  175. type: 'warning',
  176. cancelButtonText: '取消',
  177. confirmButtonText: '确定'
  178. })
  179. .then(() => {
  180. cancelTask({
  181. id: this.id,
  182. taskId: this.taskId,
  183. reason: this.form.reason,
  184. businessId: this.businessId
  185. })
  186. .then(() => {
  187. this.$emit('handleClose');
  188. })
  189. .catch(() => {
  190. this.$message.error('流程作废失败');
  191. });
  192. })
  193. .catch(() => {});
  194. }
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss"></style>