165 lines
5.2 KiB
Vue

<template>
<MBLoading
v-if="submitLoading"
style="position: absolute;display: block;z-index: 9999;background: rgb(0 0 0 / 14%);inset: 0px;overflow: hidden;margin: 0;height: 100svh;"/>
<view ref="targetRef" class="container">
<MBCard>
<uni-forms ref="baseForm" :modelValue="queryParams">
<uni-forms-item label="支付方式">
<DictSelect v-model="queryParams.isPayNow" dict="dazhong_paytype" @change="handleQuery"/>
</uni-forms-item>
<uni-forms-item label="生产单位">
<ProductionUnit v-model="queryParams.companyId" @change="handleQuery"/>
</uni-forms-item>
</uni-forms>
</MBCard>
<MBLoading v-if="loading"/>
<view v-else>
<MBCard v-if="selected.length>0" :style="{
position: 'fixed',
zIndex : 10,
width:'100%',
left: 0,
bottom: 0,
height:'110px'
}
">
<view class="context">
<view class="label">
<text>已选订单数量:</text>
<text>{{ selected.length }}</text>
</view>
<view class="label">
<text>已选订单总金额:</text>
<text>{{ totalMoney.toFixed(2) }}</text>
</view>
</view>
<view :style="{
display:'flex',
marginTop:'15px',
justifyContent:'space-between',
alignItems:'center'
}">
<button class="mini-btn" size="mini" type="success" @click="handleBack">回退</button>
<button class="mini-btn" size="mini" type="primary" @click="handleSubmit">审核</button>
</view>
</MBCard>
<ListItem v-if="tableData.length > 0" :items="tableData" @checkboxSelected="handleSelect"/>
<uni-load-more
v-else
:contentText="{
contentnomore: '- 暂无商务审批数据 -'
}"
:status="'no-more'"
/>
<MBPagination
v-if="total > 0"
v-model:limit="paging.pageSize"
v-model:page="paging.pageNum"
:total="total"
@pagination="handleQuery"
/>
</view>
</view>
</template>
<script setup>
import {getCurrentInstance, onMounted, ref} from "vue"
import UniForms from "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
import DictSelect from "../../../components/DictSelect/DictSelect.vue";
import ProductionUnit from "../../../components/ProductionUnit/ProductionUnit.vue";
import MBCard from "../../../components/MB/MBCard.vue";
import {managerConfirm, managerRefuse, mangerList} from "../../../api/BusinessApproval";
import MBPagination from "../../../components/MB/MBPagination.vue";
import MBLoading from "../../../components/MB/MBLoading.vue";
import ListItem from "./ListItem.vue";
const {proxy} = getCurrentInstance()
const queryParams = ref({
state: '1',
isPayNow: '',
companyId: ''
})
const loading = ref(true)
const total = ref(0)
const paging = ref({
pageNum: 1,
pageSize: 10,
isAsc: 'descending',
orderByColumn: 'adddate'
})
const tableData = ref([])
const submitLoading = ref(false)
const handleQuery = async () => {
loading.value = true
const data = await mangerList(queryParams.value, paging.value)
total.value = data.total
tableData.value = data.rows
loading.value = false
}
const selected = ref([])
const totalMoney = ref(0)
const handleSelect = (payload) => {
const {checked, data} = payload
const id = data.saleid
if (checked) {
if (!selected.value.includes(id)) {
selected.value.push(id)
}
} else {
selected.value = selected.value.filter(item => item !== id)
}
totalMoney.value = tableData.value.filter(item => selected.value.includes(item.saleid))
.map(i => i.contractmoney)
.reduce((a, b) => a + b, 0)
?? 0
}
onMounted(async () => {
await handleQuery()
})
const handleBack = async () => {
submitLoading.value = true
await Promise.allSettled(
selected.value.map(id =>
managerRefuse({
saleIds: id,
actionType: new Date().getDate() < 25 ? '1' : '0'
})
)
)
selected.value = []
totalMoney.value = 0
await handleQuery()
submitLoading.value = false
}
const handleSubmit = async () => {
submitLoading.value = true
await Promise.allSettled(
selected.value.map(id =>
managerConfirm({
saleIds: id,
actionType: new Date().getDate() < 25 ? '1' : '0'
})
)
)
selected.value = []
totalMoney.value = 0
await handleQuery()
submitLoading.value = false
}
</script>