莳松crm管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-crm-manage-web/src/components/SSTable/index.vue

149 lines
3.7 KiB

1 year ago
<template>
<div>
<div class="flex">
9 months ago
<el-table
:data="tableObject.tableList"
8 months ago
:row-key="rowkey"
:expand-row-keys="expandRowKeys"
9 months ago
border
style="flex: 1"
@selection-change="handleSelectionChange"
>
1 year ago
<slot></slot>
</el-table>
<el-button
ref="ColumnSetting"
plain
style="writing-mode: vertical-lr; height: 100px; letter-spacing: 2px"
@click="clickSetting"
>表格列控制</el-button
>
<el-popover
ref="TableColumnPop"
:virtual-ref="ColumnSetting"
placement="left"
width="120px"
trigger="click"
virtual-triggering
>
12 months ago
<el-checkbox-group v-model="checkedColumns" @change="confirm">
<draggable
v-model="allColumns"
item-key="field"
ghost-class="draggable-ghost"
:animation="400"
@end="onDragEnd"
>
<template #item="{ element: item }">
11 months ago
<el-checkbox :key="item.id" :label="item.id">
12 months ago
{{ item.label }}
</el-checkbox>
</template>
</draggable>
1 year ago
</el-checkbox-group>
</el-popover>
</div>
<!-- 分页 -->
<Pagination
v-model:limit="pageSize"
11 months ago
v-model:page="pageNo"
1 year ago
:total="tableObject.total"
@pagination="getList"
/>
</div>
</template>
<script setup>
12 months ago
import draggable from 'vuedraggable'
11 months ago
import * as ClueCacheApi from '@/api/clue/clueCache'
12 months ago
import { useRoute } from 'vue-router'
1 year ago
const props = defineProps({
tableObject: { type: Object, default: () => ({ tableList: [] }) },
8 months ago
tableColumns: { type: Array, default: () => [] },
rowkey: { type: String, default: 'id' },
expandRowKeys: { type: Array, default: () => [] }
1 year ago
})
9 months ago
const emit = defineEmits(['update:tableObject', 'getList', 'getCheckedColumns', 'selection-change'])
12 months ago
const route = useRoute()
1 year ago
11 months ago
const pageNo = ref(props.tableObject?.pageNo || 1)
1 year ago
const pageSize = ref(props.tableObject?.pageSize || 20)
const ColumnSetting = ref()
const TableColumnPop = ref()
12 months ago
// 展示在设置里的所有表格列,由于会排序,所以使用新属性,不直接修改原值
11 months ago
const allColumns = ref([...props.tableColumns])
12 months ago
// 已勾选的选项
1 year ago
const checkedColumns = ref([])
12 months ago
// 调用获取数据的接口,分页时需要使用
1 year ago
function getList({ page, limit }) {
11 months ago
emit('update:tableObject', { ...props.tableObject, pageNo: page, pageSize: limit })
1 year ago
nextTick(() => {
emit('getList')
})
}
12 months ago
// 点击"表格列控制"按钮,出现设置页面
1 year ago
const clickSetting = () => {
unref(TableColumnPop).TableColumnPop?.delayHide?.()
}
12 months ago
11 months ago
const routeMap = {
CluePool: 1,
ClueOrder: 2
12 months ago
}
11 months ago
12 months ago
// 获取用户已勾选的表头
11 months ago
async function getUserCheckedColumns() {
checkedColumns.value = await ClueCacheApi.getClueCache({
settingType: 2,
model: routeMap[route.name]
})
// 回显到表格中
12 months ago
emitColumns()
}
// 表格列排序
function onDragEnd() {
11 months ago
ClueCacheApi.setClueCache({
settingType: 2,
model: routeMap[route.name],
clueParamId: checkedColumns.value
})
// 表格回显
12 months ago
emitColumns()
}
9 months ago
function handleSelectionChange(val) {
emit('selection-change', val)
}
12 months ago
// 勾选确认
function confirm() {
11 months ago
ClueCacheApi.setClueCache({
settingType: 2,
model: routeMap[route.name],
clueParamId: checkedColumns.value
})
// usedSchema.value = allColumns.value.filter((it) => checkedColumns.value.includes(it.id))
12 months ago
emitColumns()
}
// 将表头数据返回至父组件
function emitColumns() {
11 months ago
const arr = allColumns.value.filter((item) => checkedColumns.value.includes(item.id))
12 months ago
emit('getCheckedColumns', arr)
}
getUserCheckedColumns()
defineExpose({ getUserCheckedColumns })
1 year ago
</script>
<style lang="scss" scoped></style>