index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. :action-list="[
  17. {
  18. text: '邮箱域名管理',
  19. action: () => openModalOne(),
  20. },
  21. {
  22. text: '添加邮箱',
  23. action: () => openModal('10'),
  24. },
  25. ]"
  26. @get-list="getList"
  27. >
  28. <template #mialAddress="{ item }">
  29. {{ item.mailUserPrefix }}@{{ item.domainName }}
  30. </template>
  31. </byTable>
  32. </div>
  33. <el-dialog
  34. :title="titleText"
  35. v-model="dialogVisible"
  36. width="450"
  37. v-loading="loading"
  38. >
  39. <byForm
  40. :formConfig="formConfig"
  41. :formOption="formOption"
  42. v-model="formData.data"
  43. :rules="rules"
  44. ref="byform"
  45. >
  46. <template #mailAddress>
  47. <el-row style="width: 100%">
  48. <el-col :span="11">
  49. <el-input
  50. v-model="formData.data.mailUserPrefix"
  51. placeholder="请输入"
  52. >
  53. </el-input>
  54. </el-col>
  55. <el-col :span="2" style="text-align: center"> @ </el-col>
  56. <el-col :span="11">
  57. <el-select
  58. v-model="formData.data.domainId"
  59. placeholder="请选择"
  60. style="width: 100%"
  61. >
  62. <el-option
  63. v-for="item in sourceListOne.data"
  64. :label="item.domainName"
  65. :value="item.id"
  66. >
  67. </el-option>
  68. </el-select>
  69. </el-col>
  70. </el-row>
  71. </template>
  72. <template #rSlot>
  73. <el-row style="width: 100%" :gutter="15">
  74. <el-col :span="10">
  75. <el-select
  76. v-model="formData.data.receiveProtocol"
  77. placeholder="收件协议"
  78. disabled
  79. >
  80. </el-select>
  81. </el-col>
  82. <el-col :span="10">
  83. <el-input
  84. v-model="formData.data.receivePort"
  85. placeholder="请输入"
  86. >
  87. </el-input>
  88. </el-col>
  89. </el-row>
  90. </template>
  91. <template #sSlot>
  92. <el-row style="width: 100%" :gutter="15">
  93. <el-col :span="10">
  94. <el-select
  95. v-model="formData.data.sendProtocol"
  96. placeholder="发件协议"
  97. disabled
  98. >
  99. </el-select>
  100. </el-col>
  101. <el-col :span="10">
  102. <el-input v-model="formData.data.sendPort" placeholder="请输入">
  103. </el-input>
  104. </el-col>
  105. </el-row>
  106. </template>
  107. </byForm>
  108. <template #footer>
  109. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  110. <el-button
  111. type="primary"
  112. v-no-double-click="submitForm"
  113. size="large"
  114. :loading="submitLoading"
  115. >
  116. 确 定
  117. </el-button>
  118. </template>
  119. </el-dialog>
  120. <el-dialog
  121. title="邮箱域名管理"
  122. v-model="dialogVisibleOne"
  123. width="800"
  124. v-loading="loading"
  125. >
  126. <div style="width: 100%">
  127. <div style="padding: 0px 20px">
  128. <el-button type="primary" @click="openModal('20')">
  129. 添加域名
  130. </el-button>
  131. </div>
  132. <byTable
  133. :source="sourceListOne.data"
  134. :config="configOne"
  135. :loading="loading"
  136. highlight-current-row
  137. :hidePagination="true"
  138. :hideSearch="true"
  139. >
  140. </byTable>
  141. </div>
  142. <template #footer>
  143. <el-button @click="dialogVisibleOne = false" size="large"
  144. >取 消</el-button
  145. >
  146. <!-- <el-button
  147. type="primary"
  148. v-no-double-click="submitForm"
  149. size="large"
  150. :loading="submitLoading"
  151. >
  152. 确 定
  153. </el-button> -->
  154. </template>
  155. </el-dialog>
  156. </div>
  157. </template>
  158. <script setup>
  159. /* eslint-disable vue/no-unused-components */
  160. import { ElMessage, ElMessageBox } from "element-plus";
  161. import byTable from "@/components/byTable/index";
  162. import byForm from "@/components/byForm/index";
  163. import { computed, defineComponent, ref } from "vue";
  164. import useUserStore from "@/store/modules/user";
  165. const loading = ref(false);
  166. const submitLoading = ref(false);
  167. const sourceList = ref({
  168. data: [],
  169. pagination: {
  170. total: 3,
  171. pageNum: 1,
  172. pageSize: 10,
  173. },
  174. });
  175. const sourceListOne = ref({
  176. data: [],
  177. });
  178. let dialogVisible = ref(false);
  179. let dialogVisibleOne = ref(false);
  180. let modalType = ref("add");
  181. let submitType = ref("");
  182. let titleText = ref("");
  183. let rules = ref({
  184. mailUserPrefix: [{ required: true, message: "请输入地址", trigger: "blur" }],
  185. domainName: [{ required: true, message: "请输入邮箱域名", trigger: "blur" }],
  186. type: [{ required: true, message: "请选择邮箱类型", trigger: "change" }],
  187. mailPassword: [{ required: true, message: "请输入授权码", trigger: "blur" }],
  188. receiveHost: [
  189. { required: true, message: "请输入收件服务器地址", trigger: "blur" },
  190. ],
  191. receivePort: [{ required: true, message: "请输入收件端口", trigger: "blur" }],
  192. receiveProtocol: [
  193. { required: true, message: "请输入收件协议", trigger: "blur" },
  194. ],
  195. sendHost: [
  196. { required: true, message: "请输入发件服务器地址", trigger: "blur" },
  197. ],
  198. sendPort: [{ required: true, message: "请输入发件端口", trigger: "blur" }],
  199. sendProtocol: [
  200. { required: true, message: "请输入发件协议", trigger: "blur" },
  201. ],
  202. });
  203. const { proxy } = getCurrentInstance();
  204. const selectConfig = [];
  205. const config = computed(() => {
  206. return [
  207. {
  208. attrs: {
  209. type: "slot",
  210. slot: "mialAddress",
  211. label: "邮箱地址",
  212. },
  213. },
  214. {
  215. attrs: {
  216. label: "授权码",
  217. prop: "mailPassword",
  218. },
  219. },
  220. {
  221. attrs: {
  222. label: "绑定用户",
  223. prop: "userName",
  224. },
  225. },
  226. {
  227. attrs: {
  228. label: "收件协议",
  229. prop: "receiveProtocol",
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "收件端口号",
  235. prop: "receivePort",
  236. },
  237. },
  238. {
  239. attrs: {
  240. label: "发件协议",
  241. prop: "sendProtocol",
  242. },
  243. },
  244. {
  245. attrs: {
  246. label: "发件端口号",
  247. prop: "sendPort",
  248. },
  249. },
  250. {
  251. attrs: {
  252. label: "操作",
  253. width: "130",
  254. align: "right",
  255. },
  256. // 渲染 el-button,一般用在最后一列。
  257. renderHTML(row) {
  258. return [
  259. {
  260. attrs: {
  261. label: "修改",
  262. type: "primary",
  263. text: true,
  264. },
  265. el: "button",
  266. click() {
  267. getDtl(row, "10");
  268. },
  269. },
  270. {
  271. attrs: {
  272. label: "删除",
  273. type: "danger",
  274. text: true,
  275. },
  276. el: "button",
  277. click() {
  278. // 弹窗提示是否删除
  279. ElMessageBox.confirm(
  280. "此操作将永久删除该数据, 是否继续?",
  281. "提示",
  282. {
  283. confirmButtonText: "确定",
  284. cancelButtonText: "取消",
  285. type: "warning",
  286. }
  287. ).then(() => {
  288. // 删除
  289. proxy
  290. .post("/enterpriseMailbox/delete", {
  291. id: row.id,
  292. })
  293. .then((res) => {
  294. ElMessage({
  295. message: "删除成功",
  296. type: "success",
  297. });
  298. getList();
  299. });
  300. });
  301. },
  302. },
  303. ];
  304. },
  305. },
  306. ];
  307. });
  308. const configOne = computed(() => {
  309. return [
  310. {
  311. attrs: {
  312. label: "邮箱域名",
  313. prop: "domainName",
  314. },
  315. },
  316. {
  317. attrs: {
  318. label: "海外邮箱",
  319. prop: "type",
  320. },
  321. render(type) {
  322. return type == 2 ? "是" : "否";
  323. },
  324. },
  325. {
  326. attrs: {
  327. label: "收件协议",
  328. prop: "receiveProtocol",
  329. },
  330. },
  331. {
  332. attrs: {
  333. label: "收件端口号",
  334. prop: "receivePort",
  335. },
  336. },
  337. {
  338. attrs: {
  339. label: "发件协议",
  340. prop: "sendProtocol",
  341. },
  342. },
  343. {
  344. attrs: {
  345. label: "发件端口号",
  346. prop: "sendPort",
  347. },
  348. },
  349. {
  350. attrs: {
  351. label: "操作",
  352. width: "130",
  353. align: "right",
  354. },
  355. // 渲染 el-button,一般用在最后一列。
  356. renderHTML(row) {
  357. return [
  358. {
  359. attrs: {
  360. label: "修改",
  361. type: "primary",
  362. text: true,
  363. },
  364. el: "button",
  365. click() {
  366. getDtl(row, "20");
  367. },
  368. },
  369. {
  370. attrs: {
  371. label: "删除",
  372. type: "danger",
  373. text: true,
  374. },
  375. el: "button",
  376. click() {
  377. // 弹窗提示是否删除
  378. ElMessageBox.confirm(
  379. "此操作将永久删除该数据, 是否继续?",
  380. "提示",
  381. {
  382. confirmButtonText: "确定",
  383. cancelButtonText: "取消",
  384. type: "warning",
  385. }
  386. ).then(() => {
  387. // 删除
  388. proxy
  389. .post("/enterpriseDomain/delete", {
  390. id: row.id,
  391. })
  392. .then((res) => {
  393. ElMessage({
  394. message: "删除成功",
  395. type: "success",
  396. });
  397. getListOne();
  398. });
  399. });
  400. },
  401. },
  402. ];
  403. },
  404. },
  405. ];
  406. });
  407. let formData = reactive({
  408. data: {},
  409. });
  410. const formOption = reactive({
  411. inline: true,
  412. labelWidth: 100,
  413. itemWidth: 100,
  414. });
  415. const byform = ref(null);
  416. const treeData = ref([]);
  417. let formConfig = ref({});
  418. const userList = ref([]);
  419. const configData = computed(() => [
  420. [
  421. {
  422. type: "slot",
  423. slotName: "mailAddress",
  424. prop: "mailUserPrefix",
  425. label: "邮箱地址",
  426. required: true,
  427. },
  428. {
  429. type: "input",
  430. prop: "mailPassword",
  431. label: "授权码",
  432. required: true,
  433. },
  434. {
  435. type: "select",
  436. prop: "userId",
  437. label: "绑定用户",
  438. data: userList.value,
  439. },
  440. ],
  441. [
  442. {
  443. type: "input",
  444. prop: "domainName",
  445. label: "邮箱域名",
  446. required: true,
  447. },
  448. {
  449. type: "radio",
  450. prop: "type",
  451. label: "是否海外邮箱",
  452. required: true,
  453. border: true,
  454. data: [
  455. { label: "是", value: "2" },
  456. { label: "否", value: "1" },
  457. ],
  458. },
  459. {
  460. type: "input",
  461. prop: "receiveHost",
  462. label: "收件服务器地址",
  463. required: true,
  464. },
  465. {
  466. type: "select",
  467. label: "收件协议",
  468. prop: "receiveProtocol",
  469. itemWidth: 33,
  470. disabled: true,
  471. style: {
  472. width: "100%",
  473. "margin-right": "10px",
  474. },
  475. },
  476. {
  477. type: "input",
  478. prop: "receivePort",
  479. label: " ",
  480. itemWidth: 33.33,
  481. },
  482. {
  483. type: "input",
  484. prop: "sendHost",
  485. label: "发件服务器地址",
  486. required: true,
  487. },
  488. {
  489. type: "select",
  490. label: "发件协议",
  491. prop: "sendProtocol",
  492. itemWidth: 33,
  493. disabled: true,
  494. style: {
  495. width: "100%",
  496. "margin-right": "10px",
  497. },
  498. },
  499. {
  500. type: "input",
  501. prop: "sendPort",
  502. label: " ",
  503. itemWidth: 33.33,
  504. },
  505. ],
  506. ]);
  507. const getList = async (req) => {
  508. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  509. loading.value = true;
  510. proxy
  511. .post("/enterpriseMailbox/page", sourceList.value.pagination)
  512. .then((message) => {
  513. console.log(message);
  514. sourceList.value.data = message.rows;
  515. sourceList.value.pagination.total = message.total;
  516. setTimeout(() => {
  517. loading.value = false;
  518. }, 200);
  519. });
  520. };
  521. const getListOne = async () => {
  522. loading.value = true;
  523. proxy
  524. .post("/enterpriseDomain/page", { pageNum: 1, pageSize: 9999 })
  525. .then((message) => {
  526. sourceListOne.value.data = message.rows;
  527. setTimeout(() => {
  528. loading.value = false;
  529. }, 200);
  530. });
  531. };
  532. const openModal = (type) => {
  533. formData.data = {};
  534. dialogVisible.value = true;
  535. modalType.value = "add";
  536. submitType.value = type;
  537. if (type === "10") {
  538. titleText.value = "添加邮箱";
  539. formConfig.value = configData.value[0];
  540. } else if (type === "20") {
  541. titleText.value = "添加域名";
  542. formConfig.value = configData.value[1];
  543. formData.data = {
  544. type: "1",
  545. receiveProtocol: "IMAP",
  546. sendProtocol: "SMTP",
  547. };
  548. }
  549. };
  550. const openModalOne = () => {
  551. dialogVisibleOne.value = true;
  552. modalType.value = "add";
  553. };
  554. const submitForm = () => {
  555. byform.value.handleSubmit((valid) => {
  556. submitLoading.value = true;
  557. if (submitType.value === "10") {
  558. proxy.post("/enterpriseMailbox/" + modalType.value, formData.data).then(
  559. (res) => {
  560. ElMessage({
  561. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  562. type: "success",
  563. });
  564. dialogVisible.value = false;
  565. submitLoading.value = false;
  566. getList();
  567. },
  568. (err) => (submitLoading.value = false)
  569. );
  570. } else if (submitType.value === "20") {
  571. proxy.post("/enterpriseDomain/" + modalType.value, formData.data).then(
  572. (res) => {
  573. ElMessage({
  574. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  575. type: "success",
  576. });
  577. dialogVisible.value = false;
  578. submitLoading.value = false;
  579. getListOne();
  580. },
  581. (err) => (submitLoading.value = false)
  582. );
  583. }
  584. });
  585. };
  586. const getDtl = (row, type) => {
  587. modalType.value = "edit";
  588. submitType.value = type;
  589. if (type === "10") {
  590. proxy.post("/enterpriseMailbox/detail", { id: row.id }).then((res) => {
  591. formConfig.value = configData.value[0];
  592. formData.data = res;
  593. });
  594. } else if (type === "20") {
  595. proxy.post("/enterpriseDomain/detail", { id: row.id }).then((res) => {
  596. formConfig.value = configData.value[1];
  597. res.type = res.type + "";
  598. formData.data = res;
  599. });
  600. }
  601. dialogVisible.value = true;
  602. };
  603. const getDict = () => {
  604. proxy
  605. .get(
  606. `/tenantUser/list?pageNum=1&pageSize=9999&tenantId=${
  607. useUserStore().user.tenantId
  608. }`
  609. )
  610. .then((res) => {
  611. userList.value = res.rows.map((x) => ({
  612. label: x.nickName,
  613. value: x.userId,
  614. }));
  615. });
  616. };
  617. getList();
  618. getListOne();
  619. getDict();
  620. </script>
  621. <style lang="scss" scoped>
  622. .tenant {
  623. padding: 20px;
  624. }
  625. </style>