index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="68px"
  10. >
  11. <el-form-item label="租户名称" prop="tenantName">
  12. <el-input
  13. v-model="queryParams.tenantName"
  14. placeholder="请输入租户名称"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="租户编号" prop="tenantCode">
  20. <el-input
  21. v-model="queryParams.tenantCode"
  22. placeholder="请输入租户编号"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="负责人" prop="owner">
  28. <el-input
  29. v-model="queryParams.owner"
  30. placeholder="请输入负责人"
  31. clearable
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item label="联系方式" prop="contactInfo">
  36. <el-input
  37. v-model="queryParams.contactInfo"
  38. placeholder="请输入联系方式"
  39. clearable
  40. @keyup.enter.native="handleQuery"
  41. />
  42. </el-form-item>
  43. <el-form-item label="地址" prop="address">
  44. <el-input
  45. v-model="queryParams.address"
  46. placeholder="请输入地址"
  47. clearable
  48. @keyup.enter.native="handleQuery"
  49. />
  50. </el-form-item>
  51. <el-form-item>
  52. <el-button
  53. type="primary"
  54. icon="el-icon-search"
  55. size="mini"
  56. @click="handleQuery"
  57. >搜索</el-button
  58. >
  59. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  60. >重置</el-button
  61. >
  62. </el-form-item>
  63. </el-form>
  64. <el-row :gutter="10" class="mb8">
  65. <el-col :span="1.5">
  66. <el-button
  67. type="primary"
  68. plain
  69. icon="el-icon-plus"
  70. size="mini"
  71. @click="handleAdd"
  72. v-hasPermi="['system:tenant:add']"
  73. >新增
  74. </el-button>
  75. </el-col>
  76. <!-- <el-col :span="1.5">
  77. <el-button
  78. type="success"
  79. plain
  80. icon="el-icon-edit"
  81. size="mini"
  82. :disabled="single"
  83. @click="handleUpdate"
  84. v-hasPermi="['system:tenant:edit']"
  85. >修改</el-button>
  86. </el-col> -->
  87. <el-col :span="1.5">
  88. <el-button
  89. type="danger"
  90. plain
  91. icon="el-icon-delete"
  92. size="mini"
  93. :disabled="multiple"
  94. @click="handleDelete"
  95. v-hasPermi="['system:tenant:remove']"
  96. >删除
  97. </el-button>
  98. </el-col>
  99. <el-col :span="1.5">
  100. <el-button
  101. type="warning"
  102. plain
  103. icon="el-icon-download"
  104. size="mini"
  105. @click="handleExport"
  106. v-hasPermi="['system:tenant:export']"
  107. >导出
  108. </el-button>
  109. <!-- <el-button
  110. type="warning"
  111. plain
  112. icon="el-icon-download"
  113. size="mini"
  114. @click="handleTest"
  115. >test
  116. </el-button> -->
  117. </el-col>
  118. <right-toolbar
  119. :showSearch.sync="showSearch"
  120. @queryTable="getList"
  121. ></right-toolbar>
  122. </el-row>
  123. <el-table
  124. v-loading="loading"
  125. :data="tenantList"
  126. @selection-change="handleSelectionChange"
  127. >
  128. <el-table-column type="selection" width="55" align="center" />
  129. <el-table-column label="租户ID" align="center" prop="tenantId" />
  130. <el-table-column label="租户名称" align="center" prop="tenantName" />
  131. <el-table-column label="租户编号" align="center" prop="tenantCode" />
  132. <el-table-column label="负责人" align="center" prop="owner" />
  133. <el-table-column label="联系方式" align="center" prop="contactInfo" />
  134. <el-table-column label="地址" align="center" prop="address" />
  135. <el-table-column
  136. label="操作"
  137. align="center"
  138. class-name="small-padding fixed-width"
  139. >
  140. <template slot-scope="scope">
  141. <el-dropdown>
  142. <el-button type="warning" plain size="small">
  143. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  144. </el-button>
  145. <el-dropdown-menu slot="dropdown">
  146. <el-dropdown-item>
  147. <el-button
  148. size="mini"
  149. type="text"
  150. icon="el-icon-edit"
  151. @click="handleUpdate(scope.row)"
  152. v-hasPermi="['system:tenant:edit']"
  153. >修改
  154. </el-button>
  155. </el-dropdown-item>
  156. <el-dropdown-item>
  157. <el-button
  158. size="mini"
  159. type="text"
  160. icon="el-icon-delete"
  161. @click="handleDelete(scope.row)"
  162. v-hasPermi="['system:tenant:remove']"
  163. >删除
  164. </el-button>
  165. </el-dropdown-item>
  166. <el-dropdown-item>
  167. <el-button
  168. size="mini"
  169. type="text"
  170. icon="el-icon-position"
  171. @click="bindDatasource(scope.row)"
  172. v-show="scope.row.datasourceId == null"
  173. >绑定数据源
  174. </el-button>
  175. </el-dropdown-item>
  176. <el-dropdown-item>
  177. <el-button
  178. size="mini"
  179. type="text"
  180. icon="el-icon-s-custom"
  181. @click="openTenantExpirationTime(scope.row)"
  182. v-hasPermi="['system:tenant:remove']"
  183. >激活租户
  184. </el-button>
  185. </el-dropdown-item>
  186. </el-dropdown-menu>
  187. </el-dropdown>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <pagination
  192. v-show="total > 0"
  193. :total="total"
  194. :page.sync="queryParams.pageNum"
  195. :limit.sync="queryParams.pageSize"
  196. @pagination="getList"
  197. />
  198. <!-- 添加或修改租户信息对话框 -->
  199. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  200. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  201. <el-form-item label="租户名称" prop="tenantName">
  202. <el-input v-model="form.tenantName" placeholder="请输入租户名称" />
  203. </el-form-item>
  204. <el-form-item label="租户编号" prop="tenantCode">
  205. <el-input v-model="form.tenantCode" placeholder="请输入租户编号" />
  206. </el-form-item>
  207. <el-form-item label="负责人" prop="owner">
  208. <el-input v-model="form.owner" placeholder="请输入负责人" />
  209. </el-form-item>
  210. <el-form-item label="联系方式" prop="contactInfo">
  211. <el-input v-model="form.contactInfo" placeholder="请输入联系方式" />
  212. </el-form-item>
  213. <el-form-item label="地址" prop="address">
  214. <el-input v-model="form.address" placeholder="请输入地址" />
  215. </el-form-item>
  216. </el-form>
  217. <div slot="footer" class="dialog-footer">
  218. <el-button type="primary" @click="submitForm">确 定</el-button>
  219. <el-button @click="cancel">取 消</el-button>
  220. </div>
  221. </el-dialog>
  222. <!-- 添加或修改数据源信息对话框 -->
  223. <el-dialog
  224. :title="dataSourceTitle"
  225. :visible.sync="dataSourceOpen"
  226. width="500px"
  227. append-to-body
  228. class="loadingClass"
  229. >
  230. <el-radio-group
  231. v-model="dataSourceType"
  232. class="mb5"
  233. @input="dataSourceTypeChange"
  234. >
  235. <el-radio-button :label="true">公网</el-radio-button>
  236. <el-radio-button :label="false">内网</el-radio-button>
  237. </el-radio-group>
  238. <el-form
  239. ref="dataSourceForm"
  240. :model="dataSourceForm"
  241. :rules="dataSourceFormRules"
  242. label-width="120px"
  243. >
  244. <el-form-item label="数据源类型" prop="databaseType">
  245. <el-select
  246. v-model="dataSourceForm.databaseType"
  247. :placeholder="palcemsg"
  248. @change="selecthandle"
  249. :disabled="dataSourceType"
  250. >
  251. <el-option
  252. v-for="item in dict.type.datasource_type"
  253. :key="item.value"
  254. :label="item.label"
  255. :value="item.value"
  256. ></el-option>
  257. </el-select>
  258. </el-form-item>
  259. <el-form-item label="数据库名称" prop="databaseName">
  260. <el-input
  261. v-model="dataSourceForm.databaseName"
  262. placeholder="请输入数据库名称"
  263. />
  264. </el-form-item>
  265. <el-form-item label="租户管理员账号" prop="tenantAccount">
  266. <el-input
  267. v-model="dataSourceForm.tenantAccount"
  268. placeholder="请输入租户管理员账号"
  269. />
  270. </el-form-item>
  271. <!-- !dataSourceType -->
  272. <el-form-item
  273. label="数据库IP"
  274. v-show="!dataSourceType"
  275. prop="databaseIp"
  276. >
  277. <el-input
  278. v-model="dataSourceForm.databaseIp"
  279. placeholder="请输数据库IP"
  280. />
  281. </el-form-item>
  282. <el-form-item label="用户名" v-show="!dataSourceType" prop="username">
  283. <el-input
  284. v-model="dataSourceForm.username"
  285. placeholder="请输入用户名"
  286. />
  287. </el-form-item>
  288. <el-form-item label="密码" v-show="!dataSourceType" prop="password">
  289. <el-input
  290. v-model="dataSourceForm.password"
  291. placeholder="请输入密码"
  292. />
  293. </el-form-item>
  294. <el-form-item label="端口号" v-show="!dataSourceType" prop="portNumber">
  295. <el-input
  296. v-model="dataSourceForm.portNumber"
  297. placeholder="请输入端口号"
  298. />
  299. </el-form-item>
  300. </el-form>
  301. <div slot="footer" class="dialog-footer">
  302. <el-button
  303. type="primary"
  304. @click="submitForm1"
  305. :disabled="dialogLoading"
  306. :loading="dialogLoading"
  307. >{{ dialogLoading ? "绑定中" : "确 定" }}</el-button
  308. >
  309. <el-button @click="cancel1">取 消</el-button>
  310. </div>
  311. </el-dialog>
  312. <!-- 激活租户弹出层-->
  313. <el-dialog
  314. title="激活租户"
  315. :visible.sync="tenantExpirationTimeOpen"
  316. width="500px"
  317. append-to-body
  318. >
  319. <el-form
  320. ref="tenantExpirationTimeFrom"
  321. :model="tenantExpirationTimeFrom"
  322. :rules="rulesTenantExpirationTime"
  323. label-width="80px"
  324. >
  325. <el-form-item
  326. label="激活租户"
  327. prop="tenantExpirationTime"
  328. label-width="110px"
  329. >
  330. <el-input
  331. v-model="tenantExpirationTimeFrom.tenantExpirationTime"
  332. placeholder="请输入激活码"
  333. />
  334. </el-form-item>
  335. <el-form-item class="btn">
  336. <el-button
  337. type="primary"
  338. @click="activationOperationMethod('tenantExpirationTimeFrom')"
  339. >确 定</el-button
  340. >
  341. <el-button @click="tanentCancel">取 消</el-button>
  342. </el-form-item>
  343. </el-form>
  344. </el-dialog>
  345. </div>
  346. </template>
  347. <script>
  348. import {
  349. listTenant,
  350. getTenant,
  351. delTenant,
  352. addTenant,
  353. updateTenant,
  354. bindDatasource,
  355. selectAllUser,
  356. createTenant,
  357. initTenantMenuData,
  358. activationOperation,
  359. } from "@/api/system/tenant";
  360. import { getDataSourceInfo, insertDataSource } from "@/api/system/data";
  361. import { servicesLoading } from "@/utils/zkqy";
  362. import { getIsExistUser } from "@/api/system/user";
  363. export default {
  364. name: "Tenant",
  365. dicts: [
  366. "datasource_type",
  367. "sqlserver_connection_information",
  368. "mysql_connection_information",
  369. "dm_connection_information",
  370. "orcale_connection_information",
  371. ],
  372. data() {
  373. return {
  374. // 弹窗的加载提示
  375. dialogLoading: false,
  376. // 遮罩层
  377. loading: true,
  378. // 选中数组
  379. ids: [],
  380. // 非单个禁用
  381. single: true,
  382. // 非多个禁用
  383. multiple: true,
  384. // 显示搜索条件
  385. showSearch: true,
  386. // 总条数
  387. total: 0,
  388. // 租户信息表格数据
  389. tenantList: [],
  390. // 弹出层标题
  391. title: "",
  392. // 是否显示弹出层
  393. open: false,
  394. // 所有用户信息
  395. allUser: [],
  396. // 查询参数
  397. queryParams: {
  398. pageNum: 1,
  399. pageSize: 10,
  400. tenantName: null,
  401. tenantCode: null,
  402. owner: null,
  403. contactInfo: null,
  404. address: null,
  405. },
  406. // 当前编辑租户的信息
  407. currentTenantInfo: {},
  408. // 表单参数
  409. form: {},
  410. // 表单校验
  411. rules: {
  412. tenantName: [
  413. { required: true, message: "租户名称不能为空", trigger: "blur" },
  414. ],
  415. tenantCode: [
  416. { required: true, message: "租户编号不能为空", trigger: "blur" },
  417. ],
  418. },
  419. //数据源表单参数
  420. dataSourceType: true, //true:公网 false:内网
  421. dataSourceForm: {
  422. databaseType: "",
  423. databaseName: "",
  424. tenantAccount: "",
  425. databaseIp: "",
  426. username: "",
  427. password: "",
  428. portNumber: "",
  429. },
  430. dataSourceTitle: "",
  431. dataSourceOpen: false,
  432. fromTenantId: null,
  433. dataSourceFormRules: {
  434. databaseType: [
  435. { required: true, message: "数据源类型不能为空", trigger: "change" },
  436. ],
  437. databaseName: [
  438. { required: true, message: "数据库名不能为空", trigger: "blur" },
  439. { validator: this.databaseNameValidator, trigger: "blur" },
  440. ],
  441. tenantAccount: [
  442. {
  443. required: true,
  444. message: "租户管理员账号不能为空",
  445. trigger: "change",
  446. },
  447. { validator: this.tenantAccountValidator, trigger: "blur" },
  448. ],
  449. databaseIp: [
  450. { required: true, message: "数据库IP不能为空", trigger: "blur" },
  451. ],
  452. username: [
  453. { required: true, message: "用户名不能为空", trigger: "blur" },
  454. ],
  455. password: [
  456. { required: true, message: "密码不能为空", trigger: "blur" },
  457. ],
  458. portNumber: [
  459. { required: true, message: "端口号不能为空", trigger: "blur" },
  460. ],
  461. },
  462. //租户激活码弹窗表单
  463. tenantExpirationTimeFrom: {
  464. tenantId: null,
  465. tenantExpirationTime: "",
  466. },
  467. //租户激活码弹窗标题
  468. tenantExpirationTimeOpen: false,
  469. //租户激活码规则验证
  470. rulesTenantExpirationTime: {
  471. tenantExpirationTime: [
  472. { required: true, message: "请输入租户激活码", trigger: "blur" },
  473. ],
  474. },
  475. };
  476. },
  477. computed: {
  478. palcemsg() {
  479. return this.dataSourceType ? "mysql" : "请选择数据源类型";
  480. },
  481. },
  482. created() {
  483. this.getList();
  484. this.selectAllUser();
  485. },
  486. methods: {
  487. // 租户名自定义校验规则
  488. async tenantAccountValidator(rule, value, callback) {
  489. // let isRepeat = this.allUser.filter((item) => item.userName == value);
  490. // if (isRepeat.length !== 0) {
  491. // callback(new Error("租户账号重复"));
  492. // } else {
  493. // callback();
  494. // }
  495. if (value) {
  496. await getIsExistUser({ userName: value }).then((res) => {
  497. if (res.code == 200) {
  498. if (res.data) {
  499. callback();
  500. } else {
  501. callback(new Error("租户管理员账号已存在"));
  502. }
  503. } else {
  504. callback(new Error("租户管理员账号校验失败,请重新输入"));
  505. }
  506. });
  507. }
  508. callback();
  509. },
  510. // 获取所用用户名,作校验用
  511. async selectAllUser() {
  512. let res = await selectAllUser();
  513. if (res.code == 200) {
  514. this.allUser = res.data;
  515. } else {
  516. console.log(res.msg);
  517. }
  518. },
  519. // 租户名自定义校验规则
  520. tenantAccountValidator(rule, value, callback) {
  521. let isRepeat = this.allUser.filter((item) => item.userName == value);
  522. if (isRepeat.length !== 0) {
  523. callback(new Error("租户账号重复"));
  524. } else {
  525. callback();
  526. }
  527. },
  528. // 数据库名称校验规则
  529. databaseNameValidator(rule, value, callback) {
  530. let regex = /^[a-z][a-z0-9]*$/;
  531. if (regex.test(value)) {
  532. callback(); // 输入内容符合规则
  533. } else {
  534. callback(new Error("只能包含小写字母和数字,且以小写字母开头"));
  535. }
  536. },
  537. // 数据源类型改变回调
  538. dataSourceTypeChange(type) {
  539. this.$nextTick(() => {
  540. this.$refs.dataSourceForm.resetFields();
  541. this.dataSourceForm.databaseType = "mysql";
  542. this.selecthandle("mysql");
  543. });
  544. },
  545. handleOpe() {},
  546. /** 查询租户信息列表 */
  547. getList() {
  548. this.loading = true;
  549. listTenant(this.queryParams).then((response) => {
  550. this.tenantList = response.rows;
  551. this.total = response.total;
  552. this.loading = false;
  553. });
  554. },
  555. // 取消按钮
  556. cancel() {
  557. this.open = false;
  558. this.reset();
  559. },
  560. // 绑定数据源取消按钮
  561. cancel1() {
  562. this.dataSourceOpen = false;
  563. this.reset1();
  564. },
  565. // 表单重置
  566. reset() {
  567. this.form = {
  568. tenantId: null,
  569. tenantName: null,
  570. tenantCode: null,
  571. owner: null,
  572. contactInfo: null,
  573. address: null,
  574. createBy: null,
  575. createTime: null,
  576. };
  577. this.resetForm("form");
  578. },
  579. // 表单重置
  580. reset1() {
  581. this.dataSourceType = true;
  582. this.dataSourceForm = {
  583. id: null,
  584. databaseName: null,
  585. databaseIp: null,
  586. tenantAccount: "",
  587. username: null,
  588. password: null,
  589. portNumber: null,
  590. databaseType: "mysql",
  591. };
  592. // this.resetForm("dataSourceForm");
  593. },
  594. /** 搜索按钮操作 */
  595. handleQuery() {
  596. this.queryParams.pageNum = 1;
  597. this.getList();
  598. },
  599. /** 重置按钮操作 */
  600. resetQuery() {
  601. this.resetForm("queryForm");
  602. this.handleQuery();
  603. },
  604. // 多选框选中数据
  605. handleSelectionChange(selection) {
  606. this.ids = selection.map((item) => item.tenantId);
  607. this.single = selection.length !== 1;
  608. this.multiple = !selection.length;
  609. },
  610. /** 新增按钮操作 */
  611. handleAdd() {
  612. // this.reset();
  613. this.open = true;
  614. this.title = "添加租户信息";
  615. },
  616. /** 修改按钮操作 */
  617. handleUpdate(row) {
  618. this.reset();
  619. const tenantId = row.tenantId || this.ids;
  620. getTenant(tenantId).then((response) => {
  621. this.form = response.data;
  622. this.open = true;
  623. this.title = "修改租户信息";
  624. });
  625. },
  626. /** 绑定数据源按钮操作 */
  627. bindDatasource(row) {
  628. this.currentTenantInfo = row;
  629. this.reset1();
  630. this.dialogLoading = false;
  631. this.dataSourceOpen = true;
  632. this.dataSourceTitle = row.tenantName + "配置数据库";
  633. this.fromTenantId = row.tenantId;
  634. this.dataSourceTypeChange();
  635. // const tenantId = row.tenantId || this.ids;
  636. // getTenant(tenantId).then((response) => {
  637. // this.form = response.data;
  638. // this.open = true;
  639. // this.title = "修改租户信息";
  640. // });
  641. },
  642. /** 提交按钮 */
  643. submitForm() {
  644. this.$refs["form"].validate((valid) => {
  645. if (valid) {
  646. if (this.form.tenantId != null) {
  647. updateTenant(this.form).then((response) => {
  648. this.$modal.msgSuccess("修改成功");
  649. this.open = false;
  650. this.getList();
  651. });
  652. } else {
  653. addTenant(this.form).then((response) => {
  654. this.$modal.msgSuccess("新增成功");
  655. this.open = false;
  656. this.getList();
  657. });
  658. }
  659. }
  660. });
  661. },
  662. /** 提交按钮 */
  663. submitForm1() {
  664. this.$refs["dataSourceForm"].validate((valid) => {
  665. if (valid) {
  666. // const loading = servicesLoading(
  667. // ".loadingClass",
  668. // "正在绑定数据源",
  669. // true
  670. // );
  671. this.dialogLoading = true;
  672. if (this.dataSourceForm.id != null) {
  673. // bindDatasource(this.dataSourceForm).then((response) => {
  674. // this.$modal.msgSuccess("修改成功");
  675. // this.dataSourceOpen = false;
  676. // this.getList();
  677. // });
  678. } else {
  679. let query = {
  680. tenantId: this.fromTenantId,
  681. dataSource: this.dataSourceForm,
  682. };
  683. bindDatasource(query).then((response) => {
  684. if (response.code == 200) {
  685. let data = {
  686. userName: this.dataSourceForm.tenantAccount,
  687. nickName: this.currentTenantInfo.tenantName,
  688. userType: "01",
  689. tenantId: this.currentTenantInfo.tenantId,
  690. password: "123456",
  691. };
  692. createTenant(data)
  693. .then(async (res) => {
  694. if (res.code == 200) {
  695. let resp = await initTenantMenuData(
  696. this.currentTenantInfo.tenantId
  697. );
  698. if ((resp.code = 200)) {
  699. this.$modal.msgSuccess("新增成功");
  700. this.dataSourceOpen = false;
  701. // loading.close();
  702. this.getList();
  703. }
  704. }
  705. })
  706. .finally(() => {
  707. this.dialogLoading = fasle;
  708. });
  709. }
  710. });
  711. }
  712. }
  713. });
  714. },
  715. /** 删除按钮操作 */
  716. handleDelete(row) {
  717. const tenantIds = row.tenantId || this.ids;
  718. this.$modal
  719. .confirm('是否确认删除租户信息编号为"' + tenantIds + '"的数据项?')
  720. .then(function () {
  721. return delTenant(tenantIds);
  722. })
  723. .then(() => {
  724. this.getList();
  725. this.$modal.msgSuccess("删除成功");
  726. })
  727. .catch(() => {});
  728. },
  729. /** 导出按钮操作 */
  730. handleExport() {
  731. this.download(
  732. "system/tenant/export",
  733. {
  734. ...this.queryParams,
  735. },
  736. `tenant_${new Date().getTime()}.xlsx`
  737. );
  738. },
  739. /**
  740. * 选择数据源校验名称
  741. */
  742. selecthandle(row) {
  743. let sql = {
  744. sqlserver: "sqlserver_connection_information",
  745. mysql: "mysql_connection_information",
  746. dm: "dm_connection_information",
  747. oracle: "oracle_connection_information",
  748. };
  749. let qar = {};
  750. this.dict.type[sql[row]].forEach((item) => {
  751. qar[item.label] = item.value;
  752. });
  753. if (this.dataSourceType) {
  754. let { databaseIp, password, portNumber, username } = qar;
  755. Object.assign(this.dataSourceForm, {
  756. databaseIp,
  757. password,
  758. portNumber,
  759. username,
  760. });
  761. }
  762. getDataSourceInfo(qar).then((res) => {
  763. // console.log(res);
  764. });
  765. },
  766. handleTest() {
  767. let formdata = {
  768. databaseType: "mysql",
  769. databaseName: "test1111",
  770. databaseIp: "127.0.0.1",
  771. username: "testname",
  772. password: "123123",
  773. portNumber: "3306",
  774. };
  775. insertDataSource(formdata).then((res) => {
  776. console.log(res);
  777. });
  778. },
  779. //重置租户激活码表单
  780. restTenantExpirationTime() {
  781. this.tenantExpirationTimeFrom = {
  782. tenantId: null,
  783. tenantExpirationTime: "",
  784. };
  785. this.resetForm("tenantExpirationTimeFrom");
  786. },
  787. /**打开激活码弹窗*/
  788. openTenantExpirationTime(row) {
  789. // this.reset();
  790. const tenantId = row.tenantId || this.ids;
  791. this.tenantExpirationTimeFrom.tenantId = row.tenantId;
  792. this.tenantExpirationTimeOpen = true;
  793. // this.title="激活租户";
  794. },
  795. /**激活租户操作*/
  796. activationOperationMethod(form) {
  797. this.$refs[form].validate(async (valid) => {
  798. if (valid) {
  799. let response = await activationOperation(
  800. this.tenantExpirationTimeFrom
  801. );
  802. if (response.code == 200) {
  803. this.$message.success("激活成功");
  804. } else {
  805. this.$message.error("激活失败");
  806. }
  807. this.tenantExpirationTimeOpen = false;
  808. this.tenantExpirationTimeFrom = {
  809. tenantId: null,
  810. tenantExpirationTime: null,
  811. };
  812. }
  813. });
  814. },
  815. // 激活租户对话框取消按钮
  816. tanentCancel() {
  817. this.tenantExpirationTimeOpen = false;
  818. this.tenantExpirationTimeFrom = {
  819. tenantId: null,
  820. tenantExpirationTime: null,
  821. };
  822. },
  823. },
  824. };
  825. </script>