tenantInfo.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 机构管理
  6. </h2>
  7. <!-- 列表 -->
  8. <div v-if="status" class="m-core">
  9. <!-- 机构基本信息 -->
  10. <organInfo
  11. ref="organInfo"
  12. :data="info"
  13. type="update"
  14. tenantInfo="SETTING"
  15. />
  16. <div
  17. style="display: flex;width: 100%;"
  18. v-if="$helpers.permission('tenantInfo/update/info')"
  19. >
  20. <i class="icon_admin_home"></i>
  21. <el-button type="primary" @click="onNext">确认</el-button>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import {
  28. tenantInfoAdd,
  29. tenantInfoInfo,
  30. tenantInfoUpdate
  31. } from "../organManager/api";
  32. import organInfo from "../organManager/components/organInfo";
  33. import { setTheme } from "@/utils/setTheme";
  34. export default {
  35. components: { organInfo },
  36. data() {
  37. return {
  38. tableList: [],
  39. form: {},
  40. info: {},
  41. status: false
  42. };
  43. },
  44. mounted() {
  45. this.__init();
  46. },
  47. methods: {
  48. async __init() {
  49. try {
  50. const res = await tenantInfoInfo({ id: this.$helpers.tenantId });
  51. this.status = true;
  52. const { config, productInfo, ...other } = res.data;
  53. const {
  54. theme,
  55. themeColor,
  56. corporateChops,
  57. corporateFinanceChops,
  58. id,
  59. ...con
  60. } = config;
  61. this.info = {
  62. ...other,
  63. theme,
  64. themeColor,
  65. corporateChops,
  66. corporateFinanceChops,
  67. configId: id
  68. };
  69. } catch (e) {}
  70. },
  71. async onNext() {
  72. const organStatus = await this.$refs.organInfo.onSubmit();
  73. if (!organStatus) return;
  74. const organData = await this.$refs.organInfo.getValues();
  75. // const { theme, themeColor, configId, ...con } = organData;
  76. const {
  77. theme,
  78. themeColor,
  79. configId,
  80. corporateChops,
  81. corporateFinanceChops,
  82. ...con
  83. } = organData;
  84. let config = {
  85. theme,
  86. themeColor,
  87. corporateChops,
  88. corporateFinanceChops,
  89. id: configId
  90. };
  91. let params = {
  92. ...con,
  93. config
  94. };
  95. try {
  96. const res = await tenantInfoUpdate(params);
  97. this.$message.success("修改更新成功");
  98. // 机构购买不能修改主题
  99. let baseTenantId = sessionStorage.getItem("baseTenantId");
  100. if (baseTenantId > 0) {
  101. setTheme({
  102. theme,
  103. themeColor
  104. });
  105. // 重新设置样式
  106. let tenantConfig = sessionStorage.getItem("tenantConfig");
  107. tenantConfig = tenantConfig ? JSON.parse(tenantConfig) : {};
  108. sessionStorage.setItem(
  109. "tenantConfig",
  110. JSON.stringify({
  111. ...tenantConfig,
  112. theme,
  113. themeColor
  114. })
  115. );
  116. }
  117. } catch (e) {}
  118. }
  119. },
  120. async beforeDestroy() {
  121. let tenantConfig = sessionStorage.getItem("tenantConfig");
  122. tenantConfig = tenantConfig ? JSON.parse(tenantConfig) : {};
  123. const organData = await this.$refs.organInfo.getValues();
  124. const { theme, themeColor } = organData;
  125. if (theme != tenantConfig.theme) {
  126. setTheme({
  127. theme: tenantConfig.theme,
  128. themeColor: tenantConfig.themeColor
  129. });
  130. }
  131. }
  132. };
  133. </script>
  134. <style lang="scss" scoped>
  135. .courseMask .el-dialog__body {
  136. padding-bottom: 0;
  137. }
  138. </style>