query.js 975 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * 获取全局配置对象
  3. * @param {*} that
  4. * @param {*} module
  5. * @param {*} key
  6. * @returns
  7. */
  8. export const getSetting = async (that, module = '', key = '') => {
  9. try {
  10. const org = that.$store.getters.level.first || ''
  11. const sql = `select setting from t_ipcc where org_ = '${org}' limit 1`
  12. const { variables: { data = [] } = {}} = await that.$common.request('sql', sql)
  13. if (data.length > 0 && data[0]?.setting) {
  14. const setting = data[0].setting?.replace(/\n/g, '')
  15. const res = JSON.parse(setting)
  16. // 根据module和key的存在情况返回不同的结果
  17. if (module !== '') {
  18. if (key !== '') {
  19. return res?.[module]?.[key]
  20. }
  21. return res?.[module]
  22. }
  23. return res
  24. }
  25. return null
  26. } catch (error) {
  27. return that.$message.warning('数据库字段配置错误!')
  28. }
  29. }