submit.vue 10 KB

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