Jelajahi Sumber

新增租户时可以选择不是租户的客户

zhuliu 2 tahun lalu
induk
melakukan
73c21db713
4 mengubah file dengan 71 tambahan dan 4 penghapusan
  1. 3 1
      src/api/index.js
  2. 10 0
      src/api/permission.js
  3. 53 2
      src/views/client/index.vue
  4. 5 1
      src/views/user/index.vue

+ 3 - 1
src/api/index.js

@@ -1,7 +1,9 @@
 
 import admin from "./admin";
+import permission from "./permission";
 
 export default {
 
-  ...admin
+  ...admin,
+  ...permission
 }

+ 10 - 0
src/api/permission.js

@@ -0,0 +1,10 @@
+import axios from '@/utils/axios'
+
+export default {
+     /**
+     * 查询没有租户的客户
+     */
+      getNoTenantClients(params) {
+        return axios.get('/permission/api/client/getNoTenantClients',{params})
+    },
+}

+ 53 - 2
src/views/client/index.vue

@@ -10,7 +10,11 @@
       </el-form-item>
     </el-form>
     <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header">
-      <el-table-column type="index" label="#" width="55" align="center"></el-table-column>
+      <el-table-column type="index" label="#" width="55" align="center">
+        <template slot-scope="scope">
+           <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
+        </template>
+      </el-table-column>
       <el-table-column prop="name" label="租户名称" align="center" show-overflow-tooltip></el-table-column>
       <el-table-column prop="contacts" label="联系人" align="center" show-overflow-tooltip></el-table-column>
       <el-table-column prop="address" label="联系人地址" align="center" show-overflow-tooltip></el-table-column>
@@ -65,7 +69,17 @@
         <el-row :gutter="24">
           <el-col :span="24">
             <el-form-item label="租户名称" prop="name">
-              <el-input v-model="ruleForm.name" placeholder="请输入名称"></el-input>
+              <el-autocomplete
+              style="width:100%"
+                v-model="ruleForm.name"
+                :fetch-suggestions="querySearch"
+                @input="input"
+                placeholder="请输入租户名称"
+                :trigger-on-focus="false"
+                @select="handleChange"
+              >
+              </el-autocomplete>
+              <!-- <el-input v-model="ruleForm.name" placeholder="请输入名称"></el-input> -->
             </el-form-item>
           </el-col>
          
@@ -314,12 +328,14 @@ export default {
       		{pattern:/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
        		 message:'请输入正确的邮箱格式',trigger:'blur'}],
       },
+      clientList:[],
     }
   },
   mounted() {
     this.getList()
     this.getFunction()
     this.getListMemberType()
+    this.getNoTenantClients()
     // this.translate()
   },
   created(){
@@ -332,6 +348,35 @@ export default {
    
   },
   methods: {
+    querySearch(queryString, cb) {
+        var clientList = this.clientList;
+        var results = (queryString ? clientList.filter(this.createFilter(queryString)) : clientList).map(item=>{
+          return {
+            value:item.name,
+            name:item.name,
+            id:item.id
+          }
+        });
+        // 调用 callback 返回建议列表的数据
+        cb(results);
+      },
+      createFilter(queryString) {
+        return (clientList) => {
+          return (clientList.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
+        };
+      },
+      getNoTenantClients(){
+        this.$api.getNoTenantClients().then(response=>{
+          this.clientList = response.data
+        })
+      },
+      input() {
+        this.$set(this.ruleForm, 'clientId', null)
+      },
+      handleChange(row) {
+        this.$set(this.ruleForm, 'clientId', row.id)
+        this.$set(this.ruleForm, 'name', row.name)
+      },
     getType(val){
         // this.getFunction(val)
     },
@@ -468,6 +513,7 @@ export default {
               this.$message.success('编辑成功')
               this.btnLoading = false
               this.getList()
+              this.getNoTenantClients()
               this.close()
             }).catch(error => {
               this.btnLoading = false
@@ -477,6 +523,7 @@ export default {
               this.$message.success('新增成功')
               this.btnLoading = false
               this.getList()
+              this.getNoTenantClients()
               this.close()
             }).catch(error => {
               this.btnLoading = false
@@ -516,8 +563,12 @@ export default {
         this.loading = true
         this.$api.deleteTenant({ id: row.id }).then(response => {
           this.$message.success('删除成功')
+          if(this.tableData.length==1){
+            this.queryParams.current -= 1
+          }
           this.loading = false
           this.getList()
+          this.getNoTenantClients()
         }).catch(error => {
           this.loading = false
         })

+ 5 - 1
src/views/user/index.vue

@@ -39,7 +39,11 @@
 				label="#"
 				width="55"
 				align="center"
-			></el-table-column>
+			>
+			<template slot-scope="scope">
+          <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
+        </template>
+			</el-table-column>
 			<el-table-column
 				prop="name"
 				label="姓名"