push-record.tsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. sendMode:'PUSH',
  65. ...getTimes(state.searchForm.sendTime, ['sendTimeStart', 'sendTimeEnd']),
  66. })
  67. state.pagination.pageTotal = Number(data.total)
  68. state.dataList = data.rows || []
  69. } catch {
  70. }
  71. state.loading = false
  72. }
  73. const columns = (): any => {
  74. return [
  75. {
  76. title: '发送时间',
  77. key: 'sendTime'
  78. },
  79. {
  80. title: '发送平台',
  81. key: 'sender'
  82. },
  83. {
  84. title: '姓名',
  85. key: 'username'
  86. },
  87. {
  88. title: '消息名称',
  89. key: 'title'
  90. },
  91. {
  92. title: '发送对象',
  93. key: 'clientId',
  94. render: (row: any) => {
  95. return (
  96. <div>
  97. {getMapValueByKey(row.clientId, new Map(Object.entries(clientType)))}
  98. </div>
  99. )
  100. }
  101. },
  102. {
  103. title: '功能模块',
  104. key: 'messageType'
  105. },
  106. {
  107. title: '触发条件',
  108. key: 'triggerCondition'
  109. },
  110. {
  111. title: '推送标题',
  112. key: 'title'
  113. },
  114. {
  115. title: '推送内容',
  116. key: 'content'
  117. },
  118. ]
  119. }
  120. return () => {
  121. return (
  122. <div class="system-menu-container">
  123. <SaveForm
  124. ref={saveForm}
  125. model={state.searchForm}
  126. onSubmit={onSubmit}
  127. saveKey="push-record"
  128. onSetModel={(val: any) => (state.searchForm = val)}
  129. >
  130. <NFormItem label="消息名称" path="description">
  131. <NInput
  132. placeholder="请输入消息名称"
  133. v-model:value={state.searchForm.description}
  134. clearable
  135. />
  136. </NFormItem>
  137. <NFormItem label="客户端" path="clientId">
  138. <NSelect
  139. placeholder="全部客户端"
  140. v-model:value={state.searchForm.clientId}
  141. options={getSelectDataFromObj(clientType)}
  142. clearable
  143. />
  144. </NFormItem>
  145. <NFormItem label="功能模块" path="model">
  146. <NSelect
  147. filterable
  148. placeholder="全部功能模块"
  149. v-model:value={state.searchForm.model}
  150. options={getSelectDataFromObj(messageSenderFunctionModule)}
  151. clearable
  152. ></NSelect>
  153. </NFormItem>
  154. <NFormItem label="发送时间" path="sendTime">
  155. <NDatePicker
  156. v-model:value={state.searchForm.sendTime}
  157. type="daterange"
  158. clearable
  159. value-format="yyyy.MM.dd"
  160. startPlaceholder="开始时间"
  161. endPlaceholder="结束时间"
  162. />
  163. </NFormItem>
  164. <NFormItem>
  165. <NSpace>
  166. <NButton type="primary" onClick={onSearch}>
  167. 搜索
  168. </NButton>
  169. <NButton type="default" onClick={onBtnReset}>
  170. 重置
  171. </NButton>
  172. </NSpace>
  173. </NFormItem>
  174. </SaveForm>
  175. <div class={['section-container']}>
  176. <NDataTable
  177. loading={state.loading}
  178. columns={columns()}
  179. data={state.dataList}
  180. rowKey={(row: any) => row.id}
  181. scrollX={'1400'}
  182. ></NDataTable>
  183. <Pagination
  184. v-model:page={state.pagination.page}
  185. v-model:pageSize={state.pagination.rows}
  186. v-model:pageTotal={state.pagination.pageTotal}
  187. onList={getList}
  188. sync
  189. saveKey="push-record"
  190. ></Pagination>
  191. </div>
  192. </div>
  193. )
  194. }
  195. }
  196. })