This commit is contained in:
@@ -8,6 +8,13 @@ export function getList(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getAll() {
|
||||
return request({
|
||||
url: '/management/api/spring/avatar-category/all',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: '/management/api/spring/avatar-category',
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
@upload-success="handleUploadSuccess"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择分类" style="width: 100%">
|
||||
<el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-input v-model.trim="form.type" placeholder="请输入类型" />
|
||||
</el-form-item>
|
||||
@@ -26,6 +31,7 @@
|
||||
|
||||
<script>
|
||||
import { doEdit, doAdd } from '@/api/spring/avatar'
|
||||
import { getAll } from '@/api/spring/avatar/category'
|
||||
import SingleUpload from '@/components/SingleUpload'
|
||||
|
||||
export default {
|
||||
@@ -34,14 +40,17 @@
|
||||
data() {
|
||||
return {
|
||||
id: '',
|
||||
categoryList: [],
|
||||
form: {
|
||||
imageUrl: '',
|
||||
type: '',
|
||||
categoryId: '',
|
||||
isEnabled: true,
|
||||
},
|
||||
rules: {
|
||||
imageUrl: [{ required: true, trigger: 'blur', message: '请上传头像图片' }],
|
||||
isEnabled: [{ required: true, trigger: 'blur', message: '请选择是否启用' }],
|
||||
categoryId: [{ required: true, trigger: 'change', message: '请选择分类' }],
|
||||
},
|
||||
title: '',
|
||||
dialogFormVisible: false,
|
||||
@@ -52,8 +61,14 @@
|
||||
return `${process.env.VUE_APP_API_BASE_URL}/management/api/common/upload`
|
||||
},
|
||||
},
|
||||
created() {},
|
||||
created() {
|
||||
this.fetchCategoryList()
|
||||
},
|
||||
methods: {
|
||||
async fetchCategoryList() {
|
||||
const { data } = await getAll()
|
||||
this.categoryList = data
|
||||
},
|
||||
handleUploadSuccess(url) {
|
||||
this.form.imageUrl = url
|
||||
},
|
||||
@@ -65,6 +80,7 @@
|
||||
this.form = {
|
||||
imageUrl: row.imageUrl,
|
||||
type: row.type,
|
||||
categoryId: row.categoryId,
|
||||
isEnabled: row.isEnabled,
|
||||
}
|
||||
this.id = row.id
|
||||
|
||||
Reference in New Issue
Block a user