提交 dd24a303 authored 作者: matian's avatar matian

Auto stash before merge of "master" and "origin/master"

上级 195ddb7e
<script setup lang="ts"> <script setup lang="ts">
// import Sortable from 'sortablejs' import Sortable 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 } from '../api' import { getCategoryList, delCategory, createCategory, updateCategory } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
const tableKey = ref(0)
const loading = ref(false) const loading = ref(false)
const prevCategoryName = ref('') const prevCategoryName = ref('')
const title = ref('') const title = ref('')
...@@ -98,6 +99,95 @@ const getParent = (node: string, tree: any) => { ...@@ -98,6 +99,95 @@ const getParent = (node: string, tree: any) => {
// } // }
// }) // })
// } // }
// 行拖拽 排序
const rowDrop = () => {
// 获取表格节点
nextTick(() => {
const el = document.querySelector('.el-table__body-wrapper tbody') as HTMLElement
let activeRows: any = []
if (!el) {
return
}
// 插件调用函数
Sortable.create(el, {
animation: 300,
onMove(dragged: any, related: any) {
// onMove() {
tableData = arrayTreeSetLevel(tableData) // 树形结构数据添加level
activeRows = treeToTile(tableData) // 把树形的结构转为列表再进行拖拽
console.log(dragged, '123', related, tableData, activeRows)
const oldRow = activeRows[dragged.rowIndex]
const newRow = activeRows[related.rowIndex]
console.log(oldRow, newRow)
// if (oldRow.level !== newRow.level && oldRow.pid !== newRow.pid) {
// //不能跨级拖拽
// return false
// }
},
onEnd(data) {
const oldIndex = data.oldIndex as number
const newIndex = data.newIndex as number
console.log(oldIndex, newIndex)
const oldRow = activeRows[oldIndex] // 移动的那个元素
const newRow = activeRows[newIndex] // 新的元素
if (oldIndex !== newIndex && oldRow.level === newRow.level && oldRow.pid === newRow.pid) {
const modelProperty = activeRows[oldIndex]
const changeIndex = newIndex - oldIndex
const index = activeRows.indexOf(modelProperty)
if (index < 0) {
return
}
activeRows.splice(index, 1)
activeRows.splice(index + changeIndex, 0, modelProperty)
console.log(111)
sortMenuData()
}
}
})
})
}
const sortMenuData = () => {
tableKey.value = Math.random() //狠狠的刷新dom
rowDrop() // 再把拖拽的功能塞入
}
// 给树形的数据去添加每一层的层级
const arrayTreeSetLevel = (array: any, levelName = 'level', childrenName = 'children') => {
if (!Array.isArray(array)) {
return []
}
const recursive = (array: any, level = 0) => {
level++
return array.map((v: any) => {
v[levelName] = level
const child = v[childrenName]
if (child && child.length) {
recursive(child, level)
}
return v
})
}
return recursive(array)
}
const treeToTile = (treeData: any, childKey = 'children') => {
// 将树数据转化为平铺数据
const arr: any = []
const expanded = (data: any) => {
if (data && data.length > 0) {
data
.filter((d: any) => d)
.forEach((e: any) => {
arr.push(e)
expanded(e[childKey] || [])
})
}
}
expanded(treeData)
return arr
}
// 获取分类列表 // 获取分类列表
const handleCategoryList = () => { const handleCategoryList = () => {
const params = { type: 'tree' } const params = { type: 'tree' }
...@@ -175,9 +265,14 @@ const rebuildData = (value: any, arr: any) => { ...@@ -175,9 +265,14 @@ const rebuildData = (value: any, arr: any) => {
} }
onMounted(() => { onMounted(() => {
// sortable('t1', tableData) // 参数分别为table的class名称,table的数据data rowDrop()
handleCategoryList() handleCategoryList()
}) })
// let move: any = {}
// const click = (obj: any) => {
// console.log(111)
// move = obj
// }
</script> </script>
<template> <template>
<AppCard title="类别管理"> <AppCard title="类别管理">
...@@ -202,9 +297,14 @@ onMounted(() => { ...@@ -202,9 +297,14 @@ onMounted(() => {
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
highlight-current-row highlight-current-row
v-loading="loading" v-loading="loading"
:key="tableKey"
> >
<el-table-column type="index" align="center" class-name="handle"> <el-table-column align="center">
<el-icon><Operation /></el-icon> <el-icon><Operation /></el-icon>
<!-- <template #default="scope">
<el-icon @mousedown="click(scope.row)"><Operation /></el-icon>
</template> -->
</el-table-column> </el-table-column>
<el-table-column prop="category_name" label="类别名称" align="center" class-name="handle" /> <el-table-column prop="category_name" label="类别名称" align="center" class-name="handle" />
<el-table-column prop="depth" label="层级" align="center" /> <el-table-column prop="depth" label="层级" align="center" />
......
...@@ -26,8 +26,7 @@ const rules = reactive<FormRules>({ ...@@ -26,8 +26,7 @@ const rules = reactive<FormRules>({
name: [{ required: true, message: '请输入讲师姓名', trigger: 'blur' }], name: [{ required: true, message: '请输入讲师姓名', trigger: 'blur' }],
title: [{ required: true, message: ' 请输入职位', trigger: 'blur' }] title: [{ required: true, message: ' 请输入职位', trigger: 'blur' }]
}) })
const listOptions = $computed(() => { const listOptions = {
return {
remote: { remote: {
params: { type: '' } params: { type: '' }
}, },
...@@ -45,7 +44,6 @@ const listOptions = $computed(() => { ...@@ -45,7 +44,6 @@ const listOptions = $computed(() => {
{ label: '操作', slots: 'table-operate', width: 300, align: 'center' } { label: '操作', slots: 'table-operate', width: 300, align: 'center' }
] ]
} }
})
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
console.log('删除', row) console.log('删除', row)
......
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage,ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { getTeacherList, deleteTeacher } from '../api' import { getTeacherList, deleteTeacher } from '../api'
const router = useRouter() const router = useRouter()
const appList = ref() const appList = ref()
const listOptions = $computed(() => { const listOptions = {
return {
remote: { remote: {
httpRequest: getTeacherList, httpRequest: getTeacherList,
params: { type: '' } params: { type: '' }
...@@ -26,14 +25,13 @@ const listOptions = $computed(() => { ...@@ -26,14 +25,13 @@ const listOptions = $computed(() => {
{ label: '操作', slots: 'table-operate', width: 230, align: 'center' } { label: '操作', slots: 'table-operate', width: 230, align: 'center' }
] ]
} }
})
// 删除讲师 // 删除讲师
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
ElMessageBox.confirm('确定要删除吗?', '提示').then(() => { ElMessageBox.confirm('确定要删除吗?', '提示').then(() => {
deleteTeacher({ id: row.id }).then(() => { deleteTeacher({ id: row.id }).then(() => {
ElMessage.success('删除成功') ElMessage.success('删除成功')
appList.value.refetch() appList.value.refetch()
}) })
}) })
} }
// 更新讲师 // 更新讲师
......
...@@ -5,8 +5,7 @@ import { Expand, Search } from '@element-plus/icons-vue' ...@@ -5,8 +5,7 @@ import { Expand, Search } from '@element-plus/icons-vue'
const appList = ref() const appList = ref()
const isCard = ref(true) const isCard = ref(false)
const listOptions = { const listOptions = {
remote: { remote: {
httpRequest: getVideoList, httpRequest: getVideoList,
......
...@@ -7,8 +7,7 @@ const appList = ref() ...@@ -7,8 +7,7 @@ const appList = ref()
const isShowDialog = ref(false) const isShowDialog = ref(false)
const isEdit = ref(false) const isEdit = ref(false)
const editData = ref({}) const editData = ref({})
const listOptions = $computed(() => { const listOptions = {
return {
remote: { remote: {
httpRequest: getCoverList, httpRequest: getCoverList,
params: { type: '' } params: { type: '' }
...@@ -27,7 +26,6 @@ const listOptions = $computed(() => { ...@@ -27,7 +26,6 @@ const listOptions = $computed(() => {
{ label: '操作', slots: 'table-operate', width: 230, align: 'center' } { label: '操作', slots: 'table-operate', width: 230, align: 'center' }
] ]
} }
})
// 删除 // 删除
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
ElMessageBox.confirm('确定要删除吗?', '提示').then(() => { ElMessageBox.confirm('确定要删除吗?', '提示').then(() => {
......
...@@ -13,48 +13,46 @@ const store = useMapStore() ...@@ -13,48 +13,46 @@ const store = useMapStore()
// 状态 // 状态
//表单每行数据 //表单每行数据
const listOptions = $computed(() => { const listOptions = {
return { remote: {
remote: { httpRequest: getDictionaryList,
httpRequest: getDictionaryList, params: {
params: { type: '',
type: '', created_time_start: '',
created_time_start: '', created_time_end: ''
created_time_end: '' }
} },
filters: [
{ type: 'input', prop: 'name', label: '字典名称:' },
{ type: 'input', prop: 'key', label: '字典类型:' },
{
type: 'select',
prop: 'status',
label: '字典状态:',
options: store.mapList?.filter((item: any) => item.key === 'system_status')[0]?.values || []
}, },
filters: [ {
{ type: 'input', prop: 'name', label: '字典名称:' }, type: 'input',
{ type: 'input', prop: 'key', label: '字典类型:' }, label: '创建时间:',
{ slots: 'created_time_start',
type: 'select', prop: 'created_time_start'
prop: 'status', },
label: '字典状态:', { slots: 'created_time_end', prop: 'created_time_end' }
options: store.mapList?.filter((item: any) => item.key === 'system_status')[0]?.values || [] ],
}, columns: [
{ { label: '字典主键', prop: 'id', width: 224, align: 'center' },
type: 'input', { label: '字典名称', prop: 'name', align: 'center' },
label: '创建时间:', { label: '字典类型', prop: 'key', align: 'center' },
slots: 'created_time_start', {
prop: 'created_time_start' label: '状态',
}, prop: 'status_name',
{ slots: 'created_time_end', prop: 'created_time_end' } align: 'center'
], },
columns: [ { label: '备注 ', prop: 'remark', align: 'center' },
{ label: '字典主键', prop: 'id', width: 224, align: 'center' }, { label: '创建时间', prop: 'created_time', align: 'center' },
{ label: '字典名称', prop: 'name', align: 'center' }, { label: '操作', slots: 'table-operate', align: 'center', width: 300 }
{ label: '字典类型', prop: 'key', align: 'center' }, ]
{ }
label: '状态',
prop: 'status_name',
align: 'center'
},
{ label: '备注 ', prop: 'remark', align: 'center' },
{ label: '创建时间', prop: 'created_time', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center', width: 300 }
]
}
})
// 新增弹窗 // 新增弹窗
const handleAdd = () => { const handleAdd = () => {
isShowDialog.value = true isShowDialog.value = true
......
...@@ -10,28 +10,26 @@ const title = ref('') ...@@ -10,28 +10,26 @@ const title = ref('')
const type = route.query.type as string const type = route.query.type as string
const isEdit = ref(false) const isEdit = ref(false)
const isListAddDialog = ref(false) const isListAddDialog = ref(false)
const listOptions = $computed(() => { const listOptions = {
return { remote: {
remote: { httpRequest: getDictionaryItemList,
httpRequest: getDictionaryItemList, params: { data_dictionary_id: route.query.id }
params: { data_dictionary_id: route.query.id } },
},
columns: [ columns: [
{ label: '字典编码', prop: 'data_dictionary_id', align: 'center' }, { label: '字典编码', prop: 'data_dictionary_id', align: 'center' },
{ label: '字典标签', prop: 'label', align: 'center' }, { label: '字典标签', prop: 'label', align: 'center' },
{ label: '字典键值', prop: 'value', align: 'center' }, { label: '字典键值', prop: 'value', align: 'center' },
{ {
label: '状态', label: '状态',
prop: 'status_name', prop: 'status_name',
align: 'center' align: 'center'
}, },
{ label: '备注 ', prop: 'remark', align: 'center' }, { label: '备注 ', prop: 'remark', align: 'center' },
{ label: '创建时间', prop: 'created_time', align: 'center' }, { label: '创建时间', prop: 'created_time', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center', minWidth: 180 } { label: '操作', slots: 'table-operate', align: 'center', minWidth: 180 }
] ]
} }
})
const handleAdd = () => { const handleAdd = () => {
isListAddDialog.value = true isListAddDialog.value = true
isEdit.value = false isEdit.value = false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论