<style lang="scss">
    
</style>
<template>
    <section>
        <p>任务管理  >  巡检记录</p>
        <div class="filter">
            <el-form   :inline="true" size="small" label-position="left">
                <el-form-item>
                        <el-input clearable placeholder="请输入风险点" v-model="form.riskpoint_item"></el-input>
                </el-form-item>
                <el-form-item>
                       <el-button @click="form.page=1,getData()" type="primary" icon="el-icon-search">搜索</el-button>
                       <!-- <el-button @click="dialogFormVisible=true,message={send_type:1}" type="primary">发送消息</el-button> -->
                </el-form-item>
            </el-form>
        </div>


        <el-table
                class="table"
                :data="list" height="64vh"
                border  v-loading="loading"
                style="width: 100%">
              
                <el-table-column
                prop="enterprise_name" 
                label="公司名称">
                </el-table-column>
                <el-table-column
                prop="name" 
                label="任务名称">
                </el-table-column>
                <el-table-column
                prop="content" 
                label="任务状态">
                <template slot-scope="scope">
                    <span v-if="scope.row.task_status==-1">过期未巡检</span>
                    <span v-if="scope.row.task_status==0">待巡检</span>
                    <span v-if="scope.row.task_status==1">无异常</span>
                    <span v-if="scope.row.task_status==2">待审核</span>
                    <span v-if="scope.row.task_status==3">审核中</span>
                    <span v-if="scope.row.task_status==4">整改中</span>
                </template>
                </el-table-column>
                <el-table-column
                prop="report_person_name" 
                label="上报人">
                </el-table-column>
                <el-table-column
                prop="ctime"  
                label="上报时间">
                <!-- <template>
                    <el-tag type="success">启用</el-tag>
                </template> -->
                </el-table-column>
                <el-table-column fixed="right"
                prop="zip"  width="100"
                label="操作">
                <template slot-scope="scope">
                    <el-button icon="el-icon-view" @click="open(scope.row)" size="mini"  type="success">查看</el-button>
                    <!-- <el-button icon="el-icon-delete" @click="del(scope.row.id)" size="mini"  type="danger">删除</el-button> -->
                </template>
                </el-table-column>
        </el-table>
        <Page  ref="pageButton"  :total='total' @pageChange='gopage'/>

        <el-dialog title="" :visible.sync="dialogFormVisible" width="500px" :close-on-click-modal='false' :close-on-press-escape='false'>
            <el-form  label-width="100px">
                <el-form-item label="任务名称">
                    {{message.name}}
                </el-form-item>
                <el-form-item label="任务状态">
                    <span v-if="message.task_status==-1">过期未巡检</span>
                    <span v-if="message.task_status==0">待巡检</span>
                    <span v-if="message.task_status==1">无异常</span>
                    <span v-if="message.task_status==2">待审核</span>
                    <span v-if="message.task_status==3">审核中</span>
                    <span v-if="message.task_status==4">整改中</span>
                </el-form-item>
                <el-form-item label="上报人">
                    {{message.report_person_name}}                
                </el-form-item>
                <el-form-item label="上报时间">
                    {{message.ctime}}
                </el-form-item>
                <el-form-item label="图片">
                    <img style="margin:0 3px;" width="80px" height="80px" v-for="item in message.imgs" :key='item' :src="item" alt="">
                </el-form-item>
                <el-form-item label="视频">
                    <video :poster="message.videos_faceimg" width="300px" height="150px" controls :src="message.videos"></video>
                </el-form-item>
            </el-form>
        </el-dialog>
    </section>
</template>
<script>
import Page from '../../components/Page';
export default {
  components:{
        Page
  },
  data(){
    return{
      dialogFormVisible:false,
      form:{riskpoint_item:'',page:1,page_size:20,message_type:'notice'},
      message:{send_type:1},
      activeName:"1",
      total:1,
      list:[],
      loading:false,
      category:[],
      area:[],
      company:[]
    }
  },
  methods:{
        gopage(size){
            if(size){
                this.form.page_size=size
            }
            this.form.page=this.$refs.pageButton.page
            this.getData()
        },
        getData(){
            var parm=this.form;
            this.loading=true
            this.$api.getMonitjobList(parm).then(res=>{
                this.list=res.data.data.list
                this.total=res.data.data.total
                this.loading=false
                this.area=this.store.area;
                this.category=this.store.categorys;
            })
            this.$api.getEnterpriseAll().then(res=>{
                this.company=res.data.data;
            })
        },
        del(id){
                this.$confirm('确定删除吗', '提示', {
                        type: 'warning'
                    }).then(() => {
                    this.$api.deleteMessages({id:id}).then((res)=>{
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            })
                            this.getData()
                    })
                })
        },
        upload(type){
            var file=document.getElementById(type).files;
            var data=new FormData();
                data.append("file",file[0])
            this.$api.uploadFile(data).then(res=>{
                if(res.data.code==0){
                        let form=this.message;
                        this.$set(form,type,res.data.data.url)
                        this.$message({message: '上传成功！',type: 'success'});
                    }else{
                        this.$message.error(res.data.message);
                    }
            })
        },
        send(){
            let parm=this.message;
            this.$api.sendMessage(parm).then(res=>{
                    if(res.data.code==0){
                        this.$message({message: '发送成功！',type: 'success'});
                        this.getData();
                        this.dialogFormVisible=false;
                    }else{
                        this.$message.error(res.data.message);
                    }
            })
        },
        open(data) {
            this.dialogFormVisible=true;
            this.message={...data}
        }

  },
  created(){
      if(this.$route.query.id){
            this.form.enterprise_id=this.$route.query.id
      }
      this.getData()
  }
}
</script>
