detailComp.vue 11.5 KB
<template>
  <div class="info-wrapper">
    <div class="item" v-for="(item, index) in configData" :key="index">
      <div class="title" v-if="item.title">{{ item.title }}</div>
      <div class="detail-content">
        <div class="form_div" v-if="item.infoData && item.infoData.length">
          <el-form
            :ref="item.childRef"
            class="edit-sub-block"
            :label-width="labelWidth"
            :inline="true"
            :model="detailInfo"
            :rules="rules"
          >
            <el-row :gutter="20">
              <template v-for="(item, key) in item.infoData">
                <template v-if="item.isHidden ? !item.isHidden : true">
                  <el-col :span="item.col ? item.col : 12" :key="key">
                    <el-form-item :label="item.title + ':'" :prop="item.key">
                      <template v-if="item.type == 'imgList'">
                        <div
                          class="photo-box"
                          v-if="
                            detailInfo[item.key] && detailInfo[item.key].length
                          "
                        >
                          <glsx-preview
                            :image-url-arr="
                              detailInfo[item.key] ? detailInfo[item.key] : []
                            "
                            :videoImg="true"
                            :picOptions="{
                              ...picOptions,
                              type: item.otherType
                            }"
                            limit="1"
                          ></glsx-preview>
                        </div>
                        <template v-else> - </template>
                      </template>
                      <template v-else-if="item.isEdit">
                        <template v-if="item.type == 'input'">
                          <el-input
                            v-model="detailInfo[item.key]"
                            :placeholder="`请输入${item.label}`"
                            :maxlength="item.maxLength || ''"
                            size="small"
                            class="edit-form-item"
                          ></el-input>
                        </template>
                        <template v-else-if="item.type == 'date'">
                          <el-date-picker
                            v-model="detailInfo[item.key]"
                            type="date"
                            :placeholder="item.label"
                            size="small"
                            class="edit-form-item"
                            :picker-options="item.pickerOptions"
                          >
                          </el-date-picker>
                        </template>
                        <template v-else-if="item.type == 'textarea'">
                          <el-input
                            type="textarea"
                            :rows="3"
                            placeholder="请输入"
                            v-model="detailInfo[item.key]"
                            :maxlength="item.maxLength"
                            class="edit-form-item"
                          >
                          </el-input>
                        </template>
                        <template v-else-if="item.type == 'select'">
                          <el-select
                            v-model="detailInfo[item.key]"
                            :placeholder="`请选择${item.label}`"
                            size="small"
                            class="edit-form-item"
                          >
                            <el-option
                              v-for="item in item.options"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            >
                            </el-option>
                          </el-select>
                        </template>
                      </template>
                      <template v-else>
                        <div class="flex">
                          <div
                            v-if="item.className && item.className(detailInfo)"
                            :style="{
                              background: item.className(detailInfo)
                            }"
                            :class="'dot'"
                          ></div>
                          <el-tooltip
                            v-if="item.hasTooltip"
                            effect="dark"
                            placement="top-start"
                          >
                            <div slot="content" class="tooltip-content">
                              {{
                                item.formatter
                                  ? item.formatter(detailInfo) || "-"
                                  : detailInfo[item.key]
                                  ? detailInfo[item.key]
                                  : "-"
                              }}
                            </div>
                            <span :style="{ ...item.style }">
                              {{
                                item.formatter
                                  ? item.formatter(detailInfo) || "-"
                                  : detailInfo[item.key]
                                  ? detailInfo[item.key]
                                  : "-"
                              }}
                            </span>
                          </el-tooltip>
                          <span v-else :style="{ ...item.style }"
                            >{{
                              item.formatter
                                ? item.formatter(detailInfo) || "-"
                                : detailInfo[item.key]
                                ? detailInfo[item.key]
                                : "-"
                            }}
                          </span>
                          <template v-if="item.suffixText">
                            <div class="unit">
                              {{ item.suffixText }}
                            </div>
                          </template>
                        </div>
                      </template>
                    </el-form-item></el-col
                  >
                </template>
              </template>
            </el-row>
          </el-form>
        </div>
        <div class="emptyCom" v-else>
          <img :src="emptyImgUrl" class="emptyImg" alt="" />
          <span class="tips">暂无信息</span>
        </div>
      </div>
      <template v-if="item.subTitle">
        <div v-for="signIndex in item.sign" :key="signIndex">
          <div class="subtitle">{{ item.subTitle }}{{ signIndex }}</div>
          <div class="detail-content">
            <div class="form_div" v-if="item.subData && item.subData.length">
              <el-form
                class="edit-sub-block"
                label-width="150px"
                :inline="true"
              >
                <el-row :gutter="20">
                  <template v-for="(item, key) in item.subData">
                    <el-col :span="item.col ? item.col : 12" :key="key">
                      <el-form-item :label="item.title + ':'">
                        <div
                          v-if="item.className && item.className(detailInfo)"
                          :style="{
                            background: item.className(detailInfo)
                          }"
                          :class="'dot'"
                        ></div>

                        <template>
                          {{
                            item.formatter
                              ? item.formatter(detailInfo) || "-"
                              : detailInfo[item.key]
                              ? detailInfo[item.key]
                              : "-"
                          }}
                        </template>
                      </el-form-item></el-col
                    >
                  </template>
                </el-row>
              </el-form>
            </div>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    configData: {
      type: Array,
      default: () => []
    },
    detailInfo: {
      type: Object,
      default: () => {}
    },
    labelWidth: {
      type: String,
      default: "150px"
    }
  },
  data() {
    return {
      emptyImgUrl: require("@/assets/resume-empty.png"),
      videoStr: "?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast",
      picOptions: {
        width: "90px",
        height: "90px",
        isClose: false
      },
      rules: {}
    }
  }
}
</script>
<style scoped lang="scss">
.info-wrapper {
  background-color: #fff;
  margin: 0 20px;
  .item {
    margin-bottom: 20px;
    .title {
      color: #333333;
      font-size: 16px;
      font-weight: bold;
      padding: 13.5px 20px;
      border-bottom: 1px solid #e5e5e5;
      line-height: 23px;
      box-sizing: border-box;
    }
    .form_div {
      color: #333333;
      padding: 20px;
      font-size: 14px;
      .edit-sub-block {
        .el-form-item {
          width: 100%;
          margin-bottom: 0px;
        }
        ::v-deep .el-form-item__label {
          color: #666666;
          font-size: 14px;
          line-height: 20px;
        }
        .itemDiv {
          display: flex;
          .halfItem {
            width: 50%;
          }
        }
        .detail-txt {
          display: inline-block;
          width: 200px;
          vertical-align: bottom;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        ::v-deep .el-col {
          margin-bottom: 20px;
        }
        ::v-deep .el-form-item__content {
          width: calc(100% - 150px);
          word-break: break-all;
          line-height: 20px;
        }
        ::v-deep el-form-item--medium .el-form-item__label {
          line-height: 20px;
        }
      }
      .unit {
        margin-left: 8px;
        flex-shrink: 0;
        line-height: 20px;
      }
      .flex {
        display: flex;
        align-items: center;
      }
      .edit-sub-block-two {
        .el-form-item {
          margin-bottom: 0px;
        }
      }
      .dot {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-right: 8px;
      }
      .photo-box {
        display: flex;
        align-items: center;
        ::v-deep .photo-activity {
          width: 100%;
          height: 100%;
          object-fit: contain;
          position: static !important;
          border-radius: 4px;
        }
        ::v-deep .video-poster {
          position: absolute;
          width: 104px;
          height: 104px;
          object-fit: fill;
          top: 0;
          right: 0;
          left: 0;
          bottom: 0;
          border-radius: 4px;
        }
        ::v-deep .mask {
          border-radius: 4px;
        }
        ::v-deep .pic-box {
          margin-right: 16px;
          .video-poster {
            width: 90px;
            height: 90px;
          }
        }
      }
    }
    .emptyCom {
      height: 300px;
      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      .emptyImg {
        width: 66px;
      }
      .tips {
        color: #666666;
        font-size: 12px;
        margin-top: 20px;
      }
    }
  }
}

.tooltip-content {
  max-height: 300px;
  overflow-y: scroll !important;
}
</style>