123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 |
- <template>
- <div class="czr-content" :class="{ 'czr-content-full': full !== false }">
- <div name="czr-table-resize-dom" class="cc-top-slot" v-if="$slots.top">
- <slot name="top" />
- </div>
- <div
- name="czr-table-resize-dom"
- class="cc-field-out"
- id="field-out"
- v-if="$slots.fieldOut"
- >
- <div class="field-out-slot czr-content-form">
- <slot name="fieldOut" />
- </div>
- </div>
- <div
- name="czr-table-resize-dom"
- class="cc-center-slot"
- v-if="$slots.center"
- >
- <slot name="center" />
- </div>
- <div name="czr-table-resize-dom" class="cc-bottom">
- <div
- id="operation"
- class="operation"
- v-if="$slots.buttons || noFilter === false"
- >
- <div class="table-title">
- <slot name="tableTitle" />
- </div>
- <div class="buttons">
- <slot name="buttons" />
- </div>
- <div class="filters" v-if="noFilter === false">
- <div
- class="tools __hover"
- @click="() => (state.showFieldColumn = true)"
- >
- <SvgIcon name="czr_tools" size="18" color="#666666" />
- </div>
- </div>
- <div
- class="filters-right"
- :style="`margin-left : ${noFilter === false || $slots.buttons ? 10 : 0}px`"
- >
- <slot name="filtersRight" />
- </div>
- </div>
- <div id="table" class="table">
- <slot name="table" />
- </div>
- </div>
- <el-dialog
- v-model="state.showFieldColumn"
- width="790px"
- align-center
- modal-class="field-dialog"
- :close-on-click-modal="false"
- :show-close="false"
- >
- <template #header>
- <span>字段筛选设置</span>
- <SvgIcon
- class="__hover"
- name="close_2"
- size="16"
- @click="() => (state.showFieldColumn = false)"
- />
- </template>
- <div class="field-column">
- <div class="fc-block fc-all">
- <div class="fcb-title">全部字段</div>
- <div class="fcb-content">
- <div class="fcbc-filter">
- <el-input
- v-model="state.columnAllInputFilter"
- placeholder="请输入关键词..."
- clearable
- >
- <template #suffix>
- <SvgIcon name="czr_search" />
- </template>
- </el-input>
- </div>
- <div class="fcbc-list">
- <template
- v-for="(item, index) in tableHeadTempDeep.filter((v) =>
- v.allLabel.includes(state.columnAllInputFilter),
- )"
- :key="item.allLabel"
- >
- <div
- class="table-head-item __hover"
- @click="item.show = !item.show"
- >
- <div class="check" :class="{ active: item.show }" />
- <CzrEllipsis class="label" :value="item.allLabel" />
- </div>
- </template>
- </div>
- <div class="fcbc-bottom">
- <div>共 {{ tableHeadTempDeep.length }} 条</div>
- <div class="__hover" @click="handleCheckAllChange">
- <div class="check" :class="{ active: columnIsAllCpt }" />
- 全选
- </div>
- </div>
- </div>
- </div>
- <div class="fc-block fc-select">
- <div class="fcb-title">已选字段</div>
- <div class="fcb-content">
- <div class="fcbc-filter">
- <el-input
- v-model="state.columnSelectInputFilter"
- placeholder="请输入关键词..."
- clearable
- >
- <template #suffix>
- <SvgIcon name="czr_search" />
- </template>
- </el-input>
- </div>
- <div class="fcbc-list">
- <template
- v-for="(item, index) in tableHeadTempDeep.filter(
- (v) =>
- v.show &&
- v.allLabel.includes(state.columnSelectInputFilter),
- )"
- :key="item.allLabel"
- >
- <div class="table-head-select-item">
- <SvgIcon name="czr_prefix" size="12" color="#e4e4e4" />
- <CzrEllipsis class="label" :value="item.allLabel" />
- <SvgIcon
- class="__hover"
- name="czr_close"
- size="12"
- color="#e4e4e4"
- @click="item.show = false"
- />
- </div>
- </template>
- </div>
- <div class="fcbc-bottom">
- <div>
- 已选 {{ tableHeadTempDeep.filter((v) => v.show).length }} 条
- </div>
- <div
- v-if="tableHeadTempDeep.filter((v) => v.show).length > 0"
- @click="tableHeadTempDeep.forEach((v) => (v.show = false))"
- class="clear __hover"
- >
- 清空
- </div>
- </div>
- </div>
- </div>
- </div>
- <template #footer>
- <div class="buttons">
- <div
- class="cancel __hover"
- @click="() => (state.showFieldColumn = false)"
- >
- 取消
- </div>
- <div
- class="submit __hover"
- @click="
- ($emit('update:tableHead', state.tableHeadTemp),
- (state.showFieldColumn = false))
- "
- >
- 确定
- </div>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup lang="ts">
- defineOptions({
- name: 'CzrContent',
- })
- import { computed, onMounted, reactive, watch } from 'vue'
- const props = defineProps({
- tableHead: {
- default: () => [],
- },
- full: {
- default: false,
- },
- noFilter: {
- default: false,
- },
- })
- const state = reactive({
- showFieldColumn: false,
- columnAllInputFilter: '',
- columnSelectInputFilter: '',
- tableHeadTemp: [],
- })
- watch(
- () => state.showFieldColumn,
- (n) => {
- if (n) {
- state.tableHeadTemp = JSON.parse(JSON.stringify(props.tableHead))
- }
- },
- )
- const tableHeadTempDeep = computed(() => {
- const list: any = []
- const deep = (arr: any[], pLabel: string = '') => {
- arr.forEach((v) => {
- v.allLabel = pLabel ? `${pLabel}-${v.label}` : v.label
- if (!v.tempFixed && v.fixed) {
- v.tempFixed = JSON.parse(JSON.stringify(v.fixed))
- }
- if (v.children && v.children.length > 0) {
- deep(v.children, v.allLabel)
- } else {
- list.push(v)
- }
- })
- }
- deep(state.tableHeadTemp)
- return list
- })
- const columnIsAllCpt = computed(() => {
- return tableHeadTempDeep.value.every((v) => v.show)
- })
- const handleCheckAllChange = () => {
- if (columnIsAllCpt.value) {
- tableHeadTempDeep.value.forEach((v) => {
- v.show = false
- })
- } else {
- tableHeadTempDeep.value.forEach((v) => {
- v.show = true
- })
- }
- }
- onMounted(() => {
- state.tableHeadTemp = JSON.parse(JSON.stringify(props.tableHead))
- })
- </script>
- <style scoped lang="scss">
- .czr-content {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- background-color: #f5fbff;
- box-sizing: border-box;
- .cc-top-slot {
- background-color: #ffffff;
- }
- .cc-field-out {
- border-radius: 8px 8px 0 0;
- background-color: #ffffff;
- height: auto;
- padding: 14px 24px 0 0;
- .field-out-slot {
- flex: 1;
- :deep(.el-form-item) {
- margin-bottom: 12px;
- }
- }
- }
- .cc-center-slot {
- margin-bottom: 10px;
- background-color: #ffffff;
- }
- .cc-bottom {
- border-radius: 0 0 8px 8px;
- background-color: #ffffff;
- flex: 1;
- z-index: 1;
- display: flex;
- flex-direction: column;
- padding: 12px 16px;
- .operation {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 12px;
- .table-title {
- margin-right: auto;
- display: flex;
- align-items: center;
- }
- .buttons {
- margin-left: auto;
- display: flex;
- :deep(> *) {
- margin-right: 10px;
- }
- }
- .filters {
- height: 36px;
- display: flex;
- align-items: center;
- .tools {
- width: 3rem;
- height: 2.25rem;
- border-radius: 0.25rem;
- border: 0.06rem solid #c0c4cc;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- }
- .table {
- flex: 1;
- z-index: 1;
- display: flex;
- }
- }
- :deep(.field-dialog) {
- .el-overlay-dialog {
- overflow: hidden;
- .el-dialog {
- border-radius: 8px;
- .el-dialog__header {
- padding: 30px 28px 38px 28px;
- margin: 0;
- font-size: 18px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #333333;
- display: flex;
- justify-content: space-between;
- }
- .el-dialog__body {
- padding: 0 28px;
- }
- .el-dialog__footer {
- padding: 22px 28px 20px 28px;
- .buttons {
- width: 100%;
- display: flex;
- justify-content: flex-end;
- > div {
- display: flex;
- align-items: center;
- justify-content: center;
- box-sizing: border-box;
- }
- .cancel {
- margin-right: 10px;
- width: 72px;
- height: 36px;
- background: #f8f8f8;
- border: 1px solid #e4e4e4;
- border-radius: 4px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #999999;
- }
- .submit {
- width: 72px;
- height: 36px;
- background: var(--czr-main-color);
- border-radius: 4px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ffffff;
- }
- }
- }
- }
- }
- }
- .field-column {
- display: flex;
- justify-content: space-between;
- gap: 16px;
- .fc-block {
- .fcb-title {
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- margin-bottom: 18px;
- }
- .fcb-content {
- height: 488px;
- border: 1px solid #e4e4e4;
- border-radius: 4px;
- display: flex;
- flex-direction: column;
- .fcbc-filter {
- padding: 10px 12px 0 12px;
- }
- .check {
- width: 18px;
- height: 18px;
- box-sizing: border-box;
- border: 1px solid #d3d3d3;
- border-radius: 2px;
- margin: 0 10px;
- cursor: pointer;
- font-size: 16px;
- &.active {
- background-color: var(--czr-main-color);
- border-color: var(--czr-main-color);
- display: grid;
- place-items: center;
- &:after {
- content: '✔';
- color: #ffffff;
- font-size: 14px;
- }
- }
- &:hover {
- opacity: 0.8;
- }
- }
- .fcbc-bottom {
- margin-top: auto;
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 40px;
- min-height: 40px;
- background: #ffffff;
- border-top: 1px solid #e4e4e4;
- border-radius: 0px 0px 4px 4px;
- padding: 0 10px 0 12px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- box-sizing: border-box;
- }
- }
- &.fc-all {
- width: 480px;
- .fcbc-list {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- padding: 20px 12px;
- row-gap: 22px;
- column-gap: 30px;
- overflow-y: auto;
- .table-head-item {
- height: 18px;
- display: flex;
- align-items: center;
- line-height: 1;
- .label {
- width: 164px;
- }
- }
- }
- .fcbc-bottom {
- > div:nth-child(2) {
- display: flex;
- align-items: center;
- .check:after {
- transform: translateY(-2px);
- }
- }
- }
- }
- &.fc-select {
- width: 244px;
- .fcbc-list {
- overflow-y: auto;
- display: grid;
- row-gap: 26px;
- padding: 20px 12px;
- grid-template-columns: repeat(1, 1fr);
- .table-head-select-item {
- display: flex;
- align-items: center;
- .svg-icon:first-child {
- margin-right: 10px;
- }
- .label {
- width: 164px;
- }
- .svg-icon:last-child {
- margin-left: auto;
- }
- }
- }
- .fcbc-bottom {
- .clear {
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: var(--czr-main-color);
- }
- }
- }
- }
- }
- &.czr-content-full {
- overflow-y: auto;
- position: absolute;
- }
- }
- </style>
|