PersonAdmin.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-09-16 11:27:35
  4. * @LastEditTime: 2021-12-21 13:34:38
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \hyyfClient\src\views\BioSafety\PersonAdmin.vue
  8. -->
  9. <template>
  10. <div class="person-admin">
  11. <!-- 顶部的按钮选择 -->
  12. <head-btns
  13. :btnNames="btnNames"
  14. :btnSelected="btnSelected"
  15. @btnSelected="getBtnSelected"
  16. >
  17. </head-btns>
  18. <!-- 图 -->
  19. <board v-if="btnSelected === 2">
  20. <div
  21. class="charts"
  22. v-loading="loading"
  23. element-loading-text="拼命加载中"
  24. element-loading-spinner="el-icon-loading"
  25. element-loading-background="rgba(0, 0, 0, 0.8)"
  26. >
  27. <chart-electro :total="total1"></chart-electro>
  28. <cost-histogram v-bind="recordData"></cost-histogram>
  29. </div>
  30. </board>
  31. <!-- 筛选条件 -->
  32. <query-conditions
  33. :formItems="formItems"
  34. :propFormData="propFormData"
  35. :defaultEmit="true"
  36. @getQueryParams="handleQuery"
  37. >
  38. </query-conditions>
  39. <!-- 表格 -->
  40. <new-table
  41. :title="title"
  42. :listData="listData"
  43. :tableItems="tableItems"
  44. :shows="tableShows"
  45. :height="475"
  46. >
  47. <!-- <template v-slot:right>
  48. <template v-if="btnSelected === 1">
  49. <div>共{{ total }}人,其中男 人,女 人</div>
  50. </template>
  51. <template v-else-if="btnSelected === 2">
  52. <div>共{{ total }}人,其中男 人,女 人</div>
  53. </template>
  54. <template v-else>
  55. <div>
  56. <el-button size="mini">添加赶猪人员</el-button>
  57. </div>
  58. </template>
  59. </template> -->
  60. <!-- 人员门禁 -->
  61. <template v-slot:recordImage="slotProps">
  62. <img
  63. :src="slotProps.row.recordImage"
  64. alt="人员门禁"
  65. width="50px"
  66. @click="clickImg(slotProps.row.recordImage)"
  67. />
  68. </template>
  69. <template v-slot:personName="slotProps">
  70. {{ slotProps.row.personName ? slotProps.row.personName : "未知 " }}
  71. </template>
  72. <!-- 档案管理 -->
  73. <template v-slot:personBiosignatures="slotProps">
  74. <img
  75. :src="slotProps.row.personBiosignatures[0].path"
  76. alt="人员门禁"
  77. width="100"
  78. @click="clickImg(slotProps.row.personBiosignatures[0].path)"
  79. />
  80. </template>
  81. <template #sex="slotProps">
  82. <span>{{ personSex[slotProps.row.sex] }}</span>
  83. </template>
  84. <template #status="slotProps">
  85. <span>{{ personStatus[slotProps.row.status] }}</span>
  86. </template>
  87. </new-table>
  88. <table-footer
  89. :totals="total"
  90. :size="size"
  91. @sizeChange="sizeChange"
  92. @pageChange="pageChange"
  93. >
  94. </table-footer>
  95. <el-dialog title="人脸图片" :visible.sync="dialogVisible" width="40%">
  96. <img :src="imgUrl" alt="人脸图片" width="100%" />
  97. <span slot="footer" class="dialog-footer">
  98. <el-button @click="dialogVisible = false">取 消</el-button>
  99. <el-button type="primary" @click="dialogVisible = false">
  100. 确 定
  101. </el-button>
  102. </span>
  103. </el-dialog>
  104. </div>
  105. </template>
  106. <script>
  107. import HeadBtns from "components/bioSafety/Btns";
  108. import QueryConditions from "components/bioSafety/QueryConditions";
  109. import NewTable from "components/newTable/NewTable";
  110. import TableFooter from "../../components/TableFooter";
  111. import Board from "components/bioSafety/Board";
  112. import ChartElectro from "./chart/ChartElectro.vue";
  113. import CostHistogram from "./chart/CostHistogram.vue";
  114. import { timeDate } from "../../utils/index";
  115. import { formItems, propFormData } from "./personAdmin/queryCondition.config";
  116. import { titles, tableItems, tableShows } from "./personAdmin/table.config";
  117. import { getFaceGuard } from "../../utils/api";
  118. import {
  119. getFaceGuardTotal,
  120. getPersonFiles,
  121. getRecord,
  122. } from "../../utils/chenApi";
  123. import { mapState } from "vuex";
  124. export default {
  125. name: "PersonAdmin",
  126. components: {
  127. HeadBtns,
  128. QueryConditions,
  129. NewTable,
  130. TableFooter,
  131. Board,
  132. ChartElectro,
  133. CostHistogram,
  134. },
  135. computed: {
  136. ...mapState(["ip"]),
  137. },
  138. data() {
  139. return {
  140. btnNames: [
  141. // 按钮情况
  142. { id: 1, name: "档案管理" },
  143. { id: 2, name: "人脸门禁" },
  144. // { id: 3, name: '赶猪监管' }
  145. ],
  146. btnSelected: 1, // 选中的按钮
  147. formItems: [], // 传给 QueryCondition 组件的 formItems
  148. propFormData: {}, // 传给 QueryCondition 组件的 propFormData
  149. title: "", // 传给 BioTable 组件的 title
  150. listData: [], // 传给 BioTable 组件的表格展示的值 listData
  151. tableItems: [], // 传给 BioTable 组件的表格的列表 tableItems
  152. tableShows: {},
  153. // table的翻页
  154. total: 0,
  155. total1: 0,
  156. isTotal: false,
  157. size: 20,
  158. pageNum: 1,
  159. selectId: "",
  160. params: {},
  161. personStatus: ["已删除", "正常", "冻结"], // 档案管理 - 人员状态
  162. personSex: ["未知", "男", "女"], // 档案管理 - 性别
  163. dialogVisible: false, // 图片放大,也不知道得多老眼昏花,这么大的图片还要再大
  164. imgUrl: "", // 点击图片后放大的图片路径
  165. recordData: {}, // 进出统计
  166. loading: true,
  167. };
  168. },
  169. mounted() {
  170. this.formItems = formItems[this.btnSelected - 1];
  171. this.propFormData = propFormData[this.btnSelected - 1];
  172. this.title = titles[this.btnSelected - 1];
  173. this.tableItems = tableItems[this.btnSelected - 1];
  174. this.tableShows = tableShows;
  175. this.initPersonFiles();
  176. },
  177. methods: {
  178. // 获取选中的按钮情况
  179. getBtnSelected(id) {
  180. this.btnSelected = id;
  181. this.formItems = formItems[id - 1];
  182. this.propFormData = propFormData[id - 1];
  183. this.title = titles[id - 1];
  184. this.tableItems = tableItems[id - 1];
  185. this.chooseApi();
  186. },
  187. // 按钮选中情况 --> 对应的 api
  188. chooseApi(flag = true) {
  189. if (this.btnSelected === 1) {
  190. if (flag) {
  191. this.pageNum = 1;
  192. }
  193. this.initPersonFiles();
  194. } else {
  195. if (flag) {
  196. this.pageNum = 1;
  197. this.faceGuardTotal();
  198. }
  199. this.faceGuard();
  200. }
  201. },
  202. // 获取查询条件
  203. handleQuery(params) {
  204. this.params = params;
  205. this.chooseApi();
  206. },
  207. // 修改size
  208. sizeChange(val) {
  209. this.size = val;
  210. this.chooseApi(false);
  211. },
  212. // 修改页数
  213. pageChange(val) {
  214. this.pageNum = val;
  215. this.chooseApi(false);
  216. },
  217. init() {
  218. let params = {
  219. pageNum: this.pageNum,
  220. pageSize: this.size,
  221. searchStr: this.keyword,
  222. };
  223. // 获取后端数据
  224. },
  225. // 人脸门禁的查询 + 近 7 小时进出统计
  226. faceGuard() {
  227. if (!this.params.time) {
  228. this.params.time = [
  229. timeDate(new Date().getTime()),
  230. timeDate(new Date().getTime()),
  231. ];
  232. }
  233. let queryParams = {
  234. pageNum: this.pageNum,
  235. pageSize: this.size,
  236. personName: this.params.name || undefined,
  237. startSwingTime: this.params.time[0] + " 00:00:00",
  238. endSwingTime: this.params.time[1] + " 23:59:59",
  239. openType: 61, // 进门,刷脸
  240. };
  241. getFaceGuard(queryParams).then(async (res) => {
  242. // 结果是 JSON 格式
  243. this.listData = JSON.parse(res.result).data.pageData;
  244. this.listData.forEach((item) => {
  245. item.channelName = item.channelName.split("人脸门禁")[0];
  246. // item.recordImage = `https://36.26.62.70:447/evo-pic/${item.recordImage}?token=${token}&oss_addr=172.16.3.223:8925`;
  247. item.recordImage = `${this.ip}/video/picture/get?alarmPicture=${item.recordImage}`;
  248. });
  249. // 近 7 小时进出统计
  250. const recordRes = await getRecord({});
  251. if (recordRes.code === 0) {
  252. const timeList = [];
  253. const dataList = [];
  254. recordRes.data.forEach((item) => {
  255. timeList.push(item.time);
  256. dataList.push(item.value);
  257. });
  258. this.recordData = { timeList, dataList };
  259. } else {
  260. this.recordData = { timeList: [], dataList: [] };
  261. }
  262. this.loading = false;
  263. });
  264. },
  265. // 人脸门禁总条数
  266. faceGuardTotal() {
  267. if (!this.params.time) {
  268. this.params.time = [
  269. timeDate(new Date().getTime()),
  270. timeDate(new Date().getTime()),
  271. ];
  272. }
  273. let queryParams = {
  274. personName: this.params.name || undefined,
  275. startSwingTime: this.params.time[0] + " 00:00:00",
  276. endSwingTime: this.params.time[1] + " 23:59:59",
  277. openType: 61, // 进门,刷脸
  278. };
  279. getFaceGuardTotal(queryParams).then((res) => {
  280. console.log("total:", JSON.parse(res.result));
  281. this.total = JSON.parse(res.result).data;
  282. if(this.isTotal === false) {
  283. this.total1 = JSON.parse(res.result).data;
  284. this.isTotal = true;
  285. }
  286. });
  287. },
  288. // 档案管理
  289. initPersonFiles() {
  290. getPersonFiles({
  291. searchKey: "",
  292. pageNum: this.pageNum,
  293. pageSize: this.size,
  294. departmentId: this.params.departmentId || 5,
  295. isContain: true,
  296. statusList: [1, 2],
  297. }).then(async ({ success, result }) => {
  298. if (success) {
  299. const listData = JSON.parse(result);
  300. this.listData = listData.data.pageData;
  301. console.log(this.listData);
  302. this.total = listData.data.totalRows;
  303. this.listData.forEach((item) => {
  304. item.personBiosignatures[0].path = `${this.ip}/video/picture/get?path=${item.personBiosignatures[0].path}`;
  305. });
  306. }
  307. });
  308. },
  309. // 点击图片放大
  310. clickImg(url) {
  311. this.dialogVisible = true;
  312. this.imgUrl = url;
  313. },
  314. },
  315. };
  316. </script>
  317. <style scoped>
  318. .person-admin {
  319. width: 100%;
  320. height: 100%;
  321. box-sizing: border-box;
  322. padding: 20px;
  323. }
  324. /* 进出统计 */
  325. .charts {
  326. height: 250px;
  327. display: flex;
  328. flex-direction: row;
  329. justify-content: space-around;
  330. align-items: center;
  331. }
  332. </style>