|
@@ -229,7 +229,10 @@ export default {
|
|
|
// 显示谱系新增 or 修改面板
|
|
|
this.visible = true
|
|
|
if (row) {
|
|
|
- this.form = row
|
|
|
+ for (let key of Object.keys(this.form)) {
|
|
|
+ this.form[key] = row[key]
|
|
|
+ }
|
|
|
+ this.form.id = row.id
|
|
|
}
|
|
|
},
|
|
|
// 选择n个养殖员
|
|
@@ -280,92 +283,80 @@ export default {
|
|
|
formSubmit () {
|
|
|
if (this.form.id) {
|
|
|
// 修改
|
|
|
- if (this.confirmInput()) {
|
|
|
- // 检查入场时间、离开场时间
|
|
|
- if (!this.confirmJobStatus()) {
|
|
|
- return
|
|
|
- }
|
|
|
- // 进行修改操作
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl('/management/employee/update'),
|
|
|
- method: 'post',
|
|
|
- data: this.$http.adornData({
|
|
|
- id: this.form.id,
|
|
|
- position: this.form.position,
|
|
|
- approachTime: this.form.approachTime,
|
|
|
- departureTime: this.form.departureTime,
|
|
|
- jobStatus: this.form.jobStatus
|
|
|
- })
|
|
|
- }).then(result => {
|
|
|
- if (result.data.code === 0) {
|
|
|
- this.resetForm();
|
|
|
- this.visible = false;
|
|
|
- this.$message({
|
|
|
- message: '成功修改养殖员信息',
|
|
|
- type: 'success',
|
|
|
- duration: 1000
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$message.error('修改养殖员信息失败');
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- // 请输入完整
|
|
|
- this.$confirm(`请输入完整`, '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- return
|
|
|
- }).catch(() => {})
|
|
|
+ if (!this.confirmComplete()) {
|
|
|
+ return
|
|
|
}
|
|
|
- } else {
|
|
|
- // 新增
|
|
|
- if (this.confirmInput(1)) {
|
|
|
- // 检查入场时间、立场时间、当前在岗
|
|
|
- if (!this.confirmJobStatus()) {
|
|
|
- return
|
|
|
- }
|
|
|
- // 进行新增操作
|
|
|
- this.$http({
|
|
|
- url: this.$http.adornUrl('/management/employee/save'),
|
|
|
- method: 'post',
|
|
|
- data: this.$http.adornData({
|
|
|
- name: this.form.name,
|
|
|
- position: this.form.position,
|
|
|
- approachTime: this.form.approachTime,
|
|
|
- departureTime: this.form.departureTime,
|
|
|
- jobStatus: this.form.jobStatus
|
|
|
- })
|
|
|
- }).then(result => {
|
|
|
- if (result.data.code === 0) {
|
|
|
- this.resetForm();
|
|
|
- this.visible = false;
|
|
|
- this.$message({
|
|
|
- message: '成功添加养殖员信息',
|
|
|
- type: 'success',
|
|
|
- duration: 1000
|
|
|
- })
|
|
|
- // TODO: 新增的pageIndex修正
|
|
|
- } else {
|
|
|
- this.$message.error('添加养殖员信息失败');
|
|
|
- }
|
|
|
+ // 检查入场时间、离开场时间
|
|
|
+ if (!this.confirmJobStatus()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 进行修改操作
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl('/management/employee/update'),
|
|
|
+ method: 'post',
|
|
|
+ data: this.$http.adornData({
|
|
|
+ id: this.form.id,
|
|
|
+ position: this.form.position,
|
|
|
+ approachTime: this.form.approachTime,
|
|
|
+ departureTime: this.form.departureTime,
|
|
|
+ jobStatus: this.form.jobStatus
|
|
|
})
|
|
|
- } else {
|
|
|
- // 请输入完整
|
|
|
- this.$confirm(`请输入完整`, '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- return
|
|
|
- }).catch(() => {})
|
|
|
+ }).then(result => {
|
|
|
+ if (result.data.code === 0) {
|
|
|
+ this.resetForm();
|
|
|
+ this.visible = false;
|
|
|
+ this.$message({
|
|
|
+ message: '成功修改养殖员信息',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message.error('修改养殖员信息失败');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ /** 新增 */
|
|
|
+ // 输入是否完整
|
|
|
+ if (!this.confirmComplete(1)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 检查入场时间、立场时间、当前在岗
|
|
|
+ if (!this.confirmJobStatus()) {
|
|
|
+ return
|
|
|
}
|
|
|
+ // 进行新增操作
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl('/management/employee/save'),
|
|
|
+ method: 'post',
|
|
|
+ data: this.$http.adornData({
|
|
|
+ name: this.form.name,
|
|
|
+ position: this.form.position,
|
|
|
+ approachTime: this.form.approachTime,
|
|
|
+ departureTime: this.form.departureTime,
|
|
|
+ jobStatus: this.form.jobStatus
|
|
|
+ })
|
|
|
+ }).then(result => {
|
|
|
+ if (result.data.code === 0) {
|
|
|
+ // 新增pageIndex的修正
|
|
|
+ this.totalPage++
|
|
|
+ let pages = Math.ceil(this.totalPage / this.pageSize)
|
|
|
+ this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
|
|
|
+ this.resetForm();
|
|
|
+ this.visible = false;
|
|
|
+ this.$message({
|
|
|
+ message: '成功添加养殖员信息',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message.error('添加养殖员信息失败');
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
// 判断新增/修改时是否输入完整
|
|
|
- confirmInput (val) {
|
|
|
- val && (delete this.form.id, delete this.form.deleted, delete this.form.gmtCreate, delete this.form.gmtModified)
|
|
|
+ validComplete (val) {
|
|
|
+ val && (delete this.form.id)
|
|
|
for (let i in this.form) {
|
|
|
if (!this.form[i].toString()) {
|
|
|
return false
|
|
@@ -373,6 +364,20 @@ export default {
|
|
|
}
|
|
|
return true
|
|
|
},
|
|
|
+ // 如不完整,则提示
|
|
|
+ confirmComplete (val) {
|
|
|
+ if (this.validComplete(val)) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ this.$confirm(`请输入完整`, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ console.log('输入不完整');
|
|
|
+ }).catch(() => {})
|
|
|
+ return false
|
|
|
+ },
|
|
|
// 清空form
|
|
|
resetForm () {
|
|
|
for (let i in this.form) {
|