BzyPhotos.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <div>
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item>测报系统</el-breadcrumb-item>
  5. <el-breadcrumb-item :to="{ path: '/index/bzy' }"
  6. >孢子仪</el-breadcrumb-item
  7. >
  8. <el-breadcrumb-item>查看图片</el-breadcrumb-item>
  9. </el-breadcrumb>
  10. <el-button type="success" size="small" @click="goBackPage()"
  11. ><i class="el-icon--left el-icon-d-arrow-left"></i>返回</el-button
  12. >
  13. <div class="check-btns">
  14. <div class="type-check">
  15. <el-button type="primary" size="mini" @click="equipStatusCheck('0')"
  16. >拍照</el-button
  17. >
  18. <el-button type="primary" size="mini" @click="equipStatusCheck('1')"
  19. >刷新</el-button
  20. >
  21. <template v-if="userType == 1">
  22. <el-button
  23. v-if="delBtnState"
  24. type="primary"
  25. size="mini"
  26. @click="equipStatusCheck('2')"
  27. >批量删除</el-button
  28. >
  29. <el-button
  30. v-if="!delBtnState"
  31. type="primary"
  32. size="mini"
  33. @click="equipStatusCheck('3')"
  34. >删除</el-button
  35. >
  36. <el-button
  37. v-if="!delBtnState"
  38. size="mini"
  39. @click="equipStatusCheck('4')"
  40. >取消</el-button
  41. >
  42. <el-button type="primary" size="mini" @click="equipStatusCheck('5')"
  43. >一键删除</el-button
  44. >
  45. </template>
  46. </div>
  47. <div class="search-box">
  48. <el-date-picker
  49. size="mini"
  50. v-model="timeRange"
  51. type="daterange"
  52. range-separator="至"
  53. clearable
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. @change="DateChange"
  57. ></el-date-picker>
  58. </div>
  59. </div>
  60. <el-row :gutter="30" v-viewer v-if="photoList.length > 0">
  61. <el-col
  62. :xs="24"
  63. :sm="24"
  64. :md="12"
  65. :lg="8"
  66. :xl="6"
  67. v-for="item in photoList"
  68. :key="item.addr"
  69. >
  70. <div class="photoItem">
  71. <div class="photoInfo">
  72. <template v-if="userType == 1">
  73. <i
  74. class="iconfont icon-shanchu"
  75. v-show="delBtnState"
  76. @click="delectImg(item.id)"
  77. ></i>
  78. <el-checkbox
  79. v-show="!delBtnState"
  80. v-model="item.checked"
  81. ></el-checkbox>
  82. </template>
  83. </div>
  84. <div class="photoImg">
  85. <!-- 有的图片放到阿里云,有的放到了服务器 -->
  86. <template v-if="item.addr.indexOf('http') != -1">
  87. <img :src="item.addr" />
  88. </template>
  89. <template v-else>
  90. <img :src="$host + item.addr" />
  91. </template>
  92. </div>
  93. <div class="date" style="background: #fff">
  94. {{ (item.addtime * 1000) | formatTime }}
  95. </div>
  96. <!-- <div class="photoCtrl">
  97. <div @click="viewDes()">
  98. <i class="iconfont icon-wendang"></i>
  99. 查看描述
  100. </div>
  101. </div> -->
  102. </div>
  103. </el-col>
  104. </el-row>
  105. <!-- 暂无数据 -->
  106. <div style="text-align: center" v-else>
  107. <img src="@/assets/images/expertDiagnosis/zanwu.png" alt />
  108. </div>
  109. <el-pagination
  110. v-if="photoList.length > 0"
  111. background
  112. layout="prev, pager, next"
  113. :total="totalNum"
  114. @current-change="changePage"
  115. ></el-pagination>
  116. </div>
  117. </template>
  118. <script>
  119. export default {
  120. data() {
  121. return {
  122. totalNum: 0,
  123. timeRange: [],
  124. delBtnState: true,
  125. device_id: this.$route.params.id,
  126. d_id: this.$route.query.d_id,
  127. photoList: [],
  128. queryInfo: {
  129. begin: '',
  130. end: '',
  131. page: 1
  132. },
  133. idList: [], //删除图片的地址数组
  134. photoDescDialogVisible: false
  135. }
  136. },
  137. mounted() {
  138. this.getPhoteList()
  139. },
  140. computed: {
  141. userType: function () {
  142. //获取用户类型
  143. return window.sessionStorage.getItem('myuser_type')
  144. }
  145. },
  146. methods: {
  147. equipStatusCheck(flag) {
  148. this.active = flag
  149. if (flag == 0) {
  150. //拍照
  151. this.equipBtnControl('takephoto')
  152. }
  153. if (flag == 1) {
  154. //刷新
  155. this.getPhoteList()
  156. }
  157. if (flag == 2) {
  158. this.delBtnState = false
  159. }
  160. if (flag == 3) {
  161. this.idList = this.photoList
  162. .filter((item) => {
  163. return item.checked == true
  164. })
  165. .map((item) => {
  166. return item.id
  167. })
  168. if (this.idList.length == 0) {
  169. this.$message.warning('请选择要删除的设备!')
  170. } else {
  171. this.delImgFun(this.idList)
  172. }
  173. }
  174. if (flag == 4) {
  175. this.photoList.map((item) => {
  176. item.checked = false
  177. })
  178. this.delBtnState = true
  179. }
  180. if (flag == 5) {
  181. this.delImgFun('')
  182. }
  183. },
  184. equipBtnControl(cmd) {
  185. this.$axios({
  186. method: 'POST',
  187. url:
  188. '/api/api_gateway?method=forecast.send_control.admin_device_control',
  189. data: this.qs.stringify({
  190. cmd,
  191. device_type_id: 7,
  192. d_id: this.$route.query.d_id
  193. })
  194. }).then((res) => {
  195. if (res.data.message == '') {
  196. this.$message.success('指令下发成功!')
  197. }
  198. })
  199. },
  200. getPhoteList() {
  201. this.$axios({
  202. method: 'POST',
  203. url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
  204. data: this.qs.stringify({
  205. device_id: this.device_id,
  206. ret: 'list',
  207. page: this.queryInfo.page,
  208. page_number: 8,
  209. time_begin: this.queryInfo.begin,
  210. time_end: this.queryInfo.end
  211. })
  212. }).then((res) => {
  213. if (res.data.message == '') {
  214. let data = res.data.data.data
  215. this.photoList = data.map((item) => {
  216. item.checked = false
  217. return item
  218. })
  219. this.totalNum = res.data.data.num
  220. this.$message.success('请求最新图片成功!')
  221. }
  222. })
  223. },
  224. //改变page
  225. changePage(val) {
  226. this.queryInfo.page = val
  227. this.getPhoteList()
  228. },
  229. DateChange() {
  230. this.queryInfo.page = 1
  231. if (this.timeRange) {
  232. this.queryInfo.begin = parseInt(
  233. new Date(this.timeRange[0]).getTime() / 1000
  234. )
  235. this.queryInfo.end = parseInt(
  236. new Date(this.timeRange[1]).getTime() / 1000
  237. )
  238. } else {
  239. this.queryInfo.begin = ''
  240. this.queryInfo.end = ''
  241. }
  242. this.getPhoteList()
  243. },
  244. viewDes() {
  245. this.$prompt('图片描述', '添加详情', {
  246. confirmButtonText: '保存',
  247. cancelButtonText: '取消'
  248. })
  249. .then(({ value }) => {})
  250. .catch(() => {
  251. this.$message({
  252. type: 'info',
  253. message: '取消输入'
  254. })
  255. })
  256. },
  257. delImgFun(idList) {
  258. this.$confirm('此操作将永久删除该设备图片, 是否继续?', '提示', {
  259. confirmButtonText: '确定',
  260. cancelButtonText: '取消',
  261. type: 'warning'
  262. })
  263. .then(() => {
  264. this.$axios({
  265. method: 'POST',
  266. url:
  267. '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
  268. data: this.qs.stringify({
  269. device_id: this.device_id,
  270. addrlist: JSON.stringify(idList)
  271. })
  272. }).then((res) => {
  273. if (res.data.message == '') {
  274. this.$message({
  275. type: 'success',
  276. message: '删除成功!'
  277. })
  278. this.getPhoteList()
  279. }
  280. })
  281. })
  282. .catch(() => {
  283. this.$message({
  284. type: 'info',
  285. message: '已取消删除'
  286. })
  287. })
  288. },
  289. delectImg(id) {
  290. this.delImgFun([id])
  291. },
  292. //返回上一页
  293. goBackPage() {
  294. this.$router.go(-1)
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang='less' scoped>
  300. .check-btns {
  301. display: flex;
  302. justify-content: space-between;
  303. margin-top: 10px;
  304. margin-bottom: 20px;
  305. align-items: center;
  306. .el-select {
  307. width: 90px;
  308. }
  309. }
  310. .photoItem {
  311. position: relative;
  312. border-radius: 10px;
  313. overflow: hidden;
  314. .photoInfo {
  315. position: absolute;
  316. top: 10px;
  317. left: 10px;
  318. right: 10px;
  319. display: flex;
  320. justify-content: space-between;
  321. span {
  322. color: #fff;
  323. }
  324. i {
  325. cursor: pointer;
  326. color: red;
  327. display: none;
  328. }
  329. }
  330. .photoImg {
  331. height: 250px;
  332. cursor: pointer;
  333. img {
  334. width: 100%;
  335. height: 100%;
  336. }
  337. }
  338. .date {
  339. text-align: center;
  340. font-size: 14px;
  341. padding: 10px 0;
  342. }
  343. .photoCtrl {
  344. background-color: #fff;
  345. text-align: center;
  346. line-height: 30px;
  347. font-size: 14px;
  348. color: #666;
  349. display: flex;
  350. justify-content: center;
  351. position: relative;
  352. cursor: pointer;
  353. .el-checkbox {
  354. position: absolute;
  355. right: 10px;
  356. }
  357. }
  358. }
  359. .photoItem:hover {
  360. .photoInfo i {
  361. display: block;
  362. }
  363. }
  364. </style>