|
|
|
|
@ -236,50 +236,53 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
submit(){
|
|
|
|
|
let areaIds = this.$refs['elTree'].getCheckedNodes().map(item => item.id)
|
|
|
|
|
let oriAreaIds = this.originalArea.map(item => item.area_id)
|
|
|
|
|
let areaPromiseAll = [];
|
|
|
|
|
let areaDifArr = this.getArrDifference(areaIds,oriAreaIds)
|
|
|
|
|
areaDifArr.forEach(item => {
|
|
|
|
|
if(oriAreaIds.indexOf(item) === -1){
|
|
|
|
|
areaPromiseAll.push(saveArea({
|
|
|
|
|
area_id:item,
|
|
|
|
|
admin_id:Number(this.activeUser)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
if(areaIds.indexOf(item) === -1){
|
|
|
|
|
areaPromiseAll.push(destroyArea(this.originalArea[oriAreaIds.indexOf(item)]?.id))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let oriTypeIds = this.originalType.map(item => item.product_type_id)
|
|
|
|
|
let typePromiseAll = [];
|
|
|
|
|
let typeDifArr = this.getArrDifference(oriTypeIds,this.checkedTypes)
|
|
|
|
|
typeDifArr.forEach(item => {
|
|
|
|
|
if(oriTypeIds.indexOf(item) === -1){
|
|
|
|
|
typePromiseAll.push(saveType({
|
|
|
|
|
product_type_id:item,
|
|
|
|
|
admin_id:Number(this.activeUser)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
if(this.checkedTypes.indexOf(item) === -1){
|
|
|
|
|
typePromiseAll.push(destroyType(this.originalType[oriTypeIds.indexOf(item)]?.id))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.$confirm("确认保存数据?","提示").then(_ => {
|
|
|
|
|
let areaIds = this.$refs['elTree'].getCheckedNodes().map(item => item.id)
|
|
|
|
|
let oriAreaIds = this.originalArea.map(item => item.area_id)
|
|
|
|
|
let areaPromiseAll = [];
|
|
|
|
|
let areaDifArr = this.getArrDifference(areaIds,oriAreaIds)
|
|
|
|
|
areaDifArr.forEach(item => {
|
|
|
|
|
if(oriAreaIds.indexOf(item) === -1){
|
|
|
|
|
areaPromiseAll.push(saveArea({
|
|
|
|
|
area_id:item,
|
|
|
|
|
admin_id:Number(this.activeUser)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
if(areaIds.indexOf(item) === -1){
|
|
|
|
|
areaPromiseAll.push(destroyArea(this.originalArea[oriAreaIds.indexOf(item)]?.id))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let oriTypeIds = this.originalType.map(item => item.product_type_id)
|
|
|
|
|
let typePromiseAll = [];
|
|
|
|
|
let typeDifArr = this.getArrDifference(oriTypeIds,this.checkedTypes)
|
|
|
|
|
typeDifArr.forEach(item => {
|
|
|
|
|
if(oriTypeIds.indexOf(item) === -1){
|
|
|
|
|
typePromiseAll.push(saveType({
|
|
|
|
|
product_type_id:item,
|
|
|
|
|
admin_id:Number(this.activeUser)
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
if(this.checkedTypes.indexOf(item) === -1){
|
|
|
|
|
typePromiseAll.push(destroyType(this.originalType[oriTypeIds.indexOf(item)]?.id))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
let submitUser = this.users.find(i => i.id == this.activeUser)
|
|
|
|
|
if (!submitUser) {
|
|
|
|
|
this.$message.warning("用户不存在")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
delete submitUser.village
|
|
|
|
|
submitUser.village_code = this.$refs['newElTree']?.getCheckedNodes()?.map(i => i.code)?.toString() || ""
|
|
|
|
|
Promise.all([...areaPromiseAll,...typePromiseAll,save(submitUser)]).then(res => {
|
|
|
|
|
this.getAdminTypes()
|
|
|
|
|
this.getAdminAreas()
|
|
|
|
|
|
|
|
|
|
this.$message({
|
|
|
|
|
type:'success',
|
|
|
|
|
message:'保存成功'
|
|
|
|
|
let submitUser = this.users.find(i => i.id == this.activeUser)
|
|
|
|
|
if (!submitUser) {
|
|
|
|
|
this.$message.warning("用户不存在")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
delete submitUser.village
|
|
|
|
|
submitUser.village_code = this.$refs['newElTree']?.getCheckedNodes()?.map(i => i.code)?.toString() || ""
|
|
|
|
|
Promise.all([...areaPromiseAll,...typePromiseAll,save(submitUser)]).then(res => {
|
|
|
|
|
this.getAdminTypes()
|
|
|
|
|
this.getAdminAreas()
|
|
|
|
|
this.getUsers()
|
|
|
|
|
|
|
|
|
|
this.$message({
|
|
|
|
|
type:'success',
|
|
|
|
|
message:'保存成功'
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|