import {detail, page} from "@/api/basic/sicker/prescribeApi";

let prescribeQuery = {
  sickerCode: '',
  page: 1,
  limit: 10
}

export default {
  data() {
    return {
      fullscreenLoading:false,
      // ============处方=============
      sickerInfo:null,
      showPrescribeDetailDialog:false,
      prescribeLoading: false,
      prescribeList: [],
      prescribeTotal: 0,
      prescribeQuery: {...prescribeQuery},
      prescribeDetail: null
      // ============处方end=============
    };
  }
  ,
  mounted() {
  },
  created() {
    this.getList()
  },
  methods: {
    onReset() {
      this.filterQuery = {...query}
      this.getList()
    },
    onSubmit() {
      this.filterQuery.page = 1;
      this.getList()
    },
    getList() {
      this.prescribeQuery = {...prescribeQuery}
      this.prescribeQuery.sickerCode = this.sickerInfo?.code
      this.prescribeLoading = true
      page(this.prescribeQuery).then(res => {
        this.prescribeLoading = false
        this.prescribeList = res.data.list || []
        this.prescribeTotal = res.data.total || 0
      }).catch(()=>{
        this.prescribeLoading = false
        this.prescribeList = []
        this.prescribeTotal = 0
      })
    },
    showPrescribeDetail(row){
      this.fullscreenLoading = true
      detail({prescribeCode:row.code}).then(res=>{
        this.fullscreenLoading = false
        if(res.code!=20000){
          this.$message.error(res.message)
          return
        }
        this.prescribeDetail = res.data
        this.showPrescribeDetailDialog = true
      }).catch (() => {
        this.fullscreenLoading = false
        this.$message.error("数据加载失败")
      })
    }
  }
}
