-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -216,10 +230,11 @@ import {
deleteConsumer,
updateConsumer,
importConsumer,
- exportConsumer
+ exportConsumer,
+ deleteConsumers
} from "@/api/crm";
-import { getSubjectAll } from "@/api/question"
-import { getWorkScopeAll } from "@/api/examtest"
+import { getSubjectAll } from "@/api/question";
+import { getWorkScopeAll } from "@/api/examtest";
import { getCompanyList } from "@/api/crm";
import { genTree, deepClone } from "@/utils";
import checkPermission from "@/utils/permission";
@@ -232,13 +247,13 @@ const defaultConsumer = {
name: "",
username: "",
company: null,
- subjects:[],
- workscope:null
+ subjects: [],
+ workscope: null
};
const listQuery = {
page: 1,
limit: 20,
- search:''
+ search: ""
};
export default {
components: { Pagination },
@@ -261,7 +276,7 @@ export default {
listQuery: {
page: 1,
limit: 20,
- search:''
+ search: ""
},
enabledOptions: [
{ key: "true", display_name: "已缴" },
@@ -271,7 +286,9 @@ export default {
dialogType: "new",
rule1: {
name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
- username: [{ required: true, message: "请输入手机号", trigger: "change" }]
+ username: [
+ { required: true, message: "请输入手机号", trigger: "change" }
+ ]
// password: [
// { required: true, message: "请输入密码", trigger: "change" }
// ],
@@ -280,7 +297,8 @@ export default {
treeLoding: false,
companyData: [],
subjectData: [],
- workscopeData:[],
+ workscopeData: [],
+ selects: []
};
},
computed: {},
@@ -294,27 +312,26 @@ export default {
checkPermission,
handleUploadSuccess(res, file) {
if (res.code == 200) {
- const loading = this.$loading({text:"正在导入中..."})
+ const loading = this.$loading({ text: "正在导入中..." });
importConsumer(res.data).then(response => {
- loading.close()
- if(response.code==200){
- this.$message({
- message: '导入成功',
- type: 'success'
- });
- this.getList(listQuery)
- }else if(response.code==206){
+ loading.close();
+ if (response.code == 200) {
this.$message({
- message: '部分未成功' + response.data,
- type: 'success'
- });
- this.getList(listQuery)
- }else{
+ message: "导入成功",
+ type: "success"
+ });
+ this.getList(listQuery);
+ } else if (response.code == 206) {
+ this.$message({
+ message: "部分未成功" + response.data,
+ type: "success"
+ });
+ this.getList(listQuery);
+ } else {
this.$message.error(response.msg);
}
-
- });
- }else{
+ });
+ } else {
this.$message.error("Excel上传失败!");
}
},
@@ -333,7 +350,14 @@ export default {
getCompanyList() {
this.treeLoding = true;
getCompanyList().then(response => {
- this.companyData = genTree(response.data);
+ this.companyData = genTree(response.data.results);
+ this.treeLoding = false;
+ });
+ },
+ searchCompany(val) {
+ this.treeLoding = true;
+ getCompanyList({search:val}).then(response => {
+ this.companyData = genTree(response.data.results);
this.treeLoding = false;
});
},
@@ -351,7 +375,7 @@ export default {
this.listQuery = {
page: 1,
limit: 20,
- search: ''
+ search: ""
};
this.getList();
},
@@ -393,12 +417,39 @@ export default {
console.error(err);
});
},
+ handleDeletes() {
+ if(this.selects.length){
+ this.$confirm("确认删除这"+ this.selects.length + "位用户吗?将丢失数据!", "警告", {
+ confirmButtonText: "确认",
+ cancelButtonText: "取消",
+ type: "error"
+ })
+ .then(async () => {
+ const { code } = await deleteConsumers({ ids: this.selects });
+ if (code >= 200) {
+ this.getList()
+ this.$message({
+ type: "success",
+ message: "成功删除!"
+ });
+ }
+ })
+ .catch(err => {
+ console.error(err);
+ });
+ }else{
+ this.$message({
+ message: '请先选择',
+ type: 'warning'
+ });
+ }
+ },
async confirmUser(form) {
this.$refs[form].validate(valid => {
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
- let consumer = this.consumer
+ let consumer = this.consumer;
updateConsumer(this.consumer.id, consumer).then(res => {
// for (let index = 0; index < this.consumerList.length; index++) {
// if (this.consumerList[index].id === this.consumer.id) {
@@ -410,9 +461,9 @@ export default {
// break;
// }
// }
- this.getList()
+ this.getList();
this.dialogVisible = false;
- if(res.code >=200){
+ if (res.code >= 200) {
this.$notify({
title: "成功",
message: "编辑成功",
@@ -420,7 +471,6 @@ export default {
duration: 2000
});
}
-
});
} else {
createConsumer(this.consumer).then(res => {
@@ -428,15 +478,14 @@ export default {
// this.consumerList.unshift(this.consumer)
this.getList();
this.dialogVisible = false;
- if(res.code >=200){
+ if (res.code >= 200) {
this.$notify({
- title: "成功",
- message: "新增成功",
- type: "success",
- duration: 2000
- });
+ title: "成功",
+ message: "新增成功",
+ type: "success",
+ duration: 2000
+ });
}
-
});
}
} else {
@@ -447,19 +496,25 @@ export default {
exportConsumer() {
const loading = this.$loading();
exportConsumer(this.listQuery).then(response => {
- loading.close()
+ loading.close();
window.open(response.data.path, "_blank");
});
},
- changeSort (val) {
- if(val.order == 'ascending'){
- this.listQuery.ordering = val.prop
- }else{
- this.listQuery.ordering = '-' + val.prop
+ changeSort(val) {
+ if (val.order == "ascending") {
+ this.listQuery.ordering = val.prop;
+ } else {
+ this.listQuery.ordering = "-" + val.prop;
}
-
- this.getList()
+ this.getList();
+ },
+ handleSelectionChange(val) {
+ let selects = [];
+ for (var i = 0; i < val.length; i++) {
+ selects.push(val[i].id);
+ }
+ this.selects = selects;
}
}
};
diff --git a/test_server/crm/views.py b/test_server/crm/views.py
index 96dd355..ab36ff7 100644
--- a/test_server/crm/views.py
+++ b/test_server/crm/views.py
@@ -65,7 +65,7 @@ class CompanyViewSet(ModelViewSet):
{'put': 'company_update'}, {'delete': 'company_delete'}]
queryset = Company.objects.filter(is_delete=0).all()
serializer_class = CompanySerializer
- pagination_class = None #不分页
+ pagination_class = CommonPagination
filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter]
search_fields = ('^name',)
ordering_fields = ('id',)
@@ -114,6 +114,16 @@ class ConsumerViewSet(ModelViewSet):
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
return Response(serializer.data)
+ @action(methods=['post'], detail=False, url_name='consumer_deletes',perms_map=[{'*':'consumer_deletes'}])
+ def deletes(self, request):
+ """
+ 批量删除用户
+ """
+ ids = request.data.get('ids', None)
+ if ids:
+ Consumer.objects.filter(id__in = ids).delete()
+ return Response(status=status.HTTP_200_OK)
+
@action(methods=['get'], detail=False,
url_path='subjectpaid', url_name='subject_paid',perms_map=[{'*':'my_subject'}])
def has_paid(self, request):