<template>
  <div class="app-container">
    <!-- 列表页搜索区 -->
    <el-card shadow="never" class="search-card" :body-style="{ padding: '15px 20px 10px' }">
      <el-form :model="queryParams" ref="queryRef" label-width="80px">
        <el-row :gutter="24">
          <el-col :span="6">
            <el-form-item label="所属公司" prop="companyNo">
              <el-select v-model="queryParams.companyNo" placeholder="请选择" style="width: 100%" clearable>
                 <el-option v-for="item in companyOptions" :key="item.companyCode || item.id" :label="item.companyName" :value="item.companyCode || item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目名称" prop="projectName">
              <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户名称" prop="customName">
              <el-input v-model="queryParams.customName" placeholder="请输入客户名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="负责人" prop="leader">
              <el-select v-model="queryParams.leader" placeholder="请选择" style="width: 100%" clearable>
                 <el-option v-for="item in userOptions" :key="item.staffId || item.userId" :label="(item.staffCode || item.userName ? '(' + (item.staffCode || item.userName) + ') ' : '') + (item.staffName || item.nickName)" :value="String(item.staffId || item.userId)" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" class="search-row">
          <el-col :span="6">
            <el-form-item label="部门" prop="deptNo">
              <el-tree-select
                v-model="queryParams.deptNo"
                :data="deptOptions"
                :props="{ value: 'id', label: 'label', children: 'children' }"
                value-key="id"
                placeholder="所属部门"
                check-strictly
                style="width: 100%"
                clearable
                filterable
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="产品支持" prop="productSupport">
              <el-select v-model="queryParams.productSupport" placeholder="请选择" style="width: 100%" clearable>
                 <el-option v-for="item in userOptions" :key="item.staffId || item.userId" :label="(item.staffCode || item.userName ? '(' + (item.staffCode || item.userName) + ') ' : '') + (item.staffName || item.nickName)" :value="String(item.staffId || item.userId)" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目级别" prop="projectLevel">
              <el-select v-model="queryParams.projectLevel" placeholder="请选择" style="width: 100%" clearable>
                 <el-option v-for="item in projectLevelOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目类型" prop="businessType">
              <el-select v-model="queryParams.businessType" placeholder="请选择" style="width: 100%" clearable>
                 <el-option v-for="item in projectTypeOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" class="search-row">
          <el-col :span="6">
            <el-form-item label="入围类型" prop="finalizationType">
              <el-select v-model="queryParams.finalizationType" placeholder="请选择" style="width: 100%" clearable>
                <el-option v-for="item in shortlistedTypeOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目状态" prop="projectStatus">
              <el-select v-model="queryParams.projectStatus" style="width: 100%" clearable>
                <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成交结果" prop="result">
              <el-select v-model="queryParams.result" placeholder="请选择" style="width: 100%" clearable>
                <el-option v-for="item in resultOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="时间查询类型" prop="timeType">
              <el-select v-model="queryParams.timeType" style="width: 100%" clearable>
                <el-option v-for="item in timeTypeOptions" :key="item.value" :label="item.label" :value="Number(item.value)" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" class="search-row">
          <el-col :span="7">
            <el-form-item label="时间范围" prop="dateRange">
              <el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" value-format="YYYY-MM-DD" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="17">
            <el-form-item label-width="20px">
              <div class="search-btns">
                <el-button icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
                <el-button type="primary" icon="Plus" @click="handleAdd" class="btn-new">新增</el-button>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <!-- 数据表格 -->
    <el-card shadow="never" class="table-card">
      <div class="tabs-control">
        <div class="tabs-left">
          <span class="page-title">年度入围（平台）信息列表</span>
          <div class="tab-items">
            <div class="tab-item" :class="{ current: activeTab === 'mine' }" @click="handleTabChange('mine')">我负责的年度入围</div>
            <div class="tab-item" :class="{ current: activeTab === 'join' }" @click="handleTabChange('join')">我参与的年度入围</div>
            <div class="tab-item badge-item" :class="{ current: activeTab === 'all' }" @click="handleTabChange('all')">
              全部年度入围
              <span class="badge" v-if="total > 0">{{ total > 99 ? '99+' : total }}</span>
            </div>
          </div>
          <div class="summary-info">
            <span class="total-label">金额总计</span>
            <span class="total-value">{{ Number(totalAmount).toFixed(2) }}</span>
            <span class="total-unit">(万)</span>
          </div>
        </div>
        <div class="tabs-right">
          <div class="action-btns">
            <el-button type="info" plain size="default" icon="Delete" :disabled="multipleSelection.length === 0" @click="handleBatchDelete">批量删除</el-button>
            <el-button type="primary" size="default" icon="Switch" :disabled="multipleSelection.length === 0" @click="handleTransfer">转移给他人</el-button>
          </div>
        </div>
      </div>
      <el-table ref="selectionTable" v-loading="loading" :data="dataList" border class="standard-table" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" align="center" fixed />
        <el-table-column label="项目名称" align="center" min-width="240" show-overflow-tooltip fixed>
          <template #default="scope">
            <span class="project-name-link" @click="handleDetail(scope.row)">{{ scope.row.projectName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="所属公司" align="center" min-width="180" show-overflow-tooltip>
          <template #default="scope">
            {{ companyOptions.find(c => (c.companyCode || c.id) === scope.row.companyNo)?.companyName || scope.row.companyNo }}
          </template>
        </el-table-column>
        <el-table-column label="客户名称" align="center" prop="customName" min-width="200" show-overflow-tooltip />
        <el-table-column label="项目级别" align="center" prop="projectLevel" width="100">
          <template #default="scope">
            {{ projectLevelOptions.find(o => String(o.value) === String(scope.row.projectLevel))?.label || scope.row.projectLevel }}
          </template>
        </el-table-column>
        <el-table-column label="项目类型" align="center" prop="businessType" width="100">
          <template #default="scope">
            {{ projectTypeOptions.find(o => String(o.value) === String(scope.row.businessType))?.label || scope.row.businessType }}
          </template>
        </el-table-column>
        <el-table-column label="金额(万)" align="center" prop="amount" width="100" sortable />
        <el-table-column label="服务期(年)" align="center" prop="standardPeriod" width="100" />
        <el-table-column label="服务时间段" align="center" prop="serviceTime" width="150" show-overflow-tooltip />
        <el-table-column label="投标截止时间" align="center" prop="tenderDeadline" width="110">
          <template #default="scope">
            <span>{{ parseTime(scope.row.tenderDeadline, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="部门" align="center" prop="deptName" width="120" />
        <el-table-column label="负责人" align="center" prop="leaderName" width="100">
          <template #default="scope">
            {{ scope.row.leaderName || scope.row.managerName || userOptions.find(u => String(u.staffId || u.userId) === String(scope.row.leader))?.staffName || '' }}
          </template>
        </el-table-column>
        <el-table-column label="产品支持" align="center" prop="productSupportName" width="100">
          <template #default="{ row }">
            <span>{{ row.productSupportName || findUserName(row.productSupport) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="赢单率(%)" align="center" width="100">
          <template #default="scope">
            {{ (scope.row.winningRate ?? scope.row.winRate) != null ? (scope.row.winningRate ?? scope.row.winRate) + '%' : '' }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime" width="120">
          <template #default="scope">
            <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="报名截止时间" align="center" prop="signUpDeadline" width="110">
          <template #default="scope">
            <span>{{ parseTime(scope.row.signUpDeadline || scope.row.entryDeadline, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="行业" align="center" prop="industry" width="120">
          <template #default="scope">
            {{ 
              scope.row.industryCategoryName || 
              scope.row.industryName || 
              industryOptions.find(o => String(o.id) === String(scope.row.profession))?.industryCategoryName || 
              ''
            }}
          </template>
        </el-table-column>
        <el-table-column label="入围类型" align="center" prop="finalizationType" width="100">
          <template #default="scope">
            {{ shortlistedTypeOptions.find(o => String(o.value) === String(scope.row.finalizationType || scope.row.shortlistedType || scope.row.selectionType))?.label || scope.row.finalizationType || scope.row.selectionType }}
          </template>
        </el-table-column>
        <el-table-column label="项目状态" align="center" prop="projectStatus" width="100">
           <template #default="scope">
             <el-tag :type="scope.row.projectStatus === 5 ? 'info' : 'warning'" plain>{{ statusOptions.find(o => String(o.value) === String(scope.row.projectStatus))?.label || '跟进中' }}</el-tag>
           </template>
        </el-table-column>
        <el-table-column label="成交结果" align="center" width="100">
          <template #default="scope">
            <template v-if="String(scope.row.dealResult || scope.row.result) === '1'">
              <span style="color: #67c23a;">赢单</span>
            </template>
            <template v-else-if="String(scope.row.dealResult || scope.row.result) === '2'">
              <span style="color: #f56c6c;">丢单</span>
            </template>
            <template v-else>
              {{ resultOptions.find(o => String(o.value) === String(scope.row.dealResult || scope.row.result))?.label || scope.row.dealResult || scope.row.result }}
            </template>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="180" fixed="right">
          <template #default="scope">
            <el-button link type="info" @click="handleDetail(scope.row)">详情</el-button>
            <el-button link type="primary" @click="handleProgress(scope.row)">进度</el-button>
            <el-button link type="info" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </el-card>
    
    <!-- 抽屉：查看/发布进度 -->
    <el-drawer title="查看进度" v-model="progressVisible" size="500px" class="progress-drawer">
      <div class="progress-container">
        <!-- 发布区域 -->
        <div class="progress-publish-box">
          <el-input
            v-model="progressContent"
            type="textarea"
            :rows="6"
            placeholder="请输入进度描述"
            maxlength="500"
            show-word-limit
            resize="none"
          />
          <div class="publish-footer">
            <el-button type="primary" icon="Plus" @click="submitProgress" :loading="publishLoading">发 布</el-button>
          </div>
        </div>

        <!-- 列表区域 -->
        <div class="progress-list" v-loading="progressListLoading">
          <div v-for="(item, index) in progressList" :key="index" class="progress-item">
            <div class="item-header">
              <span class="user-name">{{ item.createByName || item.userName || item.createBy }}</span>
              <span class="time">{{ item.createTime || item.followUpTime }}</span>
            </div>
            <div class="item-content">{{ item.content || item.followUpCondition }}</div>
          </div>
          <el-empty v-if="progressList.length === 0 && !progressListLoading" description="暂无进度数据" :image-size="60" />
        </div>

        <!-- 分页 -->
        <div class="progress-pagination" v-if="progressTotal > 0">
          <el-pagination
            v-model:current-page="progressPage"
            v-model:page-size="progressPageSize"
            layout="prev, pager, next"
            :total="progressTotal"
            @current-change="loadProgress"
            small
          />
        </div>
      </div>
    </el-drawer>

    <!-- 新增组件 -->
    <AddDialog v-model="addVisible" :options="drawerOptions" @success="getList" />

    <!-- 编辑组件 -->
    <EditDialog v-model="editVisible" :id="currentId" :options="drawerOptions" @success="getList" />

    <!-- 详情组件 -->
    <DetailDialog v-model="detailVisible" :id="currentId" :options="drawerOptions" @edit="handleEdit" @success="getList" />

    <!-- 转移负责人弹窗 -->
    <el-dialog v-model="transferVisible" title="是否将选中的年度入围转移给其他负责人？" width="500px" append-to-body>
      <el-form label-width="110px" style="padding: 10px 20px 0;">
        <el-form-item label="新负责人：" required>
          <el-select v-model="transferOwner" placeholder="请选择" style="width: 100%" filterable clearable>
            <el-option v-for="item in userOptions" :key="item.staffId || item.userId" :label="(item.staffCode || item.userName ? '(' + (item.staffCode || item.userName) + ') ' : '') + (item.staffName || item.nickName)" :value="String(item.staffId || item.userId)" />
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-checkbox v-model="keepAsMember">保留【负责人】为销售机会团队成员</el-checkbox>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="confirmTransfer">确定</el-button>
          <el-button @click="transferVisible = false">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="PlatformSelection">
import { ref, reactive, onMounted, getCurrentInstance, toRefs } from 'vue';
import {
  listPlatformSelection,
  delPlatformSelection,
  transferPlatformSelection
} from '@/api/saleManage/platformSelection/index';
import { listRecord, addRecord } from "@/api/visit/record";
import { listComStaff } from "@/api/system/comStaff/index";
import { listCompanyOption, listCustomerInfo } from "@/api/customer/customerInfo/index";
import { listIndustryCategory } from "@/api/customer/industryCategory";
import { listSalesResultAnalyze } from '@/api/saleManage/leads/salesResultAnalyze';
import { deptTreeSelect } from "@/api/system/user";
import { Search, Refresh, Plus, Delete, Switch } from '@element-plus/icons-vue';
import AddDialog from './add.vue';
import EditDialog from './edit.vue';
import DetailDialog from './detail.vue';

const proxy = getCurrentInstance().proxy;

// 列表状态
const loading = ref(false);
const total = ref(0);
const dataList = ref([]);
const dateRange = ref([]);
const multipleSelection = ref([]);
const totalAmount = ref(0);
const activeTab = ref('all');

// 进度状态
const progressVisible = ref(false);
const progressContent = ref('');
const publishLoading = ref(false);
const progressList = ref([]);
const progressListLoading = ref(false);
const currentProjectNo = ref('');
const currentCustomerName = ref('');
const currentCustomerNo = ref('');
const currentDeptName = ref('');
const currentIndustry = ref('');
const progressTotal = ref(0);
const progressPage = ref(1);
const progressPageSize = ref(5);

// 转移弹窗状态
const transferVisible = ref(false);
const transferOwner = ref('');
const keepAsMember = ref(false);

// 组件显示控制
const addVisible = ref(false);
const editVisible = ref(false);
const detailVisible = ref(false);
const currentId = ref(null);

// 查询参数
const queryParams = reactive({
  pageNum: 1,
  pageSize: 10,
  companyNo: undefined,
  projectName: undefined,
  customName: undefined,
  leader: undefined,
  deptNo: undefined,
  projectLevel: undefined,
  businessType: undefined,
  projectStatus: 1,
  timeType: 1,
  result: undefined,
  queryType: undefined,
  finalizationType: 1
});

// 下拉选项
const {
  XMJB0001, L0001, R0001, J0001, ZBPL0001, deal_result, time_query_type
} = proxy.useDict('XMJB0001', 'L0001', 'R0001', 'J0001', 'ZBPL0001', 'deal_result', 'time_query_type');

const projectLevelOptions = L0001;
const projectTypeOptions = XMJB0001;
const shortlistedTypeOptions = R0001;
const statusOptions = J0001;
const resultOptions = deal_result;
const timeTypeOptions = time_query_type;
const materialOptions = ZBPL0001;
const userOptions = ref([]);
const companyOptions = ref([]);
const deptOptions = ref([]);
const industryOptions = ref([]);

// 使用 computed 确保传给子组件的是展开后的数组（而非 ref 对象），保持响应式
const drawerOptionsBase = reactive({
  company: [],
  user: [],
  industryList: [],
});

const drawerOptions = computed(() => ({
  company: drawerOptionsBase.company,
  user: drawerOptionsBase.user,
  industryList: drawerOptionsBase.industryList,
  level: L0001.value || [],
  type: XMJB0001.value || [],
  shortlisted: R0001.value || [],
  material: ZBPL0001.value || [],
  status: J0001.value || [],
  dept: deptOptions.value || [],
}));

/** 查询列表 */
const getList = async () => {
  loading.value = true;
  try {
    const params = { ...queryParams, dealResult: queryParams.result };
    const res = await listPlatformSelection(proxy.addDateRange(params, dateRange.value));
    const list = res.rows || [];
    
    // 补全成交结果数据
    if (list.length > 0) {
      const projectNos = list.map(i => i.projectNo).filter(Boolean);
      if (projectNos.length > 0) {
        try {
          const analysisRes = await listSalesResultAnalyze({ objectNos: projectNos.join(',') });
          const analysisMap = {};
          (analysisRes.rows || analysisRes.data || []).forEach(a => {
            analysisMap[a.objectNo] = a.dealResult;
          });
          list.forEach(item => {
            if (item.projectNo && analysisMap[item.projectNo]) {
              item.dealResult = analysisMap[item.projectNo];
            }
          });
        } catch (e) {
          console.error('补全成交结果失败', e);
        }
      }
    }

    dataList.value = list;
    total.value = res.total || 0;
    totalAmount.value = dataList.value.reduce((sum, item) => sum + (Number(item.amount) || 0), 0);
  } catch (err) {
    console.error(err);
  } finally {
    loading.value = false;
  }
};

const handleQuery = () => { queryParams.pageNum = 1; getList(); };

const handleTabChange = (tab) => {
  if (activeTab.value === tab) return;
  activeTab.value = tab;
  switch (tab) {
    case 'all': delete queryParams.queryType; break;
    case 'mine': queryParams.queryType = 1; break;
    case 'join': queryParams.queryType = 2; break;
  }
  handleQuery();
};

const resetQuery = () => { dateRange.value = []; proxy.resetForm("queryRef"); handleQuery(); };
const handleSelectionChange = (selection) => { multipleSelection.value = selection; };

const handleAdd = () => {
  addVisible.value = true;
};

const handleDetail = (row) => {
  currentId.value = row.id;
  detailVisible.value = true;
};

const handleEdit = (id) => {
  currentId.value = id;
  detailVisible.value = false;
  editVisible.value = true;
};

const handleProgress = (row) => {
  currentId.value = row.id;
  currentProjectNo.value = row.projectNo;
  currentCustomerName.value = row.customName || row.customerName;
  currentCustomerNo.value = row.customNo || row.companyNo || '';
  currentDeptName.value = row.deptName || row.department || '';
  currentIndustry.value = row.industryCategoryName || row.industryName || row.industry || row.profession || '';
  progressContent.value = '';
  progressPage.value = 1;
  progressVisible.value = true;
  loadProgress();
};

const loadProgress = async () => {
  if (!currentProjectNo.value) return;
  progressListLoading.value = true;
  try {
    const res = await listRecord({ 
      objectNo: currentProjectNo.value,
      pageNum: progressPage.value,
      pageSize: progressPageSize.value
    });
    progressList.value = res.rows || [];
    progressTotal.value = res.total || 0;
  } catch (err) {
  } finally {
    progressListLoading.value = false;
  }
};

const submitProgress = async () => {
  if (!progressContent.value.trim()) return proxy.$modal.msgWarning("请输入进度内容");
  publishLoading.value = true;
  try {
    await addRecord({
      objectNo: currentProjectNo.value,
      customerNo: currentCustomerNo.value,
      customerName: currentCustomerName.value,
      department: currentDeptName.value,
      deptName: currentDeptName.value,
      profession: currentIndustry.value,
      followUpCondition: progressContent.value,
      dataType: '3', // 对应年度入围类型
      callDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
      callTypeCode: '1',
      callAim: '项目进度跟进'
    });
    proxy.$modal.msgSuccess("发布成功");
    progressContent.value = '';
    progressPage.value = 1;
    loadProgress();
    getList();
  } catch (err) {
    console.error(err);
  } finally {
    publishLoading.value = false;
  }
};

const handleDelete = (row) => {
  const ids = row.id || multipleSelection.value.map(item => item.id);
  proxy.$modal.confirm(`是否确认删除记录？`).then(() => {
    return delPlatformSelection(ids);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
};

const handleBatchDelete = () => {
  handleDelete({});
};

const handleTransfer = () => {
  transferVisible.value = true;
};

const confirmTransfer = async () => {
  if (!multipleSelection.value || multipleSelection.value.length === 0) {
    proxy.$modal.msgWarning('请先选择要转移的数据');
    return;
  }
  if (!transferOwner.value) {
    proxy.$modal.msgWarning('请选择新负责人');
    return;
  }
  try {
    await transferPlatformSelection({
      ids: multipleSelection.value.map(i => i.id),
      newLeaderId: transferOwner.value,
      keepAsMember: keepAsMember.value
    });
    proxy.$modal.msgSuccess('转移成功');
    transferVisible.value = false;
    transferOwner.value = '';
    keepAsMember.value = false;
    getList();
  } catch (err) {
    console.error('权属转移失败:', err);
  }
};

/** 初始化基础数据 */
const initData = () => {
  listIndustryCategory().then(res => {
    const flatten = (list) => {
      let result = [];
      list.forEach(item => {
        result.push(item);
        if (item.children) result = result.concat(flatten(item.children));
      });
      return result;
    };
    const listData = res.data || res.rows || [];
    const flatData = flatten(listData);
    industryOptions.value = flatData;
    drawerOptionsBase.industryList = listData; 
  });
  listComStaff({ pageSize: 1000 }).then(res => { 
    const list = res.rows || res.data || [];
    userOptions.value = list; 
    drawerOptionsBase.user = list; 
  });
  listCompanyOption().then(res => { companyOptions.value = res.data; drawerOptionsBase.company = res.data; });
  deptTreeSelect().then(res => deptOptions.value = res.data);
};

const getOptions = () => {
  listCompanyOption().then(res => { companyOptions.value = res.data || []; });
  listCustomerInfo({ pageNum: 1, pageSize: 500, isHighSeas: 'all' }).then(res => { customerList.value = res.rows || []; });
};

const findUserName = (id) => {
  if (!id) return '';
  const user = userOptions.value.find(u => String(u.staffId || u.userId) === String(id));
  return user ? (user.staffName || user.nickName) : id;
};

onMounted(() => {
  initData();
  getList();
});
</script>

<style scoped lang="scss">
.app-container { padding: 15px; background-color: #f7f9fb; min-height: calc(100vh - 84px); }

.search-card {
  margin-bottom: 10px; border: none; background: #fff; border-radius: 8px;
  :deep(.el-form-item) { margin-bottom: 6px;
    .el-form-item__label { font-weight: normal; color: #4e5969; }
  }
}

.search-row { margin-top: 5px; }
.search-btns { display: flex; gap: 12px; align-items: center; justify-content: flex-start; .el-button { border-radius: 6px; height: 32px; padding: 8px 16px; } }

.tabs-control {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px;
  .tabs-left { display: flex; align-items: center; gap: 20px;
    .page-title { font-size: 16px; color: #333; font-weight: normal; }
    .tab-items { display: flex; gap: 10px;
      .tab-item { padding: 6px 15px; border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px; color: #606266; cursor: pointer; transition: all 0.2s; position: relative; background: #fff;
        &:hover { color: #409eff; border-color: #c6e2ff; background-color: #ecf5ff; }
        &.current { color: #409eff; border-color: #409eff; background-color: #ecf5ff; }
        &.badge-item { position: relative; padding-right: 25px; }
        .badge { position: absolute; top: -8px; right: -5px; background: #f56c6c; color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 10px; line-height: 1; transform: scale(0.85); }
      }
    }
    .summary-info { font-size: 14px; color: #f56c6c; margin-left: 10px;
      .total-value { font-size: 16px; font-weight: normal; margin: 0 4px; }
    }
  }
  .tabs-right {
    .action-btns { display: flex; gap: 10px; }
  }
}

.table-card { border: none; border-radius: 8px; }
.standard-table {
  :deep(th.el-table__cell) { background-color: #f7f8fa !important; color: #4e5969; font-weight: normal; font-size: 13px; }
  :deep(td.el-table__cell) { font-size: 13px; color: #1d2129; }
}

.project-name-link { color: #409eff; cursor: pointer; &:hover { text-decoration: underline; } }
.dialog-footer { display: flex; justify-content: flex-end; gap: 12px; }

.progress-publish-box {
  padding-bottom: 20px;
  .publish-footer {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
  }
}

.progress-container {
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.progress-list {
  flex: 1;
  overflow-y: auto;
  padding-top: 10px;
  .progress-item {
    padding: 15px 0;
    border-bottom: 1px solid #f2f3f5;
    &:last-child { border-bottom: none; }
    .item-header {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      .user-name { color: #333; font-weight: bold; font-size: 14px; margin-right: 15px; }
      .time { color: #86909c; font-size: 13px; }
    }
    .item-content {
      font-size: 14px;
      color: #4e5969;
      line-height: 1.6;
      word-break: break-all;
    }
  }
}

.progress-pagination {
  margin-top: 10px;
  padding-bottom: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>
