新增可选择默认

This commit is contained in:
2026-05-25 14:35:15 +08:00
parent d8bd66ed20
commit fee7aa6f46
1 changed files with 17 additions and 55 deletions

View File

@ -1,20 +1,10 @@
<template> <template>
<div class="variety table_form-container"> <div class="variety table_form-container">
<!-- 搜索 --> <!-- 搜索 -->
<VarietySearch <VarietySearch :search-form="searchForm" :buttonLoading="loading" :search-options="searchOptions"
:search-form="searchForm" @search="handleSearch" @reset="handleReset">
:buttonLoading="loading"
:search-options="searchOptions"
@search="handleSearch"
@reset="handleReset"
>
<template #button="{ form }"> <template #button="{ form }">
<el-button <el-button type="primary" :disabled="!selectedRow" @click="handleEdit()" v-auth="'contractVariety_editVariety'">
type="primary"
:disabled="!selectedRow"
@click="handleEdit()"
v-auth="'contractVariety_editVariety'"
>
编辑 编辑
</el-button> </el-button>
<el-button type="primary" @click="handleAdd()" v-auth="'contractVariety_createVariety'"> <el-button type="primary" @click="handleAdd()" v-auth="'contractVariety_createVariety'">
@ -24,13 +14,8 @@
</VarietySearch> </VarietySearch>
<!-- 表格 --> <!-- 表格 -->
<VarietyTable <VarietyTable :table-data="varietyTree" :columns="varietyTableColumnsOptions" row-key="id"
:table-data="varietyTree" @row-click="handleRowClick" :loading="loading">
:columns="varietyTableColumnsOptions"
row-key="id"
@row-click="handleRowClick"
:loading="loading"
>
<template #onlineStatus="{ row }"> <template #onlineStatus="{ row }">
{{ ['', '上线', '下线'][row.onlineStatus] }} {{ ['', '上线', '下线'][row.onlineStatus] }}
</template> </template>
@ -40,44 +25,18 @@
</VarietyTable> </VarietyTable>
</div> </div>
<!-- dialog --> <!-- dialog -->
<VarietyDialog <VarietyDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" :button-loading="submitLoading"
:visible="dialogVisible" @confirm="handleSubmit" @cancel="handleCancel" @close="handleClose">
:title="dialogTitle" <VarietyForm :form-data="varietyForm" :form-rules="varietyFormRules" :form-items="dialogFormItemOptions"
:type="dialogType" :options-map="varietyFormOptionsMap" :row-gutter="rowGutter" :col-span="colSpan" ref="varietyFormRef">
:button-loading="submitLoading"
@confirm="handleSubmit"
@cancel="handleCancel"
@close="handleClose"
>
<VarietyForm
:form-data="varietyForm"
:form-rules="varietyFormRules"
:form-items="dialogFormItemOptions"
:options-map="varietyFormOptionsMap"
:row-gutter="rowGutter"
:col-span="colSpan"
ref="varietyFormRef"
>
<template #upload="{ formData }"> <template #upload="{ formData }">
<el-upload <el-upload ref="uploadRef" v-model:file-list="fileList" class="upload-demo" :http-request="handleUpload"
ref="uploadRef" :before-upload="beforeUpload" :limit="1" :on-exceed="handleExceed">
v-model:file-list="fileList"
class="upload-demo"
:http-request="handleUpload"
:before-upload="beforeUpload"
:limit="1"
:on-exceed="handleExceed"
>
<el-button type="primary">点击上传</el-button> <el-button type="primary">点击上传</el-button>
<template #tip> <template #tip>
<div class="el-upload__tip">jpg/png格式 图片大小不能超过20KB</div> <div class="el-upload__tip">jpg/png格式 图片大小不能超过20KB</div>
</template> </template>
<img <img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片" style="width: 100px; height: 100px" />
v-if="dialogType === 'edit'"
:src="formData.imageUrl"
alt="预览图片"
style="width: 100px; height: 100px"
/>
</el-upload> </el-upload>
</template> </template>
<template #isDefault="{ formData }"> <template #isDefault="{ formData }">
@ -409,7 +368,7 @@ const handleExceed = (files: File[]) => {
if (file) { if (file) {
uploadRef.value?.handleStart(file) // uploadRef.value?.handleStart(file) //
// http-request // http-request
handleUpload({ file, onSuccess: () => {}, onError: () => {} }) handleUpload({ file, onSuccess: () => { }, onError: () => { } })
} }
} }
@ -485,7 +444,10 @@ const handleSubmit = async () => {
}) })
await getVarietyList() await getVarietyList()
} else { } else {
await createVarietyApi({ ...params }) await createVarietyApi({
...params,
is_default: varietyForm.value.isDefault,
})
await getVarietyList() await getVarietyList()
} }
dialogVisible.value = false dialogVisible.value = false