addInvoiceDialog.vue 18 KB

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