123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299 |
- /*
- 功能说明:机构人员管理
- 负责人:王璐
- */
- var personnelObj = {
- personnelId: null,
- accountId: null,
- channelId: null,
- projectId: null,
- nature: null,
- list: null,
- IsAdmin: ""
- }
- function viewModel() {
- this.init = function () {
- //控件初始化
- $('#person').datagrid({
- toolbar: "#btn_func",
- fit: true,
- rownumbers: true,
- columns: [[
- { field: 'checkbox', checkbox: true },
- {
- field: '状态', title: '状态', width: 60, align: 'center', styler: function (value, row, index) {
- if (value == '在职') {
- return 'color:green;font-weight:bold';
- }
- if (value == '离职') {
- return 'color:red;font-weight:bold;';
- }
- }
- },
- { field: '账号', title: '账号', width: 120, align: 'center' },
- { field: '姓名', title: '姓名', width: 80 },
- { field: '性别', title: '性别', width: 40, align: 'center' },
- { field: '性质', title: '性质', width: 80, align: 'center' },
- { field: '职务', title: '职务', width: 80, align: 'center' },
- { field: '联系电话', title: '联系电话', width: 120 },
- { field: 'QQ', title: 'QQ', width: 100, align: 'center' },
- { field: '微信', title: '微信', width: 100 },
- { field: '电子邮箱', title: '电子邮箱', width: 120, align: 'center' },
- { field: '出生日期', title: '出生日期', width: 120, align: 'center' },
- { field: '入职时间', title: '入职时间', width: 120, align: 'center' },
- { field: '所属医院', title: '所属医院', width: 120, align: 'center' }
- ]],
- })
- //渠道信息初始化
- $('#ChannelInfo').datagrid({
- url: '/PersonManager/ChannelInfo',
- method: 'Get',
- singleSelect: true,
- rownumbers: true,
- fitColumns: true,
- onSelect: function (rowIndex, rowData) {
- $("#cProject").combobox({ value: "" });
- $("#dtn-search").searchbox("setValue", "");
- $('#person').datagrid('clearSelections');
- $('#person').datagrid('clearChecked');
- DataBindPeron();
- }
- });
- }
- //添加人员窗口数据初始化
- this.Personinit = function (id) {
- //性别
- $("#sex").combobox({
- url: '/PersonManager/GetSex',
- valueField: 'ID',
- textField: '显示名'
- });
- //人员性质
- $("#nature").combobox({
- url: '/PersonManager/GetXZ',
- valueField: 'ID',
- textField: '显示名',
- onChange: function (newValue, oldValue) {
- if (newValue == 3) {
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + id,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: true
- })
- $("#entryDate").datebox({
- disabled: true
- })
- }
- else if (newValue == 4 || newValue == 5) {
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + id,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: false
- })
- $("#entryDate").datebox({
- disabled: true
- })
- }
- else {
- $("#project").combobox({
- disabled: true
- })
- $("#station").combobox({
- disabled: true
- })
- $("#job").combobox({
- disabled: false
- })
- }
- },
- onLoadSuccess: function (data) {
- if (data != null) {
- $('#nature').combobox('setValue', data[1].ID);
- }
- else {
- top.ZLPMS.Msg("人员性质加载异常", 2)
- }
- }
- });
- //职务
- $("#job").combobox({
- url: '/PersonManager/GetJob',
- valueField: 'ID',
- textField: '显示名',
- //onLoadSuccess: function (data) {
- // if (data != null) {
- // $('#job').combobox('setValue', data[0].ID);
- // }
- // else {
- // top.ZLPMS.Msg("人员职务加载异常", 2)
- // }
- //}
- });
- }
- //修改人员窗口数据初始化
- this.PersonLoad = function (id, channelID) {
- //单个修改
- if (id != -1) {
- //性别
- $("#sex").combobox({
- url: '/PersonManager/GetSex',
- valueField: 'ID',
- textField: '显示名'
- });
- //人员性质
- $("#nature").combobox({
- url: '/PersonManager/GetXZ',
- valueField: 'ID',
- textField: '显示名',
- onChange: function (newValue, oldValue) {
- if (newValue == 3) {
- //项目
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: true
- })
- }
- else if (newValue == 4 || newValue == 5) {
- //项目
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: false
- })
- }
- else {
- $("#project").combobox({
- disabled: true
- })
- $("#station").combobox({
- disabled: true
- })
- $("#job").combobox({
- disabled: false
- })
- }
- },
- });
- //职务
- $("#job").combobox({
- url: '/PersonManager/GetJob',
- valueField: 'ID',
- textField: '显示名',
- })
- //项目机构
- $("#project").combobox({
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- //人员信息
- $.ajax({
- url: '/PersonManager/GetInfoByID/' + id,
- method: 'GET',
- success: function (data) {
- if (data.length > 0) {
- $('#ID').val(id);
- $('#name').val(data[0].姓名);
- $('#simple').val(data[0].简码);
- $('#contactPhone').val(data[0].联系电话);
- $('#qq').val(data[0].QQ);
- $('#email').val(data[0].电子邮箱);
- $('#weChat').val(data[0].微信);
- $('#explain').val(data[0].说明);
- $('#sex').combobox('setValue', data[0].性别);
- $('#birthDate').datebox('setValue', data[0].出生日期);
- $('#entryDate').datebox('setValue', data[0].入职时间);
- $('#nature').combobox('setValue', data[0].性质);
- $('#project').combobox('setValue', data[0].项目ID);
- $('#station').combobox('setValue', data[0].站点ID);
- $('#job').combobox('setValue', data[0].职务);
- //SysAccount(id);
- } else {
- ZLPMS.Alert("人员信息表数据加载出错!", 2);
- //弹出错误消息
- }
- }
- })
- }
- //批量修改
- else {
- $("#name").attr("disabled", true);
- $("#name").attr("placeholder", "批量操作无法输入");
- $("#simple").attr("disabled", true);
- $("#simple").attr("placeholder", "批量操作无法输入");
- $("#weChat").attr("disabled", true);
- $("#weChat").attr("placeholder", "批量操作无法输入");
- $("#qq").attr("disabled", true);
- $("#qq").attr("placeholder", "批量操作无法输入");
- $("#contactPhone").attr("placeholder", "批量操作无法输入");
- $("#contactPhone").attr("disabled", true);
- $("#email").attr("disabled", true);
- $("#email").attr("placeholder", "批量操作无法输入");
- //性别
- $("#sex").combobox({
- url: '/PersonManager/GetSex',
- valueField: 'ID',
- textField: '显示名'
- });
- //人员性质
- $("#nature").combobox({
- url: '/PersonManager/GetXZ',
- valueField: 'ID',
- textField: '显示名',
- onChange: function (newValue, oldValue) {
- if (newValue == 3) {
- //项目
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: true
- })
- }
- else if (newValue == 4 || newValue == 5) {
- //项目
- $("#project").combobox({
- disabled: false,
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- $("#station").combobox({
- disabled: false
- })
- $("#job").combobox({
- disabled: false
- })
- }
- else {
- $("#project").combobox({
- disabled: true
- })
- $("#station").combobox({
- disabled: true
- })
- $("#job").combobox({
- disabled: false
- })
- }
- },
- });
- //职务
- $("#job").combobox({
- url: '/PersonManager/GetJob',
- valueField: 'ID',
- textField: '显示名',
- })
- //项目机构
- $("#project").combobox({
- url: '/PersonManager/GetProject/' + channelID,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- //机构
- $("#station").combobox({
- url: '/PersonManager/GetStation/' + newValue,
- valueField: 'ID',
- textField: '名称'
- });
- }
- });
- }
- }
- //生成账号时窗口内部数据初始化
- this.AccountInit = function (id) {
- //角色
- $("#role").combobox({
- url: '/PersonManager/GetRole',
- valueField: 'ID',
- textField: '名称',
- onLoadSuccess: function (data) {
- if (data != null) {
- $('#role').combobox('setValue', data[0].ID);
- }
- else {
- top.ZLPMS.Msg("角色加载异常", 2)
- }
- }
- });
- $.ajax({
- url: "/PersonManager/GetInfoByID/" + id,
- method: 'GET',
- success: function (data) {
- if (data.length > 0) {
- $('#ID').val(id);
- $('#name').val(data[0].姓名);
- $('#contactPhone').val(data[0].联系电话);
- $('#email').val(data[0].电子邮箱);
- $('#channel').val(data[0].渠道ID);
- }
- else {
- top.ZLPMS.Msg("数据加载出错!", 2);
- //弹出错误消息
- }
- }
- })
- }
- //修改账号数据初始化
- this.AccountLoad = function (id) {
- $("#role").combobox({
- url: '/PersonManager/GetRole',
- valueField: 'ID',
- textField: '名称'
- });
- $.ajax({
- url: "/PersonManager/GetSysAccountInfo/" + id,
- method: 'GET',
- success: function (data) {
- if (data.length > 0) {
- $('#ID').val(id);
- $('#name').val(data[0].姓名);
- $('#account').val(data[0].账户);
- $('#email').val(data[0].邮箱);
- $('#channel').val(data[0].渠道ID);
- $('#password2').val(data[0].密码);
- $('#password1').val(data[0].密码);
- SysRole(id);
- }
- else {
- top.ZLPMS.Msg("该人员没有账户!");
- //弹出错误消息
- }
- }
- })
- //账户角色
- function SysRole(id) {
- $.ajax({
- url: '/PersonManager/GetRoleInfo/' + id,
- method: 'GET',
- success: function (data) {
- var html = ""
- for (var row = 0; row < data.length; row++) {
- if (row == data.length - 1) {
- html += data[row].角色ID
- }
- else {
- html += data[row].角色ID + ","
- }
- }
- if (data.length > 0) {
- $('#role').combobox('setValues', html.split(","));
- } else {
- //弹出错误消息
- ZLPMS.Alert("账户角色关系表数据加载出错", 2);
- }
- }
- })
- }
- }
- }
- //人员信息显示
- function DataBindPeron() {
- var search = $("#dtn-search").val();
- personnelObj.channelId = $('#ChannelInfo').datagrid("getSelected")["ID"];
- personnelObj.nature = $('input:radio:checked').val()
- personnelObj.projectId = $("#cProject").combobox('getValue');
- var Params = {
- Search: search,
- Nature: personnelObj.nature,
- Project: personnelObj.projectId
- }
- $('#person').datagrid({
- url: '/PersonManager/PersonInfo?id=' + personnelObj.channelId,
- method: 'Get',
- singleSelect: true,
- idField: "ID",
- rownumbers: true,
- pagination: true,
- toolbar: "#btn_func",
- toolbar: "#query",
- checkOnSelect: false,
- selectOnCheck: false,
- queryParams: Params,
- columns: [[{ field: 'checkbox', checkbox: true },
- {
- field: '账户状态', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
- if (row.账户状态==1) {
- return "启用";
- } else {
- return "停用";
- }
- }, styler: function (value, row, index) {
- if (value == 1) {
- return 'color:green;font-weight:bold';
- }
- else {
- return 'color:red;font-weight:bold;';
- }
- }
- },
- { field: '账号', title: '账号', width: 120, align: 'center' },
- { field: '姓名', title: '姓名', width: 80 },
- { field: '性别', title: '性别', width: 40, align: 'center' },
- { field: '性质', title: '性质', width: 80, align: 'center' },
- { field: '职务', title: '职务', width: 80, align: 'center' },
- { field: '联系电话', title: '联系电话', width: 120 },
- { field: 'QQ', title: 'QQ', width: 100, align: 'center' },
- { field: '微信', title: '微信', width: 100 },
- { field: '电子邮箱', title: '电子邮箱', width: 120, align: 'center' },
- { field: '出生日期', title: '出生日期', width: 120, align: 'center' },
- { field: '入职时间', title: '入职时间', width: 120, align: 'center' },
- { field: '所属医院', title: '所属医院', width: 120, align: 'center' }
- ]]
- });
- $('#person').datagrid('load');
- //项目下拉框数据绑定
- $("#cProject").combobox({
- url: '/PersonManager/GetProject/' + personnelObj.channelId,
- valueField: 'ID',
- textField: '名称',
- onChange: function (newValue, oldValue) {
- /* $("#cProject").combobox({ value: newValue });*/
- /* DataBindPeron(newValue);*/
- }
- });
- }
- //添加人员的窗口
- function Add_Person() {
- var id = $('#ChannelInfo').datagrid("getSelected");
- if ($('#ChannelInfo').datagrid("getSelected") == null) {
- top.ZLPMS.Msg("请选择公司")
- }
- else {
- top.ZLPMS.OpenWindow({
- title: '新建人员',
- url: '/PersonManager/PersonInfoWindow?channelId=' + id["ID"],
- area: ['1000px', '500px'],
- yes: function (index, layero) {
- Insert_Forms.Submit(index, layero);
- $("#person").datagrid("reload")
- },
- });
- }
- }
- //添加人员
- var Insert_Forms = {
- //表单提交
- Submit: function (index, layero) {
- var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
- iframeWin.Insert_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
- $("#person").datagrid("reload")
- },
- //读取数据
- PostData: function (index) {
- //执行提交验证
- var name = $("#name").val();
- var qq = $("#qq").val();
- var phone = $("#contactPhone").val();
- if (name == null || name == "") {
- top.ZLPMS.Msg("姓名不能为空!");
- }
- else if (qq == null || qq == "") {
- top.ZLPMS.Msg("QQ不能为空!");
- }
- else {
- var email = $('#email').val();
- //如果填写了邮箱
- if (email.length > 0) {
- var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (pattern.test(email)) {
- var r = $('#insert_person').form('validate');
- if (r) {//post到后台
- var param = ZLPMS.FormToObject('insert_person');
- //勾选自动生成账户
- if ($("#AutoAccount").prop("checked")) {
- if (phone == null || phone == "") {
- top.ZLPMS.Msg("联系电话不能为空!");
- return;
- }
- //手机正则验证
- //var pattern = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;(第一版本)
- /* var pattern = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;*/
- if (true) {
- $.post("/PersonManager/AutoAccount", param, function (data) {
- if (data == 1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("人员创建成功!生成账号成功(密码为:123)");
- $("#person").datagrid("reload")
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("人员信息创建成功,但账号已经被使用,请另行创建账号");
- }
- else if (data == -2) {
- top.ZLPMS.Msg("电话号码已经被使用");
- }
- else {
- top.ZLPMS.Msg("添加失败,请联系管理员");
- }
- })
- }
- else {
- top.ZLPMS.Msg("请查看电话号码格式")
- }
- }
- //没有勾选
- else {
- $.post('/PersonManager/SavePerson?type=1', param, function (data) {
- if (data == 0) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("添加失败");
- }
- else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("添加成功");
- $("#person").datagrid("reload")
- }
- });
- }
- }
- }
- else {
- {
- top.ZLPMS.Msg("请检查邮箱格式")
- }
- }
- }
- else {
- var r = $('#insert_person').form('validate');
- if (r) {
- var param = ZLPMS.FormToObject('insert_person');
- //勾选自动生成账户
- if ($("#AutoAccount").prop("checked")) {
- if (phone == null || phone == "") {
- top.ZLPMS.Msg("联系电话不能为空!");
- return;
- }
- var phone = $('#contactPhone').val();
- //手机正则验证
- //var pattern = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;(第一版本)
- /* var pattern = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;*/
- if (true) {
- $.post("/PersonManager/AutoAccount", param, function (data) {
- if (data == 1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("人员创建成功!生成账号成功(密码为:123)");
- $("#person").datagrid("load")
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("人员信息创建成功,但账号已经被使用,请另行创建账号");
- }
- else if (data == -2) {
- top.ZLPMS.Msg("电话号码已经被使用");
- }
- else {
- top.ZLPMS.Msg("添加失败,请联系管理员");
- }
- })
- }
- else {
- top.ZLPMS.Msg("请查看电话号码格式")
- }
- }
- //没有勾选
- else {
- $.post('/PersonManager/SavePerson?type=1', param, function (data) {
- if (data == 0) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("添加失败");
- }
- else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("添加成功");
- $("#person").datagrid("load")
- }
- });
- }
- }
- }
- }
- return null;
- }
- }
- //修改人员的窗口
- function Update_Person() {
- var PersonID = $("#person").datagrid("getSelected");
- personnelObj.list = $("#person").datagrid("getChecked");
- if (personnelObj.list.length == 0) {
- if (PersonID == null) {
- top.ZLPMS.Msg("请选择一行数据!"); return
- }
- else {
- var url = "/PersonManager/UpdateInfoWindow?ID=" + PersonID["ID"] + "&Type=1";
- }
- }
- else {
- //获取选中的人员ID
- var RYID = "";
- for (var i = 0; i < personnelObj.list.length; i++) {
- if (i == personnelObj.list.length - 1) {
- RYID += personnelObj.list[i].ID
- }
- else {
- RYID += personnelObj.list[i].ID + ","
- }
- };
- url = "/PersonManager/UpdateInfoWindow?ID=-1&Type=2&ChannelID=" + personnelObj.list[0]["渠道ID"] + "&RYID=" + RYID
- }
- //打开弹窗
- top.ZLPMS.OpenWindow({
- title: '修改人员',
- url: url,
- area: ['1000px', '500px'],
- yes: function (index, layero) {
- Update_Forms.Submit(index, layero);
- $('#person').datagrid('reload');
- },
- });
- }
- //修改人员
- var Update_Forms = {
- //表单提交
- Submit: function (index, layero) {
- var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
- iframeWin.Update_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
- $("#person").datagrid("reload")
- },
- //读取数据
- PostData: function (index) {
- var name = $("#name").val();
- var phone = $("#contactPhone").val();
- var pwd1 = $("#password1").val();
- var pwd2 = $("#password2").val();
- var RYID = $("#RYID").val();
- if (RYID.length == 0) {//单个修改
- if (name == null || name == "") {
- top.ZLPMS.Msg("姓名不能为空!");
- return;
- }
- //var pattern = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;(第一版本)
- /* var pattern = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;*/
- if (true) {
- var email = $('#email').val();
- //如果填写了邮箱
- if (email.length > 0) {
- var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (pattern.test(email)) {
- var r = $('#update_person').form('validate');
- if (r) {//post到后台
- var param = ZLPMS.FormToObject('update_person');
- $.post('/PersonManager/SavePerson?type=2', param, function (data) {
- if (data == 1) {
- top.ZLPMS.Msg("修改成功", 1);
- $("#person").datagrid("reload")
- top.ZLPMS.CloseWindow(index);
- } else if (data == -1) {
- top.ZLPMS.Msg("电话号码已经被使用请勿重复输入", 2);
- top.ZLPMS.CloseWindow(index);
- } else {
- top.ZLPMS.Msg("修改失败,请联系管理员", 2);
- top.ZLPMS.CloseWindow(index);
- }
- });
- }
- }
- else {
- top.ZLPMS.Msg("请查看邮箱格式")
- }
- }
- else {
- var r = $('#update_person').form('validate');
- if (r) {//post到后台
- var param = ZLPMS.FormToObject('update_person');
- $.post('/PersonManager/SavePerson?type=2', param, function (data) {
- if (data == 1) {
- top.ZLPMS.Msg("修改成功", 1);
- $("#person").datagrid("reload")
- top.ZLPMS.CloseWindow(index);
- } else if (data == -1) {
- top.ZLPMS.Msg("电话号码已经被使用请勿重复输入", 2);
- top.ZLPMS.CloseWindow(index);
- } else {
- top.ZLPMS.Msg("修改失败,请联系管理员", 2);
- top.ZLPMS.CloseWindow(index);
- }
- });
- }
- }
- }
- else {
- top.ZLPMS.Msg("请查看电话号码格式")
- }
- }
- else {//批量修改
- var r = $('#update_person').form('validate');
- if (r) {//post到后台
- var param = ZLPMS.FormToObject('update_person');
- var RYID = escape(RYID)
- $.post('/PersonManager/Batch_Save?RYID=' + RYID, param, function (data) {
- if (data > 0) {
- top.ZLPMS.Msg("修改成功", 1);
- $("#person").datagrid("reload")
- top.ZLPMS.CloseWindow(index);
- } else {
- top.ZLPMS.Msg("修改失败,请联系管理员", 2);
- top.ZLPMS.CloseWindow(index);
- }
- });
- }
- }
- }
- }
- //判断是否删除人员
- function Delete_Person() {
- personnelObj.personnelId = $('#person').datagrid("getSelected");
- personnelObj.list = $("#person").datagrid("getChecked");
- if (personnelObj.personnelId != null || personnelObj.list != "") {
- if (personnelObj.list.length > 0) {
- top.ZLPMS.Confirm('您确定要删除选中的记录吗?', 3, function () {
- //获取选中的人员ID
- var RYID = "";
- for (var i = 0; i < personnelObj.list.length; i++) {
- if (i == personnelObj.list.length - 1) {
- RYID += personnelObj.list[i].ID
- }
- else {
- RYID += personnelObj.list[i].ID + ","
- }
- };
- //执行删除
- $.ajax({
- url: "/PersonManager/Delete_Batch",
- type: 'get',
- dataType: "text",
- data: { id: RYID },
- success: function (data) {
- top.ZLPMS.Msg("选中" + personnelObj.list.length + "条记录</br>" + "成功删除" + data + "条记录")
- $('#person').datagrid('clearChecked');
- $("#person").datagrid('reload')
- }
- })
- });
- }
- else {
- //确认删除对话框
- top.ZLPMS.Confirm('您确定要删除选中的记录吗?', 3, function () {
- //执行删除
- Person_Update_Forms.Del(personnelObj.personnelId["ID"]);
- $('#person').datagrid('clearSelections');
- $('#person').datagrid('reload');
- });
- }
- } else {
- top.ZLPMS.Msg("请选择一行数据");
- }
- };
- //执行删除操作
- var Person_Update_Forms = {
- Del: function (id) {
- var PersonID = $("#person").datagrid("getSelected");
- if (PersonID == "" || PersonID == null) {
- top.ZLPMS.Msg("请选择一行数据!");
- }
- else {
- $.ajax({
- url: '/PersonManager/Delete_Person/' + id,
- method: "post",
- success: function (data) {
- if (data != 0) {
- top.ZLPMS.Msg("删除成功");
- $('#person').datagrid('clearSelections');
- $('#person').datagrid('reload');
- }
- else {
- top.ZLPMS.Msg("删除失败");
- }
- }
- })
- }
- }
- };
- //生成单个账户的弹窗
- function Account_Window() {
- personnelObj.personnelId = $("#person").datagrid("getSelected");
- if (personnelObj.personnelId == null || personnelObj.personnelId == "") {
- top.ZLPMS.Msg("请选择一行数据!");
- }
- else {
- $.post("/PersonManager/CheckAccount/" + personnelObj.personnelId["ID"], {}, function (data) {
- if (data > 0) {
- top.ZLPMS.Msg("该用户已经拥有账户!", 2)
- }
- else {
- top.ZLPMS.OpenWindow({
- title: '创建账户',
- url: '/PersonManager/Account_Window/' + personnelObj.personnelId["ID"],
- area: ['700px', '300px'],
- yes: function (index, layero) {
- Add_Account_Forms.Submit(index, layero);
- $('#person').datagrid('reload');
- },
- });
- }
- })
- }
- }
- //创建单个账号
- var Add_Account_Forms = {
- Submit: function (index, layero) {
- var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
- iframeWin.Add_Account_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
- $("#person").datagrid("load")
- },
- //读取数据
- PostData: function (index) {
- //执行提交验证
- var name = $("#name").val();
- var account = $("#contactPhone").val();
- var pwd1 = $("#password1").val();
- var pwd2 = $("#password2").val();
- /* var pattern = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;*/
- /* pattern.test(account)*/
- if (true) {
- if (name == null || name == "") {
- top.ZLPMS.Msg("姓名不能为空!");
- }
- else if (account == null || account == "") {
- top.ZLPMS.Msg("账号不能为空!");
- }
- else if (pwd1.length == 0 || pwd2.length == 0) {
- top.ZLPMS.Msg("密码不能为空!");
- }
- else if (pwd1 != pwd2) {
- top.ZLPMS.Msg("密码不相同!");
- }
- else {
- var email = $('#email').val();
- if (email.length > 0) {
- var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (pattern.test(email)) {
- var r = $('#add_account').form('validate');
- if (r) {//post到后台
- var role = $("#role").combobox("getValues").join(",");
- var url = '/PersonManager/Add_Account?role=' + role;
- var param = ZLPMS.FormToObject('add_account');
- $.post(url, param, function (data) {
- if (data == 1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("生成账号成功");
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号已经被使用,请重新输入");
- }
- else if (data == -2) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("该人员已经拥有账户,请勿重新输入!");
- }
- else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("数据异常,请重新输入", 2);
- }
- });
- }
- }
- else {
- top.ZLPMS.Msg("请查看邮箱格式")
- }
- }
- else {
- var r = $('#add_account').form('validate');
- if (r) {//post到后台
- var role = $("#role").combobox("getValues").join(",");
- var url = '/PersonManager/Add_Account?role=' + role;
- var param = ZLPMS.FormToObject('add_account');
- $.post(url, param, function (data) {
- if (data == 1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("生成账号成功");
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号已经被使用,请重新输入");
- }
- else if (data == -2) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("该人员已经拥有账户,请重新输入");
- } else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("数据异常,请重新输入", 2);
- }
- });
- }
- }
- }
- }
- else {
- top.ZLPMS.Msg("请查看账号格式是否有误(电话号码)")
- }
- }
- }
- //修改系统账户的弹窗
- function Update_Account() {
- personnelObj.personnelId = $("#person").datagrid("getSelected");
- if (personnelObj.personnelId == null) {
- top.ZLPMS.Msg("请选择一行数据!");
- }
- else {
- $.ajax({
- url: "/PersonManager/GetSysAccountInfo/" + personnelObj.personnelId["ID"],
- method: 'GET',
- success: function (data) {
- if (data.length > 0) {
- top.ZLPMS.OpenWindow({
- title: '修改账户',
- url: '/PersonManager/Account_Window_Update/' + personnelObj.personnelId["ID"],
- area: ['700px', '300px'],
- yes: function (index, layero) {
- Update_Account_Forms.Submit(index, layero);
- $('#person').datagrid('reload');
- },
- });
- }
- else {
- top.ZLPMS.Msg("该人员没有账户!", 2);
- //弹出错误消息
- }
- }
- })
- }
- }
- //执行修改系统账户操作
- var Update_Account_Forms = {
- //表单提交
- Submit: function (index, layero) {
- var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
- iframeWin.Update_Account_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
- $("#person").datagrid("load")
- },
- //读取数据
- PostData: function (index) {
- //执行提交验证
- var name = $("#name").val();
- var account = $("#account").val();
- var pwd1 = $("#password1").val();
- var pwd2 = $("#password2").val();
- if (name == null || name == "") {
- top.ZLPMS.Msg("姓名不能为空!");
- }
- else if (account == null || account == "") {
- top.ZLPMS.Msg("账号不能为空!");
- }
- else if (pwd1.length == 0 || pwd2.length == 0) {
- top.ZLPMS.Msg("密码不能为空!");
- } else if (pwd1 != pwd2) {
- top.ZLPMS.Msg("密码不相同!");
- }
- else {
- var email = $('#email').val();
- if (email.length > 0) {
- var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if (pattern.test(email)) {
- var r = $('#update_account').form('validate');
- if (r) {//post到后台
- var url = '/PersonManager/Update_Account';
- var param = ZLPMS.FormToObject('update_account');
- $.post(url, param, function (data) {
- if (data == 1 || data == 2) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号修改成功");
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号已经被使用,请重新输入");
- } else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("数据异常,请重新输入", 2);
- }
- });
- }
- }
- else {
- top.ZLPMS.Msg("请查看邮箱格式")
- }
- }
- else {
- var r = $('#update_account').form('validate');
- if (r) {//post到后台
- var role = $("#role").combobox("getValues").join(",");
- var url = '/PersonManager/Update_Account?role=' + role;
- var param = ZLPMS.FormToObject('update_account');
- $.post(url, param, function (data) {
- if (data == 1 || data == 2) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号修改成功");
- }
- else if (data == -1) {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("账号已经被使用,请重新输入");
- } else {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("数据异常,请重新输入", 2);
- }
- });
- }
- }
- }
- }
- }
- //启用/停用
- function Active() {
- personnelObj.personnelId = $("#person").datagrid("getSelected");
- if (personnelObj.personnelId == null) {
- top.ZLPMS.Msg("请选择一行数据!");
- }
- else {
- //确认删除对话框
- top.ZLPMS.Confirm('确定变更账号状态吗?', 3, function () {
- //激活/停用账户
- $.post("/PersonManager/ChangeActive?id=" + personnelObj.personnelId["ID"], function (data) {
- if (data == 1) {
- top.ZLPMS.Msg("状态变更成功!");
- $('#person').datagrid('reload');
- } else {
- top.ZLPMS.Msg("数据异常,请联系管理员", 2);
- }
- });
- });
- }
- }
- //按批量生成账户
- function Account_Window_Batch() {
- personnelObj.list = $("#person").datagrid("getChecked");
- var Data = [];
- var dataid = {};
- var dataA = [];
- var RYID = "";
- for (var i = 0; i < personnelObj.list.length; i++) {
- if (i == personnelObj.list.length - 1) {
- RYID += personnelObj.list[i].ID
- }
- else {
- RYID += personnelObj.list[i].ID + ","
- }
- };
- if (personnelObj.list.length == 0) {
- top.ZLPMS.Msg("请至少选择一条记录")
- }
- else {
- $.ajax({
- url: "/PersonManager/Add_Account_Batch",
- type: 'get',
- dataType: "text",
- data: { id: RYID },
- success: function (data) {
- top.ZLPMS.Msg("选中" + personnelObj.list.length + "条记录</br>" + "成功添加" + data + "个账户")
- $("#person").datagrid('reload')
- }
- })
- }
- }
- //简码
- function changename() {
- var val = $("#name").val();
- if (val) {//获取简码
- var code = makePy(val);
- $("#simple").val(code);
- }
- }
- //清空项目筛选条件
- function Clear() {
- $("#cProject").combobox("clear")
- }
- function Select() {
- DataBindPeron()
- }
|