|
@@ -0,0 +1,343 @@
|
|
|
+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,
|
|
|
+ wwxTemplateConfigStatus,
|
|
|
+ wxConfigInfoDetail,
|
|
|
+ wxConfigInfoPage,
|
|
|
+ wxConfigInfoStatus,
|
|
|
+ wxTemplateConfigPage, wxTemplateConfigRemove
|
|
|
+} from "@views/music-library/api";
|
|
|
+import PushConfigEdit from "@views/message/message-config/sms/modal/push-config-edit";
|
|
|
+import deepClone from "@/utils/deep.clone";
|
|
|
+import WechatConfigEdit from "@views/message/message-config/sms/modal/wechat-config-edit";
|
|
|
+import WechatConfigTemplateEdit from "@views/message/message-config/sms/modal/wechat-config-template-edit";
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'wechat-config-template',
|
|
|
+ setup(props, ctx) {
|
|
|
+ const route = useRoute()
|
|
|
+ const router = useRouter()
|
|
|
+ const dialog = useDialog()
|
|
|
+ const message = useMessage()
|
|
|
+ const state = reactive({
|
|
|
+ loading: false,
|
|
|
+ pagination: {
|
|
|
+ page: 1,
|
|
|
+ rows: 10,
|
|
|
+ pageTotal: 0
|
|
|
+ },
|
|
|
+ searchForm: {
|
|
|
+ keyword: null, //关键字
|
|
|
+ status: null // 状态
|
|
|
+ },
|
|
|
+ mpName: null as any,
|
|
|
+ dataList: [],
|
|
|
+ showEdit: false,
|
|
|
+ editMode: 'add',
|
|
|
+ editRowData: {} as any,
|
|
|
+ wxConfigAppId: null as any,
|
|
|
+ })
|
|
|
+ const tabsViewStore = useTabsViewStore()
|
|
|
+ const gotoBack = () => {
|
|
|
+ tabsViewStore.closeCurrentTab(route)
|
|
|
+ router.push({
|
|
|
+ path: '/message/messageConfig'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(async () => {
|
|
|
+ console.log('----------',route.query)
|
|
|
+ state.wxConfigAppId = route.query;
|
|
|
+ if (!route.query) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ {
|
|
|
+ const {data} = await wxConfigInfoDetail(route.query)
|
|
|
+ if (data) {
|
|
|
+ state.mpName = data.mpName
|
|
|
+ state.wxConfigAppId = data.appid
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ getList()
|
|
|
+ })
|
|
|
+
|
|
|
+ const saveForm = ref()
|
|
|
+ const onSearch = () => {
|
|
|
+ saveForm.value?.submit()
|
|
|
+ }
|
|
|
+ const onBtnReset = () => {
|
|
|
+ saveForm.value?.reset()
|
|
|
+ }
|
|
|
+
|
|
|
+ const onSubmit = () => {
|
|
|
+ state.pagination.page = 1
|
|
|
+ getList()
|
|
|
+ }
|
|
|
+
|
|
|
+ const getList = async () => {
|
|
|
+ if (!state.wxConfigAppId) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ state.loading = true
|
|
|
+ const {data} = await wxTemplateConfigPage({
|
|
|
+ ...state.pagination,
|
|
|
+ ...state.searchForm,
|
|
|
+ appid: state.wxConfigAppId
|
|
|
+ })
|
|
|
+ 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 wwxTemplateConfigStatus({
|
|
|
+ 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 wxTemplateConfigRemove(row.id)
|
|
|
+ getList()
|
|
|
+ message.success('删除成功')
|
|
|
+ } catch {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ const columns = (): any => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '编号',
|
|
|
+ key: 'id'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '指令',
|
|
|
+ key: 'command'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '微信模板ID',
|
|
|
+ key: 'wxTemplateId'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '模板消息地址',
|
|
|
+ key: 'url'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '描述',
|
|
|
+ key: 'description'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ key: 'status',
|
|
|
+ render(row: any) {
|
|
|
+ return (
|
|
|
+ <NTag type={row.status ? 'primary' : 'default'}>{row.status ? '启用' : '停用'}</NTag>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ key: 'operation',
|
|
|
+ fixed: 'right',
|
|
|
+ render(row: any) {
|
|
|
+ return (
|
|
|
+ <NSpace>
|
|
|
+ <NButton
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ text
|
|
|
+ onClick={() => {
|
|
|
+ router.push({
|
|
|
+ path: '/message/wxTemplateMessage',
|
|
|
+ query: row.id
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 消息内容配置
|
|
|
+ </NButton>
|
|
|
+ <NButton
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ text
|
|
|
+ onClick={() => {
|
|
|
+ onChangeStatus(row)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {row.status ? '停用' : '启用'}
|
|
|
+ </NButton>
|
|
|
+ <NButton
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ text
|
|
|
+ onClick={() => {
|
|
|
+ state.showEdit = true
|
|
|
+ state.editRowData = deepClone(row)
|
|
|
+ state.editMode = 'edit'
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </NButton>
|
|
|
+ <NButton
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ text
|
|
|
+ disabled={!!row.status}
|
|
|
+ onClick={() => {
|
|
|
+ onRmove(row)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </NButton>
|
|
|
+ </NSpace>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ return () => (
|
|
|
+ <div class="system-menu-container">
|
|
|
+ <NPageHeader
|
|
|
+ on-back={() => gotoBack()}
|
|
|
+ title={state.mpName}
|
|
|
+ ></NPageHeader>
|
|
|
+ <div class={['section-container']}>
|
|
|
+ <div class="system-menu-container">
|
|
|
+ <SaveForm
|
|
|
+ ref={saveForm}
|
|
|
+ model={state.searchForm}
|
|
|
+ onSubmit={onSubmit}
|
|
|
+ saveKey="wechat-config-template"
|
|
|
+ onSetModel={(val: any) => (state.searchForm = val)}
|
|
|
+ >
|
|
|
+ <NFormItem label="关键字" path="keyword">
|
|
|
+ <NInput
|
|
|
+ placeholder="平台编号/名称"
|
|
|
+ v-model:value={state.searchForm.keyword}
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </NFormItem>
|
|
|
+ <NFormItem label="状态" path="status">
|
|
|
+ <NSelect
|
|
|
+ v-model:value={state.searchForm.status}
|
|
|
+ clearable
|
|
|
+ options={
|
|
|
+ [
|
|
|
+ {
|
|
|
+ label: '启用',
|
|
|
+ value: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '停用',
|
|
|
+ value: 0
|
|
|
+ }
|
|
|
+ ] as any
|
|
|
+ }
|
|
|
+ placeholder="全部状态"
|
|
|
+ />
|
|
|
+ </NFormItem>
|
|
|
+ <NFormItem>
|
|
|
+ <NSpace>
|
|
|
+ <NButton type="primary" onClick={onSearch}>
|
|
|
+ 搜索
|
|
|
+ </NButton>
|
|
|
+ <NButton type="default" onClick={onBtnReset}>
|
|
|
+ 重置
|
|
|
+ </NButton>
|
|
|
+ </NSpace>
|
|
|
+ </NFormItem>
|
|
|
+ </SaveForm>
|
|
|
+
|
|
|
+ <NSpace style={{paddingBottom: '12px'}}>
|
|
|
+ <NButton
|
|
|
+ type="primary"
|
|
|
+ onClick={() => {
|
|
|
+ state.showEdit = true
|
|
|
+ state.editMode = 'add'
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 新增模板
|
|
|
+ </NButton>
|
|
|
+ </NSpace>
|
|
|
+
|
|
|
+ <div class={['section-container']}>
|
|
|
+ <NDataTable
|
|
|
+ loading={state.loading}
|
|
|
+ columns={columns()}
|
|
|
+ data={state.dataList}
|
|
|
+ rowKey={(row: any) => row.id}
|
|
|
+ scrollX={'1400'}
|
|
|
+ ></NDataTable>
|
|
|
+
|
|
|
+ <Pagination
|
|
|
+ v-model:page={state.pagination.page}
|
|
|
+ v-model:pageSize={state.pagination.rows}
|
|
|
+ v-model:pageTotal={state.pagination.pageTotal}
|
|
|
+ onList={getList}
|
|
|
+ sync
|
|
|
+ saveKey="wechat-config-template"
|
|
|
+ ></Pagination>
|
|
|
+ </div>
|
|
|
+ <NModal
|
|
|
+ blockScroll={true}
|
|
|
+ v-model:show={state.showEdit}
|
|
|
+ preset="dialog"
|
|
|
+ showIcon={false}
|
|
|
+ title={(state.editMode == 'add' ? '新增' : '编辑') + '模板'}
|
|
|
+ style={{width: 'auto'}}
|
|
|
+ >
|
|
|
+ <WechatConfigTemplateEdit
|
|
|
+ editMode={state.editMode}
|
|
|
+ rowData={state.editRowData}
|
|
|
+ style={{width: '450'}}
|
|
|
+ onClose={() => (state.showEdit = false)}
|
|
|
+ onGetList={() => {
|
|
|
+ state.pagination.page = 1
|
|
|
+ getList()
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </NModal>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|