<!-- 导入固有风险模板详情 -->

<template>
  <div>
    <LHeader text="固有风险信息"></LHeader>
    <van-form>
      <div
        style="
          height: 1rem;
          font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
          font-weight: 700;
          line-height: 1rem;
        "
      >
        <img
          src="@/assets/accidentIcon/bookmark.svg"
          alt=""
          style="position: relative; top: 32%; transform: translateY(-50%)"
        />
        固有风险信息
      </div>
      <van-field
        required
        readonly
        clickable
        name="name"
        v-model="form.name"
        label="危险源名称"
        placeholder="请输入"
        :rules="[{ required: true, message: '危险源名称不能为空' }]"
      />
      <!-- 单选 -->
      <van-field
        readonly
        required
        clickable
        name="pointType"
        v-model="form.pointType"
        label="风险点类型"
        placeholder="请选择"
        :rules="[{ required: true, message: '风险点类型不能为空' }]"
      />
      <van-field
        required
        label="是否为特种设备"
        v-show="form.pointType == '设备设施类'"
      >
        <template #input>
          <van-radio-group
            v-model="form.specialEquipment"
            direction="horizontal"
          >
            <van-radio :name="true">是</van-radio>
            <van-radio :name="false">否</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <van-field
        v-if="form.specialEquipment == true"
        clickable
        name="pointType"
        v-model="form.equipmentNumber"
        label="特种设备的证书号码"
        placeholder="请选择"
      />
      <!-- 多选 -->
      <van-field
        v-model="form.safetyWarningSigns"
        readonly
        required
        name="safetyWarningSigns"
        label="安全警示标志"
        placeholder="请选择"
        :rules="[{ required: true, message: '安全警示标志不能为空' }]"
      />
      <van-field
        v-model="form.factor"
        readonly
        required
        name="factor"
        label="风险因素"
        placeholder="请选择"
        :rules="[{ required: true, message: '风险因素不能为空' }]"
      />

      <van-field
        readonly
        v-model="form.type"
        required
        name="type"
        label="准事故类型"
        placeholder="请选择"
        :rules="[{ required: true, message: '准事故类型不能为空' }]"
      />
      <div
        style="
          height: 1rem;
          font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
          font-weight: 700;
          line-height: 1rem;
        "
      >
        <img
          src="@/assets/accidentIcon/bookmark.svg"
          alt=""
          style="position: relative; top: 32%; transform: translateY(-50%)"
        />
        应采取的管控措施
      </div>
      <van-field label="技术措施">
        <template #input>
          <van-field
            readonly
            v-model="form.measuresProject"
            name="measuresProject"
            label=""
            type="textarea"
            rows="3"
            autosize
            placeholder="请输入"
            style="padding-left: 0; padding-top: 0"
          />
        </template>
      </van-field>
      <van-field label="管理措施">
        <template #input>
          <van-field
            readonly
            v-model="form.measuresAdministration"
            name="measuresAdministration"
            label=""
            type="textarea"
            rows="3"
            autosize
            placeholder="请输入"
            style="padding-left: 0; padding-top: 0"
          />
        </template>
      </van-field>
      <van-field label="应急措施">
        <template #input>
          <van-field
            readonly
            v-model="form.measuresEmergency"
            name="measuresEmergency"
            label=""
            type="textarea"
            rows="3"
            autosize
            placeholder="请输入"
            style="padding-left: 0; padding-top: 0"
          />
        </template>
      </van-field>

      <div
        style="
          height: 1rem;
          font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
          font-weight: 700;
          line-height: 1rem;
        "
      >
        <img
          src="@/assets/accidentIcon/bookmark.svg"
          alt=""
          style="position: relative; top: 32%; transform: translateY(-50%)"
        />
        重大危险源管理
      </div>

      <van-field name="majorHazardSource" label="是否为重大危险源">
        <template #input>
          <span style="margin-right: 10px; color: red">否</span>
          <van-switch disabled v-model="form.majorHazardSource" size="20" />
          <span style="margin-left: 10px; color: green">是</span>
        </template>
      </van-field>
      <van-field
        v-model="form.hazardSourceName"
        :required="form.majorHazardSource"
        name="hazardSourceName"
        label="危险源名称 "
        readonly
        type="textarea"
        rows="1"
        autosize
        placeholder="请输入"
        :key="form.majorHazardSource + '123'"
        :rules="
          form.majorHazardSource
            ? [{ required: true, message: '危险源名称不能为空' }]
            : []
        "
      />
      <van-field label="重大危险源描述" :required="form.majorHazardSource">
        <template #input>
          <van-field
            readonly
            v-model="form.majorHazardSourceDescription"
            name="majorHazardSourceDescription"
            type="textarea"
            rows="3"
            autosize
            placeholder="请输入"
            :key="form.majorHazardSource + '456'"
            :rules="
              form.majorHazardSource
                ? [{ required: true, message: '重大危险源描述不能为空' }]
                : []
            "
            style="padding-left: 0; padding-top: 0"
          />
        </template>
      </van-field>
      <van-field
        :required="form.majorHazardSource"
        readonly
        clickable
        name="referenceBasis"
        :value="form.referenceBasis == 'null' ? '' : form.referenceBasis"
        label="判断依据"
        placeholder="请选择"
        :key="form.majorHazardSource + '789'"
        :rules="
          form.majorHazardSource
            ? [{ required: true, message: '判断依据不能为空' }]
            : []
        "
      />
      <div class="import-btn">
        <van-button round block type="info" @click="toImport">导入</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import LHeader from "@/components/header.vue";
import { getFun, postFun } from "@/service/table.js";
export default {
  components: { LHeader },
  data() {
    return {
      form: {},
    };
  },
  mounted() {
    this.form = this.$store.state.inherentTemplate;
  },
  methods: {
    // 请求详情数据
    postReturnEcho() {
      getFun(`/risk/plan/inherent/details/135`)
        .then((res) => {
          this.form = res.data;
        })
        .catch(() => {
          this.$toast.clear();
        });
    },
    toImport() {
      this.$router.go(-2);
    },
  },
};
</script>

<style lang="less" scoped>
.import-btn {
  padding: 20px;
}
</style>
