diff --git a/src/views/manage/AddAudiences.vue b/src/views/manage/AddAudiences.vue
index 102e7520..1f37db8d 100644
--- a/src/views/manage/AddAudiences.vue
+++ b/src/views/manage/AddAudiences.vue
@@ -28,7 +28,7 @@
取消
保存
- 保存并发布
+ 保存并发布
@@ -46,7 +46,7 @@
-
+
搜索
重置
@@ -72,7 +72,7 @@
注:单个导入文件受众成员请勿超过5000条记录,以员工号为准。必须是本系统人员
文件名称:
-
+ > -->
+
选择
上传
@@ -122,6 +137,7 @@
import userApi from "@/api/system/user";
import orgApi from "@/api/system/organiza";
import apiUserBasic from "@/api/boe/userbasic";
+ import apiAudience from "@/api/boe/audience.js";
export default{
data(){
return{
@@ -133,6 +149,8 @@
description:'',
userGroupItems:[]
},
+ isUpdate:false,
+ importUrl:process.env.VUE_APP_AUDIENCE_IMPORT_URL,
searchValue:'',
tableData:[],
tableDataShow:[],
@@ -149,7 +167,7 @@
label: 'name'
},
userData:[],
- userQueryForm:{keyWord:'',departId:''},
+ userQueryForm:{keyword:'',departId:''},
userDataLoading:false,
userDataPage:{
total:0,
@@ -166,14 +184,23 @@
mounted() {
let that = this;
if (that.$route.query.id) {
- usergroupApi.detail(that.$route.query.id).then((res) => {
- if (res.status == 200) {
- that.form = res.result;
- // that.oldUserGroupItems = JSON.parse(JSON.stringify( res.result.userGroupItems ));
- that.tableData = res.result.userGroupItems;
- that.queryTableData();
- }
+ let req = {audienceId:that.$route.query.id}
+ this.isUpdate = true;
+ apiAudience.detail(req).then((res) => {
+ if (res.status == 200) {
+ that.form = res.result;
+ that.tableData = res.result.memberList;
+ that.queryTableData();
+ }
});
+ // usergroupApi.detail(that.$route.query.id).then((res) => {
+ // if (res.status == 200) {
+ // that.form = res.result;
+ // // that.oldUserGroupItems = JSON.parse(JSON.stringify( res.result.userGroupItems ));
+ // that.tableData = res.result.userGroupItems;
+ // that.queryTableData();
+ // }
+ // });
}
},
methods:{
@@ -200,7 +227,7 @@
});
}else{
parentId = node.data.id;
-
+
apiUserBasic.getOrgInfo(parentId).then(rs=>{
if(rs.status==200){
let treeList=[];
@@ -228,7 +255,7 @@
},
openDialog(){
this.addUserShow = true;
- this.userQueryForm.keyWord = '';
+ this.userQueryForm.keyword = '';
this.userQueryForm.departId = '';
// orgApi.treeList({}).then(res => {
// if (res.status == 200) {
@@ -239,7 +266,7 @@
//this.loadUserData(this.userDataPage);
},
reset() {
- this.userQueryForm.keyWord = '';
+ this.userQueryForm.keyword = '';
this.userQueryForm.departId = '';
this.userDataPage.pageIndex = 1;
this.loadUserData(this.userDataPage, this.userQueryForm);
@@ -247,6 +274,8 @@
userSelectionChange(val) {
this.userSelection = val;
},
+
+ //搜索员工事件
queryUserData(){
this.userDataPage.pageIndex = 1;
this.loadUserData(this.userDataPage, this.userQueryForm);
@@ -255,13 +284,30 @@
this.userDataLoading = true;
params.pageIndex = page.pageIndex;
params.pageSize = page.pageSize;
- userApi.list(Object.assign(params, this.userQueryForm)).then(res => {
+
+ let req = {
+ page:page.pageIndex,
+ pageSize:page.pageSize,
+ keyword:this.userQueryForm.keyword,
+ departId:this.userQueryForm.departId
+ }
+ apiAudience.userList(req).then(res => {
if (res.status == 200) {
- this.userData = res.result.list;
- this.userDataPage.total = res.result.count;
+ console.log("搜索用户信息");
+ console.log(res);
+ this.userData = res.result.userInfoList;
+ this.userDataPage.total = res.result.totalPage;
this.userDataLoading = false;
}
})
+
+ // userApi.list(Object.assign(params, this.userQueryForm)).then(res => {
+ // if (res.status == 200) {
+ // this.userData = res.result.list;
+ // this.userDataPage.total = res.result.count;
+ // this.userDataLoading = false;
+ // }
+ // })
},
userDataCurrentChange(pageIndex){
this.userDataPage.pageIndex = pageIndex;
@@ -279,7 +325,7 @@
for(let i = 0; i < this.userSelection.length; i++){
let isAdd = true;
for(let j = 0; j < this.tableData.length; j++){
- if(this.userSelection[i].id == this.tableData[j].aid){
+ if(this.userSelection[i].id == this.tableData[j].id){
isAdd = false;
break;
}
@@ -287,12 +333,15 @@
if(isAdd){
let userItem = {}
userItem.aid = this.userSelection[i].id;
+ userItem.id = this.userSelection[i].id;
userItem.name = this.userSelection[i].name;
userItem.userNo = this.userSelection[i].userNo;
userItem.departId = this.userSelection[i].departId;
userItem.departName = this.userSelection[i].departName;
userItem.position = this.userSelection[i].duty;
this.tableData.push(userItem);
+ console.log(111);
+ console.log(this.tableData);
}
}
this.queryTableData();
@@ -443,8 +492,10 @@
this.queryTableData();
this.importUserShow = false;
},
+
+ // 保存、保存并发布事件
saveBack(status){
- if(status === 1 || status === 0){
+ if(status === 2 || status === 0){
this.form.status = status;
}else{
this.$router.push('/manage/ugroups');
@@ -455,33 +506,70 @@
this.form.userGroupItems = [];
if(this.tableData.length > 0){
for(let i = 0; i < this.tableData.length; i++){
- this.form.userGroupItems.push({aid:this.tableData[i].aid});
+ // this.form.userGroupItems.push({aid:this.tableData[i].aid});
+ this.form.userGroupItems.push(this.tableData[i].id);
}
}
- if (this.form.id != null && this.form.id != "") {
- usergroupApi
- .update(this.form)
- .then((res) => {
- if (res.status == 200) {
- this.$message({ type: "success", message: "修改成功",offset:50 });
- this.$router.push('/manage/ugroups');
- }
- })
- .catch((res) => {
- this.$message({ type: "error", message: res.message ,offset:50});
- });
- } else {
- usergroupApi
- .save(this.form)
- .then((res) => {
- if (res.status == 200) {
- this.$message({ type: "success", message: "新增成功" ,offset:50});
- this.$router.push('/manage/ugroups');
- }
- })
- .catch((res) => {
- this.$message({ type: "error", message: res.message ,offset:50});
- });
+ if (this.form.id != null && this.form.id != "") { // 修改受众
+ let req = {
+ audienceId:this.form.id,
+ audienceName:this.form.name,
+ description:this.form.description,
+ type:this.form.gtype,
+ status:this.form.status,
+ memberIdList:this.form.userGroupItems
+ }
+ apiAudience.update(req).then((res) => {
+ if (res.status == 200) {
+ this.$message({ type: "success", message: "修改成功",offset:50 });
+ this.$router.push('/manage/ugroups');
+ }else{
+ console.log("更新受众异常");
+ }
+ })
+
+ // usergroupApi
+ // .update(this.form)
+ // .then((res) => {
+ // if (res.status == 200) {
+ // this.$message({ type: "success", message: "修改成功",offset:50 });
+ // this.$router.push('/manage/ugroups');
+ // }
+ // })
+ // .catch((res) => {
+ // this.$message({ type: "error", message: res.message ,offset:50});
+ // });
+ } else { // 新增受众
+
+ let req = {
+ audienceId:this.form.id,
+ audienceName:this.form.name,
+ description:this.form.description,
+ type:this.form.gtype,
+ status:this.form.status,
+ memberIdList:this.form.userGroupItems
+ }
+ apiAudience.update(req).then((res) => {
+ if (res.status == 200) {
+ this.$message({ type: "success", message: "新增成功",offset:50 });
+ this.$router.push('/manage/ugroups');
+ }else{
+ console.log("新增受众异常");
+ }
+ })
+
+
+ // usergroupApi
+ // .save(this.form)
+ // .then((res) => {
+ // if (res.status == 200) {
+ // this.$message({ type: "success", message: "新增成功" ,offset:50});
+ // this.$router.push('/manage/ugroups');
+ // }
+ // })
+ // .catch((res) => {
+ // this.$message({ type: "error", message: res.message ,offset:50});
+ // });
}
}
});