submit.vue 6.5 KB

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