|  | @@ -0,0 +1,200 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <div class="m-container">
 | 
	
		
			
				|  |  | +    <h2>
 | 
	
		
			
				|  |  | +      <el-page-header @back="onCancel" :content="detailName"></el-page-header>
 | 
	
		
			
				|  |  | +    </h2>
 | 
	
		
			
				|  |  | +    <div class="m-core">
 | 
	
		
			
				|  |  | +      <div class="buttons">
 | 
	
		
			
				|  |  | +        <el-button type="primary" @click="openUpload()">上传照片</el-button>
 | 
	
		
			
				|  |  | +        <el-button type="primary" v-if="!editing" @click="changeMode()">编辑照片</el-button>
 | 
	
		
			
				|  |  | +        <el-button type="danger" v-if="editing" @click="remove()">删除照片</el-button>
 | 
	
		
			
				|  |  | +        <el-button type="primary" v-if="editing" @click="confirm()">确定</el-button>
 | 
	
		
			
				|  |  | +        <el-button type="primary" v-if="editing" @click="editing = false">取消</el-button>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      <el-alert
 | 
	
		
			
				|  |  | +        v-if="editing"
 | 
	
		
			
				|  |  | +        type="info"
 | 
	
		
			
				|  |  | +        class="alert"
 | 
	
		
			
				|  |  | +        :closable="false">
 | 
	
		
			
				|  |  | +        <div slot="title">
 | 
	
		
			
				|  |  | +          <el-button class="btn" type="text" :disabled="list.length === checked.length" @click="checkAll()">全选</el-button>
 | 
	
		
			
				|  |  | +          <el-button class="btn" type="text" :disabled="!checked.length" @click="checked = []">取消选择</el-button>
 | 
	
		
			
				|  |  | +          <span>共{{list.length}}条, 已选择{{checked.length}}条</span>
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  | +      </el-alert>
 | 
	
		
			
				|  |  | +      <el-checkbox-group v-model="checked">
 | 
	
		
			
				|  |  | +        <div
 | 
	
		
			
				|  |  | +          v-for="(item) in list"
 | 
	
		
			
				|  |  | +          :key="item.url"
 | 
	
		
			
				|  |  | +          class="img-container"
 | 
	
		
			
				|  |  | +        >
 | 
	
		
			
				|  |  | +          <div v-if="editing" class="ctrl-bar">
 | 
	
		
			
				|  |  | +            <el-checkbox class="check" :label="item.id"></el-checkbox>
 | 
	
		
			
				|  |  | +            <i class="el-icon-view" :class="{active: views.includes(item.id)}" @click="setView(item)"></i>
 | 
	
		
			
				|  |  | +          </div>
 | 
	
		
			
				|  |  | +          <el-image
 | 
	
		
			
				|  |  | +            :src="item.url"
 | 
	
		
			
				|  |  | +            class="img"
 | 
	
		
			
				|  |  | +            :preview-src-list="list.map(item => item.url)">
 | 
	
		
			
				|  |  | +          </el-image>
 | 
	
		
			
				|  |  | +          <el-tooltip v-if="!editing" class="item" effect="dark" :content="item.name" placement="top" :open-delay=".3">
 | 
	
		
			
				|  |  | +            <div class="name">{{item.name}}</div>
 | 
	
		
			
				|  |  | +          </el-tooltip>
 | 
	
		
			
				|  |  | +          <el-input class="nameinput" v-else v-model="item.name" size="mini" placeholder="请输入照片名称" clearable/>
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  | +      </el-checkbox-group>
 | 
	
		
			
				|  |  | +      <empty v-if="list.length == 0"/>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +    <el-dialog
 | 
	
		
			
				|  |  | +      title="上传照片"
 | 
	
		
			
				|  |  | +      :visible.sync="uploadVisible"
 | 
	
		
			
				|  |  | +      v-if="uploadVisible"
 | 
	
		
			
				|  |  | +    >
 | 
	
		
			
				|  |  | +      <upload-popup
 | 
	
		
			
				|  |  | +        @close="uploadVisible = false"
 | 
	
		
			
				|  |  | +        @submited="submited"
 | 
	
		
			
				|  |  | +        :name="$route.query.name"
 | 
	
		
			
				|  |  | +      />
 | 
	
		
			
				|  |  | +    </el-dialog>
 | 
	
		
			
				|  |  | +  </div>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +<script>
 | 
	
		
			
				|  |  | +import uploadPopup from '@/views/resetTeaming/components/training-photos/upload'
 | 
	
		
			
				|  |  | +import { photoQueryPage, photoDel } from '@/views/resetTeaming/components/training-photos/api'
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +  components: {
 | 
	
		
			
				|  |  | +    'upload-popup': uploadPopup,
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  computed: {
 | 
	
		
			
				|  |  | +    detailName() {
 | 
	
		
			
				|  |  | +      return this.$route.query.name || '相册详情'
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  data() {
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      views: [],
 | 
	
		
			
				|  |  | +      checked: [],
 | 
	
		
			
				|  |  | +      uploadVisible: false,
 | 
	
		
			
				|  |  | +      list: [],
 | 
	
		
			
				|  |  | +      editing: false,
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  mounted() {
 | 
	
		
			
				|  |  | +    this.FetchList()
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    onCancel() {
 | 
	
		
			
				|  |  | +      this.$store.dispatch("delVisitedViews", this.$route);
 | 
	
		
			
				|  |  | +      if (this.$route.query.returnUrl) {
 | 
	
		
			
				|  |  | +        this.$router.push(this.$route.query.returnUrl);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    openUpload() {
 | 
	
		
			
				|  |  | +      this.uploadVisible = true
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    changeMode() {
 | 
	
		
			
				|  |  | +      this.checked = []
 | 
	
		
			
				|  |  | +      this.views = this.list.filter(item => item.clientShow).map(item => item.id)
 | 
	
		
			
				|  |  | +      this.editing = true
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    submited() {
 | 
	
		
			
				|  |  | +      this.FetchList()
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    setView(item){
 | 
	
		
			
				|  |  | +      const indexOf = this.views.indexOf(item.id)
 | 
	
		
			
				|  |  | +      if (indexOf > -1) {
 | 
	
		
			
				|  |  | +        this.views.splice(indexOf, 1)
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        this.views.push(item.id)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    checkAll() {
 | 
	
		
			
				|  |  | +      this.checked = this.list.map(item => item.id)
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    async FetchList() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        const res = await photoQueryPage({photoAlbumId: this.$route.params.id})
 | 
	
		
			
				|  |  | +        console.log(res.data.rows)
 | 
	
		
			
				|  |  | +        this.list = res.data.rows
 | 
	
		
			
				|  |  | +      } catch (error) {}
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    async confirm() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        await this.$confirm('是否确认修改照片信息?', '提示')
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      } catch (error) {}
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    async remove() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        await this.$confirm('是否确认删除已选照片?', '提示')
 | 
	
		
			
				|  |  | +        await photoDel({
 | 
	
		
			
				|  |  | +          ids: this.checked.join(',')
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +      } catch (error) {}
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +<style lang="less" scoped>
 | 
	
		
			
				|  |  | +.img-container{
 | 
	
		
			
				|  |  | +  display: inline-flex;
 | 
	
		
			
				|  |  | +  margin-right: 20px;
 | 
	
		
			
				|  |  | +  margin-top: 20px;
 | 
	
		
			
				|  |  | +  flex-direction: column;
 | 
	
		
			
				|  |  | +  text-align: center;
 | 
	
		
			
				|  |  | +  position: relative;
 | 
	
		
			
				|  |  | +  >.name{
 | 
	
		
			
				|  |  | +    width: 150px;
 | 
	
		
			
				|  |  | +    height: 30px;
 | 
	
		
			
				|  |  | +    line-height: 30px;
 | 
	
		
			
				|  |  | +    text-align: center;
 | 
	
		
			
				|  |  | +    margin-top: 10px;
 | 
	
		
			
				|  |  | +    color: rgba(0, 0, 0, .65);
 | 
	
		
			
				|  |  | +    overflow: hidden;
 | 
	
		
			
				|  |  | +    text-overflow: ellipsis;
 | 
	
		
			
				|  |  | +    white-space: pre;
 | 
	
		
			
				|  |  | +    font-size: 14px;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  >.nameinput{
 | 
	
		
			
				|  |  | +    width: 150px;
 | 
	
		
			
				|  |  | +    margin-top: 10px;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.ctrl-bar{
 | 
	
		
			
				|  |  | +  background-color: rgba(0, 0, 0, .45);
 | 
	
		
			
				|  |  | +  height: 30px;
 | 
	
		
			
				|  |  | +  position: absolute;
 | 
	
		
			
				|  |  | +  top: 0;
 | 
	
		
			
				|  |  | +  width: 100%;
 | 
	
		
			
				|  |  | +  z-index: 1;
 | 
	
		
			
				|  |  | +  display: flex;
 | 
	
		
			
				|  |  | +  justify-content: space-between;
 | 
	
		
			
				|  |  | +  align-items: center;
 | 
	
		
			
				|  |  | +  padding: 0 15px;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.el-icon-view{
 | 
	
		
			
				|  |  | +  font-size: 14px;
 | 
	
		
			
				|  |  | +  color: #fff;
 | 
	
		
			
				|  |  | +  cursor: pointer;
 | 
	
		
			
				|  |  | +  &.active{
 | 
	
		
			
				|  |  | +    color: #14928A;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.switch{
 | 
	
		
			
				|  |  | +  position: absolute;
 | 
	
		
			
				|  |  | +  top: 10px;
 | 
	
		
			
				|  |  | +  right: 10px;
 | 
	
		
			
				|  |  | +  z-index: 1;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.img{
 | 
	
		
			
				|  |  | +  width: 150px;
 | 
	
		
			
				|  |  | +  height: 150px;
 | 
	
		
			
				|  |  | +  border-radius: 3px;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.alert{
 | 
	
		
			
				|  |  | +  margin-top: 20px;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.btn{
 | 
	
		
			
				|  |  | +  padding: 0;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</style>
 |