cashierItem.vue 15 KB

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