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