sopVoice.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /** SOP 内容类别:语音 / APP语音 */
  2. export const SOP_VOICE_TYPES = ['7', '16']
  3. /**
  4. * 是否允许新增/编辑 SOP 语音、APP语音。
  5. * 在对应环境 .env 中配置 VUE_APP_SOP_VOICE_ENABLE=false 即可关闭;恢复时改为 true 或删除该配置。
  6. * 未配置时默认开启,不影响其它客户。
  7. */
  8. export function isSopVoiceEnabled() {
  9. return process.env.VUE_APP_SOP_VOICE_ENABLE !== 'false'
  10. }
  11. export function isSopVoiceType(contentType) {
  12. return SOP_VOICE_TYPES.includes(String(contentType))
  13. }
  14. /** 新增场景:从字典中去掉语音、APP语音选项 */
  15. export function filterSopContentTypes(list) {
  16. if (isSopVoiceEnabled()) {
  17. return list || []
  18. }
  19. return (list || []).filter(item => !isSopVoiceType(item.dictValue))
  20. }
  21. /** 已有语音/APP语音内容:关闭开关后仅可删除,不可改 */
  22. export function isSopVoiceLocked(contentType) {
  23. return !isSopVoiceEnabled() && isSopVoiceType(contentType)
  24. }
  25. /** 内容类别 radio:关闭开关时隐藏语音类;当前已是该类则仍展示(便于识别后删除) */
  26. export function showSopContentTypeOption(dictValue, currentType) {
  27. if (isSopVoiceEnabled() || !isSopVoiceType(dictValue)) {
  28. return true
  29. }
  30. return String(currentType) === String(dictValue)
  31. }