<!--
 * @Description: 详情弹框
 * @Author: Sugar.
 * @Date: 2023-11-24 13:55:00
 * @LastEditors: Sugar.
 * @LastEditTime: 2023-11-24 13:55:00
 * @FilePath: \cattle_webui\src\views\perform\programmeMr\dialog\details.vue
 * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
-->
<template>
  <el-dialog
    title="剧目信息"
    :visible.sync="open"
    width="700px"
    append-to-body
    :close-on-click-modal="false"
    @close="cancel"
  >
    <div class="dialog">
      <!--   基础信息   -->
      <div class="title-class" style="margin-top: 0">基础信息</div>
      <el-row>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">剧目名称: <span>{{ form.name }}</span></div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">主办方: <span>{{ form.sponsorName }}</span></div>
        </el-col>
        <el-col :span="24">
          <div class="grid-content bg-purple item-class">是否启用: <span>{{ form.status == 1 ? '启用' : '未启用' }}</span></div>
        </el-col>
      </el-row>

      <!--   演出信息   -->
      <div class="title-class">演出信息</div>
      <el-row>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">上映日期: <span>{{ form.releaseDate }}</span></div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">演出时长: <span>{{ form.showDuration }}分钟</span></div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">演出人数: <span>{{ form.peopleNum }}人</span></div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple item-class">演员信息: <el-button style="padding: 0" type="text" @click="performerOpen">查看</el-button></div>
        </el-col>
        <el-col :span="24">
          <div class="grid-content bg-purple item-class">
            <el-row>
              <el-col :span="3">
                <div>宣传图:</div>
              </el-col>
              <el-col :span="12">
                <div v-if="form.posterImg">
                  <el-image
                    style="width: 100px; height: 100px"
                    :src="form.posterImg"
                    fit="cover"
                  />
                </div>
                <div v-else>--</div>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="24">
          <div class="grid-content bg-purple item-class">
            <el-row>
              <el-col :span="3">
                <div>剧目封面:</div>
              </el-col>
              <el-col :span="12">
                <div v-if="form.showImg">
                  <el-image
                    style="width: 100px; height: 100px"
                    :src="form.showImg"
                    fit="cover"
                  />
                </div>
                <div v-else>--</div>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="24">
          <div class="grid-content bg-purple item-class">
            <el-row>
              <el-col :span="3">
                <div>剧目海报:</div>
              </el-col>
              <el-col :span="12">
                <div v-if="form.photoList && form.photoList.length > 0">
                  <el-image
                    v-for="(item, index) in form.photoList"
                    style="width: 100px; height: 100px; margin-right: 10px; margin-bottom: 10px;"
                    :src="item.imageUrl"
                    :key="index"
                    fit="cover"
                  />
                </div>
                <div v-else>--</div>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="24">
          <div class="grid-content bg-purple item-class">
            <el-row>
              <el-col :span="3">
                <div>剧情介绍:</div>
              </el-col>
              <el-col :span="12">
                <div v-html="form.performSnapshot"></div>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>

      <!--   观影须知   -->
      <div class="title-class" style="margin-top: 0">观影须知</div>
      <el-row>
        <el-col :span="24">
          <div class="grid-content bg-purple">
            <el-row>
              <el-col :span="3">
                <div>观影须知:</div>
              </el-col>
              <el-col :span="12">
                <div v-html="form.performNotice"></div>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
    </div>


    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="cancel">确定</el-button>
    </span>


    <el-dialog
      title="演员信息"
      :visible.sync="performerVisible"
      width="800px"
      append-to-body
      :destroy-on-close="true"
      :close-on-click-modal="false"
    >
      <div>
        <el-table ref="tables"  :data="performerList" border>
          <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
          <el-table-column label="姓名" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.performerName"
                placeholder="姓名"
                disabled
                clearable
              />
            </template>
          </el-table-column>
          <el-table-column label="图片" align="center">
            <template slot-scope="scope">
              <div class="avatar" v-if="scope.row.performerHead">
                <el-image
                  style="width: 100px; height: 100px"
                  :src="scope.row.performerHead"
                  fit="cover"
                />
              </div>
            </template>
          </el-table-column>
          <el-table-column label="角色名" align="center">
            <template slot-scope="scope">
              <el-input
                disabled
                v-model="scope.row.performerRole"
                placeholder="角色名"
                clearable
              />
            </template>
          </el-table-column>
          <el-table-column label="演员简介" width="200" align="center">
            <template slot-scope="scope">
              <el-input
                type="textarea"
                disabled
                :rows="4"
                maxlength="500"
                show-word-limit
                v-model="scope.row.performerSnapshot"
                placeholder="演员简介"
                clearable
              />
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="performerVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </el-dialog>
</template>

<script>
import { getSelectById } from "@/api/programmeMr/programmeMr";
import Editor from "@/components/Editor";
export default {
  name: "detailsDia",
  components: {
    Editor,
  },
  data() {
    return {
      title: "编辑",
      model: "EDIT",
      open: false,
      loading: false,
      form: {
        id: undefined,
      },
      performerVisible: false,
      performerList: []
    };
  },
  methods: {
    /**
     * 打开弹框
     * @date 2023-11-22
     * @param {any} obj
     * @returns {any}
     */
    openDialog(title, obj) {
      this.open = true;
      if (obj){
        this.getSelectByIdApi(obj)
      }
    },
    /** 获取详情 */
    getSelectByIdApi(row) {
      const id = row.id
      getSelectById(id).then(response => {
        this.form = response.data;

      });
    },
    /**
     * 演员弹窗打开
     * @date 2023-11-22
     */
    performerOpen() {
      if(!this.form.performerList){
        this.form.performerList = []
      }
      let target=[...this.form.performerList];
      this.performerList = JSON.parse(JSON.stringify(target));
      this.performerVisible = true;
    },
    /**
     * 关闭弹框
     * @date 2023-11-22
     * @returns {any}
     */
    cancel() {
      this.open = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.dialog {
  padding: 0 30px;
  max-height: 65vh;
  overflow-y: auto;
}
.dialog {
  padding: 0 30px;
  .upload-btn {
    width: 100px;
    height: 100px;
    background-color: #fbfdff;
    border: dashed 1px #c0ccda;
    border-radius: 5px;
    i {
      font-size: 30px;
      margin-top: 20px;
    }
    &-text {
      margin-top: -10px;
    }
  }
  .avatar {
    cursor: pointer;
  }
  .title-class{
    font-size: 16px;
    font-weight: bold;
    color: black;
    margin-bottom: 20px;
    margin-top: 20px;
  }
  .item-class{
    margin-bottom: 20px;
  }
}
</style>
