addInvoiceDialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. v-if="visible"
  6. :visible.sync="visible"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. width="70%"
  10. @close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <el-form
  15. ref="form"
  16. :model="form"
  17. :rules="rules"
  18. class="el-form-box"
  19. label-width="120px"
  20. >
  21. <headerTitle title="收货信息"></headerTitle>
  22. <el-row :gutter="20">
  23. <el-col :span="12">
  24. <el-form-item label="选择订单" prop="orderNo">
  25. <el-input
  26. clearable
  27. v-model="form.orderNo"
  28. @click.native="handleOrderBtn"
  29. placeholder="请输入"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item label="委外发货单">
  35. <el-input
  36. clearable
  37. v-model="form.outsourceSendCode"
  38. @click.native="handleOutsourceSend"
  39. placeholder="请输入"
  40. />
  41. </el-form-item>
  42. </el-col>
  43. </el-row>
  44. <el-row :gutter="20">
  45. <el-col :span="12">
  46. <el-form-item label="供应商名称" prop="supplierName">
  47. <el-input
  48. clearable
  49. v-model="form.supplierName"
  50. disabled
  51. placeholder="请输入"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="12">
  56. <el-form-item label="供应商联系人" prop="linkName">
  57. <el-input clearable v-model="form.linkName" placeholder="请输入" />
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. <el-row :gutter="20">
  62. <el-col :span="12">
  63. <el-form-item label="订单类型">
  64. <el-input v-model="form.sourceTypeName" disabled></el-input>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="12">
  68. <el-form-item label="供应商电话" prop="linkPhone">
  69. <el-input clearable v-model="form.linkPhone" placeholder="请输入" />
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. <el-row :gutter="20">
  74. <el-col :span="12">
  75. <el-form-item label="车辆号" prop="carNo">
  76. <el-input clearable v-model="form.carNo" placeholder="请输入" />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="12">
  80. <el-form-item label="送货单号" prop="sendNoteNo">
  81. <el-input
  82. clearable
  83. v-model="form.sendNoteNo"
  84. placeholder="请输入"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. <el-row :gutter="20">
  90. <el-col :span="12">
  91. <el-form-item prop="receiveDate" label="收货日期">
  92. <el-date-picker
  93. style="width: 100%"
  94. v-model="form.receiveDate"
  95. type="date"
  96. placeholder="选择日期"
  97. :picker-options="pickerOptions"
  98. >
  99. </el-date-picker>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. <el-row :gutter="20">
  104. <!-- <el-col :span="12">
  105. <el-form-item prop="isQmsCheck" label="是否需要质检">
  106. <el-select v-model="form.isQmsCheck" style="width: 100%" placeholder="请选择">
  107. <el-option label="是" :value="1"></el-option>
  108. <el-option label="否" :value="0"></el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-col> -->
  112. <el-col :span="12">
  113. <el-form-item prop="receiveFiles" label="附件">
  114. <fileMain v-model="form.receiveFiles"></fileMain>
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. </el-form>
  119. <headerTitle title="物品清单" style="margin-top: 30px"></headerTitle>
  120. <inventoryTable
  121. :pricingWay="form.pricingWay"
  122. :sourceType="form.sourceType"
  123. :outsourceSendCode="form.outsourceSendCode"
  124. :is-show-supplier-mark="true"
  125. ref="inventoryTableref"
  126. :orderId="form.orderId"
  127. :productType="2"
  128. ></inventoryTable>
  129. <div slot="footer" class="footer">
  130. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  131. <el-button
  132. type="primary"
  133. v-if="isNeed_process_is_close"
  134. @click="save('sub')"
  135. v-click-once
  136. >提交</el-button
  137. >
  138. <el-button @click="cancel">返回</el-button>
  139. </div>
  140. <!-- 采购订单 -->
  141. <orderListDialog
  142. ref="orderListDialogRef"
  143. @changeParent="changeOrder"
  144. :isOutsourcing="1"
  145. ></orderListDialog>
  146. <!-- 委外发货单 -->
  147. <out-source-send-dialog
  148. :out-source-send-dialog-flag.sync="outSourceSendDialogFlag"
  149. v-if="outSourceSendDialogFlag"
  150. ref="outSourceSendDialogRef"
  151. :searchParams="searchParams"
  152. @changeParent="getOutSourceInfo"
  153. ></out-source-send-dialog>
  154. <process-submit-dialog
  155. :isNotNeedProcess="false"
  156. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  157. v-if="processSubmitDialogFlag"
  158. ref="processSubmitDialogRef"
  159. @reload="reload"
  160. ></process-submit-dialog>
  161. </ele-modal>
  162. </template>
  163. <script>
  164. import { acceptUnpackoptions } from '@/enum/dict';
  165. import dictMixins from '@/mixins/dictMixins';
  166. import { getByIdCondition } from '@/api/purchasingManage/purchaseOrder';
  167. import {
  168. addReceiveInformation,
  169. UpdateReceiveInformation,
  170. getReceiveSaleOrderrecordDetail
  171. } from '@/api/purchasingManage/purchaseorderreceive';
  172. import inventoryTable from './inventoryTable.vue';
  173. import orderListDialog from './orderListDialog.vue';
  174. import { copyObj } from '@/utils/util';
  175. import outSourceSendDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/outSourceSendDialog.vue';
  176. import { getPurchaseOutSourceSendDetailAPI } from '@/api/purchasingManage/outSourceSend';
  177. import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
  178. // import fileMain from '@/components/addDoc/index.vue';
  179. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  180. export default {
  181. mixins: [dictMixins],
  182. components: {
  183. processSubmitDialog,
  184. // fileMain,
  185. inventoryTable,
  186. orderListDialog,
  187. outSourceSendDialog
  188. },
  189. data() {
  190. let formDef = {
  191. id: '',
  192. contractId: '',
  193. isQmsCheck: 0,
  194. receiveFiles: [],
  195. contractName: '',
  196. carNo: '',
  197. carId: '',
  198. linkName: '',
  199. linkPhone: '',
  200. orderNo: '',
  201. orderId: '',
  202. outsourceSendCode: '',
  203. outsourceSendId: '',
  204. sendNoteNo: '',
  205. sourceTypeName: '',
  206. receiveDate: '',
  207. receiveType: ''
  208. };
  209. return {
  210. fullscreen: false,
  211. searchParams: {},
  212. detailData: {},
  213. payWayOptions: [],
  214. delDetailIds: [],
  215. linkNameOptions: [],
  216. acceptUnpackoptions,
  217. visible: false,
  218. outSourceSendDialogFlag: false,
  219. processSubmitDialogFlag: false,
  220. title: '',
  221. row: {},
  222. activeName: 'base',
  223. formDef,
  224. form: copyObj(formDef),
  225. tableBankData: [],
  226. tableLinkData: [],
  227. businessId: '',
  228. // 组织机构树形结构数据
  229. rules: {
  230. orderNo: [
  231. { required: true, message: '请选择采购订单', trigger: 'change' }
  232. ],
  233. receiveType: [
  234. { required: true, message: '请选择采购单类型', trigger: 'change' }
  235. ]
  236. },
  237. // 提交状态
  238. loading: false,
  239. // 是否是修改
  240. isUpdate: false,
  241. pickerOptions: {
  242. disabledDate(time) {
  243. return time.getTime() > Date.now();
  244. }
  245. }
  246. };
  247. },
  248. computed: {
  249. allcountAmount() {
  250. return this.$store.state.order.allcountAmount;
  251. }
  252. },
  253. methods: {
  254. //选择订单回调
  255. changeOrder(obj) {
  256. this.form = Object.assign({}, this.form, {
  257. orderId: obj.id,
  258. orderNo: obj.orderNo,
  259. outsourceSendCode: '',
  260. outsourceSendId: ''
  261. });
  262. this.getPurchaseorderDetail(obj.id);
  263. },
  264. //获取订单详情
  265. async getPurchaseorderDetail(id) {
  266. this.loading = true;
  267. const data = await getByIdCondition(id, 2);
  268. this.loading = false;
  269. if (data) {
  270. this.$nextTick(() => {
  271. let {
  272. partbId,
  273. partbName,
  274. partbTel,
  275. orderNo,
  276. id,
  277. partbLinkName,
  278. productList,
  279. sourceTypeName,
  280. sourceType,
  281. pricingWay
  282. } = data;
  283. if (productList && productList.length > 0) {
  284. productList.forEach((v) => {
  285. v.orderTotalCount = v.orderTotalCount || v.totalCount;
  286. v.orderProductId = v.id;
  287. });
  288. }
  289. this.form = Object.assign({}, this.form, {
  290. supplierId: partbId,
  291. supplierName: partbName,
  292. linkName: partbLinkName,
  293. linkPhone: partbTel,
  294. orderNo,
  295. orderId: id,
  296. sourceTypeName,
  297. sourceType,
  298. productList,
  299. pricingWay
  300. });
  301. // if(sourceType==1){
  302. // this.form.isQmsCheck=1
  303. // }
  304. console.log(data, 'productList');
  305. this.$refs.inventoryTableref &&
  306. this.$refs.inventoryTableref.putTableValue(productList);
  307. });
  308. }
  309. },
  310. //发货单详情
  311. async getReceiveSaleOrderDetail(id) {
  312. this.businessId = id;
  313. this.loading = true;
  314. const data = await getReceiveSaleOrderrecordDetail(id);
  315. this.loading = false;
  316. if (data) {
  317. this.$nextTick(() => {
  318. this.form = data;
  319. this.$refs.inventoryTableref &&
  320. this.$refs.inventoryTableref.putTableValue(data.productList);
  321. });
  322. }
  323. },
  324. handHead() {
  325. let item = {
  326. id: this.form.partbLinkId
  327. };
  328. this.$refs.headRef.open(item);
  329. },
  330. //选择订单弹框
  331. handleOrderBtn(e) {
  332. if (e.target.nodeName == 'I') {
  333. this.form = Object.assign({}, this.form, {
  334. contractId: '',
  335. receiveFiles: [],
  336. contractName: '',
  337. carNo: '',
  338. carId: '',
  339. linkName: '',
  340. linkPhone: '',
  341. orderNo: '',
  342. orderId: '',
  343. pricingWay: '',
  344. outsourceSendCode: '',
  345. outsourceSendId: '',
  346. sendNoteNo: '',
  347. sourceTypeName: '',
  348. receiveType: ''
  349. });
  350. this.$refs.inventoryTableref &&
  351. this.$refs.inventoryTableref.putTableValue([]);
  352. return;
  353. }
  354. let item = {
  355. id: this.form.orderId
  356. };
  357. this.$refs.orderListDialogRef.open(item);
  358. },
  359. //选择委外发货单弹框
  360. handleOutsourceSend(e) {
  361. if (e.target.nodeName == 'I') {
  362. this.form = Object.assign({}, this.form, {
  363. contractId: '',
  364. receiveFiles: [],
  365. contractName: '',
  366. carNo: '',
  367. carId: '',
  368. linkName: '',
  369. linkPhone: '',
  370. orderNo: '',
  371. orderId: '',
  372. outsourceSendCode: '',
  373. outsourceSendId: '',
  374. sendNoteNo: '',
  375. sourceTypeName: '',
  376. receiveType: '',
  377. pricingWay: ''
  378. });
  379. this.$refs.inventoryTableref &&
  380. this.$refs.inventoryTableref.putTableValue([]);
  381. return;
  382. }
  383. this.searchParams = {
  384. orderId: this.form.orderId
  385. };
  386. this.outSourceSendDialogFlag = true;
  387. this.$nextTick(() => {
  388. this.$refs.outSourceSendDialogRef.init();
  389. });
  390. },
  391. //获取委外发货单数据回调
  392. async getOutSourceInfo(row) {
  393. const data = await getPurchaseOutSourceSendDetailAPI(row.id);
  394. let orderData = await getByIdCondition(data.orderId, 2);
  395. this.$nextTick(() => {
  396. let {
  397. carNo,
  398. code,
  399. linkName,
  400. linkPhone,
  401. orderId,
  402. orderNo,
  403. // productList,
  404. sendNoteNo,
  405. supplierId,
  406. supplierName,
  407. sourceType,
  408. sourceTypeName,
  409. pricingWay,
  410. id
  411. } = data;
  412. if (orderData.productList && orderData.productList.length > 0) {
  413. orderData.productList.forEach((v) => {
  414. v.id = '';
  415. v.orderTotalCount = v.orderTotalCount || v.totalCount;
  416. });
  417. }
  418. this.form = Object.assign({}, this.form, {
  419. supplierId,
  420. supplierName,
  421. linkName,
  422. linkPhone,
  423. orderNo,
  424. orderId,
  425. sourceTypeName,
  426. sourceType,
  427. // productList,
  428. sendNoteNo,
  429. carNo,
  430. pricingWay,
  431. outsourceSendCode: code,
  432. outsourceSendId: id
  433. });
  434. // productList.forEach((item) => {
  435. // item.id = '';
  436. // });
  437. this.$refs.inventoryTableref &&
  438. this.$refs.inventoryTableref.putTableValue(
  439. orderData.productList,
  440. code
  441. );
  442. });
  443. },
  444. //打开新增编辑弹框
  445. async open(type, row, orderId, outSourceId) {
  446. this.title = type === 'add' ? '新增收货单' : '修改';
  447. this.row = row;
  448. this.visible = true;
  449. if (orderId) {
  450. await this.getPurchaseorderDetail(orderId);
  451. }
  452. if (row && row?.id) {
  453. await this.getReceiveSaleOrderDetail(row?.id);
  454. }
  455. if (outSourceId) {
  456. await this.getOutSourceInfo({ id: outSourceId });
  457. }
  458. if (type == 'add') {
  459. this.isUpdate = false;
  460. this.form.receiveDate = new Date();
  461. } else {
  462. this.isUpdate = true;
  463. }
  464. },
  465. getValidate() {
  466. return Promise.all([
  467. new Promise((resolve, reject) => {
  468. this.$refs.form.validate((valid) => {
  469. if (!valid) {
  470. reject(false);
  471. } else {
  472. resolve(true);
  473. }
  474. });
  475. }),
  476. new Promise((resolve, reject) => {
  477. this.$refs.inventoryTableref.validateForm((valid) => {
  478. if (!valid) {
  479. reject(false);
  480. } else {
  481. resolve(true);
  482. }
  483. });
  484. })
  485. ]);
  486. },
  487. async save(type) {
  488. try {
  489. await this.getValidate();
  490. // 表单验证通过,执行保存操作
  491. this.loading = true;
  492. if (!this.isUpdate) {
  493. delete this.form.id;
  494. }
  495. this.form.receiveTypeName = this.getDictValue(
  496. '采购收货单类型',
  497. this.form.receiveType
  498. );
  499. let commitData = Object.assign({}, this.form, {
  500. productList: this.$refs.inventoryTableref.getTableValue()
  501. });
  502. let is = false;
  503. commitData.productList.forEach((v, i) => {
  504. commitData.productList.forEach((v2, j) => {
  505. if (
  506. v.productCode == v2.productCode &&
  507. v.taskId == v2.taskId &&
  508. v.batchNo == v2.batchNo &&
  509. v.colorKey == v2.colorKey &&
  510. i != j
  511. ) {
  512. is = true;
  513. }
  514. });
  515. });
  516. if (is) {
  517. this.$message.error('同产品,工序、批次号、颜色不能完全一致!');
  518. return;
  519. }
  520. if (this.isUpdate) {
  521. UpdateReceiveInformation(commitData)
  522. .then(async (res) => {
  523. this.loading = false;
  524. this.$message.success('修改成功');
  525. if (type === 'sub') {
  526. let storemanIds = '';
  527. let ids = commitData.productList.map(
  528. (item) => item.warehouseId
  529. );
  530. let warehouseList = await getWarehouseListByIds(ids || []);
  531. storemanIds = warehouseList.map((item) => item.ownerId);
  532. this.sub(res, commitData.sourceType, storemanIds.toString());
  533. return;
  534. }
  535. this.cancel();
  536. this.$emit('done');
  537. })
  538. .catch((e) => {
  539. //this.loading = false;
  540. });
  541. } else {
  542. commitData.createTime = '';
  543. addReceiveInformation(commitData)
  544. .then(async (res) => {
  545. this.loading = false;
  546. this.$message.success('新增成功');
  547. if (type === 'sub') {
  548. let storemanIds = '';
  549. let ids = commitData.productList.map(
  550. (item) => item.warehouseId
  551. );
  552. let warehouseList = await getWarehouseListByIds(ids || []);
  553. storemanIds = warehouseList.map((item) => item.ownerId);
  554. this.sub(res, commitData.sourceType, storemanIds.toString());
  555. return;
  556. }
  557. this.cancel();
  558. this.$emit('done');
  559. })
  560. .catch((e) => {
  561. //this.loading = false;
  562. });
  563. }
  564. } catch (error) {
  565. console.log(error);
  566. // 表单验证未通过,不执行保存操作
  567. }
  568. },
  569. async sub(res, sourceType, storemanIds) {
  570. const data = await getReceiveSaleOrderrecordDetail(
  571. this.businessId || res
  572. );
  573. this.processSubmitDialogFlag = true;
  574. let key =
  575. sourceType == '1'
  576. ? 'purchase_receive_approve'
  577. : 'purchase_receive_approve_2';
  578. this.$nextTick(() => {
  579. let params = {
  580. businessId: data.id,
  581. businessKey: key,
  582. formCreateUserId: data.createUserId,
  583. variables: {
  584. businessCode: data.receiveNo,
  585. receiveType: data.receiveType,
  586. sourceType: data.sourceType,
  587. storemanIds: storemanIds.toString(),
  588. businessName: data.supplierName,
  589. businessType: '采购收货'
  590. }
  591. // callBackMethodType : '1',
  592. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  593. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  594. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  595. // miniHandle : '',
  596. // miniView : '',
  597. };
  598. this.$refs.processSubmitDialogRef.init(params);
  599. });
  600. // submit({
  601. // businessId: this.businessId || res,
  602. // receiveType: this.form.receiveType,
  603. // sourceType,
  604. // variables: {
  605. // storemanIds
  606. // }
  607. // }).then((res) => {
  608. // this.cancel();
  609. // this.$emit('done');
  610. // });
  611. },
  612. reload() {
  613. this.cancel();
  614. this.$emit('done');
  615. },
  616. cancel() {
  617. this.$nextTick(() => {
  618. this.activeName = 'base';
  619. // 关闭后,销毁所有的表单数据
  620. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  621. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  622. this.$store.commit('order/clearUserData');
  623. this.form = copyObj(this.formDef);
  624. this.visible = false;
  625. });
  626. }
  627. }
  628. };
  629. </script>
  630. <style scoped lang="scss">
  631. .TotalAmount {
  632. font-size: 16px;
  633. padding-right: 30px;
  634. }
  635. .headbox {
  636. display: flex;
  637. justify-content: flex-start;
  638. align-items: center;
  639. .amount {
  640. font-size: 14px;
  641. font-weight: bold;
  642. margin-right: 20px;
  643. }
  644. }
  645. </style>