submit.vue 6.2 KB

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