addPageSubPagePublic.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: 'addPageSubPagePublic',
  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.roleIds = self.$parent.form.position?self.$parent.form.roleIds:[];
  23. // obj.position = obj.position+'';
  24. obj.permitMenus = [];
  25. if(obj.status == 0){
  26. for(let i=0;i<list.length;i++){
  27. let minObj = {
  28. menuId:list[i].menuId,
  29. }
  30. if(list[i].dataScope){
  31. minObj.dataScope = list[i].dataScope
  32. if(list[i].dataScope == 3){
  33. minObj.deptIds = list[i].deptIds;
  34. minObj.deptIdsList = list[i].deptIdsList;
  35. }
  36. }else{
  37. minObj.dataScope = 0
  38. }
  39. obj.permitMenus.push(minObj)
  40. }
  41. }
  42. if(self.$parent.propsData.userId){
  43. //修改
  44. obj.userId = self.$parent.propsData.userId;
  45. self.putUserTeacherNew(obj);
  46. }else{
  47. //发布
  48. self.addUserTeacher(obj);
  49. }
  50. }
  51. });
  52. },
  53. putUserTeacherNew(obj){
  54. let self = this;
  55. putUserTeacherNew(obj).then(response => {
  56. if(response.code == 200){
  57. self.msgSuccess(response.msg);
  58. self.$parent.outPageButton();
  59. }else if(response.code==205){
  60. self.$confirm(response.msg, "警告", {
  61. confirmButtonText: "确定",
  62. cancelButtonText: "取消",
  63. type: "warning"
  64. }).then(() => {
  65. // 确定
  66. self.$router.push({ path: '/comprehensive/laboratoryManagement/accessAuthorization' });
  67. }).catch(function() {
  68. // 取消
  69. self.$parent.outPageButton();
  70. });
  71. }
  72. });
  73. },
  74. addUserTeacher(obj){
  75. let self = this;
  76. addUserTeacher(obj).then(response => {
  77. if(response.code == 200){
  78. self.msgSuccess(response.msg);
  79. self.$parent.outPageButton();
  80. }else if(response.code==205){
  81. self.$confirm(response.msg, "警告", {
  82. confirmButtonText: "确定",
  83. cancelButtonText: "取消",
  84. type: "warning"
  85. }).then(() => {
  86. // 确定
  87. self.$router.push({ path: '/comprehensive/laboratoryManagement/accessAuthorization' });
  88. }).catch(function() {
  89. // 取消
  90. self.$parent.outPageButton();
  91. });
  92. }
  93. });
  94. },
  95. }
  96. }
  97. </script>
  98. <style scoped>
  99. </style>