submit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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="qualityInspector"
  7. style="margin-bottom: 20px"
  8. :rules="{
  9. required: true,
  10. message: '请选择',
  11. trigger: 'change'
  12. }"
  13. v-if="taskDefinitionKey == 'QCLeaderApprove'"
  14. >
  15. <el-select
  16. v-model="form.qualityInspector"
  17. clearable
  18. style="width: 100%"
  19. :filterable="true"
  20. >
  21. <el-option
  22. v-for="item in userOptions"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="审批建议" style="margin-bottom: 20px">
  30. <el-input
  31. type="textarea"
  32. v-model="form.reason"
  33. placeholder="请输入审批建议"
  34. />
  35. </el-form-item>
  36. </el-form>
  37. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  38. <el-button
  39. icon="el-icon-edit-outline"
  40. type="success"
  41. size="mini"
  42. @click="handleAudit(1)"
  43. v-if="
  44. !['storeManagerApprove'].includes(taskDefinitionKey) ||
  45. (['storeManagerApprove'].includes(taskDefinitionKey) &&
  46. [2].includes(Number(outInData.flowableStatus)))
  47. "
  48. >通过
  49. </el-button>
  50. <el-button
  51. icon="el-icon-edit-outline"
  52. type="success"
  53. size="mini"
  54. :loading="isSaveLoading"
  55. @click="storeManagerApprove"
  56. v-if="
  57. ['storeManagerApprove'].includes(taskDefinitionKey) &&
  58. activeComp == 'inoutBound' &&
  59. ![1, 2].includes(Number(outInData.flowableStatus))
  60. "
  61. >申请入库
  62. </el-button>
  63. <el-button
  64. icon="el-icon-circle-close"
  65. type="danger"
  66. size="mini"
  67. @click="handleAudit(0)"
  68. v-if="
  69. !['starter', 'qualityInspectionFeedback'].includes(
  70. taskDefinitionKey
  71. ) && ![1, 2].includes(+outInData.flowableStatus)
  72. "
  73. >驳回
  74. </el-button>
  75. <el-dropdown
  76. @command="(command) => handleCommand(command)"
  77. style="margin-left: 30px"
  78. >
  79. <span class="el-dropdown-link"
  80. >更多<i class="el-icon-arrow-down el-icon--right"></i
  81. ></span>
  82. <el-dropdown-menu slot="dropdown">
  83. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  84. </el-dropdown-menu>
  85. </el-dropdown>
  86. <!-- <el-button
  87. icon="el-icon-circle-close"
  88. type="danger"
  89. size="mini"
  90. @click="handleBackList"
  91. >退回
  92. </el-button> -->
  93. <!-- <el-button
  94. icon="el-icon-circle-close"
  95. type="danger"
  96. size="mini"
  97. @click="handleAudit(0)"
  98. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  99. >不通过
  100. </el-button>
  101. <el-button
  102. icon="el-icon-edit-outline"
  103. type="primary"
  104. size="mini"
  105. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  106. @click="handleUpdateAssignee"
  107. >转办
  108. </el-button> -->
  109. <ele-modal
  110. custom-class="ele-dialog-form long-dialog-form"
  111. :centered="true"
  112. v-if="visible"
  113. :visible.sync="visible"
  114. :title="title"
  115. :close-on-click-modal="false"
  116. width="80%"
  117. :modal="false"
  118. @close="cancel"
  119. >
  120. </ele-modal>
  121. </div>
  122. </el-col>
  123. </template>
  124. <script>
  125. import {
  126. UpdateReceiveInformation,
  127. getReceiveSaleOrderrecordDetail,
  128. cancel
  129. } from '@/api/bpm/components/purchasingManage/purchaseorderreceive';
  130. import { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
  131. import { getWarehouseListByIds } from '@/api/bpm/components/saleManage/saleorder';
  132. import {
  133. getOutInBySourceBizNo,
  134. uploadQualityFile
  135. } from '@/api/classifyManage';
  136. import { listAllUserBind } from '@/api/system/organization';
  137. // import outin from '@/api/warehouseManagement/outin';
  138. import storageApi from '@/api/warehouseManagement';
  139. // 流程实例的详情页,可用于审批
  140. export default {
  141. name: '',
  142. components: {},
  143. props: {
  144. businessId: {
  145. default: ''
  146. },
  147. taskId: {
  148. default: ''
  149. },
  150. id: {
  151. default: ''
  152. },
  153. id: {
  154. default: ''
  155. },
  156. taskDefinitionKey: {
  157. default: ''
  158. },
  159. fromUser: {
  160. default: ''
  161. },
  162. },
  163. data() {
  164. return {
  165. isSaveLoading: false,
  166. form: {
  167. qualityInspector: '',
  168. reason: ''
  169. },
  170. outInData: {
  171. flowableStatus: ''
  172. },
  173. visible: false,
  174. userOptions: [],
  175. activeComp: ''
  176. };
  177. },
  178. async created() {
  179. this.userOptions = [];
  180. listAllUserBind().then((data) => {
  181. this.userOptions.push(...data);
  182. });
  183. if (this.taskDefinitionKey == 'storeManagerApprove') {
  184. let data = await getReceiveSaleOrderrecordDetail(this.businessId);
  185. try {
  186. this.outInData = await storageApi.getInfoBySourceBizNo(
  187. data.receiveNo
  188. );
  189. console.log('outInData----------', this.outInData);
  190. } catch (error) {}
  191. }
  192. },
  193. mounted() {
  194. console.log('taskDefinitionKey-------------', this.taskDefinitionKey);
  195. },
  196. methods: {
  197. cancel() {
  198. this.visible = false;
  199. },
  200. async storeManagerApprove() {
  201. let res = await this.getTableValue();
  202. let storageData = res.returnStorageData;
  203. console.log('storeManagerApprove', storageData);
  204. // isSkip 0-正常 1-外部(外部跳过内部审核流程)
  205. storageData.isSkip = 1;
  206. storageData.fromUser = this.fromUser;
  207. try {
  208. this.isSaveLoading = true;
  209. await storageApi.storage(storageData);
  210. approveTaskWithVariables({
  211. id: this.taskId,
  212. reason: this.form.reason,
  213. variables: {
  214. pass: true
  215. }
  216. }).then((res) => {
  217. if (res.code != '-1') {
  218. this.$emit('handleAudit', {
  219. status: 1,
  220. title: '入库'
  221. });
  222. }
  223. this.isSaveLoading = false;
  224. });
  225. } catch (error) {
  226. this.isSaveLoading = false;
  227. this.$message.error('保存失败');
  228. }
  229. },
  230. /** 处理转办审批人 */
  231. handleUpdateAssignee() {
  232. this.$emit('handleUpdateAssignee');
  233. },
  234. /** 退回 */
  235. handleBackList() {
  236. this.$emit('handleBackList');
  237. },
  238. activeCompChange(activeComp) {
  239. this.activeComp = activeComp;
  240. },
  241. async handleAudit(status) {
  242. let storemanIds = '';
  243. //发起人补充
  244. if (this.taskDefinitionKey === 'starter') {
  245. let arr = await this.getTableValue();
  246. if (!arr) {
  247. return;
  248. }
  249. let ids = arr.productList.map((item) => item.warehouseId);
  250. let warehouseList = await getWarehouseListByIds(ids || []);
  251. storemanIds = warehouseList.map((item) => item.ownerId);
  252. let data = await UpdateReceiveInformation(arr);
  253. if (data.code != '0') {
  254. return;
  255. }
  256. }
  257. // if (this.taskDefinitionKey === 'deptLeaderApprove') {
  258. // let arr = await this.getTableValue();
  259. // let ids = arr.form.productList.map((item) => item.warehouseId);
  260. // let data = await getWarehouseListByIds(ids || []);
  261. // storemanIds = data.map((item) => item.ownerId);
  262. // }
  263. if (this.taskDefinitionKey === 'QCLeaderApprove' && status) {
  264. if (!this.form.qualityInspector) {
  265. return this.$message.error('请选择质检员!');
  266. }
  267. }
  268. if (this.taskDefinitionKey === 'qualityInspection' && status) {
  269. let arr = await this.getTableValue(); // 是否全部已检
  270. // console.log(arr,'arr')
  271. // return;
  272. if (!arr.isAllChecked) {
  273. return this.$message.error('请完成质检!');
  274. }
  275. }
  276. if (this.taskDefinitionKey === 'qualityInspectionFeedback' && status) {
  277. let arr = await this.getTableValue();
  278. console.log('arr.qualityInspector', arr);
  279. // if (arr.qualityInspector.qualityFile.length == 0) {
  280. // return this.$message.error('请上传回执附件!');
  281. // }
  282. // console.log(arr);
  283. // await uploadQualityFile(arr.qualityInspector);
  284. if (
  285. arr.qualityInspector.qualityFile &&
  286. arr.qualityInspector.qualityFile.length > 0
  287. ) {
  288. await storageApi.uploadQualityFile(arr.qualityInspector);
  289. }
  290. }
  291. await this._approveTaskWithVariables(
  292. status,
  293. storemanIds.length > 0
  294. ? Array.from(new Set(storemanIds)).toString()
  295. : ''
  296. );
  297. },
  298. async _approveTaskWithVariables(status, storemanIds) {
  299. let variables = {
  300. pass: !!status
  301. };
  302. if (storemanIds) {
  303. variables['storemanIds'] = storemanIds;
  304. }
  305. if (this.form.qualityInspector) {
  306. variables['qualityInspector'] = this.form.qualityInspector;
  307. }
  308. let API = !!status ? approveTaskWithVariables : rejectTask;
  309. API({
  310. id: this.taskId,
  311. reason: this.form.reason,
  312. variables
  313. }).then((res) => {
  314. if (res.data.code != '-1') {
  315. this.$emit('handleAudit', {
  316. status,
  317. title: status === 0 ? '驳回' : ''
  318. });
  319. }
  320. });
  321. },
  322. getTableValue() {
  323. return new Promise((resolve, reject) => {
  324. this.$emit('getTableValue', async (data) => {
  325. resolve(await data);
  326. });
  327. });
  328. },
  329. //更多
  330. handleCommand(command) {
  331. if (command === 'cancel') {
  332. this.$confirm('是否确认作废?', {
  333. type: 'warning',
  334. cancelButtonText: '取消',
  335. confirmButtonText: '确定'
  336. })
  337. .then(() => {
  338. cancelTask({
  339. id: this.id,
  340. taskId: this.taskId,
  341. reason: this.form.reason,
  342. businessId: this.businessId
  343. })
  344. .then(() => {
  345. this.$emit('handleClose');
  346. })
  347. .catch(() => {
  348. this.$message.error('流程作废失败');
  349. });
  350. })
  351. .catch(() => {});
  352. }
  353. }
  354. }
  355. };
  356. </script>
  357. <style lang="scss"></style>