rateCount.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
  4. :leave-active-class="proxy?.animate.searchAnimate.leave">
  5. <div v-show="showSearch" class="mb-[10px]">
  6. <el-card shadow="hover" :style="{ marginTop: '10px', height: '60px' }">
  7. <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="70px">
  8. <el-form-item label="设备名称" prop="deviceName">
  9. <el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @keyup.enter="handleQuery"/>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  13. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </el-card>
  17. </div>
  18. </transition>
  19. <el-card shadow="never">
  20. <div class="table-content">
  21. <el-table v-loading="loading" :data="flowRateList" @selection-change="handleSelectionChange">
  22. <el-table-column label="" align="left" prop="" width="10"/>
  23. <el-table-column label="设备ID" align="left" prop="deviceId" width="180"/>
  24. <el-table-column label="设备名称" align="left" prop="deviceName" width="250"/>
  25. <el-table-column label="设备SN" align="left" prop="deviceSn" width="250"/>
  26. <el-table-column label="设备MAC" align="left" prop="deviceMac" width="180"/>
  27. <el-table-column label="总人数" align="center" prop="totalNum" width="100"/>
  28. <el-table-column label="今日" align="center" prop="todayNum" width="80"/>
  29. <el-table-column label="昨日" align="center" prop="yesterdayNum" width="80"/>
  30. <el-table-column label="上周" align="center" prop="lastWeekNum" width="80"/>
  31. <el-table-column label="本周" align="center" prop="weekNum" width="80"/>
  32. <el-table-column label="本月" align="center" prop="monthNum" width="80"/>
  33. <el-table-column label="备注" align="left" prop="remark" :show-overflow-tooltip="true"/>
  34. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
  35. <template #default="scope">
  36. <el-tooltip content="30天人流记录" placement="top">
  37. <el-button link type="primary" icon="View" @click="handleMonthInfo(scope.row)"
  38. v-hasPermi="['device:chatRecord:query']"></el-button>
  39. </el-tooltip>
  40. <el-tooltip content="人流列表" placement="top">
  41. <el-button link type="primary" icon="Position" @click="handleInfo(scope.row)"
  42. v-hasPermi="['device:visitorsFlowRate:query']"></el-button>
  43. </el-tooltip>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </div>
  48. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  49. v-model:limit="queryParams.pageSize" @pagination="getList"/>
  50. </el-card>
  51. <el-dialog :title="dialog.title" v-model="dialog.visible" append-to-body>
  52. <div ref="chartRef" style="width: 100%; height: 400px;"></div>
  53. <template #footer>
  54. <div class="dialog-footer">
  55. <el-button @click="cancel">关 闭</el-button>
  56. </div>
  57. </template>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script setup name="ChatRecord" lang="ts">
  62. import {getVisitorsFlowRateMonthInfo, listVisitorsFlowRateCount,} from '@/api/smsb/device/visitors_flow_rate';
  63. import {VisitorsFlowRateVO,VisitorsFlowRateForm,VisitorsFlowRateQuery} from "@/api/smsb/device/visitors_flow_rate_types";
  64. import {ref} from "vue";
  65. import {ChatRecordVO} from "@/api/smsb/device/device_chat_record_type";
  66. import * as echarts from "echarts";
  67. const {proxy} = getCurrentInstance() as ComponentInternalInstance;
  68. const flowRateList = ref<VisitorsFlowRateVO[]>([]);
  69. const buttonLoading = ref(false);
  70. const loading = ref(true);
  71. const showSearch = ref(true);
  72. const ids = ref<Array<string | number>>([]);
  73. const single = ref(true);
  74. const multiple = ref(true);
  75. const total = ref(0);
  76. const chartRef = ref();
  77. const queryFormRef = ref<ElFormInstance>();
  78. const chatRecordFormRef = ref<ElFormInstance>();
  79. const dialog = reactive<DialogOption>({
  80. visible: false,
  81. title: ''
  82. });
  83. const initFormData: VisitorsFlowRateForm = {
  84. id: undefined,
  85. deviceId: undefined,
  86. deviceName: undefined,
  87. }
  88. const data = reactive<PageData<VisitorsFlowRateForm, VisitorsFlowRateQuery>>({
  89. form: {...initFormData},
  90. queryParams: {
  91. pageNum: 1,
  92. pageSize: 10,
  93. difyId: undefined,
  94. name: undefined,
  95. deviceId: undefined,
  96. deviceName: undefined,
  97. params: {}
  98. },
  99. rules: {}
  100. });
  101. const {queryParams, form, rules} = toRefs(data);
  102. /** 查询问答记录列表 */
  103. const getList = async () => {
  104. loading.value = true;
  105. const res = await listVisitorsFlowRateCount(queryParams.value);
  106. flowRateList.value = res.rows;
  107. total.value = res.total;
  108. loading.value = false;
  109. }
  110. const handleInfo = async (row?: VisitorsFlowRateVO) => {
  111. const deviceName = row.deviceName;
  112. // 跳转页面 /source/push/review?id=1898991996092481537&type=approval&taskId=1898992031169445891
  113. proxy.$router.push('/device/pc/visitorsFlowRate?deviceName=' + deviceName);
  114. }
  115. const handleMonthInfo = async (row?: ChatRecordVO) => {
  116. const res = await getVisitorsFlowRateMonthInfo(row.deviceId);
  117. dialog.title = '30天人流记录';
  118. dialog.visible = true;
  119. // 使用 nextTick 确保 DOM 更新后再初始化图表
  120. await nextTick();
  121. const chart = echarts.init(chartRef.value, 'macaroons');
  122. chart.setOption({
  123. tooltip: {
  124. trigger: 'axis',
  125. },
  126. xAxis: {
  127. type: 'category',
  128. data: res.data.dates,
  129. },
  130. yAxis: {
  131. type: 'value',
  132. },
  133. series: [{
  134. name: '人流量',
  135. type: 'line',
  136. data: res.data.counts,
  137. smooth: true,
  138. }],
  139. });
  140. }
  141. /** 取消按钮 */
  142. const cancel = () => {
  143. reset();
  144. dialog.visible = false;
  145. }
  146. /** 表单重置 */
  147. const reset = () => {
  148. form.value = {...initFormData};
  149. chatRecordFormRef.value?.resetFields();
  150. }
  151. /** 搜索按钮操作 */
  152. const handleQuery = () => {
  153. queryParams.value.pageNum = 1;
  154. getList();
  155. }
  156. /** 重置按钮操作 */
  157. const resetQuery = () => {
  158. queryFormRef.value?.resetFields();
  159. handleQuery();
  160. }
  161. /** 多选框选中数据 */
  162. const handleSelectionChange = (selection: VisitorsFlowRateVO[]) => {
  163. ids.value = selection.map(item => item.id);
  164. single.value = selection.length != 1;
  165. multiple.value = !selection.length;
  166. }
  167. onMounted(() => {
  168. getList();
  169. });
  170. </script>