cashierItem.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <div>
  3. <el-dialog title="指示" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
  4. <el-tag type="success" style="margin-right: 10px;">剩余收费(RMB){{ Number(form.amountDr - form.actualAmountDr).toFixed(2) }}</el-tag>
  5. <el-tag type="info" style="margin-right: 10px;">剩余收费(USD){{ Number(form.amountDrUsd - form.actualAmountDrUsd).toFixed(2) }}</el-tag>
  6. <el-tag type="warning" style="margin-right: 10px;">剩余付费(RMB){{ Number(form.amountCr - form.actualAmountCr).toFixed(2) }}</el-tag>
  7. <el-tag type="danger">剩余付费(USD){{ Number(form.amountCrUsd - form.actualAmountCrUsd).toFixed(2) }}</el-tag>
  8. <avue-crud
  9. v-if="dialogVisible"
  10. :option="option"
  11. :table-loading="loading"
  12. :data="data"
  13. ref="crud"
  14. id="out-table"
  15. :header-cell-class-name="headerClassName"
  16. @on-load="onLoad"
  17. >
  18. <template slot="indexHeader" slot-scope="{ row }">
  19. <el-button type="primary" size="small" icon="el-icon-plus" circle @click="addRow"></el-button>
  20. </template>
  21. <template slot="index" slot-scope="{ row, index }">
  22. <span>{{ index + 1 }}</span>
  23. </template>
  24. <template slot="status" slot-scope="{ row }">
  25. <span v-if="row.status == 0">{{ row.dc == "D" ? "未收款" : "未支付" }}</span>
  26. <span v-if="row.status == 1">{{ row.dc == "D" ? "已收款" : "已支付" }}</span>
  27. <span v-if="row.status == 2">{{ row.dc == "D" ? "部分收款" : "部分支付" }}</span>
  28. </template>
  29. <template slot="curCode" slot-scope="{ row }">
  30. <dic-select
  31. v-if="row.$cellEdit"
  32. :key="row.dc"
  33. v-model="row.curCode"
  34. placeholder="币别"
  35. label="code"
  36. :url="'/blade-los/bcurrency/getExrate?type=2&date=' + form.billDate + ' 00:00:00' + '&dc=' + row.dc"
  37. :filterable="true"
  38. @selectChange="rowDicChange('curCode', $event, row)"
  39. ></dic-select>
  40. <span v-else>{{ row.curCode }}</span>
  41. </template>
  42. <template slot="exrate" slot-scope="{ row }">
  43. <el-input-number
  44. v-if="row.$cellEdit"
  45. style="width: 100%;"
  46. v-model="row.exrate"
  47. @change="calculateChange(row)"
  48. label="请输入汇率"
  49. size="small"
  50. :controls="false"
  51. ></el-input-number>
  52. <span v-else>{{ row.exrate }}</span>
  53. </template>
  54. <!-- <template slot="amount" slot-scope="{ row }">
  55. <el-input-number
  56. v-if="row.$cellEdit"
  57. style="width: 100%;"
  58. v-model="row.amount"
  59. @change="calculateChange(row)"
  60. label="请输入金额"
  61. size="small"
  62. :controls="false"
  63. ></el-input-number>
  64. <span v-else>{{ row.amount }}</span>
  65. </template> -->
  66. <template slot="dc" slot-scope="{ row }">
  67. <el-select v-if="row.$cellEdit" v-model="row.dc" placeholder="请选择" size="small" @change="dcChange(row)">
  68. <el-option v-for="item in dcOptions" :key="item.value" :label="item.label" :value="item.value"> </el-option>
  69. </el-select>
  70. <span v-else>{{ row.dc == "D" ? "收" : "付" }}</span>
  71. </template>
  72. <template slot="taxRate" slot-scope="{ row }">
  73. <el-input-number
  74. v-if="row.$cellEdit"
  75. style="width: 100%;"
  76. v-model="row.taxRate"
  77. @change="calculateChange(row)"
  78. label="请输入税率"
  79. size="small"
  80. :controls="false"
  81. :min="0"
  82. ></el-input-number>
  83. <span v-else>{{ row.taxRate }}</span>
  84. </template>
  85. <template slot="menu" slot-scope="{ row, index }">
  86. <el-button type="text" size="small" @click="rowEdit(row)" :disabled="row.status == 1">{{ row.$cellEdit ? "保存" : "编辑" }}</el-button>
  87. <el-button type="text" size="small" @click="rowDel(row, index)" :disabled="row.status == 1">删除</el-button>
  88. </template>
  89. </avue-crud>
  90. <span slot="footer" class="dialog-footer">
  91. <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
  92. <el-button v-if="form.cashierStatus == 0" size="mini" type="success" :disabled="data.length == 0" @click="allClick('申请出纳')"
  93. >付费申请</el-button
  94. >
  95. <el-button v-if="form.cashierStatus == 1" size="mini" type="danger" @click="allClick('撤销申请出纳')">撤销付费申请</el-button>
  96. </span>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import { MktSlotQuotation, quotationImportBatch } from "@/api/iosBasicData/bills";
  102. import dicSelect from "@/components/dicSelect/main";
  103. import { getListAll, submit, submitList, remove, applyCashier, revokeCashier } from "@/api/iosBasicData/cashier.js";
  104. import { bcurrencyGetExrate } from "@/api/iosBasicData/rateManagement";
  105. export default {
  106. props: {
  107. disabled: {
  108. type: Boolean,
  109. default: false
  110. }
  111. },
  112. components: { dicSelect },
  113. data() {
  114. return {
  115. form: {},
  116. data: [],
  117. options: [
  118. {
  119. value: 0,
  120. label: "不含税"
  121. },
  122. {
  123. value: 1,
  124. label: "含税"
  125. }
  126. ],
  127. dcOptions: [
  128. {
  129. value: "D",
  130. label: "收"
  131. },
  132. {
  133. value: "C",
  134. label: "付"
  135. }
  136. ],
  137. dialogVisible: false,
  138. loading: false,
  139. option: {
  140. height: 500,
  141. calcHeight: 30,
  142. border: true,
  143. // index: true,
  144. addBtn: false,
  145. viewBtn: false,
  146. delBtn: false,
  147. editBtn: false,
  148. // menu: false,
  149. menuWidth: 100,
  150. header: false,
  151. align: "center",
  152. column: [
  153. {
  154. label: "index",
  155. prop: "index",
  156. width: "55",
  157. headerslot: true
  158. },
  159. {
  160. label: "状态",
  161. prop: "status",
  162. width: "60",
  163. overHidden: true
  164. },
  165. {
  166. label: "收/付",
  167. prop: "dc",
  168. width: "90",
  169. overHidden: true
  170. },
  171. {
  172. label: "币别",
  173. prop: "curCode",
  174. width: "100",
  175. overHidden: true
  176. },
  177. {
  178. label: "汇率",
  179. prop: "exrate",
  180. width: "70",
  181. overHidden: true
  182. },
  183. {
  184. label: "金额",
  185. prop: "amount",
  186. width: "100",
  187. overHidden: true
  188. },
  189. {
  190. label: "转汇后金额",
  191. prop: "amountLoc",
  192. width: "100",
  193. overHidden: true
  194. },
  195. {
  196. label: "税率(%)",
  197. prop: "taxRate",
  198. width: "80",
  199. overHidden: true
  200. },
  201. {
  202. label: "净额",
  203. prop: "amountNet",
  204. width: "100",
  205. overHidden: true
  206. },
  207. {
  208. label: "税额",
  209. prop: "amountTax",
  210. width: "80",
  211. overHidden: true
  212. },
  213. {
  214. label: "经办人",
  215. prop: "cashierName",
  216. width: "100",
  217. overHidden: true
  218. },
  219. {
  220. label: "经办时间",
  221. prop: "cashierTime",
  222. width: "100",
  223. overHidden: true
  224. },
  225. {
  226. label: "创建人",
  227. prop: "createUserName",
  228. width: "100",
  229. overHidden: true
  230. },
  231. {
  232. label: "创建时间",
  233. prop: "createTime",
  234. width: "100",
  235. overHidden: true
  236. },
  237. {
  238. label: "备注",
  239. prop: "remarks",
  240. cell: true,
  241. width: 120,
  242. overHidden: true
  243. }
  244. ]
  245. }
  246. };
  247. },
  248. async created() {
  249. // this.option = await this.getColumnData(this.getColumnName(309.6), this.optionBack);
  250. },
  251. methods: {
  252. async oneClickGeneration(row, list, dataList) {
  253. if (list.length == 0) {
  254. this.processData(row, list, dataList);
  255. }
  256. if (list.length) {
  257. let ids = [];
  258. for (const item of list) {
  259. ids.push(item.id);
  260. }
  261. await remove({ ids: ids.join(",") });
  262. this.data = [];
  263. this.processData(row, list, dataList);
  264. }
  265. },
  266. //生成指示
  267. async processData(row, list, dataList) {
  268. let amountDr = 0;
  269. let amountDrUsd = 0;
  270. let amountCr = 0;
  271. let amountCrUsd = 0;
  272. for (let item of dataList) {
  273. if (item.dc == "D" && item.currentStlCurCode == "CNY") {
  274. amountDr += Number(item.currentStlAmountRMB);
  275. }
  276. if (item.dc == "D" && item.currentStlCurCode == "USD") {
  277. amountDrUsd += Number(item.currentStlAmountUSD);
  278. }
  279. if (item.dc == "C" && item.currentStlCurCode == "CNY") {
  280. amountCr += Number(item.currentStlAmountRMB);
  281. }
  282. if (item.dc == "C" && item.currentStlCurCode == "USD") {
  283. amountCrUsd += Number(item.currentStlAmountUSD);
  284. }
  285. }
  286. if (amountDr > 0 || amountDrUsd > 0) {
  287. let obj = {
  288. type: 2,
  289. date: row.billDate + " 00:00:00",
  290. dc: "D"
  291. };
  292. const res = await bcurrencyGetExrate(obj);
  293. res.data.data.forEach(item => {
  294. if (amountDr > 0 && item.code == "CNY") {
  295. this.data.push({
  296. srcId: row.id,
  297. dc: "D",
  298. curCode: item.code,
  299. exrate: item.exrate,
  300. amount: amountDr,
  301. amountLoc: Number(Number(amountDr ? amountDr : 0)).toFixed(2),
  302. taxRate: 0,
  303. amountTax: Number(Number(amountDr ? amountDr : 0)).toFixed(2),
  304. amountNet: 0,
  305. applyCashierAmount: 0
  306. });
  307. }
  308. if (amountDrUsd > 0 && item.code == "USD") {
  309. this.data.push({
  310. srcId: row.id,
  311. dc: "D",
  312. curCode: item.code,
  313. exrate: item.exrate,
  314. amount: amountDrUsd,
  315. amountLoc: Number(Number(amountDrUsd ? amountDrUsd : 0) * Number(item.exrate ? item.exrate : 0)).toFixed(2),
  316. taxRate: 0,
  317. amountTax: Number(Number(amountDrUsd ? amountDrUsd : 0) * Number(item.exrate ? item.exrate : 0)).toFixed(2),
  318. amountNet: 0,
  319. applyCashierAmount: 0
  320. });
  321. }
  322. });
  323. }
  324. if (amountCr > 0 || amountCrUsd > 0) {
  325. let obj = {
  326. type: 2,
  327. date: row.billDate + " 00:00:00",
  328. dc: "C"
  329. };
  330. const res = await bcurrencyGetExrate(obj);
  331. res.data.data.forEach(item => {
  332. if (amountCr > 0 && item.code == "CNY") {
  333. this.data.push({
  334. srcId: row.id,
  335. dc: "C",
  336. curCode: item.code,
  337. exrate: item.exrate,
  338. amount: amountCr,
  339. amountLoc: Number(Number(amountCr ? amountCr : 0)).toFixed(2),
  340. taxRate: 0,
  341. amountTax: Number(Number(amountCr ? amountCr : 0)).toFixed(2),
  342. amountNet: 0,
  343. applyCashierAmount: 0
  344. });
  345. }
  346. if (amountCrUsd > 0 && item.code == "USD") {
  347. this.data.push({
  348. srcId: row.id,
  349. dc: "C",
  350. curCode: item.code,
  351. exrate: item.exrate,
  352. amount: amountCrUsd,
  353. amountLoc: Number(Number(amountCrUsd ? amountCrUsd : 0) * Number(item.exrate ? item.exrate : 0)).toFixed(2),
  354. taxRate: 0,
  355. amountTax: Number(Number(amountCrUsd ? amountCrUsd : 0) * Number(item.exrate ? item.exrate : 0)).toFixed(2),
  356. amountNet: 0,
  357. applyCashierAmount: 0
  358. });
  359. }
  360. });
  361. }
  362. if (this.data.length) {
  363. const res = await submitList(this.data);
  364. this.data = res.data.data;
  365. }
  366. },
  367. rowEdit(row) {
  368. if (row.$cellEdit) {
  369. if (!row.curCode) {
  370. return this.$message.error("币别不能为空");
  371. }
  372. if (!row.exrate) {
  373. return this.$message.error("汇率不能为空");
  374. }
  375. if (!row.amount || row.amount == 0 || row.amount < 0) {
  376. return this.$message.error("金额不能为非正数");
  377. }
  378. if (row.dc == "D" && row.curCode == "CNY") {
  379. if (Number(row.amount) > Number(this.form.amountDr - this.form.actualAmountDr)) {
  380. return this.$message.error("金额不能超过剩余出纳收费(RMB):" + Number(this.form.amountDr - this.form.actualAmountDr));
  381. }
  382. }
  383. if (row.dc == "D" && row.curCode == "USD") {
  384. if (Number(row.amount) > Number(this.form.amountDrUsd - this.form.actualAmountDrUsd)) {
  385. return this.$message.error("金额不能超过剩余出纳收费(USD):" + Number(this.form.amountDrUsd - this.form.actualAmountDrUsd));
  386. }
  387. }
  388. if (row.dc == "C" && row.curCode == "CNY") {
  389. if (Number(row.amount) > Number(this.form.amountCr - this.form.actualAmountCr)) {
  390. return this.$message.error("金额不能超过剩余出纳付费(RMB):" + Number(this.form.amountCr - this.form.actualAmountCr));
  391. }
  392. }
  393. if (row.dc == "C" && row.curCode == "USD") {
  394. if (Number(row.amount) > Number(this.form.amountCrUsd - this.form.actualAmountCrUsd)) {
  395. return this.$message.error("金额不能超过剩余出纳付费(USD):" + Number(this.form.amountCrUsd - this.form.actualAmountCrUsd));
  396. }
  397. }
  398. submit(row).then(res => {
  399. this.$set(row, "$cellEdit", false);
  400. this.$message({
  401. type: "success",
  402. message: "保存成功!"
  403. });
  404. for (let [key, value] of Object.entries(res.data.data)) {
  405. this.$set(row, key, value);
  406. }
  407. });
  408. } else {
  409. this.$set(row, "$cellEdit", true);
  410. }
  411. },
  412. allClick(name) {
  413. if (name == "申请出纳") {
  414. for (let item of this.data) {
  415. if (!item.id || item.$cellEdit) {
  416. return this.$message.error("请保存数据");
  417. }
  418. }
  419. const loading = this.$loading({
  420. lock: true,
  421. text: "加载中",
  422. spinner: "el-icon-loading",
  423. background: "rgba(255,255,255,0.7)"
  424. });
  425. applyCashier({ id: this.form.id })
  426. .then(res => {
  427. this.$emit("update");
  428. })
  429. .finally(() => {
  430. loading.close();
  431. });
  432. }
  433. if (name == "撤销申请出纳") {
  434. for (let item of this.data) {
  435. if (!item.id || item.$cellEdit) {
  436. return this.$message.error("请保存数据");
  437. }
  438. if (item.status == 1) {
  439. return this.$message.error("数据已支付,不允许撤销申请付费");
  440. }
  441. }
  442. this.$confirm("是否撤销申请付费?", "提示", {
  443. confirmButtonText: "确定",
  444. cancelButtonText: "取消",
  445. type: "warning"
  446. }).then(() => {
  447. const loading = this.$loading({
  448. lock: true,
  449. text: "加载中",
  450. spinner: "el-icon-loading",
  451. background: "rgba(255,255,255,0.7)"
  452. });
  453. revokeCashier({ id: this.form.id })
  454. .then(res => {
  455. this.$emit("update");
  456. })
  457. .finally(() => {
  458. loading.close();
  459. });
  460. });
  461. }
  462. },
  463. rowDel(row, index) {
  464. if (row.id) {
  465. this.$confirm("确定删除数据?", {
  466. confirmButtonText: "确定",
  467. cancelButtonText: "取消",
  468. type: "warning"
  469. }).then(() => {
  470. remove({ ids: row.id }).then(res => {
  471. this.$message({
  472. type: "success",
  473. message: "删除成功!"
  474. });
  475. this.data.splice(index, 1);
  476. });
  477. });
  478. } else {
  479. this.data.splice(index, 1);
  480. }
  481. },
  482. calculateChange(row) {
  483. row.amountLoc = Number(Number(row.amount ? row.amount : 0) * Number(row.exrate ? row.exrate : 0)).toFixed(2);
  484. row.amountTax = Number(Number(row.amountLoc ? row.amountLoc : 0) * Number(row.taxRate ? row.taxRate / 100 : 0)).toFixed(2);
  485. row.amountNet = Number(Number(row.amountLoc ? row.amountLoc : 0) - Number(row.amountTax ? row.amountTax : 0)).toFixed(2);
  486. },
  487. dcChange(row) {
  488. row.curCode = null;
  489. row.exrate = null;
  490. this.calculateChange(row);
  491. },
  492. rowDicChange(name, row, el) {
  493. if (name == "curCode") {
  494. if (row) {
  495. el.exrate = row.exrate;
  496. if (el.dc == "D" && el.curCode == "CNY") {
  497. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 1) {
  498. el.amount = Number(this.form.amountDr - this.form.actualAmountDr).toFixed(2);
  499. }
  500. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 2) {
  501. el.amount = Number(0).toFixed(2);
  502. }
  503. }
  504. if (el.dc == "D" && el.curCode == "USD") {
  505. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 1) {
  506. el.amount = Number(this.form.amountDrUsd - this.form.actualAmountDrUsd).toFixed(2);
  507. }
  508. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 2) {
  509. el.amount = Number(0).toFixed(2);
  510. }
  511. }
  512. if (el.dc == "C" && el.curCode == "CNY") {
  513. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 1) {
  514. el.amount = Number(this.form.amountCr - this.form.actualAmountCr).toFixed(2);
  515. }
  516. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 2) {
  517. el.amount = Number(0).toFixed(2);
  518. }
  519. }
  520. if (el.dc == "C" && el.curCode == "USD") {
  521. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 1) {
  522. el.amount = Number(this.form.amountCrUsd - this.form.actualAmountCrUsd).toFixed(2);
  523. }
  524. if (this.data.filter(item => el.dc == item.dc && el.curCode == item.curCode).length == 2) {
  525. el.amount = Number(0).toFixed(2);
  526. }
  527. }
  528. this.calculateChange(el);
  529. } else {
  530. el.exrate = null;
  531. this.calculateChange(el);
  532. }
  533. }
  534. },
  535. addRow() {
  536. this.data.push({ $cellEdit: true, srcId: this.form.id, dc: this.form.dc, taxRate: 0 });
  537. },
  538. openDialog(row, dataList, type) {
  539. this.dialogVisible = true;
  540. this.form = row;
  541. let obj = {
  542. srcId: row.id
  543. };
  544. this.loading = true;
  545. getListAll(obj)
  546. .then(res => {
  547. if (row.cashierStatus == 0 && type == "auto") {
  548. this.oneClickGeneration(row, res.data.data, dataList);
  549. }
  550. this.data = res.data.data;
  551. })
  552. .finally(() => {
  553. this.loading = false;
  554. });
  555. },
  556. //自定义列保存
  557. async saveColumn(ref, option, optionBack, code) {
  558. /**
  559. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  560. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  561. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  562. */
  563. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  564. if (inSave) {
  565. this.$message.success("保存成功");
  566. //关闭窗口
  567. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  568. this.searchReset();
  569. }
  570. },
  571. //自定义列重置
  572. async resetColumn(ref, option, optionBack, code) {
  573. this[option] = this[optionBack];
  574. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  575. if (inSave) {
  576. this.$message.success("重置成功");
  577. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  578. }
  579. },
  580. // 更改表格颜色
  581. headerClassName(tab) {
  582. //颜色间隔
  583. let back = "";
  584. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  585. if (tab.columnIndex % 2 === 0) {
  586. back = "back-one";
  587. } else if (tab.columnIndex % 2 === 1) {
  588. back = "back-two";
  589. }
  590. }
  591. return back;
  592. }
  593. }
  594. };
  595. </script>
  596. <style scoped>
  597. ::v-deep#out-table .back-one {
  598. background: #ecf5ff !important;
  599. text-align: center;
  600. padding: 4px 0;
  601. }
  602. ::v-deep#out-table .back-two {
  603. background: #ecf5ff !important;
  604. text-align: center;
  605. padding: 4px 0;
  606. }
  607. </style>