西藏巴青项目

techServiceLocaleMixin.js 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * 科技平台与服务:tsT(techService.tsNs)、tsCommon
  3. */
  4. export default {
  5. methods: {
  6. tsT(key, values) {
  7. const ns = this.tsNs
  8. if (!ns) {
  9. return key
  10. }
  11. return this.$t(`techService.${ns}.${key}`, values)
  12. },
  13. tsCommon(key) {
  14. return this.$t(`techService.common.${key}`)
  15. },
  16. publishStatusText(v) {
  17. if (v === 0) {
  18. return this.$t("techService.status.unpublished")
  19. }
  20. if (v === 1) {
  21. return this.$t("techService.status.published")
  22. }
  23. return this.$t("techService.status.dash")
  24. },
  25. /** 列表三态:0 未发布 1 已发布 2 已下架 */
  26. displayPublishStatusText(code) {
  27. if (code === 1) {
  28. return this.$t("techService.status.published")
  29. }
  30. if (code === 2) {
  31. return this.$t("techService.status.offline")
  32. }
  33. if (code === 0) {
  34. return this.$t("techService.status.unpublished")
  35. }
  36. return this.$t("techService.status.dash")
  37. },
  38. /** 资源类型:004005~004008 或存量 1~4 */
  39. resourceTypeText(type) {
  40. const legacyKey = { 1: "resourceType1", 2: "resourceType2", 3: "resourceType3", 4: "resourceType4" }
  41. const codeKey = {
  42. "004005": "resourceType1",
  43. "004006": "resourceType2",
  44. "004007": "resourceType3",
  45. "004008": "resourceType4"
  46. }
  47. const key = legacyKey[type] || codeKey[String(type)]
  48. if (key) {
  49. return this.$t(`techService.techResource.${key}`)
  50. }
  51. return type != null && type !== "" ? String(type) : this.$t("techService.status.dash")
  52. },
  53. /** 入库状态:0 未入库 1 已入库 */
  54. kbSyncStatusText(v) {
  55. if (v === 0) {
  56. return this.$t("techService.status.kbNotIn")
  57. }
  58. if (v === 1) {
  59. return this.$t("techService.status.kbIn")
  60. }
  61. return this.$t("techService.status.dash")
  62. },
  63. /** 确认后执行同步知识库,带全局 loading */
  64. runSyncKbAfterConfirm(confirmMessage, syncFn) {
  65. let syncLoading = false
  66. return this.$modal
  67. .confirm(confirmMessage)
  68. .then(() => {
  69. syncLoading = true
  70. this.$modal.loading(this.tsCommon("syncKbLoading"))
  71. return syncFn()
  72. })
  73. .finally(() => {
  74. if (syncLoading) {
  75. this.$modal.closeLoading()
  76. }
  77. })
  78. },
  79. knowledgeTopicText(topic) {
  80. if (topic >= 1 && topic <= 5) {
  81. return this.$t(`techService.knowledge.topic${topic}`)
  82. }
  83. return this.$t("techService.status.dash")
  84. },
  85. /** 专家预约状态 0~4(与兽医接单制一致) */
  86. expertAppointmentStatusText(status) {
  87. if (status >= 0 && status <= 4) {
  88. return this.$t(`techService.expertMyAppointment.status${status}`)
  89. }
  90. return this.$t("techService.status.dash")
  91. },
  92. expertAppointmentStatusTagType(status) {
  93. const map = { 0: "warning", 1: "success", 2: "danger", 3: "info", 4: "" }
  94. return map[status] != null ? map[status] : ""
  95. }
  96. }
  97. }