amendsCostdetails.vue 43 KB

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