| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { getRateList, bcurrencyGetExrate, standardCurrency, obtainRate } from "@/api/iosBasicData/rateManagement";
- import { getCurrentDate } from "@/util/date";
- //本地存储币别信息
- export async function setRateData() {
- let obj = {
- current: 1,
- size: 20
- }
- let res = await getRateList(obj)
- localStorage.setItem("币别信息", JSON.stringify(res.data.data.records));
- return res
- }
- //本地获取币别信息
- export function getRateData() {
- if (localStorage.getItem("币别信息")) {
- return JSON.parse(localStorage.getItem("币别信息"))
- } else {
- this.$confirm('本地暂无汇率信息,请刷新页面?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'error'
- }).then(() => {
- this.setRateData()
- })
- }
- }
- //获取本币币别
- export function getLocalCurrency() {
- return localStorage.getItem("本币");
- }
- //获取本币币别
- export function getCheckRate() {
- return JSON.parse(localStorage.getItem("所有币别以汇率")) ? JSON.parse(localStorage.getItem("所有币别以汇率")) : []
- }
- // 查本币
- export async function saveLocalCurrency(deptId) {
- let obj = {
- deptId: deptId
- }
- let res = await standardCurrency(obj)
- localStorage.setItem("本币", res.data.data);
- return res.data.data ? true : false
- }
- //查所有币别以汇率
- export async function checkRate(curCode, date, dc, type, deptId) {
- let obj = {
- deptId: deptId,
- date: date ? date : getCurrentDate(),
- type: type ? type : 1
- }
- let res = await obtainRate(obj)
- localStorage.setItem("所有币别以汇率", JSON.stringify(res.data.data));
- if (curCode) {
- for (let item of res.data.data) {
- if (item.code == curCode) {
- if (type == 1 && dc == 'D') return item.exrateReceivable
- if (type == 1 && dc == 'C') return item.exratePayable
- if (type == 2 && dc == 'D') return item.exrateReceipts
- if (type == 2 && dc == 'C') return item.exratePayment
- }
- }
- }
- }
- //查汇率
- export function getExchangeRate(curCode, dc, type) {
- for (let item of this.getCheckRate()) {
- if (item.code == curCode) {
- if (type == 1 && dc == 'D') return item.exrateReceivable
- if (type == 1 && dc == 'C') return item.exratePayable
- if (type == 2 && dc == 'D') return item.exrateReceipts
- if (type == 2 && dc == 'C') return item.exratePayment
- }
- }
- }
|