Przeglądaj źródła

企微主体信息设置租户

ct 3 tygodni temu
rodzic
commit
5573eb6620

+ 9 - 1
src/api/qw/qwCompany.js

@@ -55,4 +55,12 @@ export function exportQwCompany(query) {
     method: 'get',
     params: query
   })
-}
+}
+
+export function setTenant(data) {
+  return request({
+    url: '/qw/qwCompany/setTenant',
+    method: 'post',
+    data: data
+  })
+}

+ 10 - 1
src/api/tenant/tenant.js

@@ -9,6 +9,15 @@ export function listTenant(query) {
   })
 }
 
+// 查询所有租户id以及租户名称 租户编码
+export function tenantList(query) {
+  return request({
+    url: '/tenant/tenant/tenantList',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询租户基础信息详细
 export function getTenant(id) {
   return request({
@@ -50,4 +59,4 @@ export function exportTenant(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 83 - 2
src/views/qw/qwCompany/index.vue

@@ -91,7 +91,7 @@
       <el-table-column label="企业名称" align="center" prop="corpName" />
       <el-table-column label="关联公司" align="center" prop="companyIds" >
         <template slot-scope="scope">
-          <div v-for="company in (scope.row.companyIds).split(',') ">
+          <div v-for="company in (scope.row.companyIds ? scope.row.companyIds.split(',') : [])">
             <span v-for="com in companys" v-if="com.companyId==company">{{com.companyName }} </span>
           </div>
         </template>
@@ -104,6 +104,13 @@
       <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
       <el-table-column label="更改时间" align="center" prop="updateTime" width="180"/>
       <el-table-column label="创建人" align="center" prop="createBy" />
+      <el-table-column label="租户" align="center" prop="tenantId" v-if="tenantCode == null">
+        <template slot-scope="scope">
+          <div>
+            <span v-for="item in tenantInfos" v-if="scope.row.tenantId==item.id">{{item.tenantName }} </span>
+          </div>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -120,6 +127,14 @@
             @click="handleDelete(scope.row)"
             v-hasPermi="['qw:qwCompany:remove']"
           >删除</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleTenant(scope.row)"
+            v-hasPermi="['qw:qwCompany:tenant']"
+            v-if="tenantCode==null"
+          >设置租户</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -237,13 +252,34 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog :title="tenantDialog.title" :visible.sync="tenantDialog.open" width="500px" append-to-body>
+      <el-form ref="tenantForm" :model="tenantForm" label-width="200px">
+        <el-form-item label="租户">
+          <el-select filterable v-model="tenantForm.tenantId"  placeholder="请选择租户"  clearable>
+            <el-option
+              v-for="item in tenantInfos"
+              :key="item.id"
+              :label="item.tenantName"
+              :value="item.id"
+            />
+          </el-select>
+        </el-form-item>
+
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitTenantForm">确 定</el-button>
+        <el-button @click="cancelTenant">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listQwCompany, getQwCompany, delQwCompany, addQwCompany, updateQwCompany, exportQwCompany } from "@/api/qw/qwCompany";
+import { listQwCompany, getQwCompany, delQwCompany, addQwCompany, updateQwCompany, exportQwCompany ,setTenant} from "@/api/qw/qwCompany";
 import { getCompanyList } from "@/api/company/company";
 import { listAll } from '@/api/course/coursePlaySourceConfig'
+import { tenantList } from "@/api/tenant/tenant";
 export default {
   name: "QwCompany",
   watch: {
@@ -263,6 +299,14 @@ export default {
     },
   data() {
     return {
+      tenantForm:{
+        tenantId:null
+      },
+      tenantInfos:{},
+      tenantDialog:{
+        open: false,
+        title:"设置租户"
+      },
       // 遮罩层
       loading: true,
       // 导出遮罩层
@@ -330,17 +374,34 @@ export default {
         this.companys = response.data;
 
     });
+    tenantList({status:1}).then(response => {
+      this.tenantInfos =  response.rows;
+    });
+  },
+  computed: {
+    tenantCode() {
+      console.log("----------------",this.$store.state.user.tenantCode)
+      return this.$store.state.user.tenantCode
+    }
   },
   methods: {
     /** 查询企微主体列表 */
     getList() {
       this.loading = true;
       listQwCompany(this.queryParams).then(response => {
+        console.log(response);
         this.qwCompanyList = response.rows;
         this.total = response.total;
         this.loading = false;
       });
     },
+    cancelTenant(){
+      this.tenantDialog.open = false;
+      this.tenantForm = {
+          tenantId:null,
+          qwCompanyId:null
+      }
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -433,6 +494,22 @@ export default {
         this.title = "修改企微主体";
       });
     },
+    submitTenantForm(){
+      if(this.tenantForm.tenantId == null){
+        this.msgError("租户不能为空");
+        return;
+      }
+      if(this.tenantForm.qwCompanyId == null){
+        this.msgError("企微主体不能为空");
+        return;
+      }
+      console.log("----------------",this.tenantForm);
+      setTenant(this.tenantForm).then(response => {
+        this.msgSuccess("设置成功");
+        this.tenantDialog.open = false;
+        this.getList();
+      });
+    },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
@@ -455,6 +532,10 @@ export default {
         }
       });
     },
+    handleTenant(row){
+      this.tenantForm.qwCompanyId = row.id
+      this.tenantDialog.open = true;
+    },
     /** 删除按钮操作 */
     handleDelete(row) {
       const ids = row.id || this.ids;