rateCount.vue 6.5 KB

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