addPageSubPageSZDX.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <p class="inquire-button-one" @click="upDataButton">提交</p>
  3. </template>
  4. <script>
  5. import { addUserTeacher, putUserTeacherNew } from "@/api/system/user_teacher";
  6. export default {
  7. name: 'addPageSubPageSZDX',
  8. methods:{
  9. upDataButton(){
  10. let self = this;
  11. self.$parent.$refs["form"].validate(valid => {
  12. if (valid) {
  13. if(self.$parent.form.email){
  14. let re = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
  15. if(!re.test(self.$parent.form.email)){
  16. self.msgError('请输入正确的邮箱地址')
  17. return
  18. }
  19. }
  20. let list = self.$parent.toArray();
  21. let obj = JSON.parse(JSON.stringify(self.$parent.form));
  22. obj.permitMenus = [];
  23. if(obj.status == 0){
  24. for(let i=0;i<list.length;i++){
  25. let minObj = {
  26. menuId:list[i].menuId,
  27. }
  28. if(list[i].dataScope){
  29. minObj.dataScope = list[i].dataScope
  30. if(list[i].dataScope == 3){
  31. minObj.deptIds = list[i].deptIds;
  32. minObj.deptIdsList = list[i].deptIdsList;
  33. }
  34. }else{
  35. minObj.dataScope = 0
  36. }
  37. obj.permitMenus.push(minObj)
  38. }
  39. }
  40. if(self.$parent.propsData.userId){
  41. //修改
  42. obj.userId = self.$parent.propsData.userId;
  43. self.putUserTeacherNew(obj);
  44. }else{
  45. //发布
  46. self.addUserTeacher(obj);
  47. }
  48. }
  49. });
  50. },
  51. putUserTeacherNew(obj){
  52. let self = this;
  53. putUserTeacherNew(obj).then(response => {
  54. if(response.code == 200){
  55. self.msgSuccess(response.msg);
  56. self.$parent.outPageButton();
  57. }
  58. });
  59. },
  60. addUserTeacher(obj){
  61. let self = this;
  62. addUserTeacher(obj).then(response => {
  63. if(response.code == 200){
  64. self.msgSuccess(response.msg);
  65. self.$parent.outPageButton();
  66. }
  67. });
  68. },
  69. }
  70. }
  71. </script>
  72. <style scoped>
  73. </style>