<template>
  <div>
    <el-table :data="doctorCheck.RegisterCheckList" border
      :height="(window.pageHeight < 600) ? 220 : (window.pageHeight - 380)" size="small" highlight-current-row
      ref="doctorCheck.RegisterCheckList" :row-class-name="tableRowClassName">
      <el-table-column prop="asbitemName" label="组合项目" width="120" />
      <el-table-column prop="completeFlag" label="状态" align="center">
        <template slot-scope="scope">
          <div>
            {{ dddw(dict.checkCompleteFlag, 'id', scope.row.completeFlag, 'displayName') }}
            <!--
            <el-radio v-model="scope.row.checkCompleteFlag" label="0">未检</el-radio>
            <el-radio v-model="scope.row.checkCompleteFlag" label="1">已检</el-radio>
            <el-radio v-model="scope.row.checkCompleteFlag" label="2">弃检</el-radio>
            -->
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="checkDate" label="检查日期" width="90">
        <template slot-scope="scope">
          <div v-if="scope.row.checkDate">
            {{ moment(scope.row.checkDate).format("yyyy-MM-DD") }}
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import moment from "moment";
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { dddw } from "../../utlis/proFunc"

export default {
  components: {},
  props: ["patientRegisterId"],
  data() {
    return {};
  },

  created() { },

  //挂载完成
  mounted() {
    if (this.patientRegisterId) {
      this.registerCheckList(this.patientRegisterId);
    }
  },

  computed: {
    ...mapState(["window", "dict", "doctorCheck"]),
  },
  methods: {
    moment, dddw,

    tableRowClassName({ row, rowIndex }) {
      //console.log(row)
      switch (row.completeFlag) {
        case '0':
          return 'danger'; //未检
        case '2':
          return 'info'; //未检
        default:
          return '';
      }
    },

    //获取检查组合项目
    registerCheckList(patientRegisterId) {
      console.log(`/api/app/register-check/register-check-or-asbitem/${patientRegisterId}`)
      getapi(`/api/app/register-check/register-check-or-asbitem/${patientRegisterId}`)
        .then((res) => {
          console.log("registerCheckList", res.data);
          if (res.code != -1) {
            this.doctorCheck.RegisterCheckList = res.data;
          }
        })
        .catch((err) => {
          this.$message({ type: "error", message: `操作失败，原因：${err}` });
        });
    },
  },

  watch: {
    //人员ID切换
    "patientRegisterId"(newVal, oldVal) {
      console.log("watch patientRegisterId newVal：", newVal, " oldVal：", oldVal);
      if (newVal != oldVal && newVal != '') {
        this.registerCheckList(newVal);
      }
    },
  }
};
</script>
<style scoped>
::v-deep .el-input__inner {
  text-align: center;
  padding-left: 1px;
  padding-right: 1px;
}

::v-deep .el-table th.el-table__cell {
  text-align: center;
  padding-left: 1px;
  padding-right: 1px;
}

::v-deep .el-table td.el-table__cell {
  padding-left: 1px;
  padding-right: 1px;
}

::v-deep .el-table .cell {
  padding-left: 1px;
  padding-right: 1px;
}

::v-deep input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}
</style>
