GroupTimingTable.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <schema-table
  3. ref="table"
  4. :schema="schema"
  5. >
  6. <strat-config-dialog ref="stratConfigDialog" />
  7. <table-dialog
  8. ref="historyDialog"
  9. :title="historyTitle"
  10. :schema="historySchema"
  11. />
  12. <device-service-config-dialog ref="deviceServiceConfigDialog" />
  13. </schema-table>
  14. </template>
  15. <script>
  16. import { getDevicesByAdmin } from '@/api/device'
  17. import { getHistory } from '../api'
  18. import StratConfigDialog from './StratConfigDialog'
  19. import DeviceServiceConfigDialog from './DeviceServiceConfigDialog'
  20. export default {
  21. name: 'AITimingTable',
  22. components: {
  23. StratConfigDialog,
  24. DeviceServiceConfigDialog
  25. },
  26. props: {
  27. group: {
  28. type: String,
  29. required: true
  30. }
  31. },
  32. data () {
  33. return {
  34. schema: {
  35. condition: { name: '' },
  36. list: this.getDevices,
  37. filters: [
  38. { key: 'name', type: 'search', placeholder: '设备名称' }
  39. ],
  40. buttons: [
  41. { label: '策略配置', on: this.onStratConfig },
  42. { label: '全部回采记录', on: this.onAllHistory }
  43. ],
  44. cols: [
  45. { prop: 'name', label: '设备名称', 'min-width': 120 },
  46. { prop: 'serialNumber', label: '序列号' },
  47. { prop: 'mac', label: 'MAC' },
  48. { prop: 'address', label: '地址' },
  49. { type: 'invoke', width: 180, render: [
  50. { label: '服务配置', on: this.onDeviceServiceConfig },
  51. { label: '回采记录', on: this.onDeviceHistory }
  52. ] }
  53. ]
  54. },
  55. device: null
  56. }
  57. },
  58. computed: {
  59. historyTitle () {
  60. return this.device ? `${this.device.name}的回采记录` : '全部回采记录'
  61. },
  62. historySchema () {
  63. return {
  64. condition: { auditState: void 0 },
  65. list: this.getHistory,
  66. transform: this.transform,
  67. filters: [
  68. { key: 'auditState', type: 'select', placeholder: '全部状态', options: [
  69. { value: 7, label: '合规' },
  70. { value: 2, label: '疑似' },
  71. { value: 1, label: '不合规' }
  72. ] }
  73. ],
  74. cols: [
  75. { prop: 'file', label: '截图', type: 'asset' },
  76. { prop: 'ai', label: 'AI审核', type: 'tag', width: 180 },
  77. this.device ? null : { prop: 'deviceName', label: '设备名称' },
  78. { prop: 'screenshotTime', label: '回采时间' }
  79. ]
  80. }
  81. }
  82. },
  83. watch: {
  84. group () {
  85. this.$refs.table.pageTo(1)
  86. }
  87. },
  88. methods: {
  89. getDevices (params) {
  90. return getDevicesByAdmin({
  91. tenant: this.group,
  92. ...params
  93. })
  94. },
  95. getHistory (params) {
  96. return getHistory({
  97. tenant: this.group,
  98. deviceId: this.device ? this.device.id : void 0,
  99. ...params
  100. })
  101. },
  102. transform ({ deviceName, screenshotTime, screenshotUrl, screenshotDeleted, auditState, auditMsg }) {
  103. return {
  104. file: screenshotUrl && !screenshotDeleted
  105. ? { thumbnail: screenshotUrl }
  106. : null,
  107. ai: this.getAIState(auditState, auditMsg),
  108. deviceName,
  109. screenshotTime
  110. }
  111. },
  112. getAIState (status, msg) {
  113. switch (status) {
  114. case 1:
  115. return {
  116. type: 'danger',
  117. label: '不合规'
  118. }
  119. case 2:
  120. return {
  121. type: 'warning',
  122. label: '疑似',
  123. msg
  124. }
  125. case 3:
  126. return {
  127. type: 'info',
  128. label: '审核失败',
  129. msg
  130. }
  131. case 4:
  132. case 5:
  133. case 6:
  134. return {
  135. type: 'primmary',
  136. label: '审核中'
  137. }
  138. case 7:
  139. return {
  140. type: 'success',
  141. label: '通过'
  142. }
  143. case 8:
  144. return {
  145. type: 'info',
  146. label: '无法审核',
  147. msg
  148. }
  149. case 9:
  150. return {
  151. type: 'info',
  152. label: '未开启',
  153. msg
  154. }
  155. default:
  156. return null
  157. }
  158. },
  159. onServiceConfig () {
  160. this.$refs.serviceConfigDialog.show(this.group)
  161. },
  162. onStratConfig () {
  163. this.$refs.stratConfigDialog.show(this.group)
  164. },
  165. onAllHistory () {
  166. this.device = null
  167. this.$refs.historyDialog.show()
  168. },
  169. onDeviceServiceConfig ({ id, name }) {
  170. this.$refs.deviceServiceConfigDialog.show(id, name)
  171. },
  172. onDeviceHistory ({ id, name }) {
  173. this.device = { id, name }
  174. this.$refs.historyDialog.show()
  175. }
  176. }
  177. }
  178. </script>