PersonAdmin.vue 8.7 KB

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