huangyinfeng
2024-09-09 00fe0e2047999d784d0fb353a426ffc6f35ac206
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
<template>
  <div style="height: 70vh; overflow: auto">
    <div v-for="(item, index) in groupedEmails" :key="index">
      <span class="span-title">{{ `${item.name}(${item.data.length})` }}</span>
      <vxe-table
        style="margin: 10px 0"
        :showHeader="false"
        :data="item.data"
        size="small"
        min-height="40px"
        :row-config="{ isCurrent: true, isHover: true }"
        :menu-config="tableMenu"
        @menu-click="contextMenuClickEvent"
        @cell-click="cellClickEvent"
      >
        <vxe-column type="checkbox" width="60"></vxe-column>
        <vxe-column field="sender" title="发件人" data-index="sender" min-width="300px">
          <template #default="{ row }">
            <div style="display: flex; align-items: center">
              <a-avatar size="small" style="margin-right: 8px" :src="row.avatar" />
              <a-popover placement="bottom">
                <template #content>
                  <div
                    class="p-2"
                    style="
                      display: flex;
                      align-items: center;
                      border-bottom: 1px solid rgb(5 5 5 / 6%);
                    "
                  >
                    <a-avatar size="small" style="margin-right: 8px" :src="row.avatar" />
                    <span style="color: #000; font-weight: 700">{{ row.email }}</span>
                    <CopyOutlined />
                  </div>
                  <div class="display-flex p-2">
                    <a-button type="link" size="small">新建客户</a-button>
                    <a-dropdown>
                      <a style="margin-right: 5px" class="ant-dropdown-link" @click.prevent>
                        <DownOutlined />
                      </a>
                      <template #overlay>
                        <a-menu>
                          <a-menu-item>
                            <a href="javascript:;">添加到已有客户</a>
                          </a-menu-item>
                        </a-menu>
                      </template>
                    </a-dropdown>
                    <a-button type="link" size="small">添加为线索</a-button>
 
                    <a-dropdown style="margin-right: 5px">
                      <a style="margin-right: 5px" class="ant-dropdown-link" @click.prevent>
                        <DownOutlined />
                      </a>
                      <template #overlay>
                        <a-menu>
                          <a-menu-item>
                            <a href="javascript:;">添加到通讯录</a>
                          </a-menu-item>
                        </a-menu>
                      </template>
                    </a-dropdown>
                    <a-button type="link" size="small">往来邮件</a-button></div
                  >
                </template>
                <div>
                  <span style="font-weight: 700">{{ row.sender }}</span
                  ><span style="padding: 0 8px; color: #999">|</span>
                  <span style="color: #999; font-weight: 500">{{ row.email }}</span>
                </div>
              </a-popover>
            </div>
          </template>
        </vxe-column>
        <vxe-column show-overflow field="subject" title="表题" data-index="subject" min-width="250">
          <template #default="{ row }">
            <span style="color: #3081fe; font-weight: 500">{{ row.subject }}</span> -
            <span style="color: #999">{{ row.subject }}</span>
          </template>
        </vxe-column>
        <vxe-column field="action" title="Action" width="180">
          <template #default="{ row }">
            <span style="display: flex; justify-content: space-around">
              <span>{{ row.date }}</span>
              <span><FieldTimeOutlined @click.stop="fnProcessingTime" /></span>
              <span><PushpinOutlined @click.stop="fnTagging" /></span>
            </span>
          </template>
        </vxe-column>
      </vxe-table>
    </div>
    <DrawerDetail ref="drawerDetailRef" v-model="openDrawerDetail" />
  </div>
</template>
 
<script lang="ts" setup>
  name: 'ListPageTable';
  import {
    FieldTimeOutlined,
    PushpinOutlined,
    CopyOutlined,
    DownOutlined,
  } from '@ant-design/icons-vue';
 
  import { ref, watch, defineProps, defineEmits, computed, reactive } from 'vue';
 
  // 定义属性
  interface Props {
    page: number;
    pageList?: [];
  }
  // const props = defineProps<Props>();
 
  const dataSource = [
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-06 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-07-06 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-06 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-07 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-07 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-05 20:19',
    },
    {
      sender: '百旺金税云',
      email: 'gdbwjf.dzfp3@gdfapiao.com',
      subject: '您收到一张【佛山火炬创新创业园有限公司】开具的发票【发票号码: ...',
      date: '2024-09-05 20:19',
    },
    {
      sender: '微信支付小助手',
      email: 'weixinpay@tencent.com',
      subject: '自动提现失败通知 - 微信商户平台',
      date: '2024-09-05 11:46',
    },
    {
      sender: '网易外贸通',
      email: 'mianfei@qiye.163.com',
      subject: '开发外贸客户很难?这些方法开发精准客户效率直接提升3倍',
      date: '2024-09-04 10:13',
    },
    {
      sender: 'Apple Developer',
      email: 'developer@insideapple.app',
      subject: '开发者你好:2024年9月准备好迎接 Apple Intelligence...',
      date: '2024-09-04 01:13',
    },
    {
      sender: '微信支付小助手',
      email: 'weixinpay@tencent.com',
      subject: '自动提现失败通知 - 微信商户平台',
      date: '2024-09-03 11:45',
    },
    {
      sender: 'notice',
      email: 'notice@qiye.163.com',
      subject: '【反垃圾通知】您的邮箱共收到1封异常邮件',
      date: '2024-09-03 10:02',
    },
    {
      sender: '三星电子',
      email: 'memberclub.club@samsung.com',
      subject: '【三星电子】秋日畅享,以旧换“星”,等你来!',
      date: '2024-09-02 18:15',
    },
    {
      sender: '极光',
      email: 'support@amail.jpush.io',
      subject: '极光统计运营周报 - 运营周报 ERP 2024.08.26-2024.09.01...',
      date: '2024-09-02 12:00',
    },
    {
      sender: '微信支付小助手',
      email: 'weixinpay@tencent.com',
      subject: '自动提现失败通知 - 微信商户平台',
      date: '2024-09-02 12:00',
    },
    {
      sender: 'Salesforce Dreamforce',
      email: 'apacemarketing@salesforce.com',
      subject: 'Session lineup is live. Explore now on Salesforce+',
      date: '2024-09-02 11:01',
    },
    {
      sender: '网易外贸通',
      email: 'mianfei@qiye.163.com',
      subject: '更懂外贸的AI管家来了,帮您节省30%的人工成本',
      date: '2024-09-02 09:55',
    },
  ];
 
  import dayjs from 'dayjs';
  import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
  import isoWeek from 'dayjs/plugin/isoWeek';
  dayjs.extend(isSameOrAfter);
  dayjs.extend(isSameOrBefore);
  dayjs.extend(isoWeek);
 
  interface EmailItem {
    id: number;
    subject: string;
  }
 
  // 确保 groupedData 的结构正确且 data 是 EmailItem 类型的数组
  interface GroupedDataItem {
    key: string;
    data: EmailItem[];
    name: string;
  }
 
  function groupEmailsByDate(dataSource) {
    const today = dayjs();
    const yesterday = dayjs().subtract(1, 'day');
    const startOfWeek = dayjs().startOf('week');
    const startOfMonth = dayjs().startOf('month');
    const startOfLastMonth = dayjs().subtract(1, 'month').startOf('month');
    const endOfLastMonth = dayjs().subtract(1, 'month').endOf('month');
 
    const groupedData: GroupedDataItem[] = [
      {
        data: [],
        name: '今天',
        key: 'today',
      },
      {
        data: [],
        name: '昨天',
        key: 'yesterday',
      },
      {
        data: [],
        name: '本周',
        key: 'thisWeek',
      },
      {
        data: [],
        name: '这个月',
        key: 'thisMonth',
      },
      {
        data: [],
        name: '上个月',
        key: 'lastMonth',
      },
      {
        data: [],
        name: '更早',
        key: 'earlier',
      },
    ];
 
    dataSource.forEach((item: any) => {
      try {
        const emailDate = dayjs(item.date);
 
        if (emailDate.isSame(today, 'day')) {
          groupedData[0].data.push(item);
        } else if (emailDate.isSame(yesterday, 'day')) {
          groupedData[1].data.push(item);
        } else if (emailDate.isSameOrAfter(startOfWeek) && emailDate.isBefore(today, 'day')) {
          groupedData[2].data.push(item);
        } else if (emailDate.isSameOrAfter(startOfMonth) && emailDate.isBefore(today, 'day')) {
          groupedData[3].data.push(item);
        } else if (
          emailDate.isSameOrAfter(startOfLastMonth) &&
          emailDate.isSameOrBefore(endOfLastMonth)
        ) {
          groupedData[4].data.push(item);
        } else {
          groupedData[5].data.push(item);
        }
      } catch (error) {
        console.error(`Error processing item date: ${item.date}`, error);
      }
    });
    // 将结果按中文映射进行返回
    const result = <{ data: any; name: string; key: string }[]>[];
    groupedData.forEach((group: { data: any; name: string; key: string }) => {
      if (group.data.length > 0) {
        result.push(group);
      }
    });
 
    return result;
  }
  const groupedEmails: GroupedDataItem[] = groupEmailsByDate(dataSource);
  console.log(groupedEmails);
 
  // 右键菜单
  const tableMenu = {
    className: 'my-menus',
    body: {
      options: [
        [
          {
            code: 'reply',
            name: '回复',
          },
          { code: 'replyAll', name: '回复全部' },
          { code: 'replyWithAttachment', name: '带附件回复' },
          { code: 'replyAllWithAttachment', name: '带附件回复全部' },
          { code: 'forward', name: '转发' },
          { code: 'forwardAsAttachment', name: '作为附件转发' },
          { code: 'distribute', name: '分发' },
          { code: 'setRemark', name: '设置备注' },
        ],
        [
          { code: 'toHandle', name: '待处理' },
          { code: 'markAsUnread', name: '标为未读' },
          { code: 'labelAs', name: '标注为' },
        ],
        [
          { code: 'newRule', name: '新建收发件规则' },
          { code: 'moveTo', name: '移动到' },
        ],
        [
          { code: 'exportEmail', name: '导出邮件' },
          { code: 'createFollowUp', name: '建为客户跟进' },
          { code: 'createSchedule', name: '新建日程' },
        ],
        [
          { code: 'markAsSpam', name: '标为垃圾邮件' },
          { code: 'delete', name: '删除' },
        ],
      ],
    },
  };
 
  function contextMenuClickEvent({ menu, row, column }) {
    switch (menu.code) {
      case 'copy':
        if (row && column) {
        }
        break;
      default:
    }
  }
 
  // 操作row
  function fnProcessingTime(row) {
    console.log(row);
  }
  function fnTagging(row) {
    console.log(row);
  }
  import DrawerDetail from './drawerDetail.vue';
  // 详情内容
  const openDrawerDetail = ref(false);
  const cellClickEvent = (event) => {
    console.log(event);
    openDrawerDetail.value = true;
    // collapseStore.toggle();
 
  };
</script>
<style scoped lang="less">
  .display-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
 
  .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;
  }
 
  .span-title {
    padding: 20px;
    color: #000;
    font-weight: 700;
  }
 
  .table {
    height: 80vh;
  }
 
  .my-menus {
    background-color: #f8f8f9;
  }
</style>