huangyinfeng
2024-09-18 ccfd07feeaa670a3d56548d7fea0936e299df95b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<template>
  <PageWrapper>
    <div style="height: calc(100vh - 84px)">
      <div class="head">
        <div class="left">
          <div class="left-box p-3">
            <!-- 多选 -->
            <a-checkbox
              class="icon"
              style="margin-right: 10px"
              v-model:checked="state.checkAll"
              :indeterminate="state.indeterminate"
              @change="fnCheckedChange"
            ></a-checkbox>
            <!--更新  -->
            <SyncOutlined class="icon" v-show="!checked" />
            <pageHeadLeft :checked="checked" :selectAllRow="selectAllRow" 
            :parentTableList='newList'
           ></pageHeadLeft>
          </div>
        </div>
 
        <div class="right p-3"
          >共<span style="padding: 0 5px">20</span>封
          <a-pagination
            v-model:current="pageCurrent"
            simple
            :total="50"
            style="margin-left: 10px"
          />
          <FilterOutlined style="margin-left: 10px" />
          <a-popover placement="left" trigger="click">
            <template #content>
              <div>
                <span>往来邮件聚合</span>
                <a-switch style="margin-left: 50px" v-model:checked="checked3"> </a-switch>
              </div>
              <a-divider style="margin: 10px" />
              <div>
                <span>列表展示内容</span>
              </div>
              <div class="p-2">
                <a-checkbox v-model:checked="checked">邮件摘要</a-checkbox>
              </div>
              <div class="p-2">
                <a-checkbox v-model:checked="checked">附件</a-checkbox>
              </div>
              <div style="text-align: center">
                <a-button @click="$router.push('/email/utils')">更多邮箱设置</a-button>
              </div>
            </template>
            <SettingOutlined style="margin-left: 10px" />
          </a-popover>
          <a-switch style="margin-left: 10px" v-model:checked="checked3">
            <template #checkedChildren><PushpinOutlined style="color: #0a6aff" /></template>
            <template #unCheckedChildren><PushpinOutlined /></template>
          </a-switch>
        </div>
      </div>
      <div v-if="checked" class="left-bt p-3">
        已选择此页面上所有 20 封邮件 , 选择全部 335 封邮件
      </div>
      <div class="p-4" style="height: 90%; overflow: hidden">
        <a-tabs v-model:activeKey="activeKey">
          <a-tab-pane
            v-for="item in tabsList"
            :key="item.key"
            :tab="`${item.label}${item.num ? '(' + item.num + ')' : ''}`"
            style="height: 200px"
          >
            <Table
              ref="tableRef"
              :page="pageCurrent"
              :pageList="newList"
              @selectAll="fnSelectAll"
              @updateSelectAll="updateSelectAll"
            />
          </a-tab-pane>
        </a-tabs>
      </div>
    </div>
  </PageWrapper>
</template>
 
<script lang="ts" setup>
  name: 'ListPage';
  import {
    SyncOutlined,
    SettingOutlined,
    FilterOutlined,
    PushpinOutlined,
  } from '@ant-design/icons-vue';
  import pageHeadLeft from '@/views/email/components/ListPage/pageHeadLeft.vue';
  import { PageWrapper } from '@/components/Page';
 
  import { ref, watch, defineProps, defineEmits, computed, reactive, onMounted } from 'vue';
 
  // 定义属性
  interface Props {
    pageList: [];
  }
  const props = defineProps<Props>();
  const newList = ref([]);
  const selectAllRow = ref([]);
  watch(
    () => props.pageList,
    (newValue) => {
      newList.value = newValue;
    },
  );
 
  const checked = ref(false);
  const pageCurrent = ref(1);
  const tableRef = ref();
  const state = reactive({
    indeterminate: false,
    checkAll: false,
  });
  function fnCheckedChange(e) {
    Object.assign(state, {
      indeterminate: false,
    });
    tableRef.value[0].fnSelectAll(e.target.checked);
    checked.value = e.target.checked;
  }
  function updateSelectAll(data) {
    selectAllRow.value = data.records;
    if (!data.isAll) {
      state.indeterminate = true;
      state.checkAll = false;
      if (data.records.length === 0) {
        state.indeterminate = false;
      }
    } else {
      state.indeterminate = false;
      state.checkAll = true;
    }
  }
  const tabsList = computed(() => {
    return [
      {
        key: '1',
        label: '需要处理',
        num: 20,
      },
      {
        key: '2',
        label: '尚未到期',
        num: 0,
      },
      {
        key: '3',
        label: '已完成',
        num: 0,
      },
    ];
  });
  const activeKey = ref('1');
  const checked3 = ref(false);
  import Table from '../table.vue';
  onMounted(() => {
    console.log('tableRef:', tableRef.value[0]);
  });
  function fnSelectAll() {
    console.log('44444444444');
  }
 
</script>
<style scoped lang="less">
  .head {
    display: flex;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid rgb(5 5 5 / 6%);
 
    /* 增加选择器特异性 */
    & .left {
      width: 20%;
 
      & .left-box {
        display: flex;
        align-items: center;
        justify-content: space-flex-start;
        width: 100%;
 
        & .icon {
          margin-right: 15px;
          font-size: 16px;
        }
      }
    }
 
    & .right {
      display: flex;
      align-items: center;
    }
  }
 
  .left-bt {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 27px;
    background: #fffbe6;
  }
</style>