提交 aff0826a authored 作者: lihuihui's avatar lihuihui
......@@ -134,7 +134,6 @@
"useDisplayMedia": true,
"useDocumentVisibility": true,
"useDraggable": true,
"useDropZone": true,
"useElementBounding": true,
"useElementByPoint": true,
"useElementHover": true,
......
......@@ -135,7 +135,6 @@ declare global {
const useDisplayMedia: typeof import('@vueuse/core')['useDisplayMedia']
const useDocumentVisibility: typeof import('@vueuse/core')['useDocumentVisibility']
const useDraggable: typeof import('@vueuse/core')['useDraggable']
const useDropZone: typeof import('@vueuse/core')['useDropZone']
const useElementBounding: typeof import('@vueuse/core')['useElementBounding']
const useElementByPoint: typeof import('@vueuse/core')['useElementByPoint']
const useElementHover: typeof import('@vueuse/core')['useElementHover']
......
......@@ -7,10 +7,9 @@ export function getCategoryList(params: { type: string }) {
// 新建分类
export function createCategory(data: {
category_name: string
depth?: string
status: string
need_pass: string
parent_id: string
status?: string
need_pass?: string
parent_id?: string
}) {
return httpRequest.post('/api/resource/v1/backend/category/create', data)
}
......@@ -18,7 +17,6 @@ export function createCategory(data: {
export function updateCategory(data: {
id: string
category_name: string
depth?: string
status: string
need_pass: string
parent_id: string
......
<script lang="ts" setup>
import { createCategory, updateCategory } from '../api'
import { ElMessage } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import type { FormRules } from 'element-plus'
import TreeDialog from './TreeDialog.vue'
......@@ -14,12 +17,11 @@ const categoryForm = reactive({
parent_id: '',
category_name: '',
depth: 1,
name: '',
status: '0',
need_pass: '1'
})
const rules = reactive<FormRules>({
name: [
category_name: [
{ required: true, message: '请输入类别名称', trigger: 'blur' },
{ message: '请输入类别名称', trigger: 'blur' }
]
......@@ -53,7 +55,7 @@ const props = defineProps({
})
const emit = defineEmits<{
(e: 'update:dialogVisible', dialogVisible: false): void
(e: 'confirm', categoryForm: any): void
(e: 'updatePage'): void
}>()
// 打开类别选择弹框
......@@ -76,20 +78,27 @@ const handleCancel = () => {
}
// 确认提交表单
const handleConfirm = () => {
console.log(categoryForm.parent_id, '0000')
emit('update:dialogVisible', false)
emit('confirm', categoryForm)
if (props.isEdit) {
emit('confirm', { categoryForm, isUpdate: 1, id: props.editData.id })
const params = Object.assign({ id: props.editData.idd }, categoryForm)
updateCategory(params).then(() => {
ElMessage.success('更新类别成功')
emit('update:dialogVisible', false)
emit('updatePage')
})
} else {
emit('confirm', { categoryForm, isUpdate: 0 })
const params = Object.assign({}, categoryForm)
createCategory(params).then(() => {
ElMessage.success('新建类别成功')
emit('update:dialogVisible', false)
emit('updatePage')
})
}
}
onMounted(() => {
console.log(props.prevCategoryName, 'props.prevCategoryName')
categoryForm.depth = parseInt(props.editData.depth) + 1
categoryForm.parent_id = props.editData.id
categoryForm.depth = parseInt(props.editData?.depth) + 1 || 0
categoryForm.parent_id = props.editData?.id
categoryName.value = props.prevCategoryName
if (props.isEdit) {
categoryName.value = props.prevCategoryName
......
......@@ -3,7 +3,7 @@ import Sortable from 'sortablejs'
import type { MoveEvent, SortableEvent } from 'sortablejs'
import AddDialog from '../component/AddDialog.vue'
import { Operation } from '@element-plus/icons-vue'
import { getCategoryList, delCategory, createCategory, updateCategory, moveCategory } from '../api'
import { getCategoryList, delCategory, moveCategory } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import AppList from '@/components/base/AppList.vue'
......@@ -15,11 +15,11 @@ const dialogVisible = ref(false)
interface ICategory {
pid?: string
category_name: number
category_name: string
depth: string
id: string
lft: string
need_pass: string
lft?: string
need_pass?: string
rgt: string
status_name: string
children?: ICategory[]
......@@ -27,7 +27,7 @@ interface ICategory {
let tableData = $ref<ICategory[]>([])
const editData = ref({})
const isEdit = ref(false)
const handleEdit = (index: number, row: ICategory) => {
const handleEdit = (row: ICategory) => {
title.value = '编辑类别'
isEdit.value = true
dialogVisible.value = true
......@@ -39,17 +39,17 @@ const handleEdit = (index: number, row: ICategory) => {
}
}
// 删除分类
const handleDelete = (index: number, row: ICategory) => {
const handleDelete = (row: ICategory) => {
ElMessageBox.confirm('确定要删除吗?', '提示').then(() => {
const params = { id: row.id }
delCategory(params).then(() => {
ElMessage.success('删除成功')
handleCategoryList()
handleUpdate()
})
})
}
// 行内新增类别
const handleAddRow = (index: number, row: ICategory) => {
const handleAddRow = (row: ICategory) => {
isEdit.value = false
dialogVisible.value = true
title.value = '新增类别'
......@@ -60,13 +60,13 @@ const handleAddRow = (index: number, row: ICategory) => {
prevCategoryName.value = ''
}
}
// 外部新增类别
// // 外部新增类别
const handleAddCategory = () => {
isEdit.value = false
dialogVisible.value = true
title.value = '新增类别'
editData.value = tableData[0]
prevCategoryName.value = ''
prevCategoryName.value = tableData[0].category_name
}
// 获取上级类别
const getParent = (node: string, tree: any) => {
......@@ -86,26 +86,10 @@ const getParent = (node: string, tree: any) => {
}
// 获取分类列表
const handleCategoryList = () => {
const handleUpdate = () => {
appList?.refetch()
}
// 确定
const handleConfirm = (val: any) => {
console.log(val, 'val')
if (val.isUpdate === 1) {
const params = Object.assign({ id: val.id }, val.categoryForm)
updateCategory(params).then(() => {
ElMessage.success('更新类别成功')
handleCategoryList()
})
} else if (val.isUpdate === 0) {
const params = Object.assign({}, val.categoryForm)
createCategory(params).then(() => {
ElMessage.success('新建类别成功')
handleCategoryList()
})
}
}
// 扁平列表数据
let tableDataList = $ref<ICategory[]>([])
// 列表配置
......@@ -113,7 +97,8 @@ const listOptions = {
remote: {
httpRequest: getCategoryList,
params: { type: 'tree', category_name: '' },
callback(data: Record<string, any>[]) {
callback(data: ICategory[]) {
tableData = data
tableDataList = flatten(data)
return { list: data }
}
......@@ -162,7 +147,7 @@ function useSortable() {
const relatedRow = tableDataList[newIndex]
moveCategory({ id: draggedRow.id, brother_id: relatedRow.id, type: 'before' }).then(() => {
handleCategoryList()
handleUpdate()
})
}
})
......@@ -178,12 +163,20 @@ onMounted(() => {
<template #table-drag>
<el-icon><Operation /></el-icon>
</template>
<template #table-operate="scope">
<el-button type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button @click="handleAddRow(scope.$index, scope.row)">新增</el-button>
<el-button @click="handleDelete(scope.$index, scope.row)">删除</el-button>
<template #table-operate="{ row }">
<el-link type="primary" style="margin-right: 5px" @click="handleEdit(row)">编辑</el-link>
<el-link type="primary" style="margin-right: 5px" @click="handleAddRow(row)">新增</el-link>
<el-link type="primary" @click="handleDelete(row)">删除</el-link>
</template>
</AppList>
</AppCard>
<AddDialog v-model:dialogVisible="dialogVisible" @confirm="handleConfirm" :editData="editData" :isEdit="isEdit" :title="title" :prevCategoryName="prevCategoryName" v-if="dialogVisible" />
<AddDialog
v-model:dialogVisible="dialogVisible"
@updatePage="handleUpdate"
:editData="editData"
:isEdit="isEdit"
:title="title"
:prevCategoryName="prevCategoryName"
v-if="dialogVisible"
/>
</template>
......@@ -5,19 +5,14 @@ export function getCoverList(params?: { type?: string; page?: number; page_size?
return httpRequest.get('/api/resource/v1/backend/cover/list', { params })
}
// 创建封面
export function createCover(data?: { title?: string; status?: number; type?: number; url?: number }) {
export function createCover(data?: { title?: string; status?: string; type?: string; url?: string }) {
return httpRequest.post('/api/resource/v1/backend/cover/create', data)
}
// 更新封面
export function updateCover(data?: { title?: string; status?: number; type?: number; url?: number }) {
export function updateCover(data?: { id: any; title?: string; status?: string; type?: string; url?: string }) {
return httpRequest.post('/api/resource/v1/backend/cover/update', data)
}
// 删除封面
export function deleteCover(data: { id: any }) {
export function deleteCover(data: { id: string }) {
return httpRequest.post('/api/resource/v1/backend/cover/delete', data)
}
// 获取公共字典列表
export function getMapList() {
return httpRequest.get('/api/resource/v1/util/get-data-dictionary-list')
}
......@@ -2,6 +2,7 @@
import AppUpload from '@/components/base/AppUpload.vue'
import type { FormInstance, FormRules } from 'element-plus'
import { useMapStore } from '@/stores/map'
import { updateCover, createCover } from '../api'
const store = useMapStore()
const emit = defineEmits<Emits>()
const ruleFormRef = ref<FormInstance>()
......@@ -36,7 +37,7 @@ const props = defineProps({
})
interface Emits {
(e: 'update:isShowDialog', isShowDialog: boolean): void
(e: 'createCover', form: any): void
(e: 'updatePage'): void
}
// 取消
......@@ -45,12 +46,20 @@ const handleCancel = () => {
}
// 确定
const handleConfirm = () => {
emit('update:isShowDialog', false)
if (props.isEdit === true) {
emit('createCover', { form, isUpdate: 1, id: props.editData.id })
// emit('createCover', { form, isUpdate: 1, id: props.editData.id })
const params = Object.assign({ id: props.editData.id }, form)
updateCover(params).then(() => {
emit('update:isShowDialog', false)
emit('updatePage')
})
} else {
form.title = form.url
emit('createCover', { form, isUpdate: 0 })
const params = Object.assign({}, form)
createCover(params).then(() => {
emit('update:isShowDialog', false)
emit('updatePage')
})
}
}
......
<script setup lang="ts">
import { getCoverList, createCover, updateCover, deleteCover } from '../api'
import { getCoverList, deleteCover } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import AddDialog from '../component/AddDialog.vue'
......@@ -32,25 +32,13 @@ const handleDelete = (row: any) => {
const params: any = { id: row.id }
deleteCover(params).then(() => {
ElMessage.success('删除成功')
appList.value.refetch()
handleUpdate()
})
})
}
// 确定
const handleConfirm = (val: any) => {
if (val.isUpdate === 1) {
// 更新封面
const params = Object.assign({ id: val.id }, val.form)
updateCover(params).then(() => {
appList.value.refetch()
})
} else {
// 添加封面
const params = Object.assign({}, val.form)
createCover(params).then(() => {
// 刷新页面
const handleUpdate = () => {
appList.value.refetch()
})
}
}
// 添加
const handleAdd = () => {
......@@ -82,9 +70,9 @@ const handleEdit = (row: any) => {
<template v-if="isShowDialog === true">
<AddDialog
v-model:isShowDialog="isShowDialog"
@createCover="handleConfirm"
:editData="editData"
:isEdit="isEdit"
@updatePage="handleUpdate"
/>
</template>
</AppList>
......
......@@ -19,10 +19,10 @@ export function getDictionaryList(params?: {
// 新增字典
export function createDictionary(data: {
name: string
key: number
status: boolean
remark: string
can_edit: string
key: string
status?: string
remark?: string
can_edit?: string
}) {
return httpRequest.post('/api/resource/v1/backend/data-dictionary/create', data)
}
......@@ -30,10 +30,10 @@ export function createDictionary(data: {
export function updateDictionary(data: {
id: string
name: string
key: number
status: boolean
remark: string
can_edit: string
key: string
status?: string
remark?: string
can_edit?: string
}) {
return httpRequest.post('/api/resource/v1/backend/data-dictionary/update', data)
}
......@@ -48,8 +48,8 @@ export function getDictionaryItemList(params?: { data_dictionary_id: string; pag
// 新增字典的值
export function createDictionaryItem(data: {
data_dictionary_id: string
label: number
value: boolean
label: string
value: string
sort: string
remark: string
can_edit: string
......@@ -57,12 +57,12 @@ export function createDictionaryItem(data: {
}) {
return httpRequest.post('/api/resource/v1/backend/data-dictionary/value-create', data)
}
// 新增字典的值
// 更新字典的值
export function updateDictionaryItem(data: {
id: string
id: any
data_dictionary_id: string
label: number
value: boolean
label: string
value: string
sort: string
remark: string
can_edit: string
......
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { updateDictionary, createDictionary } from '../api'
import { useMapStore } from '@/stores/map'
import type { FormInstance, FormRules } from 'element-plus'
......@@ -9,7 +11,8 @@ const form = reactive({
name: '',
key: '',
status: '1',
remark: ''
remark: '',
can_edit: ''
})
const rules = reactive<FormRules>({
name: [{ required: true, message: '请输入字典名称', trigger: 'blur' }],
......@@ -31,7 +34,7 @@ const props = defineProps({
})
interface Emits {
(e: 'update:isShowDialog', isShowDialog: boolean): void
(e: 'confirm', form: object): void
(e: 'updatePage'): void
}
const emit = defineEmits<Emits>()
......@@ -47,11 +50,20 @@ const handleConfirm = async (formEl: FormInstance | undefined) => {
await formEl.validate(valid => {
if (valid) {
if (props.isEdit === true) {
const params = Object.assign({ id: props.rowInfo.id }, form)
updateDictionary(params).then(() => {
ElMessage.success('更新成功')
emit('update:isShowDialog', false)
emit('confirm', { form, isUpdate: 1, id: props.rowInfo.id })
emit('updatePage')
})
} else {
// 新增字典
const params = Object.assign({}, form)
createDictionary(params).then(() => {
ElMessage.success('新增成功')
emit('update:isShowDialog', false)
emit('confirm', { form, isUpdate: 0 })
emit('updatePage')
})
}
}
})
......
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { updateDictionaryItem, createDictionaryItem } from '../api'
import { useMapStore } from '@/stores/map'
import type { FormInstance, FormRules } from 'element-plus'
......@@ -43,11 +45,15 @@ const props = defineProps({
type: {
type: String,
required: true
},
dictionaryId: {
type: String,
required: true
}
})
interface Emits {
(e: 'update:isListAddDialog', isListAddDialog: boolean): void
(e: 'confirm', form: object): void
(e: 'updatePage'): void
}
const emit = defineEmits<Emits>()
......@@ -63,11 +69,23 @@ const handleConfirm = async (formEl: FormInstance | undefined) => {
await formEl.validate(valid => {
if (valid) {
if (props.isEdit === true) {
// emit('confirm', { form, isUpdate: 1, id: props.editData.id })
// 更新字典的值
const params = Object.assign({ id: props.editData.id, data_dictionary_id: props.dictionaryId }, form)
updateDictionaryItem(params).then(() => {
ElMessage.success('更新成功')
emit('update:isListAddDialog', false)
emit('confirm', { form, isUpdate: 1, id: props.editData.id })
emit('updatePage')
})
} else {
// emit('confirm', { form, isUpdate: 0 })
// 新增字典的值
const params = Object.assign({ data_dictionary_id: props.dictionaryId }, form)
createDictionaryItem(params).then(() => {
ElMessage.success('新增成功')
emit('update:isListAddDialog', false)
emit('confirm', { form, isUpdate: 0 })
emit('updatePage')
})
}
}
})
......
<script setup lang="ts">
import { ElMessage, ElMessageBox } from 'element-plus'
import { useMapStore } from '@/stores/map'
import { getDictionaryList, createDictionary, updateDictionary, delDictionary } from '../api'
import { getDictionaryList, delDictionary } from '../api'
import AddDialog from '../component/AddDialog.vue'
const router = useRouter()
......@@ -73,7 +73,7 @@ const handleDelete = (row: any) => {
const params = { id: row.id }
delDictionary(params).then(() => {
ElMessage.success('删除成功')
appList.value.refetch()
handleUpdate()
})
})
}
......@@ -90,22 +90,8 @@ const handleList = (row: any) => {
}
// 确定
const handleConfirm = (val: any) => {
if (val.isUpdate === 1) {
// 更新字典
const params = Object.assign({ id: val.id }, val.form)
updateDictionary(params).then(() => {
ElMessage.success('更新成功')
appList.value.refetch()
})
} else {
// 新增字典
const params = Object.assign({}, val.form)
createDictionary(params).then(() => {
ElMessage.success('新增成功')
const handleUpdate = () => {
appList.value.refetch()
})
}
}
</script>
......@@ -130,7 +116,7 @@ const handleConfirm = (val: any) => {
</el-space>
</template>
<template v-if="isShowDialog === true">
<AddDialog v-model:isShowDialog="isShowDialog" :isEdit="isEdit" :rowInfo="rowInfo" @confirm="handleConfirm" />
<AddDialog v-model:isShowDialog="isShowDialog" :isEdit="isEdit" :rowInfo="rowInfo" @updatePage="handleUpdate" />
</template>
</AppList>
</AppCard>
......
<script setup lang="ts">
import { getDictionaryItemList, createDictionaryItem, updateDictionaryItem, delDictionaryItem } from '../api'
import { getDictionaryItemList, delDictionaryItem } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import ListAddDialog from '../component/ListAddDialog.vue'
......@@ -8,6 +8,7 @@ const appList = ref()
const editData = ref({})
const title = ref('')
const type = route.query.type as string
const dictionaryId = route.query.id as string
const isEdit = ref(false)
const isListAddDialog = ref(false)
const listOptions = {
......@@ -49,28 +50,13 @@ const handleDelete = (row: any) => {
const params = { id: row.id }
delDictionaryItem(params).then(() => {
ElMessage.success('删除成功')
appList.value.refetch()
handleUpdate()
})
})
}
// 确定
const handleConfirm = (val: any) => {
console.log(val.id, '9999')
if (val.isUpdate === 1) {
// 更新字典的值
const params = Object.assign({ id: val.id, data_dictionary_id: route.query.id }, val.form)
updateDictionaryItem(params).then(() => {
ElMessage.success('更新成功')
appList.value.refetch()
})
} else {
// 新增字典的值
const params = Object.assign({ data_dictionary_id: route.query.id }, val.form)
createDictionaryItem(params).then(() => {
ElMessage.success('新增成功')
const handleUpdate = () => {
appList.value.refetch()
})
}
}
</script>
......@@ -91,11 +77,12 @@ const handleConfirm = (val: any) => {
<template v-if="isListAddDialog === true">
<ListAddDialog
v-model:isListAddDialog="isListAddDialog"
@confirm="handleConfirm"
@updatePage="handleUpdate"
:editData="editData"
:isEdit="isEdit"
:title="title"
:type="type"
:dictionaryId="dictionaryId"
/>
</template>
</template>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论