huangyinfeng
4 天以前 db42d08c39ae6129e2b95cd24c0d57c6769282e5
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<template>
  <PageWrapper>
    <div style="height: calc(100vh - 84px)">
      <div class="my-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">{{ page.total }}</span
          >封
          <a-pagination
            v-model:current="pageCurrent"
            v-model:page-size="page.limit"
            simple
            :total="page.total"
            style="margin-left: 10px"
            @change="handlePageChange"
          />
          <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" style="height: 30px" class="left-bt p-3">
        已选择此页面上所有 20 封邮件 , 选择全部 335 封邮件
      </div>
      <div class="p-4" style="height: 90%; overflow: auto">
        <div v-if="isTabs">
          <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"
                :isDrafts="isDrafts"
                @selectAll="fnSelectAll"
                @updateSelectAll="updateSelectAll"
              />
            </a-tab-pane>
          </a-tabs>
        </div>
        <div v-else>
          <Table
            ref="tableRef"
            :page="pageCurrent"
            :pageList="newList"
            :isDrafts="isDrafts"
            @selectAll="fnSelectAll"
            @updateSelectAll="updateSelectAll"
          />
        </div>
      </div>
    </div>
  </PageWrapper>
</template>
 
<script lang="ts" setup>
  name: 'ListPage';
  import {
    SyncOutlined,
    SettingOutlined,
    FilterOutlined,
    PushpinOutlined,
  } from '@ant-design/icons-vue';
  import pageHeadLeft from './pageHeadLeft.vue';
  import { PageWrapper } from '@/components/Page';
 
  import { ref, watch, defineProps, defineEmits, computed, reactive, onMounted, inject } from 'vue';
 
  // 定义属性
  interface Props {
    pageList?: [];
    pageData?: any;
    mailType?: number;
    isDrafts?: boolean;
    isTabs?: boolean;
  }
  const props = defineProps({
    isTabs: {
      type: Boolean,
      default: true,
    },
    pageList: {
      type: Array,
      default: () => [],
    },
    pageData: {
      type: Object,
      default: () => {},
    },
    mailType: {
      type: Number,
      default: 0,
    },
    isDrafts: {
      type: Boolean,
      default: false,
    },
  });
  const newList = ref([]);
  const selectAllRow = ref([]);
  watch(
    () => props.pageList,
    (newValue) => {
      newList.value = newValue;
    },
  );
 
  const page = computed(() => props.pageData);
  const checked = computed(() => selectAllRow.value.length > 0);
  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: 0,
      },
      {
        key: '2',
        label: '客户',
        num: 0,
      },
      {
        key: '3',
        label: '同事',
        num: 0,
      },
      {
        key: '4',
        label: '通讯录',
        num: 0,
      },
      {
        key: '5',
        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');
  }
  const emit = defineEmits(['pageChange']);
  defineExpose({
    fnSelectAll,
  });
 
  const getDataList = inject('getDataList');
  function handlePageChange(page, pageSize) {
    getDataList(page);
  }
</script>
<style scoped lang="less">
  .my-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 60px;
    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%;
        height: 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>