init
This commit is contained in:
231
src/views/system/notify/message/index.vue
Normal file
231
src/views/system/notify/message/index.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<avue-crud
|
||||
ref="crudRef"
|
||||
v-model="tableForm"
|
||||
v-model:page="tablePage"
|
||||
v-model:search="tableSearch"
|
||||
:table-loading="loading"
|
||||
:data="tableData"
|
||||
:option="tableOption"
|
||||
:permission="permission"
|
||||
:before-open="beforeOpen"
|
||||
@search-change="searchChange"
|
||||
@search-reset="resetChange"
|
||||
@refresh-change="getTableData"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
>
|
||||
<!-- 表格 -->
|
||||
<template #readStatus="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="scope.row.readStatus != undefined ? scope.row.readStatus : ''"
|
||||
/>
|
||||
</template>
|
||||
<template #templateType="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="scope.row.templateType != undefined ? scope.row.templateType : ''"
|
||||
/>
|
||||
</template>
|
||||
<!-- 表单 -->
|
||||
<template #templateParams-form="{ value }">
|
||||
<div class="el-input__wrapper" style="box-shadow: none">{{ JSON.stringify(value) }}</div>
|
||||
</template>
|
||||
<template #readStatus-form="{ value }">
|
||||
<div class="el-input__wrapper" style="box-shadow: none">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="value != undefined ? value : ''"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #templateType-form="{ value }">
|
||||
<div class="el-input__wrapper" style="box-shadow: none">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="value != undefined ? value : ''"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter, getSearchDate } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
defineOptions({ name: 'SystemNotifyMessage' })
|
||||
|
||||
const { getCurrPermi } = useCrudPermi()
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const tableOption = reactive({
|
||||
addBtn: false,
|
||||
editBtn: false,
|
||||
delBtn: false,
|
||||
viewBtn: true,
|
||||
viewBtnText: '详情',
|
||||
viewBtnIcon: ' ',
|
||||
align: 'center',
|
||||
headerAlign: 'center',
|
||||
searchMenuSpan: 6,
|
||||
searchMenuPosition: 'left',
|
||||
labelSuffix: ' ',
|
||||
labelWidth: 160,
|
||||
span: 24,
|
||||
dialogWidth: '50%',
|
||||
menuWidth: 120,
|
||||
column: {
|
||||
id: {
|
||||
label: '编号',
|
||||
width: 80
|
||||
},
|
||||
userId: {
|
||||
label: '用户编号',
|
||||
search: true,
|
||||
minWidth: 90
|
||||
},
|
||||
templateId: {
|
||||
label: '模板编号',
|
||||
minWidth: 90,
|
||||
hide: true
|
||||
},
|
||||
templateCode: {
|
||||
label: '模板编码',
|
||||
minWidth: 90,
|
||||
search: true
|
||||
},
|
||||
templateNickname: {
|
||||
label: '发送人名称',
|
||||
minWidth: 100
|
||||
},
|
||||
templateContent: {
|
||||
label: '模版内容',
|
||||
width: 200,
|
||||
overHidden: true
|
||||
},
|
||||
templateParams: {
|
||||
label: '模版参数',
|
||||
width: 200,
|
||||
overHidden: true
|
||||
},
|
||||
templateType: {
|
||||
label: '模版类型',
|
||||
search: true,
|
||||
type: 'select',
|
||||
minWidth: 100,
|
||||
dicData: getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE),
|
||||
value: ''
|
||||
},
|
||||
readStatus: {
|
||||
label: '是否已读',
|
||||
type: 'select',
|
||||
width: 90,
|
||||
dicData: getIntDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING),
|
||||
value: ''
|
||||
},
|
||||
readTime: {
|
||||
label: '阅读时间',
|
||||
type: 'datetime',
|
||||
width: 180,
|
||||
formatter: (row, val, value, column) => {
|
||||
return dateFormatter(row, column, val)
|
||||
}
|
||||
},
|
||||
searchCreateTime: {
|
||||
label: '创建时间',
|
||||
search: true,
|
||||
hide: true,
|
||||
display: false,
|
||||
searchType: 'daterange',
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间'
|
||||
},
|
||||
createTime: {
|
||||
label: '创建时间',
|
||||
type: 'datetime',
|
||||
width: 180,
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
formatter: (row, val, value, column) => {
|
||||
return dateFormatter(row, column, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}) //表格配置
|
||||
const tableForm = ref<{ id?: number }>({})
|
||||
const tableData = ref([])
|
||||
const tableSearch = ref<any>({})
|
||||
const tablePage = ref({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
const permission = getCurrPermi(['system:notify-message'])
|
||||
const crudRef = ref()
|
||||
|
||||
useCrudHeight(crudRef)
|
||||
|
||||
/** 查询列表 */
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
|
||||
let searchObj = {
|
||||
...tableSearch.value,
|
||||
pageNo: tablePage.value.currentPage,
|
||||
pageSize: tablePage.value.pageSize
|
||||
}
|
||||
|
||||
if (searchObj.searchCreateTime?.length) {
|
||||
searchObj.createTime = getSearchDate(searchObj.searchCreateTime)
|
||||
}
|
||||
delete searchObj.searchCreateTime
|
||||
for (let key in searchObj) if (searchObj[key] === '') delete searchObj[key]
|
||||
try {
|
||||
const data = await NotifyMessageApi.getNotifyMessagePage(searchObj)
|
||||
tableData.value = data.list
|
||||
tablePage.value.total = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const searchChange = (params, done) => {
|
||||
tablePage.value.currentPage = 1
|
||||
getTableData().finally(() => {
|
||||
done()
|
||||
})
|
||||
}
|
||||
|
||||
/** 清空按钮操作 */
|
||||
const resetChange = () => {
|
||||
searchChange({}, () => {})
|
||||
}
|
||||
|
||||
const sizeChange = (pageSize) => {
|
||||
tablePage.value.pageSize = pageSize
|
||||
resetChange()
|
||||
}
|
||||
|
||||
const currentChange = (currentPage) => {
|
||||
tablePage.value.currentPage = currentPage
|
||||
getTableData()
|
||||
}
|
||||
|
||||
/** 表单打开前 */
|
||||
const beforeOpen = async (done, type) => {
|
||||
if (['view'].includes(type) && tableForm.value.id) {
|
||||
// tableForm.value = await NotifyMessageApi.getDictType(tableForm.value.id)
|
||||
}
|
||||
done()
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getTableData()
|
||||
})
|
||||
</script>
|
||||
248
src/views/system/notify/my/index.vue
Normal file
248
src/views/system/notify/my/index.vue
Normal file
@@ -0,0 +1,248 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<avue-crud
|
||||
ref="crudRef"
|
||||
v-model="tableForm"
|
||||
v-model:page="tablePage"
|
||||
v-model:search="tableSearch"
|
||||
:table-loading="loading"
|
||||
:data="tableData"
|
||||
:option="tableOption"
|
||||
:before-open="beforeOpen"
|
||||
@selection-change="selectionChange"
|
||||
@search-change="searchChange"
|
||||
@search-reset="resetChange"
|
||||
@refresh-change="getTableData"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
>
|
||||
<template #menu-left="{ size }">
|
||||
<el-button @click="handleUpdateList" :size="size" :disabled="!tableSelect.length">
|
||||
<Icon icon="ep:reading" class="mr-5px" /> 设置已读
|
||||
</el-button>
|
||||
<el-button @click="handleUpdateAll" :size="size">
|
||||
<Icon icon="ep:reading" class="mr-5px" /> 全部已读
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格 -->
|
||||
<template #readStatus="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="scope.row.readStatus != undefined ? scope.row.readStatus : ''"
|
||||
/>
|
||||
</template>
|
||||
<template #templateType="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="scope.row.templateType != undefined ? scope.row.templateType : ''"
|
||||
/>
|
||||
</template>
|
||||
<!-- 表单 -->
|
||||
<template #readStatus-form="{ value }">
|
||||
<div class="el-input__wrapper" style="box-shadow: none">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="value != undefined ? value : ''"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #templateType-form="{ value }">
|
||||
<div class="el-input__wrapper" style="box-shadow: none">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="value != undefined ? value : ''"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions, getBoolDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter, getSearchDate } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
defineOptions({ name: 'SystemNotifyMessage' })
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const tableOption = reactive({
|
||||
addBtn: false,
|
||||
editBtn: false,
|
||||
delBtn: false,
|
||||
viewBtn: true,
|
||||
viewBtnText: '查看',
|
||||
viewBtnIcon: ' ',
|
||||
align: 'center',
|
||||
headerAlign: 'center',
|
||||
searchMenuSpan: 6,
|
||||
searchMenuPosition: 'left',
|
||||
labelSuffix: ' ',
|
||||
labelWidth: 160,
|
||||
span: 24,
|
||||
dialogWidth: '50%',
|
||||
menuWidth: 120,
|
||||
selection: true,
|
||||
reserveSelection: true,
|
||||
column: {
|
||||
templateNickname: {
|
||||
label: '发送人',
|
||||
width: 140
|
||||
},
|
||||
searchCreateTime: {
|
||||
label: '发送时间',
|
||||
search: true,
|
||||
hide: true,
|
||||
display: false,
|
||||
searchType: 'daterange',
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间'
|
||||
},
|
||||
createTime: {
|
||||
label: '发送时间',
|
||||
searchRange: true,
|
||||
type: 'datetime',
|
||||
width: 180,
|
||||
formatter: (row, val, value, column) => {
|
||||
return dateFormatter(row, column, val)
|
||||
}
|
||||
},
|
||||
templateType: {
|
||||
label: '类型',
|
||||
width: 120,
|
||||
type: 'select',
|
||||
dicData: getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)
|
||||
},
|
||||
templateContent: {
|
||||
label: '消息内容',
|
||||
type: 'textarea',
|
||||
overHidden: true
|
||||
},
|
||||
readStatus: {
|
||||
label: '是否已读',
|
||||
type: 'select',
|
||||
width: 90,
|
||||
search: true,
|
||||
dicData: getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)
|
||||
},
|
||||
readTime: {
|
||||
label: '阅读时间',
|
||||
type: 'datetime',
|
||||
width: 180,
|
||||
viewDisplay: true,
|
||||
formatter: (row, val, value, column) => {
|
||||
return dateFormatter(row, column, val)
|
||||
}
|
||||
}
|
||||
},
|
||||
selectable: (row) => {
|
||||
return !row.readStatus
|
||||
}
|
||||
}) //表格配置
|
||||
const tableForm = ref<any>({})
|
||||
const tableData = ref([])
|
||||
const tableSearch = ref<any>({})
|
||||
const tablePage = ref({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
const tableSelect = ref<any[]>([])
|
||||
const crudRef = ref()
|
||||
|
||||
useCrudHeight(crudRef)
|
||||
|
||||
/** 标记一条站内信已读 */
|
||||
const handleReadOne = async (id) => {
|
||||
loading.value = true
|
||||
await NotifyMessageApi.updateNotifyMessageRead(id)
|
||||
await getTableData()
|
||||
}
|
||||
|
||||
/** 标记全部站内信已读 **/
|
||||
const handleUpdateAll = async () => {
|
||||
loading.value = true
|
||||
await NotifyMessageApi.updateAllNotifyMessageRead()
|
||||
message.success('全部已读成功!')
|
||||
crudRef.value.clearSelection()
|
||||
await getTableData()
|
||||
}
|
||||
|
||||
/** 标记一些站内信已读 **/
|
||||
const handleUpdateList = async () => {
|
||||
if (tableSelect.value.length === 0) {
|
||||
return
|
||||
}
|
||||
const ids = tableSelect.value.map((item) => item.id)
|
||||
await NotifyMessageApi.updateNotifyMessageRead(ids)
|
||||
message.success('批量已读成功!')
|
||||
crudRef.value.clearSelection()
|
||||
await getTableData()
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
|
||||
let searchObj = {
|
||||
...tableSearch.value,
|
||||
pageNo: tablePage.value.currentPage,
|
||||
pageSize: tablePage.value.pageSize
|
||||
}
|
||||
|
||||
if (searchObj.searchCreateTime?.length) {
|
||||
searchObj.createTime = getSearchDate(searchObj.searchCreateTime)
|
||||
}
|
||||
delete searchObj.searchCreateTime
|
||||
for (let key in searchObj) if (searchObj[key] === '') delete searchObj[key]
|
||||
try {
|
||||
const data = await NotifyMessageApi.getMyNotifyMessagePage(searchObj)
|
||||
tableData.value = data.list
|
||||
tablePage.value.total = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const searchChange = (params, done) => {
|
||||
tablePage.value.currentPage = 1
|
||||
getTableData().finally(() => {
|
||||
done()
|
||||
})
|
||||
}
|
||||
|
||||
/** 清空按钮操作 */
|
||||
const resetChange = () => {
|
||||
searchChange({}, () => {})
|
||||
}
|
||||
|
||||
const sizeChange = (pageSize) => {
|
||||
tablePage.value.pageSize = pageSize
|
||||
resetChange()
|
||||
}
|
||||
|
||||
const currentChange = (currentPage) => {
|
||||
tablePage.value.currentPage = currentPage
|
||||
getTableData()
|
||||
}
|
||||
|
||||
/** 表单打开前 */
|
||||
const beforeOpen = async (done, type) => {
|
||||
if (['view'].includes(type) && !tableForm.value.readStatus) {
|
||||
handleReadOne(tableForm.value.id)
|
||||
}
|
||||
tableOption.column.readTime.viewDisplay = tableForm.value.readStatus
|
||||
done()
|
||||
}
|
||||
|
||||
const selectionChange = (data) => {
|
||||
tableSelect.value = data
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getTableData()
|
||||
})
|
||||
</script>
|
||||
346
src/views/system/notify/template/index.vue
Normal file
346
src/views/system/notify/template/index.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<avue-crud
|
||||
ref="crudRef"
|
||||
v-model="tableForm"
|
||||
v-model:page="tablePage"
|
||||
v-model:search="tableSearch"
|
||||
:table-loading="loading"
|
||||
:data="tableData"
|
||||
:option="tableOption"
|
||||
:permission="permission"
|
||||
:before-open="beforeOpen"
|
||||
@search-change="searchChange"
|
||||
@search-reset="resetChange"
|
||||
@row-save="rowSave"
|
||||
@row-update="rowUpdate"
|
||||
@row-del="rowDel"
|
||||
@refresh-change="getTableData"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
>
|
||||
<template #type="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="scope.row.type ? scope.row.type : ''"
|
||||
/>
|
||||
</template>
|
||||
<template #status="scope">
|
||||
<dict-tag
|
||||
v-if="scope.row.status !== undefined"
|
||||
:type="DICT_TYPE.COMMON_STATUS"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
<!-- 自定义操作栏 -->
|
||||
<template #menu="{ row }">
|
||||
<el-button
|
||||
v-if="row.status === 0"
|
||||
class="ml-4px!"
|
||||
v-hasPermi="['system:notify-template:send-notify']"
|
||||
link
|
||||
@click="openSendForm(row)"
|
||||
type="primary"
|
||||
>
|
||||
<Icon :size="14" icon="ep:document"></Icon>
|
||||
<span>测试</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</ContentWrap>
|
||||
<!-- 表单弹窗:测试发送 -->
|
||||
<DesignPopup
|
||||
v-model="testPopup"
|
||||
title="发送站内信模板测试"
|
||||
:is-footer="true"
|
||||
width="40%"
|
||||
class="notify-template-popup"
|
||||
>
|
||||
<div class="p-20px">
|
||||
<avue-form ref="textFormRef" v-if="testPopup" v-model="testFormData" :option="testFormOption">
|
||||
<template #userId="{ column, disabled }">
|
||||
<UserSelect
|
||||
v-model="testFormData.userId"
|
||||
:column="column"
|
||||
:disabled="disabled"
|
||||
type="edit"
|
||||
prop="userId"
|
||||
></UserSelect>
|
||||
</template>
|
||||
</avue-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button :loading="textLoading" type="primary" @click="testSubmitFun">发 送</el-button>
|
||||
<el-button @click="testPopup = false">取 消</el-button>
|
||||
</template>
|
||||
</DesignPopup>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as NotifyTemplateApi from '@/api/system/notify/template'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
|
||||
defineOptions({ name: 'NotifySmsTemplate' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const { getCurrPermi } = useCrudPermi()
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const tableOption = reactive({
|
||||
align: 'center',
|
||||
headerAlign: 'center',
|
||||
searchMenuSpan: 6,
|
||||
searchMenuPosition: 'left',
|
||||
labelSuffix: ' ',
|
||||
labelWidth: 100,
|
||||
span: 24,
|
||||
dialogWidth: '55%',
|
||||
overHidden: true,
|
||||
searchLabelWidth: 90,
|
||||
column: {
|
||||
code: {
|
||||
label: '模板编码',
|
||||
minWidth: 90,
|
||||
span: 12,
|
||||
rules: [{ required: true, message: '模板编码不能为空', trigger: 'blur' }]
|
||||
},
|
||||
name: {
|
||||
label: '模板名称',
|
||||
search: true,
|
||||
span: 12,
|
||||
minWidth: 90,
|
||||
rules: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }]
|
||||
},
|
||||
nickname: {
|
||||
label: '发送人名称',
|
||||
search: true,
|
||||
minWidth: 90,
|
||||
rules: [{ required: true, message: '发送人名称不能为空', trigger: 'blur' }]
|
||||
},
|
||||
content: {
|
||||
label: '模板内容',
|
||||
minWidth: 100,
|
||||
rules: [{ required: true, message: '模板内容不能为空', trigger: 'blur' }],
|
||||
type: 'textarea',
|
||||
minRows: 2,
|
||||
maxRows: 4
|
||||
},
|
||||
type: {
|
||||
label: '类型',
|
||||
type: 'select',
|
||||
span: 12,
|
||||
dicData: getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE),
|
||||
rules: [{ required: true, message: '类型不能为空', trigger: 'blur' }]
|
||||
},
|
||||
status: {
|
||||
label: '状态',
|
||||
search: true,
|
||||
type: 'radio',
|
||||
span: 12,
|
||||
width: 80,
|
||||
dicData: getIntDictOptions(DICT_TYPE.COMMON_STATUS),
|
||||
rules: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
|
||||
value: CommonStatusEnum.ENABLE
|
||||
},
|
||||
remark: {
|
||||
label: '备注',
|
||||
type: 'textarea',
|
||||
minWidth: 130,
|
||||
minRows: 2,
|
||||
maxRows: 4
|
||||
},
|
||||
createTime: {
|
||||
label: '创建时间',
|
||||
searchRange: true,
|
||||
display: false,
|
||||
type: 'datetime',
|
||||
width: 180,
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
formatter: (row, val, value, column) => {
|
||||
return dateFormatter(row, column, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}) //表格配置
|
||||
const tableForm = ref<{ id?: number }>({})
|
||||
const tableData = ref([])
|
||||
const tableSearch = ref({})
|
||||
const tablePage = ref({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
})
|
||||
const permission = getCurrPermi(['system:notify-template'])
|
||||
const crudRef = ref()
|
||||
|
||||
useCrudHeight(crudRef)
|
||||
|
||||
/** 查询列表 */
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
let searchObj = {
|
||||
...tableSearch.value,
|
||||
pageNo: tablePage.value.currentPage,
|
||||
pageSize: tablePage.value.pageSize
|
||||
}
|
||||
for (let key in searchObj) if (searchObj[key] === '') delete searchObj[key]
|
||||
try {
|
||||
const data = await NotifyTemplateApi.getNotifyTemplatePage(searchObj)
|
||||
tableData.value = data.list
|
||||
tablePage.value.total = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const searchChange = (params, done) => {
|
||||
tablePage.value.currentPage = 1
|
||||
getTableData().finally(() => {
|
||||
done()
|
||||
})
|
||||
}
|
||||
|
||||
/** 清空按钮操作 */
|
||||
const resetChange = () => {
|
||||
searchChange({}, () => {})
|
||||
}
|
||||
|
||||
const sizeChange = (pageSize) => {
|
||||
tablePage.value.pageSize = pageSize
|
||||
resetChange()
|
||||
}
|
||||
|
||||
const currentChange = (currentPage) => {
|
||||
tablePage.value.currentPage = currentPage
|
||||
getTableData()
|
||||
}
|
||||
|
||||
/** 表单打开前 */
|
||||
const beforeOpen = async (done, type) => {
|
||||
if (['edit', 'view'].includes(type) && tableForm.value.id) {
|
||||
tableForm.value = await NotifyTemplateApi.getNotifyTemplate(tableForm.value.id)
|
||||
}
|
||||
done()
|
||||
}
|
||||
|
||||
/** 新增操作 */
|
||||
const rowSave = async (form, done, loading) => {
|
||||
let bool = await NotifyTemplateApi.createNotifyTemplate(form).catch(() => false)
|
||||
if (bool) {
|
||||
message.success(t('common.createSuccess'))
|
||||
resetChange()
|
||||
done()
|
||||
} else loading()
|
||||
}
|
||||
|
||||
/** 编辑操作 */
|
||||
const rowUpdate = async (form, index, done, loading) => {
|
||||
let bool = await NotifyTemplateApi.updateNotifyTemplate(form).catch(() => false)
|
||||
if (bool) {
|
||||
message.success(t('common.updateSuccess'))
|
||||
getTableData()
|
||||
done()
|
||||
} else loading()
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const rowDel = async (form, index) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await NotifyTemplateApi.deleteNotifyTemplate(form.id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getTableData()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 发送站内信按钮 */
|
||||
// 测试表单配置
|
||||
const testPopup = ref(false)
|
||||
const testFormData = ref<any>({})
|
||||
const testFormOption = ref({
|
||||
submitBtn: false,
|
||||
emptyBtn: false,
|
||||
span: 24,
|
||||
labelWidth: 120,
|
||||
column: {}
|
||||
})
|
||||
const textLoading = ref(false)
|
||||
const textFormRef = ref()
|
||||
// 打开测试表单
|
||||
const openSendForm = async (row: NotifyTemplateApi.NotifyTemplateVO) => {
|
||||
loading.value = true
|
||||
const formDatas = await NotifyTemplateApi.getNotifyTemplate(row.id || 0)
|
||||
testFormData.value = {
|
||||
content: formDatas.content,
|
||||
params: formDatas.params,
|
||||
templateCode: formDatas.code,
|
||||
templateParams: {}
|
||||
}
|
||||
testFormOption.value.column = {
|
||||
content: { label: '模板内容', type: 'textarea', disabled: true },
|
||||
userId: {
|
||||
label: '接收人',
|
||||
findType: 'all',
|
||||
multiple: true,
|
||||
columnKey: ['sex', 'post', 'deptName'],
|
||||
rules: [{ required: true, message: `接收人不能为空`, trigger: 'change' }]
|
||||
}
|
||||
}
|
||||
// 设置动态参数
|
||||
if (formDatas.params?.length) {
|
||||
formDatas.params.forEach((item) => {
|
||||
testFormData.value.templateParams[item] = ''
|
||||
testFormOption.value.column[item] = {
|
||||
label: `参数 ${item} `,
|
||||
value: '',
|
||||
bind: `templateParams.${item}`,
|
||||
rules: [{ required: true, message: `参数 ${item} 不能为空`, trigger: 'blur' }]
|
||||
}
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
testPopup.value = true
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const testSubmitFun = () => {
|
||||
textFormRef.value.validate(async (valid, hide) => {
|
||||
if (!valid) return hide()
|
||||
try {
|
||||
textLoading.value = true
|
||||
await NotifyTemplateApi.sendNotify({
|
||||
userIdList: testFormData.value.userId.split(','),
|
||||
userType: 2,
|
||||
templateCode: testFormData.value.templateCode,
|
||||
templateParams: testFormData.value.templateParams
|
||||
})
|
||||
testPopup.value = false
|
||||
} finally {
|
||||
hide()
|
||||
textLoading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getTableData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.notify-template-popup {
|
||||
.el-form-item__label {
|
||||
height: auto;
|
||||
min-height: 32px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user