PersonAdmin.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-09-16 11:27:35
  4. * @LastEditTime: 2021-11-19 14:45:43
  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. </head-btns>
  17. <!-- 筛选条件 -->
  18. <query-conditions :formItems="formItems" :propFormData="propFormData" @getQueryParams="handleQuery"></query-conditions>
  19. <!-- 表格 -->
  20. <new-table :title="title" :listData="listData" :tableItems="tableItems" :shows="tableShows" :height="475">
  21. <template v-slot:right>
  22. <template v-if="btnSelected === 1">
  23. <div>
  24. <el-button size="mini">添加人员</el-button>
  25. <el-button size="mini">添加区域</el-button>
  26. </div>
  27. </template>
  28. <template v-else-if="btnSelected === 2">
  29. <div>
  30. <el-button size="mini">黑名单</el-button>
  31. </div>
  32. </template>
  33. <template v-else>
  34. <div>
  35. <el-button size="mini">添加赶猪人员</el-button>
  36. </div>
  37. </template>
  38. </template>
  39. <template v-slot:recordImage="slotProps">
  40. <img :src="slotProps.row.recordImage" alt="人员门禁" width="100"/>
  41. </template>
  42. </new-table>
  43. <table-footer
  44. :totals="total"
  45. :size="size"
  46. @sizeChange="sizeChange"
  47. @pageChange="pageChange">
  48. </table-footer>
  49. </div>
  50. </template>
  51. <script>
  52. import HeadBtns from 'components/bioSafety/Btns'
  53. import QueryConditions from 'components/bioSafety/QueryConditions'
  54. import NewTable from 'components/newTable/NewTable'
  55. import TableFooter from "../../components/TableFooter"
  56. import { formItems, propFormData } from './personAdmin/queryCondition.config'
  57. import { titles, tableItems, tableShows } from './personAdmin/table.config'
  58. import { getFaceToken, getFaceGuard } from '../../utils/api'
  59. import { getFaceGuardTotal } from '../../utils/chenApi'
  60. export default {
  61. name: "PersonAdmin",
  62. components: {
  63. HeadBtns,
  64. QueryConditions,
  65. NewTable,
  66. TableFooter
  67. },
  68. data() {
  69. return {
  70. btnNames: [ // 按钮情况
  71. { id: 1, name: '档案管理' },
  72. { id: 2, name: '人脸门禁' },
  73. // { id: 3, name: '赶猪监管' }
  74. ],
  75. btnSelected: 2, // 选中的按钮
  76. formItems: [], // 传给 QueryCondition 组件的 formItems
  77. propFormData: {}, // 传给 QueryCondition 组件的 propFormData
  78. title: '', // 传给 BioTable 组件的 title
  79. listData: [], // 传给 BioTable 组件的表格展示的值 listData
  80. tableItems: [], // 传给 BioTable 组件的表格的列表 tableItems
  81. tableShows: {},
  82. // table的翻页
  83. total: 0,
  84. size: 20,
  85. pageNum: 1,
  86. selectId: '',
  87. params: {}
  88. }
  89. },
  90. mounted() {
  91. this.formItems = formItems[this.btnSelected - 1]
  92. this.propFormData = propFormData[this.btnSelected - 1]
  93. this.title = titles[this.btnSelected - 1]
  94. this.tableItems = tableItems[this.btnSelected - 1]
  95. this.tableShows = tableShows
  96. },
  97. methods: {
  98. // 获取选中的按钮情况
  99. getBtnSelected(id) {
  100. this.btnSelected = id
  101. this.formItems = formItems[id - 1]
  102. this.propFormData = propFormData[id - 1]
  103. this.title = titles[id - 1]
  104. this.tableItems = tableItems[id - 1]
  105. },
  106. // 获取查询条件
  107. handleQuery(params) {
  108. this.params = params
  109. if (this.btnSelected === 2) {
  110. this.faceGuard()
  111. this.faceGuardTotal()
  112. }
  113. },
  114. // 修改size
  115. sizeChange(val) {
  116. this.size = val;
  117. if (this.btnSelected === 2) {
  118. this.faceGuard()
  119. }
  120. },
  121. // 修改页数
  122. pageChange(val) {
  123. this.pageNum= val;
  124. if (this.btnSelected === 2) {
  125. this.faceGuard()
  126. }
  127. },
  128. init() {
  129. let params = {
  130. pageNum: this.pageNum,
  131. pageSize: this.size,
  132. searchStr: this.keyword
  133. }
  134. console.log(params)
  135. // 获取后端数据
  136. },
  137. // 人脸门禁的查询
  138. faceGuard() {
  139. let queryParams = {
  140. pageNum: this.pageNum,
  141. pageSize: this.size,
  142. personName: this.params.name || undefined,
  143. startSwingTime: this.params.time[0] + ' 00:00:00',
  144. endSwingTime: this.params.time[1] + ' 23:59:59',
  145. openType: 61 // 进门,刷脸
  146. }
  147. getFaceGuard(queryParams).then(async (res) => {
  148. console.log('res:', res)
  149. console.log(JSON.parse(res.result))
  150. // 结果是 JSON 格式
  151. this.listData = JSON.parse(res.result).data.pageData
  152. const { token } = await getFaceToken()
  153. this.listData.forEach(item => {
  154. item.channelName = item.channelName.split('人脸门禁')[0]
  155. item.recordImage = `https://36.26.62.70:447/evo-pic/${item.recordImage}?token=${token}&oss_addr=172.16.3.223:8925`
  156. })
  157. console.log('token:', token)
  158. })
  159. },
  160. faceGuardTotal() {
  161. let queryParams = {
  162. personName: this.params.name || undefined,
  163. startSwingTime: this.params.time[0] + ' 00:00:00',
  164. endSwingTime: this.params.time[1] + ' 23:59:59',
  165. openType: 61 // 进门,刷脸
  166. }
  167. getFaceGuardTotal(queryParams).then(res => {
  168. console.log('total:', JSON.parse(res.result))
  169. this.total = JSON.parse(res.result).data
  170. })
  171. }
  172. },
  173. }
  174. </script>
  175. <style scoped>
  176. .person-admin {
  177. width: 100%;
  178. height: 100%;
  179. box-sizing: border-box;
  180. padding: 20px;
  181. }
  182. </style>