addPreBookDrawer.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <!-- 新增预托书 -->
  3. <div id="addPreBookDrawer">
  4. <a-drawer
  5. title="新增预托书"
  6. width="89%"
  7. placement="right"
  8. :closable="true"
  9. :visible="visible"
  10. @close="handleCancel"
  11. >
  12. <!-- 主表信息 -->
  13. <a-card :bordered="true">
  14. <div class="table-page-search-wrapper">
  15. <!-- :rules="validatorRules" -->
  16. <a-form-model layout="inline" ref="form" :model="addPreBook" :rules="validatorRules">
  17. <a-row :gutter="24">
  18. <a-col :md="6" :sm="8">
  19. <a-form-model-item label="预托书号" prop="depositaryReceiptNo">
  20. <a-input placeholder="请填写预托书号" v-model="addPreBook.depositaryReceiptNo"></a-input>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :md="6" :sm="8">
  24. <a-form-model-item label="托书日期" prop="shippingOrderDate">
  25. <a-date-picker
  26. placeholder="请选择托书日期"
  27. style="width:100%;"
  28. :format="dateFormat"
  29. v-model="addPreBook.shippingOrderDate"
  30. />
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :md="12" :sm="16">
  34. <a-form-model-item label="外销发票号码" prop="exportInvoiceNo">
  35. <a-input placeholder="请输入外销发票号码" v-model="addPreBook.exportInvoiceNo"></a-input>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="8">
  39. <a-form-model-item label="经营单位" prop="unitInOperation">
  40. <a-input placeholder="请输入经营单位" v-model="addPreBook.unitInOperation"></a-input>
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="6" :sm="8">
  44. <a-form-model-item label="经营单位地址" prop="unitInOperationAddress">
  45. <a-input placeholder="请输入经营单位地址" v-model="addPreBook.unitInOperationAddress"></a-input>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="6" :sm="8">
  49. <a-form-model-item label="进仓/装柜日期" prop="latestDateOfShipment">
  50. <a-date-picker
  51. placeholder="请选择进仓/装柜日期"
  52. style="width:100%;"
  53. :format="dateFormat"
  54. v-model="addPreBook.latestDateOfShipment"
  55. />
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :md="6" :sm="8">
  59. <a-form-model-item label="最终船期" prop="theFinalShippingDate">
  60. <a-date-picker placeholder="请输入最终船期" style="width:100%;" v-model="addPreBook.theFinalShippingDate"/>
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :md="6" :sm="8">
  64. <a-form-model-item label="收货人" prop="consignee">
  65. <j-dict-select-tag
  66. style="width:100%;margin-bottom: 10px;" v-model="addPreBook.consigneeAll"
  67. dictCode="sys_dict_item,item_text,description,dict_id in(select id from sys_dict where dict_code='receiving_goods_info')"
  68. @change="consigneeSelectChange"/>
  69. <!-- <j-search-select-tag
  70. placeholder="请选择收货人"
  71. v-model="addPreBook.consigneeAll"
  72. @change="consigneeSelectChange"
  73. dict="receiving_goods_info">
  74. </j-search-select-tag> -->
  75. </a-form-model-item>
  76. </a-col>
  77. <a-col :md="6" :sm="8">
  78. <a-form-model-item label="收货人地址" prop="consigneeAddress">
  79. <a-input placeholder="根据收货人自动带出" v-model="addPreBook.consigneeAddress" ></a-input>
  80. </a-form-model-item>
  81. </a-col>
  82. <a-col :md="6" :sm="8">
  83. <a-form-model-item label="通知方" prop="notifyParty">
  84. <a-input placeholder="根据收货人自动带出" v-model="addPreBook.notifyParty" ></a-input>
  85. </a-form-model-item>
  86. </a-col>
  87. <a-col :md="6" :sm="8">
  88. <a-form-model-item label="通知方地址" prop="notifyPartyAddress">
  89. <a-input placeholder="根据收货人自动带出" v-model="addPreBook.notifyPartyAddress" ></a-input>
  90. </a-form-model-item>
  91. </a-col>
  92. <a-col :md="6" :sm="8">
  93. <a-form-model-item label="贸易国别" prop="tradeCountry">
  94. <j-search-select-tag
  95. placeholder="请选择贸易国别"
  96. v-model="addPreBook.tradeCountry"
  97. dict="trade_country">
  98. </j-search-select-tag>
  99. <!-- <a-input placeholder="请输入贸易国别" v-model="addPreBook.tradeCountry"></a-input> -->
  100. </a-form-model-item>
  101. </a-col>
  102. <a-col :md="6" :sm="8">
  103. <a-form-model-item label="运抵国别" prop="arriveInCountry">
  104. <j-search-select-tag
  105. placeholder="请选择运抵国别"
  106. v-model="addPreBook.arriveInCountry"
  107. dict="country_of_arrival">
  108. </j-search-select-tag>
  109. <!-- <a-input placeholder="请输入运抵国别" v-model="addPreBook.arriveInCountry"></a-input> -->
  110. </a-form-model-item>
  111. </a-col>
  112. <a-col :md="6" :sm="8">
  113. <a-form-model-item label="出口口岸" prop="exportPort">
  114. <j-search-select-tag
  115. placeholder="请选择出口口岸"
  116. v-model="addPreBook.exportPort"
  117. dict="export_port">
  118. </j-search-select-tag>
  119. <!-- <a-input placeholder="请输入出口口岸" v-model="addPreBook.exportPort"></a-input> -->
  120. </a-form-model-item>
  121. </a-col>
  122. <a-col :md="6" :sm="8">
  123. <a-form-model-item label="目的港" prop="destinationPort">
  124. <j-search-select-tag
  125. placeholder="请选择目的港"
  126. v-model="addPreBook.destinationPort"
  127. dict="port_of_destination">
  128. </j-search-select-tag>
  129. <!-- <a-input placeholder="请输入目的港" v-model="addPreBook.destinationPort"></a-input> -->
  130. </a-form-model-item>
  131. </a-col>
  132. <a-col :md="6" :sm="8">
  133. <a-form-model-item label="收汇方式" prop="exchangeEarningsValue">
  134. <j-search-select-tag
  135. placeholder="请选择收汇方式"
  136. v-model="addPreBook.exchangeEarningsValue"
  137. dict="collection_method">
  138. </j-search-select-tag>
  139. <!-- <a-input placeholder="请输入收汇方式" v-model="addPreBook.exchangeEarningsValue"></a-input> -->
  140. </a-form-model-item>
  141. </a-col>
  142. <a-col :md="6" :sm="8">
  143. <a-form-model-item label="成交方式" prop="termsOfDeliveryvalue">
  144. <j-search-select-tag
  145. placeholder="请选择成交方式"
  146. v-model="addPreBook.termsOfDeliveryvalue"
  147. dict="transaction_method">
  148. </j-search-select-tag>
  149. <!-- <a-input placeholder="请输入成交方式" v-model="addPreBook.termsOfDeliveryvalue"></a-input> -->
  150. </a-form-model-item>
  151. </a-col>
  152. <a-col :md="6" :sm="8">
  153. <a-form-model-item label="金额" prop="money">
  154. <a-input placeholder="请输入金额" v-model="addPreBook.money"></a-input>
  155. </a-form-model-item>
  156. </a-col>
  157. </a-row>
  158. </a-form-model>
  159. </div>
  160. </a-card>
  161. <!--操作按钮区域 参照预装箱单 増行-->
  162. <a-card :bordered="true" style="marginTop:10px;">
  163. <!-- table-->
  164. <a-spin :spinning="confirmLoading">
  165. <!-- :rules="validatorRules" -->
  166. <j-vxe-table
  167. ref="vTable"
  168. toolbar
  169. row-number
  170. row-selection
  171. drag-sort
  172. keep-source
  173. :height="400"
  174. :loading="loading"
  175. :dataSource="addPreBook.syLetterDepositItemList"
  176. :columns="addPerBookColumns"
  177. :alwaysEdit=true
  178. :bordered=true
  179. :toolbarConfig="toolbarConfig"
  180. @valueChange="handleValueChange"
  181. >
  182. <template v-slot:toolbarSuffix>
  183. <a-button @click="referadvancePackingList" type="primary" icon="ordered-list">参照预装箱单</a-button>
  184. </template>
  185. <template v-slot:action="props">
  186. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
  187. <a>删除</a>
  188. </a-popconfirm>
  189. </template>
  190. </j-vxe-table>
  191. </a-spin>
  192. </a-card>
  193. <!-- 页面底部保存取消 -->
  194. <div
  195. :style="{
  196. position: 'absolute',
  197. right: 0,
  198. bottom: 0,
  199. width: '100%',
  200. borderTop: '1px solid #e9e9e9',
  201. padding: '10px 16px',
  202. background: '#fff',
  203. textAlign: 'right',
  204. zIndex: 1
  205. }"
  206. >
  207. <a-popconfirm title="确定放弃新增?" @confirm="handleCancel" okText="确定" cancelText="取消">
  208. <a-button :style="{ marginRight: '8px' }">取消</a-button>
  209. </a-popconfirm>
  210. <a-button type="primary" @click="myHandSave">
  211. 保存
  212. </a-button>
  213. <a-button type="primary" @click="myHandSubmit" style="margin-left: 8px">
  214. 保存并提交
  215. </a-button>
  216. </div>
  217. </a-drawer>
  218. <!-- 参照预装箱单 -->
  219. <advancePackingList-modal ref="advancePackingListModal" :father="aa" @callback="referCallback" @ok="modalFormOk"></advancePackingList-modal>
  220. </div>
  221. </template>
  222. <script>
  223. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  224. import JEllipsis from '@/components/jeecg/JEllipsis'
  225. import moment from 'moment'
  226. import AdvancePackingListModal from '@views/pre-book/advancePackingListModal.vue'
  227. import { JVXETypes } from '@/components/jeecg/JVxeTable'
  228. import { addPreBook, editById } from '@api/document/pre-book.js'
  229. export default {
  230. name: 'AddPreBookDrawer', // 新增预托书
  231. computed: {},
  232. mixins: [JeecgListMixin],
  233. components: { AdvancePackingListModal, JEllipsis, moment }, // 参照预装箱单 弹框
  234. data() {
  235. return {
  236. // 表头
  237. addPerBookColumns: [
  238. {
  239. title: '英文名称',
  240. key: 'englishName',
  241. width: 120,
  242. fixed: 'left',
  243. className: 'replacecolor'
  244. },
  245. {
  246. title: '款号',
  247. key: 'itemNumber',
  248. width: 120,
  249. fixed: 'left',
  250. className: 'replacecolor'
  251. },
  252. {
  253. title: '小po',
  254. key: 'poNo',
  255. width: 120,
  256. className: 'replacecolor'
  257. },
  258. {
  259. title: '数量',
  260. key: 'total',
  261. width: 120,
  262. className: 'replacecolor'
  263. },
  264. {
  265. title: '箱数',
  266. key: 'boxNumber',
  267. width: 90,
  268. className: 'replacecolor'
  269. },
  270. {
  271. title: '毛重',
  272. key: 'totalGrossWeight',
  273. width: 120,
  274. className: 'replacecolor'
  275. },
  276. {
  277. title: '净重',
  278. key: 'totalNetWeight',
  279. width: 120,
  280. className: 'replacecolor'
  281. },
  282. {
  283. title: '体积',
  284. key: 'totalVolume',
  285. width: 160,
  286. className: 'replacecolor'
  287. },
  288. {
  289. title: '分销点',
  290. key: 'distributionPoint',
  291. width: 120,
  292. className: 'replacecolor'
  293. },
  294. {
  295. title: '集装箱代号',
  296. key: 'containerCode',
  297. width: 120,
  298. type:JVXETypes.inputNumber,
  299. className: 'replacecolor'
  300. },
  301. {
  302. title: '集装箱号',
  303. key: 'containerNumber',
  304. width: 120,
  305. type:JVXETypes.inputNumber,
  306. className: 'replacecolor'
  307. },
  308. {
  309. title: '单价',
  310. key: 'unitPrice',
  311. width: 120,
  312. className: 'replacecolor'
  313. },
  314. {
  315. title: '金额',
  316. key: 'totalPrice',
  317. width: 120,
  318. className: 'replacecolor'
  319. },
  320. // {
  321. // title: '创建时间',
  322. // dataIndex: 'createTime',
  323. // align: 'center',
  324. // sorter: true,
  325. // customRender: text => {
  326. // return moment(text).format('YYYY-MM-DD')
  327. // }
  328. // },
  329. {
  330. title: '预发货日期',
  331. key: 'scheduledShipDate',
  332. width: 120,
  333. className: 'replacecolor'
  334. },
  335. {
  336. title: '业务员',
  337. key: 'salesman',
  338. width: 120,
  339. className: 'replacecolor'
  340. },
  341. {
  342. title: '业务部门',
  343. key: 'operatingDepartment',
  344. width: 120,
  345. className: 'replacecolor'
  346. },
  347. {
  348. title: '采购/委外订单号',
  349. key: 'purchaseAboardOrderNum',
  350. width: 160,
  351. className: 'replacecolor'
  352. },
  353. {
  354. title: '采购/委外工厂',
  355. key: 'purchaseAboardFactory',
  356. width: 160,
  357. className: 'replacecolor'
  358. },
  359. {
  360. title: '操作',
  361. key: 'action',
  362. type: JVXETypes.slot,
  363. width: 100,
  364. align: 'center',
  365. fixed: 'right',
  366. slotName: 'action',
  367. }
  368. ],
  369. addPerBookData: [],
  370. msgFormSon: 'test', // 子组件传来数据的变量
  371. loading: false, // 表格加载
  372. addPreBook: {}, //主表信息
  373. confirmLoading: false,
  374. visible: false,
  375. dateFormat: 'YYYY-MM-DD',
  376. toolbarConfig: {
  377. btn: []
  378. },
  379. validatorRules:{
  380. shippingOrderDate:[{required: true, message: '托书日期不能为空!'}],
  381. consignee:[{required: true, message: '收货人不能为空!'}],
  382. depositaryReceiptNo:[{required: true, message: '预托书号不能为空!'}],
  383. },
  384. }
  385. },
  386. created() {},
  387. methods: {
  388. // 参照预装箱单
  389. referadvancePackingList() {
  390. //子表中有数据时,传值给参照数据组件
  391. if(this.addPreBook.syLetterDepositItemList.length !== 0){
  392. this.$refs.advancePackingListModal.fatherData = this.addPreBook.syLetterDepositItemList
  393. }
  394. this.$refs.advancePackingListModal.advancePackingListModVis = true;
  395. this.$refs.advancePackingListModal.queryParam = {};
  396. this.$refs.advancePackingListModal.searchQuery();
  397. },
  398. // 増行
  399. handleAddColumn() {
  400. console.log('増行')
  401. const addrow = {
  402. englishName: '',
  403. sort: '',
  404. smallPo: '',
  405. quantity: '',
  406. boxNumber: '',
  407. grossWeight: '',
  408. netWeight: '',
  409. volume: '',
  410. distributionPoint: '',
  411. containerCode: '',
  412. containerNumber: '',
  413. unitPrice: '',
  414. scheduledShipDate: '',
  415. salesman: '',
  416. operatingDepartment: '',
  417. purchaseAboardOrderNum: '',
  418. purchaseAboardFactory: '',
  419. operation: ''
  420. }
  421. this.addPerBookData.push(addrow)
  422. },
  423. // ------------------------------------------
  424. // 操作 删除
  425. handleDelete(index) {
  426. var ret = this.addPreBook.syLetterDepositItemList.splice(index, 1);
  427. this.setHeadCalField();
  428. return ret;
  429. },
  430. // 抽屉 取消
  431. handleCancel() {
  432. this.close()
  433. },
  434. myHandSave(){
  435. this.addPreBook.theDocumentsState=0;
  436. this.saveAdd();
  437. },
  438. myHandSubmit(){
  439. this.addPreBook.theDocumentsState=1;
  440. this.saveAdd();
  441. },
  442. // 抽屉 提交
  443. saveAdd() {
  444. const that = this;
  445. var newObj = this.addPreBook;
  446. if (newObj.syLetterDepositItemList.length == 0){
  447. this.$message.error('当前记录没有子表记录,无法保存');
  448. return;
  449. }
  450. // 触发表单验证
  451. this.$refs.form.validate(valid => {
  452. if (valid) {
  453. that.confirmLoading = true;
  454. if (newObj.id == undefined || newObj.id == "" || newObj.id == null){
  455. addPreBook(newObj).then(res => {
  456. that.confirmLoading = false;
  457. if (res.success) {
  458. this.$message.success('新增成功')
  459. this.close()
  460. //清空信息
  461. this.fatherList(); // 调用父组件 查询方法
  462. // this.msgFormSon = {} 清空子表信息
  463. }else{
  464. this.$message.error(res.message)
  465. }
  466. })
  467. }else{
  468. editById(newObj).then(res => {
  469. that.confirmLoading = false;
  470. if (res.success) {
  471. this.$message.success('修改成功')
  472. this.close();
  473. this.fatherList() // 调用父组件 查询方法
  474. // this.msgFormSon = {} 清空子表信息
  475. }else{
  476. this.$message.error(res.message)
  477. }
  478. })
  479. }
  480. }
  481. })
  482. // this.getShipmentList() // 刷新发运明细列表
  483. },
  484. close() {
  485. this.$emit('close')
  486. this.visible = false
  487. this.$refs.form.resetFields()
  488. },
  489. // ------------------------------------------
  490. modalFormOk() {},
  491. aa() {},
  492. // 参照回调
  493. referCallback(dataList){
  494. var subList = this.convertReferToSub(dataList);
  495. var filterList = subList.filter(newItem=>{
  496. return this.addPreBook.syLetterDepositItemList.filter(item=>{
  497. return item.syPreAssembledPackingListItemId === newItem.syPreAssembledPackingListItemId;
  498. }).length == 0;
  499. });
  500. this.addPreBook.syLetterDepositItemList = this.addPreBook.syLetterDepositItemList.concat(filterList);
  501. this.setHeadCalField();
  502. },
  503. // 参照数据转换成子表
  504. convertReferToSub(dataList){
  505. var ret = [];
  506. for (var i=0; i<dataList.length; i++){
  507. var data = dataList[i];
  508. var sub = {
  509. id:"",
  510. syLetterDepositId:"",
  511. syPreAssembledPackingListId:data.id,
  512. syPreAssembledPackingListItemId:data.itemId,
  513. acSetNo:data.acSetNo,
  514. garmentFactory:"",
  515. hod:"",
  516. styleNo:"",
  517. poNo:data.smallPo,
  518. itemCode:"",
  519. distributionPoint:data.distributionPoint,
  520. size:data.size,
  521. startingBoxNumber:"",
  522. endCaseNumber:"",
  523. colour:data.colour,
  524. piecesBox:data.piecesBox,
  525. boxNumber:data.boxNumber,
  526. total:data.piecesBox*data.boxNumber,
  527. netWeight:data.totalNetWeight/data.boxNumber,
  528. totalNetWeight:data.totalNetWeight,
  529. grossWeight:data.totalGrossWeight/data.boxNumber,
  530. totalGrossWeight:data.totalGrossWeight,
  531. outerBoxLength:0,
  532. outerBoxWidth:0,
  533. outerBoxHeight:0,
  534. totalVolume:data.totalVolume,
  535. netWeightToo:0,
  536. unitPrice:data.unitPrice,
  537. totalPrice:data.totalPrice,
  538. containerCode:data.containerCode,
  539. containerNumber:data.containerNumber,
  540. custor:data.customer,
  541. itemNumber:data.itemNumber,
  542. };
  543. ret.push(sub);
  544. }
  545. return ret;
  546. },
  547. handleValueChange(event) {
  548. },
  549. // 收货人下拉框
  550. consigneeSelectChange(value){
  551. if(value !=null && value !='' &&value != 'undefined'){
  552. var valueArr = value.split("+")
  553. this.addPreBook.consignee = valueArr[0];
  554. if (valueArr.length == 4){
  555. this.addPreBook.consigneeAddress = valueArr[1];
  556. this.addPreBook.notifyParty = valueArr[2];
  557. this.addPreBook.notifyPartyAddress = valueArr[3];
  558. }else{
  559. this.$message.error('收货信息维护有问题,请检查!')
  560. }
  561. }else{
  562. this.addPreBook.consigneeAddress = '';
  563. this.addPreBook.notifyParty = '';
  564. this.addPreBook.notifyPartyAddress = '';
  565. }
  566. },
  567. // 设置表头计算字段
  568. setHeadCalField(){
  569. var money = 0
  570. for (var i=0; i<this.addPreBook.syLetterDepositItemList.length; i++){
  571. money += this.addPreBook.syLetterDepositItemList[i].totalPrice;
  572. }
  573. this.addPreBook.money = money;
  574. }
  575. },
  576. mounted() {},
  577. // 接收父组件查询方法
  578. props: {
  579. fatherList: {
  580. type: Function,
  581. default: null
  582. }
  583. },
  584. }
  585. </script>
  586. <style lang="less" scoped>
  587. @import '~@assets/less/common.less';
  588. @import '~@assets/less/overwriter.less';
  589. /deep/ .ant-table-thead > tr > th {
  590. text-align: center;
  591. // font-weight: 700;
  592. }
  593. /deep/ .ant-table-tbody {
  594. text-align: center;
  595. }
  596. // /deep/ th.replacecolor {
  597. // background-color: #ccc;
  598. // }
  599. // 抽屉里的card样式
  600. /deep/ .ant-drawer-content {
  601. background-color: #f0f2f5;
  602. }
  603. /deep/ .ant-drawer-body {
  604. padding: 10px;
  605. }
  606. </style>