|
|
@ -20,8 +20,9 @@ |
|
|
|
<div :class="['line', { active: active == 'dayShift' }]"> |
|
|
|
<p @click="active = 'dayShift'">白天值班:</p> |
|
|
|
<div> |
|
|
|
<p v-for="(item, index) in dayShift" :key="`${item.id}_${index}`" @click="removeDutyPerson(item)">{{ |
|
|
|
item.name }}</p> |
|
|
|
<p v-for="(item, index) in dayShift" :key="`${item.id}_${index}`" @click="removeDutyPerson(item)"> |
|
|
|
{{ item.name }} |
|
|
|
</p> |
|
|
|
<div class="no-data" v-if="!dayShift.length">未添加人员</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -29,8 +30,9 @@ |
|
|
|
<div :class="['line', { active: active == 'graveyardShift' }]"> |
|
|
|
<p @click="active = 'graveyardShift'">晚上值班:</p> |
|
|
|
<div> |
|
|
|
<p v-for="(item, index) in graveyardShift" :key="`${index}_${item.id}`" @click="removeDutyPerson(item)">{{ |
|
|
|
item.name }}</p> |
|
|
|
<p v-for="(item, index) in graveyardShift" :key="`${index}_${item.id}`" @click="removeDutyPerson(item)"> |
|
|
|
{{ item.name }} |
|
|
|
</p> |
|
|
|
<div class="no-data" v-if="!graveyardShift.length">未添加人员</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -141,7 +143,8 @@ export default { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
chooseDutyPerson(item) { |
|
|
|
const hasInserted = this[this.active].find(_item => _item.id === item.id); |
|
|
|
|
|
|
|
const hasInserted = this[this.active].find(_item => _item.employeesId === item.id || _item.id === item.id); |
|
|
|
|
|
|
|
if (hasInserted) return Message.warning("人员已存在"); |
|
|
|
|
|
|
@ -150,11 +153,11 @@ export default { |
|
|
|
removeDutyPerson(item) { |
|
|
|
const index = this[this.active].findIndex(_item => _item.id === item.id); |
|
|
|
|
|
|
|
if (index === -1) return Message.warning("人员不存在"); |
|
|
|
if (index === -1) return;//Message.warning("人员不存在"); |
|
|
|
|
|
|
|
this[this.active].splice(index, 1); |
|
|
|
}, |
|
|
|
getPeopleList(id) { |
|
|
|
getPeopleList(stationId) { |
|
|
|
this.peopleList = []; |
|
|
|
|
|
|
|
this.dayShift = []; |
|
|
@ -163,32 +166,44 @@ export default { |
|
|
|
const closeMessage = loadingMessage({ message: "人员获取中..." }); |
|
|
|
|
|
|
|
request({ |
|
|
|
// url: `/business/employees/list`, |
|
|
|
// method: "GET", |
|
|
|
// params: { |
|
|
|
// organizationId: id |
|
|
|
// } |
|
|
|
url: `/business/shifts/byStation`, |
|
|
|
method: "POST", |
|
|
|
data: { |
|
|
|
station: this.data.station, |
|
|
|
date: this.data.date, |
|
|
|
url: `/business/employees/list`, |
|
|
|
method: "GET", |
|
|
|
params: { |
|
|
|
organizationId: stationId |
|
|
|
} |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
|
if (result.code != 200) return Message.error("人员获取失败"); |
|
|
|
if (!result.data?.length) return Message.warning("该驻点下暂无人员"); |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return Message.error("人员获取失败"); |
|
|
|
if (!result.rows?.length) return Message.warning("该驻点下暂无人员"); |
|
|
|
|
|
|
|
Message.success("人员获取成功") |
|
|
|
// Message.success("人员获取成功") |
|
|
|
|
|
|
|
this.peopleList = result.data; |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
this.peopleList = result.rows; |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("人员获取失败") |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
|
|
|
|
//修改时,获取已排版人员列表 |
|
|
|
if (this.data) { |
|
|
|
request({ |
|
|
|
url: `/business/shifts/byStation`, |
|
|
|
method: "POST", |
|
|
|
data: { |
|
|
|
station: this.data.station, |
|
|
|
date: this.data.date, |
|
|
|
} |
|
|
|
}).then((result) => { |
|
|
|
console.log("result.data:", result.data); |
|
|
|
this.dayShift = result.data.filter(item => item.scheduling === "1"); |
|
|
|
console.log("this.dayShift11:", this.dayShift); |
|
|
|
this.graveyardShift = result.data.filter(item => item.scheduling === "2"); |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("人员获取失败") |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
updateData(data) { |
|
|
|
return request({ |
|
|
@ -197,13 +212,14 @@ export default { |
|
|
|
data: { |
|
|
|
date: data.date, |
|
|
|
employeesJson: [ |
|
|
|
...this.dayShift.map(({ id }) => ({ |
|
|
|
employeesId: id, |
|
|
|
...this.dayShift.map((item) => ({ |
|
|
|
//添加和修改时,人员id字段来源不一样 |
|
|
|
employeesId: item.employeesId ? item.employeesId : item.id, |
|
|
|
scheduling: 1, |
|
|
|
station: data.station |
|
|
|
})), |
|
|
|
...this.graveyardShift.map(({ id }) => ({ |
|
|
|
employeesId: id, |
|
|
|
...this.graveyardShift.map((item) => ({ |
|
|
|
employeesId: item.employeesId ? item.employeesId : item.id, |
|
|
|
scheduling: 2, |
|
|
|
station: data.station |
|
|
|
})), |
|
|
@ -214,26 +230,24 @@ export default { |
|
|
|
async submit() { |
|
|
|
let data = this.data; |
|
|
|
|
|
|
|
if (this.$refs.FormRef) |
|
|
|
if (this.$refs.FormRef) { |
|
|
|
data = await this.$refs.FormRef.validate(); |
|
|
|
console.log("%c [ data ]-202-「ModifyDutyInformationTable.vue」", "font-size:15px; background:#9afce6; color:#deffff;", data, this.value2); |
|
|
|
} |
|
|
|
// console.log("%c [ data ]-202-「ModifyDutyInformationTable.vue」", "font-size:15px; background:#9afce6; color:#deffff;", data, this.value2); |
|
|
|
|
|
|
|
const closeMessage = loadingMessage({ message: "正在保存值班信息..." }); |
|
|
|
const closeMessage = loadingMessage({ message: "正在保存值班信息111..." }); |
|
|
|
|
|
|
|
if (!this.data) { |
|
|
|
this.updateData(data) |
|
|
|
.then((result) => { |
|
|
|
console.log("%c [ result ]-217-「ModifyDutyInformationTable.vue」", "font-size:15px; background:#335cf6; color:#77a0ff;", result); |
|
|
|
this.updateData(data).then((result) => { |
|
|
|
// console.log("%c [ result ]-217-「ModifyDutyInformationTable.vue」", "font-size:15px; background:#335cf6; color:#77a0ff;", result); |
|
|
|
if (result.code != 200) return Message.error("保存失败"); |
|
|
|
|
|
|
|
Message.success("保存成功"); |
|
|
|
|
|
|
|
this.$emit('close') |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("保存失败") |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
return; |
|
|
@ -244,31 +258,71 @@ export default { |
|
|
|
(this.data.dayShift || []).forEach(item => { |
|
|
|
const findIndex = this.dayShift.findIndex(_item => _item.id === item.id); |
|
|
|
|
|
|
|
if (findIndex === -1) deleteIds.push(item.delId) |
|
|
|
if (findIndex === -1) deleteIds.push(item.id) |
|
|
|
}); |
|
|
|
(this.data.graveyardShift || []).forEach(item => { |
|
|
|
const findIndex = this.graveyardShift.findIndex(_item => _item.id === item.id); |
|
|
|
|
|
|
|
if (findIndex === -1) deleteIds.push(item.delId) |
|
|
|
|
|
|
|
if (findIndex === -1) deleteIds.push(item.id) |
|
|
|
}) |
|
|
|
|
|
|
|
Promise.allSettled([ |
|
|
|
deleteIds?.length ? request({ |
|
|
|
|
|
|
|
// Promise.allSettled([ |
|
|
|
// deleteIds?.length ? request({ |
|
|
|
// url: `/business/shifts/${deleteIds.join()}`, |
|
|
|
// method: "DELETE", |
|
|
|
// data: {} |
|
|
|
// }) : Promise.resolve(), |
|
|
|
// this.updateData(this.data) |
|
|
|
// ]).then(([del, update]) => { |
|
|
|
// if (del.status === 'rejected' && update.status === 'rejected') return Message.error("修改失败"); |
|
|
|
// if (del.value?.code != '200' && update.value?.code != '200') return Message.error("修改失败"); |
|
|
|
|
|
|
|
// this.$emit('close') |
|
|
|
// }).finally(() => { |
|
|
|
// closeMessage(); |
|
|
|
// }) |
|
|
|
|
|
|
|
//如果有需要删除的人员,先删除,再更新 |
|
|
|
if(deleteIds?.length){ |
|
|
|
request({ |
|
|
|
url: `/business/shifts/${deleteIds.join()}`, |
|
|
|
method: "DELETE", |
|
|
|
data: {} |
|
|
|
}) : Promise.resolve(), |
|
|
|
this.updateData(this.data) |
|
|
|
]) |
|
|
|
.then(([del, update]) => { |
|
|
|
if (del.status === 'rejected' && update.status === 'rejected') return Message.error("修改失败"); |
|
|
|
if (del.value?.code != '200' && update.value?.code != '200') return Message.error("修改失败"); |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return Message.error("修改失败"); |
|
|
|
|
|
|
|
this.updateData(this.data).then((result) => { |
|
|
|
if (result.code != 200) return Message.error("修改失败"); |
|
|
|
|
|
|
|
Message.success("修改成功"); |
|
|
|
|
|
|
|
this.$emit('close') |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("修改失败") |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("删除失败") |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
this.updateData(this.data).then((result) => { |
|
|
|
if (result.code != 200) return Message.error("修改失败"); |
|
|
|
|
|
|
|
Message.success("修改成功"); |
|
|
|
|
|
|
|
this.$emit('close') |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
}).catch((err) => { |
|
|
|
Message.error("修改失败") |
|
|
|
}).finally(() => { |
|
|
|
closeMessage(); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|