新增可选择默认
This commit is contained in:
parent
d8bd66ed20
commit
fee7aa6f46
|
|
@ -1,20 +1,10 @@
|
|||
<template>
|
||||
<div class="variety table_form-container">
|
||||
<!-- 搜索 -->
|
||||
<VarietySearch
|
||||
:search-form="searchForm"
|
||||
:buttonLoading="loading"
|
||||
:search-options="searchOptions"
|
||||
@search="handleSearch"
|
||||
@reset="handleReset"
|
||||
>
|
||||
<VarietySearch :search-form="searchForm" :buttonLoading="loading" :search-options="searchOptions"
|
||||
@search="handleSearch" @reset="handleReset">
|
||||
<template #button="{ form }">
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!selectedRow"
|
||||
@click="handleEdit()"
|
||||
v-auth="'contractVariety_editVariety'"
|
||||
>
|
||||
<el-button type="primary" :disabled="!selectedRow" @click="handleEdit()" v-auth="'contractVariety_editVariety'">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleAdd()" v-auth="'contractVariety_createVariety'">
|
||||
|
|
@ -24,13 +14,8 @@
|
|||
</VarietySearch>
|
||||
|
||||
<!-- 表格 -->
|
||||
<VarietyTable
|
||||
:table-data="varietyTree"
|
||||
:columns="varietyTableColumnsOptions"
|
||||
row-key="id"
|
||||
@row-click="handleRowClick"
|
||||
:loading="loading"
|
||||
>
|
||||
<VarietyTable :table-data="varietyTree" :columns="varietyTableColumnsOptions" row-key="id"
|
||||
@row-click="handleRowClick" :loading="loading">
|
||||
<template #onlineStatus="{ row }">
|
||||
{{ ['', '上线', '下线'][row.onlineStatus] }}
|
||||
</template>
|
||||
|
|
@ -40,44 +25,18 @@
|
|||
</VarietyTable>
|
||||
</div>
|
||||
<!-- dialog -->
|
||||
<VarietyDialog
|
||||
:visible="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
:type="dialogType"
|
||||
: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"
|
||||
>
|
||||
<VarietyDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" :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 }">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
v-model:file-list="fileList"
|
||||
class="upload-demo"
|
||||
:http-request="handleUpload"
|
||||
:before-upload="beforeUpload"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
>
|
||||
<el-upload ref="uploadRef" 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>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">jpg/png格式 图片大小不能超过20KB</div>
|
||||
</template>
|
||||
<img
|
||||
v-if="dialogType === 'edit'"
|
||||
:src="formData.imageUrl"
|
||||
alt="预览图片"
|
||||
style="width: 100px; height: 100px"
|
||||
/>
|
||||
<img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片" style="width: 100px; height: 100px" />
|
||||
</el-upload>
|
||||
</template>
|
||||
<template #isDefault="{ formData }">
|
||||
|
|
@ -409,7 +368,7 @@ const handleExceed = (files: File[]) => {
|
|||
if (file) {
|
||||
uploadRef.value?.handleStart(file) // 手动加入文件队列
|
||||
// 手动调用上传(因为 http-request 是自定义的)
|
||||
handleUpload({ file, onSuccess: () => {}, onError: () => {} })
|
||||
handleUpload({ file, onSuccess: () => { }, onError: () => { } })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -485,7 +444,10 @@ const handleSubmit = async () => {
|
|||
})
|
||||
await getVarietyList()
|
||||
} else {
|
||||
await createVarietyApi({ ...params })
|
||||
await createVarietyApi({
|
||||
...params,
|
||||
is_default: varietyForm.value.isDefault,
|
||||
})
|
||||
await getVarietyList()
|
||||
}
|
||||
dialogVisible.value = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue