<template>
  <div class="page">
    <el-form label-width="140px">
      <div class="content-detail">
        <div class="basic-details">
          <div class="basic-details-title">
            <span class="border-span">基本信息</span>
          </div>
          <el-row>
            <el-col :span="6">
              <el-form-item label="规则编码">
                <span> {{ infoData.code }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="规则名称">
                <span> {{ infoData.name }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="规则类型">
                <span>
                  {{ getDictValue('规则类型',  infoData.ruleType) }}
				  </span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="状态">
                <span class="primary-text" v-if="infoData.status">生效</span>
                <span class="danger-text" v-else-if="!infoData.status"
                  >失效</span
                >
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="创建人">
                <span> {{ infoData.createUserName }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="创建时间">
                <span> {{ infoData.createTime }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="巡点检周期">
                <rule-cycle :formData="infoData" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="操作方式/注意事项">
                <el-link
                  v-for="item in infoData.contentImage"
                  @click="$fileSystemDownload(item)"
                  :key="item.docId"
                  >{{ item.name }}</el-link
                >
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <template v-if="!(infoData.ruleType && infoData.ruleType.code == 4)">
          <div class="basic-details-title">
            <span class="border-span">内容配置</span>
          </div>
          <el-table
            ref="multipleTable"
            :data="tableData"
            tooltip-effect="dark"
            style="width: 100%"
            border
            :header-cell-style="{ background: '#F0F3F3' }"
          >
            <el-table-column type="index" label="序号" width="60"/>
            <el-table-column prop="name" label="检测事项" />
            <el-table-column prop="content" label="检测内容" />
            <el-table-column prop="norm" label="检测标准" />
          </el-table>
        </template>
      </div>

      <div class="content-detail" v-show="num == 2"></div>
    </el-form>
  </div>
</template>
<script>
  import dictMixins from '@/mixins/dictMixins';
  import RuleCycle from './components/rule-cycle'
  import {  getDetail  } from '@/api/ruleManagement/matter'
export default {
  mixins: [dictMixins],
  components: { RuleCycle },
  data () {
    return {
      num: 1,
      dialogVisible: false,
      infoData: {},
      form: {},
      type: [],
      tableData: [],
      ruleTypeObj: {
        1: '巡点检规则',
        2: '保养规则',
        4: '盘点规则'
      }
    }
  },
  async created () {
    this.getInfo()
	 this.requestDict('规则类型');
  },
  methods: {
    delete () {},
    // 点击切换事件
    tab (index) {
      this.num = index
    },

    // 表格数据
    async getInfo () {
      const data = await getDetail(this.$route.query.id)
        this.tableData = data.ruleItems
        this.infoData = data
    }
  }
}
</script>
<style lang="scss" scoped>
.page {
  padding: 10px;
}
.page-title {
  background: #fff;
  font-size: 18px;
  padding: 6px 20px;
  font-weight: 500;
  .page-title-div {
    margin: 5px 0;
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid #eaeefb;
    .title-div-no {
      margin-left: 10px;
      font-weight: 400;
      color: #909090;
      font-size: 14px;
    }
  }
}
.page-data {
  padding-top: 10px;
}
.content-detail {
  background: #fff;
  padding: 20px;
}
.flows {
  .flow-left {
    width: 156px;
    height: 70px;
    border: 1px dashed #ccc;
    padding: 10px;
  }
  .row {
    margin-top: 13px;
  }
}
.basic-details-title {
  margin-bottom: 12px;
  margin-top: 20px;
  border-bottom: 1px solid #1890ff;
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.basic-details-title .border-span {
  height: 18px;
  font-size: 16px;
  border-left: 4px solid #1890ff;
  padding-left: 8px;

  font-weight: 500;
}
.heade-right {
  // float: right;
  .heade-right-content {
    margin-right: 12px;
    font-size: 14px;
    display: inline-block;
    .content-key {
      color: #3e3e3e;
      margin-right: 12px;
      font-weight: 500;
    }
    .content-value {
      color: #000;
    }
  }
}
.list-title {
  font-size: 14px;
  color: #3e3e3e;
  margin: 10px 0px;
}
.goods {
  background: #a30014;
  border: 1px solid #a30014;
}
.details-title {
  display: inline-block;
  color: #6e6e6e;
  font-size: 14px;
  font-weight: bold;
  margin-right: 13px;
  width: 70px;
  text-align: right;
}
.details-con {
  color: #3e3e3e;
  font-size: 14px;
}
.detailed-tab {
  margin-left: 10px;
  margin-top: 10px;
}
::v-deep .el-form-item--medium .el-form-item__label {
  color: #6e6e6e;
  font-size: 14px;
  font-weight: bold;
}
.warehouse {
  display: block;
  border-bottom: 1px solid #eaeefb;
  padding: 10px 0;
}
.box-card {
  .store-box {
    width: 80%;
    .store-box-span {
      display: inline-block;
      font-size: 14px;
      height: 50px;
      width: 50px;
      text-align: center;
      line-height: 50px;
      color: #fff;
      margin: 2px;
    }
  }
}
.vacant {
  background: #3196fb;
}
.inUse {
  background: #157a2c;
}
.invalid {
  background: #cccccc;
}
.full {
  background: #cc3300;
}
</style>
