mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-01-19 03:52:50 +08:00
修复tabs query bug 代码优化
This commit is contained in:
parent
4bcd0cfc3b
commit
61aa570cf2
@ -28,7 +28,10 @@ const emit = defineEmits(['update:modelValue', 'change'])
|
||||
|
||||
const magicTable = ref()
|
||||
const props = defineProps({
|
||||
modelValue: Array,
|
||||
modelValue: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
cols: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
@ -36,11 +39,15 @@ const props = defineProps({
|
||||
showNo: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
operation: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
})
|
||||
|
||||
const tableOptions = reactive({
|
||||
data: [],
|
||||
data: props.modelValue,
|
||||
cols: [],
|
||||
showNo: props.showNo
|
||||
})
|
||||
@ -48,25 +55,26 @@ const tableOptions = reactive({
|
||||
for (var i in props.cols) {
|
||||
var col = props.cols[i]
|
||||
tableOptions.cols.push({
|
||||
type: 'dynamic',
|
||||
field: col.field,
|
||||
label: col.label
|
||||
...col,
|
||||
type: 'dynamic'
|
||||
})
|
||||
}
|
||||
|
||||
tableOptions.cols.push({
|
||||
label: '操作',
|
||||
type: 'btns',
|
||||
width: 85,
|
||||
fixed: 'right',
|
||||
btns: [{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
click: (row, index) => {
|
||||
tableOptions.data.splice(index, 1)
|
||||
}
|
||||
}]
|
||||
})
|
||||
if(props.operation){
|
||||
tableOptions.cols.push({
|
||||
label: '操作',
|
||||
type: 'btns',
|
||||
width: 85,
|
||||
fixed: 'right',
|
||||
btns: [{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
click: (row, index) => {
|
||||
tableOptions.data.splice(index, 1)
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, (value) => {
|
||||
console.log(value)
|
||||
|
@ -56,10 +56,6 @@ for(var key in props.where){
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.where,() => {
|
||||
console.log(props.where)
|
||||
})
|
||||
|
||||
const emit = defineEmits(['search', 'mounted'])
|
||||
|
||||
function input(input){
|
||||
|
@ -75,10 +75,6 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.checkedIds, (value) => {
|
||||
console.log(value)
|
||||
})
|
||||
|
||||
const tree = ref()
|
||||
const treeData = ref([])
|
||||
const searchData = ref([])
|
||||
|
@ -43,8 +43,10 @@
|
||||
tabValue.value = global.tabValue.value
|
||||
})
|
||||
function openTab(item){
|
||||
console.log(global.visitedViews.map(it => it.name))
|
||||
proxy.$router.push({
|
||||
path: item.props.name
|
||||
path: item.props.name,
|
||||
query: global.visitedViews.filter(it => it.path == item.props.name)[0].query
|
||||
})
|
||||
}
|
||||
function removeTab(path){
|
||||
@ -58,7 +60,8 @@
|
||||
if(it.path == path){
|
||||
global.visitedViews.splice(i, 1)
|
||||
proxy.$router.push({
|
||||
path: global.visitedViews[global.visitedViews.length - 1].path
|
||||
path: global.visitedViews[global.visitedViews.length - 1].path,
|
||||
query: global.visitedViews[global.visitedViews.length - 1].query
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -66,7 +69,8 @@
|
||||
}
|
||||
function refresh(path){
|
||||
proxy.$router.replace({
|
||||
path: `/redirect${path}`
|
||||
path: `/redirect${path}`,
|
||||
query: global.visitedViews.filter(it => it.path == path)[0].query
|
||||
})
|
||||
}
|
||||
function close(type, path){
|
||||
@ -85,16 +89,17 @@
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(var i = 0; i < global.visitedViews.length; i++){
|
||||
if(global.visitedViews[i].path != path){
|
||||
global.visitedViews.splice(i, 1)
|
||||
for(var i = 0, len = global.visitedViews.length; i < len; i++){
|
||||
if(global.visitedViews[0].path != path){
|
||||
global.visitedViews.splice(0, 1)
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
proxy.$router.push({
|
||||
path: path
|
||||
path: path,
|
||||
query: global.visitedViews.filter(it => it.path == path)[0].query
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
@ -24,9 +24,13 @@ document.title = global.title
|
||||
router.beforeEach((to, from) => {
|
||||
global.tabValue.value = to.path
|
||||
if((to.name && global.visitedViews.length === 0 || global.visitedViews.every(it => it.path !== to.path)) && !to.path.startsWith('/redirect') && !to.path.startsWith('/login')){
|
||||
console.log(to)
|
||||
global.visitedViews.push(to)
|
||||
}
|
||||
global.visitedViews.forEach((it, i) => {
|
||||
if(it.path == to.path){
|
||||
global.visitedViews[i] = to
|
||||
}
|
||||
})
|
||||
return true
|
||||
})
|
||||
app.use(globalProperties)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div style="padding: 50px;">
|
||||
<el-button type="primary" @click="getData" style="margin-bottom: 10px">获取数据</el-button>
|
||||
<mb-editor-table v-model="tableDatas" :cols="cols" :show-no="false" />
|
||||
<mb-editor-table v-model="tableDatas" :cols="cols" :show-no="false" :operation="false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -188,8 +188,8 @@ const tableOptions = reactive({
|
||||
}
|
||||
]
|
||||
})
|
||||
let dialogTitle = ref('')
|
||||
let searchTimeout = reactive()
|
||||
const dialogTitle = ref('')
|
||||
var searchTimeout = reactive()
|
||||
const menuFormDialog = ref()
|
||||
const menuFormRef = ref()
|
||||
|
||||
@ -197,7 +197,6 @@ function reloadTable(){
|
||||
proxy.$get('menu/tree').then(res => {
|
||||
menuData.value = res.data.list
|
||||
tableOptions.data = menuData.value
|
||||
searchMenu()
|
||||
})
|
||||
}
|
||||
|
||||
@ -208,6 +207,9 @@ function expand(){
|
||||
}
|
||||
|
||||
function searchMenu() {
|
||||
refreshTable.value = false
|
||||
tableOptions.el["default-expand-all"] = true
|
||||
nextTick(() => refreshTable.value = true)
|
||||
clearTimeout(searchTimeout)
|
||||
searchTimeout = setTimeout(() => {
|
||||
if(searchValue.value){
|
||||
|
@ -218,7 +218,7 @@ const rules = reactive({
|
||||
name: [{ required: true, message: '请输入机构名称', trigger: 'change' }],
|
||||
code: [{ required: true, message: '请输入机构编码', trigger: 'change' }]
|
||||
})
|
||||
const searchTimeout = null
|
||||
var searchTimeout = null
|
||||
const officeFormDialog = ref()
|
||||
const dataForm = ref()
|
||||
|
||||
@ -237,9 +237,7 @@ watch(officeData, () => {
|
||||
function expand(){
|
||||
refreshTable.value = false
|
||||
tableOptions.el["default-expand-all"] = !tableOptions.el["default-expand-all"]
|
||||
nextTick(() => {
|
||||
refreshTable.value = true
|
||||
})
|
||||
nextTick(() => refreshTable.value = true)
|
||||
}
|
||||
|
||||
function searchOffice() {
|
||||
|
@ -22,12 +22,11 @@
|
||||
search-width="100%"
|
||||
:checked="false"
|
||||
@check-change="checkChange"
|
||||
@mounted="treeMounted"
|
||||
/>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
<mb-search :where="tableOptions.where" @search="reloadTable" @mounted="searchMounted">
|
||||
<mb-search :where="tableOptions.where" @search="reloadTable">
|
||||
<template #btns>
|
||||
<el-button :loading="downloadLoading" class="filter-item" icon="ElDownload" @click="handleDownload">
|
||||
导出
|
||||
@ -175,16 +174,12 @@ const userFormDialog = ref()
|
||||
const table = ref()
|
||||
const userForm = ref()
|
||||
|
||||
function searchMounted(){
|
||||
if(proxy.$route.query.roleId){
|
||||
tableOptions.where.roleId.value = proxy.$route.query.roleId
|
||||
}
|
||||
if(proxy.$route.query.roleId){
|
||||
tableOptions.where.roleId.value = proxy.$route.query.roleId
|
||||
}
|
||||
|
||||
function treeMounted(){
|
||||
if(proxy.$route.query.officeId){
|
||||
tableOptions.where.officeId = proxy.$route.query.officeId
|
||||
}
|
||||
if(proxy.$route.query.officeId){
|
||||
tableOptions.where.officeId = proxy.$route.query.officeId
|
||||
}
|
||||
|
||||
function checkChange(values) {
|
||||
|
Loading…
Reference in New Issue
Block a user