CzrContent.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <div class="czr-content" :class="{ 'czr-content-full': full !== false }">
  3. <div name="czr-table-resize-dom" class="cc-top-slot" v-if="$slots.top">
  4. <slot name="top" />
  5. </div>
  6. <div
  7. name="czr-table-resize-dom"
  8. class="cc-field-out"
  9. id="field-out"
  10. v-if="$slots.fieldOut"
  11. >
  12. <div class="field-out-slot czr-content-form">
  13. <slot name="fieldOut" />
  14. </div>
  15. </div>
  16. <div
  17. name="czr-table-resize-dom"
  18. class="cc-center-slot"
  19. v-if="$slots.center"
  20. >
  21. <slot name="center" />
  22. </div>
  23. <div name="czr-table-resize-dom" class="cc-bottom">
  24. <div
  25. id="operation"
  26. class="operation"
  27. v-if="$slots.buttons || noFilter === false"
  28. >
  29. <div class="table-title">
  30. <slot name="tableTitle" />
  31. </div>
  32. <div class="buttons">
  33. <slot name="buttons" />
  34. </div>
  35. <div class="filters" v-if="noFilter === false">
  36. <div
  37. class="tools __hover"
  38. @click="() => (state.showFieldColumn = true)"
  39. >
  40. <SvgIcon name="czr_tools" size="18" color="#666666" />
  41. </div>
  42. </div>
  43. <div
  44. class="filters-right"
  45. :style="`margin-left : ${noFilter === false || $slots.buttons ? 10 : 0}px`"
  46. >
  47. <slot name="filtersRight" />
  48. </div>
  49. </div>
  50. <div id="table" class="table">
  51. <slot name="table" />
  52. </div>
  53. </div>
  54. <el-dialog
  55. v-model="state.showFieldColumn"
  56. width="790px"
  57. align-center
  58. modal-class="field-dialog"
  59. :close-on-click-modal="false"
  60. :show-close="false"
  61. >
  62. <template #header>
  63. <span>字段筛选设置</span>
  64. <SvgIcon
  65. class="__hover"
  66. name="close_2"
  67. size="16"
  68. @click="() => (state.showFieldColumn = false)"
  69. />
  70. </template>
  71. <div class="field-column">
  72. <div class="fc-block fc-all">
  73. <div class="fcb-title">全部字段</div>
  74. <div class="fcb-content">
  75. <div class="fcbc-filter">
  76. <el-input
  77. v-model="state.columnAllInputFilter"
  78. placeholder="请输入关键词..."
  79. clearable
  80. >
  81. <template #suffix>
  82. <SvgIcon name="czr_search" />
  83. </template>
  84. </el-input>
  85. </div>
  86. <div class="fcbc-list">
  87. <template
  88. v-for="(item, index) in tableHeadTempDeep.filter((v) =>
  89. v.allLabel.includes(state.columnAllInputFilter),
  90. )"
  91. :key="item.allLabel"
  92. >
  93. <div
  94. class="table-head-item __hover"
  95. @click="item.show = !item.show"
  96. >
  97. <div class="check" :class="{ active: item.show }" />
  98. <CzrEllipsis class="label" :value="item.allLabel" />
  99. </div>
  100. </template>
  101. </div>
  102. <div class="fcbc-bottom">
  103. <div>共 {{ tableHeadTempDeep.length }} 条</div>
  104. <div class="__hover" @click="handleCheckAllChange">
  105. <div class="check" :class="{ active: columnIsAllCpt }" />
  106. 全选
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="fc-block fc-select">
  112. <div class="fcb-title">已选字段</div>
  113. <div class="fcb-content">
  114. <div class="fcbc-filter">
  115. <el-input
  116. v-model="state.columnSelectInputFilter"
  117. placeholder="请输入关键词..."
  118. clearable
  119. >
  120. <template #suffix>
  121. <SvgIcon name="czr_search" />
  122. </template>
  123. </el-input>
  124. </div>
  125. <div class="fcbc-list">
  126. <template
  127. v-for="(item, index) in tableHeadTempDeep.filter(
  128. (v) =>
  129. v.show &&
  130. v.allLabel.includes(state.columnSelectInputFilter),
  131. )"
  132. :key="item.allLabel"
  133. >
  134. <div class="table-head-select-item">
  135. <SvgIcon name="czr_prefix" size="12" color="#e4e4e4" />
  136. <CzrEllipsis class="label" :value="item.allLabel" />
  137. <SvgIcon
  138. class="__hover"
  139. name="czr_close"
  140. size="12"
  141. color="#e4e4e4"
  142. @click="item.show = false"
  143. />
  144. </div>
  145. </template>
  146. </div>
  147. <div class="fcbc-bottom">
  148. <div>
  149. 已选 {{ tableHeadTempDeep.filter((v) => v.show).length }} 条
  150. </div>
  151. <div
  152. v-if="tableHeadTempDeep.filter((v) => v.show).length > 0"
  153. @click="tableHeadTempDeep.forEach((v) => (v.show = false))"
  154. class="clear __hover"
  155. >
  156. 清空
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. <template #footer>
  163. <div class="buttons">
  164. <div
  165. class="cancel __hover"
  166. @click="() => (state.showFieldColumn = false)"
  167. >
  168. 取消
  169. </div>
  170. <div
  171. class="submit __hover"
  172. @click="
  173. ($emit('update:tableHead', state.tableHeadTemp),
  174. (state.showFieldColumn = false))
  175. "
  176. >
  177. 确定
  178. </div>
  179. </div>
  180. </template>
  181. </el-dialog>
  182. </div>
  183. </template>
  184. <script setup lang="ts">
  185. defineOptions({
  186. name: 'CzrContent',
  187. })
  188. import { computed, onMounted, reactive, watch } from 'vue'
  189. const props = defineProps({
  190. tableHead: {
  191. default: () => [],
  192. },
  193. full: {
  194. default: false,
  195. },
  196. noFilter: {
  197. default: false,
  198. },
  199. })
  200. const state = reactive({
  201. showFieldColumn: false,
  202. columnAllInputFilter: '',
  203. columnSelectInputFilter: '',
  204. tableHeadTemp: [],
  205. })
  206. watch(
  207. () => state.showFieldColumn,
  208. (n) => {
  209. if (n) {
  210. state.tableHeadTemp = JSON.parse(JSON.stringify(props.tableHead))
  211. }
  212. },
  213. )
  214. const tableHeadTempDeep = computed(() => {
  215. const list: any = []
  216. const deep = (arr: any[], pLabel: string = '') => {
  217. arr.forEach((v) => {
  218. v.allLabel = pLabel ? `${pLabel}-${v.label}` : v.label
  219. if (!v.tempFixed && v.fixed) {
  220. v.tempFixed = JSON.parse(JSON.stringify(v.fixed))
  221. }
  222. if (v.children && v.children.length > 0) {
  223. deep(v.children, v.allLabel)
  224. } else {
  225. list.push(v)
  226. }
  227. })
  228. }
  229. deep(state.tableHeadTemp)
  230. return list
  231. })
  232. const columnIsAllCpt = computed(() => {
  233. return tableHeadTempDeep.value.every((v) => v.show)
  234. })
  235. const handleCheckAllChange = () => {
  236. if (columnIsAllCpt.value) {
  237. tableHeadTempDeep.value.forEach((v) => {
  238. v.show = false
  239. })
  240. } else {
  241. tableHeadTempDeep.value.forEach((v) => {
  242. v.show = true
  243. })
  244. }
  245. }
  246. onMounted(() => {
  247. state.tableHeadTemp = JSON.parse(JSON.stringify(props.tableHead))
  248. })
  249. </script>
  250. <style scoped lang="scss">
  251. .czr-content {
  252. width: 100%;
  253. height: 100%;
  254. display: flex;
  255. flex-direction: column;
  256. background-color: #f5fbff;
  257. box-sizing: border-box;
  258. .cc-top-slot {
  259. background-color: #ffffff;
  260. }
  261. .cc-field-out {
  262. border-radius: 8px 8px 0 0;
  263. background-color: #ffffff;
  264. height: auto;
  265. padding: 14px 24px 0 0;
  266. .field-out-slot {
  267. flex: 1;
  268. :deep(.el-form-item) {
  269. margin-bottom: 12px;
  270. }
  271. }
  272. }
  273. .cc-center-slot {
  274. margin-bottom: 10px;
  275. background-color: #ffffff;
  276. }
  277. .cc-bottom {
  278. border-radius: 0 0 8px 8px;
  279. background-color: #ffffff;
  280. flex: 1;
  281. z-index: 1;
  282. display: flex;
  283. flex-direction: column;
  284. padding: 12px 16px;
  285. .operation {
  286. display: flex;
  287. align-items: center;
  288. justify-content: space-between;
  289. margin-bottom: 12px;
  290. .table-title {
  291. margin-right: auto;
  292. display: flex;
  293. align-items: center;
  294. }
  295. .buttons {
  296. margin-left: auto;
  297. display: flex;
  298. :deep(> *) {
  299. margin-right: 10px;
  300. }
  301. }
  302. .filters {
  303. height: 36px;
  304. display: flex;
  305. align-items: center;
  306. .tools {
  307. width: 3rem;
  308. height: 2.25rem;
  309. border-radius: 0.25rem;
  310. border: 0.06rem solid #c0c4cc;
  311. display: flex;
  312. align-items: center;
  313. justify-content: center;
  314. }
  315. }
  316. }
  317. .table {
  318. flex: 1;
  319. z-index: 1;
  320. display: flex;
  321. }
  322. }
  323. :deep(.field-dialog) {
  324. .el-overlay-dialog {
  325. overflow: hidden;
  326. .el-dialog {
  327. border-radius: 8px;
  328. .el-dialog__header {
  329. padding: 30px 28px 38px 28px;
  330. margin: 0;
  331. font-size: 18px;
  332. font-family: Microsoft YaHei;
  333. font-weight: bold;
  334. color: #333333;
  335. display: flex;
  336. justify-content: space-between;
  337. }
  338. .el-dialog__body {
  339. padding: 0 28px;
  340. }
  341. .el-dialog__footer {
  342. padding: 22px 28px 20px 28px;
  343. .buttons {
  344. width: 100%;
  345. display: flex;
  346. justify-content: flex-end;
  347. > div {
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. box-sizing: border-box;
  352. }
  353. .cancel {
  354. margin-right: 10px;
  355. width: 72px;
  356. height: 36px;
  357. background: #f8f8f8;
  358. border: 1px solid #e4e4e4;
  359. border-radius: 4px;
  360. font-size: 14px;
  361. font-family: Microsoft YaHei;
  362. font-weight: 400;
  363. color: #999999;
  364. }
  365. .submit {
  366. width: 72px;
  367. height: 36px;
  368. background: var(--czr-main-color);
  369. border-radius: 4px;
  370. font-size: 14px;
  371. font-family: Microsoft YaHei;
  372. font-weight: 400;
  373. color: #ffffff;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .field-column {
  381. display: flex;
  382. justify-content: space-between;
  383. gap: 16px;
  384. .fc-block {
  385. .fcb-title {
  386. font-size: 14px;
  387. font-family: Microsoft YaHei;
  388. font-weight: 400;
  389. color: #666666;
  390. margin-bottom: 18px;
  391. }
  392. .fcb-content {
  393. height: 488px;
  394. border: 1px solid #e4e4e4;
  395. border-radius: 4px;
  396. display: flex;
  397. flex-direction: column;
  398. .fcbc-filter {
  399. padding: 10px 12px 0 12px;
  400. }
  401. .check {
  402. width: 18px;
  403. height: 18px;
  404. box-sizing: border-box;
  405. border: 1px solid #d3d3d3;
  406. border-radius: 2px;
  407. margin: 0 10px;
  408. cursor: pointer;
  409. font-size: 16px;
  410. &.active {
  411. background-color: var(--czr-main-color);
  412. border-color: var(--czr-main-color);
  413. display: grid;
  414. place-items: center;
  415. &:after {
  416. content: '✔';
  417. color: #ffffff;
  418. font-size: 14px;
  419. }
  420. }
  421. &:hover {
  422. opacity: 0.8;
  423. }
  424. }
  425. .fcbc-bottom {
  426. margin-top: auto;
  427. display: flex;
  428. justify-content: space-between;
  429. align-items: center;
  430. height: 40px;
  431. min-height: 40px;
  432. background: #ffffff;
  433. border-top: 1px solid #e4e4e4;
  434. border-radius: 0px 0px 4px 4px;
  435. padding: 0 10px 0 12px;
  436. font-size: 14px;
  437. font-family: Microsoft YaHei;
  438. font-weight: 400;
  439. color: #666666;
  440. box-sizing: border-box;
  441. }
  442. }
  443. &.fc-all {
  444. width: 480px;
  445. .fcbc-list {
  446. display: grid;
  447. grid-template-columns: repeat(2, 1fr);
  448. padding: 20px 12px;
  449. row-gap: 22px;
  450. column-gap: 30px;
  451. overflow-y: auto;
  452. .table-head-item {
  453. height: 18px;
  454. display: flex;
  455. align-items: center;
  456. line-height: 1;
  457. .label {
  458. width: 164px;
  459. }
  460. }
  461. }
  462. .fcbc-bottom {
  463. > div:nth-child(2) {
  464. display: flex;
  465. align-items: center;
  466. .check:after {
  467. transform: translateY(-2px);
  468. }
  469. }
  470. }
  471. }
  472. &.fc-select {
  473. width: 244px;
  474. .fcbc-list {
  475. overflow-y: auto;
  476. display: grid;
  477. row-gap: 26px;
  478. padding: 20px 12px;
  479. grid-template-columns: repeat(1, 1fr);
  480. .table-head-select-item {
  481. display: flex;
  482. align-items: center;
  483. .svg-icon:first-child {
  484. margin-right: 10px;
  485. }
  486. .label {
  487. width: 164px;
  488. }
  489. .svg-icon:last-child {
  490. margin-left: auto;
  491. }
  492. }
  493. }
  494. .fcbc-bottom {
  495. .clear {
  496. font-size: 14px;
  497. font-family: Microsoft YaHei;
  498. font-weight: 400;
  499. color: var(--czr-main-color);
  500. }
  501. }
  502. }
  503. }
  504. }
  505. &.czr-content-full {
  506. overflow-y: auto;
  507. position: absolute;
  508. }
  509. }
  510. </style>