<template>
  <el-card class="hl-card" style="min-height: 80vh; position: relative">
    <template #header>
      <span>首页</span>
    </template>

    <div>
      <el-card shadow="never">
        <el-skeleton :loading="loading" animated>
          <el-row :gutter="20" justify="space-between">
            <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
              <div class="flex items-center">
                <img :src="avatar" alt="" class="mr-20px h-70px w-70px rounded-[50%]" />
                <div>
                  <div class="text-20px">
                    {{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
                  </div>
                  <!--                <div class="mt-10px text-14px text-gray-500">
                  {{ t('workplace.toady') }}，20℃ - 32℃！
                </div>-->
                </div>
              </div>
            </el-col>
            <!-- 我的待办列表 -->
            <el-col>
              <div style="border: 1px solid #dcdfe6; padding: 20px; margin: 10px;">
                <div style="color: #70aa3b;text-align: center;">我的待办</div>
                <div style="padding: 15px;">
                  <ContentWrap>
                    <el-table v-loading="loading" border :data="daibanlist">
                      <el-table-column label="序号" align="center" width="80px" type="index" />
                      <el-table-column label="级别" align="center" prop="jibie" width="80" />
					  <el-table-column label="待办名称" align="center" prop="type" width="auto" />
                      <el-table-column label="待办事项" align="center" prop="dbsx" width="auto" />
                      <el-table-column label="事项生成时间" align="center" prop="sctime" width="200" />
                      <el-table-column label="操作" align="center" width="80">
                     <template #default="scope">
                      <el-button
                           link
                           type="danger"
                           @click="handlePay(scope.row)"
                           v-if="isButtonTypeInList(scope.row.type) && scope.row.yesorno === '0'">
                           查看
                         </el-button>
                         <el-button
                           link
                           disabled
                           type="success"
                           @click="handlePay(scope.row)"
                           v-else-if="isButtonTypeInList(scope.row.type) && scope.row.yesorno === '1'">
                           已阅
                         </el-button>
                         <el-button
                           link
                           type="danger"
                           @click="handlePay(scope.row)"
                           v-else-if="!isButtonTypeInList(scope.row.type) && scope.row.yesorno === '0'">
                           处理
                         </el-button>
                         <el-button
                           link disabled
                           type="success"
                           @click="handlePay(scope.row)"
                           v-else-if="!isButtonTypeInList(scope.row.type) && scope.row.yesorno === '1'">
                           处理中
                         </el-button>
                     </template>
                      </el-table-column>
                    </el-table>
                  </ContentWrap>
                </div>

              </div>
            </el-col>
            <!-- 重点关注列表 -->
            <el-col>
              <div style="border: 1px solid #dcdfe6; padding: 10px; margin: 10px;">
                <div style="color: #ff0000;text-align: center;">重点关注</div>
                <div style="padding: 15px;">
                  <ContentWrap>
                    <el-table v-loading="loading" border :data="zhongdianlist">
                      <el-table-column label="序号" align="center" width="80px" type="index" />
                      <el-table-column label="级别" align="center" prop="jibie" width="80" />
					  <el-table-column label="待办名称" align="center" prop="type" width="auto" />
                      <el-table-column label="待办事项" align="center" prop="dbsx" width="auto" />
                      <el-table-column label="事项生成时间" align="center" prop="sctime" width="200" />
                      <!-- <el-table-column label="负责人" align="center" prop="fuzeren" width="120" /> -->
                      <el-table-column label="操作" align="center" width="80">
                        <template #default="scope">
                       <el-button
                         link
                         type="danger"
                         @click="handlePaysee(scope.row)"
                         v-if="scope.row.yesorno === '0'">
                         查看
                       </el-button>

                       <el-button
                         link disabled
                         type="success"
                         @click="handlePaysee(scope.row)"
                         v-else-if="scope.row.yesorno === '1'">
                         已阅
                       </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </ContentWrap>

                </div>

              </div>
            </el-col>


            <!--          <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
            <div class="h-70px flex items-center justify-end lt-sm:mt-10px">
              <div class="px-8px text-right">
                <div class="mb-20px text-14px text-gray-400">{{ t('workplace.project') }}</div>
                <CountTo
                  class="text-20px"
                  :start-val="0"
                  :end-val="totalSate.project"
                  :duration="2600"
                />
              </div>
              <el-divider direction="vertical" />
              <div class="px-8px text-right">
                <div class="mb-20px text-14px text-gray-400">{{ t('workplace.toDo') }}</div>
                <CountTo
                  class="text-20px"
                  :start-val="0"
                  :end-val="totalSate.todo"
                  :duration="2600"
                />
              </div>
              <el-divider direction="vertical" border-style="dashed" />
              <div class="px-8px text-right">
                <div class="mb-20px text-14px text-gray-400">{{ t('workplace.access') }}</div>
                <CountTo
                  class="text-20px"
                  :start-val="0"
                  :end-val="totalSate.access"
                  :duration="2600"
                />
              </div>
            </div>
          </el-col>-->
          </el-row>
        </el-skeleton>
      </el-card>

     <el-dialog title="提示" v-model="showDialog" width="30%" center>
        <span>该物料需求计划是否正常？</span>
        <template #footer>
          <el-button @click="showDialog = false">异 常</el-button>
          <el-button type="primary" @click="suerMaterialNeed()">正 常</el-button>
        </template>
      </el-dialog>
    </div>

    <!--  <el-row class="mt-5px" :gutter="20" justify="space-between">
    <el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-10px">
      <el-card shadow="never">
        <template #header>
          <div class="h-3 flex justify-between">
            <span>{{ t('workplace.project') }}</span>
            <el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
          </div>
        </template>
        <el-skeleton :loading="loading" animated>
          <el-row>
            <el-col
              v-for="(item, index) in projects"
              :key="`card-${index}`"
              :xl="8"
              :lg="8"
              :md="8"
              :sm="24"
              :xs="24"
            >
              <el-card shadow="hover">
                <div class="flex items-center">
                  <Icon :icon="item.icon" :size="25" class="mr-10px" />
                  <span class="text-16px">{{ item.name }}</span>
                </div>
                <div class="mt-15px text-14px text-gray-400">{{ t(item.message) }}</div>
                <div class="mt-20px flex justify-between text-12px text-gray-400">
                  <span>{{ item.personal }}</span>
                  <span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-skeleton>
      </el-card>

      <el-card shadow="never" class="mt-5px">
        <el-skeleton :loading="loading" animated>
          <el-row :gutter="20" justify="space-between">
            <el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
              <el-card shadow="hover" class="mb-10px">
                <el-skeleton :loading="loading" animated>
                  <Echart :options="pieOptionsData" :height="280" />
                </el-skeleton>
              </el-card>
            </el-col>
            <el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
              <el-card shadow="hover" class="mb-10px">
                <el-skeleton :loading="loading" animated>
                  <Echart :options="barOptionsData" :height="280" />
                </el-skeleton>
              </el-card>
            </el-col>
          </el-row>
        </el-skeleton>
      </el-card>
    </el-col>
    <el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-10px">
      <el-card shadow="never">
        <template #header>
          <div class="h-3 flex justify-between">
            <span>{{ t('workplace.shortcutOperation') }}</span>
          </div>
        </template>
        <el-skeleton :loading="loading" animated>
          <el-row>
            <el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-10px">
              <div class="flex items-center">
                <Icon :icon="item.icon" class="mr-10px" />
                <el-link type="default" :underline="false" @click="setWatermark(item.name)">
                  {{ item.name }}
                </el-link>
              </div>
            </el-col>
          </el-row>
        </el-skeleton>
      </el-card>
      <el-card shadow="never" class="mt-10px">
        <template #header>
          <div class="h-3 flex justify-between">
            <span>{{ t('workplace.notice') }}</span>
            <el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
          </div>
        </template>
        <el-skeleton :loading="loading" animated>
          <div v-for="(item, index) in notice" :key="`dynamics-${index}`">
            <div class="flex items-center">
              <img :src="avatar" alt="" class="mr-20px h-35px w-35px rounded-[50%]" />
              <div>
                <div class="text-14px">
                  <Highlight :keys="item.keys.map((v) => t(v))">
                    {{ item.type }} : {{ item.title }}
                  </Highlight>
                </div>
                <div class="mt-15px text-12px text-gray-400">
                  {{ formatTime(item.date, 'yyyy-MM-dd') }}
                </div>
              </div>
            </div>
            <el-divider />
          </div>
        </el-skeleton>
      </el-card>
    </el-col>
  </el-row>-->
  </el-card>

</template>
<script lang="ts" setup>
import { set } from 'lodash-es'
import { EChartsOption, format } from 'echarts'
import { formatTime } from '@/utils'
import { ElNotification } from 'element-plus'
import { useUserStore } from '@/store/modules/user'
import { useWatermark } from '@/hooks/web/useWatermark'
import avatarImg from '@/assets/imgs/smile.png'
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
import { pieOptions, barOptions } from './echarts-data'
import { useCommonStore } from '@/store/modules/common'
//all
import * as bdgzsomthingApi from '@/api/heli/bdgzsomthing'
//
import * as PurchaseOrderApi from '@/api/heli/purchaseorder'
//订单审核
import * as ProjectOrderApi from '@/api/heli/projectorder'
//bom审核
import * as ProcessBomApi from '@/api/heli/processbom'
import * as StorageLogApi from '@/api/heli/storagelog'
import { buttonTypes, includesButtonType } from './constants.js';

import * as UserApi from '@/api/system/user'
import { any } from 'vue-types'
defineOptions({ name: 'Home' })
const commonStore = useCommonStore()
const router = useRouter()
const { t } = useI18n()
const message = useMessage() // 消息弹窗
const userStore = useUserStore()
const { setWatermark } = useWatermark()
const loading = ref(true)
const fieldOptionModelVisible = ref(false)
const avatar = userStore.getUser.avatar ? userStore.getUser.avatar : avatarImg
const username = userStore.getUser.nickname
const userid = userStore.getUser.id//nickname
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
const userDept = ref()
// 获取统计数
let totalSate = reactive<WorkplaceTotal>({
  project: 0,
  access: 0,
  todo: 0
})
//按钮的类型
const buttonTypes = ref([
  '库存低于安全库存',
  '订单发货满一年',
  '设计任务到期',
  '装配任务到期',
  '生产任务到期',
  '质检任务到期前',
  '《物料需求计划》的采购',
  '《物料需求计划》提交后',
  'BOM变更通知'

]);
const showDialog = ref(false);
// 计算属性来判断类型是否在 buttonTypes 中
const isButtonTypeInList = (type) => {
  if(type == '《物料需求计划》的采购'){

  }else{
    return buttonTypes.value.includes(type);
  }
};

// const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const daibanlist = ref([]) // 列表的数据
const zhongdianlist = ref([]) // 列表的数据
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  code: '',
  name: '',
  status: undefined
})
//采购订单审核
const queryParams1 = reactive({
  pageNo: 1,
  pageSize: 100,
  id: undefined,
  purchaseNo: undefined,
  supplierId: undefined,
  contractNo: undefined,
  purchaseType: undefined,
  projectMaterialPlanId: undefined,
  goodsType: undefined,
  currencyType: undefined,
  taxRatio: undefined,
  estimatedPrice: undefined,
  actualPrice: undefined,
  status: 2,
  submitUserId: undefined,
  submitTime: [],
  auditor: undefined,
  auditTime: [],
  description: undefined,
  creator: undefined,
  createTime: [],
})

//订单审核
const queryParams2 = reactive({
  pageNo: 1,
  pageSize: 10,
  code: undefined,
  orderStatus: 8,
  orderStatusList: [8, 16, 32, 64],
  deliveryStatus: undefined,
  businessDeptId: undefined,
  customerName: undefined,
  projectName: undefined,
  businessLine: undefined,
  blueprintNo: undefined,
  hasPrice: undefined,
  price: undefined,
  currency: undefined,
  projectStartTime: [],
  projectEndTime: [],
  isUrgency: undefined,
  property: undefined,
  referenceTechnology: undefined,
  hasAlter: undefined,
  lastAlterTime: [],
  qualityRequirement: undefined,
  remark: undefined,
  hasContract: undefined,
  hasTechnologyProtocol: undefined,
  hasBlueprint: undefined,
  blueprintRemark: undefined,
  status: undefined,
  createTime: [],
  businessManName: undefined,
  isSnapshot: 0,
  snapshotId: undefined,
  snapshotCode: undefined,
  orderTime: [],
  snapshotOrderTime: []
})

// bom审核
const queryParams3 = reactive({
  pageNo: 1,
  pageSize: 10,
  code: undefined,
  planCode: undefined,
  projectCode: undefined,
  customerName: undefined,
  projectName: undefined,
  projectSubName: undefined,
  version: undefined,
  bomStatus: undefined,
  remark: undefined,
  status: undefined,
  createTime: [],
  userId:userid
})
//库存低于安全库存
const queryParams4 = reactive({
  pageNo: 1,
  pageSize: 100,
  matCode: undefined,
  matName: undefined,
  matType: undefined,
  lotNo: undefined,
  whId: undefined,
  rgId:undefined,
  pnId: undefined,
  headerNo: undefined,
})

//all
const queryParamsall = reactive({
  pageNo: 1,
  pageSize: 10,
  createTime: [],
  click: undefined,
  clickid: undefined,
  thingname: undefined,
  things: undefined,
  level: undefined,
  showname: undefined,
  showname: [],
  dborgz: undefined,
  yesorno: undefined,
  attr1: undefined,
  attr2: undefined,
  attr3: undefined,
  attr4: undefined,
  attr5: undefined,
  clicktime: [],
  nowtime: [],
  attr6: undefined,
  attr6: [],
  attr7: undefined,
  attr7: [],
  attr8: undefined,
  attr8: [],
  attr9: undefined,
  attr10: undefined,
  attr10: [],
  attr11: undefined,
  attr12: undefined,
  attr13: undefined,
  attr14: undefined,
  attr15: undefined,
})
const queryParamsallin = reactive({
  pageNo: 1,
  pageSize: 100,
  createTime: [],
  click: undefined,
  clickid: undefined,
  thingname: undefined,
  things: undefined,
  level: undefined,
  showname: undefined,
  showname: [],
  dborgz: undefined,
  yesorno: undefined,
  attr1: undefined,
  attr2: undefined,
  attr3: undefined,
  attr4: undefined,
  attr5: undefined,
  clicktime: [],
  nowtime: [],
  attr6: undefined,
  attr6: [],
  attr7: undefined,
  attr7: [],
  attr8: undefined,
  attr8: [],
  attr9: undefined,
  attr10: undefined,
  attr10: [],
  attr11: undefined,
  attr12: undefined,
  attr13: undefined,
  attr14: undefined,
  attr15: undefined,
})
/** 待办查询列表 */
const getList = async () => {
  loading.value = true
  try {
	  const abc=username
	  queryParamsallin.click=username
	  const data = await bdgzsomthingApi.getbdgzsomthingPage(queryParamsallin)

	  //定时任务查询

	  // //采购订单审核
	  // const data1 = await PurchaseOrderApi.getPurchaseOrderPageByStatus(queryParams1)
	  // //订单审核
	  // const data2 = await ProjectOrderApi.getProjectOrderPage(queryParams2)
	  //bom审核

	  // const data3 = await ProcessBomApi.getProcessBomPages(queryParams3)
	  //库存低于安全库存
	  // const data4 = await StorageLogApi.getStorageNowPagesmall(queryParams4)
	  //订单发货满一年
	  // const data5 = await DeliverOrderApi.getDeliverOrderPagemyn()

  const tableData = [];
  const tableData1 = [];

  data.forEach(item => {

    const newItem = {
		id:item.id,
      idid: item.attr2,
      type: item.thingname,
	  things:item.things,
      jibie: item.level,
      dbsx: '',
	  yesorno:item.yesorno,
      sctime: formatTime(item.createTime, 'yyyy-MM-dd HH:mm:ss')
    };

    switch (item.thingname) {
      case '订单有价格':
        newItem.dbsx = `${item.things} `;
        break;
      case '库存低于安全库存':
        newItem.dbsx = `${item.things} `;
        break;
      case '订单发货满一年':
        newItem.dbsx = `${item.things} `;
        break;
      case '设计任务到期':
        newItem.dbsx = `${item.things} `;
        break;
      case '装配任务到期':
        newItem.dbsx = `${item.things} `;
        break;
      case '生产任务到期':
        newItem.dbsx = `${item.things} `;
        break;
      case '质检任务到期前':
        newItem.dbsx = `${item.things} `;
        break;
      case '《物料需求计划》提交后':
        newItem.dbsx = `${item.things} `;
        break;
      case '《物料需求计划》的采购':
        newItem.dbsx = `${item.things} `;
        break;
      case '《采购订单》到货时通知检验':
        newItem.dbsx = `${item.things} `;
        break;
      case '《采购订单》检验合格后通知仓库进行入库操作':
        newItem.dbsx = `${item.things} `;
        break;
      case 'BOM变更审核':
        newItem.dbsx = `${item.things} `;
        break;
      case 'BOM变更审核通过后':
        newItem.dbsx = `${item.things} `;
        break;
		case 'BOM变更通知':
		  newItem.dbsx = `${item.things} `;
		  break;
      case '质检通知单':
        newItem.dbsx = `${item.things} `;
        break;
      // default:
      //   newItem = {}; // 如果thingname不匹配任何已知情况，则不创建新项
    }

    // 根据 item.dborgz 的值决定将 newItem 添加到哪个数组
    if (item.dborgz === '待办' && newItem) {
      tableData.push(newItem);
    } else if (newItem) {
      tableData1.push(newItem);
    }
  });
// data2.list.forEach(item => {
//   const newItem = {
// 	  idid:item.code,
// 	type:'订单审核',
//     jibie: '紧急', // 这里可以根据实际情况设置紧急程度
//     dbsx: `<订单审核>单据续号${item.code} 需要您处理`,
//     sctime: formatTime(item.createTime,'yyyy-MM-dd HH:mm:ss')
//   };
//   tableData.push(newItem);
// });


    daibanlist.value = tableData;
    // total.value = tableData.length;
	zhongdianlist.value = tableData1;
	// total.value = tableData.length;

  } finally {
    loading.value = false
  }
}



/** 关注查询列表 */
const getList1 = async () => {
  loading.value = true
  try {
    const tableData = [
    ];

    zhongdianlist.value = tableData;
    total.value = tableData.length;
  } finally {
    loading.value = false
  }
}
const materialNeedRow = ref(any)
const suerMaterialNeed = async() =>{
  await bdgzsomthingApi.deletebdgzsByThings(materialNeedRow.value.things);
  showDialog.value = false;
  ElNotification({
    title: '提示',
    message: materialNeedRow.value.things+'处理成功！',
    duration: 0,
  })
  getList()
}
/** 支付按钮操作 */
const handlePay =async (row: any) => {
	if (row.type == '订单有价格') {
	    router.push({ path: '/order/project', query: { idid: row.idid } });
      await bdgzsomthingApi.deleteByIdNew(row.id);
		// router.push({ path: '/order/project', state: { idid: row.idid } });
	}
	if (row.type == '《物料需求计划》提交后') {
    await bdgzsomthingApi.deleteByIdNew(row.id);
		router.push({ path: '/purchase/MaterialPlanAudit', state: { idid: row.idid } });
	    // router.push({ path: '/purchase/MaterialPlanAudit', query: { idid: row.idid } });
	}
	if (row.type == 'BOM变更审核') {
		// router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
	    router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
    await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
	}
	if (row.type == 'BOM变更通知') {
		// router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
	    router.push({ path: '/processDesign/heli/processdesign/bom', state: { idid: row.idid } });
		await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
	}
	if (row.type == 'BOM变更审核通过后') {
		// router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
	    router.push({ path: '/plan/PlanTasks', state: { idid: row.idid } });
	}
	if (row.type == '质检通知单') {
		// router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
	    router.push({ path: '/quality/unqualifiedNotificationApprove', state: { idid: row.idid } });
    await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
	}
	// &lt;
if (row.type == '设计任务到期'){
  await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
}
  if (row.type == '装配任务到期'){
    await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
  }
  if (row.type == '生产任务到期'){
    await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
  }
	if (row.type == '订单发货满一年') {
		// router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
	    router.push({ path: '/order/project', query: { idid: row.idid } });
	}
  if(row.type == '《物料需求计划》的采购'){
      showDialog.value = true;
      materialNeedRow.value = row;

  }
  if(row.type == '库存低于安全库存' || row.type == '订单发货满一年'){
    await bdgzsomthingApi.deleteByIdNew1(row.id);
  }
	// 库存低于安全库存
	if (row.type == '库存低于安全库存'
	||row.type == '《采购订单》到货时通知检验'
	||row.type == '设计任务到期'
	||row.type == '装配任务到期'
	||row.type == '生产任务到期'
	||row.type == '质检任务到期前'
    ||row.type == '《物料需求计划》提交后'
	// ||(row.type == '《物料需求计划》的采购'&&userDept.value.deptName != '采购部')

	) {
	    // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', query: { idid: row.idid } });
		await bdgzsomthingApi.updatebdgzsomthingbyidone(row.id)
		ElMessage({
		       message: '已阅',
		       type: 'success',
		     });
				getList()
	}

	// if(row.type == 'BOM变更通知'){
	//
	// }


}
/** 支付按钮操作 */
const handlePaysee =async (row: any) => {
  if(row.type == '库存低于安全库存' || row.type == '订单发货满一年'){
    await bdgzsomthingApi.deleteByIdNew1(row.id);
  }else{
      if (row.type == '订单有价格') {
        router.push({ path: '/order/project', query: { idid: row.idid } });
        await bdgzsomthingApi.deleteByIdNew(row.id);
      // router.push({ path: '/order/project', state: { idid: row.idid } });
      }else{
        await bdgzsomthingApi.updatebdgzsomthingbyidone(row.id)
      }
    if (row.type == 'BOM变更通知') {
      // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
      router.push({ path: '/processDesign/heli/processdesign/bom', state: { idid: row.idid } });
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
    if (row.type == '设计任务到期'){
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
    if (row.type == '质检通知单') {
      // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
      router.push({ path: '/quality/unqualifiedNotificationApprove', state: { idid: row.idid } });
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
    if (row.type == 'BOM变更审核') {
      // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
      // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', state: { idid: row.idid } });
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
    if (row.type == '装配任务到期'){
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
    if (row.type == '生产任务到期'){
      await bdgzsomthingApi.updatebdgzsomthingbyidoneandok(row.id)  //直接修改取消显示
    }
  }

	// 库存低于安全库存
	    // router.push({ path: '/processDesign/heli/processdesign/bomShenhe', query: { idid: row.idid } });
	   ElMessage({
	          message: '已阅',
	          type: 'success',
	        });
		getList()
}


const getCount = async () => {
  const data = {
    project: 40,
    access: 2340,
    todo: 10
  }
  totalSate = Object.assign(totalSate, data)
}

// 获取项目数
let projects = reactive<Project[]>([])
const getProject = async () => {
  const data = [
    {
      name: 'Github',
      icon: 'akar-icons:github-fill',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    },
    {
      name: 'Vue',
      icon: 'logos:vue',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    },
    {
      name: 'Angular',
      icon: 'logos:angular-icon',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    },
    {
      name: 'React',
      icon: 'logos:react',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    },
    {
      name: 'Webpack',
      icon: 'logos:webpack',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    },
    {
      name: 'Vite',
      icon: 'vscode-icons:file-type-vite',
      message: 'workplace.introduction',
      personal: 'Archer',
      time: new Date()
    }
  ]
  projects = Object.assign(projects, data)
}

// 获取通知公告
let notice = reactive<Notice[]>([])
const getNotice = async () => {
  const data = [
    {
      title: '系统升级版本',
      type: '通知',
      keys: ['通知', '升级'],
      date: new Date()
    },
    {
      title: '系统凌晨维护',
      type: '公告',
      keys: ['公告', '维护'],
      date: new Date()
    },
    {
      title: '系统升级版本',
      type: '通知',
      keys: ['通知', '升级'],
      date: new Date()
    },
    {
      title: '系统凌晨维护',
      type: '公告',
      keys: ['公告', '维护'],
      date: new Date()
    }
  ]
  notice = Object.assign(notice, data)
}

// 获取快捷入口
let shortcut = reactive<Shortcut[]>([])

const getShortcut = async () => {
  const data = [
    {
      name: 'Github',
      icon: 'akar-icons:github-fill',
      url: 'github.io'
    },
    {
      name: 'Vue',
      icon: 'logos:vue',
      url: 'vuejs.org'
    },
    {
      name: 'Vite',
      icon: 'vscode-icons:file-type-vite',
      url: 'https://vitejs.dev/'
    },
    {
      name: 'Angular',
      icon: 'logos:angular-icon',
      url: 'github.io'
    },
    {
      name: 'React',
      icon: 'logos:react',
      url: 'github.io'
    },
    {
      name: 'Webpack',
      icon: 'logos:webpack',
      url: 'github.io'
    }
  ]
  shortcut = Object.assign(shortcut, data)
}

// 用户来源
const getUserAccessSource = async () => {
  const data = [
    { value: 335, name: 'analysis.directAccess' },
    { value: 310, name: 'analysis.mailMarketing' },
    { value: 234, name: 'analysis.allianceAdvertising' },
    { value: 135, name: 'analysis.videoAdvertising' },
    { value: 1548, name: 'analysis.searchEngines' }
  ]
  set(
    pieOptionsData,
    'legend.data',
    data.map((v) => t(v.name))
  )
  pieOptionsData!.series![0].data = data.map((v) => {
    return {
      name: t(v.name),
      value: v.value
    }
  })
}
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption

// 周活跃量
const getWeeklyUserActivity = async () => {
  const data = [
    { value: 13253, name: 'analysis.monday' },
    { value: 34235, name: 'analysis.tuesday' },
    { value: 26321, name: 'analysis.wednesday' },
    { value: 12340, name: 'analysis.thursday' },
    { value: 24643, name: 'analysis.friday' },
    { value: 1322, name: 'analysis.saturday' },
    { value: 1324, name: 'analysis.sunday' }
  ]
  set(
    barOptionsData,
    'xAxis.data',
    data.map((v) => t(v.name))
  )
  set(barOptionsData, 'series', [
    {
      name: t('analysis.activeQuantity'),
      data: data.map((v) => v.value),
      type: 'bar'
    }
  ])
}

const getAllApi = async () => {
  await Promise.all([
    getCount(),
    getProject(),
    getNotice(),
    getShortcut(),
    getUserAccessSource(),
    getWeeklyUserActivity()
  ])
  loading.value = false
}

const getUserInfo = async () => {
  userDept.value = await UserApi.getUser(userid);
  console.log(userDept.value)
}

getAllApi()

const openwarn = () => {
  ElNotification({
    title: `设计预警通知`,
    message: `铸造工艺设计负责人: <span class="bordercolor">${`薛小宝`} </span>请注意!<br/>
    项目编号【<span class="bordercolor">${`2546845`} </span>】的图纸设计即将超时，请及时完成。`,
    type: 'warning',
    offset: 100,
    dangerouslyUseHTMLString: true,
    duration: 0,
    customClass: 'my-notification'
  })
}

onMounted(() => {
  getUserInfo();
  // openwarn()
  getList()
  getList1()
})
</script>
<style lang="scss">
.my-notification {
  width: 380px;

  .el-notification__group {
    .el-notification__content {
      .bordercolor {
        color: #409eff;
      }
    }
  }
}
</style>
