mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-09 20:57:17 +08:00
feat(system/smsConfig): 短信配置新增设为默认功能
This commit is contained in:
@@ -29,3 +29,8 @@ export function updateSmsConfig(data: any, id: string) {
|
|||||||
export function deleteSmsConfig(id: string) {
|
export function deleteSmsConfig(id: string) {
|
||||||
return http.del(`${BASE_URL}`, { ids: [id] })
|
return http.del(`${BASE_URL}`, { ids: [id] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @desc 设置默认配置 */
|
||||||
|
export function setDefaultSmsConfig(id: string) {
|
||||||
|
return http.put(`${BASE_URL}/${id}/default`)
|
||||||
|
}
|
||||||
|
@@ -379,6 +379,7 @@ export interface SmsConfigResp {
|
|||||||
maximum: string
|
maximum: string
|
||||||
supplierConfig: string
|
supplierConfig: string
|
||||||
status: number
|
status: number
|
||||||
|
isDefault: boolean
|
||||||
createUser: string
|
createUser: string
|
||||||
createTime: string
|
createTime: string
|
||||||
updateUser: string
|
updateUser: string
|
||||||
|
@@ -33,6 +33,10 @@
|
|||||||
<template #default>新增</template>
|
<template #default>新增</template>
|
||||||
</a-button>
|
</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
<template #isDefault="{ record }">
|
||||||
|
<a-tag v-if="record.isDefault" color="arcoblue">是</a-tag>
|
||||||
|
<a-tag v-else color="red">否</a-tag>
|
||||||
|
</template>
|
||||||
<template #supplier="{ record }">
|
<template #supplier="{ record }">
|
||||||
<GiCellTag :value="record.supplier" :dict="sms_supplier" />
|
<GiCellTag :value="record.supplier" :dict="sms_supplier" />
|
||||||
</template>
|
</template>
|
||||||
@@ -43,15 +47,26 @@
|
|||||||
<a-space>
|
<a-space>
|
||||||
<a-link v-permission="['system:smsLog:list']" title="发送记录" @click="onLog(record)">发送记录</a-link>
|
<a-link v-permission="['system:smsLog:list']" title="发送记录" @click="onLog(record)">发送记录</a-link>
|
||||||
<a-link v-permission="['system:smsConfig:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
<a-link v-permission="['system:smsConfig:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||||
<a-link
|
<a-dropdown>
|
||||||
v-permission="['system:smsConfig:delete']"
|
<a-button v-if="has.hasPermOr(['system:smsConfig:setDefault', 'system:smsConfig:delete'])" type="text" size="mini" title="更多">
|
||||||
status="danger"
|
<template #icon>
|
||||||
:disabled="record.disabled"
|
<icon-more :size="16" />
|
||||||
:title="record.disabled ? '不可删除' : '删除'"
|
</template>
|
||||||
@click="onDelete(record)"
|
</a-button>
|
||||||
|
<template #content>
|
||||||
|
<a-doption
|
||||||
|
v-permission="['system:smsConfig:setDefault']"
|
||||||
|
:title="record.isDefault ? '该配置已设为默认配置' : record.status === 2 ? '请先启用配置' : ''"
|
||||||
|
:disabled="record.isDefault || record.status === 2"
|
||||||
|
@click="onSetDefault(record)"
|
||||||
>
|
>
|
||||||
删除
|
设为默认
|
||||||
</a-link>
|
</a-doption>
|
||||||
|
<a-doption v-permission="['system:smsConfig:delete']" :title="record.disabled ? '不可删除' : '删除'">
|
||||||
|
<a-link status="danger" :disabled="record.disabled" @click="onDelete(record)">删除</a-link>
|
||||||
|
</a-doption>
|
||||||
|
</template>
|
||||||
|
</a-dropdown>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</GiTable>
|
</GiTable>
|
||||||
@@ -61,9 +76,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
|
import { Message, Modal } from '@arco-design/web-vue'
|
||||||
import type { TableInstance } from '@arco-design/web-vue'
|
import type { TableInstance } from '@arco-design/web-vue'
|
||||||
import SmsConfigAddModal from './SmsConfigAddModal.vue'
|
import SmsConfigAddModal from './SmsConfigAddModal.vue'
|
||||||
import { type SmsConfigQuery, type SmsConfigResp, deleteSmsConfig, listSmsConfig } from '@/apis/system/smsConfig'
|
import {
|
||||||
|
type SmsConfigQuery,
|
||||||
|
type SmsConfigResp,
|
||||||
|
deleteSmsConfig,
|
||||||
|
listSmsConfig,
|
||||||
|
setDefaultSmsConfig,
|
||||||
|
} from '@/apis/system/smsConfig'
|
||||||
import { useTable } from '@/hooks'
|
import { useTable } from '@/hooks'
|
||||||
import { useDict } from '@/hooks/app'
|
import { useDict } from '@/hooks/app'
|
||||||
import { isMobile } from '@/utils'
|
import { isMobile } from '@/utils'
|
||||||
@@ -107,6 +129,7 @@ const columns: TableInstance['columns'] = [
|
|||||||
placeholder: '请选择厂商',
|
placeholder: '请选择厂商',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ title: '是否默认', dataIndex: 'isDefault', slotName: 'isDefault', width: 100, align: 'center' },
|
||||||
{ title: 'Access Key', dataIndex: 'accessKey', slotName: 'accessKey', width: 200, ellipsis: true, tooltip: true },
|
{ title: 'Access Key', dataIndex: 'accessKey', slotName: 'accessKey', width: 200, ellipsis: true, tooltip: true },
|
||||||
{ title: 'Secret Key', dataIndex: 'secretKey', slotName: 'secretKey', width: 200, ellipsis: true, tooltip: true },
|
{ title: 'Secret Key', dataIndex: 'secretKey', slotName: 'secretKey', width: 200, ellipsis: true, tooltip: true },
|
||||||
{ title: '短信签名', dataIndex: 'signature', slotName: 'signature', width: 200, ellipsis: true, tooltip: true },
|
{ title: '短信签名', dataIndex: 'signature', slotName: 'signature', width: 200, ellipsis: true, tooltip: true },
|
||||||
@@ -143,7 +166,7 @@ const columns: TableInstance['columns'] = [
|
|||||||
width: 200,
|
width: 200,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fixed: !isMobile() ? 'right' : undefined,
|
fixed: !isMobile() ? 'right' : undefined,
|
||||||
show: has.hasPermOr(['system:smsLog:list', 'system:smsConfig:update', 'system:smsConfig:delete']),
|
show: has.hasPermOr(['system:smsLog:list', 'system:smsConfig:update', 'system:smsConfig:delete', 'system:smsConfig:setDefault']),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -158,11 +181,33 @@ const reset = () => {
|
|||||||
// 删除
|
// 删除
|
||||||
const onDelete = (record: SmsConfigResp) => {
|
const onDelete = (record: SmsConfigResp) => {
|
||||||
return handleDelete(() => deleteSmsConfig(record.id), {
|
return handleDelete(() => deleteSmsConfig(record.id), {
|
||||||
content: `是否确定删除配置「${record.name}」?`,
|
content: `是否确定删除短信配置「${record.name}」?`,
|
||||||
showModal: true,
|
showModal: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设为默认
|
||||||
|
const onSetDefault = (record: SmsConfigResp) => {
|
||||||
|
Modal.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `是否确定将短信配置「${record.name}」设为默认配置?`,
|
||||||
|
hideCancel: false,
|
||||||
|
maskClosable: false,
|
||||||
|
onBeforeOk: async () => {
|
||||||
|
try {
|
||||||
|
const res = await setDefaultSmsConfig(record.id)
|
||||||
|
if (res.success) {
|
||||||
|
Message.success('设置成功')
|
||||||
|
search()
|
||||||
|
}
|
||||||
|
return res.success
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const SmsConfigAddModalRef = ref<InstanceType<typeof SmsConfigAddModal>>()
|
const SmsConfigAddModalRef = ref<InstanceType<typeof SmsConfigAddModal>>()
|
||||||
// 新增
|
// 新增
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
|
Reference in New Issue
Block a user