diff --git a/src/components/ma-crud/index.vue b/src/components/ma-crud/index.vue index f1fe832101c5f8bc0e77f1c2a8135cbbfc5227c5..0e119c6291f98955c05f3cf4b0311d0cc796dcb4 100644 --- a/src/components/ma-crud/index.vue +++ b/src/components/ma-crud/index.vue @@ -151,7 +151,7 @@ import config from '@/config/crud' import { isFunction } from '@vue/shared' -import { ref, watch, nextTick, onMounted } from 'vue' +import {ref, watch, nextTick, onMounted} from 'vue' import MaSearch from './components/search.vue' import MaForm from './components/form.vue' @@ -237,7 +237,7 @@ import checkRole from '@/directives/role/role' import { Message } from '@arco-design/web-vue' import { request } from '@/utils/request' import tool from '@/utils/tool' -import _ from 'lodash' +import _, {cloneDeep} from 'lodash' const loading = ref(true) const reloadColumn = ref(true) @@ -248,6 +248,7 @@ const pageSizeOption = ref([10, 20, 30, 50, 100]) const total = ref(0) const requestParams = ref({}) const columns = ref([]) +const listColumns = ref([]) const slots = ref([]) const searchSlots = ref([]) const showSearch = ref(true) @@ -497,8 +498,8 @@ const getSearchSlot = () => { return sls } -slots.value = getSlot(settingProps.columns) -searchSlots.value = getSearchSlot(settingProps.columns) +slots.value = getSlot() +searchSlots.value = getSearchSlot() const requestData = async () => { defaultCrud.value = Object.assign(defaultCrud.value, settingProps.crud) @@ -513,10 +514,36 @@ const requestData = async () => { columns.value.push({ title: defaultCrud.value.operationColumnText, dataIndex: '__operation', width: defaultCrud.value.operationWidth, align: 'right', fixed: 'right' }) } showSearch.value = !defaultCrud.value.expandSearch + + //拷贝 + listColumns.value = cloneDeep(columns.value) + + //列表字段排序 + bubleSort(listColumns.value) initRequestParams() await refresh() } +//列表字段排序 +const bubleSort = (arr) => { + const len = arr.length; + let data = '' + for (let k=0;karr[i+1]['rank']){ + data = arr[k] + arr[k] = arr[i+1] + arr[i+1] = data + + } + } + } + return arr +} + + const initRequestParams = () => { requestParams.value[config.request.page] = 1 requestParams.value[config.request.pageSize] = config.pageSize @@ -660,7 +687,7 @@ const dbClickOpenEdit = (record) => { editAction(record) } } - + } }