relieveLogsList.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="layout-container">
  3. <!-- 菜单栏 -->
  4. <From :form-items="dynamicFormItems" @formSubmitted="handleFormSubmitted" @formReset="handleFormReset" />
  5. <!-- 表格 -->
  6. <div class="layout-container">
  7. <Table @getTableData="changeTableData" v-model:page="page" ref="table" :data="tableData"
  8. @selection-change="handleSelectionChange">
  9. <el-table-column prop="appId" label="应用ID" width="150" />
  10. <el-table-column prop="appName" label="应用名称" width="150" />
  11. <el-table-column prop="ditchName" label="渠道来源" width="150" />
  12. <el-table-column prop="nickName" label="用户昵称" width="90" />
  13. <el-table-column prop="userId" label="用户ID" width="160" />
  14. <el-table-column prop="userStatus" label="用户状态" width="90">
  15. <template #default="scope">
  16. {{ getDictionaryName('user_status',scope.row.userStatus) }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="platformId" label="平台ID" width="150" />
  20. <el-table-column prop="deblockingReason" label="解禁原因" width="200" />
  21. <el-table-column prop="deblockingTime" label="解禁时间" width="160">
  22. <template #default="scope">
  23. {{ convertUTCToBeijing(scope.row.deblockingTime) }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="lastLoginTime" label="最新登录时间" width="160">
  27. <template #default="scope">
  28. {{ convertUTCToBeijing(scope.row.lastLoginTime) }}
  29. </template>
  30. </el-table-column>
  31. <el-table-column prop="operatorName" label="操作人" width="90" />
  32. <el-table-column prop="registryTime" label="注册时间" width="160">
  33. <template #default="scope">
  34. {{ convertUTCToBeijing(scope.row.registryTime) }}
  35. </template>
  36. </el-table-column>
  37. <!-- <el-table-column label="操作" width="150" fixed="right">
  38. <template #default="scope">
  39. <div class="button">
  40. <el-button class="button-item" type="primary" style="margin-bottom: 5px;" @click="edit(scope.row)">
  41. 更改用户状态
  42. </el-button>
  43. </div>
  44. </template>
  45. </el-table-column> -->
  46. </Table>
  47. </div>
  48. <!-- 操作弹窗 -->
  49. <Layer :layer="layer" @confirm="submit(ruleForm)" @close="layer.show = false">
  50. <el-form :model="formEdit" :rules="rules" ref="ruleForm" label-width="120px" style="margin-right:30px;">
  51. <el-form-item label="用户状态:" required prop="userStatus">
  52. <el-select v-model="formEdit.userStatus" placeholder="请选择状态" filterable>
  53. <el-option v-for="option in getOptions('user_status')" :key="option.label" :label="option.label"
  54. :value="option.value">
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="原因:" prop="reason">
  59. <el-input v-model="formEdit.reason" placeholder="请输入原因" clearable />
  60. </el-form-item>
  61. </el-form>
  62. </Layer>
  63. </div>
  64. </template>
  65. <script setup>
  66. import { onBeforeMount, ref, reactive } from "vue";
  67. import From from "@/components/from/index.vue";
  68. import Table from "@/components/table/index.vue";
  69. import Layer from '@/components/layer/index.vue'
  70. import Card from './components/card/index.vue'
  71. import { ElMessage } from 'element-plus'
  72. import { riskDeblockingList, riskChangeUserStatus } from '@/api/riskModule.js'
  73. import { convertUTCToBeijing, camelToSnake } from '@/utils/index.js'
  74. import { useGetDictList } from '@/hooks/useGetDictList.js'
  75. import { useStore } from 'vuex'
  76. const store = useStore()
  77. const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
  78. const form = ref(null);
  79. const tableData = ref([]);
  80. // 分页参数, 供table使用
  81. const page = reactive({
  82. pageNum: 1,
  83. pageSize: 20,
  84. total: 0,
  85. });
  86. const formSearch = ref({
  87. appId: null,// 应用ID
  88. channelOrigin: null,// 渠道来源
  89. deblockingReason: null,// 解封原因
  90. deblockingTimeBegin: null,// 解封时间开始
  91. deblockingTimeEnd: null,// 解封时间结束
  92. loginTimeBegin: null,// 登录时间开始
  93. loginTimeEnd: null,// 登录时间截止
  94. operator: null,// 用户昵称
  95. limit: 20,// 当前页数量(查询量)
  96. page: 1,// 当前页码
  97. });
  98. const dynamicFormItems = ref([])
  99. onBeforeMount(() => {
  100. settingData()
  101. getList();
  102. });
  103. // 获取缓存数据设置筛选数据
  104. const settingData = () => {
  105. loadDictData().then(async () => {
  106. dynamicFormItems.value = [
  107. {
  108. label: '用户ID',
  109. prop: 'userId',
  110. type: 'input',
  111. needEnterEvent: true
  112. },
  113. {
  114. label: '应用ID',
  115. prop: 'appId',
  116. type: 'input',
  117. needEnterEvent: true
  118. },
  119. {
  120. label: '渠道来源',
  121. prop: 'channelOrigin',
  122. type: 'select',
  123. options: getOptions('channel_origin'),
  124. },
  125. {
  126. label: '解封原因',
  127. prop: 'deblockingReason',
  128. type: 'input',
  129. needEnterEvent: true
  130. },
  131. { label: '解封时间', prop: 'deblockingTime', type: 'daterange' },
  132. { label: '登录时间', prop: 'loginTime', type: 'daterange' },
  133. ]
  134. })
  135. }
  136. // 分页数据
  137. const getList = async () => {
  138. let res = await riskDeblockingList({ ...formSearch.value });
  139. tableData.value = res.data;
  140. page.total = res.pageMeta.total;
  141. };
  142. const changeTableData = () => {
  143. formSearch.value.page = page.pageNum;
  144. formSearch.value.limit = page.pageSize;
  145. // 分页切换
  146. getList();
  147. };
  148. // 搜索
  149. const handleFormSubmitted = (formData) => {
  150. formSearch.value.page = 1;
  151. formSearch.value.limit = 20;
  152. formSearch.value.appId = formData.appId;
  153. formSearch.value.channelId = formData.channelId;
  154. formSearch.value.channelType = formData.channelType;
  155. formSearch.value.channelOrigin = formData.channelOrigin;
  156. formSearch.value.deblockingReason = formData.deblockingReason
  157. formSearch.value.operator = formData.operator
  158. // 解封时间
  159. if (formData.deblockingTime) {
  160. formSearch.value.deblockingTimeBegin = formData.deblockingTime[0];
  161. formSearch.value.deblockingTimeEnd = formData.deblockingTime[1];
  162. }else{
  163. formSearch.value.deblockingTimeBegin = null
  164. formSearch.value.deblockingTimeEnd = null
  165. }
  166. // 登录时间
  167. if (formData.loginTime) {
  168. formSearch.value.loginTimeBegin = formData.loginTime[0];
  169. formSearch.value.loginTimeEnd = formData.loginTime[1];
  170. }else {
  171. formSearch.value.loginTimeBegin = null
  172. formSearch.value.loginTimeEnd = null
  173. }
  174. getList();
  175. };
  176. // 表单重置
  177. const handleFormReset = () => {
  178. formSearch.value = {
  179. appId: null,// 应用ID
  180. channelOrigin: null,// 渠道来源
  181. deblockingReason: null,// 解封原因
  182. deblockingTimeBegin: null,// 解封时间开始
  183. deblockingTimeEnd: null,// 解封时间结束
  184. loginTimeBegin: null,// 登录时间开始
  185. loginTimeEnd: null,// 登录时间截止
  186. operator: null,// 用户昵称
  187. limit: 20,// 当前页数量(查询量)
  188. page: 1,// 当前页码
  189. };
  190. getList();
  191. };
  192. // 选择监听器
  193. const handleSelectionChange = (val) => {
  194. // context.emit("selection-change", val)
  195. }
  196. // 弹窗
  197. const layer = ref({
  198. show: false,
  199. title: "更改用户状态",
  200. showButton: true,
  201. width: '300px'
  202. });
  203. const formEdit = ref({
  204. bannedType: null,//封禁类型 1-渠道 2-平台
  205. operator: '',//操作人
  206. operatorName: '',//操作人名称
  207. reason: '',//原因
  208. userId: '', //用户ID
  209. userStatus: null, //用户状态
  210. })
  211. const edit = (row) => {
  212. ruleForm.value?.resetFields()
  213. layer.value.show = true
  214. formEdit.value.bannedType = row.channelType
  215. formEdit.value.operator = store.state.user.info.loginName
  216. formEdit.value.operatorName = store.state.user.info.nickName
  217. formEdit.value.userId = row.userId
  218. }
  219. const ruleForm = ref(null);
  220. const rules = reactive({
  221. userStatus: [
  222. {
  223. required: true,
  224. message: "请选择用户状态",
  225. trigger: "change",
  226. },
  227. ],
  228. reason: [
  229. {
  230. required: true,
  231. message: "请输入更改原因",
  232. trigger: ["blur"],
  233. },
  234. ],
  235. });
  236. const submit = async (formEl) => {
  237. await formEl.validate(async (valid, fields) => {
  238. if (valid) {
  239. // 提交内容
  240. riskChangeUserStatus(formEdit.value).then((res) => {
  241. ElMessage.success('更改用户状态成功')
  242. getList();
  243. })
  244. } else {
  245. console.log("error submit!", fields);
  246. }
  247. })
  248. layer.value.show = false
  249. }
  250. </script>
  251. <style scoped lang="scss">
  252. .layout-container {
  253. .card {
  254. .title {
  255. margin-bottom: 10px;
  256. font-weight: 600;
  257. }
  258. display: flex;
  259. flex-direction: column;
  260. align-items: start;
  261. width: calc(100% - 60px);
  262. margin: 30px 30px 0;
  263. }
  264. .button {
  265. display: flex;
  266. flex-direction: column;
  267. .button-item {
  268. margin: 4px;
  269. }
  270. }
  271. }
  272. </style>