Browse Source

项目文件管理完成

2545307760@qq.com 5 months ago
parent
commit
8f97fba300

+ 1 - 1
src/pinia/finance/finance.js

@@ -1,5 +1,5 @@
 import { defineStore } from 'pinia'
-import {getAllProject, queryProjectExpense} from "@/api/project"
+import { getAllProject, queryProjectExpense } from "@/api/project"
 import { getAllUsers } from "@/api/user"
 import { queryExpensesGenre } from "@/api/firmCost"
 export const useFinanceStore = defineStore('finance',() => {

+ 2 - 1
src/router/index.js

@@ -84,7 +84,8 @@ let routes= [
                     },
                 ],
             },
-        ]
+        ],
+        redirect: '/'
     },
     //{
     //配置404页面

+ 104 - 29
src/view/dashboard/components/dataStat.vue

@@ -1,17 +1,17 @@
 <template>
+  <van-cell-group>
+    <van-cell is-link title="筛选条件" @click="feeScreenShow = true" size="large">
+      <template #value>
+        <van-row justify="end">
+          <van-col @click.stop="resetFeeDetail">
+            <van-text-ellipsis content="重置"/>
+          </van-col>
+        </van-row>
+      </template>
+    </van-cell>
+  </van-cell-group>
   <van-tabs v-model:active="active">
     <van-tab title="按费用类型">
-      <van-cell-group>
-        <van-cell is-link title="筛选条件" @click="feeScreenShow = true" size="large">
-          <template #value>
-            <van-row justify="end">
-              <van-col @click.stop="resetFeeDetail">
-                <van-text-ellipsis content="重置"/>
-              </van-col>
-            </van-row>
-          </template>
-        </van-cell>
-      </van-cell-group>
       <van-collapse v-model="activeType" style="margin-top: 0.5rem">
         <van-collapse-item
             size="large"
@@ -56,35 +56,70 @@
   >
     <van-row style="margin-top: 0.5rem" class="feeScreenBox">
       <van-col :span="22" :offset="1">
-        <el-form label-width="90" label-position="left" size="large">
+        <el-form label-width="100" label-position="left" size="large">
+          <el-form-item label="项目:">
+            <el-select
+                v-model="condition.code"
+                clearable
+                placeholder="请选择项目"
+            >
+              <el-option
+                  v-for="item in projectData"
+                  :key="item.code"
+                  :label="item.name"
+                  :value="item.code"
+              />
+            </el-select>
+          </el-form-item>
           <el-form-item label="年份:">
             <el-date-picker
-                v-model="monthFee.yearTime"
+                v-model="condition.yearTime"
                 type="year"
                 placeholder="请选择年份"
                 format="YYYY"
                 value-format="YYYY"
                 clearable
-                @clear="monthFee.yearTime = ''"
+                @clear="condition.yearTime = ''"
             />
           </el-form-item>
           <el-form-item
-              label="月份:"
+              label="月份"
           >
             <el-date-picker
-                v-model="monthFee.monthTime"
+                v-model="condition.monthTime"
                 type="month"
                 placeholder="请选择月份"
                 format="YYYY-MM"
                 value-format="YYYY-MM"
                 clearable
-                @clear="monthFee.monthTime = ''"
+                @clear="condition.monthTime = ''"
             />
           </el-form-item>
+          <el-form-item
+              label="费用类型:"
+          >
+            <el-select
+                v-model="condition.genre"
+                clearable
+                placeholder="请选择项目"
+            >
+              <el-option
+                  v-for="item in firmCostTypeList"
+                  :key="item.ID"
+                  :label="item.name"
+                  :value="item.ID"
+              />
+            </el-select>
+          </el-form-item>
         </el-form>
         <van-row style="margin-top: 1rem">
           <van-col :span="24">
-            <van-button type="primary" size="large">查询</van-button>
+            <van-button
+                @click="queryDataInfo"
+                type="primary"
+                size="large">
+              查询
+            </van-button>
           </van-col>
         </van-row>
       </van-col>
@@ -93,47 +128,87 @@
 </template>
 
 <script setup>
-import { queryProjectMonthFee, queryMonthExpenses } from '@/api/project'
+import { queryProjectMonthFee, queryMonthExpenses,getAllProject } from '@/api/project'
+import { queryExpensesGenre } from "@/api/firmCost";
 defineOptions({
   name: 'DataStat',
 })
 onMounted(() => {
   getProjectMonthFee()
   getMonthExpenses()
+  queryAllProject()
+  getExpensesGenre()
 })
 const active = ref(0);
 const activeType = ref(['1'])
 const activeNames = ref(['1']);
-const monthFee = reactive({
-  monthTime: '',
-  yearTime: '',
-  code: ''
-})
-const monthExpenses = reactive({
+const condition = reactive({
   monthTime: '',
   yearTime: '',
+  code: '',
   genre: 0
 })
+// 获取所有项目
+const projectData = reactive([])
+const queryAllProject = () => {
+  getAllProject().then(res => {
+    if (res.code === 0) {
+      projectData.length = 0
+      projectData.push(...res.data)
+    }
+  })
+}
+// 查询公司费用类型
+const firmCostTypeList = reactive([])
+const queryDataInfo = () => {
+  getProjectMonthFee()
+  getMonthExpenses()
+}
+const getExpensesGenre = () => {
+  queryExpensesGenre().then(res => {
+    if (res.code === 0) {
+      firmCostTypeList.length = 0
+      firmCostTypeList.push(...res.data)
+    }
+  })
+}
 // 费用类型搜索、重置
 const feeScreenShow = ref(false)
 const resetFeeDetail = () => {
-  console.log('重置')
+  const initial = {
+    monthTime: '',
+    yearTime: '',
+    code: '',
+    genre: 0
+  }
+  Object.assign(condition, initial)
+  getProjectMonthFee()
+  getMonthExpenses()
 }
 const feeList = reactive([])
 const getProjectMonthFee = () => {
+  const monthFee = {
+    monthTime: condition.monthTime,
+    yearTime: condition.yearTime,
+    code: condition.code
+  }
   queryProjectMonthFee(monthFee).then(res => {
     if (res.code === 0) {
-      console.log('费用类型', res.data)
       feeList.length = 0
       feeList.push(...res.data)
+      feeScreenShow.value = false
     }
   })
 }
 const expensesList = reactive([])
 const getMonthExpenses = () => {
+  const monthExpenses = {
+    monthTime: condition.monthTime,
+    yearTime: condition.yearTime,
+    genre: condition.genre
+  }
   queryMonthExpenses(monthExpenses).then(res => {
     if (res.code === 0) {
-      console.log('部门', res.data)
       expensesList.length = 0
       expensesList.push(...res.data)
     }
@@ -162,6 +237,6 @@ const expenditures = computed(() => {
 }
 
 .feeScreenBox{
-  height: 300px;
+  height: 350px;
 }
 </style>

+ 48 - 33
src/view/dashboard/components/projectSum.vue

@@ -7,6 +7,15 @@
         @click="projectPickerShow = true"
     />
   </van-cell-group>
+  <van-row style="margin-top: 0.4rem">
+    <van-col :offset="1" :span="23">
+      <van-button
+          @click="resetChart"
+          icon="replay">
+        重置
+      </van-button>
+    </van-col>
+  </van-row>
   <div ref="myChart" id="myChart" class="chartBox"></div>
   <van-popup v-model:show="projectPickerShow" position="bottom">
     <van-picker
@@ -30,34 +39,9 @@ const columnsField = {
 }
 const currentProject = ref('')
 const projectPickerShow = ref(false)
+// 图表数据
 onMounted(() => {
-  const dom = document.getElementById('myChart');
-  const myChart = echarts.init(dom);
-  const option = {
-    tooltip: {
-      trigger: 'axis',
-      axisPointer: { type: 'cross' }
-    },
-    xAxis: {
-      type: 'category',
-      data: ['项目应收款', '项目已收款', '项目总营业额']
-    },
-    yAxis: {
-      type: 'value'
-    },
-    grid: {
-      left: "2%",
-      containLabel: true
-    },
-    series: [
-      {
-        data: [900000, 120000, 920000],
-        type: 'bar',
-        barWidth: '25%'
-      }
-    ]
-  }
-  myChart.setOption(option)
+  openChart('')
   queryAllProject()
 })
 // 查询项目列表
@@ -75,20 +59,51 @@ const queryAllProject = () => {
 const confirmProject = (val) => {
   currentProject.value = val.selectedOptions[0].name
   const code = val.selectedOptions[0].code
-  getProjectSum(code)
+  openChart(code)
   projectPickerShow.value = false
 }
 
-const getProjectSum = (code) => {
+const openChart = (code) => {
   queryProjectSum(code).then(res => {
     if (res.code === 0) {
-      console.log(res.data)
-      console.log('应收', res.data.Receivables)
-      console.log('收款', res.data.TotalCollectionAmount)
-      console.log('总营业额', res.data.TotalProjectAmount)
+      const receivable = res.data.Receivables
+      const received = res.data.TotalCollectionAmount
+      const turnover = res.data.TotalProjectAmount
+      const dom = document.getElementById('myChart');
+      const myChart = echarts.init(dom);
+      const option = {
+        tooltip: {
+          trigger: 'axis',
+          axisPointer: { type: 'cross' }
+        },
+        xAxis: {
+          type: 'category',
+          data: ['项目应收款', '项目已收款', '项目总营业额']
+        },
+        yAxis: {
+          type: 'value'
+        },
+        grid: {
+          left: "2%",
+          containLabel: true
+        },
+        series: [
+          {
+            data: [receivable, received, turnover],
+            type: 'bar',
+            barWidth: '25%'
+          }
+        ]
+      }
+      myChart.setOption(option)
     }
   })
 }
+
+const resetChart = () => {
+  currentProject.value = ''
+  openChart('')
+}
 </script>
 
 <style scoped lang="less">

+ 2 - 1
src/view/login/login.vue

@@ -96,7 +96,8 @@ const userLogin = () => {
     if (res.code === 0) {
       const data = res.data
       userStore.updateInfo(res.data)
-      router.push({path: '/navigation'})
+      router.push({path:'/navigation'})
+      // router.push({path: '/navigation/dashboard'})
     }
   })
 }

+ 30 - 20
src/view/navigation/navigation.vue

@@ -1,5 +1,25 @@
+<template>
+  <van-nav-bar left-text="退出登录" left-arrow class="mainInterface" @click-left="returnBack">
+    <template #title>
+      <span style="font-weight: 500">{{pageTitle}}</span>
+    </template>
+    <template #right>
+      <van-icon name="bars" size="35px" @click="openNavigation"/>
+    </template>
+  </van-nav-bar>
+  <router-view/>
+  <van-popup v-model:show="navigatorShow" round position="bottom">
+    <van-picker
+        :columns="navigationList"
+        @cancel="navigatorShow = false"
+        @confirm="confirmNavigator"
+    />
+  </van-popup>
+</template>
+
 <script setup>
 import {asyncMenu} from '@/api/menu.js'
+import {showConfirmDialog} from "vant";
 const router = useRouter()
 onMounted(() => {
   getMenuList()
@@ -50,29 +70,19 @@ const navigatorJump = (mine) => {
 }
 
 const returnBack = () => {
-  router.back()
+  showConfirmDialog({
+    message:
+        '确定要退出登录吗',
+  })
+      .then(() => {
+        router.push({path: '/'})
+      })
+      .catch(() => {
+        // on cancel
+      })
 }
 </script>
 
-<template>
-  <van-nav-bar left-text="返回" left-arrow class="mainInterface" @click-left="returnBack">
-    <template #title>
-      <span style="font-weight: 500">{{pageTitle}}</span>
-    </template>
-    <template #right>
-      <van-icon name="bars" size="35px" @click="openNavigation"/>
-    </template>
-  </van-nav-bar>
-  <router-view/>
-  <van-popup v-model:show="navigatorShow" round position="bottom">
-    <van-picker
-        :columns="navigationList"
-        @cancel="navigatorShow = false"
-        @confirm="confirmNavigator"
-    />
-  </van-popup>
-</template>
-
 <style scoped lang="scss">
 
 </style>