<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="background: #F3F3F3;padding: 20px 15px; padding-bottom: 0;margin-bottom: 20px;">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="创建时间:" prop="postCode">
               <el-date-picker
                     v-model="queryParams.value1"
                     type="date"
                     placeholder="选择日期">
              </el-date-picker>
              <span style="margin: 0  10px;">至</span>
              <el-date-picker
                     v-model="queryParams.value1"
                     type="date"
                     placeholder="选择日期">
              </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-col :span="8">
                <el-form-item label="岗位编码" prop="postCode">
                  <el-input
                    v-model="queryParams.postCode"
                    placeholder="请输入岗位编码"
                    clearable
                    @keyup.enter.native="handleQuery"

                  />
                  </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="岗位编码" prop="postCode">
                  <el-input
                    v-model="queryParams.postCode"
                    placeholder="请输入岗位编码"
                    clearable
                    @keyup.enter.native="handleQuery"

                  />
                  </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="岗位编码" prop="postCode">
                  <el-input
                    v-model="queryParams.postCode"
                    placeholder="请输入岗位编码"
                    clearable
                    @keyup.enter.native="handleQuery"

                  />
                  </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="8">
                <el-form-item label="岗位编码" prop="postCode">
                  <el-input
                    v-model="queryParams.postCode"
                    placeholder="请输入岗位编码"
                    clearable
                    @keyup.enter.native="handleQuery"

                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="岗位名称" prop="postName">
                  <el-input
                    v-model="queryParams.postName"
                    placeholder="请输入岗位名称"
                    clearable
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
              </el-col>
            </el-col>
          </el-row>
          <el-form-item class="butt bnjle">
            <el-button type="primary"   @click="handleQuery">搜索</el-button>
            <el-button   @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>


      <div class="casr">
              <el-row :gutter="10" class="mb8">
                <!-- <el-col :span="1.5">
                  <div style="font-weight: bold;font-size: 14px;color: #343434; display: flex;align-items: center;">
                    当夜全选
                  </div>
                </el-col> -->
                <el-col :span="1.5">
                  <el-button
                    type="primary"
                    plain
                    size="mini"
                    @click="handleAdd"
                    v-hasPermi="['system:post:add']"
                  >添加</el-button>
                </el-col>
                <!-- <el-col :span="1.5">
                  <el-button
                    type="success"
                    plain
                    size="mini"
                    :disabled="single"
                    @click="handleUpdate"
                    v-hasPermi="['system:post:edit']"
                  >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="danger"
                    plain
                    size="mini"
                    :disabled="multiple"
                    @click="handleDelete"
                    v-hasPermi="['system:post:remove']"
                  >删除</el-button>
                </el-col> -->
                <el-col :span="1.5">
                  <el-button
                    type="warning"
                    plain
                    size="mini"
                    @click="handleExport"
                    v-hasPermi="['system:post:export']"
                  >导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
              </el-row>
              <div style="margin-top: 25px;">
                <el-row :gutter="10">
                  <el-col :span="8" v-for="(item,index) in postList" :key="index" >
                    <div v-if="isshoe" @click="isac(item)" :class=" item.isnum ==true ? 'ingwe' :'' " style="position: relative; background-color: #fff;box-shadow: 0px 0px 10px 0px #CDCDCD;border-radius: 4px;margin-bottom: 10px;">
                     <div class="carlist houselist" style="margin-bottom: 0;">
                     	<div class="ctop flexc">
                     		<img src="../../../assets/images/icon_ky_jmda_yz.png" class="imgs" />
                     		<!-- <image src="../../../assets/images/icon_ky_jmda_zh.png" class="imgs" v-if="ite.type==2"></image> -->
                     		<div class="tit">幸福小区12#1101室</div>
                     		<!-- div class="btn btnbga">预约</div>
                     		<div class="btn btnbgb">已来访</div>
                     		<div class="btn btnbgc">待来访</div> -->
                     		<div class="flex1"></div>
                     		<div class="txt ca" >业主</div>
                     	<!-- 	<div class="txt cb" v-if="ite.type==2">租户</div> -->
                     	</div>
                     	<div style="display: flex; background: linear-gradient(-90deg, #F2F5FF 0%, #FBFDFF 100%);border-radius: 20px;
                         border: 1px solid #E6E6E6;padding: 20px;margin: 15px 15px 0 15px;">
                        <div>
                          <img src="../../../assets/images/icon_ky_jmda_yz.png" style="width: 76px;height: 76px;border-radius: 50%;" />
                        </div>
                        <div class="clists" style="flex: 1;">
                          <div class="w50 flexc">
                          	<div class="clist"><div class="tit">身份证号  </div>有</div>
                          </div>
                        	<div class="w50 flexc">
                        		<div class="clist"><div class="tit">身高 | </div>袁玥</div>
                        		<div class="clist"><div class="tit">体重 | </div>121.3m²</div>
                        	</div>
                        	<div class="w50 flexc">
                        		<div class="clist"><div class="tit">性别 | </div>3室1厅</div>
                        		<div class="clist"><div class="tit">年龄 | </div>3口人</div>
                        	</div>

                        </div>
                      </div>
                     </div>
                      <div class="bortt tongty" style="justify-content: space-between;">
                        <p ><span style="cursor: pointer;"  v-hasPermi="['student:info:edit']" @click="handleUpdate(item)">修改</span> <span style="cursor: pointer;"  @click="handleUpdatef(item)">查看</span> </p>

                        <p v-hasPermi="['student:info:remove']" style="border-left: 1px solid #DADADA;color:red;cursor: pointer;" @click="handleDelete(item)">删除</p>
                      </div>
                      <img v-if="item.isnum == true" src="../../../assets/images/icon_htgl_kp_gx.png" alt="" style="width: 35px;height: 35px;position: absolute;bottom: 0;right: 0;">
                    </div>
                  </el-col>
                </el-row>
              </div>
      </div>


      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </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 { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post";
import 'videojs-flash'
export default {
  name: "Post",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      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,
    };
  },
  created() {
    this.getList();
  },
  mounted() {



  },
  beforeDestroy() {
      if (this.player) {
        this.player.dispose()
      }
    },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;

      listPost(this.queryParams).then(response => {
        this.postList = response.rows;
        this.postList.filter(rou=>{
          rou.isnum = false
        })
        this.getge(this.postList)
        this.total = response.total;
        this.loading = false;
      });
    },
    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 = "修改岗位";
      });
    },
    // 查看按钮
    handleUpdatef(){
      this.$router.push({
        path: '/wuguan/jiankangxingq',
      })
    },
    /** 提交按钮 */
    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">
  .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;}
  			.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;
    }
  }
  </style>


