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