<template>
  <div class="app-container">
    <div style="background-color: #fff;padding: 20px;border-radius: 10px;">
      <p style="margin: 0; font-weight: 800;font-size: 16px;color: #343434;display: flex;align-items: center;margin-bottom: 20px;">
        <img src="../../../assets/images/icon_htgl_btzs.png" alt="" style="width: 16px;height: 20px;">
       <span style="margin-left: 10px;">报修详情</span>
      </p>
      <div style="margin-top: 15px;" class="xiahgw">
        <el-steps :active="actjse" simple>
          <el-step title="报修" icon="el-icon-upload2"></el-step>
          <el-step title="指派" icon="el-icon-upload"></el-step>
          <el-step title="上门" icon="el-icon-top"></el-step>
          <el-step title="完成" icon="el-icon-check"></el-step>
        </el-steps>
      </div>
      <div class="casr">
              <div style="margin-top: 25px;">
                <p class="ngose"><span></span><span>报修信息</span></p>
                <div class="baoxe">
                  <p style="margin-bottom: 30px;">{{form.repairTitle == null ?'zanwushuj' : form.repairTitle }}</p>
                  <p style="margin-bottom: 30px;">{{form.repairDetails == null ?'zanwushuj' : form.repairDetails }}</p>
                  <div style="margin-bottom: 30px;">
                    <el-row :gutter="20" >
                      <el-col :span="4" v-for="(item,index) in form.baoimg" :key="index" v-if="form.repairImages !=null" >
                        <img :src="defaultSettings.urls+baseUrl +item" alt="" style="width: 100%;height: 150px;border-radius: 10px;">

                      </el-col>
                      <el-col :span="4" v-if="form.repairImages ==null">
                         <div style="position: relative;" >
                                    <!-- defaultSettings.urls+baseUrl +itemt.url -->
                         <img src="../../../assets/images/zwshuj.png" alt="" style="width: 100%;height: 150px;border-radius: 10px;">
                                   <!-- <p style="position: absolute;bottom: 0;left: 0;font-weight: 500; height: 24px;background-color: rgba(0,0,0,.5);color: #fff;font-size: 14px;width: 100%;padding-left: 10px;line-height: 24px;margin: 0;">{{itemt.title}}</p> -->
                         </div>
                      </el-col>

                    </el-row>
                  </div>
                  <p style="margin-bottom: 30px;font-family: PingFang SC;font-weight: bold;
                     font-size: 16px;color: #196CFF;">基础信息</p>
                  <div>
                    <el-row>
                      <el-col :span="6">
                       <div style="font-size: 14px;color:#666666; display: flex;"> <span style="color: #161616;">报修类别：</span><dict-tag :options="dict.type.baoxiutype" :value="form.maintenanceCategory"/></div>
                      </el-col>
                      <el-col :span="6">
                       <p style="font-size: 14px;color:#666666;"><span style="color: #161616;">报修门户：</span>{{form.houseAddress == null ?'zanwushuj' : form.houseAddress }}</p>
                      </el-col>
                      <el-col :span="6">
                        <p style="font-size: 14px;color:#666666;"><span style="color: #161616;">报修时间：</span>{{form.repairTime == null ?'zanwushuj' : form.repairTime }}</p>
                      </el-col>
                      <el-col :span="6">
                        <p style="font-size: 14px;color:#666666;"><span style="color: #161616;">联系方式：</span>{{form.phoneNumber == null ?'zanwushuj' : form.phoneNumber }}</p>
                      </el-col>
                    </el-row>
                  </div>
                </div>
                <div style="margin: 30px 0;">
                  <p class="ngose"><span></span><span>上门信息</span></p>
                </div>
                <el-row>
                  <el-col :span="24">
                    <el-col :span="8">
                       <p style="font-size: 14px;color:#666666;"> <span style="color: #161616;">上门时间：</span>{{form.visitTime == null ?'暂无数据' : form.visitTime }}</p>
                    </el-col>
                    <el-col :span="8">
                       <p style="font-size: 14px;color:#666666;"> <span style="color: #161616;">结束时间：</span>{{form.completionTime == null ?'暂无数据' : form.completionTime }}</p>
                    </el-col>
                  </el-col>
                  <el-col :span="24">
                    <el-col :span="8">
                       <div style="font-size: 14px;color:#666666; display: flex;align-items: flex-start;margin-top: 15px;">
                         <span style="color: #161616;">上门图片：</span>
                          <image-preview :src="form.visitPhoto" :width="100" :height="100" style="border-radius: 5px;"  />
                         <!-- <img src="../../../assets/images/pic_htgl_left_tp.png" alt="" > </p> -->
                         </div>
                    </el-col>
                    <el-col :span="8">
                       <p style="font-size: 14px;color:#666666; display: flex;align-items: flex-start;">
                         <span style="color: #161616;">结束图片：</span>
                          <image-preview :src="form.completionPhoto" :width="100" :height="100" style="border-radius: 5px;"  />
                         <!-- <img src="../../../assets/images/pic_htgl_left_tp.png" alt="" style="width: 100px;height: 100px;border-radius: 5px;"> </p> -->
                         </p>
                    </el-col>
                  </el-col>
                </el-row>
              </div>
      </div>



    </div>

    <!-- 添加或修改岗位对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="640px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="家庭住址" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="15">
            <el-form-item label="岗位名称" prop="postName">
              <el-input v-model="form.postName" placeholder="请输入岗位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="24" class="unimg">
            <el-form-item label="上传头像" prop="remark">
              <image-upload v-model="form.entrancePermit"/>
            </el-form-item>
          </el-col>
        </el-row>



      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRepair, getRepair, delRepair, addRepair, updateRepair } from "@/api/wuguan/repair";
import 'videojs-flash'
const defaultSettings = require("@/settings.js");
export default {
  name: "Post",
  dicts: ['sys_normal_disable','baoxiutype'],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      defaultSettings:defaultSettings,
      // 显示搜索条件
      showSearch: true,
       baseUrl: process.env.VUE_APP_BASE_API,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        postCode: undefined,
        postName: undefined,
        status: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        postName: [
          { required: true, message: "岗位名称不能为空", trigger: "blur" }
        ],
        postCode: [
          { required: true, message: "岗位编码不能为空", trigger: "blur" }
        ],
        postSort: [
          { required: true, message: "岗位顺序不能为空", trigger: "blur" }
        ]
      },
      activeName:'first',
      videoState: false, // 视频播放状态
      poster:true,
      controls:true,
      videoData:{},
       player: null,
       isshoe:true,
       actjse:1
    };
  },
  created() {
    if(this.$route.query.id != undefined){
      this.getList(this.$route.query.id);
    }
  },
  mounted() {



  },
  beforeDestroy() {
      if (this.player) {
        this.player.dispose()
      }
    },
  methods: {
    /** 查询岗位列表 */
    getList(repairId) {
      getRepair(repairId).then(response => {
        this.form = response.data;
        this.form.baoimg = []
        this.form.baoshang = []
        this.form.baojieshu = []
        if(this.form.repairImages != null && this.form.repairImages != ''){
          this.form.baoimg = this.form.repairImages.split(',')
        }
        if(this.form.visitPhoto != null && this.form.visitPhoto != ''){
          this.form.baoshang = this.form.visitPhoto.split(',')
        }
        if(this.form.completionPhoto != null && this.form.completionPhoto != ''){
          this.form.baojieshu = this.form.completionPhoto.split(',')
        }
        if(this.form.repairStatus ==1){
           this.actjse = 0
        }else if(this.form.repairStatus ==2){
          this.actjse = 1
        }else if(this.form.repairStatus ==3){
          this.actjse = 2
        }else if(this.form.repairStatus ==4){
          this.actjse = 3
        }


        // this.open = true;
        this.title = "报修信息";

      });
    },
    getge(valy){

        this.$nextTick(() => {
             setTimeout(() => {
        for(var i =0; i < valy.length;i++){
          let du = document.getElementById("myVideo" + i) //获取组件下的video
                 var hour = parseInt((du.duration) / 3600);
                 var minute = parseInt((du.duration % 3600) / 60);
                 var second = parseInt(du.duration % 60);
                 let result = ''
                 if (hour > 0) {
                 result = this.formatTimeStr(hour) + ':' + this.formatTimeStr(minute) + ':' + this
                 .formatTimeStr(second)
                           } else {
                              result = this.formatTimeStr(minute) + ':' + 
                            this.formatTimeStr(second)
                            }

                       this.isshoe = false
                       valy[i].result = result
                       this.isshoe = true
                       console.log(valy[i],result,du)
          //                   return result //转化成分，秒
                       }
                      }, 1200)

                    })
    },
    formatTimeStr(val) {
            if (val > 9) {
              return val
            } else {
              return '0' + val
            }
          },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        postId: undefined,
        postCode: undefined,
        postName: undefined,
        postSort: 0,
        status: "0",
        remark: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加岗位";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const postId = row.postId || this.ids
      getPost(postId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改岗位";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.postId != undefined) {
            updatePost(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPost(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const postIds = row.postId || this.ids;
      this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项？').then(function() {
        return delPost(postIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/post/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },

      handleClick(){

      },
    isac(val){
      console.log(5,val)
      val.isnum = !val.isnum
      this.isshoe = false
      this.isshoe = true
    },

  }
};
</script>
<style  lang="scss">
  .xiahgw{
    .el-step__head.is-process{
      color:#71A4FF;
      border-color:#71A4FF;
    }
    .el-step__title.is-process{
      color:#71A4FF;
    }
  }
  .unimg{
    .el-upload--picture-card{
      width:102px;
      height: 102px;
      line-height: 102px;
    }
  }

  .bnjle{
    margin-left: 20px;
  }
  .butt{
    .el-button--small{
      padding: 9px 23px !important;
      font-size: 14px;
    }
  }
  .casr{
    .el-tabs__item.is-active{
      color: #196CFF;
    }
    .el-tabs--card > .el-tabs__header .el-tabs__item{
      padding: 0  30px !important;
    }
  }
  .el-table .el-table__header-wrapper th{
    background-color:#F5F6F8;
    color:#343434;
  }
  .el-table{
    color:#343434;
  }
</style>
<style scoped lang="scss">
  .flexc{
    display: flex;
    justify-content: space-between;
  }
  	.carlist{background: #FFFFFF;border-radius: 10px;margin-bottom: 14px;
  		.ctop{border-bottom: 1px solid #E5E5E5;padding:13px 12px;
  			.imgs{width: 20px;height: 21px;margin-right: 15px;}
  			.tit{font-size: 16px;color: #272727;font-weight: bold;margin-right: 7px;overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;}
  			.txt{font-weight: 500;font-size: 14px;
  				&.ca{color: #3565ED;}
  				&.cb{color: #FE5A0E;}
  				&.cc{color: #28C529;}
  			}
  			.txta{font-weight: 500;font-size: 14px;color: #AAAAAA;}
  			.num{font-size: 14px;color: #AAAAAA;}
  		}
  		.btn{height: 17px;border-radius: 9px;display: flex;align-items: center;justify-content: center;padding: 0 5px;font-size:12px;margin-right: 12px;
  			&.btna{border: 1px solid #06C770;color: #06C770;}
  			&.btnb{border: 1px solid #3565ED;color: #3565ED;}
  			&.btnc{border: 1px solid #FE5A0E;color: #FE5A0E;}
  			&.btnbga{border: 1px solid #0156FE;color: #3565ED;background: #DFEAFF;height: 18px;}
  			&.btnbgb{border: 1px solid #C1C1C1;color: #666666;background: #F1F1F1;height: 18px;}
  			&.btnbgc{border: 1px solid #FE5A0E;color:#FE5A0E;background:#FFEEE6;height: 18px;}
  		}
  		.clists{padding: 12px 12px 4px;
  			.clist{font-weight: 500;margin-bottom: 8px;
  	font-size: 13px;color: #272727;display: flex;line-height: 17px;
  				.tit{font-size: 14px;color: #AAAAAA;flex: 0 0 auto;margin-right: 8px;text-align-last: justify;}
  				.imgas{display: flex;align-items: center;flex-wrap: wrap;
  					image{width: 71px;height: 71px;margin-right: 15px;margin-top:4px;}
  				}
  			}
  			.w50{
  				.clist{width: 50%;}
  			}
  		}
  	}
  	.houselist{
  		.clists{padding-bottom: 1px !important;}
  		.clist{margin-bottom: 11px !important;}
  	}
  .goe{
    p{
      margin: 0;
      font-weight: 800;
      font-size: 16px;
      color: #161616;
      margin-top: 10px;
      margin-bottom: 3px;
      padding: 0 10px;
      overflow: hidden;
      text-overflow: ellipsis;
      display:-webkit-box; //作为弹性伸缩盒子模型显示。
      -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
      -webkit-line-clamp:1; //显示的行
    }
    p:nth-child(2){

    }
  }
  .ingwe{
    border: 2px solid #196CFF;
  }
  .renyuangs{
    p{
      font-weight: 500;
      font-size: 14px;
      color: #161616;
      padding: 0;
    }
  }
  .tongty{
    display: flex;
    align-items: center;
  }
  .bortt{
    border-top: 1px solid #DADADA;
    margin-top: 15px;

    p{
      margin: 0;
      font-weight: bold;
      font-size: 14px;
      color: #5F8BF4;
      width:50%;
      padding: 10px;
      text-align: center;
    }
  }
  .ngose{
    margin: 0;
    display: flex;
    align-items: center;
    font-family: PingFang SC;
    font-weight: bold;
    font-size: 16px;
    color: #161616;
    span:nth-child(1){
      width: 12px;
      height: 12px;
      background: #28C529;
      border-radius: 50%;
      margin-right: 16px;
    }
  }
  .baoxe{
    background: #F5FDF5;
    border-radius: 4px;
    padding: 20px;
    margin-top: 10px;
    p{
      margin: 0;
    }
    p:nth-child(1){
     font-family: PingFang SC;
     font-weight: bold;
     font-size: 18px;
     color: #161616;
    }
    p:nth-child(2){
     font-family: PingFang SC;
     font-weight: 500;
     font-size: 14px;
     color: #666666;
    }
  }
  </style>


