amendsCostdetails.vue 43 KB

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