Merge branch 'master' of https://e.coding.net/ctcdevteam/examtest
This commit is contained in:
commit
f9717cdbbb
|
@ -30,6 +30,13 @@ export function transferCompany(id, data) {
|
|||
})
|
||||
}
|
||||
|
||||
export function transferCompanys(data) {
|
||||
return request({
|
||||
url: `/crm/company/transfers/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function deleteCompany(id) {
|
||||
return request({
|
||||
url: `/crm/company/${id}/`,
|
||||
|
|
|
@ -15,7 +15,13 @@
|
|||
icon="el-icon-refresh-left"
|
||||
@click="resetFilter"
|
||||
>刷新重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleTrans"
|
||||
v-if="checkPermission(['consumer__transfers'])"
|
||||
>批量移交</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="tableData.results"
|
||||
style="width: 100%;margin-top:10px;"
|
||||
|
@ -27,9 +33,9 @@
|
|||
row-key="id"
|
||||
default-expand-all
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="index" width="50"></el-table-column>
|
||||
<el-table-column type="selection" width="50"></el-table-column>
|
||||
<el-table-column label="单位名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
|
@ -92,7 +98,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getCompanyList, createCompany, deleteCompany, updateCompany, transferCompany } from "@/api/crm";
|
||||
import { getCompanyList, createCompany, deleteCompany, updateCompany, transferCompany, transferCompanys } from "@/api/crm";
|
||||
import { deepClone } from "@/utils";
|
||||
import checkPermission from "@/utils/permission";
|
||||
import Pagination from "@/components/Pagination"
|
||||
|
@ -112,6 +118,7 @@ export default {
|
|||
components: { Pagination },
|
||||
data() {
|
||||
return {
|
||||
selects:[],
|
||||
company: {
|
||||
id: "",
|
||||
name: "",
|
||||
|
@ -236,6 +243,34 @@ export default {
|
|||
})
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
let selects = [];
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
selects.push(val[i].id);
|
||||
}
|
||||
this.selects = selects;
|
||||
},
|
||||
handleTrans() {
|
||||
if (this.selects.length) {
|
||||
this.$prompt('请输入管理员账号以确认将'+this.selects.length + '家企业及其学员转交给他', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
// inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
|
||||
// inputErrorMessage: '邮箱格式不正确'
|
||||
}).then(({ value }) => {
|
||||
transferCompanys({admin:value, companys:this.selects}).then(res=>{
|
||||
this.$message.success('转交成功!')
|
||||
this.getList()
|
||||
})
|
||||
}).catch(() => {
|
||||
});
|
||||
} else {
|
||||
this.$message({
|
||||
message: "请先选择",
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<div slot="header" class="clearfix">
|
||||
<span>单位</span>
|
||||
</div>
|
||||
<el-table
|
||||
:data="tableDatac.results"
|
||||
style="width: 100%;"
|
||||
border
|
||||
fit
|
||||
v-loading="listLoadingc"
|
||||
highlight-current-row
|
||||
height="160"
|
||||
row-key="id"
|
||||
@row-click = 'handleCompanyClick'
|
||||
>
|
||||
<el-table-column label="单位名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="tableDatac.count>0"
|
||||
:total="tableDatac.count"
|
||||
:page.sync="listQueryc.page"
|
||||
:limit.sync="listQueryc.limit"
|
||||
@pagination="getListc"
|
||||
/>
|
||||
|
||||
</el-card>
|
||||
<el-card style="margin-top:6px">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>学员</span>
|
||||
</div>
|
||||
<div>
|
||||
<el-select
|
||||
v-if="checkPermission(['admin'])"
|
||||
|
@ -17,7 +49,7 @@
|
|||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select
|
||||
<!-- <el-select
|
||||
v-model="listQuery.company"
|
||||
placeholder="所属单位"
|
||||
clearable
|
||||
|
@ -34,7 +66,7 @@
|
|||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-select> -->
|
||||
<el-select
|
||||
v-model="listQuery.role"
|
||||
placeholder="用户类型"
|
||||
|
@ -90,7 +122,7 @@
|
|||
type="primary"
|
||||
icon="el-icon-refresh-left"
|
||||
@click="resetFilter"
|
||||
>刷新重置</el-button>
|
||||
>刷新</el-button>
|
||||
</div>
|
||||
<div style="margin-top:10px">
|
||||
|
||||
|
@ -151,6 +183,7 @@
|
|||
@change="tableKey=tableKey+1"
|
||||
>创建信息</el-checkbox>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="consumerList"
|
||||
style="width: 100%;margin-top:10px;"
|
||||
|
@ -158,7 +191,7 @@
|
|||
fit
|
||||
v-loading="listLoading"
|
||||
highlight-current-row
|
||||
max-height="600"
|
||||
height="400"
|
||||
@sort-change="changeSort"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
|
@ -235,7 +268,7 @@
|
|||
:limit.sync="listQuery.limit"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
</el-card>
|
||||
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑用户':'新增用户'">
|
||||
<el-form
|
||||
:model="consumer"
|
||||
|
@ -355,7 +388,6 @@ import { getUserList } from "@/api/user";
|
|||
import { getToken } from "@/utils/auth";
|
||||
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||
import Companychose from "@/views/crm/companychose";
|
||||
|
||||
const defaultConsumer = {
|
||||
id: "",
|
||||
name: "",
|
||||
|
@ -390,11 +422,18 @@ export default {
|
|||
consumerList: [],
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
listLoadingc: false,
|
||||
listQuery: {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search: "",
|
||||
},
|
||||
listQueryc: {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search: "",
|
||||
},
|
||||
tableDatac: {count:0},
|
||||
enabledOptions: [
|
||||
{ key: "true", display_name: "已缴" },
|
||||
{ key: "false", display_name: "未缴" },
|
||||
|
@ -473,7 +512,7 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getCompanyList();
|
||||
this.getListc();
|
||||
this.getSubjectAll();
|
||||
this.getWorkScopeAll();
|
||||
this.getConsumerRoleAll();
|
||||
|
@ -518,20 +557,27 @@ export default {
|
|||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
getCompanyList() {
|
||||
this.treeLoding = true;
|
||||
getCompanyList().then((response) => {
|
||||
this.companyData = genTree(response.data.results);
|
||||
this.treeLoding = false;
|
||||
});
|
||||
},
|
||||
searchCompany(val) {
|
||||
this.treeLoding = true;
|
||||
getCompanyList({ search: val, perm: "all" }).then((response) => {
|
||||
this.companyData = genTree(response.data.results);
|
||||
this.treeLoding = false;
|
||||
getListc() {
|
||||
this.listLoadingc = true;
|
||||
getCompanyList(this.listQueryc).then((response) => {
|
||||
this.tableDatac = response.data;
|
||||
this.listLoadingc = false;
|
||||
});
|
||||
},
|
||||
// getCompanyList() {
|
||||
// this.treeLoding = true;
|
||||
// getCompanyList().then((response) => {
|
||||
// this.companyData = genTree(response.data.results);
|
||||
// this.treeLoding = false;
|
||||
// });
|
||||
// },
|
||||
// searchCompany(val) {
|
||||
// this.treeLoding = true;
|
||||
// getCompanyList({ search: val, perm: "all" }).then((response) => {
|
||||
// this.companyData = genTree(response.data.results);
|
||||
// this.treeLoding = false;
|
||||
// });
|
||||
// },
|
||||
getSubjectAll() {
|
||||
getSubjectAll().then((response) => {
|
||||
this.subjectData = genTree(response.data);
|
||||
|
@ -714,8 +760,8 @@ export default {
|
|||
},
|
||||
getAdminOptions() {
|
||||
if (checkPermission(["admin"])) {
|
||||
getUserList().then((res) => {
|
||||
this.adminOptions = genTree(res.data.results);
|
||||
getUserList({pageoff:true}).then((res) => {
|
||||
this.adminOptions = res.data;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -729,6 +775,10 @@ export default {
|
|||
this.consumer.company = val.id;
|
||||
}
|
||||
},
|
||||
handleCompanyClick(row, column, event){
|
||||
this.listQuery.company = row.id
|
||||
this.getList()
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -133,6 +133,22 @@ class CompanyViewSet(ModelViewSet):
|
|||
return Response(status=status.HTTP_200_OK)
|
||||
else:
|
||||
return Response({"error":"账号错误"})
|
||||
|
||||
@action(methods=['put'], detail=False, url_name='company_transfers',perms_map=[{'*':'company_transfers'}])
|
||||
def transfers(self, request, *args, **kwargs):
|
||||
"""
|
||||
批量移交
|
||||
"""
|
||||
companys = Company.objects.filter(id__in = request.data['companys'])
|
||||
adminname = request.data.get('admin', None)
|
||||
if adminname and UserProfile.objects.filter(username=adminname).exists():
|
||||
adminobj = UserProfile.objects.get(username=adminname)
|
||||
if companys.exists():
|
||||
companys.update(create_admin=adminobj)
|
||||
Consumer.objects.filter(company__in = companys).update(create_admin=adminobj)
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
else:
|
||||
return Response({"error":"账号错误"})
|
||||
|
||||
class ConsumerViewSet(ModelViewSet):
|
||||
"""
|
||||
|
|
|
@ -57,9 +57,9 @@ class UserInfoView(APIView):
|
|||
|
||||
|
||||
|
||||
from utils.pagination import PageOrNot
|
||||
|
||||
|
||||
class UserViewSet(ModelViewSet):
|
||||
class UserViewSet(PageOrNot, ModelViewSet):
|
||||
"""
|
||||
用户管理:增删改查
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
from rest_framework.pagination import PageNumberPagination
|
||||
from rest_framework.exceptions import ParseError
|
||||
|
||||
class MyPagination(PageNumberPagination):
|
||||
page_size = 10
|
||||
page_size_query_param = 'page_size'
|
||||
|
||||
class PageOrNot:
|
||||
def paginate_queryset(self, queryset):
|
||||
if (self.paginator is None):
|
||||
return None
|
||||
elif self.request.query_params.get('pageoff', None) and self.get_queryset().count()<500:
|
||||
return None
|
||||
elif self.request.query_params.get('pageoff', None) and self.get_queryset().count()>=500:
|
||||
return ParseError('单次请求数据量大,请求中止')
|
||||
return self.paginator.paginate_queryset(queryset, self.request, view=self)
|
Loading…
Reference in New Issue