parent
6e741f941b
commit
fc6cf381c5
|
|
@ -1,119 +1,169 @@
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<CuNavbar :isBack="isBack" title="上报"></CuNavbar>
|
<CuNavbar :isBack="isBack" title="上报"></CuNavbar>
|
||||||
<uv-sticky>
|
<view :class="[checkPermission(['store']) ? '' : 'pointer-events-none']">
|
||||||
<view class="bg-white h-80rpx flex items-center px-base">
|
<uv-form
|
||||||
<view>2024-03-21</view>
|
class="mt-30rpx"
|
||||||
<uv-icon class="ml-10rpx" size="20rpx" name="arrow-down-fill"></uv-icon>
|
labelPosition="left"
|
||||||
</view>
|
ref="formRef"
|
||||||
</uv-sticky>
|
:model="form"
|
||||||
{{ store.is_lottery_store }}
|
:rules="rules"
|
||||||
<uv-form
|
errorType="toast"
|
||||||
class="mt-30rpx"
|
labelWidth="130rpx"
|
||||||
labelPosition="left"
|
>
|
||||||
ref="form"
|
<view class="px-base space-y-20rpx">
|
||||||
labelWidth="130rpx"
|
<view class="card">
|
||||||
>
|
<view class="pl-20rpx">
|
||||||
<view class="px-base space-y-20rpx">
|
<uv-form-item
|
||||||
<view class="card">
|
label="日期"
|
||||||
<view class="pl-20rpx">
|
prop="form.date"
|
||||||
<uv-form-item label="日期" prop="userInfo.sex">
|
@click="showDateSelect"
|
||||||
<uv-input
|
|
||||||
disabled
|
|
||||||
disabledColor="#ffffff"
|
|
||||||
placeholder="请选择日期"
|
|
||||||
:border="`none`"
|
|
||||||
>
|
>
|
||||||
</uv-input>
|
<uv-input
|
||||||
<template v-slot:right>
|
disabled
|
||||||
<uv-icon name="arrow-right"></uv-icon>
|
v-model="form.date"
|
||||||
|
disabledColor="#ffffff"
|
||||||
|
placeholder="请选择日期"
|
||||||
|
:border="`none`"
|
||||||
|
>
|
||||||
|
</uv-input>
|
||||||
|
<template v-slot:right>
|
||||||
|
<uv-icon name="arrow-right"></uv-icon>
|
||||||
|
</template>
|
||||||
|
</uv-form-item>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="card" v-for="(item, i) in form.items" :key="i">
|
||||||
|
<TitleComp :title="item.name"></TitleComp>
|
||||||
|
<view class="mt-20rpx">
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
</view>
|
||||||
|
<view class="pl-20rpx">
|
||||||
|
<uv-form-item label="销售" :prop="`items.${i}.sales`">
|
||||||
|
<uv-input
|
||||||
|
@input="salesChange"
|
||||||
|
v-model="item.sales"
|
||||||
|
:border="`none`"
|
||||||
|
type="digit"
|
||||||
|
:placeholder="`请输入${item.name}销售金额`"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
<uv-form-item label="兑奖" :prop="`items.${i}.expenditure`">
|
||||||
|
<uv-input
|
||||||
|
@input="expenditureChange"
|
||||||
|
v-model="item.expenditure"
|
||||||
|
:border="`none`"
|
||||||
|
type="digit"
|
||||||
|
:placeholder="`请输入${item.name}兑奖金额`"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="card">
|
||||||
|
<TitleComp title="汇总情况"></TitleComp>
|
||||||
|
<view class="mt-20rpx">
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
</view>
|
||||||
|
<view class="pl-20rpx">
|
||||||
|
<uv-form-item label="销售合计" prop="sales">
|
||||||
|
<uv-input
|
||||||
|
:border="`none`"
|
||||||
|
type="digit"
|
||||||
|
v-model="form.sales"
|
||||||
|
placeholder="请输入总账销售金额"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
<uv-form-item label="兑奖合计" prop="expenditure">
|
||||||
|
<uv-input
|
||||||
|
type="digit"
|
||||||
|
:border="`none`"
|
||||||
|
v-model="form.expenditure"
|
||||||
|
placeholder="请输入电总账兑奖金额"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
<uv-form-item label="新增客户" prop="new_customers">
|
||||||
|
<uv-input
|
||||||
|
:border="`none`"
|
||||||
|
v-model="form.new_customers"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入微信新增人数"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
<uv-line color="#f5f5f5"></uv-line>
|
||||||
|
<uv-form-item label="交账金额" prop="handover_amount">
|
||||||
|
<uv-input
|
||||||
|
:border="`none`"
|
||||||
|
type="digit"
|
||||||
|
v-model="form.handover_amount"
|
||||||
|
placeholder="请输入交账金额"
|
||||||
|
></uv-input>
|
||||||
|
</uv-form-item>
|
||||||
|
<view class="text-primary text-24rpx py-10rpx"
|
||||||
|
>* 请确保填写的交账金额正确无误!</view
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="card">
|
||||||
|
<TitleComp title="时段报表照片">
|
||||||
|
<template #right>
|
||||||
|
<view class="text-24rpx text-gray-400"
|
||||||
|
>{{ form.photos.length }}/9</view
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
|
</TitleComp>
|
||||||
|
<uv-form-item label="" prop="photos">
|
||||||
|
<view>
|
||||||
|
<uv-upload
|
||||||
|
width="200rpx"
|
||||||
|
height="200rpx"
|
||||||
|
:maxCount="9"
|
||||||
|
multiple
|
||||||
|
:fileList="form.photos"
|
||||||
|
@afterRead="afterRead"
|
||||||
|
@delete="deletePic"
|
||||||
|
name="photos"
|
||||||
|
></uv-upload>
|
||||||
|
</view>
|
||||||
</uv-form-item>
|
</uv-form-item>
|
||||||
|
<view class="text-primary text-24rpx py-10rpx">
|
||||||
|
*竞彩时段报表照片,玩法时段报表照片,每日账本上传(需亲笔签字),销量本上传
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="card">
|
</uv-form>
|
||||||
<TitleComp title="电彩"></TitleComp>
|
</view>
|
||||||
<view class="pl-20rpx">
|
|
||||||
<uv-form-item label="销售" borderBottom>
|
|
||||||
<uv-input
|
|
||||||
border="none"
|
|
||||||
placeholder="请输入电彩销售金额"
|
|
||||||
></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
<uv-form-item label="兑奖">
|
|
||||||
<uv-input
|
|
||||||
border="none"
|
|
||||||
placeholder="请输入电彩兑奖金额"
|
|
||||||
></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="card">
|
|
||||||
<TitleComp title="汇总情况"></TitleComp>
|
|
||||||
<view class="pl-20rpx">
|
|
||||||
<uv-form-item label="销售合计" borderBottom>
|
|
||||||
<uv-input
|
|
||||||
border="none"
|
|
||||||
placeholder="请输入总账销售金额"
|
|
||||||
></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
<uv-form-item label="兑奖合计" borderBottom>
|
|
||||||
<uv-input
|
|
||||||
border="none"
|
|
||||||
placeholder="请输入电总账兑奖金额"
|
|
||||||
></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
<uv-form-item label="新增客户" borderBottom>
|
|
||||||
<uv-input
|
|
||||||
border="none"
|
|
||||||
placeholder="请输入微信新增人数"
|
|
||||||
></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
<uv-form-item label="交账金额" borderBottom>
|
|
||||||
<uv-input border="none" placeholder="请输入交账金额"></uv-input>
|
|
||||||
</uv-form-item>
|
|
||||||
<view class="text-primary text-24rpx py-10rpx"
|
|
||||||
>* 请确保填写的交账金额正确无误!</view
|
|
||||||
>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="card">
|
|
||||||
<TitleComp title="时段报表照片">
|
|
||||||
<template #right>
|
|
||||||
<view class="text-24rpx text-gray-400">0/9</view>
|
|
||||||
</template>
|
|
||||||
</TitleComp>
|
|
||||||
<view class="mt-20rpx">
|
|
||||||
<uv-upload
|
|
||||||
width="200rpx"
|
|
||||||
height="200rpx"
|
|
||||||
:fileList="[
|
|
||||||
{
|
|
||||||
url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
name="3"
|
|
||||||
multiple
|
|
||||||
:maxCount="9"
|
|
||||||
:previewFullImage="true"
|
|
||||||
></uv-upload>
|
|
||||||
</view>
|
|
||||||
<view class="text-primary text-24rpx py-10rpx">
|
|
||||||
*竞彩时段报表照片,玩法时段报表照片,每日账本上传(需亲笔签字),销量本上传
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</uv-form>
|
|
||||||
<view class="h-130rpx">
|
<view class="h-130rpx">
|
||||||
<view
|
<view
|
||||||
class="fixed bottom-0 left-0 right-0 h-120rpx bg-white flex-center box-border px-base"
|
class="fixed bottom-0 left-0 right-0 h-120rpx bg-white flex-center box-border px-base"
|
||||||
:style="style"
|
:style="style"
|
||||||
>
|
>
|
||||||
<view class="w-full">
|
<view class="w-full">
|
||||||
<uv-button type="primary" shape="circle" block> 上报 </uv-button>
|
<uv-button type="primary" shape="circle" block @click="submit">
|
||||||
|
上报
|
||||||
|
</uv-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<uv-calendars
|
||||||
|
color="#ee2c37"
|
||||||
|
confirmColor="#ee2c37"
|
||||||
|
ref="calendars"
|
||||||
|
@confirm="calendarsConfirm"
|
||||||
|
:endDate="endDate"
|
||||||
|
:date="form.date"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<uv-modal
|
||||||
|
ref="modalRef"
|
||||||
|
title="提示"
|
||||||
|
content="确定提交?"
|
||||||
|
@confirm="onSubmit"
|
||||||
|
:showCancelButton="true"
|
||||||
|
></uv-modal>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -122,16 +172,23 @@ import { http } from '@/utils/request'
|
||||||
import CuNavbar from '@/components/cu-navbar/index'
|
import CuNavbar from '@/components/cu-navbar/index'
|
||||||
import TitleComp from '@/components/title-comp/index'
|
import TitleComp from '@/components/title-comp/index'
|
||||||
import { addUnit, sys } from '@climblee/uv-ui/libs/function/index'
|
import { addUnit, sys } from '@climblee/uv-ui/libs/function/index'
|
||||||
import { computed, ref, onBeforeMount, reactive } from 'vue'
|
import { computed, ref, onBeforeMount, reactive, onMounted, watch } from 'vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { useUserStore } from '@/store/modules/user'
|
||||||
|
import { timeFormat } from '@climblee/uv-ui/libs/function/index'
|
||||||
|
import { add } from '@/utils/index'
|
||||||
|
import checkPermission from '@/utils/permission'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
const calendars = ref(null)
|
||||||
|
const modalRef = ref(null)
|
||||||
|
const formRef = ref(null)
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const userInfo = computed(() => userStore.userInfo || {})
|
const userInfo = computed(() => userStore.userInfo || {})
|
||||||
const store = computed(() => userInfo.value.store)
|
const store = computed(() => userInfo.value.store)
|
||||||
|
const endDate = timeFormat(new Date(), 'yyyy-mm-dd')
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
dateTime: Number(new Date()),
|
date: endDate,
|
||||||
items: [],
|
items: [],
|
||||||
new_customers: '',
|
new_customers: '',
|
||||||
sales: '',
|
sales: '',
|
||||||
|
|
@ -139,6 +196,23 @@ const form = reactive({
|
||||||
handover_amount: '',
|
handover_amount: '',
|
||||||
photos: [],
|
photos: [],
|
||||||
})
|
})
|
||||||
|
const rules = reactive({
|
||||||
|
date: {
|
||||||
|
required: true,
|
||||||
|
message: '请选择日期',
|
||||||
|
trigger: ['change'],
|
||||||
|
},
|
||||||
|
handover_amount: {
|
||||||
|
required: true,
|
||||||
|
message: '请输入交账金额',
|
||||||
|
trigger: ['change'],
|
||||||
|
},
|
||||||
|
photos: {
|
||||||
|
type: 'array',
|
||||||
|
required: true,
|
||||||
|
message: '请上传时段报表照片',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isBack: {
|
isBack: {
|
||||||
|
|
@ -152,12 +226,56 @@ const style = computed(() => {
|
||||||
return style
|
return style
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onShow(() => {
|
||||||
if (!store.value.is_lottery_store) {
|
getData(endDate)
|
||||||
getTypeList()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const submit = () => {
|
||||||
|
formRef.value.validate().then((res) => {
|
||||||
|
modalRef.value.open()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const onSubmit = async () => {
|
||||||
|
const params = {
|
||||||
|
date: form.date,
|
||||||
|
sales: form.sales,
|
||||||
|
expenditure: form.expenditure,
|
||||||
|
handover_amount: form.handover_amount,
|
||||||
|
new_customers: form.new_customers,
|
||||||
|
photos: form.photos.map((item) => item.url),
|
||||||
|
items: form.items,
|
||||||
|
}
|
||||||
|
http
|
||||||
|
.request({
|
||||||
|
url: '/ledgers',
|
||||||
|
method: 'POST',
|
||||||
|
header: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
data: params,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
uni.$emit('revert:submit', res)
|
||||||
|
uni.showToast({
|
||||||
|
title: '提交成功',
|
||||||
|
duration: 2000,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const getData = async () => {
|
||||||
|
const resData = await http.get(`/ledgers/${form.date}`)
|
||||||
|
|
||||||
|
Object.assign(form, resData, {
|
||||||
|
photos:
|
||||||
|
resData?.photos?.map((item) => {
|
||||||
|
return { url: item }
|
||||||
|
}) || [],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const getTypeList = () => {
|
const getTypeList = () => {
|
||||||
http
|
http
|
||||||
.get('/keywords', {
|
.get('/keywords', {
|
||||||
|
|
@ -166,7 +284,113 @@ const getTypeList = () => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res)
|
form.items = res
|
||||||
|
res.forEach((item, i) => {
|
||||||
|
rules[`items.${i}.${'sales'}`] = {
|
||||||
|
required: true,
|
||||||
|
message: `请输入${item.name}销售金额`,
|
||||||
|
}
|
||||||
|
rules[`items.${i}.${'expenditure'}`] = {
|
||||||
|
required: true,
|
||||||
|
message: `请输入${item.name}兑奖金额`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log(rules)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const calendarsConfirm = (e) => {
|
||||||
|
form.date = e.fulldate
|
||||||
|
getData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const showDateSelect = () => {
|
||||||
|
calendars.value.open()
|
||||||
|
hideKeyboard()
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideKeyboard = () => {
|
||||||
|
uni.hideKeyboard()
|
||||||
|
}
|
||||||
|
|
||||||
|
const afterRead = async (event) => {
|
||||||
|
let lists = [].concat(event.file)
|
||||||
|
let fileListLen = form[event.name].length
|
||||||
|
|
||||||
|
lists.map((item) => {
|
||||||
|
form[event.name].push({
|
||||||
|
...item,
|
||||||
|
status: 'uploading',
|
||||||
|
message: '上传中',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
for (let i = 0; i < lists.length; i++) {
|
||||||
|
const result = await uploadFilePromise(lists[i].url)
|
||||||
|
let item = form[event.name][fileListLen]
|
||||||
|
form[event.name].splice(
|
||||||
|
fileListLen,
|
||||||
|
1,
|
||||||
|
Object.assign(item, {
|
||||||
|
status: 'success',
|
||||||
|
message: '',
|
||||||
|
url: result,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
fileListLen++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadFilePromise = (url) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
http
|
||||||
|
.upload('/fileupload', {
|
||||||
|
filePath: url,
|
||||||
|
name: 'file',
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
resolve(res.url)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const deletePic = (event) => {
|
||||||
|
form[event.name].splice(event.index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const salesChange = () => {
|
||||||
|
const val = form?.items || []
|
||||||
|
const sales = val.reduce((a, b) => {
|
||||||
|
return add(a, b?.sales ?? 0)
|
||||||
|
}, 0)
|
||||||
|
form.sales = sales || null
|
||||||
|
}
|
||||||
|
|
||||||
|
const expenditureChange = () => {
|
||||||
|
const val = form?.items || []
|
||||||
|
const expenditure = val.reduce((a, b) => {
|
||||||
|
return add(a, b?.expenditure ?? 0)
|
||||||
|
}, 0)
|
||||||
|
form.expenditure = expenditure || null
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => form.items,
|
||||||
|
(val) => {
|
||||||
|
const sales = val.reduce((a, b) => {
|
||||||
|
return add(a, b?.sales ?? 0)
|
||||||
|
}, 0)
|
||||||
|
const expenditure = val.reduce((a, b) => {
|
||||||
|
return add(a, b?.expenditure ?? 0)
|
||||||
|
}, 0)
|
||||||
|
// form.sales = sales || null
|
||||||
|
// form.expenditure = expenditure || null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
/**
|
||||||
|
* 获取月份天数
|
||||||
|
* @param {number} year
|
||||||
|
* @param {number} month
|
||||||
|
* @returns 天数
|
||||||
|
*/
|
||||||
|
export function getDayCount(year, month) {
|
||||||
|
if (month == 2) {
|
||||||
|
if (year % 400 === 0 || (year % 4 === 0 && year % 100)) { // 闰年
|
||||||
|
return 29;
|
||||||
|
}
|
||||||
|
return 28;
|
||||||
|
}
|
||||||
|
return [1, 3, 5, 7, 8, 10, 12].indexOf(month) >= 0 ? 31 : 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算指定日期 后几天的日期
|
||||||
|
* @param {Date} date
|
||||||
|
* @param {Number} count
|
||||||
|
*/
|
||||||
|
export function dateAfterDayCount(date = Date.now(), count = 1) {
|
||||||
|
date = new Date(date)
|
||||||
|
date.setDate(date.getDate() + count)
|
||||||
|
return date
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 加法函数(精度丢失问题)
|
||||||
|
export function add(arg1, arg2) {
|
||||||
|
let r1, r2, m;
|
||||||
|
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
||||||
|
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
||||||
|
m = Math.pow(10, Math.max(r1, r2));
|
||||||
|
return (arg1 * m + arg2 * m) / m
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 减法函数(精度丢失问题)
|
||||||
|
export function sub(arg1, arg2) {
|
||||||
|
let r1, r2, m, n;
|
||||||
|
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
||||||
|
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
||||||
|
m = Math.pow(10, Math.max(r1, r2));
|
||||||
|
n = (r1 >= r2) ? r1 : r2;
|
||||||
|
return Number(((arg1 * m - arg2 * m) / m).toFixed(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 乘法函数(精度丢失问题)
|
||||||
|
export function mcl(num1, num2) {
|
||||||
|
let m = 0, s1 = num1.toString(), s2 = num2.toString();
|
||||||
|
try { m += s1.split(".")[1].length } catch (e) { }
|
||||||
|
try { m += s2.split(".")[1].length } catch (e) { }
|
||||||
|
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 除法函数(精度丢失问题)
|
||||||
|
export function division(num1, num2) {
|
||||||
|
let t1, t2, r1, r2;
|
||||||
|
try {
|
||||||
|
t1 = num1.toString().split('.')[1].length;
|
||||||
|
} catch (e) {
|
||||||
|
t1 = 0;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
t2 = num2.toString().split(".")[1].length;
|
||||||
|
} catch (e) {
|
||||||
|
t2 = 0;
|
||||||
|
}
|
||||||
|
r1 = Number(num1.toString().replace(".", ""));
|
||||||
|
r2 = Number(num2.toString().replace(".", ""));
|
||||||
|
return (r1 / r2) * Math.pow(10, t2 - t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//递归生成树形结构
|
||||||
|
export function getTreeData(data, pid, pidName = 'parentId', idName = 'id', childrenName = 'children', key = 'key', isNull = true) {
|
||||||
|
let arr = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
if (data[i][pidName] == pid) {
|
||||||
|
data[i][key] = data[i][idName];
|
||||||
|
data[i][childrenName] = getTreeData(data, data[i][idName], pidName, idName, childrenName, key, isNull);
|
||||||
|
if (isNull && data[i][childrenName].length == 0) delete data[i][childrenName]
|
||||||
|
arr.push(data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
|
|
||||||
|
export default function checkPermission(value) {
|
||||||
|
const store = useUserStoreWithOut()
|
||||||
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
|
const roles = store?.roles || []
|
||||||
|
const permissionRoles = value
|
||||||
|
|
||||||
|
const hasPermission = roles.some(role => {
|
||||||
|
return permissionRoles.includes(role)
|
||||||
|
})
|
||||||
|
return hasPermission
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ http.setConfig((config) => {
|
||||||
config.baseURL = apiUrl;
|
config.baseURL = apiUrl;
|
||||||
config.timeout = 10000;
|
config.timeout = 10000;
|
||||||
config.header = Object.assign({
|
config.header = Object.assign({
|
||||||
'Content-Type': 'application/json;charset=UTF-8'
|
// 'Content-Type': 'application/json;charset=UTF-8',
|
||||||
}, config.header);
|
}, config.header);
|
||||||
/* 设置全局配置 */
|
/* 设置全局配置 */
|
||||||
config.validateStatus = (statusCode) => {
|
config.validateStatus = (statusCode) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue