tenant.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. ref="crud"
  7. v-model="form"
  8. :page.sync="page"
  9. :permission="permissionList"
  10. :before-open="beforeOpen"
  11. @row-del="rowDel"
  12. @row-update="rowUpdate"
  13. @row-save="rowSave"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. v-if="permission.tenant_delete"
  26. plain
  27. @click="handleDelete">删 除
  28. </el-button>
  29. <el-button size="small"
  30. plain
  31. v-if="userInfo.role_name.includes('administrator')"
  32. icon="el-icon-setting"
  33. @click="handleSetting">授权配置
  34. </el-button>
  35. <el-button size="small"
  36. plain
  37. v-if="userInfo.role_name.includes('administrator')"
  38. icon="el-icon-coin"
  39. @click="handleDatasource">数据源配置
  40. </el-button>
  41. <el-button type="primary"
  42. size="small"
  43. icon="el-icon-delete"
  44. plain
  45. @click="CopyPopupfun">复 制
  46. </el-button>
  47. </template>
  48. <template slot-scope="{row}"
  49. slot="accountNumber">
  50. <el-tag>{{ row.accountNumber > 0 ? row.accountNumber : '不限制' }}</el-tag>
  51. </template>
  52. <template slot-scope="{row}"
  53. slot="expireTime">
  54. <el-tag>{{ row.expireTime ? row.expireTime : '不限制' }}</el-tag>
  55. </template>
  56. </avue-crud>
  57. <el-dialog title="企业授权配置"
  58. append-to-body
  59. :visible.sync="box"
  60. width="450px">
  61. <avue-form :option="settingOption" v-model="settingForm" @submit="handleSubmit"/>
  62. </el-dialog>
  63. <el-dialog title="企业数据源配置"
  64. append-to-body
  65. :visible.sync="datasourceBox"
  66. width="450px">
  67. <avue-form :option="datasourceOption" v-model="datasourceForm" @submit="handleDatasourceSubmit"/>
  68. </el-dialog>
  69. <el-dialog title="企业复制"
  70. append-to-body
  71. :visible.sync="CopyVisible"
  72. width="450px">
  73. <avue-form ref="CopyRef" :option="CopyOption" v-model="CopyForm" @submit="copyTenantfun"/>
  74. </el-dialog>
  75. </basic-container>
  76. </template>
  77. <script>
  78. import {getList, getDetail, remove, update, add, setting, datasource, tenantCopyData} from "@/api/system/tenant";
  79. import {mapGetters} from "vuex";
  80. import error from "@/views/monitor/log/error.vue";
  81. export default {
  82. data() {
  83. return {
  84. form: {},
  85. selectionList: [],
  86. query: {},
  87. loading: true,
  88. box: false,
  89. datasourceBox: false,
  90. CopyVisible:false, // 复制企业弹窗
  91. page: {
  92. pageSize: 10,
  93. currentPage: 1,
  94. total: 0
  95. },
  96. option: {
  97. align: 'center',
  98. height: 'auto',
  99. calcHeight: 30,
  100. tip: false,
  101. searchShow: true,
  102. searchMenuSpan: 6,
  103. border: true,
  104. index: true,
  105. selection: true,
  106. viewBtn: true,
  107. dialogWidth: 900,
  108. dialogClickModal: false,
  109. column: [
  110. {
  111. label: "企业ID",
  112. prop: "tenantId",
  113. width: 100,
  114. search: true,
  115. addDisplay: false,
  116. editDisplay: false,
  117. span: 24,
  118. rules: [{
  119. required: true,
  120. message: "请输入企业ID",
  121. trigger: "blur"
  122. }]
  123. },
  124. {
  125. label: "企业名称",
  126. prop: "tenantName",
  127. search: true,
  128. width: 180,
  129. span: 24,
  130. rules: [{
  131. required: true,
  132. message: "请输入参数名称",
  133. trigger: "blur"
  134. }]
  135. },
  136. {
  137. label: "联系人",
  138. prop: "linkman",
  139. width: 100,
  140. search: true,
  141. rules: [{
  142. required: true,
  143. message: "请输入联系人",
  144. trigger: "blur"
  145. }]
  146. },
  147. {
  148. label: "联系电话",
  149. prop: "contactNumber",
  150. width: 150,
  151. },
  152. {
  153. label: "联系地址",
  154. prop: "address",
  155. span: 24,
  156. minRows: 2,
  157. type: "textarea",
  158. hide: true,
  159. },
  160. {
  161. label: "账号额度",
  162. prop: "accountNumber",
  163. width: 90,
  164. slot: true,
  165. addDisplay: false,
  166. editDisplay: false,
  167. },
  168. {
  169. label: "过期时间",
  170. prop: "expireTime",
  171. width: 180,
  172. slot: true,
  173. addDisplay: false,
  174. editDisplay: false,
  175. },
  176. {
  177. label: "绑定域名",
  178. prop: "domain",
  179. width: 160,
  180. span: 24,
  181. overHidden: true,
  182. },{
  183. label: "公司类型",
  184. type: "select",
  185. dicUrl: "/api/blade-system/dict/dictionary?code=company_type",
  186. props: {
  187. label: "dictValue",
  188. value: "dictKey"
  189. },
  190. dataType: "number",
  191. width: 80,
  192. prop: "billType",
  193. slot: true,
  194. overHidden: true,
  195. rules: [{
  196. required: true,
  197. message: "请输入机构类型",
  198. trigger: "blur"
  199. }]
  200. },
  201. {
  202. label: "平台客户编码",
  203. prop: "corpCode",
  204. width: 120,
  205. span: 12,
  206. overHidden: true,
  207. },
  208. {
  209. label: "对应平台(企业id)",
  210. prop: "terrace",
  211. labelWidth: 140,
  212. width: 140,
  213. span: 12,
  214. overHidden: true,
  215. },
  216. {
  217. label: "微信AppId",
  218. prop: "appId",
  219. width: 100,
  220. span: 12,
  221. overHidden: true
  222. },
  223. {
  224. label: "系统背景",
  225. prop: "backgroundUrl",
  226. type: 'upload',
  227. listType: 'picture-img',
  228. dataType: 'string',
  229. action: '/api/blade-resource/oss/endpoint/put-file',
  230. propsHttp: {
  231. res: 'data',
  232. url: 'link',
  233. },
  234. hide: true,
  235. span: 24,
  236. },
  237. ]
  238. },
  239. data: [],
  240. settingForm: {},
  241. settingOption: {
  242. column: [
  243. {
  244. label: "账号额度",
  245. prop: "accountNumber",
  246. type: "number",
  247. span: 24,
  248. },
  249. {
  250. label: "过期时间",
  251. prop: "expireTime",
  252. type: "date",
  253. format: "yyyy-MM-dd hh:mm:ss",
  254. valueFormat: "yyyy-MM-dd hh:mm:ss",
  255. span: 24,
  256. },
  257. ]
  258. },
  259. CopyOption: {
  260. column: [
  261. {
  262. label: "企业",
  263. prop: "tenantIdCopy",
  264. dicData:[],
  265. type: "select",
  266. filterable:true,
  267. remote:true,
  268. dicUrl: "/api/blade-system/tenant/list?tenantId={{key}}",
  269. props: {
  270. label: "tenantId",
  271. value: "tenantId",
  272. res:'data.records'
  273. },
  274. span: 24,
  275. rules: [{
  276. required: true,
  277. message: "请选择企业",
  278. trigger: "blur"
  279. }]
  280. },
  281. {
  282. label: "类型",
  283. prop: "type",
  284. multiple:true,
  285. type: 'select',
  286. dicData:[
  287. {
  288. label:'业务字典',
  289. value:'1',
  290. },
  291. {
  292. label:'角色',
  293. value:'2',
  294. },
  295. {
  296. label:'审批流程-货代',
  297. value:'3',
  298. },
  299. {
  300. label:'业务审批配置-货代',
  301. value:'8',
  302. },
  303. {
  304. label:'编号配置',
  305. value:'4',
  306. },
  307. {
  308. label:'业务类型',
  309. value:'5',
  310. },{
  311. label:'报表',
  312. value:'6',
  313. },{
  314. label:'汇率',
  315. value:'7',
  316. },{
  317. label:'业务参数',
  318. value:'9',
  319. }
  320. ],
  321. span: 24,
  322. rules: [{
  323. required: true,
  324. message: "请选择类型",
  325. trigger: "blur"
  326. }]
  327. },
  328. ]
  329. }, // 复制弹窗配置项
  330. CopyForm:{}, // 复制弹窗表单数据
  331. datasourceForm: {},
  332. datasourceOption: {
  333. column: [
  334. {
  335. label: "数据源",
  336. prop: "datasourceId",
  337. search: true,
  338. span: 24,
  339. type: "select",
  340. dicUrl: "/api/blade-develop/datasource/select",
  341. props: {
  342. label: "name",
  343. value: "id"
  344. },
  345. rules: [{
  346. required: true,
  347. message: "请选择数据源",
  348. trigger: "blur"
  349. }]
  350. },
  351. ]
  352. }
  353. };
  354. },
  355. computed: {
  356. ...mapGetters(["userInfo", "permission"]),
  357. permissionList() {
  358. return {
  359. addBtn: this.vaildData(this.permission.tenant_add, false),
  360. viewBtn: this.vaildData(this.permission.tenant_view, false),
  361. delBtn: this.vaildData(this.permission.tenant_delete, false),
  362. editBtn: this.vaildData(this.permission.tenant_edit, false)
  363. };
  364. },
  365. ids() {
  366. let ids = [];
  367. this.selectionList.forEach(ele => {
  368. ids.push(ele.id);
  369. });
  370. return ids.join(",");
  371. },
  372. tenantId() {
  373. return this.selectionList[0].tenantId;
  374. }
  375. },
  376. methods: {
  377. // 复制企业
  378. copyTenantfun(form, done, loading){
  379. tenantCopyData({
  380. tenantId:this.selectionList[0].tenantId,
  381. tenantIdCopy:this.CopyForm.tenantIdCopy,
  382. type:this.CopyForm.type.join(',')
  383. }).then(res=>{
  384. this.$message({
  385. type: "success",
  386. message: "操作成功!"
  387. });
  388. done();
  389. this.CopyVisible = false
  390. },error => {
  391. window.console.log(error);
  392. loading();
  393. })
  394. },
  395. rowSave(row, done, loading) {
  396. add(row).then(() => {
  397. this.onLoad(this.page);
  398. this.$message({
  399. type: "success",
  400. message: "操作成功!"
  401. });
  402. done();
  403. }, error => {
  404. window.console.log(error);
  405. loading();
  406. });
  407. },
  408. rowUpdate(row, index, done, loading) {
  409. update(row).then(() => {
  410. this.onLoad(this.page);
  411. this.$message({
  412. type: "success",
  413. message: "操作成功!"
  414. });
  415. done();
  416. }, error => {
  417. window.console.log(error);
  418. loading();
  419. });
  420. },
  421. rowDel(row) {
  422. this.$confirm("确定将选择数据删除?", {
  423. confirmButtonText: "确定",
  424. cancelButtonText: "取消",
  425. type: "warning"
  426. })
  427. .then(() => {
  428. return remove(row.id);
  429. })
  430. .then(() => {
  431. this.onLoad(this.page);
  432. this.$message({
  433. type: "success",
  434. message: "操作成功!"
  435. });
  436. });
  437. },
  438. beforeOpen(done, type) {
  439. if (["view"].includes(type)) {
  440. getDetail(this.form.id).then(res => {
  441. const data = res.data.data;
  442. if (!(data.accountNumber > 0)) {
  443. data.accountNumber = "不限制";
  444. }
  445. if (!data.expireTime) {
  446. data.expireTime = "不限制";
  447. }
  448. this.form = data;
  449. });
  450. }
  451. done();
  452. },
  453. searchReset() {
  454. this.query = {};
  455. this.onLoad(this.page);
  456. },
  457. searchChange(params, done) {
  458. this.query = params;
  459. this.page.currentPage = 1;
  460. this.onLoad(this.page, params);
  461. done();
  462. },
  463. selectionChange(list) {
  464. this.selectionList = list;
  465. },
  466. selectionClear() {
  467. this.selectionList = [];
  468. this.$refs.crud.toggleSelection();
  469. },
  470. handleDelete() {
  471. if (this.selectionList.length === 0) {
  472. this.$message.warning("请选择至少一条数据");
  473. return;
  474. }
  475. this.$confirm("确定将选择数据删除?", {
  476. confirmButtonText: "确定",
  477. cancelButtonText: "取消",
  478. type: "warning"
  479. })
  480. .then(() => {
  481. return remove(this.ids);
  482. })
  483. .then(() => {
  484. this.onLoad(this.page);
  485. this.$message({
  486. type: "success",
  487. message: "操作成功!"
  488. });
  489. this.$refs.crud.toggleSelection();
  490. });
  491. },
  492. // 复制弹窗开启
  493. CopyPopupfun(){
  494. if (this.selectionList.length === 0) {
  495. this.$message.warning("请选择至少一条数据");
  496. return;
  497. }
  498. this.CopyForm.tenantIdCopy = ''
  499. this.CopyForm.type = null
  500. this.CopyVisible = true
  501. },
  502. handleSetting() {
  503. if (this.selectionList.length === 0) {
  504. this.$message.warning("请选择至少一条数据");
  505. return;
  506. }
  507. if (this.selectionList.length === 1) {
  508. getDetail(this.selectionList[0].id).then(res => {
  509. const data = res.data.data;
  510. this.settingForm.accountNumber = data.accountNumber;
  511. this.settingForm.expireTime = data.expireTime;
  512. });
  513. } else {
  514. this.settingForm.accountNumber = -1;
  515. this.settingForm.expireTime = '';
  516. }
  517. this.box = true;
  518. },
  519. handleDatasource() {
  520. if (this.selectionList.length === 0) {
  521. this.$message.warning("请选择至少一条数据");
  522. return;
  523. }
  524. if (this.selectionList.length !== 1) {
  525. this.$message.warning("只能选择一条数据");
  526. return;
  527. }
  528. getDetail(this.selectionList[0].id).then(res => {
  529. const data = res.data.data;
  530. this.datasourceForm.datasourceId = data.datasourceId;
  531. });
  532. this.datasourceBox = true;
  533. },
  534. handleSubmit(form, done, loading) {
  535. setting(this.ids, form).then(() => {
  536. this.onLoad(this.page);
  537. this.$message({
  538. type: "success",
  539. message: "配置成功!"
  540. });
  541. done();
  542. this.box = false;
  543. }, error => {
  544. window.console.log(error);
  545. loading();
  546. });
  547. },
  548. handleDatasourceSubmit(form, done, loading) {
  549. datasource(this.tenantId, form.datasourceId).then(() => {
  550. this.$message({
  551. type: "success",
  552. message: "配置成功!"
  553. });
  554. done();
  555. this.datasourceBox = false;
  556. }, error => {
  557. window.console.log(error);
  558. loading();
  559. });
  560. },
  561. currentChange(currentPage) {
  562. this.page.currentPage = currentPage;
  563. },
  564. sizeChange(pageSize) {
  565. this.page.pageSize = pageSize;
  566. },
  567. refreshChange() {
  568. this.onLoad(this.page, this.query);
  569. },
  570. onLoad(page, params = {}) {
  571. this.loading = true;
  572. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  573. const data = res.data.data;
  574. this.page.total = data.total;
  575. this.data = data.records;
  576. this.loading = false;
  577. this.selectionClear();
  578. });
  579. }
  580. }
  581. };
  582. </script>
  583. <style>
  584. </style>