index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <template>
  2. <div>
  3. <div class="right-top">
  4. <img src="../../assets/home.png" alt="" />
  5. <span>解封/</span>
  6. <span class="info">解封</span>
  7. </div>
  8. <el-card class="search-card">
  9. <div class="right-bottom-inp" >
  10. <div class="inp">
  11. <label for="inp2" style="background-color: #dcdfe6">编号</label>
  12. <el-input
  13. size="mini"
  14. suffix-icon="el-icon-search"
  15. type="text"
  16. id="inp2"
  17. placeholder="请输入设备编号"
  18. v-model="inp2"
  19. autocomplete="off"
  20. >
  21. </el-input>
  22. </div>
  23. <div class="btn">
  24. <el-button size="mini" @click="handleReset">重置</el-button>
  25. <el-button size="mini" type="primary" @click="handleSearchs"
  26. >查询</el-button
  27. >
  28. </div>
  29. </div>
  30. <!-- 表格部分 -->
  31. <!-- 内容区域 -->
  32. <div class="table-container">
  33. <el-table ref="multipleTable" :data="list" style="width: 100%">
  34. <el-table-column label="序号" width="100" align="center">
  35. <template slot-scope="scope">
  36. {{ scope.$index + 1 + (page - 1) * page_size }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="设备名称" width="100" align="center">
  40. <template slot-scope="scope">{{ scope.row.device_name }}</template>
  41. </el-table-column>
  42. <el-table-column label="设备编号" width="200" align="center">
  43. <template slot-scope="scope">{{ scope.row.device_id }}</template>
  44. </el-table-column>
  45. <el-table-column label="拍照数量" width="100" align="center">
  46. <template slot-scope="scope">{{ scope.row.photo_num }}</template>
  47. </el-table-column>
  48. <el-table-column label="描述信息" width="800" align="center">
  49. <template slot-scope="scope">{{ scope.row.msg_info }}</template>
  50. </el-table-column>
  51. <el-table-column label="封禁时间" width="200" align="center">
  52. <template slot-scope="scope">{{ scope.row.create_time }}</template>
  53. </el-table-column>
  54. <el-table-column label="操作" width="150" align="center">
  55. <template slot-scope="scope">
  56. <el-button
  57. size="mini"
  58. type="success"
  59. :disabled="isDisabled"
  60. @click="handleBan(scope.$index, scope.row)"
  61. >解封</el-button
  62. >
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. </div>
  67. <!-- 分页区域 -->
  68. <div class="pagination-container">
  69. <el-pagination
  70. background
  71. @current-change="handleCurrentChange"
  72. :page-size="page_size"
  73. :current-page="page"
  74. layout="prev, pager, next,jumper"
  75. :total="total"
  76. >
  77. </el-pagination>
  78. </div>
  79. </el-card>
  80. <el-card class="data" v-for="(item, index) in phoneList" :key="index">
  81. <div class="container">
  82. <span id="name">{{ item.device_id }}</span>
  83. <el-button
  84. size="small"
  85. class="button"
  86. icon="el-icon-circle-check"
  87. @click="clickcard(item)"
  88. >解封</el-button
  89. >
  90. <div class="bottom clearfix">
  91. <div class="msg-info">{{ item.msg_info.split(":")[1] }}</div>
  92. <div class="time-div">
  93. <span id="runState-text"
  94. >设备名称:<span id="runState">{{ item.device_name }}</span></span
  95. >
  96. <span id="time">{{ item.create_time }}</span>
  97. </div>
  98. </div>
  99. </div>
  100. </el-card>
  101. <el-card style="width:93%;margin:10px auto;" v-if="phoneList.length === 0 ? true : false">暂无数据</el-card>
  102. <div class="load-bottom">
  103. <div id="loadMore" @click="loadMore" v-show="isShow">加载更多...</div>
  104. <div id="loadMore" @click="put" v-show="isPut">收起</div>
  105. </div>
  106. </div>
  107. </template>
  108. <script>
  109. export default {
  110. name: "BanManage",
  111. data() {
  112. return {
  113. isDisabled: false,
  114. i: 1, //点击加载更多的i
  115. obj: {}, //存放更多操作的数据
  116. isShow: true, //加载更多是否显示
  117. isPut: false, //收起是否显示
  118. inp1: "",
  119. inp2: "",
  120. phoneList: [], //手机样式表格的数据源
  121. list: [], // 表格的数据源
  122. page: 1, // 当前是第几页
  123. page_size: 10, // 每页显示多少条数据
  124. total: null, // 数据总条数,
  125. device_name: "", // 设备名称
  126. device_id: "", // 设备id
  127. photo_num: "", // 拍照数量
  128. msg_info: "", // 描述信息
  129. create_time: "", // 封禁时间
  130. };
  131. },
  132. created() {},
  133. mounted() {
  134. this.getList();
  135. this.timer();
  136. this.getPhoneList();
  137. },
  138. methods: {
  139. // 加载更多
  140. async loadMore() {
  141. this.i++;
  142. this.isPut = true;
  143. // console.log(this.i);
  144. // 请求下所有数据,获取总数据量来判断是否显示记载更多
  145. if(this.inp2!='') {
  146. const res = await this.$axios(`/api/photo/?device_id=${this.inp2}`,"GET");
  147. let total = res.result.paging.total;
  148. const response = await this.$axios(`/api/photo/?device_id=${this.inp2}&page=${this.i}&size=10`,"GET");
  149. // console.log(response);
  150. this.phoneList = this.phoneList.concat(response.result.data)
  151. if (this.i > total / 10) {
  152. this.isShow = false;
  153. }
  154. }else {
  155. const res = await this.$axios(`/api/photo/`, "GET");
  156. // console.log(res);
  157. // console.log(res.result.paging.total);
  158. let total = res.result.paging.total;
  159. const response = await this.$axios(`/api/photo/?page=${this.i}&size=10`,"GET");
  160. // console.log(response.result.data);
  161. this.phoneList = this.phoneList.concat(response.result.data);
  162. // console.log(this.phoneList);
  163. // console.log("---------------");
  164. if (this.i > total / 10) {
  165. this.isShow = false;
  166. }
  167. }
  168. },
  169. // 收起
  170. async put() {
  171. const response = await this.$axios(`/api/photo/?page=1&size=10`, "GET");
  172. this.phoneList = [];
  173. this.phoneList = this.phoneList.concat(response.result.data);
  174. this.isPut = false;
  175. this.isShow = true;
  176. this.i = 1;
  177. this.inp2 = ''
  178. },
  179. clickcard(item) {
  180. // console.log(item)
  181. this.obj = item;
  182. // console.log(this.obj);
  183. let confirmText = ['确定解封'+this.obj.device_id+'吗?5秒后自动解封!请稍等!','注意:解封按钮3秒内只能点击一次!']
  184. const newDatas = []
  185. const h = this.$createElement
  186. for (const i in confirmText) {
  187. newDatas.push(h('p', null, confirmText[i]))
  188. }
  189. this.$confirm(
  190. // `确定解封${this.obj.device_id}吗?5秒后自动解封!请稍等!
  191. // 注意:解封按钮3秒内只能点击一次!`,
  192. "提示",
  193. {
  194. title:'提示',
  195. message:h('div',null,newDatas),
  196. confirmButtonText: "确定",
  197. cancelButtonText: "取消",
  198. type: "error",
  199. center:true
  200. }
  201. )
  202. .then(() => {
  203. // 点击确定的操作(调用接口)
  204. this.$axios("/api/photo/", "POST", {
  205. device_id: this.obj.device_id,
  206. }).then((data) => {
  207. // console.log(data);
  208. this.$message({
  209. type: "success",
  210. message: "已解封",
  211. });
  212. // 解封之后在刷新页面
  213. this.getList();
  214. });
  215. // console.log(111);
  216. this.getList();
  217. // console.log('isClick');
  218. this.isDisabled = true;
  219. setTimeout(() => {
  220. this.isDisabled = false;
  221. }, 3000);
  222. })
  223. .catch(() => {
  224. // 点取消的提示
  225. this.$message({
  226. type: "success",
  227. message: "已取消解封",
  228. });
  229. });
  230. },
  231. timer() {
  232. // setInterval(() => {
  233. // // console.log(11);s
  234. // this.getList();
  235. // }, 5000);
  236. },
  237. // pc端获取表格数据
  238. async getList() {
  239. const response = await this.$axios(
  240. `/api/photo/?page=${this.page}&size=10`,
  241. "GET"
  242. );
  243. // console.log(response);
  244. if (response.code === 0) {
  245. this.page_size = 10;
  246. this.list = response.result.data;
  247. this.total = response.result.paging.total;
  248. }
  249. },
  250. // 手机端获取数据
  251. async getPhoneList() {
  252. const response = await this.$axios(`/api/photo/?page=${this.page}&size=10`,"GET");
  253. // console.log(response);
  254. if (response.code === 0) {
  255. this.page_size = 10;
  256. this.phoneList = response.result.data;
  257. this.total = response.result.paging.total;
  258. let total = response.result.paging.total
  259. // console.log(total);
  260. if(total > 10) {
  261. this.isShow = true
  262. }else{
  263. this.isShow = false
  264. }
  265. }
  266. },
  267. // 解封操作
  268. handleBan(index, row) {
  269. this.$confirm(
  270. `确定解封${row.device_id}吗?5秒后自动解封!请稍等
  271. 注意:解封按钮3秒内只能点击一次!`,
  272. "提示",
  273. {
  274. confirmButtonText: "确定",
  275. cancelButtonText: "取消",
  276. type: "error",
  277. }
  278. )
  279. .then(() => {
  280. // 点击确定的操作(调用接口)
  281. this.$axios("/api/photo/", "POST", {
  282. device_id: row.device_id,
  283. }).then((data) => {
  284. // console.log(data);
  285. this.$message({
  286. type: "success",
  287. message: "已解封",
  288. });
  289. // 解封之后在刷新页面
  290. this.getList();
  291. });
  292. // console.log(111);
  293. this.getList();
  294. // console.log('isClick');
  295. this.isDisabled = true;
  296. setTimeout(() => {
  297. this.isDisabled = false;
  298. }, 3000);
  299. })
  300. .catch(() => {
  301. // 点取消的提示
  302. this.$message({
  303. type: "success",
  304. message: "已取消解封",
  305. });
  306. });
  307. },
  308. handleSearchs() {
  309. this.page = 1;
  310. this.handleSearch();
  311. },
  312. // 查询
  313. async handleSearch() {
  314. let response = await this.$axios(`api/photo/?device_id=${this.inp2}`)
  315. // console.log(response);
  316. let total = response.result.paging.total
  317. // console.log(total);
  318. if(total <=10) {
  319. this.isShow = false
  320. }else{
  321. this.isShow = true
  322. }
  323. // this.page = 1
  324. this.$axios(`/api/photo/?device_id=${this.inp2}&page=${this.page}&size=10`,"GET").then((res) => {
  325. // console.log(res)
  326. this.list = [];
  327. this.phoneList = [];
  328. this.list = res.result.data;
  329. this.phoneList = res.result.data;
  330. this.total = res.result.paging.total;
  331. // console.log(this.inp2)
  332. this.device_id = this.inp2;
  333. this.inp2 = this.device_id;
  334. // console.log(this.device_id)
  335. }).catch((err) => {
  336. console.log(err);
  337. });
  338. },
  339. // 重置
  340. handleReset() {
  341. this.inp2 = "";
  342. this.getList();
  343. this.getPhoneList();
  344. },
  345. handleCurrentChange(val) {
  346. // 当前页改变的时候触发
  347. // console.log(this.inp2)
  348. this.inp2 = this.inp2.trim();
  349. if (this.inp2 === "") {
  350. this.page = val;
  351. // console.log('getlist')
  352. this.getList();
  353. } else {
  354. // console.log('search')
  355. // console.log(this.device_id);
  356. this.inp2 = this.device_id;
  357. this.page = val;
  358. this.handleSearch();
  359. }
  360. },
  361. },
  362. };
  363. </script>
  364. <style scoped lang="less">
  365. // pc端样式
  366. @media screen and (min-width: 992px) {
  367. .data,
  368. .load-bottom {
  369. display: none;
  370. }
  371. .right-top {
  372. // width: 100%;
  373. // width: calc(100vw - 146px);
  374. background-color: rgb(240, 242, 245);
  375. min-width: 1185px;
  376. height: 50px;
  377. display: flex;
  378. align-items: center;
  379. font-size: 16px;
  380. color: #1a2a35;
  381. > img {
  382. margin-left: 12px;
  383. margin-right: 12px;
  384. }
  385. .info {
  386. color: #3eb984;
  387. }
  388. }
  389. .right-bottom-inp {
  390. display: flex;
  391. .inp:nth-child(2) {
  392. margin-left: 6px;
  393. }
  394. .inp {
  395. width: 260px;
  396. height: 28px;
  397. font-size: 13px;
  398. border-radius: 3px;
  399. font-weight: 500;
  400. color: #909399;
  401. display: flex;
  402. align-items: center;
  403. margin-left: 22px;
  404. label {
  405. display: inline-block;
  406. box-sizing: border-box;
  407. width: 88px;
  408. height: 28px;
  409. line-height: 28px;
  410. text-align: center;
  411. border: 1px solid #dcdfe6;
  412. border-radius: 3px 0px 0px 3px;
  413. border-right: none;
  414. }
  415. }
  416. }
  417. .el-pagination {
  418. text-align: center;
  419. margin-top: 20px;
  420. }
  421. ::v-deep {
  422. .el-pagination.is-background .el-pager li:not(.disabled).active {
  423. background-color: green;
  424. color: #fff;
  425. }
  426. .el-input__inner {
  427. border-radius: 0px !important;
  428. }
  429. }
  430. .el-card {
  431. // border: 1px solid red;
  432. // height: 800px;
  433. width: 93vw;
  434. margin: 0 auto;
  435. }
  436. .table-container {
  437. // border: 1px solid red;
  438. height: 680px;
  439. }
  440. .btn {
  441. // border: 1px solid red;
  442. margin-left: 10px;
  443. }
  444. }
  445. // 手机样式
  446. @media screen and (min-width: 320px) and (max-width: 992px) {
  447. .right-top {
  448. // border: 1px solid blue;
  449. display: none;
  450. width: 93%;
  451. height: 30px;
  452. line-height: 30px;
  453. margin: 0 auto;
  454. }
  455. .right-top img {
  456. width: 18px;
  457. height: 18px;
  458. vertical-align: middle;
  459. margin-top: -3px;
  460. }
  461. .right-top span:nth-of-type(1) {
  462. margin-left: 5px;
  463. }
  464. .info {
  465. color: #3eb984;
  466. }
  467. .inp label {
  468. display: none;
  469. }
  470. .inp .el-input {
  471. // border: 1px solid red;
  472. width: 90%;
  473. }
  474. .right-bottom-inp {
  475. display: flex;
  476. flex-direction: row;
  477. }
  478. .table-container {
  479. display: none;
  480. }
  481. .pagination-container {
  482. display: none;
  483. }
  484. // 搜索栏卡片样式
  485. .search-card {
  486. width: 93%;
  487. margin: 0 auto;
  488. // border: 1px solid red;
  489. }
  490. .inp {
  491. width: 50%;
  492. // border: 1px solid red;
  493. margin-right: 10%;
  494. }
  495. .search-card .el-input {
  496. width: 100%;
  497. // border: 1px solid green;
  498. }
  499. // 展示数据卡片
  500. .data {
  501. width: 93%;
  502. margin: 0 auto;
  503. margin-top: 5px;
  504. position: relative;
  505. }
  506. // 解封按钮
  507. .button {
  508. position: absolute;
  509. top: 5%;
  510. right: 0;
  511. border: transparent;
  512. }
  513. // 设备id
  514. #name {
  515. font-weight: 600;
  516. }
  517. .msg-info {
  518. height: 40px;
  519. margin-top: 10px;
  520. margin-bottom: 10px;
  521. }
  522. // 设备名称
  523. #runState-text {
  524. color: #999;
  525. }
  526. #runState {
  527. color: #666;
  528. }
  529. .load-bottom {
  530. display: flex;
  531. flex-direction: row;
  532. }
  533. #loadMore {
  534. width: 30%;
  535. // border: 1px solid red;
  536. padding: 10px 0;
  537. margin-top: 10px;
  538. margin-left: 50px;
  539. color: gray;
  540. text-align: center;
  541. }
  542. .time-div {
  543. display: flex;
  544. flex-direction: row;
  545. justify-content: space-between;
  546. }
  547. #time {
  548. color: #999;
  549. }
  550. ::v-deep {
  551. .search-card .el-card__body {
  552. padding: 10px;
  553. }
  554. }
  555. }
  556. </style>