gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
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
<script lang="ts" setup>
import type { Reply } from './types';
 
import { computed, ref } from 'vue';
 
import { NewsType } from '..\..\..\..\packages\constants\src';
import { IconifyIcon } from '..\..\..\..\packages\icons\src';
 
import { Button, Col, Modal, Row } from 'ant-design-vue';
 
import { WxMaterialSelect, WxNews } from '#/views/mp/components';
 
defineOptions({ name: 'TabNews' });
 
const props = defineProps<{
  modelValue: Reply;
  newsType?: NewsType;
}>();
 
const emit = defineEmits<{
  (e: 'update:modelValue', v: Reply): void;
}>();
 
const reply = computed<Reply>({
  get: () => props.modelValue,
  set: (val) => emit('update:modelValue', val),
});
 
const showDialog = ref(false);
 
/** 选择素材 */
function selectMaterial(item: any) {
  showDialog.value = false;
  reply.value.articles = item.content.newsItem;
}
 
/** 删除图文 */
function onDelete() {
  reply.value.articles = [];
}
</script>
 
<template>
  <div>
    <Row>
      <div
        v-if="reply.articles && reply.articles.length > 0"
        class="mx-auto mb-[10px] w-[280px] border border-[#eaeaea] p-[10px]"
      >
        <WxNews :articles="reply.articles" />
        <Col class="pt-[10px] text-center">
          <Button danger shape="circle" @click="onDelete">
            <template #icon>
              <IconifyIcon icon="lucide:trash-2" />
            </template>
          </Button>
        </Col>
      </div>
 
      <!-- 选择素材 -->
      <Col v-if="!reply.content" :span="24">
        <Row class="text-center" align="middle">
          <Col :span="24">
            <Button type="primary" @click="showDialog = true">
              {{
                newsType === NewsType.Published
                  ? '选择已发布图文'
                  : '选择草稿箱图文'
              }}
              <template #icon>
                <IconifyIcon icon="lucide:circle-check" />
              </template>
            </Button>
          </Col>
        </Row>
      </Col>
      <Modal
        v-model:open="showDialog"
        title="选择图文"
        :width="1200"
        :footer="null"
        destroy-on-close
      >
        <WxMaterialSelect
          type="news"
          :account-id="reply.accountId"
          :news-type="newsType"
          @select-material="selectMaterial"
        />
      </Modal>
    </Row>
  </div>
</template>