Admin
2022-07-19 3e26b9d02f44b33d03b1a9cddcdaf5cadab13143
src/views/specialWorkSystem/workPlan/workAppointSummary/index.vue
@@ -1,13 +1,503 @@
<template>
    <div>作业预约汇总</div>
   <div class="home-container">
      <el-scrollbar height="100%">
      <el-row class="homeCard">
         <el-col :span="12">
            <div class="grid-content topInfo">
               <el-date-picker
                     v-model="searchTime"
                     type="datetime"
                     placeholder="预约时间"
                     size="large"
                     style="width: 100%;white-space: nowrap;margin-right: 20px"
               />
               <el-select v-model="typeValue" placeholder="请选择预约类型" style="width: 100%">
                  <el-option
                        v-for="item in reserveOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                  />
               </el-select>
               <el-button type="primary">查询历史</el-button>
               <el-button plain>重置</el-button>
               <el-button type="primary" @click="dialogChartsVisible = true">查看统计图表</el-button>
            </div>
         </el-col>
      </el-row>
      <div class="homeCard">
         <div class="main-card">
            <el-table :data="tableData" border style="width: 100%" :header-cell-style="{background: '#fafafa'}">
               <el-table-column prop="id" label="编号" width="180" />
               <el-table-column prop="time" label="预约时间" width="180" />
               <el-table-column prop="department" label="预约部门" />
               <el-table-column prop="dirtyWork" label="动土作业" width="180" />
               <el-table-column prop="fireWork" label="动火作业" width="180" />
               <el-table-column prop="hangWork" label="吊装作业" />
               <el-table-column prop="spaceWork" label="受限空间作业" width="180" />
               <el-table-column prop="cut" label="断路" width="180" />
               <el-table-column prop="high" label="高处" />
               <el-table-column prop="block" label="盲板抽堵" width="180" />
               <el-table-column prop="tempUse" label="临时用电" width="180" />
               <el-table-column fixed="right" label="操作" align="center" width="180">
                  <template #default>
                     <el-button link type="primary" size="small">操作</el-button>
                  </template>
               </el-table-column>
            </el-table>
         </div>
         <div class="pageBtn">
            <el-pagination
                  v-model:currentPage="currentPage"
                  v-model:page-size="pageSize"
                  :page-sizes="[10, 15]"
                  small=false
                  background
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="100"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
            />
         </div>
      </div>
      <el-dialog v-model="dialogChartsVisible" title="统计图表">
         <el-row>
            <div class="grid-content">
               <div style="margin-bottom: 10px">日期查询:</div>
               <div class="block">
                  <el-date-picker
                     v-model="dateRange"
                     type="daterange"
                     unlink-panels
                     range-separator="至"
                     start-placeholder="开始日期"
                     end-placeholder="截止日期"
                     :shortcuts="shortcuts"
                     size="large"
                  />
               </div>
            </div>
         </el-row>
         <el-row>
            <div class="grid-content">
               <div style="margin-bottom: 10px">部门查询:</div>
               <div>
                  <el-cascader
                        v-model="departmentName"
                        :options="departmentOptions"
                        :props="props"
                        @change="handleChange"
                  />
               </div>
            </div>
         </el-row>
         <div ref="myChart" style="width: 100%;height:400px;"></div>
      </el-dialog>
      </el-scrollbar>
   </div>
</template>
<script>
    export default {
        name: "index"
    }
<script lang="ts">
   import { toRefs, reactive, defineComponent, ref, onMounted } from 'vue';
   import { storeToRefs } from 'pinia';
   import { initBackEndControlRoutes } from '/@/router/backEnd';
   import {useUserInfo} from "/@/stores/userInfo";
   import { Session } from '/@/utils/storage';
   import * as echarts from 'echarts/core';
   import { TooltipComponent, TooltipComponentOption, GridComponent, GridComponentOption, LegendComponent, LegendComponentOption } from 'echarts/components';
   import { BarChart, BarSeriesOption } from 'echarts/charts';
   import { CanvasRenderer } from 'echarts/renderers';
   echarts.use([
      TooltipComponent,
      GridComponent,
      LegendComponent,
      BarChart,
      CanvasRenderer
   ]);
   let global: any = {
      homeChartOne: null,
      homeChartTwo: null,
      homeCharThree: null,
      dispose: [null, '', undefined],
   };
   interface stateType {
      homeOne: Array <type>
   }
   interface type {
      id:number,
      name: string
   }
   export default defineComponent({
      name: 'home',
      setup() {
         const userInfo = useUserInfo()
         const { userInfos } = storeToRefs(userInfo);
         const searchTime = ref('');
         const typeValue = ref('');
         const departmentName = ref('');
         const reserveOptions = [
            {
               value: 'Option1',
               label: 'Option1',
            },
            {
               value: 'Option2',
               label: 'Option2',
            },
            {
               value: 'Option3',
               label: 'Option3',
            },
            {
               value: 'Option4',
               label: 'Option4',
            },
            {
               value: 'Option5',
               label: 'Option5',
            },
         ];
         const tableData = [
            {
               id: '10801920',
               time: '2022-06-29',
               department: '电工部',
               dirtyWork: '',
               fireWork: '',
               hangWork: '',
               spaceWork: '',
               cut: '',
               high: '',
               block: '',
               tempUse: ''
            },
            {
               id: '10801920',
               time: '2022-06-29',
               department: '电工部',
               dirtyWork: '',
               fireWork: '',
               hangWork: '',
               spaceWork: '',
               cut: '',
               high: '',
               block: '',
               tempUse: ''
            },
            {
               id: '10801920',
               time: '2022-06-29',
               department: '',
               dirtyWork: '',
               fireWork: '',
               hangWork: '',
               spaceWork: '',
               cut: '',
               high: '',
               block: '',
               tempUse: ''
            }
         ];
         const dialogChartsVisible = ref(false);
         const dateRange = ref('')
         const shortcuts = [
            {
               text: '上一周',
               value: () => {
                  const end = new Date()
                  const start = new Date()
                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
                  return [start, end]
               },
            },
            {
               text: '前一个月',
               value: () => {
                  const end = new Date()
                  const start = new Date()
                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
                  return [start, end]
               },
            },
            {
               text: '前三个月',
               value: () => {
                  const end = new Date()
                  const start = new Date()
                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
                  return [start, end]
               },
            },
         ];
         const props = {
            expandTrigger: 'hover',
         };
         const departmentOptions = [
            {
               value: 'guide',
               label: 'Guide',
               children: [
                  {
                     value: 'disciplines',
                     label: 'Disciplines',
                     children: [
                        {
                           value: 'consistency',
                           label: 'Consistency',
                        },
                        {
                           value: 'feedback',
                           label: 'Feedback',
                        }
                     ],
                  },
                  {
                     value: 'navigation',
                     label: 'Navigation',
                     children: [
                        {
                           value: 'side nav',
                           label: 'Side Navigation',
                        },
                        {
                           value: 'top nav',
                           label: 'Top Navigation',
                        },
                     ],
                  },
               ],
            },
            {
               value: 'component',
               label: 'Component',
            },
            {
               value: 'resource',
               label: 'Resource',
               children: [
                  {
                     value: 'axure',
                     label: 'Axure Components',
                  },
                  {
                     value: 'sketch',
                     label: 'Sketch Templates',
                  },
                  {
                     value: 'docs',
                     label: 'Design Documentation',
                  },
               ],
            },
         ];
         const handleChange = (value) => {
            console.log(value)
         };
         const state  = reactive<stateType>({
            homeOne:[{id:1,name:'基础数据权限管理系统'},{id:2,name:'双重预防系统'},{id:3,name:'系统2'},{id:4,name:'系统3'},{id:5,name:'系统4'}],
         });
         const myChart = ref<HTMLElement>()
         const myCharts = ref<any>()
         setTimeout(()=>{
            type EChartsOption = echarts.ComposeOption<
                  | TooltipComponentOption
                  | GridComponentOption
                  | LegendComponentOption
                  | BarSeriesOption
                  >;
            myCharts.value = echarts.init(myChart.value!);
            const option: EChartsOption = {
               tooltip: {
                  trigger: 'axis',
                  axisPointer: {
                     // Use axis to trigger tooltip
                     type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
                  }
               },
               legend: {},
               grid: {
                  left: '3%',
                  right: '3%',
                  bottom: '3%',
                  containLabel: true
               },
               xAxis: {
                  type: 'value'
               },
               yAxis: {
                  type: 'category',
                  data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
               },
               series: [
                  {
                     name: 'Direct',
                     type: 'bar',
                     stack: 'total',
                     label: {
                        show: true
                     },
                     emphasis: {
                        focus: 'series'
                     },
                     data: [320, 302, 301, 334, 390, 330, 320]
                  },
                  {
                     name: 'Mail Ad',
                     type: 'bar',
                     stack: 'total',
                     label: {
                        show: true
                     },
                     emphasis: {
                        focus: 'series'
                     },
                     data: [120, 132, 101, 134, 90, 230, 210]
                  },
                  {
                     name: 'Affiliate Ad',
                     type: 'bar',
                     stack: 'total',
                     label: {
                        show: true
                     },
                     emphasis: {
                        focus: 'series'
                     },
                     data: [220, 182, 191, 234, 290, 330, 310]
                  },
                  {
                     name: 'Video Ad',
                     type: 'bar',
                     stack: 'total',
                     label: {
                        show: true
                     },
                     emphasis: {
                        focus: 'series'
                     },
                     data: [150, 212, 201, 154, 190, 330, 410]
                  },
                  {
                     name: 'Search Engine',
                     type: 'bar',
                     stack: 'total',
                     label: {
                        show: true
                     },
                     emphasis: {
                        focus: 'series'
                     },
                     data: [820, 832, 901, 934, 1290, 1330, 1320]
                  }
               ]
            };
            option && myCharts.value.setOption(option);
         },2000)
         // 分布图
         // onMounted(()=>{
         //    setTimeout(() => {
         //       drawChart()
         //    },1000)
         // });
         // 折线图
         const renderMenu = async (value: string) => {
            Session.set('projectId',value)
            userInfos.value.projectId = value
            await initBackEndControlRoutes();
         };
         return {
            renderMenu,
            searchTime,
            typeValue,
            reserveOptions,
            tableData,
            dialogChartsVisible,
            dateRange,
            shortcuts,
            departmentName,
            departmentOptions,
            props,
            myChart,
            handleChange,
            ...toRefs(state),
         };
      },
   });
</script>
<style scoped>
<style scoped lang="scss">
   $homeNavLengh: 8;
   .home-container {
      height: 100%;
      overflow: hidden;
      padding: 20px;
      .homeCard{
         width: 100%;
         padding: 20px;
         background: #fff;
         border-radius: 4px;
      }
      .el-row{
         display: flex;
         align-items: center;
         margin-bottom: 20px;
         &:last-child {
            margin-bottom: 0;
         }
         .grid-content{
            align-items: center;
            min-height: 36px;
         }
         .topInfo {
            display: flex;
            align-items: center;
            font-size: 16px;
            font-weight: bold;
            &>div{
               white-space: nowrap;
               margin-right: 20px;
            }
         }
      }
      .main-card{
         width: 100%;
         .cardTop{
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
            .mainCardBtn{
               margin: 0;
            }
         }
      }
      .pageBtn{
         display: flex;
         align-items: center;
         justify-content: right;
         margin-top: 20px;
         .demo-pagination-block + .demo-pagination-block {
            margin-top: 10px;
         }
         .demo-pagination-block .demonstration {
            margin-bottom: 16px;
         }
      }
   }
   .el-input{
      width: 100% !important;
   }
   .el-date-editor::v-deep{
      width: 100%;
   }
   .el-select{
      width: 100%;
   }
</style>