noticeway.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <a-spin :spinning="state.loading" >
  3. <a-row :gutter="[16, 16]">
  4. <a-col span="16" >
  5. <a-card
  6. title="参数配置"
  7. >
  8. <template v-slot:extra >
  9. <a-button type="primary" @click="openModal" >{{modelRef.tenantId ? '修改配置' : '创建配置'}}</a-button>
  10. </template>
  11. <a-row>
  12. <a-col span="24" class="email" >
  13. <a-form v-if="modelRef.tenantId" >
  14. <a-form-item label="MQTT 服务地址" >
  15. {{ state.sys.mqttServerUrl }}
  16. </a-form-item>
  17. <a-form-item label="COAP 服务地址" >
  18. {{ state.sys.coapServerUrl }}
  19. </a-form-item>
  20. <a-form-item label="HTTP 服务地址" >
  21. {{ state.sys.httpServerUrl }}
  22. </a-form-item>
  23. <a-form-item label="邮件地址📧" >
  24. {{ state.sys.mailSetting?.host }}
  25. </a-form-item>
  26. <a-form-item label="邮件协议🔗" >
  27. {{ state.sys.mailSetting?.protocol }}
  28. </a-form-item>
  29. <a-form-item label="邮件账号🔢" >
  30. {{ state.sys.mailSetting?.username }}
  31. </a-form-item>
  32. <a-form-item label="邮件密码🫥" >
  33. {{ state.sys.mailSetting?.password }}
  34. </a-form-item>
  35. </a-form>
  36. <a-empty v-else description="暂无邮箱信息" />
  37. </a-col>
  38. </a-row>
  39. </a-card>
  40. </a-col>
  41. <a-col span="18" >
  42. </a-col>
  43. </a-row>
  44. </a-spin>
  45. <modal-pro
  46. :label="modalTitle"
  47. :open="state.visible"
  48. ok-text="确定"
  49. cancel-text="取消"
  50. @cancel="state.visible = false"
  51. @ok="ok"
  52. >
  53. <a-form :label-col="{span: 6}" :wrapper-col="{span: 14}">
  54. <a-form-item label="MQTT 服务地址" v-bind="validateInfos.mqttServerUrl">
  55. <a-input allowClear v-model:value="state.sys.mqttServerUrl" />
  56. </a-form-item>
  57. <a-form-item label="COAP 服务地址" v-bind="validateInfos.coapServerUrl">
  58. <a-input allowClear v-model:value="state.sys.coapServerUrl" />
  59. </a-form-item>
  60. <a-form-item label="HTTP 服务地址" v-bind="validateInfos.httpServerUrl">
  61. <a-input allowClear v-model:value="state.sys.httpServerUrl" />
  62. </a-form-item>
  63. <a-form-item label="邮件地址" v-bind="validateInfos.host">
  64. <a-input allowClear v-model:value="modelRef.host" />
  65. </a-form-item>
  66. <a-form-item label="邮件端口" v-bind="validateInfos.port">
  67. <a-input allowClear v-model:value="modelRef.port" />
  68. </a-form-item>
  69. <a-form-item label="邮件协议" v-bind="validateInfos.protocol">
  70. <a-input allowClear v-model:value="modelRef.protocol" />
  71. </a-form-item>
  72. <a-form-item label="邮件账号" v-bind="validateInfos.username">
  73. <a-input allowClear v-model:value="modelRef.username" />
  74. </a-form-item>
  75. <a-form-item label="邮件密码" v-bind="validateInfos.password">
  76. <a-input allowClear v-model:value="modelRef.password" />
  77. </a-form-item>
  78. </a-form>
  79. </modal-pro>
  80. </template>
  81. <script lang="ts" setup >
  82. import { SysController } from '@/controller'
  83. import { computed, onMounted, reactive } from 'vue'
  84. import { Form } from 'ant-design-vue'
  85. const state = reactive<{
  86. sys: Partial<IOT.API.SYS.Sys>,
  87. visible: boolean
  88. loading: boolean
  89. }>({
  90. sys: {},
  91. visible: false,
  92. loading: false
  93. })
  94. const modalTitle = computed(() => modelRef.id ? '修改邮箱' : '创建邮箱')
  95. const modelRef = reactive({
  96. tenantId: '',
  97. host: '',
  98. port: '',
  99. protocol: '',
  100. username: '',
  101. password: ''
  102. })
  103. const useForm = Form.useForm
  104. const { resetFields, validate, validateInfos } = useForm(modelRef, reactive({
  105. host: [{ required: true, message: '请填写邮件地址' }],
  106. port: [{ required: true, message: '请填写邮件端口' }],
  107. protocol: [{ required: true, message: '请填写邮件协议' }],
  108. username: [{ required: true, message: '请填写邮件账号' }],
  109. password: [{ required: true, message: '请填写邮件密码' }]
  110. }))
  111. const ok = () => {
  112. validate().then(async () => {
  113. if (modelRef.tenantId) {
  114. await SysController.updateSysConf({ ...state.sys, mailSetting: modelRef })
  115. } else {
  116. await SysController.addSysConf({ ...state.sys, mailSetting: modelRef })
  117. }
  118. state.visible = false
  119. getLogo()
  120. })
  121. }
  122. const openModal = () => {
  123. state.visible = true
  124. }
  125. const getLogo = async () => {
  126. state.loading = true
  127. const { data } = await SysController.sysConf()
  128. state.loading = false
  129. console.log('data:', data)
  130. state.sys = data || { mailSetting: {} }
  131. resetFields(data.mailSetting || { mailSetting: {} })
  132. modelRef.tenantId = data ? data.tenantId : ''
  133. console.log(' modelRef.id :', modelRef)
  134. }
  135. onMounted(() => {
  136. getLogo()
  137. })
  138. </script>
  139. <style lang="less" scoped >
  140. .logo-box {
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. .logo {
  146. width: 200px;
  147. height: 200px;
  148. border-radius: 50%;
  149. border: 1px solid #ccc;
  150. }
  151. }
  152. .email {
  153. display: flex;
  154. // justify-content: center;
  155. margin-left: 70px;
  156. margin-top: 20px;
  157. font-size: 22px;
  158. }
  159. .label {
  160. font-size: 32px;
  161. margin-top: 20px;
  162. }
  163. .center {
  164. display: flex;
  165. justify-content: center;
  166. align-items: center;
  167. }
  168. </style>