123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- <template>
- <basic-container>
- <avue-crud :option="option"
- :table-loading="loading"
- :data="data"
- ref="crud"
- v-model="form"
- :page.sync="page"
- :permission="permissionList"
- :before-open="beforeOpen"
- @row-del="rowDel"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad">
- <template slot="menuLeft">
- <el-button type="danger"
- size="small"
- icon="el-icon-delete"
- v-if="permission.tenant_delete"
- plain
- @click="handleDelete">删 除
- </el-button>
- <el-button size="small"
- plain
- v-if="userInfo.role_name.includes('administrator')"
- icon="el-icon-setting"
- @click="handleSetting">授权配置
- </el-button>
- <el-button size="small"
- plain
- v-if="userInfo.role_name.includes('administrator')"
- icon="el-icon-coin"
- @click="handleDatasource">数据源配置
- </el-button>
- <el-button type="primary"
- size="small"
- icon="el-icon-delete"
- plain
- @click="CopyPopupfun">复 制
- </el-button>
- </template>
- <template slot-scope="{row}"
- slot="accountNumber">
- <el-tag>{{ row.accountNumber > 0 ? row.accountNumber : '不限制' }}</el-tag>
- </template>
- <template slot-scope="{row}"
- slot="expireTime">
- <el-tag>{{ row.expireTime ? row.expireTime : '不限制' }}</el-tag>
- </template>
- </avue-crud>
- <el-dialog title="租户授权配置"
- append-to-body
- :visible.sync="box"
- width="450px">
- <avue-form :option="settingOption" v-model="settingForm" @submit="handleSubmit"/>
- </el-dialog>
- <el-dialog title="租户数据源配置"
- append-to-body
- :visible.sync="datasourceBox"
- width="450px">
- <avue-form :option="datasourceOption" v-model="datasourceForm" @submit="handleDatasourceSubmit"/>
- </el-dialog>
- <el-dialog title="租户复制"
- append-to-body
- :visible.sync="CopyVisible"
- width="450px">
- <avue-form ref="CopyRef" :option="CopyOption" v-model="CopyForm" @submit="copyTenantfun"/>
- </el-dialog>
- </basic-container>
- </template>
- <script>
- import {getList, getDetail, remove, update, add, setting, datasource, tenantCopyData} from "@/api/system/tenant";
- import {mapGetters} from "vuex";
- import error from "@/views/monitor/log/error.vue";
- export default {
- data() {
- return {
- form: {},
- selectionList: [],
- query: {},
- loading: true,
- box: false,
- datasourceBox: false,
- CopyVisible:false, // 复制租户弹窗
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- option: {
- align: 'center',
- height: 'auto',
- calcHeight: 30,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- selection: true,
- viewBtn: true,
- dialogWidth: 900,
- dialogClickModal: false,
- column: [
- {
- label: "租户ID",
- prop: "tenantId",
- width: 100,
- search: true,
- addDisplay: false,
- editDisplay: false,
- span: 24,
- rules: [{
- required: true,
- message: "请输入租户ID",
- trigger: "blur"
- }]
- },
- {
- label: "租户名称",
- prop: "tenantName",
- search: true,
- width: 180,
- span: 24,
- rules: [{
- required: true,
- message: "请输入参数名称",
- trigger: "blur"
- }]
- },
- {
- label: "联系人",
- prop: "linkman",
- width: 100,
- search: true,
- rules: [{
- required: true,
- message: "请输入联系人",
- trigger: "blur"
- }]
- },
- {
- label: "联系电话",
- prop: "contactNumber",
- width: 150,
- },
- {
- label: "联系地址",
- prop: "address",
- span: 24,
- minRows: 2,
- type: "textarea",
- hide: true,
- },
- {
- label: "账号额度",
- prop: "accountNumber",
- width: 90,
- slot: true,
- addDisplay: false,
- editDisplay: false,
- },
- {
- label: "过期时间",
- prop: "expireTime",
- width: 180,
- slot: true,
- addDisplay: false,
- editDisplay: false,
- },
- {
- label: "绑定域名",
- prop: "domain",
- width: 160,
- span: 24,
- overHidden: true,
- },{
- label: "公司类型",
- type: "select",
- dicUrl: "/api/blade-system/dict/dictionary?code=company_type",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
- dataType: "number",
- width: 80,
- prop: "billType",
- slot: true,
- overHidden: true,
- rules: [{
- required: true,
- message: "请输入机构类型",
- trigger: "blur"
- }]
- },
- {
- label: "平台客户编码",
- prop: "corpCode",
- width: 120,
- span: 12,
- overHidden: true,
- },
- {
- label: "对应平台(租户id)",
- prop: "terrace",
- labelWidth: 140,
- width: 140,
- span: 12,
- overHidden: true,
- },
- {
- label: "微信AppId",
- prop: "appId",
- width: 100,
- span: 12,
- overHidden: true
- },
- {
- label: "系统背景",
- prop: "backgroundUrl",
- type: 'upload',
- listType: 'picture-img',
- dataType: 'string',
- action: '/api/blade-resource/oss/endpoint/put-file',
- propsHttp: {
- res: 'data',
- url: 'link',
- },
- hide: true,
- span: 24,
- },
- ]
- },
- data: [],
- settingForm: {},
- settingOption: {
- column: [
- {
- label: "账号额度",
- prop: "accountNumber",
- type: "number",
- span: 24,
- },
- {
- label: "过期时间",
- prop: "expireTime",
- type: "date",
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- span: 24,
- },
- ]
- },
- CopyOption: {
- column: [
- {
- label: "租户",
- prop: "tenantIdCopy",
- dicData:[],
- type: "select",
- filterable:true,
- remote:true,
- dicUrl: "/api/blade-system/tenant/list?tenantId={{key}}",
- props: {
- label: "tenantId",
- value: "tenantId",
- res:'data.records'
- },
- span: 24,
- rules: [{
- required: true,
- message: "请选择租户",
- trigger: "blur"
- }]
- },
- {
- label: "类型",
- prop: "type",
- multiple:true,
- type: 'select',
- dicData:[
- {
- label:'业务字典',
- value:'1',
- },
- {
- label:'角色',
- value:'2',
- },
- {
- label:'审批流程',
- value:'3',
- },
- {
- label:'编号配置',
- value:'4',
- },
- {
- label:'业务类型',
- value:'5',
- }
- ],
- span: 24,
- rules: [{
- required: true,
- message: "请选择类型",
- trigger: "blur"
- }]
- },
- ]
- }, // 复制弹窗配置项
- CopyForm:{}, // 复制弹窗表单数据
- datasourceForm: {},
- datasourceOption: {
- column: [
- {
- label: "数据源",
- prop: "datasourceId",
- search: true,
- span: 24,
- type: "select",
- dicUrl: "/api/blade-develop/datasource/select",
- props: {
- label: "name",
- value: "id"
- },
- rules: [{
- required: true,
- message: "请选择数据源",
- trigger: "blur"
- }]
- },
- ]
- }
- };
- },
- computed: {
- ...mapGetters(["userInfo", "permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.tenant_add, false),
- viewBtn: this.vaildData(this.permission.tenant_view, false),
- delBtn: this.vaildData(this.permission.tenant_delete, false),
- editBtn: this.vaildData(this.permission.tenant_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- },
- tenantId() {
- return this.selectionList[0].tenantId;
- }
- },
- methods: {
- // 复制租户
- copyTenantfun(form, done, loading){
- tenantCopyData({
- tenantId:this.selectionList[0].tenantId,
- tenantIdCopy:this.CopyForm.tenantIdCopy,
- type:this.CopyForm.type.join(',')
- }).then(res=>{
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- this.CopyVisible = false
- },error => {
- window.console.log(error);
- loading();
- })
- },
- rowSave(row, done, loading) {
- add(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- rowUpdate(row, index, done, loading) {
- update(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- });
- },
- beforeOpen(done, type) {
- if (["view"].includes(type)) {
- getDetail(this.form.id).then(res => {
- const data = res.data.data;
- if (!(data.accountNumber > 0)) {
- data.accountNumber = "不限制";
- }
- if (!data.expireTime) {
- data.expireTime = "不限制";
- }
- this.form = data;
- });
- }
- done();
- },
- searchReset() {
- this.query = {};
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$refs.crud.toggleSelection();
- });
- },
- // 复制弹窗开启
- CopyPopupfun(){
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.CopyForm.tenantIdCopy = ''
- this.CopyForm.type = null
- this.CopyVisible = true
- },
- handleSetting() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- if (this.selectionList.length === 1) {
- getDetail(this.selectionList[0].id).then(res => {
- const data = res.data.data;
- this.settingForm.accountNumber = data.accountNumber;
- this.settingForm.expireTime = data.expireTime;
- });
- } else {
- this.settingForm.accountNumber = -1;
- this.settingForm.expireTime = '';
- }
- this.box = true;
- },
- handleDatasource() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- if (this.selectionList.length !== 1) {
- this.$message.warning("只能选择一条数据");
- return;
- }
- getDetail(this.selectionList[0].id).then(res => {
- const data = res.data.data;
- this.datasourceForm.datasourceId = data.datasourceId;
- });
- this.datasourceBox = true;
- },
- handleSubmit(form, done, loading) {
- setting(this.ids, form).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "配置成功!"
- });
- done();
- this.box = false;
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- handleDatasourceSubmit(form, done, loading) {
- datasource(this.tenantId, form.datasourceId).then(() => {
- this.$message({
- type: "success",
- message: "配置成功!"
- });
- done();
- this.datasourceBox = false;
- }, error => {
- window.console.log(error);
- loading();
- });
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- }
- }
- };
- </script>
- <style>
- </style>
|