push-record.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import {defineComponent, onMounted, reactive, ref} from 'vue'
  2. import SaveForm from '@components/save-form'
  3. import {DataTableRowKey, NButton, NDataTable, NDatePicker, 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} 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. export default defineComponent({
  11. name: 'push-record',
  12. props: {
  13. appKey: {
  14. type: String,
  15. required: true
  16. }
  17. },
  18. setup(props) {
  19. const dialog = useDialog()
  20. const message = useMessage()
  21. const state = reactive({
  22. loading: false,
  23. appId: null as any,
  24. pagination: {
  25. page: 1,
  26. rows: 10,
  27. pageTotal: 0
  28. },
  29. searchForm: {
  30. description: null, //消息名称
  31. clientId: null, //客户端
  32. model: null, // 功能模块
  33. sendTime: null // 发送时间
  34. },
  35. dataList: []
  36. })
  37. onMounted(async () => {
  38. getList()
  39. })
  40. const saveForm = ref()
  41. const onSearch = () => {
  42. saveForm.value?.submit()
  43. }
  44. const onBtnReset = () => {
  45. saveForm.value?.reset()
  46. }
  47. const onSubmit = () => {
  48. state.pagination.page = 1
  49. getList()
  50. }
  51. const checkedRowKeysRef = ref<DataTableRowKey[]>([])
  52. const handleCheck = (rowKeys: DataTableRowKey[]) => {
  53. checkedRowKeysRef.value = rowKeys
  54. }
  55. const getList = async () => {
  56. try {
  57. state.loading = true
  58. const {data} = await sysMessageConfigPage({
  59. ...state.pagination,
  60. description: state.searchForm.description,
  61. clientId: state.searchForm.clientId,
  62. model: state.searchForm.model,
  63. appKey: props.appKey,
  64. ...getTimes(state.searchForm.sendTime, ['sendTimeStart', 'sendTimeEnd']),
  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: 'sendTime'
  77. },
  78. {
  79. title: '发送平台',
  80. key: 'sender'
  81. },
  82. {
  83. title: '姓名',
  84. key: 'username'
  85. },
  86. {
  87. title: '消息名称',
  88. key: 'title'
  89. },
  90. {
  91. title: '发送对象',
  92. key: 'clientId',
  93. render: (row: any) => {
  94. return (
  95. <div>
  96. {getMapValueByKey(row.clientId, new Map(Object.entries(clientType)))}
  97. </div>
  98. )
  99. }
  100. },
  101. {
  102. title: '功能模块',
  103. key: 'messageType'
  104. },
  105. {
  106. title: '触发条件',
  107. key: 'triggerCondition'
  108. },
  109. {
  110. title: '推送标题',
  111. key: 'title'
  112. },
  113. {
  114. title: '推送内容',
  115. key: 'content'
  116. },
  117. ]
  118. }
  119. return () => {
  120. return (
  121. <div class="system-menu-container">
  122. <SaveForm
  123. ref={saveForm}
  124. model={state.searchForm}
  125. onSubmit={onSubmit}
  126. saveKey="push-record"
  127. onSetModel={(val: any) => (state.searchForm = val)}
  128. >
  129. <NFormItem label="消息名称" path="description">
  130. <NInput
  131. placeholder="请输入消息名称"
  132. v-model:value={state.searchForm.description}
  133. clearable
  134. />
  135. </NFormItem>
  136. <NFormItem label="客户端" path="clientId">
  137. <NSelect
  138. placeholder="全部客户端"
  139. v-model:value={state.searchForm.clientId}
  140. options={getSelectDataFromObj(clientType)}
  141. clearable
  142. />
  143. </NFormItem>
  144. <NFormItem label="功能模块" path="model">
  145. <NSelect
  146. filterable
  147. placeholder="全部功能模块"
  148. v-model:value={state.searchForm.model}
  149. options={getSelectDataFromObj(messageSenderFunctionModule)}
  150. clearable
  151. ></NSelect>
  152. </NFormItem>
  153. <NFormItem label="发送时间" path="sendTime">
  154. <NDatePicker
  155. v-model:value={state.searchForm.sendTime}
  156. type="daterange"
  157. clearable
  158. value-format="yyyy.MM.dd"
  159. startPlaceholder="开始时间"
  160. endPlaceholder="结束时间"
  161. />
  162. </NFormItem>
  163. <NFormItem>
  164. <NSpace>
  165. <NButton type="primary" onClick={onSearch}>
  166. 搜索
  167. </NButton>
  168. <NButton type="default" onClick={onBtnReset}>
  169. 重置
  170. </NButton>
  171. </NSpace>
  172. </NFormItem>
  173. </SaveForm>
  174. <div class={['section-container']}>
  175. <NDataTable
  176. loading={state.loading}
  177. columns={columns()}
  178. data={state.dataList}
  179. rowKey={(row: any) => row.id}
  180. scrollX={'1400'}
  181. ></NDataTable>
  182. <Pagination
  183. v-model:page={state.pagination.page}
  184. v-model:pageSize={state.pagination.rows}
  185. v-model:pageTotal={state.pagination.pageTotal}
  186. onList={getList}
  187. sync
  188. saveKey="push-record"
  189. ></Pagination>
  190. </div>
  191. </div>
  192. )
  193. }
  194. }
  195. })