From 982c97ab82f3beb1b4febcf014562eda34b9fc05 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期二, 29 九月 2026 17:59:41 +0800
Subject: [PATCH] feat(ui): 江苏商贸品牌视觉与首页/登录页改版
---
src/views/wxcp/notice/modules/push-modal.vue | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/src/views/wxcp/notice/modules/push-modal.vue b/src/views/wxcp/notice/modules/push-modal.vue
new file mode 100644
index 0000000..918ad4a
--- /dev/null
+++ b/src/views/wxcp/notice/modules/push-modal.vue
@@ -0,0 +1,100 @@
+<script lang="ts" setup>
+import type { WxCpNoticeApi } from '#/api/wxcp/notice';
+
+import { ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+import { Alert, Button, message } from 'ant-design-vue';
+
+import { pushNotice } from '#/api/wxcp/notice';
+
+import PushScopePicker from '../../components/push-scope-picker.vue';
+import { PUSH_SCOPE } from '../../data';
+
+defineOptions({ name: 'WxCpNoticePushModal' });
+
+const emit = defineEmits<{ success: [] }>();
+
+const notice = ref<WxCpNoticeApi.Notice>({});
+const scope = ref<number>(PUSH_SCOPE.ALL);
+const target = ref<string>('');
+const pushing = ref(false);
+const resultMessage = ref('');
+
+const [Modal, modalApi] = useVbenModal({
+ onOpenChange(isOpen: boolean) {
+ if (!isOpen) {
+ notice.value = {};
+ resultMessage.value = '';
+ return;
+ }
+ const data = modalApi.getData<{ notice: WxCpNoticeApi.Notice }>();
+ notice.value = data.notice ?? {};
+ scope.value = data.notice?.pushScope ?? PUSH_SCOPE.ALL;
+ target.value = data.notice?.pushTarget ?? '';
+ },
+});
+
+async function handlePush() {
+ if (!notice.value.id) {
+ return;
+ }
+ if (scope.value !== PUSH_SCOPE.ALL && !target.value.trim()) {
+ message.warning('閫夋嫨銆屾寚瀹氶儴闂ㄣ�嶆垨銆屾寚瀹氭垚鍛樸�嶆椂锛岃鍏堥�夋嫨鎺ㄩ�佺洰鏍�');
+ return;
+ }
+ pushing.value = true;
+ resultMessage.value = '';
+ try {
+ const res = await pushNotice({
+ id: notice.value.id,
+ pushScope: scope.value,
+ pushTarget: scope.value === PUSH_SCOPE.ALL ? '' : target.value,
+ });
+ if (res?.success) {
+ message.success('鎺ㄩ�佹垚鍔�');
+ emit('success');
+ await modalApi.close();
+ } else {
+ resultMessage.value = res?.message || '鎺ㄩ�佸け璐�';
+ }
+ } catch (error: unknown) {
+ resultMessage.value = (error as Error)?.message || '鎺ㄩ�佸け璐�';
+ } finally {
+ pushing.value = false;
+ }
+}
+</script>
+
+<template>
+ <Modal title="鎺ㄩ�侀�氱煡" class="w-2/5">
+ <div class="px-4">
+ <div class="mb-4 rounded bg-gray-50 p-3 text-sm dark:bg-gray-800">
+ <div class="mb-1 font-medium">{{ notice.title }}</div>
+ <div class="text-gray-500">
+ 鎺ㄩ�佸悗鎴愬憳鐨勪紒涓氬井淇′細鏀跺埌绾枃鏈秷鎭紝鍐呭瓒呰繃 600 瀛椾細鑷姩鎴柇銆�
+ </div>
+ </div>
+
+ <div class="mb-2 text-sm font-medium">鎺ㄩ�佽寖鍥�</div>
+ <PushScopePicker v-model:scope="scope" v-model:target="target" />
+
+ <Alert
+ v-if="resultMessage"
+ class="mt-4"
+ type="error"
+ :message="resultMessage"
+ show-icon
+ />
+ </div>
+
+ <template #footer>
+ <div class="flex justify-end gap-2">
+ <Button @click="modalApi.close()">鍙栨秷</Button>
+ <Button type="primary" :loading="pushing" @click="handlePush">
+ 纭鎺ㄩ��
+ </Button>
+ </div>
+ </template>
+ </Modal>
+</template>
--
Gitblit v1.9.3