<template>
  <div class="topform">
    <div v-if="form.getParamslistData">
      <div v-for="(aitem, aindex) in form.getParamslistData"  :key="aindex">
          <el-card>
        
            <div class="toptitle">{{ aitem.taskPartitionDictName }}</div>
            <div
              style="display: flex"
              v-for="(bitem, bindex) in aitem.portraitSnVOList"
              :key="bindex"
            >
              <el-card class="box-card">
                <el-form
                  ref="form"
                  :inline="true"
                  :model="form"
                  class="form"
                  label-width="100px"
                  :rules="rules"
                >
                  <el-form-item
                    v-for="(cItem, cIndex) in bitem.groupingValues"
                    :key="cIndex"
                    :label="cItem.fieldName"
                  >
                    <el-input v-model="cItem.fieldValue"></el-input>
                  </el-form-item>
                </el-form>
              </el-card>
              <div class="icon">
                <i
                  class="el-icon-delete"
                  @click="delitem(aindex,bindex)"
                  v-if="bindex != 0"
                ></i>
                <i
                  v-if="bindex == 0"
                  class="el-icon-circle-plus-outline"
                  @click="additem(aindex,bindex)"
                ></i>
              </div>
            </div>
          </el-card>
        </div>
      <!-- <div
        v-for="(item, index) in getParamslistData"
        :key="index"
        style="display: flex"
      >
        <el-card class="box-card">
          <el-form
            ref="form"
            :inline="true"
            :model="form"
            class="form"
            label-width="100px"
            :rules="rules"
          >
            <el-form-item
              v-for="(ite, ind) in item"
              :label="ite.fieldName"
              :key="ind"
            >
              <el-input class="textarea" v-model="ite.fieldValue" v-if="!portaitCheckStatus"></el-input>
              <el-input class="textarea" v-model="ite.fieldValue" disabled  v-else></el-input>

            </el-form-item>
          </el-form>
        </el-card>
        <div class="icon" v-if="!portaitCheckStatus">
          <i
            class="el-icon-delete"
            @click="delitem(index)"
            v-if="index != 0"
          ></i>
          <i
            v-if="index == 0"
            class="el-icon-circle-plus-outline"
            @click="additem(index)"
          ></i>
        </div>
      </div> -->
    </div>


  </div>

</template>

<script>

import {
  getPortaitByPatient
} from '@/api/manage/Auditing.js'
export default {
  props:['patientId','portaitCheckStatus'],//接收psMsg值

  data() {
    return {
      CheckStatus:'',
      moban: [],
      querytParams: {
        taskPartitionDictId: 0,
        // patientId: this.$route.query.patientId,
        patientId: null,
      },
      rules: {
        routeCheckStatus: [
          { required: true, message: '请选择节点审核状态', trigger: 'change' }
        ],
      },
      form: {
      getParamslistData: [],

      },
      // form:{},
      // getParamslistData: [],

    }
  },
  watch: {
    "getParamslistData": {
      handler(newValue, oldValue) {
        console.log(newValue,'newValue')
        this.$emit("portraitlist", newValue);
      },
      deep: true,
    },
    portaitCheckStatus: {
      handler(newValue, oldValue) {
        this.portaitCheckStatus=newValue
        console.log(newValue, "portaitCheckStatus");
      },
    }

  },
  created() {
    this.CheckStatus=this.$route.query.routeCheckStatus
  },
  mounted() {
    this.querytParams.patientId=this.patientId
    this.getParams()
  },
  methods: {
    // 右侧列表
    getParams() {
      // getPortaitByPatient
      getPortaitByPatient(this.querytParams).then(res => {
        console.log(res, 'res')
        this.moban = JSON.parse(JSON.stringify(res.data))
        this.getParamslistData = res.data
        // console.log(this.getParamslistData, '009090')

      })
    },
    // 添加
    additem(index) {
      this.moban[0].forEach(e => {
        e.fieldValue = ""
        e.portraitSn = ''
        // e.id = ""
      })
      const newVal = JSON.parse(JSON.stringify(this.moban[0]))
      // const newVal = JSON.parse(JSON.stringify(this.getParamslistData[0]))
      // newVal.forEach(i => {
      //   // i.sn = this.getParamslistData.length +1
      //   i.sn = this.getParamslistData[this.getParamslistData.length - 1][0].sn + 1
      // })
      this.getParamslistData.push(newVal)
    },
    // 删除
    delitem(index, item) {
      // this.form.items.splice(index, 1)
      this.getParamslistData.splice(index, 1)

    },

  },

}
</script>
<style scoped lang="scss">
::v-deep .el-input.is-disabled .el-input__inner{
  background: #fff;
}
.topform {
  width: 100%;
  position: relative;
  height: calc(100% - 177px);
  // overflow-y: auto;
  padding: 15px 70px 30px 15px;
  .toptitle {
    font-weight: 500;
    padding: 20px;
    font-size: 18px;
  }
  .box-card {
    // width:calc(100% - 149px);
    width: 97%;
    margin-left: 20px;
    padding-top: 25px;
    margin-bottom: 20px;
    .textarea {
      display: flex;
      // width: 500px;
      // width: 100%;
    }
  }
  .icon {
    width: 45px;
    right: -20px;
    top: 40px;
    position: relative;
  }
  .form {
    width: 100%;
    ::v-deep .el-form-item {
      display: flex;
    }
    ::v-deep .el-form-item__content {
      flex: 1;
    }
    ::v-deep .el-input__inner {
      height: 30px !important;
      line-height: 30px !important;
    }

    ::v-deep .el-form-item__label {
      font-size: 12px !important;
    }
  }
}
</style>
