<template>
  <div>
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div v-show="showSearch" class="mb-[10px]">
        <el-card shadow="hover">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
            <el-form-item :label="t('project.management.search.code')" prop="code">
              <el-input v-model="queryParams.code" :placeholder="t('project.management.search.codePlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.name')" prop="name">
              <el-input v-model="queryParams.name" :placeholder="t('project.management.search.namePlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.language')" prop="language">
              <el-select v-model="queryParams.language" :placeholder="t('project.management.search.languagePlaceholder')" clearable style="width: 240px;">
                <el-option v-for="dict in project_language" :key="dict.value" :label="parseI18nName(dict.label)" :value="dict.value"/>
              </el-select>
            </el-form-item>
            <el-form-item :label="t('project.management.search.type')" prop="type">
              <el-select v-model="queryParams.type" :placeholder="t('project.management.search.typePlaceholder')" clearable style="width: 240px;">
                <el-option v-for="dict in project_type" :key="dict.value" :label="parseI18nName(dict.label)" :value="dict.value"/>
              </el-select>
            </el-form-item>
            <el-form-item :label="t('project.management.search.pdGpd')" prop="pdGpd">
              <el-input v-model="queryParams.pdGpd" :placeholder="t('project.management.search.pdGpdPlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.pmGpm')" prop="pmGpm">
              <el-input v-model="queryParams.pmGpm" :placeholder="t('project.management.search.pmGpmPlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.ctaGcta')" prop="ctaGcta">
              <el-input v-model="queryParams.ctaGcta" :placeholder="t('project.management.search.ctaGctaPlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.sponsor')" prop="sponsor">
              <el-input v-model="queryParams.sponsor" :placeholder="t('project.management.search.sponsorPlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.cro')" prop="cro">
              <el-input v-model="queryParams.cro" :placeholder="t('project.management.search.croPlaceholder')" clearable @keyup.enter="handleQuery" style="width: 240px;" />
            </el-form-item>
            <el-form-item :label="t('project.management.search.startTime')">
              <el-date-picker
                v-model="dateRangeStartTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                range-separator="-"
                :start-placeholder="t('project.management.search.startDate')"
                :end-placeholder="t('project.management.search.endDate')"
                :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
                style="width: 240px;"
              />
            </el-form-item>
            <el-form-item :label="t('project.management.search.endTime')">
              <el-date-picker
                v-model="dateRangeEndTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                range-separator="-"
                :start-placeholder="t('project.management.search.startDate')"
                :end-placeholder="t('project.management.search.endDate')"
                :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
                style="width: 240px;"
              />
            </el-form-item>
            <el-form-item :label="t('project.management.search.createTime')">
              <el-date-picker
                v-model="dateRangeCreateTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                range-separator="-"
                :start-placeholder="t('project.management.search.startDate')"
                :end-placeholder="t('project.management.search.endDate')"
                :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
                style="width: 240px;"
              />
            </el-form-item>
            <el-form-item :label="t('project.management.search.updateTime')">
              <el-date-picker
                v-model="dateRangeUpdateTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                range-separator="-"
                :start-placeholder="t('project.management.search.startDate')"
                :end-placeholder="t('project.management.search.endDate')"
                :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
                style="width: 240px;"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="Search" @click="handleQuery">{{ t('project.management.search.search') }}</el-button>
              <el-button icon="Refresh" @click="resetQuery">{{ t('project.management.search.reset') }}</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
    </transition>

    <el-card shadow="never">
      <template #header>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['project:management:add']">{{ t('project.management.button.add') }}</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['project:management:remove']">{{ t('project.management.button.delete') }}</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['project:management:export']">{{ t('project.management.button.export') }}</el-button>
          </el-col>
          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
      </template>

      <el-table v-loading="loading" border :data="managementList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column :label="t('project.management.table.id')" align="center" prop="id" v-if="true" />
        <el-table-column :label="t('project.management.table.code')" align="center" prop="code" width="150" />
        <el-table-column :label="t('project.management.table.name')" align="center" prop="name" width="200" />
        <el-table-column :label="t('project.management.table.language')" align="center" prop="language" width="90">
          <template #default="scope">
            <dict-tag :options="project_language" :value="scope.row.language" />
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.type')" align="center" prop="type" width="140">
          <template #default="scope">
            <dict-tag :options="project_type" :value="scope.row.type" />
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.status')" align="center" prop="status" width="100">
          <template #default="scope">
            <el-tag :type="getStatusType(scope.row.status)">{{ getStatusText(scope.row.status) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.pdGpd')" align="center" prop="pdGpd" width="150" />
        <el-table-column :label="t('project.management.table.pmGpm')" align="center" prop="pmGpm" width="150" />
        <el-table-column :label="t('project.management.table.ctaGcta')" align="center" prop="ctaGcta" width="150" />
        <el-table-column :label="t('project.management.table.sponsor')" align="center" prop="sponsor" width="150" />
        <el-table-column :label="t('project.management.table.cro')" align="center" prop="cro" width="150" />
        <el-table-column :label="t('project.management.table.startTime')" align="center" prop="startTime" width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.endTime')" align="center" prop="endTime" width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.createTime')" align="center" prop="createTime" width="180">
          <template #default="scope">
            <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.updateTime')" align="center" prop="updateTime" width="180">
          <template #default="scope">
            <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="t('project.management.table.operation')" align="center" fixed="right"  class-name="small-padding fixed-width" width="320">
          <template #default="scope">
            <el-tooltip :content="t('project.management.tooltip.detail')" placement="top">
              <el-button link type="primary" icon="View" @click="handleViewDetail(scope.row)" v-hasPermi="['project:management:query']"></el-button>
            </el-tooltip>
            <el-tooltip :content="t('project.management.tooltip.edit')" placement="top">
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['project:management:edit']"></el-button>
            </el-tooltip>
            <el-tooltip :content="t('project.management.tooltip.delete')" placement="top">
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['project:management:remove']"></el-button>
            </el-tooltip>
            <el-tooltip :content="t('project.management.tooltip.updateStatus')" placement="top">
              <el-button link type="primary" icon="Refresh" @click="handleUpdateStatus(scope.row)" v-hasPermi="['project:management:updateStatus']"></el-button>
            </el-tooltip>
          </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-dialog :title="t('project.management.tooltip.updateStatus')" v-model="statusDialog.visible" width="500px" append-to-body>
      <el-form ref="statusFormRef" :model="statusForm" :rules="statusRules" label-width="100px">
        <el-form-item :label="t('project.management.table.code')" prop="code">
          <el-input v-model="statusForm.code" disabled />
        </el-form-item>
        <el-form-item :label="t('project.management.table.name')" prop="name">
          <el-input v-model="statusForm.name" disabled />
        </el-form-item>
        <el-form-item :label="t('project.management.table.status')" prop="status">
          <el-select v-model="statusForm.status" :placeholder="t('project.management.message.selectStatus')" style="width: 100%;">
            <el-option :label="t('project.management.status.unstarted')" :value="0" />
            <el-option :label="t('project.management.status.underway')" :value="1" />
            <el-option :label="t('project.management.status.paused')" :value="2" />
            <el-option :label="t('project.management.status.finished')" :value="3" />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="statusButtonLoading" type="primary" @click="submitStatusForm">{{ t('project.management.button.submit') }}</el-button>
          <el-button @click="statusDialog.visible = false">{{ t('project.management.button.cancel') }}</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加或修改项目管理对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="900px" append-to-body>
      <el-form ref="managementFormRef" :model="form" :rules="rules" label-width="100px">
        <!-- 图标 - 居中显示在最顶部 -->
        <el-row :gutter="20" justify="center">
          <el-col :span="24" style="text-align: center; margin-bottom: 20px;">
            <image-upload v-model="form.icon" :limit="1" style="display: inline-block;"/>
          </el-col>
        </el-row>

        <el-divider content-position="left">{{ t('project.management.form.sectionBasic') }}</el-divider>

        <!-- 第二行：项目编号和名称 -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.code')" prop="code">
              <el-input v-model="form.code" :placeholder="t('project.management.form.codePlaceholder')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.name')" prop="name">
              <el-input v-model="form.name" :placeholder="t('project.management.form.namePlaceholder')" />
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 第三行：语言和类型 -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.language')" prop="language">
              <el-select v-model="form.language" :placeholder="t('project.management.form.languagePlaceholder')" style="width: 100%;">
                <el-option
                    v-for="dict in project_language"
                    :key="dict.value"
                    :label="parseI18nName(dict.label)"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.type')" prop="type">
              <el-select v-model="form.type" :placeholder="t('project.management.form.typePlaceholder')" style="width: 100%;">
                <el-option
                    v-for="dict in project_type"
                    :key="dict.value"
                    :label="parseI18nName(dict.label)"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="left">{{ t('project.management.form.sectionResponsible') }}</el-divider>

        <!-- 第四行：PD/GPD、PM/GPM -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.pdGpd')" prop="pdGpd">
              <el-input v-model="form.pdGpd" :placeholder="t('project.management.form.pdGpdPlaceholder')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.pmGpm')" prop="pmGpm">
              <el-input v-model="form.pmGpm" :placeholder="t('project.management.form.pmGpmPlaceholder')" />
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 第五行：CTA/GCTA -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.ctaGcta')" prop="ctaGcta">
              <el-input v-model="form.ctaGcta" :placeholder="t('project.management.form.ctaGctaPlaceholder')" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="left">{{ t('project.management.form.sectionPartner') }}</el-divider>

        <!-- 第六行：Sponsor、CRO -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.sponsor')" prop="sponsor">
              <el-input v-model="form.sponsor" :placeholder="t('project.management.form.sponsorPlaceholder')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.cro')" prop="cro">
              <el-input v-model="form.cro" :placeholder="t('project.management.form.croPlaceholder')" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider></el-divider>

        <!-- 第七行：开始时间、结束时间 -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.startTime')" prop="startTime">
              <el-date-picker clearable
                v-model="form.startTime"
                type="date"
                value-format="YYYY-MM-DD"
                :placeholder="t('project.management.form.startTimePlaceholder')"
                style="width: 100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="t('project.management.form.endTime')" prop="endTime">
              <el-date-picker clearable
                v-model="form.endTime"
                type="date"
                value-format="YYYY-MM-DD"
                :placeholder="t('project.management.form.endTimePlaceholder')"
                style="width: 100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- 第八行：备注 -->
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item :label="t('project.management.form.note')" prop="note">
              <el-input v-model="form.note" type="textarea" :rows="3" :placeholder="t('project.management.form.notePlaceholder')" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="primary" @click="submitForm">{{ t('project.management.button.submit') }}</el-button>
          <el-button @click="cancel">{{ t('project.management.button.cancel') }}</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { inject } from 'vue';
import { listManagement, getManagement, delManagement, addManagement, updateManagement, updateStatus } from '@/api/project/management';
import { ManagementVO, ManagementQuery, ManagementForm } from '@/api/project/management/types';
import { useI18n } from 'vue-i18n';
import { parseI18nName } from '@/utils/i18n';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { t } = useI18n();
const { project_type, project_language } = toRefs<any>(proxy?.useDict('project_type', 'project_language'));

// 项目状态枚举映射
const projectStatusMap: Record<number, string> = {
  0: 'unstarted',
  1: 'underway',
  2: 'paused',
  3: 'finished'
};

// 获取状态文本（国际化）
const getStatusText = (status: number | undefined) => {
  if (status === undefined || status === null) return '-';
  const statusKey = projectStatusMap[status];
  return statusKey ? t(`project.management.status.${statusKey}`) : status;
};

// 获取状态标签类型
const getStatusType = (status: number | undefined): 'success' | 'info' | 'warning' | 'primary' | 'danger' => {
  const typeMap: Record<number, 'success' | 'info' | 'warning' | 'primary' | 'danger'> = {
    0: 'info',
    1: 'success',
    2: 'warning',
    3: 'primary'
  };
  if (status === undefined || status === null) return 'info';
  return typeMap[status] || 'info';
};

// 注入父组件提供的方法和组件
const switchComponent = inject<any>('switchComponent');
const DetailComponent = inject<any>('DetailComponent');

const managementList = ref<ManagementVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const dateRangeStartTime = ref<[DateModelType, DateModelType]>(['', '']);
const dateRangeEndTime = ref<[DateModelType, DateModelType]>(['', '']);
const dateRangeCreateTime = ref<[DateModelType, DateModelType]>(['', '']);
const dateRangeUpdateTime = ref<[DateModelType, DateModelType]>(['', '']);

const queryFormRef = ref<ElFormInstance>();
const managementFormRef = ref<ElFormInstance>();
const statusFormRef = ref<ElFormInstance>();

const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const statusDialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const statusForm = ref<{
  id?: string | number;
  code?: string;
  name?: string;
  status?: number;
}>({
  id: undefined,
  code: undefined,
  name: undefined,
  status: undefined
});

const statusButtonLoading = ref(false);

const statusRules = {
  status: [
    { required: true, message: t('project.management.rule.statusRequired'), trigger: 'change' }
  ]
};

const initFormData: ManagementForm = {
  id: undefined,
  code: undefined,
  name: undefined,
  icon: undefined,
  language: undefined,
  type: undefined,
  status: undefined,
  pdGpd: undefined,
  pmGpm: undefined,
  ctaGcta: undefined,
  sponsor: undefined,
  cro: undefined,
  note: undefined,
  startTime: undefined,
  endTime: undefined,
}
const data = reactive<PageData<ManagementForm, ManagementQuery>>({
  form: {...initFormData},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    code: undefined,
    name: undefined,
    language: undefined,
    type: undefined,
    status: undefined,
    pdGpd: undefined,
    pmGpm: undefined,
    ctaGcta: undefined,
    sponsor: undefined,
    cro: undefined,
    params: {
      startTime: undefined,
      endTime: undefined,
      createTime: undefined,
      updateTime: undefined,
    }
  },
  rules: {
    id: [
      { required: true, message: t('project.management.rule.idRequired'), trigger: "blur" }
    ],
    code: [
      { required: true, message: t('project.management.rule.codeRequired'), trigger: "blur" }
    ],
    name: [
      { required: true, message: t('project.management.rule.nameRequired'), trigger: "blur" }
    ],
    language: [
      { required: true, message: t('project.management.rule.languageRequired'), trigger: "change" }
    ],
    type: [
      { required: true, message: t('project.management.rule.typeRequired'), trigger: "change" }
    ],
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询项目管理列表 */
const getList = async () => {
  loading.value = true;
  queryParams.value.params = {};
  proxy?.addDateRange(queryParams.value, dateRangeStartTime.value, 'StartTime');
  proxy?.addDateRange(queryParams.value, dateRangeEndTime.value, 'EndTime');
  proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, 'CreateTime');
  proxy?.addDateRange(queryParams.value, dateRangeUpdateTime.value, 'UpdateTime');
  const res = await listManagement(queryParams.value);
  managementList.value = res.rows;
  total.value = res.total;
  loading.value = false;
}

/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
}

/** 表单重置 */
const reset = () => {
  form.value = {...initFormData};
  managementFormRef.value?.resetFields();
}

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

/** 重置按钮操作 */
const resetQuery = () => {
  dateRangeStartTime.value = ['', ''];
  dateRangeEndTime.value = ['', ''];
  dateRangeCreateTime.value = ['', ''];
  dateRangeUpdateTime.value = ['', ''];
  queryFormRef.value?.resetFields();
  handleQuery();
}

/** 多选框选中数据 */
const handleSelectionChange = (selection: ManagementVO[]) => {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
const handleAdd = () => {
  reset();
  dialog.visible = true;
  dialog.title = t('project.management.dialog.add');
}

/** 修改按钮操作 */
const handleUpdate = async (row?: ManagementVO) => {
  reset();
  const _id = row?.id || ids.value[0]
  const res = await getManagement(_id);
  Object.assign(form.value, res.data);
  dialog.visible = true;
  dialog.title = t('project.management.dialog.edit');
}

/** 提交按钮 */
const submitForm = () => {
  managementFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      buttonLoading.value = true;
      if (form.value.id) {
        await updateManagement(form.value).finally(() =>  buttonLoading.value = false);
      } else {
        await addManagement(form.value).finally(() =>  buttonLoading.value = false);
      }
      proxy?.$modal.msgSuccess(t('project.management.message.operationSuccess'));
      dialog.visible = false;
      await getList();
    }
  });
}

/** 删除按钮操作 */
const handleDelete = async (row?: ManagementVO) => {
  const _ids = row?.id || ids.value;
  await proxy?.$modal.confirm(t('project.management.message.deleteConfirm', { ids: _ids })).finally(() => loading.value = false);
  await delManagement(_ids);
  proxy?.$modal.msgSuccess(t('project.management.message.deleteSuccess'));
  await getList();
}

/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download('project/management/export', {
    ...queryParams.value
  }, `management_${new Date().getTime()}.xlsx`)
}

/** 查看详情按钮操作 */
const handleViewDetail = (row: ManagementVO) => {
  if (switchComponent && DetailComponent) {
    switchComponent(DetailComponent, { projectId: row.id });
  }
}

/** 更新状态按钮操作 */
const handleUpdateStatus = (row: ManagementVO) => {
  statusForm.value = {
    id: row.id,
    code: row.code,
    name: row.name,
    status: row.status
  };
  statusDialog.visible = true;
};

/** 提交状态更新 */
const submitStatusForm = () => {
  statusFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      statusButtonLoading.value = true;
      try {
        await updateStatus(statusForm.value.id!, statusForm.value.status!);
        proxy?.$modal.msgSuccess(t('project.management.message.updateStatusSuccess'));
        statusDialog.visible = false;
        await getList();
      } finally {
        statusButtonLoading.value = false;
      }
    }
  });
};

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