|
|
@@ -10,10 +10,11 @@
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="所属公司" prop="companyId">
|
|
|
+ <el-form-item label="所属公司" prop="companyIds">
|
|
|
<el-select
|
|
|
- v-model="queryParams.companyId"
|
|
|
+ v-model="queryParams.companyIds"
|
|
|
filterable
|
|
|
+ multiple
|
|
|
remote
|
|
|
reserve-keyword
|
|
|
placeholder="请输入公司名称搜索"
|
|
|
@@ -132,7 +133,7 @@
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="ID" align="center" prop="id" />
|
|
|
<el-table-column label="名称" align="center" prop="name" />
|
|
|
- <el-table-column label="所属公司" align="center" prop="companyId" :formatter="companyNameFormatter"/>
|
|
|
+ <el-table-column label="所属公司" align="center" prop="companyIds" :formatter="companyNameFormatter"/>
|
|
|
<el-table-column label="图标" align="center" prop="img">
|
|
|
<template slot-scope="scope">
|
|
|
<el-image
|
|
|
@@ -233,10 +234,11 @@
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="所属公司" prop="companyId">
|
|
|
+ <el-form-item label="所属公司" prop="companyIds">
|
|
|
<el-select
|
|
|
- v-model="form.companyId"
|
|
|
+ v-model="form.companyIds"
|
|
|
filterable
|
|
|
+ multiple
|
|
|
remote
|
|
|
reserve-keyword
|
|
|
placeholder="请输入公司名称搜索"
|
|
|
@@ -507,6 +509,7 @@ export default {
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
name: null,
|
|
|
+ companyIds: [],
|
|
|
appid: null,
|
|
|
status: null
|
|
|
},
|
|
|
@@ -566,6 +569,7 @@ export default {
|
|
|
title: null,
|
|
|
open: false,
|
|
|
form: {
|
|
|
+ companyIds: [],
|
|
|
setCompanyIdList: []
|
|
|
},
|
|
|
bindRules:{
|
|
|
@@ -853,8 +857,35 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
companyNameFormatter(row){
|
|
|
- let company = this.formatterCompanyOptions.filter(item => item.dictValue === row.companyId)[0];
|
|
|
- return company ? company.dictLabel : '';
|
|
|
+ const rawCompanyIds = row.companyIds !== undefined && row.companyIds !== null
|
|
|
+ ? row.companyIds
|
|
|
+ : (row.company_ids !== undefined && row.company_ids !== null ? row.company_ids : row.companyId);
|
|
|
+ let companyIds = [];
|
|
|
+ if (Array.isArray(rawCompanyIds)) {
|
|
|
+ companyIds = rawCompanyIds;
|
|
|
+ } else if (typeof rawCompanyIds === 'string') {
|
|
|
+ // 兼容 "300,305" / "[300, 305]" / "300"
|
|
|
+ companyIds = (rawCompanyIds.match(/\d+/g) || []);
|
|
|
+ } else if (rawCompanyIds !== undefined && rawCompanyIds !== null && rawCompanyIds !== '') {
|
|
|
+ companyIds = [rawCompanyIds];
|
|
|
+ }
|
|
|
+ const normalizedIds = companyIds
|
|
|
+ .map(item => Number(item))
|
|
|
+ .filter(item => Number.isFinite(item));
|
|
|
+ if (!normalizedIds.length) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ const companyNameMap = this.formatterCompanyOptions.reduce((map, item) => {
|
|
|
+ const key = Number(item.dictValue);
|
|
|
+ if (Number.isFinite(key)) {
|
|
|
+ map[key] = item.dictLabel;
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }, {});
|
|
|
+ return normalizedIds
|
|
|
+ .map(id => companyNameMap[id])
|
|
|
+ .filter(Boolean)
|
|
|
+ .join('、');
|
|
|
},
|
|
|
|
|
|
// 获取开关配置
|
|
|
@@ -894,7 +925,16 @@ export default {
|
|
|
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
- list(this.queryParams).then(response => {
|
|
|
+ const normalizedCompanyIds = Array.isArray(this.queryParams.companyIds)
|
|
|
+ ? this.queryParams.companyIds
|
|
|
+ .map(item => Number(item))
|
|
|
+ .filter(item => Number.isFinite(item))
|
|
|
+ : [];
|
|
|
+ const params = {
|
|
|
+ ...this.queryParams,
|
|
|
+ companyIds: normalizedCompanyIds
|
|
|
+ };
|
|
|
+ list(params).then(response => {
|
|
|
this.list = response.rows;
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
@@ -906,6 +946,7 @@ export default {
|
|
|
},
|
|
|
resetQuery() {
|
|
|
this.resetForm("queryForm");
|
|
|
+ this.queryParams.companyIds = [];
|
|
|
this.getList();
|
|
|
},
|
|
|
handleAdd() {
|
|
|
@@ -918,9 +959,22 @@ export default {
|
|
|
this.reset()
|
|
|
const id = row.id || this.ids
|
|
|
get(id).then(response => {
|
|
|
+ const rawCompanyIds = Array.isArray(response.data.companyIds)
|
|
|
+ ? response.data.companyIds
|
|
|
+ : (response.data.companyIds ? String(response.data.companyIds).split(',') : []);
|
|
|
+ const normalizedCompanyIds = rawCompanyIds
|
|
|
+ .map(item => Number(item))
|
|
|
+ .filter(item => Number.isFinite(item));
|
|
|
+ if (!normalizedCompanyIds.length && response.data.companyId !== null && response.data.companyId !== undefined && response.data.companyId !== '') {
|
|
|
+ const companyIdNum = Number(response.data.companyId);
|
|
|
+ if (Number.isFinite(companyIdNum)) {
|
|
|
+ normalizedCompanyIds.push(companyIdNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
this.form = {
|
|
|
...response.data,
|
|
|
- type: response.data.type.toString()
|
|
|
+ type: response.data.type.toString(),
|
|
|
+ companyIds: normalizedCompanyIds
|
|
|
}
|
|
|
if(!!this.form.setCompanyIds){
|
|
|
this.$set(
|
|
|
@@ -957,16 +1011,16 @@ export default {
|
|
|
submitForm() {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
+ const normalizedCompanyIds = Array.isArray(this.form.companyIds)
|
|
|
+ ? this.form.companyIds.map(item => Number(item)).filter(item => Number.isFinite(item))
|
|
|
+ : [];
|
|
|
if(!!this.form.setCompanyIdList && this.form.setCompanyIdList.length > 0){
|
|
|
this.form.setCompanyIds = this.form.setCompanyIdList.join(',')
|
|
|
}else{
|
|
|
this.form.setCompanyIds = "";
|
|
|
}
|
|
|
-
|
|
|
- // 处理companyId,将null转换为空字符串
|
|
|
- if (this.form.companyId === null || this.form.companyId === undefined) {
|
|
|
- this.form.companyId = '';
|
|
|
- }
|
|
|
+ this.form.companyIds = normalizedCompanyIds;
|
|
|
+ this.form.companyId = '';
|
|
|
|
|
|
if (this.form.customAuthEnabled === 0) {
|
|
|
this.form.miniAppAuthType = '';
|
|
|
@@ -1008,6 +1062,7 @@ export default {
|
|
|
this.form = {
|
|
|
id: null,
|
|
|
name: null,
|
|
|
+ companyIds: [],
|
|
|
appid: null,
|
|
|
secret: null,
|
|
|
img: null,
|