<template>
  <div class="app-continer">
    <div style="margin: 15px 0; padding: 0 20px">
      <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="90px">
        <el-form-item label="科室" prop="orgIdList">
            <el-select
              v-model="queryParams.orgIdList"
              placeholder="请选择科室"
              clearable
              multiple
              style="width: 480px"
            >
              <el-option
                v-for="item in departmentList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        <el-form-item label="结算时间：" prop="activeFlag">
          <el-date-picker
            v-model="occurrenceTime"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            style="width: 300px; margin-bottom: 10px; margin-left: 20px"
            value-format="YYYY-MM-DD"
            :clearable="false"
            @change="getClinicRecord"
          />
        </el-form-item>
        <div style="float: right">
          <el-button type="primary" plain @click="getClinicRecord">查询</el-button>
          <el-button type="warning" plain @click="handleReset">重置</el-button>
        </div>
      </el-form>
    </div>
    <el-table :data="clinicRecord" show-summary border>
      <!-- <el-table-column label="计算类型" align="center" prop="statusEnum_enumText" /> -->
      <el-table-column label="序号" width="80" type="index" align="center">
        <template #default="scope">
            <span>{{ (queryParams.pageNo - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="科室" align="center" prop="orgName" :show-overflow-tooltip="true"/>
      <el-table-column label="人次" align="center" prop="personCnt" :show-overflow-tooltip="true"/>
      <el-table-column label="应收金额" align="center" prop="amount" :show-overflow-tooltip="true"/>
      <el-table-column label="实收金额" align="center" prop="receivedAmount" width="280" :show-overflow-tooltip="true"/>
      <el-table-column label="挂号费" align="center" prop="registrationFee" :show-overflow-tooltip="true"/>
      <el-table-column label="处置费" align="center" prop="serviceFee" :show-overflow-tooltip="true"/>
      <el-table-column label="药品费" align="center" prop="medFee" :show-overflow-tooltip="true"/>
      <!-- <el-table-column label="优惠金额" align="center" prop="entererName" :show-overflow-tooltip="true"/> -->
      <!-- <el-table-column label="日结" align="center" prop="outcomeEnum_dictText" :show-overflow-tooltip="true"/> -->
      <!-- <el-table-column label="月累计" align="center" prop="printCount" :show-overflow-tooltip="true"/> -->
      <el-table-column label="备注" align="center" prop="printCount" :show-overflow-tooltip="true"/>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getLists"
    />
  </div>
</template>

<script setup name="incomeStatement">
const { proxy } = getCurrentInstance();
import { getChargeItemByOrg, getDepartmentList } from './components/api.js';
import { formatDate } from '@/utils/index';
const occurrenceTime = ref([formatDate(new Date()),formatDate(new Date())]);
const total = ref(0);
const queryParams = ref({
  pageNo: 1,
  pageSize: 10,
  startTime:"",
  endTime:"",
  searchKey:"",
});
const clinicRecord = ref([]);
const paymentDetailList = ref([])
const departmentList = ref([])
getOrgId()
getClinicRecord();
function getClinicRecord() {
  queryParams.value.startTime =
  occurrenceTime.value && occurrenceTime.value.length == 2
    ? occurrenceTime.value[0] + " 00:00:00"
    : "";
  queryParams.value.endTime =
    occurrenceTime.value && occurrenceTime.value.length == 2
      ? occurrenceTime.value[1] + " 23:59:59"
      : "";
  queryParams.value.pageNo = 1;
  getLists()
}
function getOrgId() {
  getDepartmentList().then(res => {
    departmentList.value = res.data
  })
}
function getLists(){
  getChargeItemByOrg(queryParams.value).then((res) => {
    total.value = res.data.total;
    clinicRecord.value = res.data.clinic;
  });
}
/** 清空条件按钮操作 */
function handleReset() {
  // 清空查询条件
  occurrenceTime.value = ""
  queryParams.value.startTime = ""
  queryParams.value.endTime = ""
  proxy.resetForm("queryRef");
  getLists();
}
</script>
<style scoped>
.el-dialog{
  height: 90vh!important;
}
.dialog-footer {
  text-align: right;
}
.el-textarea__inner {
  resize: none;
}
</style>