amendsCostdetails.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. <template>
  2. <div>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="tableData"
  6. v-model="form"
  7. id="out-table"
  8. :header-cell-class-name="headerClassName"
  9. ref="crud"
  10. :row-style="{height:'20px'}"
  11. :cell-style="{padding:'0px'}"
  12. @selection-change="handleSelectionChange"
  13. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 322.1)"
  14. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 322.1)" >
  15. <template slot="menuLeft">
  16. <el-button type="danger" plain size="small" :disabled="disabled"
  17. @click="batchDelete" >一键删除
  18. </el-button>
  19. <el-button type="info" plain size="small" :disabled="disabled"
  20. @click="feecenterSubmitListfun">一键保存
  21. </el-button>
  22. <el-button type="info" plain size="small" :disabled="disabled"
  23. @click="oneclickEditingfun">一键编辑
  24. </el-button>
  25. <el-button type="primary" plain size="small" :disabled="!form.id"
  26. @click="printingCostsfun()">打印账单</el-button>
  27. </template>
  28. <template slot="indexHeader" slot-scope="scope">
  29. <el-button type="primary" size="small" icon="el-icon-plus" circle
  30. :disabled="disabled"
  31. @click="addfun"></el-button>
  32. </template>
  33. <template slot="index" slot-scope="scope">
  34. <span>{{scope.index + 1}}</span>
  35. </template>
  36. <template slot="accStatus" slot-scope="{row,size}">
  37. <span>{{row.accStatus?'是':'否'}}</span>
  38. </template>
  39. <template slot="dc" slot-scope="{row,size}">
  40. <search-query v-if="row.editType"
  41. :datalist="dcData"
  42. :selectValue="row.dc"
  43. :filterable="true"
  44. :clearable="true"
  45. :remote="true"
  46. :buttonIf="false"
  47. :disabled="dcDisabled"
  48. @corpChange="corpChange($event,'dc',row)"
  49. placeholder="请选择收/付">
  50. </search-query>
  51. <span v-else >{{row.dc}}</span>
  52. </template>
  53. <template slot="corpCnName" slot-scope="{ row }">
  54. <search-query v-if="row.editType"
  55. :datalist="corpCnNameData"
  56. :selectValue="row.corpCnName"
  57. :filterable="true"
  58. :clearable="true"
  59. :remote="true"
  60. :buttonIf="false"
  61. placeholder="请选择往来单位"
  62. :forParameter="{key:'id',label:'cnName',value:'cnName'}"
  63. @remoteMethod="getBcorpsListfun($event,'corpCnName')"
  64. @corpChange="corpChange($event,'corpCnName',row)"
  65. @corpFocus="getBcorpsListfun($event,'corpCnName')" >
  66. </search-query>
  67. <span v-else style="color: #1e9fff" @click="corpClick(row)">{{row.corpCnName}}</span>
  68. </template>
  69. <template slot="feeCnName" slot-scope="{ row }">
  70. <search-query v-if="row.editType"
  71. :datalist="feeCnNameData"
  72. :selectValue="row.feeCnName"
  73. :filterable="true"
  74. :clearable="true"
  75. :remote="true"
  76. :buttonIf="false"
  77. placeholder="请选择费用简称"
  78. :forParameter="{key:'id',label:'cnName',value:'cnName'}"
  79. @remoteMethod="bfeesListfun($event,'feeCnName')"
  80. @corpChange="corpChange($event,'feeCnName',row)"
  81. @corpFocus="bfeesListfun($event,'feeCnName')" >
  82. </search-query>
  83. <span v-else >{{row.feeCnName}}</span>
  84. </template>
  85. <template slot="elementsCnName" slot-scope="{ row }">
  86. <search-query v-if="row.editType"
  87. :datalist="elementsData"
  88. :selectValue="row.elementsCnName"
  89. :filterable="true"
  90. :clearable="true"
  91. :remote="true"
  92. :buttonIf="false"
  93. placeholder="请选择核算要素"
  94. :forParameter="{key:'id',label:'cnName',value:'cnName'}"
  95. @remoteMethod="getBaccelementsListfun($event,'elementsCnName')"
  96. @corpChange="corpChange($event,'elementsCnName',row,)"
  97. @corpFocus="getBaccelementsListfun($event,'elementsCnName')" >
  98. </search-query>
  99. <span v-else >{{row.elementsCnName}}</span>
  100. </template>
  101. <template slot="paymode" slot-scope="{ row }">
  102. <search-query v-if="row.editType"
  103. :datalist="paymodeData"
  104. :selectValue="row.paymode"
  105. :clearable="true"
  106. :buttonIf="false"
  107. placeholder="请选择预付/到付"
  108. :forParameter="{key:'dictKey',label:'dictValue',value:'dictKey'}"
  109. @corpChange="corpChange($event,'paymode',row)"
  110. @corpFocus="paymodeWorkDictsfun" >
  111. </search-query>
  112. <span v-else>{{row.paymode}}</span>
  113. </template>
  114. <template slot="unitNo" slot-scope="{ row }">
  115. <search-query v-if="row.editType"
  116. :datalist="unitNoData"
  117. :selectValue="row.unitNo"
  118. :filterable="true"
  119. :clearable="true"
  120. :remote="true"
  121. :buttonIf="false"
  122. placeholder="请选择计量单位"
  123. :forParameter="{key:'id',label:'code',value:'code',disabled:'status'}"
  124. @corpFocus="getBunitsPagefun"
  125. @corpChange="corpChange($event,'unitNo',row)" >
  126. </search-query>
  127. <span v-else>{{row.unitNo}}</span>
  128. </template>
  129. <template slot="curCode" slot-scope="{ row }">
  130. <search-query v-if="row.editType"
  131. :datalist="curCodeData"
  132. :selectValue="row.curCode"
  133. :filterable="true"
  134. :clearable="true"
  135. :remote="true"
  136. :buttonIf="false"
  137. placeholder="请选择币种"
  138. :forParameter="{key:'id',label:'code',value:'code'}"
  139. @remoteMethod="bcurrencyGetExratefun(row.dc)"
  140. @corpChange="corpChange($event,'curCode',row)"
  141. @corpFocus="bcurrencyGetExratefun(row.dc)" >
  142. </search-query>
  143. <span v-else>{{row.curCode}}</span>
  144. </template>
  145. <template slot="isTax" slot-scope="{row}">
  146. <span>{{row.isTax?'是':'否'}}</span>
  147. </template>
  148. <template slot="price" slot-scope="{ row }">
  149. <el-input-number v-if="row.editType" v-model="row.price" size="small"
  150. placeholder="请输入单价" @blur="priceinputfun($event,row)" :controls="false"></el-input-number>
  151. <span v-else>{{row.price}}</span>
  152. </template>
  153. <template slot="quantity" slot-scope="{ row }">
  154. <el-input-number v-if="row.editType" v-model="row.quantity" size="small" :min="1"
  155. placeholder="请输入数量" @blur="quantityinputfun(row)" :controls="false"></el-input-number>
  156. <span v-else>{{row.quantity}}</span>
  157. </template>
  158. <template slot="remarks" slot-scope="{ row }">
  159. <el-input v-if="row.editType" v-model="row.remarks" size="small"
  160. placeholder="请输入备注" ></el-input>
  161. <span v-else>{{row.remarks}}</span>
  162. </template>
  163. <!--<template slot-scope="scope" slot="menu">-->
  164. <!-- <el-button type="text" size="small" :disabled="scope.row.accStatus || disabled" @click="deletefun(scope.row,scope.index)">删除</el-button>-->
  165. <!--</template>-->
  166. </avue-crud>
  167. <!--往来单位弹窗-->
  168. <el-dialog
  169. title="导出"
  170. :visible.sync="corpVisible"
  171. append-to-body
  172. width="70%"
  173. :close-on-click-modal="false">
  174. <span slot="title">
  175. <el-button type="primary" size="mini" @click.stop="exportfun" >导出</el-button>
  176. </span>
  177. <div style="padding-bottom: 30px;" >
  178. <el-table
  179. :data="corpDialog"
  180. border
  181. size="mini"
  182. :row-style="{height:'20px',padding:'0px',fontSize:'12px'}"
  183. :cell-style="{padding:'0px',fontSize:'12px'}"
  184. style="width: 100%">
  185. <el-table-column prop="corpCnName" label="客户名称" width="140px" >
  186. <template slot-scope="{ row }">
  187. <span class="textoverflow">{{row.corpCnName}}</span>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="mblno" label="MB/L NO" width="140px" />
  191. <el-table-column prop="amountDr" label="应收金额" />
  192. <el-table-column prop="amountCr" label="应付金额" />
  193. <el-table-column prop="amountDrUsd" label="应收金额USD" width="140px" />
  194. <el-table-column prop="amountCrUsd" label="应付金额USD" width="140px" />
  195. <el-table-column prop="amountDrLoc" label="应收金额合计" width="140px" />
  196. <el-table-column prop="amountCrLoc" label="应付金额合计" width="140px" />
  197. <el-table-column prop="stlAmountDr" label="已结算应收金额" width="140px" />
  198. <el-table-column prop="stlAmountCr" label="已结算应付金额" width="140px" />
  199. <el-table-column prop="stlAmountDrUsd" label="已结算应收金额USD" width="140px" />
  200. <el-table-column prop="stlAmountCrUsd" label="已结算应付金额USD" width="140px" />
  201. <el-table-column prop="stlAmountDrLoc" label="已结算应收金额合计" width="140px" />
  202. <el-table-column prop="stlAmountCrLoc" label="已结算应付金额合计" width="140px" />
  203. </el-table>
  204. </div>
  205. </el-dialog>
  206. </div>
  207. </template>
  208. <script>
  209. import {getBcorpsDetail, getBcorpsList} from "@/api/iosBasicData/bcorps";
  210. import {bfeesList} from "@/api/iosBasicData/bfees";
  211. import {getBaccelementsList} from "@/api/iosBasicData/baccelements";
  212. import {bcurrencyGetExrate} from "@/api/iosBasicData/rateManagement";
  213. import {getWorkDicts} from "@/api/system/dictbiz";
  214. import {getBunitsPage} from "@/api/iosBasicData/bunits";
  215. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  216. import {dateFormat} from "@/util/date";
  217. import {
  218. feecenterRemove,
  219. feecenterSubmitList
  220. } from "@/api/iosBasicData/feecenter";
  221. import {listFeeCountByCorp} from "@/api/iosBasicData/bills";
  222. import {amendsDetail} from "@/api/iosBasicData/amends";
  223. import {getToken} from "@/util/auth";
  224. export default {
  225. components: {SearchQuery},
  226. props:{
  227. tableData:{
  228. type:Array,
  229. default:[]
  230. },
  231. form:{
  232. type:Object,
  233. default:{}
  234. },
  235. disabled:{
  236. type:Boolean,
  237. default:false
  238. },
  239. // dc禁用
  240. dcDisabled:{
  241. type:Boolean,
  242. default:false
  243. },
  244. },
  245. data(){
  246. return {
  247. option:{},
  248. optionBack:{
  249. stripe:true,
  250. maxHeight:'250',
  251. calcHeight: 30,
  252. tip: false,
  253. searchShow: true,
  254. searchMenuSpan: 6,
  255. border: true,
  256. selection: true,
  257. dialogClickModal: false,
  258. addBtn:false,
  259. viewBtn:false,
  260. delBtn:false,
  261. editBtn:false,
  262. menuWidth:'100',
  263. refreshBtn:false,
  264. menu:false,
  265. column:[
  266. {
  267. label: "index",
  268. prop: "index",
  269. width: "55",
  270. headerslot:true,
  271. },
  272. {
  273. label: "账单",
  274. prop: "accStatus",
  275. width: "60",
  276. },
  277. {
  278. label: "收/付",
  279. prop: "dc",
  280. width: "100",
  281. },
  282. {
  283. label: "往来单位",
  284. prop: "corpCnName",
  285. width: "160",
  286. overHidden:true,
  287. },
  288. {
  289. label: "费用简称",
  290. prop: "feeCnName",
  291. width: "120",
  292. overHidden:true,
  293. },
  294. {
  295. label: "预付/到付",
  296. prop: "paymode",
  297. width: "120",
  298. },
  299. {
  300. label: "计量单位",
  301. prop: "unitNo",
  302. width: "120",
  303. },
  304. {
  305. label: "币种",
  306. prop: "curCode",
  307. width: "120",
  308. },
  309. {
  310. label: "汇率",
  311. prop: "exrate",
  312. width: "100",
  313. },
  314. {
  315. label: "单价",
  316. prop: "price",
  317. width: "120",
  318. },
  319. {
  320. label: "数量",
  321. prop: "quantity",
  322. width: "120",
  323. },
  324. {
  325. label: "CNY(含税)",
  326. prop: "rmbAmount",
  327. width: "100",
  328. },
  329. {
  330. label: "USD(含税)",
  331. prop: "usdAmount",
  332. width: "100",
  333. },
  334. {
  335. label: "CNY(净额)",
  336. prop: "rmbAmountNet",
  337. width: "100",
  338. },
  339. {
  340. label: "USD(净额)",
  341. prop: "usdAmountNet",
  342. width: "100",
  343. },
  344. {
  345. label: "核算要素",
  346. prop: "elementsCnName",
  347. width: "120",
  348. overHidden:true,
  349. },
  350. {
  351. label: "付费申请金额",
  352. prop: "appliedAmount",
  353. width: "120",
  354. },
  355. {
  356. label: "发票申请金额",
  357. prop: "appliedInvoiceAmount",
  358. width: "120",
  359. },
  360. {
  361. label: "已开票金额",
  362. prop: "uninvoicedAmount",
  363. width: "120",
  364. },
  365. {
  366. label: "已结算金额",
  367. prop: "stlTtlAmount",
  368. width: "120",
  369. },
  370. {
  371. label: "备注",
  372. prop: "remarks",
  373. width: "100",
  374. },
  375. {
  376. label: "单价是否含税",
  377. prop: "isTax",
  378. width: "120",
  379. },
  380. ]
  381. },
  382. loading:false,
  383. form:{},
  384. // 收/付
  385. dcData:[
  386. {
  387. label:'收',
  388. value:'D'
  389. },
  390. {
  391. label:'付',
  392. value:'C'
  393. }
  394. ],
  395. corpCnNameData:[], // 往来单位数据
  396. feeCnNameData:[], // 费用数据
  397. elementsData:[], // 核算要素
  398. paymodeData:[], // 预付到付数据
  399. unitNoData:[], // 计算单位数据
  400. curCodeData:[], // 币别数据
  401. handleSelectionData:[], // 多选选择的数据
  402. corpVisible:false, // 往来单位弹窗
  403. corpDialog:[], // 往来单位弹窗数据
  404. corpRow:{}, // 往来单位弹窗数据
  405. }
  406. },
  407. async created() {
  408. this.option = await this.getColumnData(this.getColumnName(322.1), this.optionBack);
  409. },
  410. methods:{
  411. // 弹窗导出
  412. exportfun(){
  413. const routeData = this.$router.resolve({
  414. path: '/api/blade-los/finaccbills/listFeeCountByCorpExport',//跳转目标窗口的地址
  415. query: {
  416. dc: this.corpRow.dc,
  417. corpId:this.corpRow.corpId
  418. }
  419. })
  420. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  421. },
  422. // 往来单位弹窗开启
  423. corpClick(row){
  424. this.corpVisible = true
  425. listFeeCountByCorp({
  426. corpId:row.corpId,
  427. dc:row.dc
  428. }).then(res=>{
  429. this.corpRow = row
  430. this.corpDialog = res.data.data
  431. })
  432. },
  433. printingCostsfun(){
  434. this.$emit('printingCostsfun')
  435. },
  436. // 应收新增
  437. addfun(){
  438. this.$emit('addfun')
  439. },
  440. // 一键编辑
  441. oneclickEditingfun(){
  442. this.$emit('oneclickEditingfun')
  443. },
  444. // 一键删除
  445. batchDelete(){
  446. if (this.handleSelectionData.length === 0) {
  447. this.$message.warning("请选择至少一条数据");
  448. return;
  449. }
  450. this.$confirm("确定将选择数据删除?", {
  451. confirmButtonText: "确定",
  452. cancelButtonText: "取消",
  453. type: "warning"
  454. }).then(()=>{
  455. let multiList = this.handleSelectionData
  456. let arr = this.tableData
  457. // 获取有id 的数据
  458. const itemsWithId = multiList.filter(item => item.hasOwnProperty('id'));
  459. let arrIds = itemsWithId.map(item=>item.id) // 获取id 数据
  460. // 把选中的删除掉
  461. multiList.forEach((item)=>{
  462. for (let index in arr) {
  463. if (JSON.stringify(item) == JSON.stringify(arr[index])) {
  464. arr.splice(Number(index),1)
  465. }
  466. }
  467. })
  468. // 有id 的处理
  469. if(itemsWithId.length != 0) {
  470. feecenterRemove(arrIds.join(',')).then(res=>{
  471. this.$message.success('操作成功')
  472. // this.$emit('billsDetailfun')
  473. })
  474. }
  475. })
  476. },
  477. // 小删除
  478. deletefun(row,index) {
  479. this.$confirm("确定将选择数据删除?", {
  480. confirmButtonText: "确定",
  481. cancelButtonText: "取消",
  482. type: "warning"
  483. }).then(()=>{
  484. if (row.id) {
  485. // 删除接口
  486. feecenterRemove(row.id).then(res=>{
  487. this.$message({
  488. type: "success",
  489. message: "操作成功!"
  490. });
  491. this.$emit('amendsDetailfun')
  492. })
  493. }else {
  494. this.tableData.splice(index, 1)
  495. }
  496. })
  497. },
  498. // 下拉的回调
  499. async corpChange(value,name,row) {
  500. if (name == 'corpCnName') {
  501. if (!value) {
  502. this.$set(row,'corpCnName','')
  503. this.$set(row,'corpEnName','')
  504. this.$set(row,'corpId','')
  505. }
  506. for(let item of this.corpCnNameData) {
  507. if (item.cnName == value){
  508. this.$set(row,'corpCnName',item.cnName)
  509. this.$set(row,'corpEnName',item.enName)
  510. this.$set(row,'corpId',item.id)
  511. }
  512. }
  513. }else if (name == 'feeCnName') {
  514. if (!value) {
  515. this.$set(row,'feeCnName','')
  516. this.$set(row,'feeEnName','')
  517. this.$set(row,'feeId','')
  518. this.$set(row,'feeCode','')
  519. // 选择费用简称带出核算要素
  520. this.$set(row,'elementsId','')
  521. this.$set(row,'elementsCnName','')
  522. this.$set(row,'elementsCode','')
  523. this.$set(row,'elementsEnName','')
  524. }
  525. for(let item of this.feeCnNameData) {
  526. if (item.cnName == value){
  527. if (value == 'PS') {
  528. // 查询当前客户的 ps规则是否等于零和null
  529. const psres = await getBcorpsDetail(this.form.corpId)
  530. if (!psres.data.data.psRate || Number(psres.data.data.psRate) == 0) {
  531. this.$confirm('PS规则为零不能添加费用', {
  532. confirmButtonText: "确定",
  533. cancelButtonText: "取消",
  534. type: "warning"
  535. })
  536. this.$set(row,'feeCnName','')
  537. this.$set(row,'feeEnName','')
  538. this.$set(row,'feeId','')
  539. this.$set(row,'feeCode','')
  540. // 核算要素
  541. this.$set(row,'elementsId','')
  542. this.$set(row,'elementsCnName','')
  543. this.$set(row,'elementsCode','')
  544. this.$set(row,'elementsEnName','')
  545. return
  546. }
  547. }
  548. this.$set(row,'feeCnName',item.cnName)
  549. this.$set(row,'feeEnName',item.enName)
  550. this.$set(row,'feeId',item.id)
  551. this.$set(row,'feeCode',item.code)
  552. // 选择费用简称带出核算要素
  553. this.$set(row,'elementsId',item.accElementId)
  554. this.$set(row,'elementsCnName',item.accElementName)
  555. this.$set(row,'elementsCode',item.elementsCode)
  556. this.$set(row,'elementsEnName',item.elementsEnName)
  557. // 拿取费用简称下的计量单位
  558. this.getBunitsPagefun(true,item,row)
  559. // 币别
  560. if (value == 'PS') {
  561. this.$set(row,'curCode','USD')
  562. }else {
  563. this.$set(row,'curCode',item.curNo)
  564. }
  565. // 汇率
  566. bcurrencyGetExrate({
  567. date:this.form.etd?this.form.etd.slice(0,10) + ' 00:00:00':dateFormat(new Date(), "yyyy-MM-dd") + ' 00:00:00', // 开船日期
  568. dc:row.dc
  569. }).then(res=>{
  570. for (let item of res.data.data) {
  571. if (item.code == row.curCode) {
  572. this.$set(row,'exrate',item.exrate)
  573. }
  574. }
  575. })
  576. // 计算金额
  577. this.$set(row,'amount',Number(row.price) * Number(row.quantity?row.quantity:0))
  578. if (row.curCode == 'CNY') {
  579. this.$set(row,'rmbAmount',row.amount)
  580. this.$set(row,'usdAmount','')
  581. this.$set(row,'rmbAmountNet',row.amount)
  582. this.$set(row,'usdAmountNet','')
  583. }else {
  584. this.$set(row,'usdAmount',row.amount)
  585. this.$set(row,'rmbAmount','')
  586. this.$set(row,'usdAmountNet',row.amount)
  587. this.$set(row,'rmbAmountNet','')
  588. }
  589. }
  590. }
  591. }else if (name == 'unitNo') {
  592. // 计量单位
  593. this.$set(row,name,value)
  594. for (let item of this.unitNoData) {
  595. if (item.code == value) {
  596. // 按箱型
  597. if (item.quantityRule == 1) {
  598. // 选择的箱那边的数据
  599. if (item.boxquantity) {
  600. this.$set(row,'quantity',item.boxquantity)
  601. }
  602. }
  603. // 按票
  604. if (item.quantityRule == 2) {
  605. this.$set(row,'quantity',1)
  606. }
  607. // 按重量
  608. if (item.quantityRule == 3) {
  609. this.$set(row,'quantity',this.form.grossWeight)
  610. }
  611. // 按TEU
  612. if (item.quantityRule == 4) {
  613. this.$set(row,'quantity',item.boxquantity)
  614. }
  615. // 按尺码
  616. if (item.quantityRule == 5) {
  617. this.$set(row,'quantity',this.form.measurement)
  618. }
  619. // 按件数
  620. if (item.quantityRule == 6) {
  621. this.$set(row,'quantity',this.form.quantity)
  622. }
  623. }
  624. }
  625. this.$set(row,'amount',Number(row.price?row.price:0) * Number(row.quantity?row.quantity:0))
  626. if (row.curCode == 'CNY') {
  627. this.$set(row,'rmbAmount',row.amount)
  628. this.$set(row,'usdAmount','')
  629. this.$set(row,'rmbAmountNet',row.amount)
  630. this.$set(row,'usdAmountNet','')
  631. }else {
  632. this.$set(row,'usdAmount',row.amount)
  633. this.$set(row,'rmbAmount','')
  634. this.$set(row,'usdAmountNet',row.amount)
  635. this.$set(row,'rmbAmountNet','')
  636. }
  637. } else if (name == 'elementsCnName') {
  638. if (!value) {
  639. this.$set(row,'elementsId','')
  640. this.$set(row,'elementsCnName','')
  641. this.$set(row,'elementsCode','')
  642. this.$set(row,'elementsEnName','')
  643. }
  644. // 核算要素
  645. for (let item of this.elementsData) {
  646. if (item.cnName == value) {
  647. this.$set(row,'elementsId',item.id)
  648. this.$set(row,'elementsCnName',item.cnName)
  649. this.$set(row,'elementsCode',item.code)
  650. this.$set(row,'elementsEnName',item.enName)
  651. }
  652. }
  653. }else if (name == 'curCode') {
  654. if (row.feeCnName == 'PS') {
  655. this.$set(row,'curCode','')
  656. value = 'USD'
  657. }
  658. for(let item of this.curCodeData) {
  659. if (item.code == value){
  660. if (item.code == 'USD') {
  661. if (Number(item.exrate) <= 1) {
  662. this.$message.warning('当前选择的币别汇率不能小于零')
  663. return
  664. }
  665. }else {
  666. if (Number(item.exrate) == 0) {
  667. this.$message.warning('当前选择的币别汇率不能为零')
  668. return
  669. }
  670. }
  671. this.$set(row,'curCode',item.code)
  672. this.$set(row,'exrate',item.exrate)
  673. this.$set(row,'amount',Number(row.price) * Number(row.quantity?row.quantity:0))
  674. if (row.curCode == 'CNY') {
  675. this.$set(row,'rmbAmount',row.amount)
  676. this.$set(row,'usdAmount','')
  677. this.$set(row,'rmbAmountNet',row.amount)
  678. this.$set(row,'usdAmountNet','')
  679. }else {
  680. this.$set(row,'usdAmount',row.amount)
  681. this.$set(row,'rmbAmount','')
  682. this.$set(row,'usdAmountNet',row.amount)
  683. this.$set(row,'rmbAmountNet','')
  684. }
  685. }
  686. }
  687. } else {
  688. this.$set(row,name,value)
  689. }
  690. },
  691. // 费用信息明细保存按钮
  692. feecenterSubmitListfun(){
  693. if (!this.form.id) {
  694. return this.$message.warning('请先保存数据')
  695. }
  696. // 判断必填项
  697. let sum = '请输入'
  698. for (let item of this.tableData) {
  699. if (!item.dc) {
  700. sum += ` 应收序号${item.$index + 1}收/付`
  701. }
  702. if (!item.corpId) {
  703. sum += ` 应收序号${item.$index + 1}往来单位`
  704. }
  705. if (!item.feeId) {
  706. sum += ` 应收序号${item.$index + 1}费用简称`
  707. }
  708. if (!item.elementsId) {
  709. sum += ` 应收序号${item.$index + 1}核算要素`
  710. }
  711. if (!item.curCode) {
  712. sum += ` 应收序号${item.$index + 1}币种`
  713. }
  714. }
  715. if(sum != '请输入') {
  716. this.$confirm(sum, {
  717. confirmButtonText: "确定",
  718. cancelButtonText: "取消",
  719. type: "warning"
  720. })
  721. return;
  722. }
  723. this.tableData.map((row,index)=>{
  724. row.dc = row.dc
  725. row.pid = this.form.id
  726. row.sort = Number(index) + 1
  727. row.businessType = this.form.businessType // 业务类型
  728. row.billType = this.form.billType // 单据类型
  729. row.billNo = this.form.billNo // 单据编号
  730. row.billDate = this.form.billDate // 单据日期
  731. row.billCorpId = this.form.corpId // 主表客户 id
  732. row.billCorpCnName = this.form.corpCnName // 主表客户中文名称
  733. row.billCorpEnName = this.form.corpEnName // 主表客户英文名称
  734. row.lineId = this.form.lineId // 航线 id
  735. row.lineCnName = this.form.lineCnName // 航线中文名称
  736. row.lineEnName = this.form.lineEnName // 航线英文名称
  737. row.vesselId = this.form.vesselId // 船名 id
  738. row.vesselCnName = this.form.vesselCnName // 中文船名
  739. row.vesselEnName = this.form.vesselEnName // 英文船名
  740. row.voyageNo = this.form.voyageNo // 航次
  741. row.mblno = this.form.mblno // MB/L NO
  742. row.hblno = this.form.hblno // HB/L NO
  743. row.etd = this.form.etd // 开船日期
  744. row.eta = this.form.eta // 到港日期
  745. row.polId = this.form.polId // 装货港 id
  746. row.polCode = this.form.polCode // 装货港代码
  747. row.polCnName = this.form.polCnName // 装货港中文名称
  748. row.polEnName = this.form.polEnName // 装货港英文名称
  749. row.podId = this.form.podId // 卸货港 id
  750. row.podCode = this.form.podCode // 卸货港代码
  751. row.podCnName = this.form.podCnName // 卸货港中文名称
  752. row.podEnName = this.form.podEnName // 卸货港英文名称
  753. row.corpArgreementNo = this.form.corpArgreementNo // 客户约号
  754. })
  755. feecenterSubmitList(this.tableData).then(res=>{
  756. this.$message({
  757. type: "success",
  758. message: "操作成功!"
  759. });
  760. this.$emit('amendsDetailfun')
  761. })
  762. },
  763. // 单价
  764. priceinputfun(value,row){
  765. if (Number(value) <= 0) {
  766. this.$message({
  767. type: "warning",
  768. message: "单价不能输入负数!"
  769. });
  770. return
  771. }
  772. this.$set(row,'amount',Number(row.price) * Number(row.quantity?row.quantity:0))
  773. // 判断是否有币种
  774. if (!row.curCode) {
  775. return;
  776. }
  777. if (row.curCode == 'CNY') {
  778. this.$set(row,'rmbAmount',row.amount)
  779. this.$set(row,'usdAmount','')
  780. this.$set(row,'rmbAmountNet',row.amount)
  781. this.$set(row,'usdAmountNet','')
  782. }else {
  783. this.$set(row,'usdAmount',row.amount)
  784. this.$set(row,'rmbAmount','')
  785. this.$set(row,'usdAmountNet',row.amount)
  786. this.$set(row,'rmbAmountNet','')
  787. }
  788. },
  789. // 数量
  790. quantityinputfun(row) {
  791. if (row.quantity <= 0) {
  792. this.$message({
  793. type: "warning",
  794. message: "数量不能输入负数!"
  795. });
  796. this.$set(row,'quantity',1)
  797. return
  798. }
  799. this.$set(row,'amount',Number(row.price?row.price:0) * Number(row.quantity))
  800. // 判断是否有币种
  801. if (!row.curCode) {
  802. return;
  803. }
  804. if (row.curCode == 'CNY') {
  805. this.$set(row,'rmbAmount',row.amount)
  806. this.$set(row,'usdAmount','')
  807. }else {
  808. this.$set(row,'usdAmount',row.amount)
  809. this.$set(row,'rmbAmount','')
  810. }
  811. },
  812. // 获取客户数据
  813. getBcorpsListfun(cnName){
  814. getBcorpsList(1,10,{cnName}).then(res=>{
  815. this.corpCnNameData = res.data.data.records
  816. })
  817. },
  818. // 获取费用数据
  819. bfeesListfun(cnName){
  820. bfeesList(1,10,{cnName}).then(res=>{
  821. this.feeCnNameData = res.data.data.records
  822. })
  823. },
  824. // 获取费用信息 核算要素信息
  825. getBaccelementsListfun(cnName){
  826. getBaccelementsList(1,10,{cnName}).then(res=>{
  827. this.elementsData = res.data.data.records
  828. })
  829. },
  830. // 获取预付到付字典数据
  831. paymodeWorkDictsfun(){
  832. getWorkDicts('payment_method_los').then((res) => {
  833. this.paymodeData = res.data.data
  834. })
  835. },
  836. // 获取币别数据
  837. bcurrencyGetExratefun(dc){
  838. bcurrencyGetExrate({
  839. date:this.form.etd?this.form.etd.slice(0,10) + ' 00:00:00':dateFormat(new Date(), "yyyy-MM-dd") + ' 00:00:00', // 开船日期
  840. dc:dc
  841. }).then(res=>{
  842. this.curCodeData = res.data.data
  843. })
  844. },
  845. // 获取计算属性
  846. async getBunitsPagefun(type,feeRow,row){
  847. let srcBillId = null
  848. if (this.form.billType == 'MH') {
  849. srcBillId = this.form.masterId
  850. }else {
  851. srcBillId = this.form.id
  852. }
  853. const res = await getBunitsPage({srcBillId})
  854. this.unitNoData = []
  855. let boxarr40 = ['40HC','40GP']
  856. let boxarr20 = ['20GP']
  857. let teunum = 0
  858. for (let item of res.data.data) {
  859. // 按箱型
  860. if (item.quantityRule != 1) {
  861. // TEU
  862. if (item.quantityRule == 4) {
  863. for (let data of this.form.preContainersList) {
  864. if (boxarr40.indexOf(data.cntrTypeCode) != -1) {
  865. teunum += Number(data.quantity) * 2
  866. }else if (boxarr20.indexOf(data.cntrTypeCode) != -1) {
  867. teunum += Number(data.quantity)
  868. }
  869. }
  870. this.unitNoData.push({...item, boxquantity: teunum})
  871. }else {
  872. this.unitNoData.push(item) // 不是TEU和不是箱的走这个
  873. }
  874. }
  875. }
  876. let arr = this.form.preContainersList.map(item=>{
  877. return {
  878. quantityRule:1, // 1 是按箱量
  879. code:item.cntrTypeCode,
  880. boxquantity:item.quantity,
  881. }
  882. })
  883. this.unitNoData = [...arr,...this.unitNoData]
  884. // 选择费用时带出第一条
  885. if (type) {
  886. let feeunitNodata = []
  887. for (let item of this.unitNoData) {
  888. if (item.quantityRule == feeRow.unitNo) {
  889. feeunitNodata.push(item)
  890. }
  891. }
  892. this.corpChange(feeunitNodata[0].code,'unitNo',row)
  893. }
  894. },
  895. // 多选选择的数据
  896. handleSelectionChange(arr){
  897. // this.$emit('handleSelectionChange',arr)
  898. this.handleSelectionData = arr
  899. },
  900. //自定义列保存
  901. async saveColumnTwo(ref, option, optionBack, code) {
  902. /**
  903. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  904. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  905. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  906. */
  907. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  908. if (inSave) {
  909. this.$message.success("保存成功");
  910. //关闭窗口
  911. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  912. }
  913. },
  914. //自定义列重置
  915. async resetColumnTwo(ref, option, optionBack, code) {
  916. this[option] = this[optionBack];
  917. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  918. if (inSave) {
  919. this.$message.success("重置成功");
  920. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  921. }
  922. },
  923. // 更改表格颜色
  924. headerClassName(tab) {
  925. //颜色间隔
  926. let back = ""
  927. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  928. if (tab.columnIndex % 2 === 0) {
  929. back = "back-one"
  930. } else if (tab.columnIndex % 2 === 1) {
  931. back = "back-two"
  932. }
  933. }
  934. return back;
  935. },
  936. },
  937. }
  938. </script>
  939. <style scoped>
  940. ::v-deep#out-table .back-one {
  941. background: #ecf5ff !important;
  942. text-align: center;
  943. padding: 4px 0;
  944. }
  945. ::v-deep#out-table .back-two {
  946. background: #ecf5ff !important;
  947. text-align: center;
  948. padding: 4px 0;
  949. }
  950. .textoverflow {
  951. width: 100%;
  952. overflow: hidden;
  953. white-space: nowrap;
  954. text-overflow: ellipsis;
  955. }
  956. </style>