|
@@ -184,7 +184,18 @@ const rules = {
|
|
|
}
|
|
}
|
|
|
const { showEditDialog } = setupEditDialog(model)
|
|
const { showEditDialog } = setupEditDialog(model)
|
|
|
async function onEdit(row) {
|
|
async function onEdit(row) {
|
|
|
|
|
+ if (!categories.value.length) {
|
|
|
|
|
+ await fetchCategories()
|
|
|
|
|
+ }
|
|
|
model.value = row ? await http.get(`/series/${row.id}`) : {}
|
|
model.value = row ? await http.get(`/series/${row.id}`) : {}
|
|
|
|
|
+ if (Array.isArray(model.value.categories)) {
|
|
|
|
|
+ const isIdArray = model.value.categories.length > 0 && typeof model.value.categories[0] !== 'object'
|
|
|
|
|
+ if (isIdArray) {
|
|
|
|
|
+ model.value.categories = model.value.categories
|
|
|
|
|
+ .map((cid) => categories.value.find((c) => c.id === cid))
|
|
|
|
|
+ .filter(Boolean)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
showEditDialog.value = true
|
|
showEditDialog.value = true
|
|
|
}
|
|
}
|
|
|
async function submit() {
|
|
async function submit() {
|
|
@@ -196,6 +207,17 @@ async function submit() {
|
|
|
ElMessage.success('保存成功')
|
|
ElMessage.success('保存成功')
|
|
|
}
|
|
}
|
|
|
const categories = ref([])
|
|
const categories = ref([])
|
|
|
|
|
+async function fetchCategories() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await http.get('/categories', { order: 'sort', pageSize: 1000 })
|
|
|
|
|
+ categories.value = Array.isArray(res) ? res : res?.data || []
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ categories.value = []
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ fetchCategories()
|
|
|
|
|
+})
|
|
|
const showUploadDialog = ref(false)
|
|
const showUploadDialog = ref(false)
|
|
|
const uploading = ref(false)
|
|
const uploading = ref(false)
|
|
|
const uploadingVideo = ref(false)
|
|
const uploadingVideo = ref(false)
|