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