2026-01-24 17:45:54 +03:30
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<BasicMainCard>
|
|
|
|
|
<div class="flex w-full h-full">
|
|
|
|
|
<tbl ref="table" class="w-full h-full" @add="add" />
|
|
|
|
|
</div>
|
|
|
|
|
</BasicMainCard>
|
|
|
|
|
|
2026-05-31 11:51:52 +03:30
|
|
|
<BasicActionSheet
|
|
|
|
|
v-model:visible="addSMSVisible"
|
|
|
|
|
title="ارسال پیامک"
|
|
|
|
|
modal-width="80vw"
|
|
|
|
|
drawer-height="90vh"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
:showButton="true"
|
|
|
|
|
:showCancel="true"
|
|
|
|
|
:showOk="true"
|
|
|
|
|
ok-text="ارسال"
|
|
|
|
|
cancel-text="انصراف"
|
2026-01-24 17:45:54 +03:30
|
|
|
@ok="ok"
|
2026-05-31 11:51:52 +03:30
|
|
|
@close="closeSmsSheet"
|
|
|
|
|
@cancel="closeSmsSheet"
|
2026-01-24 17:45:54 +03:30
|
|
|
>
|
2026-05-31 11:51:52 +03:30
|
|
|
<div v-if="isMobile" class="mb-3 text-base font-700">ارسال پیامک</div>
|
|
|
|
|
<SmsEditorFormBody ref="smsEditorRef" :form="form" :group-items="groupItems" :loading="loading" />
|
|
|
|
|
</BasicActionSheet>
|
2026-01-24 17:45:54 +03:30
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import tbl from './components/table.vue'
|
|
|
|
|
import type { FormInstance } from 'ant-design-vue'
|
2026-05-31 11:51:52 +03:30
|
|
|
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
|
|
|
|
import SmsEditorFormBody from './components/SmsEditorFormBody.vue'
|
2026-01-24 17:45:54 +03:30
|
|
|
import { message } from 'ant-design-vue/es'
|
|
|
|
|
import type { FunctionItem } from '@/model/Item'
|
2026-05-31 11:51:52 +03:30
|
|
|
import { createSMS, getGroupsList } from '@/api/sms'
|
2026-01-24 17:45:54 +03:30
|
|
|
import type { Sms } from '@/model/sms'
|
2026-05-31 11:51:52 +03:30
|
|
|
import { isMobile } from '@core/utils/is'
|
2026-01-24 17:45:54 +03:30
|
|
|
|
|
|
|
|
const loading = ref<boolean>(false)
|
|
|
|
|
const groupItems = ref<FunctionItem[]>()
|
2026-05-31 11:51:52 +03:30
|
|
|
const table = ref<null | { fetch: () => void }>(null)
|
|
|
|
|
const smsEditorRef = ref<{
|
|
|
|
|
validateFields?: () => ReturnType<NonNullable<FormInstance['validateFields']>>
|
|
|
|
|
resetAll?: () => void
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const form = ref<Sms>({
|
|
|
|
|
message: '',
|
|
|
|
|
numbers: [],
|
|
|
|
|
single: []
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const addSMSVisible = ref<boolean>(false)
|
2026-01-24 17:45:54 +03:30
|
|
|
|
|
|
|
|
onMounted(() => getGroups())
|
|
|
|
|
|
|
|
|
|
async function getGroups() {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
groupItems.value = await getGroupsList()
|
|
|
|
|
} catch (e) {
|
2026-05-31 11:51:52 +03:30
|
|
|
console.error(e)
|
2026-01-24 17:45:54 +03:30
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-31 11:51:52 +03:30
|
|
|
function refreshTable() {
|
|
|
|
|
table.value?.fetch()
|
2026-01-24 17:45:54 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-31 11:51:52 +03:30
|
|
|
function closeSmsSheet() {
|
|
|
|
|
addSMSVisible.value = false
|
2026-01-24 17:45:54 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function add() {
|
|
|
|
|
addSMSVisible.value = true
|
|
|
|
|
resetData()
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-31 11:51:52 +03:30
|
|
|
function resetData() {
|
2026-01-24 17:45:54 +03:30
|
|
|
form.value = {
|
|
|
|
|
message: '',
|
|
|
|
|
numbers: [],
|
|
|
|
|
single: []
|
|
|
|
|
}
|
2026-05-31 11:51:52 +03:30
|
|
|
smsEditorRef.value?.resetAll?.()
|
2026-01-24 17:45:54 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ok() {
|
2026-05-31 11:51:52 +03:30
|
|
|
smsEditorRef.value?.validateFields?.().then(async () => {
|
2026-01-24 17:45:54 +03:30
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
if (!form.value.numbers) form.value.numbers = []
|
2026-05-31 11:51:52 +03:30
|
|
|
form.value.numbers.push(...(form.value.single ?? []))
|
2026-01-24 17:45:54 +03:30
|
|
|
await createSMS(form.value)
|
|
|
|
|
resetData()
|
|
|
|
|
addSMSVisible.value = false
|
2026-05-31 11:51:52 +03:30
|
|
|
refreshTable()
|
2026-01-24 17:45:54 +03:30
|
|
|
message.success('با موفقیت ارسال شد')
|
|
|
|
|
} catch (e) {
|
2026-05-31 11:51:52 +03:30
|
|
|
console.error(e)
|
2026-01-24 17:45:54 +03:30
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</script>
|