wechat-record.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import {defineComponent, onMounted, reactive, ref} from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {DataTableRowKey, NButton, NDataTable, NDatePicker, NDescriptions, NDescriptionsItem, NFormItem, NInput, NSelect, NSpace, NTag, useDialog, useMessage} from 'naive-ui'
  4. import Pagination from '@components/pagination'
  5. import {getMapValueByKey, getSelectDataFromObj} from '@/utils/objectUtil'
  6. import {appKey, clientType, messageSenderFunctionModule, messageSenderMode, musicSheetSourceType, musicSheetType} from '@/utils/constant'
  7. import {musicSheetApplicationExtendCategoryList, musicSheetApplicationExtendStatus, sysMessageConfigPage} from '@views/music-library/api'
  8. import {subjectPage, sysApplicationPage} from '@views/system-manage/api'
  9. import {filterTimes, getTimes} from "@/utils/dateUtil";
  10. import TheTooltip from "@components/TheTooltip";
  11. import {getOwnerName} from "@views/music-library/musicUtil";
  12. export default defineComponent({
  13. name: 'wechat-record',
  14. props: {
  15. appKey: {
  16. type: String,
  17. required: true
  18. }
  19. },
  20. setup(props) {
  21. const dialog = useDialog()
  22. const message = useMessage()
  23. const state = reactive({
  24. loading: false,
  25. appId: null as any,
  26. pagination: {
  27. page: 1,
  28. rows: 10,
  29. pageTotal: 0
  30. },
  31. searchForm: {
  32. description: null, //消息名称
  33. clientId: null, //客户端
  34. model: null, // 功能模块
  35. status: null // 状态
  36. },
  37. dataList: []
  38. })
  39. onMounted(async () => {
  40. getList()
  41. })
  42. const saveForm = ref()
  43. const onSearch = () => {
  44. saveForm.value?.submit()
  45. }
  46. const onBtnReset = () => {
  47. saveForm.value?.reset()
  48. }
  49. const onSubmit = () => {
  50. state.pagination.page = 1
  51. getList()
  52. }
  53. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  54. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  55. checkedRowKeysRef.value = rowKeys
  56. }
  57. const getList = async () => {
  58. try {
  59. state.loading = true
  60. const {data} = await sysMessageConfigPage({
  61. ...state.pagination,
  62. ...state.searchForm,
  63. appKey: props.appKey,
  64. sendMode:'WECHAT',
  65. })
  66. state.pagination.pageTotal = Number(data.total)
  67. state.dataList = data.rows || []
  68. } catch {
  69. }
  70. state.loading = false
  71. }
  72. const columns = (): any => {
  73. return [
  74. {
  75. title: '消息名称',
  76. key: 'description'
  77. },
  78. {
  79. title: '发送时间',
  80. key: 'sendTime'
  81. },
  82. {
  83. title: '姓名',
  84. key: 'username'
  85. },
  86. {
  87. title: 'openID',
  88. key: 'openId'
  89. },
  90. {
  91. title: '消息名称',
  92. key: 'title'
  93. },
  94. {
  95. title: '消息内容',
  96. key: 'content',
  97. render: (row: any) => (
  98. <>
  99. <NDescriptions labelPlacement="left" column={1}>
  100. <NDescriptionsItem label="流程名称">
  101. {getMapValueByKey(row.sourceType, new Map(Object.entries(musicSheetSourceType)))}
  102. </NDescriptionsItem>
  103. <NDescriptionsItem label="流程编号">
  104. {row.wxTemplateId}
  105. </NDescriptionsItem>
  106. <NDescriptionsItem label="申请人">
  107. <TheTooltip content={getOwnerName(row.musicSheetExtend, row.sourceType)} />
  108. </NDescriptionsItem>
  109. <NDescriptionsItem label="申请时间">
  110. <TheTooltip content={row.createTime} />
  111. </NDescriptionsItem>
  112. </NDescriptions>
  113. </>
  114. )
  115. },
  116. {
  117. title: '发送对象',
  118. key: 'clientId',
  119. render: (row: any) => {
  120. return (
  121. <div>
  122. {getMapValueByKey(row.clientId, new Map(Object.entries(clientType)))}
  123. </div>
  124. )
  125. }
  126. },
  127. {
  128. title: '功能模块',
  129. key: 'messageType'
  130. },
  131. {
  132. title: '触发条件',
  133. key: 'triggerCondition'
  134. },
  135. ]
  136. }
  137. return () => {
  138. return (
  139. <div class="system-menu-container">
  140. <SaveForm
  141. ref={saveForm}
  142. model={state.searchForm}
  143. onSubmit={onSubmit}
  144. saveKey="wechat-record"
  145. onSetModel={(val: any) => (state.searchForm = val)}
  146. >
  147. <NFormItem label="消息名称" path="description">
  148. <NInput
  149. placeholder="请输入消息名称"
  150. v-model:value={state.searchForm.description}
  151. clearable
  152. />
  153. </NFormItem>
  154. <NFormItem label="发送对象" path="clientId">
  155. <NSelect
  156. placeholder="全部发送对象"
  157. v-model:value={state.searchForm.clientId}
  158. options={getSelectDataFromObj(clientType)}
  159. clearable
  160. />
  161. </NFormItem>
  162. <NFormItem label="功能模块" path="model">
  163. <NSelect
  164. filterable
  165. placeholder="全部功能模块"
  166. v-model:value={state.searchForm.model}
  167. options={getSelectDataFromObj(messageSenderFunctionModule)}
  168. clearable
  169. ></NSelect>
  170. </NFormItem>
  171. <NFormItem label="状态" path="status">
  172. <NSelect
  173. v-model:value={state.searchForm.status}
  174. placeholder="请选择状态"
  175. options={
  176. [
  177. {
  178. label: '启用',
  179. value: true
  180. },
  181. {
  182. label: '停用',
  183. value: false
  184. }
  185. ] as any
  186. }
  187. clearable
  188. />
  189. </NFormItem>
  190. <NFormItem>
  191. <NSpace>
  192. <NButton type="primary" onClick={onSearch}>
  193. 搜索
  194. </NButton>
  195. <NButton type="default" onClick={onBtnReset}>
  196. 重置
  197. </NButton>
  198. </NSpace>
  199. </NFormItem>
  200. </SaveForm>
  201. <div class={['section-container']}>
  202. <NDataTable
  203. loading={state.loading}
  204. columns={columns()}
  205. data={state.dataList}
  206. rowKey={(row: any) => row.id}
  207. scrollX={'1400'}
  208. ></NDataTable>
  209. <Pagination
  210. v-model:page={state.pagination.page}
  211. v-model:pageSize={state.pagination.rows}
  212. v-model:pageTotal={state.pagination.pageTotal}
  213. onList={getList}
  214. sync
  215. saveKey="wechat-record"
  216. ></Pagination>
  217. </div>
  218. </div>
  219. )
  220. }
  221. }
  222. })