PersonAdmin.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 { getFaceToken, getFaceGuard } from "../../utils/api";
  107. import { getFaceGuardTotal, getPersonFiles } from "../../utils/chenApi";
  108. export default {
  109. name: "PersonAdmin",
  110. components: {
  111. HeadBtns,
  112. QueryConditions,
  113. NewTable,
  114. TableFooter,
  115. },
  116. data() {
  117. return {
  118. btnNames: [
  119. // 按钮情况
  120. { id: 1, name: "档案管理" },
  121. { id: 2, name: "人脸门禁" },
  122. // { id: 3, name: '赶猪监管' }
  123. ],
  124. btnSelected: 1, // 选中的按钮
  125. formItems: [], // 传给 QueryCondition 组件的 formItems
  126. propFormData: {}, // 传给 QueryCondition 组件的 propFormData
  127. title: "", // 传给 BioTable 组件的 title
  128. listData: [], // 传给 BioTable 组件的表格展示的值 listData
  129. tableItems: [], // 传给 BioTable 组件的表格的列表 tableItems
  130. tableShows: {},
  131. // table的翻页
  132. total: 0,
  133. size: 20,
  134. pageNum: 1,
  135. selectId: "",
  136. params: {},
  137. personStatus: ["已删除", "正常", "冻结"], // 档案管理 - 人员状态
  138. personSex: ["未知", "男", "女"], // 档案管理 - 性别
  139. dialogVisible: false, // 图片放大,也不知道得多老眼昏花,这么大的图片还要再大
  140. imgUrl: "", // 点击图片后放大的图片路径
  141. };
  142. },
  143. mounted() {
  144. this.formItems = formItems[this.btnSelected - 1];
  145. this.propFormData = propFormData[this.btnSelected - 1];
  146. this.title = titles[this.btnSelected - 1];
  147. this.tableItems = tableItems[this.btnSelected - 1];
  148. this.tableShows = tableShows;
  149. this.initPersonFiles();
  150. },
  151. methods: {
  152. // 获取选中的按钮情况
  153. getBtnSelected(id) {
  154. this.btnSelected = id;
  155. this.formItems = formItems[id - 1];
  156. this.propFormData = propFormData[id - 1];
  157. this.title = titles[id - 1];
  158. this.tableItems = tableItems[id - 1];
  159. this.chooseApi();
  160. },
  161. // 按钮选中情况 --> 对应的 api
  162. chooseApi(flag = true) {
  163. if (this.btnSelected === 1) {
  164. if (flag) {
  165. this.pageNum = 1;
  166. }
  167. this.initPersonFiles();
  168. } else {
  169. if (flag) {
  170. this.pageNum = 1;
  171. this.faceGuardTotal();
  172. }
  173. this.faceGuard();
  174. }
  175. },
  176. // 获取查询条件
  177. handleQuery(params) {
  178. this.params = params;
  179. this.chooseApi();
  180. },
  181. // 修改size
  182. sizeChange(val) {
  183. this.size = val;
  184. this.chooseApi(false);
  185. },
  186. // 修改页数
  187. pageChange(val) {
  188. this.pageNum = val;
  189. this.chooseApi(false);
  190. },
  191. init() {
  192. let params = {
  193. pageNum: this.pageNum,
  194. pageSize: this.size,
  195. searchStr: this.keyword,
  196. };
  197. console.log(params);
  198. // 获取后端数据
  199. },
  200. // 人脸门禁的查询
  201. faceGuard() {
  202. if (!this.params.time) {
  203. this.params.time = [
  204. timeDate(new Date().getTime() - 1000 * 60 * 60 * 24),
  205. timeDate(new Date().getTime()),
  206. ];
  207. }
  208. let queryParams = {
  209. pageNum: this.pageNum,
  210. pageSize: this.size,
  211. personName: this.params.name || undefined,
  212. startSwingTime: this.params.time[0] + " 00:00:00",
  213. endSwingTime: this.params.time[1] + " 23:59:59",
  214. openType: 61, // 进门,刷脸
  215. };
  216. getFaceGuard(queryParams).then(async (res) => {
  217. console.log("res:", res);
  218. console.log(JSON.parse(res.result));
  219. // 结果是 JSON 格式
  220. this.listData = JSON.parse(res.result).data.pageData;
  221. const { token } = await getFaceToken();
  222. this.listData.forEach((item) => {
  223. item.channelName = item.channelName.split("人脸门禁")[0];
  224. // item.recordImage = `https://36.26.62.70:447/evo-pic/${item.recordImage}?token=${token}&oss_addr=172.16.3.223:8925`;
  225. item.recordImage = `http://192.168.1.171:8089/picture/get?alarmPicture=${item.recordImage}`
  226. });
  227. console.log(this.listData)
  228. console.log("token:", token);
  229. });
  230. },
  231. // 人脸门禁总条数
  232. faceGuardTotal() {
  233. if (!this.params.time) {
  234. this.params.time = [
  235. timeDate(new Date().getTime() - 1000 * 60 * 60 * 24),
  236. timeDate(new Date().getTime()),
  237. ];
  238. }
  239. let queryParams = {
  240. personName: this.params.name || undefined,
  241. startSwingTime: this.params.time[0] + " 00:00:00",
  242. endSwingTime: this.params.time[1] + " 23:59:59",
  243. openType: 61, // 进门,刷脸
  244. };
  245. getFaceGuardTotal(queryParams).then((res) => {
  246. console.log("total:", JSON.parse(res.result));
  247. this.total = JSON.parse(res.result).data;
  248. });
  249. },
  250. // 档案管理
  251. initPersonFiles() {
  252. getPersonFiles({
  253. searchKey: "",
  254. pageNum: this.pageNum,
  255. pageSize: this.size,
  256. departmentId: this.params.departmentId || 5,
  257. isContain: true,
  258. statusList: [1, 2],
  259. }).then(async ({ success, result }) => {
  260. if (success) {
  261. const listData = JSON.parse(result);
  262. this.listData = listData.data.pageData;
  263. this.total = listData.data.totalRows;
  264. const { token } = await getFaceToken();
  265. this.listData.forEach((item) => {
  266. item.personBiosignatures[0].path = `https://36.26.62.70:447/evo-pic/${item.personBiosignatures[0].path}?token=${token}&oss_addr=172.16.3.223:9876`;
  267. });
  268. }
  269. });
  270. },
  271. // 点击图片放大
  272. clickImg(url) {
  273. this.dialogVisible = true;
  274. this.imgUrl = url;
  275. },
  276. },
  277. };
  278. </script>
  279. <style scoped>
  280. .person-admin {
  281. width: 100%;
  282. height: 100%;
  283. box-sizing: border-box;
  284. padding: 20px;
  285. }
  286. </style>