index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <com-head :options="headList" >
  3. <el-form label-width="84px" inline="true">
  4. <el-form-item label="S/N码:">
  5. <el-input v-model="search.state.snCode" placeholder="请输入"></el-input>
  6. </el-form-item>
  7. <el-form-item label="所属架构:">
  8. <com-select v-model="search.state.deptId" />
  9. </el-form-item>
  10. <el-form-item class="searh-btns" style="grid-area: 1 / 3 / 2 / 4;">
  11. <el-button type="primary" @click="search.submit">查询</el-button>
  12. <el-button type="primary" plain @click="search.reset">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </com-head>
  16. <div class="body-layer">
  17. <div class="body-head">
  18. <h3 style="visibility: hidden;">相机列表</h3>
  19. <div class="table-ctrl-right">
  20. <!-- <el-input placeholder="关键词" suffix-icon="el-icon-search" class="search-scene" v-model="search.state.searchKey" style="width: auto" /> -->
  21. <el-button
  22. type="primary"
  23. @click="oper.readyInsert"
  24. v-if="auth.add"
  25. >绑定相机</el-button
  26. >
  27. </div>
  28. </div>
  29. <el-table
  30. ref="multipleTable"
  31. :data="dataList.state"
  32. tooltip-effect="dark"
  33. style="width: 100%"
  34. @row-click="dataList.selectRow"
  35. >
  36. <el-table-column label="序号" width="55" v-slot:default="{ $index }">
  37. <div style="text-align: center">{{ pag.state.size * (pag.state.currPage - 1) + $index + 1 }}</div>
  38. </el-table-column>usedSpace totalSpace
  39. <el-table-column label="S/N码" prop="snCode"></el-table-column>
  40. <el-table-column label="所属架构" prop="deptName"></el-table-column>
  41. <el-table-column label="云容量使用情况" v-slot:default="{ row }">
  42. {{row.usedSpaceStr}} / {{row.totalSpaceStr}}
  43. </el-table-column>
  44. <el-table-column label="操作" v-slot:default="{ row }" v-if="auth.unbind || auth.update">
  45. <!-- <span class="oper-span" @click="oper.readyUpdate(row)" v-if="auth.update">编辑</span> -->
  46. <span class="oper-span"
  47. @click="unbindCamrea(row)"
  48. v-if="auth.delete"
  49. style="color: var(--primaryColor)">
  50. 解绑
  51. </span>
  52. </el-table-column>
  53. </el-table>
  54. <com-pagination
  55. @size-change="pag.sizeChange"
  56. @current-change="pag.currentChange"
  57. :current-page="pag.state.currPage"
  58. :page-size="pag.state.size"
  59. layout="total, sizes, prev, pager, next, jumper"
  60. :total="pag.state.total"/>
  61. </div>
  62. <com-dialog
  63. :title="(oper.state.id ? '编辑' : '绑定') + '相机'"
  64. v-model:show="oper.state.show"
  65. enterText="确 定"
  66. @submit="submit"
  67. width="480"
  68. >
  69. <el-form ref="form" :model="form" label-width="68px" class="camera-from">
  70. <el-form-item label="SN码:" class="mandatory">
  71. <el-input :modelValue="oper.state.snCode" placeholder="请输入相机底部SN码,如214D5RE2G8" @update:modelValue="val => oper.state.snCode = val.trim()"></el-input>
  72. </el-form-item>
  73. </el-form>
  74. </com-dialog>
  75. </template>
  76. <script>
  77. import { ref, watch } from "vue";
  78. import getTableState from "@/state/tableRef";
  79. import auth from "@/state/viewAuth";
  80. import comDialog from "@/components/dialog";
  81. import comPagination from "@/components/pagination";
  82. import comSelect from "@/components/company-select";
  83. import comHead from "@/components/head";
  84. import { dateFormat } from '@/util'
  85. import {
  86. getCameraList,
  87. insertCamera,
  88. deleteCamera,
  89. unbindCamera,
  90. updateCamera
  91. } from '@/request/config'
  92. import axios from 'axios';
  93. export default {
  94. name: 'camera',
  95. setup() {
  96. const state = getTableState({
  97. insertUrl: insertCamera,
  98. updateUrl: updateCamera,
  99. getUrl: getCameraList,
  100. delUrl: deleteCamera,
  101. searchAttr: { deptId: '', snCode: '' },
  102. operAttr: { snCode: '', cameraSn: '' },
  103. delMsg: '解绑相机,该相机拍摄的场景也将一并解绑(场景在云端存储,不会删除)确定要解绑吗?'
  104. });
  105. const headList = ref([{ name: "相机管理", value: 2 }]);
  106. const time = ref(null)
  107. watch(state.oper.value.state, () => {
  108. state.oper.value.state.cameraSn = state.oper.value.state.snCode
  109. })
  110. watch(time, () => {
  111. if (time.value) {
  112. state.search.value.state.startTime = dateFormat(new Date(time.value[0]), 'yyyy-MM-dd hh:mm:ss')
  113. state.search.value.state.endTime = dateFormat(new Date(time.value[1]), 'yyyy-MM-dd 23:59:59')
  114. } else {
  115. state.search.value.state.startTime = state.search.value.state.endTime = ''
  116. }
  117. })
  118. watch(
  119. [() => state.search.value.state.startTime, () => state.search.value.state.endTime],
  120. () => {
  121. if (!state.search.value.state.startTime || !state.search.value.state.endTime) {
  122. time.value = null
  123. }
  124. }
  125. )
  126. return { ...state, headList, time, auth };
  127. },
  128. methods: {
  129. async unbindCamrea(data) {
  130. if (await this.$confirm('解绑相机,该相机拍摄的场景也将一并解绑(场景在云端存储,不会删除)确定要解绑吗?', '提示')) {
  131. await axios.post(unbindCamera, {cameraSn: data.snCode})
  132. this.dataList.refer()
  133. }
  134. },
  135. submit() {
  136. if (!this.oper.state.snCode.trim()) {
  137. return this.$message.error('S/N码不能为空!', '提示')
  138. }
  139. this.oper.state.id ? this.oper.update() : this.oper.insert()
  140. }
  141. },
  142. components: {
  143. "com-dialog": comDialog,
  144. "com-head": comHead,
  145. "com-pagination": comPagination,
  146. "com-select": comSelect
  147. },
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. .table-ctrl-right {
  152. .search-scene {
  153. margin: 0 20px 0 26px;
  154. }
  155. i {
  156. margin-left: 20px;
  157. font-size: 1.7rem;
  158. vertical-align: middle;
  159. cursor: pointer;
  160. &.active {
  161. color: var(--primaryColor);
  162. }
  163. }
  164. }
  165. // .camera-from {
  166. // width: 420px;
  167. // margin: 0 auto;
  168. // }
  169. </style>