|
|
@ -5,32 +5,57 @@
|
|
|
|
import ElTable from './extra/ElTable.vue';
|
|
|
|
import ElTable from './extra/ElTable.vue';
|
|
|
|
import { ElTableColumn } from 'element-plus/es/components/table/index';
|
|
|
|
import { ElTableColumn } from 'element-plus/es/components/table/index';
|
|
|
|
const props = defineProps({
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 列表唯一标识
|
|
|
|
|
|
|
|
*/
|
|
|
|
code: {
|
|
|
|
code: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 列表标题
|
|
|
|
|
|
|
|
*/
|
|
|
|
title: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 是否支持拖拽排序
|
|
|
|
|
|
|
|
*/
|
|
|
|
sortable: {
|
|
|
|
sortable: {
|
|
|
|
type: Boolean,
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 列表配置
|
|
|
|
|
|
|
|
*/
|
|
|
|
config: {
|
|
|
|
config: {
|
|
|
|
type: Object,
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 列表操作
|
|
|
|
|
|
|
|
*/
|
|
|
|
operation: {
|
|
|
|
operation: {
|
|
|
|
type: Array,
|
|
|
|
type: Array,
|
|
|
|
default() {
|
|
|
|
default() {
|
|
|
|
return ['create', 'remove', 'search'];
|
|
|
|
return ['create', 'remove', 'search'];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 列表总数据量
|
|
|
|
|
|
|
|
*/
|
|
|
|
total: {
|
|
|
|
total: {
|
|
|
|
type: Number,
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 重置筛选条件,支持异步函数
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
reset: {
|
|
|
|
|
|
|
|
type: Function,
|
|
|
|
|
|
|
|
default: () => null,
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const emits = defineEmits([
|
|
|
|
const emits = defineEmits([
|
|
|
|
'create',
|
|
|
|
'create',
|
|
|
@ -41,7 +66,6 @@
|
|
|
|
'selectAll',
|
|
|
|
'selectAll',
|
|
|
|
'selectionChange',
|
|
|
|
'selectionChange',
|
|
|
|
'currentChange',
|
|
|
|
'currentChange',
|
|
|
|
'reset',
|
|
|
|
|
|
|
|
'template',
|
|
|
|
'template',
|
|
|
|
'import',
|
|
|
|
'import',
|
|
|
|
'export',
|
|
|
|
'export',
|
|
|
@ -188,7 +212,7 @@
|
|
|
|
const pages = computed(() => store.state.local.listPage);
|
|
|
|
const pages = computed(() => store.state.local.listPage);
|
|
|
|
const search = ref(
|
|
|
|
const search = ref(
|
|
|
|
props.code
|
|
|
|
props.code
|
|
|
|
? store.state.local.listPage[props.code]
|
|
|
|
? _.cloneDeep(unref(pages)[props.code])
|
|
|
|
: {
|
|
|
|
: {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageIndex: 1,
|
|
|
|
length: 10,
|
|
|
|
length: 10,
|
|
|
@ -200,10 +224,13 @@
|
|
|
|
length: 10,
|
|
|
|
length: 10,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) => {
|
|
|
|
) => {
|
|
|
|
|
|
|
|
if (props.config.page?.sizes && !props.config.page?.sizes?.includes(page.length)) {
|
|
|
|
|
|
|
|
page.length = props.config.page.sizes[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
if (props.code) {
|
|
|
|
if (props.code) {
|
|
|
|
store.commit('local/setListPage', {
|
|
|
|
store.commit('local/setListPage', {
|
|
|
|
...unref(pages),
|
|
|
|
...unref(pages),
|
|
|
|
[props.code]: page,
|
|
|
|
[props.code]: _.cloneDeep(page),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
search.value = page;
|
|
|
|
search.value = page;
|
|
|
@ -223,10 +250,9 @@
|
|
|
|
const handleSearch = () => {
|
|
|
|
const handleSearch = () => {
|
|
|
|
emits('search', unref(search));
|
|
|
|
emits('search', unref(search));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const handleReset = () => {
|
|
|
|
const handleReset = async () => {
|
|
|
|
emits('reset');
|
|
|
|
await props.reset?.();
|
|
|
|
search.value = { pageIndex: 1, length: 10 };
|
|
|
|
search.value = { pageIndex: 1, length: 10 };
|
|
|
|
handleSearch();
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const handleTemplate = () => {
|
|
|
|
const handleTemplate = () => {
|
|
|
|
emits('template');
|
|
|
|
emits('template');
|
|
|
@ -418,7 +444,7 @@
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
''
|
|
|
|
''
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{props.code ? (
|
|
|
|
{props.config.setting !== false ? (
|
|
|
|
<ElButton class="setting-btn" icon="setting" type="text" onClick={() => handleSetting()}>
|
|
|
|
<ElButton class="setting-btn" icon="setting" type="text" onClick={() => handleSetting()}>
|
|
|
|
<ElIcon name="Setting" />
|
|
|
|
<ElIcon name="Setting" />
|
|
|
|
<span>设置</span>
|
|
|
|
<span>设置</span>
|
|
|
|