<template>
|
<div class='wish_distribution'>
|
<section>
|
<p class="label">发起人:</p>
|
<p>{{detail.sponsorName}}</p>
|
</section>
|
<section>
|
<p class="label">联系电话:</p>
|
<p>{{detail.sponsorPhone}}</p>
|
</section>
|
<section>
|
<p class="label">发起时间:</p>
|
<p>{{detail.createAt}}</p>
|
</section>
|
<section>
|
<p class="label">心愿详情:</p>
|
<p class="wish-details">{{detail.detail}}</p>
|
</section>
|
<!-- <section>
|
<p class="label">完成形式:</p>
|
<article>
|
<el-radio
|
v-model="radio"
|
label="1"
|
>分配人员</el-radio>
|
<el-radio
|
v-model="radio"
|
label="2"
|
>发起活动</el-radio>
|
</article>
|
</section> -->
|
|
<section>
|
<p class="label h32">分配处理人:</p>
|
<div>
|
<el-checkbox-button
|
v-for="(personnel, index) in personnelList"
|
v-model="personnel.checked"
|
:key="index">{{personnel.name}}</el-checkbox-button>
|
</div>
|
</section>
|
|
<section v-for="(personnel, index) in personnelList.filter(d => d.checked)" :key="index">
|
<p class="label h32">{{`分配${personnel.name}:`}}</p>
|
<article>
|
<el-select
|
v-model="personnel.value"
|
placeholder= "请选择"
|
size="small"
|
>
|
<el-option
|
v-for="item in personnel.options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
<p class="add-people" @click="addUser(personnel.name)">没找到,去添加?</p>
|
</article>
|
</section>
|
<div v-if ="num !== detailId.length" class="next" @click="nextDetails">点击下一条</div>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
props: {
|
item: {
|
type: Object,
|
default: () => {
|
return {};
|
},
|
},
|
door: {
|
type: Object,
|
default: () => {
|
return {};
|
},
|
},
|
},
|
components: {},
|
data() {
|
return {
|
detail: {},
|
personnelList: [
|
{name: '后台用户',type:1, checked: true, value: '' ,options:[]},
|
// {name: '党员',type:2, checked: false, value: '' ,options:[]},
|
// {name: '志愿者',type:3, checked: false, value: '' ,options:[]},
|
// {name: '社工',type:4, checked: false, value: '' ,options:[]},
|
// {name: '四长四员',type:5, checked: false, value: '' ,options:[]}
|
],
|
text: "",
|
radio: "1",
|
// assignor: "",
|
// Choosepersonnel:['选择后台用户'],
|
options: [],
|
memberList:[],
|
volunteerList:[],
|
loading: false,
|
detailId:[], //下一条的ID集合
|
num:0,
|
type:[1],
|
};
|
},
|
watch: {
|
item: {
|
handler() {
|
this.setItem();
|
},
|
deep: true,
|
},
|
door: {
|
handler(n) {
|
if (n.r) {
|
this.sub(n.t);
|
}
|
},
|
deep: true,
|
},
|
},
|
methods: {
|
// 查看大图
|
onScaleImage(j) {
|
let list = (this.detail.photoPathList || "").split(",").filter((k) => {
|
return k !== "";
|
});
|
this.$store.dispatch("setImage", {
|
time: Date.now(),
|
pic: list[j],
|
list,
|
tool: true,
|
});
|
},
|
onSearch(v) {
|
// this.loading = true;
|
// this.getSelect(v);
|
},
|
sub(type) {
|
/** 处理完所以下一条点确定,就隐藏 */
|
if(this.detailId.length < 0) {
|
this.onClose(type);
|
return void 0;
|
}
|
|
let responsibleId = [];
|
let handleList = []
|
|
for (let i = 0; i < this.personnelList.length; i++) {
|
const item = this.personnelList[i];
|
if (item.checked) {
|
if (!item.value) {
|
demo.toast(`请分配${item.name}`)
|
return void 0;
|
}
|
responsibleId.push(item.value)
|
handleList.push({
|
userId:item.value,
|
type:item.type
|
});
|
}
|
}
|
|
const params = {
|
id: this.detail.id,
|
form: this.radio,
|
wishName: this.detail.wishName,
|
type: this.radio === "2" ? "4" : "3",
|
handleList:handleList,
|
handleIds: responsibleId
|
// responsibleId: responsibleId.join(','),
|
// responsibleName: responsibleId.map(d => this.options.find(m => m.value === d).label).join(',')
|
}
|
|
console.log(params);
|
|
this.$api.put("communityactivity/putmicrowish", params, () => {
|
demo.toast("分配成功");
|
// 清空分配人
|
this.personnelList.forEach((item, index) => {
|
item.value = '';
|
item.checked = !index;
|
})
|
|
this.nextDetails();
|
this.$nextTick(() => {
|
this.$store.dispatch("setFixed", {
|
event: "del",
|
type: type,
|
time: Date.now(),
|
});
|
this.$store.dispatch("setPageReset", "/act_wish");
|
});
|
});
|
},
|
|
//去添加
|
addUser(index) {
|
// console.log(index)
|
if(index == '后台用户') {
|
this.$router.push("/sys_user")
|
}
|
if(index == '党员') {
|
this.$router.push("/com_member")
|
}
|
if(index == '志愿者') {
|
this.$router.push("/man_vol")
|
}
|
|
},
|
|
// getSelect() {
|
// this.$api.get("communityactivity/wish/handle/list", {type:1}, e => {
|
// this.loading = false;
|
// this.options = e.data.map((k) => {
|
// return { label: k.name, value: k.userId };
|
// });
|
// this.personnelList[0].options = this.options;
|
// })
|
// },
|
getSelect(index) {
|
this.$api.get("communityactivity/wish/handle/list", {type:index+1}, e => {
|
this.loading = false;
|
this.options = e.data.map((k) => {
|
return { label: k.name, value: k.userId };
|
});
|
this.personnelList[index].options = this.options;
|
})
|
},
|
getmember() {
|
this.$api.get("communityactivity/wish/handle/list", {type:2}, e => {
|
this.loading = false;
|
this.memberList = e.data.map((k) => {
|
return { label: k.name, value: k.userId };
|
});
|
this.personnelList[1].options = this.memberList;
|
})
|
},
|
getvolunteer() {
|
this.$api.get("communityactivity/wish/handle/list", {type:3}, e => {
|
this.loading = false;
|
this.volunteerList = e.data.map((k) => {
|
return { label: k.name, value: k.userId };
|
});
|
this.personnelList[2].options = this.volunteerList;
|
})
|
},
|
setItem() {
|
if (this.item.id) {
|
// 选择后台用户
|
// this.getSelect();
|
// //选择党员
|
// this.getmember();
|
// //选择志愿者
|
// this.getvolunteer();
|
|
this.personnelList.map((item,index)=>{
|
this.getSelect(index)
|
})
|
|
this.$api.get(
|
"communityactivity/detailmicrowish",
|
{ id: this.item.id },
|
(e) => {
|
this.detail = e;
|
this.detailId = e.idList; //查询下一条的所有Id
|
this.removeByValue(this.detailId, this.item.id);
|
}
|
);
|
} else {
|
demo.toast("错误活动");
|
}
|
},
|
|
// 删除数组指定的元素
|
removeByValue(arr, val) {
|
for(var i = 0; i < arr.length; i++) {
|
if(arr[i] == val) {
|
arr.splice(i, 1);
|
break;
|
}
|
}
|
},
|
|
//下一条
|
nextDetails() {
|
// 清空分配人
|
this.personnelList.forEach((item, index) => {
|
item.value = '';
|
item.checked = !index;
|
});
|
|
if(this.num < this.detailId.length) {
|
this.num = this.num +1;
|
this.getDetail();
|
} else {
|
this.onClose();
|
}
|
},
|
|
onClose () {
|
let type = "wish-distribution"
|
this.$nextTick(() => {
|
this.$store.dispatch("setFixed", {
|
event: "del",
|
type: type,
|
time: Date.now(),
|
});
|
this.$store.dispatch("setPageReset", "/act_wish");
|
});
|
},
|
|
//获取详情
|
getDetail() {
|
this.$api.get(
|
"communityactivity/detailmicrowish",
|
{ id: this.detailId[this.num-1 ] },
|
(e) => {
|
this.detail = e;
|
}
|
);
|
},
|
},
|
mounted() {
|
this.setItem();
|
},
|
};
|
</script>
|
<style lang='less' scoped>
|
.wish_distribution {
|
font-size: 14px;
|
color: #333;
|
.wish-details {
|
line-height: 20px;
|
}
|
.next {
|
font-size: 14px;
|
color: #409EFF;
|
font-weight: 500;
|
text-align: right;
|
cursor: pointer;
|
position: absolute;
|
right: 20px;
|
bottom: 20px;
|
}
|
.add-people {
|
font-size: 13px;
|
color: #409EFF;
|
cursor: pointer;
|
padding-top: 5px;
|
}
|
section {
|
display: flex;
|
margin-bottom: 20px;
|
.label {
|
width: 100px;
|
text-align: right;
|
& + * {
|
width: calc(~"100% - 100px");
|
}
|
}
|
.h32 {
|
line-height: 32px;
|
& + article {
|
max-width: 400px;
|
}
|
}
|
&.flex > article {
|
width: 50%;
|
display: flex;
|
}
|
}
|
}
|
</style>
|