| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <template>
- <div>
- <el-breadcrumb separator-class="el-icon-arrow-right">
- <el-breadcrumb-item>测报系统</el-breadcrumb-item>
- <el-breadcrumb-item :to="{ path: '/index/bzy' }"
- >孢子仪</el-breadcrumb-item
- >
- <el-breadcrumb-item>查看图片</el-breadcrumb-item>
- </el-breadcrumb>
- <el-button type="success" size="small" @click="goBackPage()"
- ><i class="el-icon--left el-icon-d-arrow-left"></i>返回</el-button
- >
- <div class="check-btns">
- <div class="type-check">
- <el-button type="primary" size="mini" @click="equipStatusCheck('0')"
- >拍照</el-button
- >
- <el-button type="primary" size="mini" @click="equipStatusCheck('1')"
- >刷新</el-button
- >
- <template v-if="userType == 1">
- <el-button
- v-if="delBtnState"
- type="primary"
- size="mini"
- @click="equipStatusCheck('2')"
- >批量删除</el-button
- >
- <el-button
- v-if="!delBtnState"
- type="primary"
- size="mini"
- @click="equipStatusCheck('3')"
- >删除</el-button
- >
- <el-button
- v-if="!delBtnState"
- size="mini"
- @click="equipStatusCheck('4')"
- >取消</el-button
- >
- <el-button type="primary" size="mini" @click="equipStatusCheck('5')"
- >一键删除</el-button
- >
- </template>
- </div>
- <div class="search-box">
- <el-date-picker
- size="mini"
- v-model="timeRange"
- type="daterange"
- range-separator="至"
- clearable
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- @change="DateChange"
- ></el-date-picker>
- </div>
- </div>
- <el-row :gutter="30" v-viewer v-if="photoList.length > 0">
- <el-col
- :xs="24"
- :sm="24"
- :md="12"
- :lg="8"
- :xl="6"
- v-for="item in photoList"
- :key="item.addr"
- >
- <div class="photoItem">
- <div class="photoInfo">
- <template v-if="userType == 1">
- <i
- class="iconfont icon-shanchu"
- v-show="delBtnState"
- @click="delectImg(item.id)"
- ></i>
- <el-checkbox
- v-show="!delBtnState"
- v-model="item.checked"
- ></el-checkbox>
- </template>
- </div>
- <div class="photoImg">
- <!-- 有的图片放到阿里云,有的放到了服务器 -->
- <template v-if="item.addr.indexOf('http') != -1">
- <img :src="item.addr" />
- </template>
- <template v-else>
- <img :src="$host + item.addr" />
- </template>
- </div>
- <div class="date" style="background: #fff">
- {{ (item.addtime * 1000) | formatTime }}
- </div>
- <!-- <div class="photoCtrl">
- <div @click="viewDes()">
- <i class="iconfont icon-wendang"></i>
- 查看描述
- </div>
- </div> -->
- </div>
- </el-col>
- </el-row>
- <!-- 暂无数据 -->
- <div style="text-align: center" v-else>
- <img src="@/assets/images/expertDiagnosis/zanwu.png" alt />
- </div>
- <el-pagination
- v-if="photoList.length > 0"
- background
- layout="prev, pager, next"
- :total="totalNum"
- @current-change="changePage"
- ></el-pagination>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- totalNum: 0,
- timeRange: [],
- delBtnState: true,
- device_id: this.$route.params.id,
- d_id: this.$route.query.d_id,
- photoList: [],
- queryInfo: {
- begin: '',
- end: '',
- page: 1
- },
- idList: [], //删除图片的地址数组
- photoDescDialogVisible: false
- }
- },
- mounted() {
- this.getPhoteList()
- },
- computed: {
- userType: function () {
- //获取用户类型
- return window.sessionStorage.getItem('myuser_type')
- }
- },
- methods: {
- equipStatusCheck(flag) {
- this.active = flag
- if (flag == 0) {
- //拍照
- this.equipBtnControl('takephoto')
- }
- if (flag == 1) {
- //刷新
- this.getPhoteList()
- }
- if (flag == 2) {
- this.delBtnState = false
- }
- if (flag == 3) {
- this.idList = this.photoList
- .filter((item) => {
- return item.checked == true
- })
- .map((item) => {
- return item.id
- })
- if (this.idList.length == 0) {
- this.$message.warning('请选择要删除的设备!')
- } else {
- this.delImgFun(this.idList)
- }
- }
- if (flag == 4) {
- this.photoList.map((item) => {
- item.checked = false
- })
- this.delBtnState = true
- }
- if (flag == 5) {
- this.delImgFun('')
- }
- },
- equipBtnControl(cmd) {
- this.$axios({
- method: 'POST',
- url:
- '/api/api_gateway?method=forecast.send_control.admin_device_control',
- data: this.qs.stringify({
- cmd,
- device_type_id: 7,
- d_id: this.$route.query.d_id
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.$message.success('指令下发成功!')
- }
- })
- },
- getPhoteList() {
- this.$axios({
- method: 'POST',
- url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
- data: this.qs.stringify({
- device_id: this.device_id,
- ret: 'list',
- page: this.queryInfo.page,
- page_number: 8,
- time_begin: this.queryInfo.begin,
- time_end: this.queryInfo.end
- })
- }).then((res) => {
- if (res.data.message == '') {
- let data = res.data.data.data
- this.photoList = data.map((item) => {
- item.checked = false
- return item
- })
- this.totalNum = res.data.data.num
- this.$message.success('请求最新图片成功!')
- }
- })
- },
- //改变page
- changePage(val) {
- this.queryInfo.page = val
- this.getPhoteList()
- },
- DateChange() {
- this.queryInfo.page = 1
- if (this.timeRange) {
- this.queryInfo.begin = parseInt(
- new Date(this.timeRange[0]).getTime() / 1000
- )
- this.queryInfo.end = parseInt(
- new Date(this.timeRange[1]).getTime() / 1000
- )
- } else {
- this.queryInfo.begin = ''
- this.queryInfo.end = ''
- }
- this.getPhoteList()
- },
- viewDes() {
- this.$prompt('图片描述', '添加详情', {
- confirmButtonText: '保存',
- cancelButtonText: '取消'
- })
- .then(({ value }) => {})
- .catch(() => {
- this.$message({
- type: 'info',
- message: '取消输入'
- })
- })
- },
- delImgFun(idList) {
- this.$confirm('此操作将永久删除该设备图片, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- this.$axios({
- method: 'POST',
- url:
- '/api/api_gateway?method=forecast.forecast_system.equip_photo_del',
- data: this.qs.stringify({
- device_id: this.device_id,
- addrlist: JSON.stringify(idList)
- })
- }).then((res) => {
- if (res.data.message == '') {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- this.getPhoteList()
- }
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- delectImg(id) {
- this.delImgFun([id])
- },
- //返回上一页
- goBackPage() {
- this.$router.go(-1)
- }
- }
- }
- </script>
- <style lang='less' scoped>
- .check-btns {
- display: flex;
- justify-content: space-between;
- margin-top: 10px;
- margin-bottom: 20px;
- align-items: center;
- .el-select {
- width: 90px;
- }
- }
- .photoItem {
- position: relative;
- border-radius: 10px;
- overflow: hidden;
- .photoInfo {
- position: absolute;
- top: 10px;
- left: 10px;
- right: 10px;
- display: flex;
- justify-content: space-between;
- span {
- color: #fff;
- }
- i {
- cursor: pointer;
- color: red;
- display: none;
- }
- }
- .photoImg {
- height: 250px;
- cursor: pointer;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .date {
- text-align: center;
- font-size: 14px;
- padding: 10px 0;
- }
- .photoCtrl {
- background-color: #fff;
- text-align: center;
- line-height: 30px;
- font-size: 14px;
- color: #666;
- display: flex;
- justify-content: center;
- position: relative;
- cursor: pointer;
- .el-checkbox {
- position: absolute;
- right: 10px;
- }
- }
- }
- .photoItem:hover {
- .photoInfo i {
- display: block;
- }
- }
- </style>
|