<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="130px"
    >
      <el-form-item label="项目编号" prop="projectCode">
        <el-input
          v-model="queryParams.projectCode"
          placeholder="请输入项目编号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
      <el-form-item label="项目名称" prop="projectName">
        <el-input
          v-model="queryParams.projectName"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
      <el-form-item label="生产计划号" prop="taskNo">
        <el-input
          v-model="queryParams.taskNo"
          placeholder="请输入生产计划号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
	  <el-form-item label="子项目名称" prop="projectSubName">
	    <el-input
	      v-model="queryParams.projectSubName"
	      placeholder="请输入子项目名称"
	      clearable
	      @keyup.enter="handleQuery"
	      class="!w-240px"
	    />
	  </el-form-item>
	  <el-form-item label="零件名称" prop="materialName">
	    <el-input
	      v-model="queryParams.materialName"
	      placeholder="请输入零件名称"
	      clearable
	      @keyup.enter="handleQuery"
	      class="!w-240px"
	    />
	  </el-form-item>
	  <el-form-item label="任务负责人" prop="owner">
	    <!-- <el-input
	      v-model="queryParams.owner"
	      placeholder="请输入零件名称"
	      clearable
	      @keyup.enter="handleQuery"
	      class="!w-240px"
	    /> -->
                                      <el-select  class="!w-240px"  v-model="queryParams.owner"  filterable  placeholder="请选择任务责任人" >
                                  <el-option v-for="item in userList" :key="item.id" :label="item.username + ' ' + item.nickname" :value="item.id" />
                                </el-select>

	  </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>

<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          @click="handleExport"-->
<!--          :loading="exportLoading"-->
<!--          v-hasPermi="['heli:shenhe:export']"-->
<!--        >-->
<!--          <Icon icon="ep:download" class="mr-5px" /> 导出-->
<!--        </el-button>-->
      </el-form-item>
    </el-form>
  </ContentWrap>

  <!-- 列表 -->
  <ContentWrap>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
    <el-tab-pane label="加工件" name="first">{{  }}</el-tab-pane>
    <el-tab-pane label="标准件" name="second">{{  }}</el-tab-pane>
    </el-tabs>
    <el-table style="height: 500px;" v-loading="loading" :data="list"  :show-overflow-tooltip="true" border class="hl-table"  :cell-class-name="cellClassName">
		  <el-table-column type="index" min-width="60"  label="序号" align="center" />
	  <el-table-column label="零件名称" align="center" prop="materialName" min-width="180"/>
                  <el-table-column label="材质" prop="compositionName" min-width="180"/>
                  <el-table-column label="规格型号" prop="spec" min-width="180"/>
 <el-table-column label="数量" prop="boomAmount" min-width="145"/>
<el-table-column v-if="activeIndex == 'first'" label="下料" min-width="145">
  <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '下料'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span class="left" v-if="!item.reportTime">{{ item.sort }}</span>
          <span class="right">
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行 -->
        <div class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
          <span class="right">
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
          </span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
        <el-table-column v-if="activeIndex == 'first'"  label="电焊"  min-width="145">
          <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '电焊'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
         <el-table-column v-if="activeIndex == 'first'"  label="编程"  min-width="145">
          <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '编程'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
          <el-table-column v-if="activeIndex == 'first'"  label="开粗"  min-width="145">
            <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '开粗'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
           <el-table-column v-if="activeIndex == 'first'"  label="铣床"  min-width="145">
            <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '铣床'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
            <el-table-column v-if="activeIndex == 'first'"  label="车床"  min-width="145">
              <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '车床'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
             <el-table-column v-if="activeIndex == 'first'"  label="热处理"  min-width="145">
              <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '热处理'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
              <el-table-column v-if="activeIndex == 'first'"  label="磨床"  min-width="145">
                <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '磨床'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
               <el-table-column v-if="activeIndex == 'first'"  label="数控1"  min-width="145">
                <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '数控1'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                <el-table-column v-if="activeIndex == 'first'"  label="数控2"  min-width="145">
                  <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '数控2'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                 <el-table-column v-if="activeIndex == 'first'"  label="火花"  min-width="145">
                  <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '火花'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                  <el-table-column v-if="activeIndex == 'first'"  label="线切割"  min-width="145">
                    <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '线切割'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                   <el-table-column v-if="activeIndex == 'first'"  label="刻字"  min-width="145">
                    <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '刻字'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                    <el-table-column v-if="activeIndex == 'first'"  label="网格"  min-width="145">
                      <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '网格'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
                     <el-table-column v-if="activeIndex == 'first'"  label="深孔钻"  min-width="145">
  <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '深孔钻'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>
<el-table-column v-if="activeIndex == 'first'"  label="钻孔" min-width="145">
  <template #default="{ row }">
    <template v-for="(item, index) in row.taskDispatchDetailDOList" :key="index">
      <div v-if="item.procedureName === '钻孔'" class="custom-cell">
        <!-- 第一行 -->
        <div class="first-row">
          <span >
            <span v-if="!item.reportTime">{{ item.sort }}</span> <!-- 仅当 reportTime 为空时显示 sort -->
          </span>
          <span>
            <!-- isOutsourcing 图片 -->
            <img
              v-if="item.isOutsourcing === 'Y'"
              src="/src/assets/imgs/out.png"
              class="status-icon"
            />
            <!-- checkYn 图片 -->
            <img
              v-if="item.checkYn === 0"
              src="/src/assets/imgs/checkstatusss.png"
              class="status-icon"
            />
          </span>
        </div>
        <!-- 第二行（仅当 reportTime 有值时显示） -->
        <div v-if="item.reportTime" class="second-row">
          <span class="left">{{ formatLongToDate(item.reportTime) }}</span>
        </div>
      </div>
    </template>
  </template>
</el-table-column>

      <!--标准件-->
      <!--加工件-->

	  <el-table-column v-if="activeIndex == 'second'" label="物料需求计划" align="center" prop="planBoomExists" min-width="180">
                    <template #default="{ row }">
                      {{ row.planBoomExists ?(row.planBoomExists== 1?'✔':''):''}}
                    </template>
      </el-table-column>
                  <el-table-column v-if="activeIndex == 'second'" label="去库存" prop="purYard" min-width="180">
                       <template #default="{ row }">
                      {{ row.purYard ?(row.purYard== 1?'✔':''):''}}
                    </template>
      </el-table-column>
                  <el-table-column v-if="activeIndex == 'second'" label="采购单" prop="makeStatus" min-width="180">
                     <template #default="{ row }">
                      {{ row.makeStatus ?(row.makeStatus== 1?'送审':(row.makeStatus == 2 ? '已审批':'')):''}}
                    </template>
      </el-table-column>
 <el-table-column v-if="activeIndex == 'second'" label="采购订单" prop="orderNoExists" min-width="180">
                     <template #default="{ row }">
                      {{ row.orderNoExists ?(row.orderNoExists== 1?'✔':(row.orderNoExists == 0 ? '':'')):''}}
                    </template>
      </el-table-column>
	  <el-table-column v-if="activeIndex == 'second'" label="收货状态" align="center" prop="receivingStatus" min-width="180">
                     <template #default="{ row }">
                      {{ row.receivingStatus ?(row.receivingStatus== 1?'未收货':(row.receivingStatus == 2 ? '收货中':(row.receivingStatus == 3 ? '已收货':''))):''}}
                    </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <!-- 表单弹窗：添加/修改 -->

</template>

<script setup lang="ts">
import download from '@/utils/download'
import * as PlanSchedule from '@/api/heli/planSchedule'
import * as processbomApi from '@/api/heli/processbom'
import { getIntDictOptions, getStrDictOptions, DICT_TYPE, getDictLabel } from '@/utils/dict'
	import UserSelect from '@/views/heli/hlvuestyle/userSelect.vue'
import * as UserApi from '@/api/system/user'
import type { TabsPaneContext } from 'element-plus'
import { get } from 'sortablejs'
defineOptions({ name: 'Shenhe' })
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  projectCode: undefined,
  projectName: undefined,
  taskNo: undefined,
  projectSubName: undefined,
  materialName: undefined,
  owner: undefined,
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中

const handleSelectedUser1 = (newValue: any) => {
  queryParams.owner = newValue?.id
  console.log(queryParams.owner)
}
const formatDateT = (timestamp) => {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  return `${year}-${month}-${day}`; // 返回 YYYY-MM-DD 格式
}

const activeName = ref('first')
const activeIndex = ref('first')
/**切换tab */
const handleClick =  async(tab: TabsPaneContext, event: Event) => {
  var tabIndex = tab.props.name;
  queryParams.pageNo = 1;
  activeIndex.value = tabIndex;
  await getList(tabIndex);
}

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {

    if( activeIndex.value  == 'first'){
    const data = await processbomApi.getPlanBb(queryParams)
    console.log(data)
    list.value = data.list

    total.value = data.total
    }else{
          const data = await processbomApi.planBZJPage(queryParams)
    list.value = data.list

    total.value = data.total
    }
  } finally {
    loading.value = false
  }
}
const  formatLongToDate = (longTimestamp) => {
  if(!longTimestamp){
    return '';
  }
  const date = new Date(longTimestamp);
  // const year = date.getFullYear();
  const year = String(date.getFullYear()).slice(-2);
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始
  const day = String(date.getDate()).padStart(2, '0');
  return `${year}-${month}-${day}`;
}


const cellClassName = ({ row,column }) => {
  if(row.taskDispatchDetailDOList){
      for(var i = 0 ;i < row.taskDispatchDetailDOList.length ; i++){
    var item = row.taskDispatchDetailDOList[i];

      if (item.procedureName == column.label && item.flag === 1) {
        return 'green-cell'
      };
  if (item.procedureName == column.label && item.flag === 2) return 'yellow-cell';
  if (item.procedureName == column.label && item.flag === 3) return 'red-cell';
  return '';
  }
  }

};


/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}

/** 添加/修改操作 */
const formRef = ref()




/** 导出按钮操作 */
const handleExport = async () => {
  try {
    // 导出的二次确认
    await message.exportConfirm()
    // 发起导出
    exportLoading.value = true
    const data = await ShenheApi.exportShenhe(queryParams)
    download.excel(data, '审核.xls')
  } catch {
  } finally {
    exportLoading.value = false
  }
}

/** 初始化 **/
onMounted(async () => {
	loading.value = true
  await getList()

  userList.value = await UserApi.getSimpleUserList()
})
</script>
<style>

.warning-row {
  background-color: #D3D3D3 !important;
}
.green-cell {
  background-color: #e6f7e6 !important;
}
.yellow-cell {
  background-color: #fffbe6 !important;
}
.red-cell {
  background-color: #fff1f0 !important;
}
.custom-cell {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.first-row, .second-row {
  display: flex;
justify-content: flex-start;
  width: 100%;
  margin-bottom: 4px; /* 增加行间距 */
}

.status-icon {
  width: 35px;  /* 增大图片宽度 */
  height: 35px; /* 增大图片高度 */
  margin-left: 8px;
  vertical-align: middle;
  object-fit: contain; /* 确保图片比例不变形 */
}
</style>
