From 73379c4c734bae73a799a65954536fa41fb83e56 Mon Sep 17 00:00:00 2001
From: zhaoxiaohao <913652501@qq.com>
Date: Mon, 10 Aug 2020 09:05:13 +0800
Subject: [PATCH] c端 不添加数据user
---
kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/doctor_form.html | 223 +++++++++++++++++++++++++++++--------------------------
1 files changed, 119 insertions(+), 104 deletions(-)
diff --git a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/doctor_form.html b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/doctor_form.html
index c741722..ba26922 100644
--- a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/doctor_form.html
+++ b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/doctor_form.html
@@ -54,10 +54,10 @@
</div>
</div>
<div class="layui-inline">
- <label class="layui-form-label">角色</label>
+ <label class="layui-form-label">Email</label>
<div class="layui-input-block" style="width: 150px;">
- <select name="roleId" xm-select="roleId" lay-verify="required">
- </select>
+ <input name="doctorEmail" type="text" class="layui-input" maxlength="20" lay-verify="required|email"
+ required />
</div>
</div>
</div>
@@ -77,11 +77,11 @@
<input name="doctorOtherLink" type="text" class="layui-input" maxlength="20" />
</div>
</div>
- <div class="layui-inline">
- <label class="layui-form-label">Email</label>
+ <div class="layui-inline" id="roleId_div">
+ <label class="layui-form-label">角色</label>
<div class="layui-input-block" style="width: 150px;">
- <input name="doctorEmail" type="text" class="layui-input" maxlength="20" lay-verify="required|email"
- required />
+ <select name="roleId" xm-select="roleId">
+ </select>
</div>
</div>
</div>
@@ -129,27 +129,24 @@
</div>
</div>
</div>
- <div style="display:flex">
+ <div style="display:flex" class="account">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">登录帐号</label>
<div class="layui-input-block" style="width: 150px;">
- <input name="username" id="username" readonly type="text" class="layui-input" maxlength="20"
- lay-verify="required" required />
+ <input name="username" id="username" readonly type="text" class="layui-input" maxlength="20" />
</div>
</div>
<div class="layui-inline" id="password_div">
<label class="layui-form-label">登录密码</label>
<div class="layui-input-block" style="width: 150px;">
- <input name="password" type="password" id="password" class="layui-input" maxlength="20"
- lay-verify="required|phone" required />
- </div>
- </div>
+ <input name="password" type="password" id="password" class="layui-input" maxlength="20" />
+ </div>
+ </div>
<div class="layui-inline" id="passwordSure_div">
<label class="layui-form-label">确认密码</label>
<div class="layui-input-block" style="width: 150px;">
- <input name="passwordSure" type="password" id="passwordSure" lay-verify="required|confirmPass" class="layui-input"
- maxlength="20" />
+ <input name="passwordSure" type="password" id="passwordSure" class="layui-input" maxlength="20" />
</div>
</div>
@@ -215,9 +212,10 @@
var $ = layui.jquery;
-
+ //医生管理员
+ var guanliyuan_role = undefined;
//获取角色
- var get_role = function () {
+ var get_role = function (flag) {
admin.req('api-user/findByMap?tenant_id=hospital', {}, function (data) {
layer.closeAll('loading');
if (0 == data.code) {
@@ -229,22 +227,16 @@
value: data.data[i].id
});
}
+ guanliyuan_role = data.data[0].id;
formSelects.data('roleId', 'local', {
arr: roleSelectData
});
-
// 回显user数据
- var user = admin.getTempData('t_user');
- $('#user-form').attr('method', 'POST');
- if (user) {
- form.val('user-form', user);
- $('#user-form').attr('method', 'POST');
- var rds = new Array();
- for (var i = 0; i < user.roles.length; i++) {
- rds.push(user.roles[i].id);
- }
- formSelects.value('roleId', rds);
+ var doctor = admin.getTempData('t_doctor');
+ if (doctor.roles) {
+ formSelects.value('roleId', doctor.roles);
}
+
} else {
layer.msg('获取角色失败', {
icon: 2,
@@ -252,6 +244,16 @@
});
}
}, 'GET');
+ }
+ /*
+ * 验证手机号码
+ */
+ function validatorTel(content) {
+
+ // 正则验证格式
+ eval("var reg = /^1[34578]\\d{9}$/;");
+ var flag=RegExp(reg).test(content)
+ return flag;
}
//判断用户名是否被使用
var username_is_usered = function (username_id) {
@@ -262,7 +264,7 @@
if (data.code == 0) {
if (data.data > 0) {
$("#" + username_id).val("")
- layer.msg("该登录帐号已经使用", {
+ layer.msg("该手机号已经使用", {
icon: 2,
time: 2000
})
@@ -275,84 +277,36 @@
}
}, 'post');
}
- // // 显示编辑弹窗
- // var showEditModel = function (data, flag) {
- // var title = "";
- // if (flag == 1) {
- // title = "查看详情";
- // } else if (flag == 2) {
- // title = "新增";
- // } else if (flag == 3) {
- // title = "编辑";
- // }
-
- // layer.open({
- // type: 1,
- // title: title,
- // area: '650px',
- // offset: '120px',
- // content: $('#app-model').html(),
- // success: function () {
- // $('#app-form')[0].reset();
- // $('#app-form').attr('method', 'POST');
- // //将医院的数据保存到下拉表
- // let selected = false;
- // //将科室的数据绑定到里面
- // if (flag != 2) {
- // getdepartment(data.hospitalId);
- // }
- // if (data) {
- // if (data.isAnswer) {
- // $("#isAnswer-shi").attr('checked', true);
- // } else {
- // $("#isAnswer-fou").attr('checked', true);
- // }
-
- // if (data.isSigning) {
- // $("#isSigning-shi").attr('checked', true);
- // } else {
- // $("#isSigning-fou").attr('checked', true);
- // }
-
- // if (data.isTop) {
- // $("#isTop-shi").attr('checked', true);
- // } else {
- // $("#isTop-fou").attr('checked', true);
- // }
-
- // if (data.doctorState) {
- // $("#doctorState-shi").attr('checked', true);
- // } else {
- // $("#doctorState-fou").attr('checked', true);
- // }
- // form.val('app-form', data);
- // if (flag == 1) {
- // //将确定隐藏 doctorState-shi
- // $("#sure").hide();
- // $("#phonto").hide();
- // //将所有的设置为只读
- // $('#app-form').find('input').attr('readonly', true);
- // $('#app-form').find('select,input[type="radio"]').attr('disabled',
- // true);
- // } else {
- // $("#sure").show();
- // $('#app-form').attr('method', 'POST');
- // }
- // }
- // }
- // });
- // };
// 表单提交事件
form.on('submit(user-form-submit)', function (data) {
layer.load(2);
+ debugger
data.field.hospitalId = $("#hospitalId").val();
if (data.field.roleId != null && data.field.roleId != "") {
data.field.roles = data.field.roleId.split(',');
}
+ if ($("#doctorType").val() == 2) {
+ //将关于密码的的去掉
+ data.field.username = "";
+ data.field.password = "";
+ data.field.passwordSure = "";
+ } else {
+ if (data.field.roles.length == 0) {
+ layer.msg("请选择角色");
+ return
+ }
+ if (data.field.roles.includes(guanliyuan_role)) {
+ data.field.isAdminUser = true;
+ } else {
+ data.field.isAdminUser = false;
+ }
+ }
+ // guanliyuan_role
// data.field.hospitalId = ""+data.field.hospitalId;
data.field.roleId = null;
+
admin.req('api-user/sysdoctor', JSON.stringify(data.field), function (data) {
layer.closeAll('loading');
if (data.code == 0) {
@@ -413,7 +367,7 @@
//职称添加数据
var getZhiCheng = function () {
admin.req('api-user/sysdictionaries/findAll', JSON.stringify({
- dictionariesClassId: "DOCTOR_RANK"
+ dictionariesClassId: "1248150699682988034"
}), function (data) {
layer.closeAll('loading');
if (0 === data.code) {
@@ -497,16 +451,39 @@
layer.closeAll('loading');
}
});
+ //将密码隐藏
+ $(".account").hide();
+ //将密码置空
+ $("#password").val("");
form.render();
$("#username").blur(function () {
username_is_usered("username");
})
- $("#doctorTel-add").blur(function () {
+
+ //医生类型的选择事件
+ // form.on('select(doctorType)', function (data) {
+ // // console.log("eeeeeeeeeeeeeeeee");
+ // // var doctor = admin.getTempData('t_doctor');
+ // // debugger
+ // // console.log("doctordoctordoctordoctordoctor",doctor);
+ // var doctorType = $('#doctorType').val();
+ // //将密码项取消
+ // if (doctorType == 2) {
+ // $(".account").hide();
+ // } else {
+ // $(".account").show();
+ // }
+ // })
+ };
+ $("#doctorTel-add").blur(function () {
$("#username").val($("#doctorTel-add").val())
+ var doctorTel_add = $("#doctorTel-add").val();
+ debugger
+ if (!validatorTel(doctorTel_add)) {
+ layer.msg("请输入正确的手机号");
+ }
username_is_usered("username");
})
- };
-
//自动完成-医院名称
autocomplete.render({
elem: $('#hospitalName')[0],
@@ -521,6 +498,33 @@
getdepartment(resp.id);
}
});
+ //医生类型的选择事件
+ form.on('select(doctorType)', function (data) {
+ var doctor = admin.getTempData('t_doctor');
+ var doctorType = $('#doctorType').val();
+ if (doctor.doctorType == 2 && doctorType == 2) {
+ $(".account").hide();
+ $("#roleId_div").hide()
+ } else if (doctor.doctorType == 2 && doctorType != 2) {
+ $(".account").show();
+ $("#password_div").show();
+ $("#passwordSure_div").show();
+ $("#roleId_div").show()
+ if (doctor.username == null) {
+ $("#username").val(doctor.doctorTel);
+ form.render();
+ }
+ } else if (doctor.doctorType != 2 && doctorType != 2) {
+ $(".account").show();
+ $("#password_div").hide();
+ $("#passwordSure_div").hide();
+ $("#roleId_div").show()
+ } else if (doctor.doctorType != 2 && doctorType == 2) {
+ $(".account").hide();
+ $("#roleId_div").hide()
+ }
+
+ })
//数据的回显
var doctor = admin.getTempData('t_doctor');
$('#app-form-add').attr('method', 'POST');
@@ -532,17 +536,28 @@
//获取销售代表
getXiaoShouDaiBiao();
//获取角色
- get_role();
+ get_role(doctor.isAdminUser);
+
form.val('app-form-add', doctor);
$("#hospitalId").val(doctor.hospitalId);
$("#password_div").hide();
$("#passwordSure_div").hide();
+
+ //将密码项取消
+ if (doctor.doctorType == 2) {
+ $(".account").hide();
+ $("#roleId_div").hide()
+ } else {
+ $(".account").show();
+ $("#roleId_div").show()
+ }
$('#demo2').append('<img src="' + doctor.doctorLogo +
- '" width="50px" height="50px" alt="' + "name" +
- '" class="layui-upload-img">')
+ '" width="50px" height="50px" alt="' + "name" +
+ '" class="layui-upload-img">')
$("#password").removeAttr("lay-verify")
$("#password").removeAttr("required")
$("#passwordSure").removeAttr("lay-verify")
+
form.render();
} else {
loadEditData();
--
Gitblit v1.8.0