vben
2020-11-28 54d14056462566521f2528480c13fb24279156ae
fix: fix table column settings not displayed by setting
3个文件已修改
25 ■■■■■ 已修改文件
CHANGELOG.zh_CN.md 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Table/src/components/TableSetting.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vite.config.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CHANGELOG.zh_CN.md
@@ -31,6 +31,8 @@
- form: 修复表单校验先设置在校验及控制台错误信息问题
- `modal`&`drawer` 修复组件传递数组参数问题
- form: 修复`updateSchema`赋值含有`[]`时不生效
- table: 修复表格 `TableAction` 图标显示问题
- table: 修复表格列设置通过`setColumns`设置不显示
### 🎫 Chores
src/components/Table/src/components/TableSetting.vue
@@ -77,7 +77,7 @@
  </div>
</template>
<script lang="ts">
  import { defineComponent, ref, reactive, toRefs, PropType, computed } from 'vue';
  import { defineComponent, ref, reactive, toRefs, PropType, computed, watchEffect } from 'vue';
  import { injectTable } from '../hooks/useProvinceTable';
  import { Tooltip, Divider, Dropdown, Menu, Popover, Checkbox } from 'ant-design-vue';
  import {
@@ -132,7 +132,7 @@
      const { toggleFullscreen, isFullscreenRef } = useFullscreen(table.wrapRef);
      const selectedKeysRef = ref<SizeType[]>([table.getSize()]);
      let plainOptions: Options[] = [];
      const plainOptions = ref<Options[]>([]);
      const state = reactive<State>({
        indeterminate: false,
        checkAll: true,
@@ -142,6 +142,12 @@
      const { t } = useI18n('component.table');
      watchEffect(() => {
        const columns = table.getColumns();
        if (columns.length) {
          init();
        }
      });
      function init() {
        let ret: Options[] = [];
        table.getColumns({ ignoreIndex: true, ignoreAction: true }).forEach((item) => {
@@ -150,7 +156,8 @@
            value: (item.dataIndex || item.title) as string,
          });
        });
        plainOptions = ret;
        plainOptions.value = ret;
        const checkList = table
          .getColumns()
          .map((item) => item.dataIndex || item.title) as string[];
@@ -171,7 +178,7 @@
      function onCheckAllChange(e: ChangeEvent) {
        state.indeterminate = false;
        const checkList = plainOptions.map((item) => item.value);
        const checkList = plainOptions.value.map((item) => item.value);
        if (e.target.checked) {
          state.checkedList = checkList;
          table.setColumns(checkList);
@@ -182,8 +189,9 @@
      }
      function onChange(checkedList: string[]) {
        state.indeterminate = !!checkedList.length && checkedList.length < plainOptions.length;
        state.checkAll = checkedList.length === plainOptions.length;
        const len = plainOptions.value.length;
        state.indeterminate = !!checkedList.length && checkedList.length < len;
        state.checkAll = checkedList.length === len;
        table.setColumns(checkedList);
      }
@@ -207,7 +215,6 @@
        }
      );
      init();
      return {
        redo: () => table.reload(),
        handleTitleClick,
vite.config.ts
@@ -55,7 +55,7 @@
   * Available options are 'terser' or 'esbuild'.
   * @default 'terser'
   */
  minify: isDevFn() ? 'esbuild' : 'terser',
  minify: isDevFn() ? false : 'terser',
  /**
   * Base public path when served in production.
   * @default '/'