submit.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <el-form-item
  5. label="审批建议"
  6. style="margin-bottom: 20px"
  7. :rules="{
  8. required: true,
  9. message: '请选择',
  10. trigger: 'change'
  11. }"
  12. >
  13. <el-input
  14. type="textarea"
  15. v-model="form.reason"
  16. placeholder="请输入审批建议"
  17. />
  18. </el-form-item>
  19. </el-form>
  20. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  21. <el-button
  22. icon="el-icon-edit-outline"
  23. type="success"
  24. size="mini"
  25. :loading="isLoading"
  26. @click="handleAudit(1)"
  27. >通过
  28. </el-button>
  29. <el-button
  30. icon="el-icon-circle-close"
  31. type="danger"
  32. size="mini"
  33. @click="handleAudit(0)"
  34. v-if="!['starter'].includes(taskDefinitionKey)"
  35. >驳回
  36. </el-button>
  37. <el-dropdown
  38. @command="(command) => handleCommand(command)"
  39. style="margin-left: 30px"
  40. >
  41. <span class="el-dropdown-link"
  42. >更多<i class="el-icon-arrow-down el-icon--right"></i
  43. ></span>
  44. <el-dropdown-menu slot="dropdown">
  45. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  46. </el-dropdown-menu>
  47. </el-dropdown>
  48. <!-- <el-button
  49. icon="el-icon-circle-close"
  50. type="danger"
  51. size="mini"
  52. @click="handleBackList"
  53. >退回
  54. </el-button> -->
  55. <!-- <el-button
  56. icon="el-icon-circle-close"
  57. type="danger"
  58. size="mini"
  59. @click="handleAudit(0)"
  60. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  61. >不通过
  62. </el-button>
  63. <el-button
  64. icon="el-icon-edit-outline"
  65. type="primary"
  66. size="mini"
  67. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  68. @click="handleUpdateAssignee"
  69. >转办
  70. </el-button> -->
  71. </div>
  72. </el-col>
  73. </template>
  74. <script>
  75. import storageApi from '@/api/warehouseManagement';
  76. import { cancel } from '@/api/bpm/components/purchasingManage/outSourceSend';
  77. import { approveTaskWithVariables, rejectTask } from '@/api/bpm/task';
  78. import { getWarehouseListByIds } from '@/api/bpm/components/saleManage/saleorder';
  79. // 流程实例的详情页,可用于审批
  80. export default {
  81. name: '',
  82. components: {
  83. // Parser
  84. },
  85. props: {
  86. businessId: {
  87. default: ''
  88. },
  89. taskId: {
  90. default: ''
  91. },
  92. id: {
  93. default: ''
  94. },
  95. taskDefinitionKey: {
  96. default: ''
  97. }
  98. },
  99. data() {
  100. return {
  101. isLoading: false,
  102. form: {
  103. reason: ''
  104. },
  105. tabOptions: [
  106. { key: 'starter', permissionType: 'update', name: '发起人申请' },
  107. {
  108. key: 'deptLeaderApprove',
  109. permissionType: 'view',
  110. name: '部门主管审批'
  111. },
  112. { key: 'storeman', permissionType: 'view', name: '仓管出库' }
  113. ]
  114. };
  115. },
  116. created() {},
  117. methods: {
  118. /** 处理转办审批人 */
  119. handleUpdateAssignee() {
  120. this.$emit('handleUpdateAssignee');
  121. },
  122. /** 退回 */
  123. handleBackList() {
  124. this.$emit('handleBackList');
  125. },
  126. async handleAudit(status) {
  127. let storemanIds = '';
  128. let permissionType = this.tabOptions.find(
  129. (item) => item.key == this.taskDefinitionKey
  130. )?.permissionType;
  131. if (permissionType === 'update') {
  132. await this.getTableValue();
  133. }
  134. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  135. let arr = await this.getTableValue();
  136. let ids = arr.productList.map((item) => item.warehouseId);
  137. let data = await getWarehouseListByIds(ids || []);
  138. storemanIds = [...new Set(data.map((item) => item.ownerId))].join(
  139. ','
  140. );
  141. }
  142. if (this.taskDefinitionKey === 'storeman' && !!status) {
  143. let data = await this.getTableValue();
  144. let storageData = data.returnStorageData;
  145. // 入库来源isSkip 0-正常 1-外部(外部跳过内部审核流程)
  146. storageData.isSkip = 1;
  147. console.log(storageData);
  148. try {
  149. this.isLoading = true;
  150. const res = await storageApi.outStorage(storageData);
  151. if (res.code == 0) {
  152. let API = !!status ? approveTaskWithVariables : rejectTask;
  153. API({
  154. id: this.taskId,
  155. reason: this.form.reason,
  156. variables: {
  157. pass: !!status
  158. }
  159. }).then((res) => {
  160. if (res.code != '-1') {
  161. this.$emit('handleAudit', {
  162. status: status,
  163. title: !status ? '驳回' : ''
  164. });
  165. }
  166. this.isLoading = false;
  167. });
  168. }
  169. } catch (error) {
  170. this.isLoading = false;
  171. console.error('保存失败:', error);
  172. }
  173. } else {
  174. await this._approveTaskWithVariables(status, storemanIds);
  175. }
  176. },
  177. async _approveTaskWithVariables(status, storemanIds) {
  178. let variables = {
  179. pass: !!status,
  180. storemanIds
  181. };
  182. let API = !!status ? approveTaskWithVariables : rejectTask;
  183. API({
  184. id: this.taskId,
  185. reason: this.form.reason,
  186. variables
  187. }).then((res) => {
  188. if (res.data.code != '-1') {
  189. this.$emit('handleAudit', {
  190. status,
  191. title: status === 0 ? '驳回' : ''
  192. });
  193. }
  194. });
  195. },
  196. getTableValue() {
  197. return new Promise((resolve, reject) => {
  198. this.$emit('getTableValue', async (data) => {
  199. resolve(await data);
  200. });
  201. });
  202. },
  203. //更多
  204. handleCommand(command) {
  205. if (command === 'cancel') {
  206. this.$confirm('是否确认作废?', {
  207. type: 'warning',
  208. cancelButtonText: '取消',
  209. confirmButtonText: '确定'
  210. })
  211. .then(() => {
  212. cancel({
  213. id: this.taskId,
  214. reason: this.form.reason,
  215. businessId: this.businessId
  216. })
  217. .then(() => {
  218. this.$emit('handleClose');
  219. })
  220. .catch(() => {
  221. this.$message.error('流程作废失败');
  222. });
  223. })
  224. .catch(() => {});
  225. }
  226. }
  227. }
  228. };
  229. </script>
  230. <style lang="scss"></style>