|
@@ -0,0 +1,219 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="my-layout">
|
|
|
|
+ <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
|
|
|
|
+ <el-form :inline="true" @submit.stop.prevent>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-select lable="选择项目" v-model="state.uploadFilter.ProjectId" value-key="id" clearable>
|
|
|
|
+ <el-option v-for="item in state.uploadProjectList" :key="item.id" :label="item.name"
|
|
|
|
+ :value="item.id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-upload style="margin-right: 5px;" :action="StatAction" :headers="StatHeaders"
|
|
|
|
+ :data="{ ProjectId: state.uploadFilter.ProjectId }"
|
|
|
|
+ :show-file-list="false" :before-upload="OnUploadStatBefore" :on-success="onUploadStatSuccess"
|
|
|
|
+ :on-error="onUploadStatError" accept=".xlsx">
|
|
|
|
+ <el-button type="primary" icon="ele-Upload"> 导入每日统计 </el-button>
|
|
|
|
+ </el-upload>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-date-picker v-model="state.uploadFilter.EffecDate" type="date" placeholder="选择结算日期"></el-date-picker>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="primary" @click="onSettle"> 结算 </el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <!-- <el-form-item>
|
|
|
|
+ <el-button type="primary" icon="ele-Download" @click="onDownExcel"> 导出项目统计模板 </el-button>
|
|
|
|
+ </el-form-item> -->
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-card>
|
|
|
|
+ <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
|
|
|
|
+ <el-form :inline="true" @submit.stop.prevent>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-select lable="选择项目" v-model="state.filter.projectId" value-key="id" clearable>
|
|
|
|
+ <el-option v-for="item in state.uploadProjectList" :key="item.id" :label="item.name"
|
|
|
|
+ :value="item.id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-select lable="选择平台" v-model="state.filter.tenantId" value-key="id" clearable>
|
|
|
|
+ <el-option v-for="item in state.uploadProjectList" :key="item.id" :label="item.name"
|
|
|
|
+ :value="item.id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-select lable="选择结算状态" v-model="state.filter.isSettele" clearable>
|
|
|
|
+ <el-option label="已结算" value="1"></el-option>
|
|
|
|
+ <el-option label="未结算" value="0"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-date-picker v-model="state.filter.effectDate" type="date" placeholder="选择作业时间"></el-date-picker>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-card>
|
|
|
|
+ <el-card class="my-fill mt8" shadow="never">
|
|
|
|
+ <el-table v-loading="state.loading" :data="state.listData" row-key="id" height="'100%'"
|
|
|
|
+ style="width: 100%; height: 100%">
|
|
|
|
+ <el-table-column label="项目名称" prop="projectName" min-width="120" show-overflow-tooltip />
|
|
|
|
+ <el-table-column label="所属平台" prop="orgName" min-width="120" show-overflow-tooltip />
|
|
|
|
+ <el-table-column label="作业日期" min-width="120" show-overflow-tooltip >
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ {{ row.effectDate.split(" ")[0]}}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="汇总(有效/总数)" min-width="120" show-overflow-tooltip>
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ {{ row.vaildCount }}/{{ row.count }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="状态" min-width="120" show-overflow-tooltip>
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ {{ row.isSettle === 1?'已结算':'未结算' }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <!-- <el-table-column label="操作" width="180" header-align="center" align="center" fixed="right">
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ <el-button size="small" text type="primary" @click="onDetail(row)">查看明细</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column> -->
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-card>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+<script lang="ts" setup name="admin/projectlink">
|
|
|
|
+import { onMounted, computed, reactive, onBeforeMount, getCurrentInstance } from 'vue'
|
|
|
|
+import { PageInputProjectStatManagePageInput, ProjectStatManagePageOutput, ProjectSelectOutput } from '/@/api/admin/data-contracts'
|
|
|
|
+import { ProjectStatApi } from '/@/api/admin/ProjectStat'
|
|
|
|
+import { ProjectApi } from '/@/api/admin/project'
|
|
|
|
+import pinia from '/@/stores/index'
|
|
|
|
+import { useUserInfo } from '/@/stores/userInfo'
|
|
|
|
+import eventBus from '/@/utils/mitt'
|
|
|
|
+import { AxiosResponse } from 'axios'
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const { proxy } = getCurrentInstance() as any
|
|
|
|
+const storesUserInfo = useUserInfo(pinia)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const state = reactive({
|
|
|
|
+ loading: false,
|
|
|
|
+ tenantFormTitle: '',
|
|
|
|
+ linkFormTitle: '',
|
|
|
|
+ uploadFilter: {
|
|
|
|
+ ProjectId: 0,
|
|
|
|
+ EffecDate: ''
|
|
|
|
+ },
|
|
|
|
+ filter: {
|
|
|
|
+ projectId: 0,
|
|
|
|
+ tenantId: 0,
|
|
|
|
+ isSettele: -1,
|
|
|
|
+ effectDate: ''
|
|
|
|
+ },
|
|
|
|
+ pageInput: {
|
|
|
|
+ currentPage: 1,
|
|
|
|
+ pageSize: 20,
|
|
|
|
+ } as PageInputProjectStatManagePageInput,
|
|
|
|
+ total: 0,
|
|
|
|
+ listData: [] as Array<ProjectStatManagePageOutput>,
|
|
|
|
+ uploadProjectList: [] as Array<ProjectSelectOutput>,
|
|
|
|
+ queryProjectList: [] as Array<ProjectSelectOutput>,
|
|
|
|
+ LinkLoading: false,
|
|
|
|
+ token: storesUserInfo.getToken()
|
|
|
|
+})
|
|
|
|
+onMounted(() => {
|
|
|
|
+ onProjects();
|
|
|
|
+ onQuery()
|
|
|
|
+ eventBus.off('refreshProjectStat')
|
|
|
|
+ eventBus.on('refreshProjectStat', async () => {
|
|
|
|
+ onQuery()
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+})
|
|
|
|
+onBeforeMount(() => {
|
|
|
|
+ eventBus.off('refreshProjectStat')
|
|
|
|
+})
|
|
|
|
+//查询
|
|
|
|
+const onQuery = async () => {
|
|
|
|
+ state.loading = true
|
|
|
|
+ state.pageInput.filter = state.filter
|
|
|
|
+ const res = await new ProjectStatApi().getPageManage(state.pageInput).catch(() => {
|
|
|
|
+ state.loading = false
|
|
|
|
+ })
|
|
|
|
+ state.listData = res?.data?.list ?? []
|
|
|
|
+ state.total = res?.data?.total ?? 0
|
|
|
|
+ state.loading = false
|
|
|
|
+}
|
|
|
|
+//项目列表
|
|
|
|
+const onProjects = async () => {
|
|
|
|
+ let input: any = {}
|
|
|
|
+ const res = await new ProjectApi().getAll(input).catch(() => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ state.uploadProjectList = res?.data ?? []
|
|
|
|
+ state.queryProjectList = res?.data ?? []
|
|
|
|
+}
|
|
|
|
+//导入项目统计
|
|
|
|
+// 上传项目统计请求url
|
|
|
|
+const StatAction = computed(() => {
|
|
|
|
+ return import.meta.env.VITE_API_URL + '/api/admin/project-stat/upload'
|
|
|
|
+})
|
|
|
|
+// 上传项目统计请求头部
|
|
|
|
+const StatHeaders = computed(() => {
|
|
|
|
+ return { Authorization: 'Bearer ' + state.token }
|
|
|
|
+})
|
|
|
|
+// 上传项目统计成功
|
|
|
|
+const onUploadStatSuccess = (res: AxiosResponse) => {
|
|
|
|
+ state.LinkLoading = false
|
|
|
|
+ if (!res?.success) {
|
|
|
|
+ if (res.msg) {
|
|
|
|
+ proxy.$modal.msgError(res.msg)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ eventBus.off('refreshProjectStat')
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// 上传项目统计失败
|
|
|
|
+const onUploadStatError = (error: any) => {
|
|
|
|
+ state.LinkLoading = false
|
|
|
|
+ let message = ''
|
|
|
|
+ if (error.message) {
|
|
|
|
+ try {
|
|
|
|
+ message = JSON.parse(error.message)?.msg
|
|
|
|
+ } catch (err) {
|
|
|
|
+ message = error.message || ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (message) proxy.$modal.msgError(message)
|
|
|
|
+}
|
|
|
|
+//上传项目统计前
|
|
|
|
+const OnUploadStatBefore = () => {
|
|
|
|
+ if (state.uploadFilter.ProjectId <= 0) {
|
|
|
|
+ proxy.$modal.msgError("请选择项目");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ state.token = storesUserInfo.getToken()
|
|
|
|
+ state.LinkLoading = true
|
|
|
|
+}
|
|
|
|
+//结算
|
|
|
|
+const onSettle = async () => {
|
|
|
|
+ proxy.$modal
|
|
|
|
+ .confirm(`请确认是否结算`)
|
|
|
|
+ .then(async () => {
|
|
|
|
+ const res = await new ProjectStatApi().Settle(state.uploadFilter, { loading: true }).catch(() => {
|
|
|
|
+ proxy.$modal.closeLoading()
|
|
|
|
+ })
|
|
|
|
+ if (res?.success) {
|
|
|
|
+ eventBus.emit('refreshProjectStat')
|
|
|
|
+ }
|
|
|
|
+ proxy.$modal.closeLoading()
|
|
|
|
+ })
|
|
|
|
+ .catch(() => { })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+</script>
|