Browse Source

feat: 首页

chenjj 4 weeks ago
parent
commit
d86db44d8d
4 changed files with 322 additions and 8 deletions
  1. 30 0
      src/api/index.js
  2. 290 2
      src/views/index.vue
  3. 1 5
      src/views/staff/user/index.vue
  4. 1 1
      vite.config.js

+ 30 - 0
src/api/index.js

@@ -0,0 +1,30 @@
+import request from '@/utils/request'
+
+// 订单总览
+export const orderSummary = (data) => {
+  return request({
+    url: `/core/org/stat/orderSummary`,
+    method: 'post',
+    data
+  })
+}
+// 人员总览
+export const userSummary = (data) => {
+    return request({
+      url: `/core/org/stat/userSummary`,
+      method: 'post',
+      data
+    })
+  }
+
+//机构排名
+export const orgRank = (data) => {
+    return request({
+      url: `/core/org/stat/orgRank`,
+      method: 'post',
+      data
+    })
+  }
+
+
+  

+ 290 - 2
src/views/index.vue

@@ -1,11 +1,299 @@
 <template>
-  <div class="home-content">11</div>
+  <div class="home-content">
+    
+    <el-row :gutter="20">
+      <el-col :span="12" style="margin-bottom: 20px;">
+        <el-card shadow="never">
+          <div class="card-header">
+            <h3 class="card-title">订单总览</h3>
+            <el-radio-group v-model="queryKey" style="margin-bottom: 30px" @change="init">
+        <el-radio-button v-for="item in btns" :key="item.key" :value="item.key">{{ item.name }}</el-radio-button>
+      </el-radio-group>
+          </div>
+          <el-row>
+            <el-col :span="6" v-for="item in orderReview" :key="item.key">
+              <el-statistic :value="data[item.key]">
+                <template #title>
+                  <div>
+                    {{ item.name }}
+                  </div>
+                </template>
+              </el-statistic>
+            </el-col>
+          </el-row>
+        </el-card>
+      </el-col>
+      <el-col :span="12">
+        <el-card shadow="never">
+          <div class="card-header">
+            <h3 class="card-title">人员总览</h3>
+            <el-radio-group v-model="userKey" style="margin-bottom: 30px" @change="init">
+              <el-radio-button v-for="item in userbtns" :key="item.key" :value="item.key">{{ item.name }}</el-radio-button>
+            </el-radio-group>
+          </div>
+          <el-row>
+            <el-col :span="6" v-for="item in userReview" :key="item.key">
+              <el-statistic :value="data[item.key]">
+                <template #title>
+                  <div>
+                    {{ item.name }}
+                  </div>
+                </template>
+              </el-statistic>
+            </el-col>
+          </el-row>
+        </el-card>
+      </el-col>
+      <el-col :span="12">
+        <el-card shadow="never">
+          <div class="card-header">
+            <h3 class="card-title">区县收入排名</h3>
+          </div>
+          <el-row>
+            <el-col :span="24" v-for="item in data.orgAmountVos" :key="item.key">
+              <div class="phStyle">
+                <div class="phStyle-left">{{ item.orgName }}:</div>
+                <div class="progress"><el-progress :percentage="(item.orderAmount/data.orgAmountVos[0].orderAmount) * 100">
+                <span>{{ item.orderAmount  }}</span>
+               </el-progress></div>
+              </div>
+            </el-col>
+          </el-row>
+        </el-card>
+      </el-col>
+      <el-col :span="12">
+        <el-card shadow="never">
+          <div class="card-header">
+            <h3 class="card-title">区县订单总量排名</h3>
+          </div>
+          <el-row>
+            <el-col :span="24" v-for="item in data.orgOrderVos" :key="item.key">
+              <div class="phStyle">
+                <div class="phStyle-left">{{ item.orgName }}:</div>
+                <div class="progress"><el-progress :percentage="(item.orderTotal/data.orgOrderVos[0].orderTotal) * 100">
+                <span>{{ item.orderTotal  }}</span>
+               </el-progress></div>
+              </div>
+            </el-col>
+          </el-row>
+        </el-card>
+      </el-col>
+    </el-row>
+
+
+
+
+  </div>
 </template>
 
-<script setup></script>
+<script setup>
+import { orderSummary, userSummary, orgRank } from '@/api/index'
+import { computed } from 'vue'
+import { onMounted } from 'vue'
+
+const queryKey = ref('')
+const userKey = ref(1)
+
+const queryparmasTimes = computed(() => {
+  if(queryKey.value === 'today'){
+    return getToday();
+  }
+  if(queryKey.value === 'yesterday'){
+    return getYesterday();
+  }
+  if(queryKey.value === 'week'){
+    return getThisWeek();
+  }
+  return ''
+})
+
+const btns = [
+  {
+    name: '今日',
+    key: 'today'
+  },
+  {
+    name: '昨日',
+    key: 'yesterday'
+  },
+  {
+    name: '本周',
+    key: 'getThisWeek'
+  },
+  {
+    name: '全部',
+    key: ''
+  },
+]
+const userbtns = [
+  {
+    name: '用户',
+    key: 1
+  },
+  {
+    name: '志愿者',
+    key: 2
+  },
+]
+const orderReview = [
+  {
+    name: '订单总量',
+    key: 'orderTotal'
+  },
+  {
+    name: '取消单量',
+    key: 'orderCancelTotal'
+  },
+  {
+    name: '总金额',
+    key: 'orderTotalAmount'
+  },
+  {
+    name: '完成单量',
+    key: 'orderFinishTotal	'
+  },
+]
+
+const userReview = [
+  {
+    name: '用户总量',
+    key: 'userTotal'
+  },
+  {
+    name: '今日新增',
+    key: 'todayAdd'
+  },
+  {
+    name: '昨日新增',
+    key: 'yesterdayAdd'
+  },
+  {
+    name: '本月新增',
+    key: 'monthAdd'
+  },
+]
+const getToday = () => {
+  const today = new Date();
+  today.setHours(0, 0, 0, 0); // 设置为当天的零点
+  return today;
+};
+
+const getYesterday = () => {
+  const yesterday = new Date();
+  yesterday.setDate(yesterday.getDate() - 1);
+  yesterday.setHours(0, 0, 0, 0); // 设置为昨天的零点
+  return yesterday;
+};
+
+const getThisWeek = () => {
+  const today = new Date();
+  const dayOfWeek = today.getDay(); // 获取今天的星期几(0-6,0是周日)
+  const diffToMonday = today.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1); // 计算到周一的天数差值
+  const monday = new Date(today);
+  monday.setDate(diffToMonday);
+  monday.setHours(0, 0, 0, 0); // 设置为本周一的零点
+  return monday;
+};
+
+
+const data = ref({
+  order: 388
+})
+
+
+const init = async () => {
+  try {
+    const parmas = {
+      startDate:queryparmasTimes.value
+    }
+    const res1 = await orderSummary(parmas)
+    const res2 = await userSummary({...parmas,userType: userKey.value})
+    const res3 = await orgRank({})
+    data.value = {
+      ...res1.data,
+      ...res2.data,
+      ...res3.data,
+    }
+    console.log('data.value');
+    
+  } catch (error) {
+
+  }
+}
+
+onMounted(() => {
+  init()
+})
+
+</script>
 
 <style lang="scss" scoped>
 .home-content {
   padding: 24px;
 }
+
+.card-header {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.phStyle {
+  // display: flex;
+  // align-items: center;
+  // flex-direction: column;
+  .phStyle-left {
+    // width: 200px;
+    // text-align: right;
+  }
+  .progress {
+    flex: 1;
+  }
+}
+</style>
+
+<style scoped>
+.el-statistic {
+  --el-statistic-content-font-size: 28px;
+  text-align: center;
+}
+
+.statistic-card {
+  height: 100%;
+  padding: 20px;
+  border-radius: 4px;
+  background-color: var(--el-bg-color-overlay);
+}
+
+.statistic-footer {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  flex-wrap: wrap;
+  font-size: 12px;
+  color: var(--el-text-color-regular);
+  margin-top: 16px;
+}
+
+.statistic-footer .footer-item {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.statistic-footer .footer-item span:last-child {
+  display: inline-flex;
+  align-items: center;
+  margin-left: 4px;
+}
+
+.green {
+  color: var(--el-color-success);
+}
+
+.red {
+  color: var(--el-color-error);
+}
+.el-radio-group {
+  margin-bottom: 0px !important;
+}
 </style>

+ 1 - 5
src/views/staff/user/index.vue

@@ -24,7 +24,7 @@ const listPageData = reactive({
     tableColumn: [
         {
             label: '用户ID',
-            prop: 'roleId',
+            prop: 'userId',
              width: '180px'
         },
         {
@@ -58,10 +58,6 @@ const listPageData = reactive({
             type: 'input',
             isSearch: true
         },
-        {
-            label: '是否有疾病',
-            prop: 'isContagion',
-        },
         {
             label: '住址',
             prop: 'adress',

+ 1 - 1
vite.config.js

@@ -38,7 +38,7 @@ export default defineConfig(({ mode, command }) => {
         // https://cn.vitejs.dev/config/#server-proxy
         '/dev-api': {
           // target: 'http://localhost:9527',
-          target: 'http://192.168.100.133:9527',
+          target: 'http://192.168.100.121:9527',
           changeOrigin: true,
           rewrite: (p) => p.replace(/^\/dev-api/, '')
         },