604 lines
17 KiB
Plaintext
604 lines
17 KiB
Plaintext
<template>
|
|||
|
|
<div class="fa-full-height">
|
||
|
|
<FaSearchBar
|
||
|
|
v-show="showSearchBar"
|
||
|
|
ref="searchBarRef"
|
||
|
|
v-model="searchForm"
|
||
|
|
:items="PollinationSearchItems"
|
||
|
|
:rules="searchBarRules"
|
||
|
|
:is-expand="false"
|
||
|
|
:show-expand="true"
|
||
|
|
:show-reset="true"
|
||
|
|
:show-search="true"
|
||
|
|
:disabled-search="false"
|
||
|
|
:default-expanded="false"
|
||
|
|
include-audit
|
||
|
|
@search="handleSearch"
|
||
|
|
@reset="onResetSearch"
|
||
|
|
/>
|
||
|
|
|
||
|
|
<ElCard class="fa-table-card" :style="{ 'margin-top': showSearchBar ? '12px' : '0' }">
|
||
|
|
<FaTableHeader
|
||
|
|
v-model:columns="columnChecks"
|
||
|
|
v-model:showSearchBar="showSearchBar"
|
||
|
|
:loading="loading"
|
||
|
|
@refresh="refreshData"
|
||
|
|
>
|
||
|
|
<template #left>
|
||
|
|
<FaTableHeaderLeft
|
||
|
|
:remove-ids="selectedIds"
|
||
|
|
:perm-create="['module_bre:pollination:create']"
|
||
|
|
:perm-import="['module_bre:pollination:import']"
|
||
|
|
:perm-export="['module_bre:pollination:export']"
|
||
|
|
:perm-delete="['module_bre:pollination:delete']"
|
||
|
|
:delete-loading="batchDeleting"
|
||
|
|
:create-loading="createLoading"
|
||
|
|
@add="handleAdd"
|
||
|
|
@import="openImport"
|
||
|
|
@export="openExport"
|
||
|
|
@delete="handleBatchDelete"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
</FaTableHeader>
|
||
|
|
|
||
|
|
<FaTable
|
||
|
|
ref="faTableRef"
|
||
|
|
:loading="loading"
|
||
|
|
:data="data"
|
||
|
|
:columns="columns"
|
||
|
|
:pagination="pagination"
|
||
|
|
@selection-change="onTableSelectionChange"
|
||
|
|
@pagination:size-change="handleSizeChange"
|
||
|
|
@pagination:current-change="handleCurrentChange"
|
||
|
|
/>
|
||
|
|
</ElCard>
|
||
|
|
|
||
|
|
<FaDialog
|
||
|
|
v-model="dialogVisible.visible"
|
||
|
|
:title="dialogVisible.title"
|
||
|
|
width="920px"
|
||
|
|
dialog-class="crud-embed-dialog"
|
||
|
|
modal-class="crud-embed-dialog"
|
||
|
|
:form-mode="dialogVisible.type"
|
||
|
|
:confirm-loading="submitLoading"
|
||
|
|
:close-on-click-modal="false"
|
||
|
|
@cancel="crud.handleCloseDialog"
|
||
|
|
@close="crud.handleCloseDialog"
|
||
|
|
@confirm="crud.handleSubmit"
|
||
|
|
>
|
||
|
|
<template v-if="dialogVisible.type === 'detail'">
|
||
|
|
<FaDescriptions
|
||
|
|
:column="4"
|
||
|
|
:data="detailFormData"
|
||
|
|
:items="PollinationDetailItems"
|
||
|
|
max-height="70vh"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
<template v-else>
|
||
|
|
<FaForm
|
||
|
|
:key="PollinationFormRenderKey"
|
||
|
|
scrollbar
|
||
|
|
max-height="70vh"
|
||
|
|
ref="dataFormRef"
|
||
|
|
v-model="formData"
|
||
|
|
:items="PollinationDialogFormItems"
|
||
|
|
:rules="rules"
|
||
|
|
label-suffix=":"
|
||
|
|
:label-width="120"
|
||
|
|
label-position="right"
|
||
|
|
:span="12"
|
||
|
|
:gutter="16"
|
||
|
|
:show-reset="false"
|
||
|
|
:show-submit="false"
|
||
|
|
class="crud-dialog-art-form"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
</FaDialog>
|
||
|
|
|
||
|
|
<FaImportDialog
|
||
|
|
v-model="importVisible"
|
||
|
|
:content-config="PollinationImportContentConfig"
|
||
|
|
default-template-file-name="pollination_import_template.xlsx"
|
||
|
|
@upload="handleCrudImportUpload"
|
||
|
|
/>
|
||
|
|
|
||
|
|
<FaExportDialog
|
||
|
|
v-model="exportVisible"
|
||
|
|
:content-config="PollinationExportContentConfig"
|
||
|
|
:query-params="exportQueryParams"
|
||
|
|
:page-data="data"
|
||
|
|
:selection-data="selectedRows"
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import type { TableOperationAction } from "@/utils/table";
|
||
|
|
import { renderTableOperationCell, stripPaginationParams, toCrudCols } from "@utils";
|
||
|
|
import { useCrudForm } from "@/hooks/core/useCrudForm";
|
||
|
|
import { ResultEnum } from "@/enums/api/result.enum";
|
||
|
|
import type { IContentConfig, IObject } from "@/components/modal/types";
|
||
|
|
import type { AuditSearchFormParams } from "@/components/forms/fa-search-bar/auditSearchFormItems";
|
||
|
|
import type { FormItem } from "@/components/forms/fa-form/index.vue";
|
||
|
|
import CrossCombinationAPI, { type CrossCombinationOption } from "@/api/module_bre/cross_combination";
|
||
|
|
import PlotAPI, { type PlotOption } from "@/api/module_bre/plot";
|
||
|
|
import PersonnelAPI, { type PersonnelOption } from "@/api/module_bre/personnel";
|
||
|
|
import PollinationAPI, { type PollinationForm, type PollinationPageQuery, type PollinationTable } from "@/api/module_bre/pollination";
|
||
|
|
import type { ColumnOption } from "@/types/component";
|
||
|
|
import FaDescriptions from "@/components/others/fa-descriptions/index.vue";
|
||
|
|
import FaForm from "@/components/forms/fa-form/index.vue";
|
||
|
|
import FaTableHeader from "@/components/tables/fa-table-header/index.vue";
|
||
|
|
|
||
|
|
defineOptions({
|
||
|
|
name: "Pollination",
|
||
|
|
inheritAttrs: false,
|
||
|
|
});
|
||
|
|
|
||
|
|
const cross_combinationOptions = ref<CrossCombinationOption[]>([]);
|
||
|
|
const plotOptions = ref<PlotOption[]>([]);
|
||
|
|
const personnelOptions = ref<PersonnelOption[]>([]);
|
||
|
|
|
||
|
|
const cross_combinationOptionsMap = computed(() => {
|
||
|
|
const m: Record<number, string> = {};
|
||
|
|
for (const o of cross_combinationOptions.value) m[o.value] = o.label;
|
||
|
|
return m;
|
||
|
|
});
|
||
|
|
const plotOptionsMap = computed(() => {
|
||
|
|
const m: Record<number, string> = {};
|
||
|
|
for (const o of plotOptions.value) m[o.value] = o.label;
|
||
|
|
return m;
|
||
|
|
});
|
||
|
|
const personnelOptionsMap = computed(() => {
|
||
|
|
const m: Record<number, string> = {};
|
||
|
|
for (const o of personnelOptions.value) m[o.value] = o.label;
|
||
|
|
return m;
|
||
|
|
});
|
||
|
|
|
||
|
|
async function loadCrossCombinationOptions() {
|
||
|
|
try {
|
||
|
|
const res = await CrossCombinationAPI.getCrossCombinationOptions();
|
||
|
|
if (res.data.code === ResultEnum.SUCCESS) {
|
||
|
|
cross_combinationOptions.value = res.data.data ?? [];
|
||
|
|
}
|
||
|
|
} catch (error: unknown) {
|
||
|
|
if (import.meta.env.DEV) console.error("[Pollination] loadCrossCombinationOptions", error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
async function loadPlotOptions() {
|
||
|
|
try {
|
||
|
|
const res = await PlotAPI.getPlotOptions();
|
||
|
|
if (res.data.code === ResultEnum.SUCCESS) {
|
||
|
|
plotOptions.value = res.data.data ?? [];
|
||
|
|
}
|
||
|
|
} catch (error: unknown) {
|
||
|
|
if (import.meta.env.DEV) console.error("[Pollination] loadPlotOptions", error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
async function loadPersonnelOptions() {
|
||
|
|
try {
|
||
|
|
const res = await PersonnelAPI.getPersonnelOptions();
|
||
|
|
if (res.data.code === ResultEnum.SUCCESS) {
|
||
|
|
personnelOptions.value = res.data.data ?? [];
|
||
|
|
}
|
||
|
|
} catch (error: unknown) {
|
||
|
|
if (import.meta.env.DEV) console.error("[Pollination] loadPersonnelOptions", error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const createInitialFormData = (): PollinationForm => ({
|
||
|
|
id: undefined,
|
||
|
|
combination_id: undefined,
|
||
|
|
plot_id: undefined,
|
||
|
|
pollination_date: undefined,
|
||
|
|
flower_count: undefined,
|
||
|
|
effective_count: undefined,
|
||
|
|
bre_personnel_id: undefined,
|
||
|
|
remark: undefined,
|
||
|
|
});
|
||
|
|
|
||
|
|
type PollinationSearchFormParams = {
|
||
|
|
combination_id?: number;
|
||
|
|
plot_id?: number;
|
||
|
|
bre_personnel_id?: number;
|
||
|
|
} & AuditSearchFormParams;
|
||
|
|
|
||
|
|
const searchForm = ref<PollinationSearchFormParams>({
|
||
|
|
combination_id: undefined,
|
||
|
|
plot_id: undefined,
|
||
|
|
bre_personnel_id: undefined,
|
||
|
|
created_id: undefined,
|
||
|
|
updated_id: undefined,
|
||
|
|
created_time: [],
|
||
|
|
updated_time: [],
|
||
|
|
});
|
||
|
|
|
||
|
|
const showSearchBar = ref(true);
|
||
|
|
const searchBarRef = ref<{ validate: () => Promise<boolean> } | null>(null);
|
||
|
|
const searchBarRules: Record<string, unknown> = {};
|
||
|
|
|
||
|
|
const PollinationSearchItems = computed(() => [
|
||
|
|
{
|
||
|
|
label: "杂交组合",
|
||
|
|
key: "combination_id",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择杂交组合",
|
||
|
|
options: cross_combinationOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 8,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "试验地块",
|
||
|
|
key: "plot_id",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择试验地块",
|
||
|
|
options: plotOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 8,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
label: "授粉人",
|
||
|
|
key: "bre_personnel_id",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择授粉人",
|
||
|
|
options: personnelOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 8,
|
||
|
|
},
|
||
|
|
]);
|
||
|
|
|
||
|
|
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||
|
|
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } = useTableSelection<PollinationTable>();
|
||
|
|
|
||
|
|
const createLoading = ref(false);
|
||
|
|
|
||
|
|
const {
|
||
|
|
columns,
|
||
|
|
columnChecks,
|
||
|
|
data,
|
||
|
|
loading,
|
||
|
|
pagination,
|
||
|
|
searchParams,
|
||
|
|
getData,
|
||
|
|
replaceSearchParams,
|
||
|
|
resetSearchParams,
|
||
|
|
handleSizeChange,
|
||
|
|
handleCurrentChange,
|
||
|
|
refreshData,
|
||
|
|
refreshCreate,
|
||
|
|
refreshUpdate,
|
||
|
|
refreshRemove,
|
||
|
|
} = useTable({
|
||
|
|
core: {
|
||
|
|
apiFn: PollinationAPI.getPollinationList,
|
||
|
|
apiParams: {
|
||
|
|
page_no: 1,
|
||
|
|
page_size: 10,
|
||
|
|
},
|
||
|
|
columnsFactory: (): ColumnOption<PollinationTable>[] => [
|
||
|
|
{ type: "globalIndex", width: 56, label: "序号" },
|
||
|
|
{ type: "selection", width: 48, fixed: "left" },
|
||
|
|
{ prop: "combination_name", label: "杂交组合", minWidth: 140, showOverflowTooltip: true },
|
||
|
|
{ prop: "plot_name", label: "试验地块", minWidth: 140, showOverflowTooltip: true },
|
||
|
|
{ prop: "pollination_date", label: "授粉日期", minWidth: 140, showOverflowTooltip: true },
|
||
|
|
{ prop: "flower_count", label: "花朵数", minWidth: 100 },
|
||
|
|
{ prop: "effective_count", label: "有效坐果数", minWidth: 100 },
|
||
|
|
{ prop: "bre_personnel_name", label: "授粉人", minWidth: 140, showOverflowTooltip: true },
|
||
|
|
{
|
||
|
|
prop: "created_time",
|
||
|
|
label: "创建时间",
|
||
|
|
width: 168,
|
||
|
|
sortable: true,
|
||
|
|
showOverflowTooltip: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
prop: "updated_time",
|
||
|
|
label: "更新时间",
|
||
|
|
width: 168,
|
||
|
|
sortable: true,
|
||
|
|
showOverflowTooltip: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
prop: "created_by",
|
||
|
|
label: "创建人",
|
||
|
|
minWidth: 100,
|
||
|
|
formatter: (row: PollinationTable) => row.created_by?.name ?? "—",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
prop: "updated_by",
|
||
|
|
label: "更新人",
|
||
|
|
minWidth: 100,
|
||
|
|
formatter: (row: PollinationTable) => row.updated_by?.name ?? "—",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
prop: "operation",
|
||
|
|
label: "操作",
|
||
|
|
width: 180,
|
||
|
|
fixed: "right",
|
||
|
|
align: "center",
|
||
|
|
formatter: (row: PollinationTable) => formatPollinationOperationCell(row),
|
||
|
|
},
|
||
|
|
],
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
const PollinationCrudCols = toCrudCols(columns);
|
||
|
|
|
||
|
|
const exportQueryParams = computed(() => {
|
||
|
|
return stripPaginationParams(searchParams as Record<string, unknown>);
|
||
|
|
});
|
||
|
|
|
||
|
|
const PollinationImportContentConfig = computed<IContentConfig>(() => ({
|
||
|
|
permPrefix: "module_bre:pollination",
|
||
|
|
cols: PollinationCrudCols.value,
|
||
|
|
indexAction: async () => ({}),
|
||
|
|
importTemplate: () => PollinationAPI.downloadTemplatePollination(),
|
||
|
|
}));
|
||
|
|
|
||
|
|
const PollinationExportContentConfig = computed(() => ({
|
||
|
|
permPrefix: "module_bre:pollination",
|
||
|
|
cols: PollinationCrudCols.value,
|
||
|
|
exportsBlobAction: async (params: IObject) => {
|
||
|
|
const merged = {
|
||
|
|
...(exportQueryParams.value as unknown as Record<string, unknown>),
|
||
|
|
...params,
|
||
|
|
} as unknown as PollinationPageQuery;
|
||
|
|
const res = await PollinationAPI.exportPollination(merged);
|
||
|
|
return res.data as Blob;
|
||
|
|
},
|
||
|
|
}));
|
||
|
|
|
||
|
|
const { dialogVisible } = useCrudDialog();
|
||
|
|
|
||
|
|
const detailFormData = ref<PollinationTable>({});
|
||
|
|
|
||
|
|
const PollinationDetailItems: import("@/components/others/fa-descriptions/index.vue").DescriptionsItem[] = [
|
||
|
|
{ label: "杂交组合", prop: "combination_name" },
|
||
|
|
{ label: "试验地块", prop: "plot_name" },
|
||
|
|
{ label: "授粉日期", prop: "pollination_date" },
|
||
|
|
{ label: "花朵数", prop: "flower_count" },
|
||
|
|
{ label: "有效坐果数", prop: "effective_count" },
|
||
|
|
{ label: "授粉人", prop: "bre_personnel_name" },
|
||
|
|
{ label: "备注", prop: "remark" },
|
||
|
|
{ label: "UUID", prop: "uuid" },
|
||
|
|
{ label: "创建人", prop: "created_by.name" },
|
||
|
|
{ label: "更新人", prop: "updated_by.name" },
|
||
|
|
{ label: "创建时间", prop: "created_time" },
|
||
|
|
{ label: "更新时间", prop: "updated_time" },
|
||
|
|
];
|
||
|
|
|
||
|
|
const PollinationDialogFormItems = computed<FormItem[]>(() => [
|
||
|
|
{
|
||
|
|
key: "combination_id",
|
||
|
|
label: "杂交组合",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择杂交组合",
|
||
|
|
options: cross_combinationOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "plot_id",
|
||
|
|
label: "试验地块",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择试验地块",
|
||
|
|
options: plotOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "pollination_date",
|
||
|
|
label: "授粉日期",
|
||
|
|
type: "date",
|
||
|
|
props: {
|
||
|
|
type: "date",
|
||
|
|
placeholder: "请选择授粉日期",
|
||
|
|
},
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "flower_count",
|
||
|
|
label: "花朵数",
|
||
|
|
type: "number",
|
||
|
|
props: { placeholder: "请输入花朵数" },
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "effective_count",
|
||
|
|
label: "有效坐果数",
|
||
|
|
type: "number",
|
||
|
|
props: { placeholder: "请输入有效坐果数" },
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "bre_personnel_id",
|
||
|
|
label: "授粉人",
|
||
|
|
type: "select",
|
||
|
|
props: {
|
||
|
|
placeholder: "请选择授粉人",
|
||
|
|
options: personnelOptions.value,
|
||
|
|
clearable: true,
|
||
|
|
filterable: true,
|
||
|
|
},
|
||
|
|
span: 12,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "remark",
|
||
|
|
label: "备注",
|
||
|
|
type: "input",
|
||
|
|
props: { type: "textarea", rows: 3, placeholder: "请输入备注" },
|
||
|
|
span: 24,
|
||
|
|
},
|
||
|
|
]);
|
||
|
|
|
||
|
|
const formData = ref<PollinationForm>(createInitialFormData());
|
||
|
|
|
||
|
|
const rules = reactive({
|
||
|
|
combination_id: [{ required: true, message: "请选择杂交组合", trigger: "change" }],
|
||
|
|
});
|
||
|
|
|
||
|
|
const dataFormRef = ref<InstanceType<typeof FaForm> | null>(null);
|
||
|
|
const PollinationFormRenderKey = ref(0);
|
||
|
|
|
||
|
|
const crud = useCrudForm<PollinationForm>({
|
||
|
|
formData,
|
||
|
|
initialFormData: createInitialFormData(),
|
||
|
|
dialogVisible,
|
||
|
|
dataFormRef,
|
||
|
|
formRenderKey: PollinationFormRenderKey,
|
||
|
|
detailApi: PollinationAPI.getPollinationDetail,
|
||
|
|
createApi: PollinationAPI.createPollination,
|
||
|
|
updateApi: PollinationAPI.updatePollination,
|
||
|
|
titles: { create: "新增授粉管理", update: "修改授粉管理", detail: "授粉管理详情" },
|
||
|
|
detailFormData,
|
||
|
|
onCreateSuccess: async () => {
|
||
|
|
await refreshCreate();
|
||
|
|
},
|
||
|
|
onUpdateSuccess: async () => {
|
||
|
|
await refreshUpdate();
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
const { submitLoading } = crud;
|
||
|
|
|
||
|
|
const { importVisible, exportVisible, openImport, openExport } = useImportExport();
|
||
|
|
|
||
|
|
const handleSearch = async (params: PollinationSearchFormParams) => {
|
||
|
|
await searchBarRef.value?.validate();
|
||
|
|
replaceSearchParams({
|
||
|
|
combination_id: params.combination_id,
|
||
|
|
plot_id: params.plot_id,
|
||
|
|
bre_personnel_id: params.bre_personnel_id,
|
||
|
|
created_id: params.created_id ?? undefined,
|
||
|
|
updated_id: params.updated_id ?? undefined,
|
||
|
|
created_time:
|
||
|
|
Array.isArray(params.created_time) && params.created_time.length === 2
|
||
|
|
? params.created_time
|
||
|
|
: undefined,
|
||
|
|
updated_time:
|
||
|
|
Array.isArray(params.updated_time) && params.updated_time.length === 2
|
||
|
|
? params.updated_time
|
||
|
|
: undefined,
|
||
|
|
} as Record<string, unknown>);
|
||
|
|
await getData();
|
||
|
|
};
|
||
|
|
|
||
|
|
const onResetSearch = async () => {
|
||
|
|
searchForm.value = {
|
||
|
|
combination_id: undefined,
|
||
|
|
plot_id: undefined,
|
||
|
|
bre_personnel_id: undefined,
|
||
|
|
created_id: undefined,
|
||
|
|
updated_id: undefined,
|
||
|
|
created_time: [],
|
||
|
|
updated_time: [],
|
||
|
|
};
|
||
|
|
await resetSearchParams();
|
||
|
|
};
|
||
|
|
|
||
|
|
function buildPollinationRowActions(row: PollinationTable): TableOperationAction[] {
|
||
|
|
const all: TableOperationAction[] = [
|
||
|
|
{
|
||
|
|
key: "detail",
|
||
|
|
label: "详情",
|
||
|
|
artType: "view",
|
||
|
|
perm: "module_bre:pollination:detail",
|
||
|
|
run: () => void crud.handleOpenDialog("detail", row.id),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "edit",
|
||
|
|
label: "编辑",
|
||
|
|
artType: "edit",
|
||
|
|
icon: "ri:edit-2-line",
|
||
|
|
perm: "module_bre:pollination:update",
|
||
|
|
run: () => void crud.handleOpenDialog("update", row.id),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: "delete",
|
||
|
|
label: "删除",
|
||
|
|
artType: "delete",
|
||
|
|
icon: "ri:delete-bin-4-line",
|
||
|
|
perm: "module_bre:pollination:delete",
|
||
|
|
run: () => deletePollinationRow(row),
|
||
|
|
},
|
||
|
|
];
|
||
|
|
return all;
|
||
|
|
}
|
||
|
|
|
||
|
|
function formatPollinationOperationCell(row: PollinationTable) {
|
||
|
|
return renderTableOperationCell(buildPollinationRowActions(row), {
|
||
|
|
wrapperClass: "inline-flex flex-wrap items-center justify-end gap-1",
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
async function handleAdd() {
|
||
|
|
createLoading.value = true;
|
||
|
|
try {
|
||
|
|
await crud.handleOpenDialog("create");
|
||
|
|
} finally {
|
||
|
|
createLoading.value = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const deletePollinationRow = async (row: PollinationTable) => {
|
||
|
|
if (!row.id) return;
|
||
|
|
try {
|
||
|
|
await confirmDelete(`确定删除「${row.id ?? row.id}」吗?此操作不可恢复!`);
|
||
|
|
await PollinationAPI.deletePollination([row.id!]);
|
||
|
|
faTableRef.value?.elTableRef?.clearSelection();
|
||
|
|
await refreshRemove();
|
||
|
|
} catch {
|
||
|
|
// 用户取消
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
async function handleBatchDelete() {
|
||
|
|
const ids = selectedIds.value;
|
||
|
|
if (ids.length === 0) return;
|
||
|
|
try {
|
||
|
|
await confirmBatchDelete(ids.length);
|
||
|
|
batchDeleting.value = true;
|
||
|
|
await PollinationAPI.deletePollination(ids);
|
||
|
|
faTableRef.value?.elTableRef?.clearSelection();
|
||
|
|
await refreshRemove();
|
||
|
|
} catch {
|
||
|
|
// 用户取消
|
||
|
|
} finally {
|
||
|
|
batchDeleting.value = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function handleCrudImportUpload(uploadFormData: FormData) {
|
||
|
|
try {
|
||
|
|
const res = await PollinationAPI.importPollination(uploadFormData);
|
||
|
|
if (res.data.code === ResultEnum.SUCCESS) {
|
||
|
|
ElMessage.success(res.data.msg || "导入成功");
|
||
|
|
importVisible.value = false;
|
||
|
|
await refreshData();
|
||
|
|
}
|
||
|
|
} catch (error: unknown) {
|
||
|
|
if (import.meta.env.DEV) console.error("[Import]", error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
onMounted(() => {
|
||
|
|
loadCrossCombinationOptions();
|
||
|
|
loadPlotOptions();
|
||
|
|
loadPersonnelOptions();
|
||
|
|
});
|
||
|
|
</script>
|