Răsfoiți Sursa

feat: 租户管理

yang-kai 2 ani în urmă
părinte
comite
215e4aaaef

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTenantController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.system;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.SysTenant;
+import com.ruoyi.system.service.ISysTenantService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 租户信息Controller
+ * 
+ * @author ruoyi
+ * @date 2023-06-03
+ */
+@RestController
+@RequestMapping("/system/tenant")
+public class SysTenantController extends BaseController
+{
+    @Autowired
+    private ISysTenantService sysTenantService;
+
+    /**
+     * 查询租户信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(SysTenant sysTenant)
+    {
+        startPage();
+        List<SysTenant> list = sysTenantService.selectSysTenantList(sysTenant);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出租户信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:export')")
+    @Log(title = "租户信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SysTenant sysTenant)
+    {
+        List<SysTenant> list = sysTenantService.selectSysTenantList(sysTenant);
+        ExcelUtil<SysTenant> util = new ExcelUtil<SysTenant>(SysTenant.class);
+        util.exportExcel(response, list, "租户信息数据");
+    }
+
+    /**
+     * 获取租户信息详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:query')")
+    @GetMapping(value = "/{tenantId}")
+    public AjaxResult getInfo(@PathVariable("tenantId") Long tenantId)
+    {
+        return success(sysTenantService.selectSysTenantByTenantId(tenantId));
+    }
+
+    /**
+     * 新增租户信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:add')")
+    @Log(title = "租户信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SysTenant sysTenant)
+    {
+        return toAjax(sysTenantService.insertSysTenant(sysTenant));
+    }
+
+    /**
+     * 修改租户信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:edit')")
+    @Log(title = "租户信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SysTenant sysTenant)
+    {
+        return toAjax(sysTenantService.updateSysTenant(sysTenant));
+    }
+
+    /**
+     * 删除租户信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:tenant:remove')")
+    @Log(title = "租户信息", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{tenantIds}")
+    public AjaxResult remove(@PathVariable Long[] tenantIds)
+    {
+        return toAjax(sysTenantService.deleteSysTenantByTenantIds(tenantIds));
+    }
+}

+ 123 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysTenant.java

@@ -0,0 +1,123 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 租户信息对象 sys_tenant
+ * 
+ * @author ruoyi
+ * @date 2023-06-03
+ */
+public class SysTenant extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 租户ID */
+    private Long tenantId;
+
+    /** 租户名称 */
+    @Excel(name = "租户名称")
+    private String tenantName;
+
+    /** 租户编号(公司统一信用代码) */
+    @Excel(name = "租户编号", readConverterExp = "公=司统一信用代码")
+    private String tenantCode;
+
+    /** 负责人 */
+    @Excel(name = "负责人")
+    private String owner;
+
+    /** 联系方式 */
+    @Excel(name = "联系方式")
+    private String contactInfo;
+
+    /** 地址 */
+    @Excel(name = "地址")
+    private String address;
+
+    /** 是否删除(0:未删除,1已删除) */
+    @Excel(name = "是否删除(0:未删除,1已删除)")
+    private String isDel;
+
+    public void setTenantId(Long tenantId) 
+    {
+        this.tenantId = tenantId;
+    }
+
+    public Long getTenantId() 
+    {
+        return tenantId;
+    }
+    public void setTenantName(String tenantName) 
+    {
+        this.tenantName = tenantName;
+    }
+
+    public String getTenantName() 
+    {
+        return tenantName;
+    }
+    public void setTenantCode(String tenantCode) 
+    {
+        this.tenantCode = tenantCode;
+    }
+
+    public String getTenantCode() 
+    {
+        return tenantCode;
+    }
+    public void setOwner(String owner) 
+    {
+        this.owner = owner;
+    }
+
+    public String getOwner() 
+    {
+        return owner;
+    }
+    public void setContactInfo(String contactInfo) 
+    {
+        this.contactInfo = contactInfo;
+    }
+
+    public String getContactInfo() 
+    {
+        return contactInfo;
+    }
+    public void setAddress(String address) 
+    {
+        this.address = address;
+    }
+
+    public String getAddress() 
+    {
+        return address;
+    }
+    public void setIsDel(String isDel) 
+    {
+        this.isDel = isDel;
+    }
+
+    public String getIsDel() 
+    {
+        return isDel;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("tenantId", getTenantId())
+            .append("tenantName", getTenantName())
+            .append("tenantCode", getTenantCode())
+            .append("owner", getOwner())
+            .append("contactInfo", getContactInfo())
+            .append("address", getAddress())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("isDel", getIsDel())
+            .toString();
+    }
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTenantMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.SysTenant;
+
+/**
+ * 租户信息Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2023-06-03
+ */
+public interface SysTenantMapper 
+{
+    /**
+     * 查询租户信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 租户信息
+     */
+    public SysTenant selectSysTenantByTenantId(Long tenantId);
+
+    /**
+     * 查询租户信息列表
+     * 
+     * @param sysTenant 租户信息
+     * @return 租户信息集合
+     */
+    public List<SysTenant> selectSysTenantList(SysTenant sysTenant);
+
+    /**
+     * 新增租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    public int insertSysTenant(SysTenant sysTenant);
+
+    /**
+     * 修改租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    public int updateSysTenant(SysTenant sysTenant);
+
+    /**
+     * 删除租户信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 结果
+     */
+    public int deleteSysTenantByTenantId(Long tenantId);
+
+    /**
+     * 批量删除租户信息
+     * 
+     * @param tenantIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSysTenantByTenantIds(Long[] tenantIds);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTenantService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+import com.ruoyi.system.domain.SysTenant;
+
+/**
+ * 租户信息Service接口
+ * 
+ * @author ruoyi
+ * @date 2023-06-03
+ */
+public interface ISysTenantService 
+{
+    /**
+     * 查询租户信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 租户信息
+     */
+    public SysTenant selectSysTenantByTenantId(Long tenantId);
+
+    /**
+     * 查询租户信息列表
+     * 
+     * @param sysTenant 租户信息
+     * @return 租户信息集合
+     */
+    public List<SysTenant> selectSysTenantList(SysTenant sysTenant);
+
+    /**
+     * 新增租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    public int insertSysTenant(SysTenant sysTenant);
+
+    /**
+     * 修改租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    public int updateSysTenant(SysTenant sysTenant);
+
+    /**
+     * 批量删除租户信息
+     * 
+     * @param tenantIds 需要删除的租户信息主键集合
+     * @return 结果
+     */
+    public int deleteSysTenantByTenantIds(Long[] tenantIds);
+
+    /**
+     * 删除租户信息信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 结果
+     */
+    public int deleteSysTenantByTenantId(Long tenantId);
+}

+ 95 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java

@@ -0,0 +1,95 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.SysTenantMapper;
+import com.ruoyi.system.domain.SysTenant;
+import com.ruoyi.system.service.ISysTenantService;
+
+/**
+ * 租户信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2023-06-03
+ */
+@Service
+public class SysTenantServiceImpl implements ISysTenantService 
+{
+    @Autowired
+    private SysTenantMapper sysTenantMapper;
+
+    /**
+     * 查询租户信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 租户信息
+     */
+    @Override
+    public SysTenant selectSysTenantByTenantId(Long tenantId)
+    {
+        return sysTenantMapper.selectSysTenantByTenantId(tenantId);
+    }
+
+    /**
+     * 查询租户信息列表
+     * 
+     * @param sysTenant 租户信息
+     * @return 租户信息
+     */
+    @Override
+    public List<SysTenant> selectSysTenantList(SysTenant sysTenant)
+    {
+        return sysTenantMapper.selectSysTenantList(sysTenant);
+    }
+
+    /**
+     * 新增租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    @Override
+    public int insertSysTenant(SysTenant sysTenant)
+    {
+        sysTenant.setCreateTime(DateUtils.getNowDate());
+        return sysTenantMapper.insertSysTenant(sysTenant);
+    }
+
+    /**
+     * 修改租户信息
+     * 
+     * @param sysTenant 租户信息
+     * @return 结果
+     */
+    @Override
+    public int updateSysTenant(SysTenant sysTenant)
+    {
+        return sysTenantMapper.updateSysTenant(sysTenant);
+    }
+
+    /**
+     * 批量删除租户信息
+     * 
+     * @param tenantIds 需要删除的租户信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysTenantByTenantIds(Long[] tenantIds)
+    {
+        return sysTenantMapper.deleteSysTenantByTenantIds(tenantIds);
+    }
+
+    /**
+     * 删除租户信息信息
+     * 
+     * @param tenantId 租户信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysTenantByTenantId(Long tenantId)
+    {
+        return sysTenantMapper.deleteSysTenantByTenantId(tenantId);
+    }
+}

+ 89 - 0
ruoyi-system/src/main/resources/mapper/system/SysTenantMapper.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.SysTenantMapper">
+    
+    <resultMap type="SysTenant" id="SysTenantResult">
+        <result property="tenantId"    column="tenant_id"    />
+        <result property="tenantName"    column="tenant_name"    />
+        <result property="tenantCode"    column="tenant_code"    />
+        <result property="owner"    column="owner"    />
+        <result property="contactInfo"    column="contact_info"    />
+        <result property="address"    column="address"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="isDel"    column="is_del"    />
+    </resultMap>
+
+    <sql id="selectSysTenantVo">
+        select tenant_id, tenant_name, tenant_code, owner, contact_info, address, create_by, create_time, is_del from sys_tenant
+    </sql>
+
+    <select id="selectSysTenantList" parameterType="SysTenant" resultMap="SysTenantResult">
+        <include refid="selectSysTenantVo"/>
+        <where>  
+            <if test="tenantName != null  and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
+            <if test="tenantCode != null  and tenantCode != ''"> and tenant_code = #{tenantCode}</if>
+            <if test="owner != null  and owner != ''"> and owner = #{owner}</if>
+            <if test="contactInfo != null  and contactInfo != ''"> and contact_info = #{contactInfo}</if>
+            <if test="address != null  and address != ''"> and address = #{address}</if>
+            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
+        </where>
+    </select>
+    
+    <select id="selectSysTenantByTenantId" parameterType="Long" resultMap="SysTenantResult">
+        <include refid="selectSysTenantVo"/>
+        where tenant_id = #{tenantId}
+    </select>
+        
+    <insert id="insertSysTenant" parameterType="SysTenant" useGeneratedKeys="true" keyProperty="tenantId">
+        insert into sys_tenant
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="tenantName != null and tenantName != ''">tenant_name,</if>
+            <if test="tenantCode != null and tenantCode != ''">tenant_code,</if>
+            <if test="owner != null">owner,</if>
+            <if test="contactInfo != null">contact_info,</if>
+            <if test="address != null">address,</if>
+            <if test="createBy != null and createBy != ''">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="isDel != null and isDel != ''">is_del,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="tenantName != null and tenantName != ''">#{tenantName},</if>
+            <if test="tenantCode != null and tenantCode != ''">#{tenantCode},</if>
+            <if test="owner != null">#{owner},</if>
+            <if test="contactInfo != null">#{contactInfo},</if>
+            <if test="address != null">#{address},</if>
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="isDel != null and isDel != ''">#{isDel},</if>
+         </trim>
+    </insert>
+
+    <update id="updateSysTenant" parameterType="SysTenant">
+        update sys_tenant
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
+            <if test="tenantCode != null and tenantCode != ''">tenant_code = #{tenantCode},</if>
+            <if test="owner != null">owner = #{owner},</if>
+            <if test="contactInfo != null">contact_info = #{contactInfo},</if>
+            <if test="address != null">address = #{address},</if>
+            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
+        </trim>
+        where tenant_id = #{tenantId}
+    </update>
+
+    <delete id="deleteSysTenantByTenantId" parameterType="Long">
+        delete from sys_tenant where tenant_id = #{tenantId}
+    </delete>
+
+    <delete id="deleteSysTenantByTenantIds" parameterType="String">
+        delete from sys_tenant where tenant_id in 
+        <foreach item="tenantId" collection="array" open="(" separator="," close=")">
+            #{tenantId}
+        </foreach>
+    </delete>
+</mapper>

+ 44 - 0
ruoyi-ui/src/api/system/tenant.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 查询租户信息列表
+export function listTenant(query) {
+  return request({
+    url: '/system/tenant/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询租户信息详细
+export function getTenant(tenantId) {
+  return request({
+    url: '/system/tenant/' + tenantId,
+    method: 'get'
+  })
+}
+
+// 新增租户信息
+export function addTenant(data) {
+  return request({
+    url: '/system/tenant',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改租户信息
+export function updateTenant(data) {
+  return request({
+    url: '/system/tenant',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除租户信息
+export function delTenant(tenantId) {
+  return request({
+    url: '/system/tenant/' + tenantId,
+    method: 'delete'
+  })
+}

+ 309 - 0
ruoyi-ui/src/views/system/tenant/index.vue

@@ -0,0 +1,309 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="租户名称" prop="tenantName">
+        <el-input
+          v-model="queryParams.tenantName"
+          placeholder="请输入租户名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="租户编号" prop="tenantCode">
+        <el-input
+          v-model="queryParams.tenantCode"
+          placeholder="请输入租户编号"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="负责人" prop="owner">
+        <el-input
+          v-model="queryParams.owner"
+          placeholder="请输入负责人"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="联系方式" prop="contactInfo">
+        <el-input
+          v-model="queryParams.contactInfo"
+          placeholder="请输入联系方式"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="地址" prop="address">
+        <el-input
+          v-model="queryParams.address"
+          placeholder="请输入地址"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['system:tenant:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['system:tenant:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['system:tenant:remove']"
+        >删除</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['system:tenant:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="tenantList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="租户ID" align="center" prop="tenantId" />
+      <el-table-column label="租户名称" align="center" prop="tenantName" />
+      <el-table-column label="租户编号" align="center" prop="tenantCode" />
+      <el-table-column label="负责人" align="center" prop="owner" />
+      <el-table-column label="联系方式" align="center" prop="contactInfo" />
+      <el-table-column label="地址" align="center" prop="address" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['system:tenant:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['system:tenant:remove']"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改租户信息对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="租户名称" prop="tenantName">
+          <el-input v-model="form.tenantName" placeholder="请输入租户名称" />
+        </el-form-item>
+        <el-form-item label="租户编号" prop="tenantCode">
+          <el-input v-model="form.tenantCode" placeholder="请输入租户编号" />
+        </el-form-item>
+        <el-form-item label="负责人" prop="owner">
+          <el-input v-model="form.owner" placeholder="请输入负责人" />
+        </el-form-item>
+        <el-form-item label="联系方式" prop="contactInfo">
+          <el-input v-model="form.contactInfo" placeholder="请输入联系方式" />
+        </el-form-item>
+        <el-form-item label="地址" prop="address">
+          <el-input v-model="form.address" placeholder="请输入地址" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listTenant, getTenant, delTenant, addTenant, updateTenant } from "@/api/system/tenant";
+
+export default {
+  name: "Tenant",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 租户信息表格数据
+      tenantList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        tenantName: null,
+        tenantCode: null,
+        owner: null,
+        contactInfo: null,
+        address: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        tenantName: [
+          { required: true, message: "租户名称不能为空", trigger: "blur" }
+        ],
+        tenantCode: [
+          { required: true, message: "租户编号不能为空", trigger: "blur" }
+        ]
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 查询租户信息列表 */
+    getList() {
+      this.loading = true;
+      listTenant(this.queryParams).then(response => {
+        this.tenantList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        tenantId: null,
+        tenantName: null,
+        tenantCode: null,
+        owner: null,
+        contactInfo: null,
+        address: null,
+        createBy: null,
+        createTime: null,
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.tenantId)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加租户信息";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const tenantId = row.tenantId || this.ids
+      getTenant(tenantId).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改租户信息";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.tenantId != null) {
+            updateTenant(this.form).then(response => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addTenant(this.form).then(response => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const tenantIds = row.tenantId || this.ids;
+      this.$modal.confirm('是否确认删除租户信息编号为"' + tenantIds + '"的数据项?').then(function() {
+        return delTenant(tenantIds);
+      }).then(() => {
+        this.getList();
+        this.$modal.msgSuccess("删除成功");
+      }).catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download('system/tenant/export', {
+        ...this.queryParams
+      }, `tenant_${new Date().getTime()}.xlsx`)
+    }
+  }
+};
+</script>