|
|
|
@ -46,10 +46,10 @@
|
|
|
|
|
import { ref, watchEffect, onMounted, watch, inject, nextTick } from 'vue'; |
|
|
|
|
import type { PropType } from 'vue'; |
|
|
|
|
import { useRoute } from 'vue-router'; |
|
|
|
|
|
|
|
|
|
import { getTableSeting, postSaveTableSeting } from '@/api/basic/table'; |
|
|
|
|
const functions = inject('functions') as any; |
|
|
|
|
import Sortable from 'sortablejs'; |
|
|
|
|
import { handleClearTableQuery } from '@/utils/util'; |
|
|
|
|
import { getObjType, handleClearTableQuery } from '@/utils/util'; |
|
|
|
|
interface TableColumnType { |
|
|
|
|
/** 表格列的key */ |
|
|
|
|
prop: string; |
|
|
|
@ -128,13 +128,36 @@ const columnRef = ref([...props.modelValue]);
|
|
|
|
|
|
|
|
|
|
const tableEl1 = ref(); |
|
|
|
|
|
|
|
|
|
const _arr = functions.getStorage($route.fullPath + props.columnListName); |
|
|
|
|
// const _arr = functions.getStorage($route.fullPath + props.columnListName); |
|
|
|
|
|
|
|
|
|
if (_arr) { |
|
|
|
|
columnRef.value = [..._arr]; |
|
|
|
|
handleClearTableQuery(_arr); |
|
|
|
|
emit('update:modelValue', _arr); |
|
|
|
|
} |
|
|
|
|
// if (_arr) { |
|
|
|
|
// columnRef.value = [..._arr]; |
|
|
|
|
// handleClearTableQuery(_arr); |
|
|
|
|
// emit('update:modelValue', _arr); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
const initTable = async () => { |
|
|
|
|
try { |
|
|
|
|
const submitData = { tableKey: $route.fullPath + props.columnListName }; |
|
|
|
|
|
|
|
|
|
const res = await getTableSeting(submitData); |
|
|
|
|
|
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
|
|
|
|
|
const _arr = JSON.parse(data); |
|
|
|
|
|
|
|
|
|
if (getObjType(_arr) !== 'array') return; |
|
|
|
|
console.log('_arr :>> ', _arr); |
|
|
|
|
columnRef.value = [..._arr]; |
|
|
|
|
handleClearTableQuery(_arr); |
|
|
|
|
emit('update:modelValue', _arr); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log('error :>> ', error); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
initTable(); |
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
for (let index = 0; index < props.modelValue.length; index++) { |
|
|
|
@ -173,7 +196,11 @@ const initSortable = () => {
|
|
|
|
|
const currRow = arr.splice(oldIndex, 1)[0]; |
|
|
|
|
arr.splice(newIndex, 0, currRow); |
|
|
|
|
|
|
|
|
|
functions.setStorage($route.fullPath + props.columnListName, arr); |
|
|
|
|
// functions.setStorage($route.fullPath + props.columnListName, arr); |
|
|
|
|
postSaveTableSeting({ |
|
|
|
|
tableKey: $route.fullPath + props.columnListName, |
|
|
|
|
tableSetCongig: JSON.stringify(arr), |
|
|
|
|
}); |
|
|
|
|
// emit('update:modelValue', arr); |
|
|
|
|
// nextTick(() => { |
|
|
|
|
// emit('setcolum', arr, 4); |
|
|
|
@ -212,7 +239,5 @@ let headtop = ref<headtoptype[]>([
|
|
|
|
|
// width:'150' |
|
|
|
|
}, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
setTimeout(() => {}, 2000); |
|
|
|
|
</script> |
|
|
|
|
<style lang="scss"></style> |
|
|
|
|