<template>

  <div class="dialog-h-content scroll-h">
    <div v-if="initLoading"
         class="m-row">
      <div class="m-info">
        <div class="info-prop">
          <span class="info-title-4">场所区域：</span>
          <span>{{ formData.gridName||'--'  }}</span>
        </div>

        <div class="info-prop">
          <span class="info-title-4">场所类型：</span>
          <span>{{ formData.placeOrgName||'--' }}</span>
        </div>

        <div class="info-prop">
          <span class="info-title-4">场所名称：</span>
          <span>{{ formData.ninePlaceName||'--'}}</span>
        </div>

        <div class="info-prop">
          <span class="info-title-4">分队名称：</span>
          <span>{{ formData.placePatrolTeamName||'--'  }}</span>
        </div>
        <div class="info-prop">
          <span class="info-title-4">检查人员：</span>
          <span>{{ formData.inspectorsNames||'--'  }}</span>
        </div>
        <div class="info-prop">
          <span class="info-title-4">首次巡查时间：</span>
          <span>{{ formData.firstTime||'--'  }}</span>
        </div>
        <div class="info-prop">
          <span class="info-title-4">隐患明细：</span>
          <span>{{ formData.detailed||'--'  }}</span>
        </div>
        <div class="info-prop">
          <span class="info-title-4">首次检查结论：</span>
          <span>{{ formData.firstResult==='0'?'合格':'不合格'  }}</span>
        </div>
        <div class="info-prop">
          <span class="info-title-4">拟复查时间：</span>
          <span>{{ formData.reviewTime||'--'  }}</span>
        </div>

      </div>

    </div>
    <!-- <div class="div_btn">
      <el-button size="small"
                 @click="handleCancle">取 消</el-button>
      <el-button size="small"
                 v-if="formType != 'detail'"
                 type="primary"
                 :disabled="btnDisable"
                 @click="handleComfirm">确 定</el-button>
    </div> -->
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
import { requestPost } from '@/js/dai/request'

let loading // 加载动画
export default {
  data () {
    return {


      initLoading: false,

      placesList: [],//场景列表
      teamsList: [],//分队列表
      inspectorsList: [],//检查人员列表

      placePatrolRecordId: '',
      formData: {
        gridId: '',//网格Id	
        ninePlaceVal: '',//九小场所类型value值	
        placeOrgId: '',//场所下的组织Id-场所名称	
        placePatrolTeamId: '',//场所下分队Id	
        inspectorArray: [],//检查人员数组
        inspectors: '',//检查人员Id，逗号分隔
        firstTime: '',//首次巡查时间	
        detailed: '',//隐患明细	
        firstResult: '',//首次检查结果【0:合格 1:不合格】	
        reviewTime: '',//拟复查时间	
      },

    }
  },
  components: {},
  mounted () {

  },

  methods: {

    async initForm (placePatrolRecordId) {

      this.startLoading()


      this.placePatrolRecordId = placePatrolRecordId
      this.formData.placePatrolRecordId = placePatrolRecordId
      await this.loadFormData()


      this.initLoading = true
      this.endLoading()
    },


    //加载form
    async loadFormData () {
      const url = '/gov/org/placepatrolrecord/detail'

      let params = {
        placePatrolRecordId: this.placePatrolRecordId
      }

      const { data, code, msg } = await requestPost(url, params)

      if (code === 0) {
        data.inspectorArray = data.inspectors.split(',')
        this.formData = { ...data }



      } else {
        this.$message.error(msg)
      }
    },

    handleCancle () {

      this.resetData()
      this.$emit('dialogCancle')

    },

    resetData () {
      this.formData = {}
    },
    // 开启加载动画
    startLoading () {
      loading = Loading.service({
        lock: true, // 是否锁定
        text: '正在加载……', // 加载中需要显示的文字
        background: 'rgba(0,0,0,.7)' // 背景颜色
      })
    },
    // 结束加载动画
    endLoading () {
      // clearTimeout(timer);
      if (loading) {
        loading.close()
      }
    }
  },
  computed: {
    dataRule () {
      return {

        gridId: [
          { required: true, message: '场所网格不能为空', trigger: 'blur' }
        ],
        ninePlaceVal: [
          { required: true, message: '场所类型不能为空', trigger: 'blur' },
        ],
        placeOrgId: [
          { required: true, message: '场所名称不能为空', trigger: 'blur' }
        ],
        placePatrolTeamId: [
          { required: true, message: '分队不能为空', trigger: 'blur' }
        ],

        inspectorArray: [
          { required: true, message: '巡检人员不能为空', trigger: 'blur' }
        ],
        firstTime: [
          { required: true, message: '首次巡查时间不能为空', trigger: 'blur' }
        ],
        detailed: [
          { required: true, message: '隐患明细不能为空', trigger: 'blur' }
        ],
        firstResult: [
          { required: true, message: '首次巡查结果不能为空', trigger: 'blur' }
        ]
      }
    },

  },
  props: {

    gridList: {
      type: Array,
      default: []
    },
    resultList: {
      type: Array,
      default: []
    },
    placeTypeList: {
      type: Array,
      default: []
    },
  }
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/modules/management/detail-main.scss";
</style>

