index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. const formConfig = ref({});
  418. const configData = [
  419. [
  420. {
  421. type: "slot",
  422. slotName: "mailAddress",
  423. prop: "mailUserPrefix",
  424. label: "邮箱地址",
  425. required: true,
  426. },
  427. {
  428. type: "input",
  429. prop: "mailPassword",
  430. label: "授权码",
  431. required: true,
  432. },
  433. {
  434. type: "select",
  435. prop: "userId",
  436. label: "绑定用户",
  437. isLoad: {
  438. url: `/tenantUser/list?pageNum=1&pageSize=9999&tenantId=${
  439. useUserStore().user.tenantId
  440. }`,
  441. labelKey: "nickName",
  442. labelVal: "userId",
  443. method: "get",
  444. resUrl: "rows",
  445. },
  446. },
  447. ],
  448. [
  449. {
  450. type: "input",
  451. prop: "domainName",
  452. label: "邮箱域名",
  453. required: true,
  454. },
  455. {
  456. type: "radio",
  457. prop: "type",
  458. label: "是否海外邮箱",
  459. required: true,
  460. border: true,
  461. data: [
  462. { label: "是", value: "2" },
  463. { label: "否", value: "1" },
  464. ],
  465. },
  466. {
  467. type: "input",
  468. prop: "receiveHost",
  469. label: "收件服务器地址",
  470. required: true,
  471. },
  472. {
  473. type: "select",
  474. label: "收件协议",
  475. prop: "receiveProtocol",
  476. itemWidth: 33,
  477. disabled: true,
  478. style: {
  479. width: "100%",
  480. "margin-right": "10px",
  481. },
  482. },
  483. {
  484. type: "input",
  485. prop: "receivePort",
  486. label: " ",
  487. itemWidth: 33.33,
  488. },
  489. {
  490. type: "input",
  491. prop: "sendHost",
  492. label: "发件服务器地址",
  493. required: true,
  494. },
  495. {
  496. type: "select",
  497. label: "发件协议",
  498. prop: "sendProtocol",
  499. itemWidth: 33,
  500. disabled: true,
  501. style: {
  502. width: "100%",
  503. "margin-right": "10px",
  504. },
  505. },
  506. {
  507. type: "input",
  508. prop: "sendPort",
  509. label: " ",
  510. itemWidth: 33.33,
  511. },
  512. ],
  513. ];
  514. const getList = async (req) => {
  515. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  516. loading.value = true;
  517. proxy
  518. .post("/enterpriseMailbox/page", sourceList.value.pagination)
  519. .then((message) => {
  520. console.log(message);
  521. sourceList.value.data = message.rows;
  522. sourceList.value.pagination.total = message.total;
  523. setTimeout(() => {
  524. loading.value = false;
  525. }, 200);
  526. });
  527. };
  528. const getListOne = async () => {
  529. loading.value = true;
  530. proxy
  531. .post("/enterpriseDomain/page", { pageNum: 1, pageSize: 9999 })
  532. .then((message) => {
  533. sourceListOne.value.data = message.rows;
  534. setTimeout(() => {
  535. loading.value = false;
  536. }, 200);
  537. });
  538. };
  539. const openModal = (type) => {
  540. formData.data = {};
  541. dialogVisible.value = true;
  542. modalType.value = "add";
  543. submitType.value = type;
  544. if (type === "10") {
  545. titleText.value = "添加邮箱";
  546. formConfig.value = configData[0];
  547. } else if (type === "20") {
  548. titleText.value = "添加域名";
  549. formConfig.value = configData[1];
  550. formData.data = {
  551. type: "1",
  552. receiveProtocol: "IMAP",
  553. sendProtocol: "SMTP",
  554. };
  555. }
  556. };
  557. const openModalOne = () => {
  558. dialogVisibleOne.value = true;
  559. modalType.value = "add";
  560. };
  561. const submitForm = () => {
  562. byform.value.handleSubmit((valid) => {
  563. submitLoading.value = true;
  564. if (submitType.value === "10") {
  565. proxy.post("/enterpriseMailbox/" + modalType.value, formData.data).then(
  566. (res) => {
  567. ElMessage({
  568. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  569. type: "success",
  570. });
  571. dialogVisible.value = false;
  572. submitLoading.value = false;
  573. getList();
  574. },
  575. (err) => (submitLoading.value = false)
  576. );
  577. } else if (submitType.value === "20") {
  578. proxy.post("/enterpriseDomain/" + modalType.value, formData.data).then(
  579. (res) => {
  580. ElMessage({
  581. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  582. type: "success",
  583. });
  584. dialogVisible.value = false;
  585. submitLoading.value = false;
  586. getListOne();
  587. },
  588. (err) => (submitLoading.value = false)
  589. );
  590. }
  591. });
  592. };
  593. const getDtl = (row, type) => {
  594. modalType.value = "edit";
  595. submitType.value = type;
  596. if (type === "10") {
  597. proxy.post("/enterpriseMailbox/detail", { id: row.id }).then((res) => {
  598. formConfig.value = configData[0];
  599. formData.data = res;
  600. });
  601. } else if (type === "20") {
  602. proxy.post("/enterpriseDomain/detail", { id: row.id }).then((res) => {
  603. formConfig.value = configData[1];
  604. res.type = res.type + "";
  605. formData.data = res;
  606. });
  607. }
  608. dialogVisible.value = true;
  609. };
  610. getList();
  611. getListOne();
  612. </script>
  613. <style lang="scss" scoped>
  614. .tenant {
  615. padding: 20px;
  616. }
  617. </style>