/**
 * 牧业疫病诊疗服务：dtT（按 data.dtNs 取子模块文案）、dtCommon（通用按钮/校验）
 */
export default {
  methods: {
    dtT(key, values) {
      const ns = this.dtNs
      if (!ns) {
        return key
      }
      return this.$t(`diseaseTreatment.${ns}.${key}`, values)
    },
    dtCommon(key) {
      return this.$t(`diseaseTreatment.common.${key}`)
    },
    /** 列表/详情三态：0 未发布 1 已发布 2 已下架 */
    displayPublishStatusText(code) {
      if (code === 1) {
        return this.$t("diseaseTreatment.status.published")
      }
      if (code === 2) {
        return this.$t("diseaseTreatment.status.offline")
      }
      if (code === 0) {
        return this.$t("diseaseTreatment.status.unpublished")
      }
      return this.$t("diseaseTreatment.status.dash")
    },
    resourceTypeText(type) {
      if (type >= 1 && type <= 4) {
        return this.dtT("resourceType" + type)
      }
      return this.$t("diseaseTreatment.status.dash")
    },
    /** 兽医预约状态 0～4 */
    vetAppointmentStatusText(status) {
      if (status >= 0 && status <= 4) {
        return this.$t(`diseaseTreatment.vetMyAppointment.status${status}`)
      }
      return this.$t("diseaseTreatment.status.dash")
    },
    vetAppointmentStatusTagType(status) {
      const map = { 0: "warning", 1: "success", 2: "danger", 3: "info", 4: "" }
      return map[status] != null ? map[status] : ""
    },
    /** 机构预约状态 3 已取消、4 已完成、5 已预约 */
    orgAppointmentStatusText(status) {
      if (status === 5) {
        return this.$t("diseaseTreatment.orgMyAppointment.status5")
      }
      if (status === 3) {
        return this.$t("diseaseTreatment.orgMyAppointment.status3")
      }
      if (status === 4) {
        return this.$t("diseaseTreatment.orgMyAppointment.status4")
      }
      return this.$t("diseaseTreatment.status.dash")
    },
    orgAppointmentStatusTagType(status) {
      const map = { 5: "success", 3: "info", 4: "" }
      return map[status] != null ? map[status] : ""
    }
  }
}
