submit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 } 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. },
  160. data() {
  161. return {
  162. isSaveLoading: false,
  163. form: {
  164. qualityInspector: '',
  165. reason: ''
  166. },
  167. outInData: {
  168. flowableStatus: ''
  169. },
  170. visible: false,
  171. userOptions: [],
  172. activeComp: ''
  173. };
  174. },
  175. async created() {
  176. this.userOptions = [];
  177. listAllUserBind().then((data) => {
  178. this.userOptions.push(...data);
  179. });
  180. if (this.taskDefinitionKey == 'storeManagerApprove') {
  181. let data = await getReceiveSaleOrderrecordDetail(this.businessId);
  182. try {
  183. this.outInData = await storageApi.getInfoBySourceBizNo(
  184. data.receiveNo
  185. );
  186. console.log('outInData----------', this.outInData);
  187. } catch (error) {}
  188. }
  189. },
  190. mounted() {
  191. console.log('taskDefinitionKey-------------', this.taskDefinitionKey);
  192. },
  193. methods: {
  194. cancel() {
  195. this.visible = false;
  196. },
  197. async storeManagerApprove() {
  198. let res = await this.getTableValue();
  199. let storageData = res.returnStorageData;
  200. console.log(storageData);
  201. // isSkip 0-正常 1-外部(外部跳过内部审核流程)
  202. storageData.isSkip = 1;
  203. try {
  204. this.isSaveLoading = true;
  205. await storageApi.storage(storageData);
  206. approveTaskWithVariables({
  207. id: this.taskId,
  208. reason: this.form.reason,
  209. variables: {
  210. pass: true
  211. }
  212. }).then((res) => {
  213. if (res.code != '-1') {
  214. this.$emit('handleAudit', {
  215. status: 1,
  216. title: '入库'
  217. });
  218. }
  219. this.isSaveLoading = false;
  220. });
  221. } catch (error) {
  222. this.isSaveLoading = false;
  223. this.$message.error('保存失败');
  224. }
  225. },
  226. /** 处理转办审批人 */
  227. handleUpdateAssignee() {
  228. this.$emit('handleUpdateAssignee');
  229. },
  230. /** 退回 */
  231. handleBackList() {
  232. this.$emit('handleBackList');
  233. },
  234. activeCompChange(activeComp) {
  235. this.activeComp = activeComp;
  236. },
  237. async handleAudit(status) {
  238. let storemanIds = '';
  239. //发起人补充
  240. if (this.taskDefinitionKey === 'starter') {
  241. let arr = await this.getTableValue();
  242. if (!arr) {
  243. return;
  244. }
  245. let ids = arr.productList.map((item) => item.warehouseId);
  246. let warehouseList = await getWarehouseListByIds(ids || []);
  247. storemanIds = warehouseList.map((item) => item.ownerId);
  248. let data = await UpdateReceiveInformation(arr);
  249. if (data.code != '0') {
  250. return;
  251. }
  252. }
  253. // if (this.taskDefinitionKey === 'deptLeaderApprove') {
  254. // let arr = await this.getTableValue();
  255. // let ids = arr.form.productList.map((item) => item.warehouseId);
  256. // let data = await getWarehouseListByIds(ids || []);
  257. // storemanIds = data.map((item) => item.ownerId);
  258. // }
  259. if (this.taskDefinitionKey === 'QCLeaderApprove' && status) {
  260. if (!this.form.qualityInspector) {
  261. return this.$message.error('请选择质检员!');
  262. }
  263. }
  264. if (this.taskDefinitionKey === 'qualityInspection' && status) {
  265. let arr = await this.getTableValue(); // 是否全部已检
  266. // console.log(arr,'arr')
  267. // return;
  268. if (!arr.isAllChecked) {
  269. return this.$message.error('请完成质检!');
  270. }
  271. }
  272. if (this.taskDefinitionKey === 'qualityInspectionFeedback' && status) {
  273. let arr = await this.getTableValue();
  274. console.log('arr.qualityInspector', arr);
  275. // if (arr.qualityInspector.qualityFile.length == 0) {
  276. // return this.$message.error('请上传回执附件!');
  277. // }
  278. // console.log(arr);
  279. // await uploadQualityFile(arr.qualityInspector);
  280. if (
  281. arr.qualityInspector.qualityFile &&
  282. arr.qualityInspector.qualityFile.length > 0
  283. ) {
  284. await storageApi.uploadQualityFile(arr.qualityInspector);
  285. }
  286. }
  287. await this._approveTaskWithVariables(
  288. status,
  289. storemanIds.length > 0
  290. ? Array.from(new Set(storemanIds)).toString()
  291. : ''
  292. );
  293. },
  294. async _approveTaskWithVariables(status, storemanIds) {
  295. let variables = {
  296. pass: !!status
  297. };
  298. if (storemanIds) {
  299. variables['storemanIds'] = storemanIds;
  300. }
  301. if (this.form.qualityInspector) {
  302. variables['qualityInspector'] = this.form.qualityInspector;
  303. }
  304. let API = !!status ? approveTaskWithVariables : rejectTask;
  305. API({
  306. id: this.taskId,
  307. reason: this.form.reason,
  308. variables
  309. }).then((res) => {
  310. if (res.data.code != '-1') {
  311. this.$emit('handleAudit', {
  312. status,
  313. title: status === 0 ? '驳回' : ''
  314. });
  315. }
  316. });
  317. },
  318. getTableValue() {
  319. return new Promise((resolve, reject) => {
  320. this.$emit('getTableValue', async (data) => {
  321. resolve(await data);
  322. });
  323. });
  324. },
  325. //更多
  326. handleCommand(command) {
  327. if (command === 'cancel') {
  328. this.$confirm('是否确认作废?', {
  329. type: 'warning',
  330. cancelButtonText: '取消',
  331. confirmButtonText: '确定'
  332. })
  333. .then(() => {
  334. cancel({
  335. id: this.taskId,
  336. reason: this.form.reason,
  337. businessId: this.businessId
  338. })
  339. .then(() => {
  340. this.$emit('handleClose');
  341. })
  342. .catch(() => {
  343. this.$message.error('流程作废失败');
  344. });
  345. })
  346. .catch(() => {});
  347. }
  348. }
  349. }
  350. };
  351. </script>
  352. <style lang="scss"></style>