lex-xin 3 years ago
parent
commit
9e5d08a4f5
1 changed files with 178 additions and 169 deletions
  1. 178 169
      src/views/visitManager/addVisit.vue

+ 178 - 169
src/views/visitManager/addVisit.vue

@@ -153,175 +153,184 @@ export default {
 				this.$toast(res.msg)
 			}
 
-			if(this.id) {
-				setLoading(true)
-				let queryInfo = await visitGetInfo({ id: this.id })
-				const queryResult = queryInfo.data
-				let form = this.form
-				setLoading(false)
-				if(queryResult.code == 200) {
-					let tempData = queryResult.data
-					this.studentName = tempData.studentName
-					form.studentId = tempData.studentId
-					form.type = tempData.type
-					form.purpose = tempData.purpose
-					form.overview = tempData.overview
-					form.feedback = tempData.feedback
-					form.visitTime = dayjs(tempData.visitTime).format('YYYY-MM-DD')
-					form.visiterType = tempData.visiterType
-				} else {
-					this.$toast(res.msg)
-				}
-			}
-		},
-		async onSubmit() {
-			const form = this.form
-			if(!form.studentId) {
-				this.$toast('请选择学员')
-				return
-			} else if(!form.type) {
-				this.$toast('请选择回访类型')
-				return
-			} else if(!form.purpose) {
-				this.$toast('请选择回访目的')
-				return
-			} else if(!form.overview) {
-				this.$toast('请输入当前学生情况')
-				return
-			} else if(!form.feedback) {
-				this.$toast('请输入沟通后家长反馈')
-				return
-			} else if(!form.visitTime) {
-				this.$toast('请选择回访时间')
-				return
-			}
-			if(this.clickStatus) {
-				return
-			}
-			this.clickStatus = true
-			setLoading(true)
-			let res = await visitAdd(form)
-			let result = res.data
-			setLoading(false)
-			if(result.code == 200) {
-				this.$toast('添加成功')
-				this.$router.push('visitList')
-			} else {
-				this.$toast(result.msg)
-				this.clickStatus = false
-				return
-			}
-		},
-		onCheckStudent() {
-			if(this.id) {
-				return
-			}
-			this.statusList.studentStatus = true
-		},
-		onChange(type) {
-			if(this.id) {
-				return
-			}
-			let visit = this.visit
-			let form = this.form
-			if(type == 'type') {
-				visit.data = this.typeList
-			} else if(type == 'purpose') {
-				if(form.type == '其它') {
-					visit.data = [{name: '其它'}]
-				} else if(form.type == '课程推荐') {
-					visit.data = [{name: '新课推荐'}, {name: '续费提醒'}]
-				} else if(form.type == '常规回访') {
-					visit.data = [{name: '课后及作业回访'}, {name: '练习及乐团表现'}]
-				} else {
-					this.$toast('请选择回访类型')
-					return
-				}
-			}
-			visit.status = true
-			visit.type = type
-		},
-		onSearch() {
-			this.params.page = 1
-			this.dataList = []
-			this.dataShow = true
-			this.loading = true
-			this.finished = false
-			this.getStudent()
-		},
-		onCheckboxSelect(item) {
-			this.radioSelect = item.userId
-			this.radioSelectName = item.userName
-		},
-		onPopupCancel () {
-			this.statusList.studentStatus = false
-		},
-		onPopupSubmit() {
-			this.form.studentId = this.radioSelect
-			this.studentName = this.radioSelectName
-			this.statusList.studentStatus = false
-		},
-		onCurrentConfirm(value) {
-			if(value) {
-				this.form.visitTime = dayjs(value).format('YYYY-MM-DD')
-			}
-			this.dataForm.status = false
-		},
-		onEnListShow() {
-			if(this.id) {
-				return
-			}
-			this.dataForm.status = true
-		},
-		getStudent() {
-			let params = this.params
-			queryStudentsWithTeacher(params).then(res => {
-				let result = res.data
-				this.loading = false
-				if (result.code == 200 && result.data) {
-					params.page = result.data.pageNo
-					this.dataList = this.dataList.concat(result.data.rows)
-					if (params.page >= result.data.totalPage) {
-						this.finished = true
-					}
-					this.params.page++
-				} else {
-					this.finished = true
-				}
-				// 判断是否有数据
-				if (this.dataList.length <= 0) {
-					this.dataShow = false
-				}
-			})
-		},
-		onModeSelect(value) {
-			let visit = this.visit
-			let form = this.form
-			if(visit.type == 'type') {
-				form.type = value.name
-				form.purpose = null
-			} else if(visit.type == 'purpose') {
-				form.purpose = value.name
-			}
-			visit.status = false
-		},
-		formatter(type, value) {
-			if (type === 'year') {
-				return `${value}年`;
-			} else if (type === 'month') {
-				return `${value}月`
-			} else if (type === 'day') {
-				return `${value}日`
-			}
-			return value;
-		},
-		desensitPhone(phone) { // 手机号脱敏
-			let first = phone.substr(0, 3)
-			let last  = phone.substr(-4)
-			return first + '****' + last
-		}
-	}
-}
+      if (this.id) {
+        setLoading(true);
+        let queryInfo = await visitGetInfo({ id: this.id });
+        const queryResult = queryInfo.data;
+        let form = this.form;
+        setLoading(false);
+        if (queryResult.code == 200) {
+          let tempData = queryResult.data;
+          this.studentName = tempData.studentName;
+          form.studentId = tempData.studentId;
+          form.type = tempData.type;
+          form.purpose = tempData.purpose;
+          form.overview = tempData.overview;
+          form.feedback = tempData.feedback;
+          form.visitTime = dayjs(tempData.visitTime).format("YYYY年MM月DD日");
+          form.visiterType = tempData.visiterType;
+        } else {
+          this.$toast(res.msg);
+        }
+      }
+    },
+    async onSubmit() {
+      let form = this.form;
+      if (!form.studentId) {
+        this.$toast("请选择学员");
+        return;
+      } else if (!form.type) {
+        this.$toast("请选择回访类型");
+        return;
+      } else if (!form.purpose) {
+        this.$toast("请选择回访目的");
+        return;
+      } else if (!form.overview) {
+        this.$toast("请输入当前学生情况");
+        return;
+      } else if (!form.feedback) {
+        this.$toast("请输入沟通后家长反馈");
+        return;
+      } else if (!form.visitTime) {
+        this.$toast("请选择回访时间");
+        return;
+      }
+      if (this.clickStatus) {
+        return;
+      }
+      this.clickStatus = true;
+      setLoading(true);
+      // let visitTime = this.form.visitTime.replace(/[^\d]/g,'/');
+      // let someDate = new Date(visitTime)
+      let { visitTime, ...more } =  this.from
+      visitTime = dayjs(this.dataForm.currentDate).format("YYYY-MM-DD")
+      let params = {
+        ...more,
+        visitTime
+      }
+      let res = await visitAdd({ ...params });
+      let result = res.data;
+      setLoading(false);
+      if (result.code == 200) {
+        this.$toast("添加成功");
+        this.$router.push("visitList");
+      } else {
+        this.$toast(result.msg);
+        this.clickStatus = false;
+        return;
+      }
+    },
+    onCheckStudent() {
+      if (this.id) {
+        return;
+      }
+      this.statusList.studentStatus = true;
+    },
+    onChange(type) {
+      if (this.id) {
+        return;
+      }
+      let visit = this.visit;
+      let form = this.form;
+      if (type == "type") {
+        visit.data = this.typeList;
+      } else if (type == "purpose") {
+        if (form.type == "其它") {
+          visit.data = [{ name: "其它" }];
+        } else if (form.type == "课程推荐") {
+          visit.data = [{ name: "新课推荐" }, { name: "续费提醒" }];
+        } else if (form.type == "常规回访") {
+          visit.data = [{ name: "课后及作业回访" }, { name: "练习及乐团表现" }];
+        } else {
+          this.$toast("请选择回访类型");
+          return;
+        }
+      }
+      visit.status = true;
+      visit.type = type;
+    },
+    onSearch() {
+      this.params.page = 1;
+      this.dataList = [];
+      this.dataShow = true;
+      this.loading = true;
+      this.finished = false;
+      this.getStudent();
+    },
+    onCheckboxSelect(item) {
+      this.radioSelect = item.userId;
+      this.radioSelectName = item.userName;
+    },
+    onPopupCancel() {
+      this.statusList.studentStatus = false;
+    },
+    onPopupSubmit() {
+      this.form.studentId = this.radioSelect;
+      this.studentName = this.radioSelectName;
+      this.statusList.studentStatus = false;
+    },
+    onCurrentConfirm(value) {
+      if (value) {
+        this.form.visitTime = dayjs(value).format("YYYY年MM月DD日");
+      }
+      this.dataForm.status = false;
+    },
+    onEnListShow() {
+      if (this.id) {
+        return;
+      }
+      this.dataForm.status = true;
+    },
+    getStudent() {
+      let params = this.params;
+      queryStudentsWithTeacher(params).then((res) => {
+        let result = res.data;
+        this.loading = false;
+        if (result.code == 200 && result.data) {
+          params.page = result.data.pageNo;
+          this.dataList = this.dataList.concat(result.data.rows);
+          if (params.page >= result.data.totalPage) {
+            this.finished = true;
+          }
+          this.params.page++;
+        } else {
+          this.finished = true;
+        }
+        // 判断是否有数据
+        if (this.dataList.length <= 0) {
+          this.dataShow = false;
+        }
+      });
+    },
+    onModeSelect(value) {
+      let visit = this.visit;
+      let form = this.form;
+      if (visit.type == "type") {
+        form.type = value.name;
+        form.purpose = null;
+      } else if (visit.type == "purpose") {
+        form.purpose = value.name;
+      }
+      visit.status = false;
+    },
+    formatter(type, value) {
+      if (type === "year") {
+        return `${value}年`;
+      } else if (type === "month") {
+        return `${value}月`;
+      } else if (type === "day") {
+        return `${value}日`;
+      }
+      return value;
+    },
+    desensitPhone(phone) {
+      // 手机号脱敏
+      let first = phone.substr(0, 3);
+      let last = phone.substr(-4);
+      return first + "****" + last;
+    },
+  },
+};
 </script>
 <style lang='less' scoped>
 	@import url("../../assets/commonLess/variable.less");