<template>
  <div class="mod-home" v-loading="loadAll">
    <!-- <h3>项目介绍</h3> -->
    <el-row :gutter="12">
      <el-col :span="12">
        <el-card shadow="hover">
          待处理订单
          <span class="number">{{ orderNum }}</span>
          <router-link :to="{ path: '/order-buyorder', query: {} }">
            <el-button type="primary" size="mini">去处理</el-button>
          </router-link>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card shadow="hover">
          待处理工单/ 反馈
          <span class="number">{{ workOrderNum }}</span>
          <router-link :to="{ path: '/workOrder', query: {} }">
            <el-button type="primary" size="mini">去处理</el-button>
          </router-link>
        </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="12" style="margin-top: 30px;"  v-if="medicalNum > 0||medicalNum2>0">
      <el-col :span="12">
        <el-card shadow="hover">
          待处理医案
          <div style="display: flex;align-items: center;">   <p v-if="medicalNum > 0"><span style="color: #c97902;"> 待审核：</span><span class="number">{{ medicalNum }}</span></p>
          <p v-if="medicalNum2 > 0"><span style="color: #2568d9;"> 三审待审批：</span>
           <span class="number">{{ medicalNum2 }}</span></p><router-link :to="{ path: '/medicalrecords-medicalList', query: {} }">
            <el-button type="primary" size="mini" v-if="medicalNum > 0||medicalNum2>0"

              >去处理</el-button
            >
          </router-link></div>
       
          
        </el-card>
      </el-col>
   
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      medicalNum: 0,
      medicalNum2: 0,
      orderNum: 0,
      workOrderNum: 0,
      // loadAll:true,
      loaded: 0
    };
  },
  created() {
    this.getMedicalList();
    this.getDataList();
    this.getWorkDataList();
  },
  methods: {
    // 待发出列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/book/buyOrder/orderList"),
        method: "post",
        data: this.$http.adornData({
          searchKeyWord: "",
          productName: "",
          startTime: null,
          endTime: null,
          orderStatus: 1,
          pageIndex: 1,
          pageSize: 5
        })
      })
        .then(({ data }) => {
          console.log(data, "列表数据");
          if (data && data.code === 0) {
            // this.dataList = data.result.records
            this.orderNum = data.result.total;
            this.loaded += 1;
          }
        })
        .catch(e => {
          this.$message.error("获取待处理订单错误");
        });
    },
    // 获取工单列表
    getWorkDataList() {
      this.$http({
        url: this.$http.adornUrl("/common/sysFeedback/getList"),
        method: "post",
        data: this.$http.adornData({
          account: "",
          type: "",
          status: "0"
        })
      })
        .then(({ data }) => {
          if (data.code == 0) {
            this.workOrderNum = data.res.length;
            this.loaded += 1;
            // console.log('_list',_list)
          }
        })
        .catch(e => {
          this.$message.error("获取待处理工数量失败");
          // console.log("表单提交报错");
        });
    },
    // 获取工单列表
    getMedicalList() {
      this.$http({
        url: this.$http.adornUrl(
          "/master/medicalRecords/getMedicalRecordsListCheck"
        ),
        method: "post",
        data: this.$http.adornData({
          current: 1,
          limit: 999999,
          state: 1
        })
      }).then(({ data }) => {
        this.medicalNum = data.page.total;
      });
      this.$http({
        url: this.$http.adornUrl(
          "/master/medicalRecords/getMedicalRecordsListCheck"
        ),
        method: "post",
        data: this.$http.adornData({
          current: 1,
          limit: 999999,
          state: 3,
          infoCount: 2
        })
      }).then(({ data }) => {
        this.medicalNum2 = data.page.total;
      });
    }
  },
  computed: {
    loadAll() {
      console.log("this.loaded", this.loaded);
      if (this.loaded == 2) {
        return false;
      } else {
        return true;
      }
    }
  }
};
</script>

<style>
.number {
  font-size: 30px;
  color: #ec6452;
  font-weight: bold;
  display: inline-block;
  margin-right: 20px;
  margin-left: 20px;
}
</style>
