index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <wrapper
  3. fill
  4. margin
  5. padding
  6. background
  7. >
  8. <schema-table
  9. ref="table"
  10. :schema="schema"
  11. />
  12. <confirm-dialog
  13. ref="editDialog"
  14. title="抓图参数配置"
  15. @confirm="onConfirm"
  16. >
  17. <div class="c-grid-form auto u-align-self--center">
  18. <span class="c-grid-form__label">启用</span>
  19. <div class="l-flex--row c-grid-form__option">
  20. <el-switch
  21. v-model="config.enabled"
  22. active-color="#13ce66"
  23. inactive-color="#ff4949"
  24. />
  25. </div>
  26. <span class="c-grid-form__label">抓图时间范围</span>
  27. <el-time-picker
  28. v-model="range"
  29. class="u-width"
  30. is-range
  31. format="HH:mm:ss"
  32. value-format="HH:mm:ss"
  33. :clearable="false"
  34. />
  35. <span class="c-grid-form__label">抓图间隔(s)</span>
  36. <el-input-number
  37. v-model="config.offset"
  38. class="has-info"
  39. data-info="范围:5~50"
  40. controls-position="right"
  41. :min="5"
  42. :max="50"
  43. step-strictly
  44. />
  45. <span class="c-grid-form__label">开机保护时间(s)</span>
  46. <el-input-number
  47. v-model="config.preserveSecond"
  48. class="has-info"
  49. data-info="范围:0~3600"
  50. controls-position="right"
  51. :min="0"
  52. :max="3600"
  53. step-strictly
  54. />
  55. <span class="c-grid-form__label">确认黑屏持续时间(min)</span>
  56. <el-input-number
  57. v-model="config.confirmDuration"
  58. class="has-info"
  59. data-info="范围:1~30"
  60. controls-position="right"
  61. :min="1"
  62. :max="30"
  63. step-strictly
  64. />
  65. </div>
  66. </confirm-dialog>
  67. <table-dialog
  68. ref="resultDialog"
  69. title="检测结果"
  70. size="lg"
  71. :schema="snapSchema"
  72. />
  73. <preview-dialog ref="previewDialog" />
  74. <camera-dialog ref="cameraDialog" />
  75. <mesh-dialog ref="meshDialog" />
  76. </wrapper>
  77. </template>
  78. <script>
  79. import { Camera } from '@/constant'
  80. import {
  81. getCameras,
  82. updateCamera
  83. } from '@/api/external'
  84. import {
  85. AduitStatus,
  86. AduitStatusInfo,
  87. getSnapPicConfig,
  88. updateSnapPicConfig,
  89. getSnapPicResults
  90. } from './api'
  91. import MeshDialog from '../../components/MeshDialog.vue'
  92. export default {
  93. name: 'CameraSnapPic',
  94. components: {
  95. MeshDialog
  96. },
  97. data () {
  98. return {
  99. schema: {
  100. list: getCameras,
  101. condition: { cameraType: Camera.LED },
  102. filters: [
  103. { key: 'boundFlag', type: 'select', placeholder: '使用情况', options: [
  104. { value: 0, label: '未使用' },
  105. { value: 1, label: '已使用' }
  106. ] },
  107. { key: 'identifier', type: 'search', placeholder: '唯一标识' },
  108. { key: 'remark', type: 'search', placeholder: '备注' }
  109. ],
  110. cols: [
  111. { type: 'refresh' },
  112. { prop: 'manufacturerName', label: '厂商' },
  113. { prop: 'model', label: '型号' },
  114. { prop: 'identifier', label: '唯一标识' },
  115. { prop: 'remark', label: '备注', render: (data, h) => h('edit-input', {
  116. props: {
  117. value: `${data.remark}`
  118. },
  119. on: { edit: val => this.onEditRemark(data, val) }
  120. }), 'class-name': 'c-edit-column', 'min-width': 120 },
  121. { type: 'tag', render: ({ onlineStatus }) => onlineStatus === 1
  122. ? { type: 'success', label: '在线' }
  123. : { type: 'danger', label: '离线' } },
  124. { label: '使用情况', type: 'tag', render: ({ bound }) => bound
  125. ? { type: 'success', label: '已使用' }
  126. : { type: 'primary', label: '未使用' } },
  127. { type: 'invoke', render: [
  128. { label: '查看', allow: ({ onlineStatus }) => onlineStatus, on: this.onView },
  129. { label: '所属网点', allow: ({ bound }) => bound, on: this.onViewMesh },
  130. { label: '配置', on: this.onConfig },
  131. { label: '检测结果', on: this.onResult }
  132. ], width: 260 }
  133. ]
  134. },
  135. cameraId: null,
  136. config: {}
  137. }
  138. },
  139. computed: {
  140. range: {
  141. get () {
  142. return [this.config.startTime || '', this.config.endTime || '']
  143. },
  144. set (val) {
  145. this.$set(this.config, 'startTime', val[0])
  146. this.$set(this.config, 'endTime', val[1])
  147. }
  148. },
  149. snapSchema () {
  150. return {
  151. list: getSnapPicResults,
  152. condition: { cameraId: this.cameraId },
  153. cols: [
  154. { prop: 'file', type: 'asset', on: this.onViewAsset, refresh: true },
  155. { prop: 'snapTime', label: '抓图时间', width: 160 },
  156. { prop: 'auditState', label: '审核状态', type: 'tag', render: ({ auditState }) => {
  157. const info = AduitStatusInfo[auditState]
  158. return info
  159. ? {
  160. type: auditState === AduitStatus.RESOLVED
  161. ? 'success'
  162. : auditState === AduitStatus.REJECTED
  163. ? 'danger'
  164. : auditState === AduitStatus.FAILED
  165. ? 'warning'
  166. : 'primary',
  167. label: info
  168. }
  169. : null
  170. }, width: 120, align: 'center' },
  171. { prop: 'auditMsg', label: '审核信息' },
  172. { prop: 'auditTime', label: '审核时间', width: 160 }
  173. ]
  174. }
  175. }
  176. },
  177. methods: {
  178. onEditRemark (camera, { newVal, oldVal }) {
  179. if (newVal === oldVal) {
  180. return
  181. }
  182. camera.remark = newVal
  183. updateCamera({
  184. id: camera.id,
  185. username: camera.username,
  186. remark: newVal
  187. }).catch(() => {
  188. camera.remark = oldVal
  189. })
  190. },
  191. onConfig (camera) {
  192. getSnapPicConfig(camera.identifier).then(({ data }) => {
  193. const { startTime, endTime, offset, preserveSecond, confirmDuration, enabled } = {
  194. startTime: '07:00:00',
  195. endTime: '22:00:00',
  196. offset: 10,
  197. preserveSecond: 0,
  198. confirmDuration: 1,
  199. enabled: false,
  200. ...data
  201. }
  202. this.config = {
  203. startTime,
  204. endTime,
  205. offset,
  206. preserveSecond,
  207. confirmDuration,
  208. enabled
  209. }
  210. this.$identifier = camera.identifier
  211. this.$refs.editDialog.show()
  212. })
  213. },
  214. onConfirm (done) {
  215. if (!this.config.startTime || !this.config.endTime) {
  216. this.$message({
  217. type: 'warning',
  218. message: '请选择抓图时间范围'
  219. })
  220. return
  221. }
  222. updateSnapPicConfig(this.$identifier, this.config).then(done)
  223. },
  224. onView (camera) {
  225. this.$refs.cameraDialog.show(camera)
  226. },
  227. onViewMesh ({ id }) {
  228. this.$refs.meshDialog.show(id)
  229. },
  230. onResult (camera) {
  231. this.cameraId = camera.id
  232. this.$refs.resultDialog.show()
  233. },
  234. onViewAsset ({ file }) {
  235. this.$refs.previewDialog.show(file)
  236. }
  237. }
  238. }
  239. </script>