addInvoiceDialog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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 {
  167. getByIdCondition
  168. } from '@/api/purchasingManage/purchaseOrder';
  169. import {
  170. addReceiveInformation,
  171. UpdateReceiveInformation,
  172. getReceiveSaleOrderrecordDetail,
  173. } from '@/api/purchasingManage/purchaseorderreceive';
  174. import inventoryTable from './inventoryTable.vue';
  175. import orderListDialog from './orderListDialog.vue';
  176. import { copyObj } from '@/utils/util';
  177. import outSourceSendDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/outSourceSendDialog.vue';
  178. import { getPurchaseOutSourceSendDetailAPI } from '@/api/purchasingManage/outSourceSend';
  179. import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
  180. // import fileMain from '@/components/addDoc/index.vue';
  181. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  182. export default {
  183. mixins: [dictMixins],
  184. components: {
  185. processSubmitDialog,
  186. // fileMain,
  187. inventoryTable,
  188. orderListDialog,
  189. outSourceSendDialog,
  190. },
  191. data() {
  192. let formDef = {
  193. id: '',
  194. contractId: '',
  195. isQmsCheck: 0,
  196. receiveFiles: [],
  197. contractName: '',
  198. carNo: '',
  199. carId: '',
  200. linkName: '',
  201. linkPhone: '',
  202. orderNo: '',
  203. orderId: '',
  204. outsourceSendCode: '',
  205. outsourceSendId: '',
  206. sendNoteNo: '',
  207. sourceTypeName: '',
  208. receiveDate: '',
  209. receiveType: ''
  210. };
  211. return {
  212. fullscreen: false,
  213. searchParams: {},
  214. detailData: {},
  215. payWayOptions: [],
  216. delDetailIds: [],
  217. linkNameOptions: [],
  218. acceptUnpackoptions,
  219. visible: false,
  220. outSourceSendDialogFlag: false,
  221. processSubmitDialogFlag: false,
  222. title: '',
  223. row: {},
  224. activeName: 'base',
  225. formDef,
  226. form: copyObj(formDef),
  227. tableBankData: [],
  228. tableLinkData: [],
  229. businessId: '',
  230. // 组织机构树形结构数据
  231. rules: {
  232. orderNo: [
  233. { required: true, message: '请选择采购订单', trigger: 'change' }
  234. ],
  235. receiveType: [
  236. { required: true, message: '请选择采购单类型', trigger: 'change' }
  237. ]
  238. },
  239. // 提交状态
  240. loading: false,
  241. // 是否是修改
  242. isUpdate: false,
  243. pickerOptions: {
  244. disabledDate(time) {
  245. return time.getTime() > Date.now();
  246. }
  247. },
  248. };
  249. },
  250. computed: {
  251. allcountAmount() {
  252. return this.$store.state.order.allcountAmount;
  253. }
  254. },
  255. methods: {
  256. //选择订单回调
  257. changeOrder(obj) {
  258. this.form = Object.assign({}, this.form, {
  259. orderId: obj.id,
  260. orderNo: obj.orderNo
  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. });
  287. }
  288. this.form = Object.assign({}, this.form, {
  289. supplierId: partbId,
  290. supplierName: partbName,
  291. linkName: partbLinkName,
  292. linkPhone: partbTel,
  293. orderNo,
  294. orderId: id,
  295. sourceTypeName,
  296. sourceType,
  297. productList,
  298. pricingWay
  299. });
  300. // if(sourceType==1){
  301. // this.form.isQmsCheck=1
  302. // }
  303. console.log(data, 'productList');
  304. this.$refs.inventoryTableref &&
  305. this.$refs.inventoryTableref.putTableValue(productList);
  306. });
  307. }
  308. },
  309. //发货单详情
  310. async getReceiveSaleOrderDetail(id) {
  311. this.businessId = id;
  312. this.loading = true;
  313. const data = await getReceiveSaleOrderrecordDetail(id);
  314. this.loading = false;
  315. if (data) {
  316. this.$nextTick(() => {
  317. this.form = data;
  318. this.$refs.inventoryTableref &&
  319. this.$refs.inventoryTableref.putTableValue(data.productList);
  320. });
  321. }
  322. },
  323. handHead() {
  324. let item = {
  325. id: this.form.partbLinkId
  326. };
  327. this.$refs.headRef.open(item);
  328. },
  329. //选择订单弹框
  330. handleOrderBtn(e) {
  331. if (e.target.nodeName == 'I') {
  332. this.form = Object.assign({}, this.form, {
  333. contractId: '',
  334. receiveFiles: [],
  335. contractName: '',
  336. carNo: '',
  337. carId: '',
  338. linkName: '',
  339. linkPhone: '',
  340. orderNo: '',
  341. orderId: '',
  342. pricingWay: '',
  343. outsourceSendCode: '',
  344. outsourceSendId: '',
  345. sendNoteNo: '',
  346. sourceTypeName: '',
  347. receiveType: ''
  348. });
  349. this.$refs.inventoryTableref &&
  350. this.$refs.inventoryTableref.putTableValue([]);
  351. return;
  352. }
  353. let item = {
  354. id: this.form.orderId
  355. };
  356. this.$refs.orderListDialogRef.open(item);
  357. },
  358. //选择委外发货单弹框
  359. handleOutsourceSend(e) {
  360. if (e.target.nodeName == 'I') {
  361. this.form = Object.assign({}, this.form, {
  362. contractId: '',
  363. receiveFiles: [],
  364. contractName: '',
  365. carNo: '',
  366. carId: '',
  367. linkName: '',
  368. linkPhone: '',
  369. orderNo: '',
  370. orderId: '',
  371. outsourceSendCode: '',
  372. outsourceSendId: '',
  373. sendNoteNo: '',
  374. sourceTypeName: '',
  375. receiveType: '',
  376. pricingWay: ''
  377. });
  378. this.$refs.inventoryTableref &&
  379. this.$refs.inventoryTableref.putTableValue([]);
  380. return;
  381. }
  382. this.searchParams = {
  383. orderId: this.form.orderId
  384. };
  385. this.outSourceSendDialogFlag = true;
  386. this.$nextTick(() => {
  387. this.$refs.outSourceSendDialogRef.init();
  388. });
  389. },
  390. //获取委外发货单数据回调
  391. async getOutSourceInfo(row) {
  392. const data = await getPurchaseOutSourceSendDetailAPI(row.id);
  393. let orderData = await getByIdCondition(data.orderId,2);
  394. this.$nextTick(() => {
  395. let {
  396. carNo,
  397. code,
  398. linkName,
  399. linkPhone,
  400. orderId,
  401. orderNo,
  402. // productList,
  403. sendNoteNo,
  404. supplierId,
  405. supplierName,
  406. sourceType,
  407. sourceTypeName,
  408. pricingWay,
  409. id
  410. } = data;
  411. if (orderData.productList && orderData.productList.length > 0) {
  412. orderData.productList.forEach((v) => {
  413. v.id = '';
  414. v.orderTotalCount = v.orderTotalCount || v.totalCount;
  415. });
  416. }
  417. this.form = Object.assign({}, this.form, {
  418. supplierId,
  419. supplierName,
  420. linkName,
  421. linkPhone,
  422. orderNo,
  423. orderId,
  424. sourceTypeName,
  425. sourceType,
  426. // productList,
  427. sendNoteNo,
  428. carNo,
  429. pricingWay,
  430. outsourceSendCode: code,
  431. outsourceSendId: id,
  432. });
  433. // productList.forEach((item) => {
  434. // item.id = '';
  435. // });
  436. this.$refs.inventoryTableref &&
  437. this.$refs.inventoryTableref.putTableValue(orderData.productList, code);
  438. });
  439. },
  440. //打开新增编辑弹框
  441. async open(type, row, orderId, outSourceId) {
  442. this.title = type === 'add' ? '新增收货单' : '修改';
  443. this.row = row;
  444. this.visible = true;
  445. if (orderId) {
  446. await this.getPurchaseorderDetail(orderId);
  447. }
  448. if (row && row?.id) {
  449. await this.getReceiveSaleOrderDetail(row?.id);
  450. }
  451. if (outSourceId) {
  452. await this.getOutSourceInfo({ id: outSourceId });
  453. }
  454. if (type == 'add') {
  455. this.isUpdate = false;
  456. this.form.receiveDate = new Date();
  457. } else {
  458. this.isUpdate = true;
  459. }
  460. },
  461. getValidate() {
  462. return Promise.all([
  463. new Promise((resolve, reject) => {
  464. this.$refs.form.validate((valid) => {
  465. if (!valid) {
  466. reject(false);
  467. } else {
  468. resolve(true);
  469. }
  470. });
  471. }),
  472. new Promise((resolve, reject) => {
  473. this.$refs.inventoryTableref.validateForm((valid) => {
  474. if (!valid) {
  475. reject(false);
  476. } else {
  477. resolve(true);
  478. }
  479. });
  480. })
  481. ]);
  482. },
  483. async save(type) {
  484. try {
  485. await this.getValidate();
  486. // 表单验证通过,执行保存操作
  487. this.loading = true;
  488. if (!this.isUpdate) {
  489. delete this.form.id;
  490. }
  491. this.form.receiveTypeName = this.getDictValue(
  492. '采购收货单类型',
  493. this.form.receiveType
  494. );
  495. let commitData = Object.assign({}, this.form, {
  496. productList: this.$refs.inventoryTableref.getTableValue()
  497. });
  498. if (this.isUpdate) {
  499. UpdateReceiveInformation(commitData)
  500. .then(async (res) => {
  501. this.loading = false;
  502. this.$message.success('修改成功');
  503. if (type === 'sub') {
  504. let storemanIds = '';
  505. let ids = commitData.productList.map(
  506. (item) => item.warehouseId
  507. );
  508. let warehouseList = await getWarehouseListByIds(ids || []);
  509. storemanIds = warehouseList.map((item) => item.ownerId);
  510. this.sub(res, commitData.sourceType, storemanIds.toString());
  511. return;
  512. }
  513. this.cancel();
  514. this.$emit('done');
  515. })
  516. .catch((e) => {
  517. //this.loading = false;
  518. });
  519. } else {
  520. commitData.createTime = '';
  521. addReceiveInformation(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. }
  542. } catch (error) {
  543. console.log(error);
  544. // 表单验证未通过,不执行保存操作
  545. }
  546. },
  547. async sub(res, sourceType, storemanIds) {
  548. const data = await getReceiveSaleOrderrecordDetail(
  549. this.businessId || res
  550. );
  551. this.processSubmitDialogFlag = true;
  552. let key =
  553. sourceType == '1'
  554. ? 'purchase_receive_approve'
  555. : 'purchase_receive_approve_2';
  556. this.$nextTick(() => {
  557. let params = {
  558. businessId: data.id,
  559. businessKey: key,
  560. formCreateUserId: data.createUserId,
  561. variables: {
  562. businessCode: data.receiveNo,
  563. receiveType: data.receiveType,
  564. sourceType: data.sourceType,
  565. storemanIds: storemanIds.toString(),
  566. businessName: data.supplierName,
  567. businessType: '采购收货'
  568. }
  569. // callBackMethodType : '1',
  570. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  571. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  572. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  573. // miniHandle : '',
  574. // miniView : '',
  575. };
  576. this.$refs.processSubmitDialogRef.init(params);
  577. });
  578. // submit({
  579. // businessId: this.businessId || res,
  580. // receiveType: this.form.receiveType,
  581. // sourceType,
  582. // variables: {
  583. // storemanIds
  584. // }
  585. // }).then((res) => {
  586. // this.cancel();
  587. // this.$emit('done');
  588. // });
  589. },
  590. reload() {
  591. this.cancel();
  592. this.$emit('done');
  593. },
  594. cancel() {
  595. this.$nextTick(() => {
  596. this.activeName = 'base';
  597. // 关闭后,销毁所有的表单数据
  598. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  599. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  600. this.$store.commit('order/clearUserData');
  601. this.form = copyObj(this.formDef);
  602. this.visible = false;
  603. });
  604. }
  605. }
  606. };
  607. </script>
  608. <style scoped lang="scss">
  609. .TotalAmount {
  610. font-size: 16px;
  611. padding-right: 30px;
  612. }
  613. .headbox {
  614. display: flex;
  615. justify-content: flex-start;
  616. align-items: center;
  617. .amount {
  618. font-size: 14px;
  619. font-weight: bold;
  620. margin-right: 20px;
  621. }
  622. }
  623. </style>