<template>
  <div id="inforsPoint">
    <el-form ref="ruleForm" :model="form" label-width="150px" :inline="true" :label-position="'left'">
      <el-form-item :label="item.InfoPointName" v-for="item in InforsList" :key="item.InfoPointCode"
        :class="{FloorTypeSelect:item.InputMode == 'D1'||item.Unit}">
        <el-input v-model="form[item.Path]" v-if="item.Visible && (item.InputMode == 'B1')"></el-input>
        <el-input v-model="form[item.Path]" v-else-if="item.Visible && (item.InputMode == 'A1'||item.InputMode == 'A2')" type="number">
          <template slot="append" v-if="item.Unit">{{item.Unit}}</template>
        </el-input>
        <el-select v-model="form[item.Path]" placeholder="请选择" v-else-if="item.Visible && (item.InputMode == 'D1')">
          <el-option v-for="op in item.options" :key="op.Code" :label="op.Name" :value="op.Code">
          </el-option>
        </el-select>
        <el-input v-model="form[item.Path]"
          v-else-if="item.Visible && (item.InputMode == 'L'||item.InputMode == 'L1'||item.InputMode == 'L2'||item.InputMode == 'M')"></el-input>
        <el-input v-model="form[item.Path]" v-else readonly title="暂不支持"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getDataDictionary } from "@/api/scan/request";
export default {
  props: {
    type: {
      default: 'Floor'
    }
  },
  data() {
    return {
      form: {},
      InforsList: []
    };
  },
  created() {
    this.getInforsPoint()
  },
  methods: {
    getInforsPoint() {
      let params = {
        data: {
          Orders: "sort asc,InfoPointCode asc",
          PageNumber: 1,
          PageSize: 50
        },
        type: 'Building '
      };
      getDataDictionary(params, res => {
        this.InforsList = res.Content.map(item => {
          if (item.InputMode === 'D1') {
            item.options = JSON.parse(item.DataSource)
          }
          return item
        })
      })
    },
  }
};
</script>
<style lang="scss" scoped>
#inforsPoint {
  .el-form-item {
    /deep/ label.el-form-item__label {
      font-size: 12px;
    }
  }
  /deep/ .FloorTypeSelect .el-form-item__content {
    width: 178px;
  }
}
</style>
