import {NButton, NDataTable, NFormItem, NInput, NModal, NPageHeader, NSelect, NSpace, NTag, useDialog, useMessage} from 'naive-ui' import {defineComponent, onMounted, reactive, ref} from 'vue' import {useRoute, useRouter} from 'vue-router' import {useTabsViewStore} from '@/store/modules/tabsView' import SaveForm from "@components/save-form"; import Pagination from "@components/pagination"; import {appSendConfigPage, smsConfigDetail, smsConfigRemove, smsConfigStatus, wxConfigInfoPage, wxConfigInfoStatus} from "@views/music-library/api"; import PushConfigEdit from "@views/message/message-config/push/modal/push-config-edit"; import deepClone from "@/utils/deep.clone"; import WechatConfigEdit from "@views/message/message-config/wechat/modal/wechat-config-edit"; export default defineComponent({ name: 'wechat-config', setup(props, ctx) { const route = useRoute() const router = useRouter() const dialog = useDialog() const message = useMessage() const state = reactive({ loading: false, appId: null as any, pagination: { page: 1, rows: 10, pageTotal: 0 }, searchForm: { keyword: null, //关键字 status: null // 状态 }, name: null as any, dataList: [], showEdit: false, editMode: 'add', editRowData: {} as any, }) const tabsViewStore = useTabsViewStore() const gotoBack = () => { tabsViewStore.closeCurrentTab(route) router.push({ path: '/message/messageConfig' }) } onMounted(async () => { getList() }) const saveForm = ref() const onSearch = () => { saveForm.value?.submit() } const onBtnReset = () => { saveForm.value?.reset() } const onSubmit = () => { state.pagination.page = 1 getList() } const getList = async () => { try { state.loading = true const {data} = await wxConfigInfoPage({ ...state.pagination, ...state.searchForm, }) state.pagination.pageTotal = Number(data.total) state.dataList = data.rows || [] } catch { } state.loading = false } const onChangeStatus = (row: any) => { const statusStr = row.status ? '停用' : '启用' dialog.warning({ title: '提示', content: `是否${statusStr}?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await wxConfigInfoStatus({ id: row.id, status: !row.status }) getList() message.success(`${statusStr}成功`) } catch { } } }) } const onRmove = (row: any): void => { dialog.warning({ title: '提示', content: `删除"${row.name}",是否继续?`, positiveText: '确定', negativeText: '取消', onPositiveClick: async () => { try { await smsConfigRemove(row.id) getList() message.success('删除成功') } catch { } } }) } const columns = (): any => { return [ { title: '编号', key: 'id' }, { title: '公众号名称', key: 'mpName' }, { title: '公众号ID', key: 'appid' }, { title: '接入密钥', key: 'secret' }, { title: '消息密钥', key: 'token' }, { title: '加密模式密钥', key: 'aeskey' }, { title: '状态', key: 'status', render(row: any) { return ( {row.status ? '启用' : '停用'} ) } }, { title: '操作', key: 'operation', fixed: 'right', render(row: any) { return ( { router.push({ path: '/message/wxTemplateConfig', query: row.id }) }} > 查看模板 { onChangeStatus(row) }} > {row.status ? '停用' : '启用'} { state.showEdit = true state.editRowData = deepClone(row) state.editMode = 'edit' }} > 修改 { onRmove(row) }} > 删除 ) } } ] } return () => (
(state.searchForm = val)} > 搜索 重置 { state.showEdit = true state.editMode = 'add' }} > 新增公众号配置
row.id} scrollX={'1400'} >
(state.showEdit = false)} onGetList={() => { state.pagination.page = 1 getList() }} />
) } })