index.vue 6.8 KB

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