<template>
  <div class="bigBox">
    <MOSTY.FromPage :title="props.fromData.title" @closeDialog="black">
      <template #content>
        <MOSTY.Assort :title="'基础信息'" />
        <el-form class="mosty-from-wrap" ref="elform" label-width="130px" :model="fromData" :inline="true"
          :rules="rules" :disabled="true">
          <el-form-item label="风险单元类型:" prop="unitType">
            <MOSTY.DictRidioAndSelect :dictData="D_BZ_FXDYLX" v-model="fromData.unitType" style="width: 337px"
              selectType="radio" disabled placeholder='请选择风险单元类型' />
          </el-form-item>
          <el-form-item label="名称:" prop="activityfacility">
            <el-input v-model="fromData.activityfacility" style="width: 337px" disabled></el-input>
          </el-form-item>
          <el-form-item label="风险类型:" prop="type">
            <MOSTY.DictRidioAndSelect :dictData="D_BZ_FXLX" v-model="fromData.type" style="width: 337px"
              selectType="radio" placeholder='请选择风险单元类型' />
          </el-form-item>
          <el-form-item label="可能产生的后果:" prop="consequense" style="width: 100%">
            <el-select v-model="fromData.consequense" multiple style="width: 100%" placeholder="请选择可能产生的后果">
              <el-option v-for="item in D_TB_KNCSDHG" :key="item.value" :label="item.label"
                :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="控制措施:" prop="controls" style="width: 100%">
            <el-select v-model="fromData.controls" multiple style="width:100%">
              <el-option v-for="item in D_TB_WXYKZCS" :key="item.value" :label="item.label"
                :value="item.value"></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="危险源描述:" prop="description" style="width: 100%">
            <el-input v-model="fromData.description" type="textarea" :rows="3" show-word-limit maxlength="500" />
          </el-form-item>
          <el-form-item label="备注:" prop="bz" style="width: 100%">
            <el-input v-model="fromData.bz" type="textarea" :rows="3" show-word-limit maxlength="500" />
          </el-form-item>
        </el-form>
      </template>
      <template #footer>
        <el-button @click="black"> <el-icon>
            <DocumentDelete />
          </el-icon>
          <span>关闭</span></el-button>
      </template>
    </MOSTY.FromPage>
  </div>
</template>

<script setup>
import {
  reactive,
  ref,
  onMounted,
  getCurrentInstance
} from "vue";
import * as MOSTY from "@/components/MyComponents/index";
import { ElMessage } from "element-plus";
import { getApi, deleteApi, putApi, postApi } from "@/api/tobAcco_api.js";
import { getItem } from "@/utils/storage";
const { proxy } = getCurrentInstance();
const { D_TB_KNCSDHG, D_TB_WXYKZCS, D_BZ_FXLX, D_BZ_FXDYLX } = proxy.$dict("D_TB_KNCSDHG", "D_TB_WXYKZCS", "D_BZ_FXLX", "D_BZ_FXDYLX");
const rules = {
  volume: [{ required: true, message: "请输入复烤量", trigger: "blur" }],
  yearly: [{ required: true, message: "请选择年份", trigger: "blur" }],
  username: [{ required: true, message: "请选择人员", trigger: "blur" }],
};
const props = defineProps({
  fromData: {
    type: Object,
    default: {}
  }
});
const fromData = ref({})
const emit = defineEmits("changePage");
const ruleFormRef = ref();
onMounted(() => {

  if (props.fromData.id) {
    getmain(props.fromData.id)
  }
});




//获取详情
function getmain(id) {
  if (id) {
    getApi({}, `/mosty-jcgl/danger2Baseinfo/getDanger2BaseinfoById/${id}`).then(
      (res) => {
        if (res.controls) {
          res.controls = res.controls.split(",");
        }
        if (res.consequense) {
          res.consequense = res.consequense.split(",");
        }
        fromData.value = res;
        let dm = res.parttype.split('').reverse().join('')
        fromData.value.unitType = dm.substring(dm.length - 2)
      }
    );
  }
}

const black = () => {

  emit("changePage");
};

</script>

<style lang="scss" scoped>
.table-lable {
  margin: 10px;
  color: var(--el-color-primary);
}

::v-deep ::-webkit-scrollbar {
  display: none !important;
}

::v-deep .el-pagination {
  justify-content: center !important;
}

::v-deep .el-form {
  width: 1580px;
  margin: auto;
  padding: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: start;
}

.el-form-item {
  display: flex;
  margin-right: 20px;
}

.bigBox {
  display: block !important;
  padding: 0 14px;
  box-sizing: border-box;
}

::v-deep .el-form-item__content {
  margin-left: 0px !important;
}


::v-deep .el-table .cell {
  padding: 0 0 !important;
}

::v-deep .el-table--border .el-table__cell .cell {
  padding-left: 0px !important;

  >input {
    width: 100%;
    height: 33px;
  }
}


::v-deep .el-upload-list {
  width: 50%;
}
</style>