PersonManager.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. /*
  2. 功能说明:机构人员管理
  3. 负责人:王璐
  4. */
  5. var personnelObj = {
  6. personnelId: null,
  7. accountId: null,
  8. channelId: null,
  9. projectId: null,
  10. nature: null,
  11. list: null,
  12. IsAdmin: ""
  13. }
  14. function viewModel() {
  15. this.init = function () {
  16. //控件初始化
  17. $('#person').datagrid({
  18. toolbar: "#btn_func",
  19. fit: true,
  20. rownumbers: true,
  21. columns: [[
  22. { field: 'checkbox', checkbox: true },
  23. {
  24. field: '状态', title: '状态', width: 60, align: 'center', styler: function (value, row, index) {
  25. if (value == '在职') {
  26. return 'color:green;font-weight:bold';
  27. }
  28. if (value == '离职') {
  29. return 'color:red;font-weight:bold;';
  30. }
  31. }
  32. },
  33. { field: '账号', title: '账号', width: 120, align: 'center' },
  34. { field: '姓名', title: '姓名', width: 80 },
  35. { field: '性别', title: '性别', width: 40, align: 'center' },
  36. { field: '性质', title: '性质', width: 80, align: 'center' },
  37. { field: '职务', title: '职务', width: 80, align: 'center' },
  38. { field: '联系电话', title: '联系电话', width: 120 },
  39. { field: 'QQ', title: 'QQ', width: 100, align: 'center' },
  40. { field: '微信', title: '微信', width: 100 },
  41. { field: '电子邮箱', title: '电子邮箱', width: 120, align: 'center' },
  42. { field: '出生日期', title: '出生日期', width: 120, align: 'center' },
  43. { field: '入职时间', title: '入职时间', width: 120, align: 'center' },
  44. { field: '所属医院', title: '所属医院', width: 120, align: 'center' }
  45. ]],
  46. })
  47. //渠道信息初始化
  48. $('#ChannelInfo').datagrid({
  49. url: '/PersonManager/ChannelInfo',
  50. method: 'Get',
  51. singleSelect: true,
  52. rownumbers: true,
  53. fitColumns: true,
  54. onSelect: function (rowIndex, rowData) {
  55. $("#cProject").combobox({ value: "" });
  56. $("#dtn-search").searchbox("setValue", "");
  57. $('#person').datagrid('clearSelections');
  58. $('#person').datagrid('clearChecked');
  59. DataBindPeron();
  60. }
  61. });
  62. }
  63. //添加人员窗口数据初始化
  64. this.Personinit = function (id) {
  65. //性别
  66. $("#sex").combobox({
  67. url: '/PersonManager/GetSex',
  68. valueField: 'ID',
  69. textField: '显示名'
  70. });
  71. //人员性质
  72. $("#nature").combobox({
  73. url: '/PersonManager/GetXZ',
  74. valueField: 'ID',
  75. textField: '显示名',
  76. onChange: function (newValue, oldValue) {
  77. if (newValue == 3) {
  78. $("#project").combobox({
  79. disabled: false,
  80. url: '/PersonManager/GetProject/' + id,
  81. valueField: 'ID',
  82. textField: '名称',
  83. onChange: function (newValue, oldValue) {
  84. //机构
  85. $("#station").combobox({
  86. url: '/PersonManager/GetStation/' + newValue,
  87. valueField: 'ID',
  88. textField: '名称'
  89. });
  90. }
  91. });
  92. $("#station").combobox({
  93. disabled: false
  94. })
  95. $("#job").combobox({
  96. disabled: true
  97. })
  98. $("#entryDate").datebox({
  99. disabled: true
  100. })
  101. }
  102. else if (newValue == 4 || newValue == 5) {
  103. $("#project").combobox({
  104. disabled: false,
  105. url: '/PersonManager/GetProject/' + id,
  106. valueField: 'ID',
  107. textField: '名称',
  108. onChange: function (newValue, oldValue) {
  109. //机构
  110. $("#station").combobox({
  111. url: '/PersonManager/GetStation/' + newValue,
  112. valueField: 'ID',
  113. textField: '名称'
  114. });
  115. }
  116. });
  117. $("#station").combobox({
  118. disabled: false
  119. })
  120. $("#job").combobox({
  121. disabled: false
  122. })
  123. $("#entryDate").datebox({
  124. disabled: true
  125. })
  126. }
  127. else {
  128. $("#project").combobox({
  129. disabled: true
  130. })
  131. $("#station").combobox({
  132. disabled: true
  133. })
  134. $("#job").combobox({
  135. disabled: false
  136. })
  137. }
  138. },
  139. onLoadSuccess: function (data) {
  140. if (data != null) {
  141. $('#nature').combobox('setValue', data[1].ID);
  142. }
  143. else {
  144. top.ZLPMS.Msg("人员性质加载异常", 2)
  145. }
  146. }
  147. });
  148. //职务
  149. $("#job").combobox({
  150. url: '/PersonManager/GetJob',
  151. valueField: 'ID',
  152. textField: '显示名',
  153. //onLoadSuccess: function (data) {
  154. // if (data != null) {
  155. // $('#job').combobox('setValue', data[0].ID);
  156. // }
  157. // else {
  158. // top.ZLPMS.Msg("人员职务加载异常", 2)
  159. // }
  160. //}
  161. });
  162. }
  163. //修改人员窗口数据初始化
  164. this.PersonLoad = function (id, channelID) {
  165. //单个修改
  166. if (id != -1) {
  167. //性别
  168. $("#sex").combobox({
  169. url: '/PersonManager/GetSex',
  170. valueField: 'ID',
  171. textField: '显示名'
  172. });
  173. //人员性质
  174. $("#nature").combobox({
  175. url: '/PersonManager/GetXZ',
  176. valueField: 'ID',
  177. textField: '显示名',
  178. onChange: function (newValue, oldValue) {
  179. if (newValue == 3) {
  180. //项目
  181. $("#project").combobox({
  182. disabled: false,
  183. url: '/PersonManager/GetProject/' + channelID,
  184. valueField: 'ID',
  185. textField: '名称',
  186. onChange: function (newValue, oldValue) {
  187. //机构
  188. $("#station").combobox({
  189. url: '/PersonManager/GetStation/' + newValue,
  190. valueField: 'ID',
  191. textField: '名称'
  192. });
  193. }
  194. });
  195. $("#station").combobox({
  196. disabled: false
  197. })
  198. $("#job").combobox({
  199. disabled: true
  200. })
  201. }
  202. else if (newValue == 4 || newValue == 5) {
  203. //项目
  204. $("#project").combobox({
  205. disabled: false,
  206. url: '/PersonManager/GetProject/' + channelID,
  207. valueField: 'ID',
  208. textField: '名称',
  209. onChange: function (newValue, oldValue) {
  210. //机构
  211. $("#station").combobox({
  212. url: '/PersonManager/GetStation/' + newValue,
  213. valueField: 'ID',
  214. textField: '名称'
  215. });
  216. }
  217. });
  218. $("#station").combobox({
  219. disabled: false
  220. })
  221. $("#job").combobox({
  222. disabled: false
  223. })
  224. }
  225. else {
  226. $("#project").combobox({
  227. disabled: true
  228. })
  229. $("#station").combobox({
  230. disabled: true
  231. })
  232. $("#job").combobox({
  233. disabled: false
  234. })
  235. }
  236. },
  237. });
  238. //职务
  239. $("#job").combobox({
  240. url: '/PersonManager/GetJob',
  241. valueField: 'ID',
  242. textField: '显示名',
  243. })
  244. //项目机构
  245. $("#project").combobox({
  246. url: '/PersonManager/GetProject/' + channelID,
  247. valueField: 'ID',
  248. textField: '名称',
  249. onChange: function (newValue, oldValue) {
  250. //机构
  251. $("#station").combobox({
  252. url: '/PersonManager/GetStation/' + newValue,
  253. valueField: 'ID',
  254. textField: '名称'
  255. });
  256. }
  257. });
  258. //人员信息
  259. $.ajax({
  260. url: '/PersonManager/GetInfoByID/' + id,
  261. method: 'GET',
  262. success: function (data) {
  263. if (data.length > 0) {
  264. $('#ID').val(id);
  265. $('#name').val(data[0].姓名);
  266. $('#simple').val(data[0].简码);
  267. $('#contactPhone').val(data[0].联系电话);
  268. $('#qq').val(data[0].QQ);
  269. $('#email').val(data[0].电子邮箱);
  270. $('#weChat').val(data[0].微信);
  271. $('#explain').val(data[0].说明);
  272. $('#sex').combobox('setValue', data[0].性别);
  273. $('#birthDate').datebox('setValue', data[0].出生日期);
  274. $('#entryDate').datebox('setValue', data[0].入职时间);
  275. $('#nature').combobox('setValue', data[0].性质);
  276. $('#project').combobox('setValue', data[0].项目ID);
  277. $('#station').combobox('setValue', data[0].站点ID);
  278. $('#job').combobox('setValue', data[0].职务);
  279. //SysAccount(id);
  280. } else {
  281. ZLPMS.Alert("人员信息表数据加载出错!", 2);
  282. //弹出错误消息
  283. }
  284. }
  285. })
  286. }
  287. //批量修改
  288. else {
  289. $("#name").attr("disabled", true);
  290. $("#name").attr("placeholder", "批量操作无法输入");
  291. $("#simple").attr("disabled", true);
  292. $("#simple").attr("placeholder", "批量操作无法输入");
  293. $("#weChat").attr("disabled", true);
  294. $("#weChat").attr("placeholder", "批量操作无法输入");
  295. $("#qq").attr("disabled", true);
  296. $("#qq").attr("placeholder", "批量操作无法输入");
  297. $("#contactPhone").attr("placeholder", "批量操作无法输入");
  298. $("#contactPhone").attr("disabled", true);
  299. $("#email").attr("disabled", true);
  300. $("#email").attr("placeholder", "批量操作无法输入");
  301. //性别
  302. $("#sex").combobox({
  303. url: '/PersonManager/GetSex',
  304. valueField: 'ID',
  305. textField: '显示名'
  306. });
  307. //人员性质
  308. $("#nature").combobox({
  309. url: '/PersonManager/GetXZ',
  310. valueField: 'ID',
  311. textField: '显示名',
  312. onChange: function (newValue, oldValue) {
  313. if (newValue == 3) {
  314. //项目
  315. $("#project").combobox({
  316. disabled: false,
  317. url: '/PersonManager/GetProject/' + channelID,
  318. valueField: 'ID',
  319. textField: '名称',
  320. onChange: function (newValue, oldValue) {
  321. //机构
  322. $("#station").combobox({
  323. url: '/PersonManager/GetStation/' + newValue,
  324. valueField: 'ID',
  325. textField: '名称'
  326. });
  327. }
  328. });
  329. $("#station").combobox({
  330. disabled: false
  331. })
  332. $("#job").combobox({
  333. disabled: true
  334. })
  335. }
  336. else if (newValue == 4 || newValue == 5) {
  337. //项目
  338. $("#project").combobox({
  339. disabled: false,
  340. url: '/PersonManager/GetProject/' + channelID,
  341. valueField: 'ID',
  342. textField: '名称',
  343. onChange: function (newValue, oldValue) {
  344. //机构
  345. $("#station").combobox({
  346. url: '/PersonManager/GetStation/' + newValue,
  347. valueField: 'ID',
  348. textField: '名称'
  349. });
  350. }
  351. });
  352. $("#station").combobox({
  353. disabled: false
  354. })
  355. $("#job").combobox({
  356. disabled: false
  357. })
  358. }
  359. else {
  360. $("#project").combobox({
  361. disabled: true
  362. })
  363. $("#station").combobox({
  364. disabled: true
  365. })
  366. $("#job").combobox({
  367. disabled: false
  368. })
  369. }
  370. },
  371. });
  372. //职务
  373. $("#job").combobox({
  374. url: '/PersonManager/GetJob',
  375. valueField: 'ID',
  376. textField: '显示名',
  377. })
  378. //项目机构
  379. $("#project").combobox({
  380. url: '/PersonManager/GetProject/' + channelID,
  381. valueField: 'ID',
  382. textField: '名称',
  383. onChange: function (newValue, oldValue) {
  384. //机构
  385. $("#station").combobox({
  386. url: '/PersonManager/GetStation/' + newValue,
  387. valueField: 'ID',
  388. textField: '名称'
  389. });
  390. }
  391. });
  392. }
  393. }
  394. //生成账号时窗口内部数据初始化
  395. this.AccountInit = function (id) {
  396. //角色
  397. $("#role").combobox({
  398. url: '/PersonManager/GetRole',
  399. valueField: 'ID',
  400. textField: '名称',
  401. onLoadSuccess: function (data) {
  402. if (data != null) {
  403. $('#role').combobox('setValue', data[0].ID);
  404. }
  405. else {
  406. top.ZLPMS.Msg("角色加载异常", 2)
  407. }
  408. }
  409. });
  410. $.ajax({
  411. url: "/PersonManager/GetInfoByID/" + id,
  412. method: 'GET',
  413. success: function (data) {
  414. if (data.length > 0) {
  415. $('#ID').val(id);
  416. $('#name').val(data[0].姓名);
  417. $('#contactPhone').val(data[0].联系电话);
  418. $('#email').val(data[0].电子邮箱);
  419. $('#channel').val(data[0].渠道ID);
  420. }
  421. else {
  422. top.ZLPMS.Msg("数据加载出错!", 2);
  423. //弹出错误消息
  424. }
  425. }
  426. })
  427. }
  428. //修改账号数据初始化
  429. this.AccountLoad = function (id) {
  430. $("#role").combobox({
  431. url: '/PersonManager/GetRole',
  432. valueField: 'ID',
  433. textField: '名称'
  434. });
  435. $.ajax({
  436. url: "/PersonManager/GetSysAccountInfo/" + id,
  437. method: 'GET',
  438. success: function (data) {
  439. if (data.length > 0) {
  440. $('#ID').val(id);
  441. $('#name').val(data[0].姓名);
  442. $('#account').val(data[0].账户);
  443. $('#email').val(data[0].邮箱);
  444. $('#channel').val(data[0].渠道ID);
  445. $('#password2').val(data[0].密码);
  446. $('#password1').val(data[0].密码);
  447. SysRole(id);
  448. }
  449. else {
  450. top.ZLPMS.Msg("该人员没有账户!");
  451. //弹出错误消息
  452. }
  453. }
  454. })
  455. //账户角色
  456. function SysRole(id) {
  457. $.ajax({
  458. url: '/PersonManager/GetRoleInfo/' + id,
  459. method: 'GET',
  460. success: function (data) {
  461. var html = ""
  462. for (var row = 0; row < data.length; row++) {
  463. if (row == data.length - 1) {
  464. html += data[row].角色ID
  465. }
  466. else {
  467. html += data[row].角色ID + ","
  468. }
  469. }
  470. if (data.length > 0) {
  471. $('#role').combobox('setValues', html.split(","));
  472. } else {
  473. //弹出错误消息
  474. ZLPMS.Alert("账户角色关系表数据加载出错", 2);
  475. }
  476. }
  477. })
  478. }
  479. }
  480. }
  481. //人员信息显示
  482. function DataBindPeron() {
  483. var search = $("#dtn-search").val();
  484. personnelObj.channelId = $('#ChannelInfo').datagrid("getSelected")["ID"];
  485. personnelObj.nature = $('input:radio:checked').val()
  486. personnelObj.projectId = $("#cProject").combobox('getValue');
  487. var Params = {
  488. Search: search,
  489. Nature: personnelObj.nature,
  490. Project: personnelObj.projectId
  491. }
  492. $('#person').datagrid({
  493. url: '/PersonManager/PersonInfo?id=' + personnelObj.channelId,
  494. method: 'Get',
  495. singleSelect: true,
  496. idField: "ID",
  497. rownumbers: true,
  498. pagination: true,
  499. toolbar: "#btn_func",
  500. toolbar: "#query",
  501. checkOnSelect: false,
  502. selectOnCheck: false,
  503. queryParams: Params,
  504. columns: [[{ field: 'checkbox', checkbox: true },
  505. {
  506. field: '账户状态', title: '状态', width: 60, align: 'center', formatter: function (value, row, index) {
  507. if (row.账户状态==1) {
  508. return "启用";
  509. } else {
  510. return "停用";
  511. }
  512. }, styler: function (value, row, index) {
  513. if (value == 1) {
  514. return 'color:green;font-weight:bold';
  515. }
  516. else {
  517. return 'color:red;font-weight:bold;';
  518. }
  519. }
  520. },
  521. { field: '账号', title: '账号', width: 120, align: 'center' },
  522. { field: '姓名', title: '姓名', width: 80 },
  523. { field: '性别', title: '性别', width: 40, align: 'center' },
  524. { field: '性质', title: '性质', width: 80, align: 'center' },
  525. { field: '职务', title: '职务', width: 80, align: 'center' },
  526. { field: '联系电话', title: '联系电话', width: 120 },
  527. { field: 'QQ', title: 'QQ', width: 100, align: 'center' },
  528. { field: '微信', title: '微信', width: 100 },
  529. { field: '电子邮箱', title: '电子邮箱', width: 120, align: 'center' },
  530. { field: '出生日期', title: '出生日期', width: 120, align: 'center' },
  531. { field: '入职时间', title: '入职时间', width: 120, align: 'center' },
  532. { field: '所属医院', title: '所属医院', width: 120, align: 'center' }
  533. ]]
  534. });
  535. $('#person').datagrid('load');
  536. //项目下拉框数据绑定
  537. $("#cProject").combobox({
  538. url: '/PersonManager/GetProject/' + personnelObj.channelId,
  539. valueField: 'ID',
  540. textField: '名称',
  541. onChange: function (newValue, oldValue) {
  542. /* $("#cProject").combobox({ value: newValue });*/
  543. /* DataBindPeron(newValue);*/
  544. }
  545. });
  546. }
  547. //添加人员的窗口
  548. function Add_Person() {
  549. var id = $('#ChannelInfo').datagrid("getSelected");
  550. if ($('#ChannelInfo').datagrid("getSelected") == null) {
  551. top.ZLPMS.Msg("请选择公司")
  552. }
  553. else {
  554. top.ZLPMS.OpenWindow({
  555. title: '新建人员',
  556. url: '/PersonManager/PersonInfoWindow?channelId=' + id["ID"],
  557. area: ['1000px', '500px'],
  558. yes: function (index, layero) {
  559. Insert_Forms.Submit(index, layero);
  560. $("#person").datagrid("reload")
  561. },
  562. });
  563. }
  564. }
  565. //添加人员
  566. var Insert_Forms = {
  567. //表单提交
  568. Submit: function (index, layero) {
  569. var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
  570. iframeWin.Insert_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
  571. $("#person").datagrid("reload")
  572. },
  573. //读取数据
  574. PostData: function (index) {
  575. //执行提交验证
  576. var name = $("#name").val();
  577. var qq = $("#qq").val();
  578. var phone = $("#contactPhone").val();
  579. if (name == null || name == "") {
  580. top.ZLPMS.Msg("姓名不能为空!");
  581. }
  582. else if (qq == null || qq == "") {
  583. top.ZLPMS.Msg("QQ不能为空!");
  584. }
  585. else {
  586. var email = $('#email').val();
  587. //如果填写了邮箱
  588. if (email.length > 0) {
  589. var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  590. if (pattern.test(email)) {
  591. var r = $('#insert_person').form('validate');
  592. if (r) {//post到后台
  593. var param = ZLPMS.FormToObject('insert_person');
  594. //勾选自动生成账户
  595. if ($("#AutoAccount").prop("checked")) {
  596. if (phone == null || phone == "") {
  597. top.ZLPMS.Msg("联系电话不能为空!");
  598. return;
  599. }
  600. //手机正则验证
  601. //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}$/;(第一版本)
  602. /* 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}$/;*/
  603. if (true) {
  604. $.post("/PersonManager/AutoAccount", param, function (data) {
  605. if (data == 1) {
  606. top.ZLPMS.CloseWindow(index);
  607. top.ZLPMS.Msg("人员创建成功!生成账号成功(密码为:123)");
  608. $("#person").datagrid("reload")
  609. }
  610. else if (data == -1) {
  611. top.ZLPMS.CloseWindow(index);
  612. top.ZLPMS.Msg("人员信息创建成功,但账号已经被使用,请另行创建账号");
  613. }
  614. else if (data == -2) {
  615. top.ZLPMS.Msg("电话号码已经被使用");
  616. }
  617. else {
  618. top.ZLPMS.Msg("添加失败,请联系管理员");
  619. }
  620. })
  621. }
  622. else {
  623. top.ZLPMS.Msg("请查看电话号码格式")
  624. }
  625. }
  626. //没有勾选
  627. else {
  628. $.post('/PersonManager/SavePerson?type=1', param, function (data) {
  629. if (data == 0) {
  630. top.ZLPMS.CloseWindow(index);
  631. top.ZLPMS.Msg("添加失败");
  632. }
  633. else {
  634. top.ZLPMS.CloseWindow(index);
  635. top.ZLPMS.Msg("添加成功");
  636. $("#person").datagrid("reload")
  637. }
  638. });
  639. }
  640. }
  641. }
  642. else {
  643. {
  644. top.ZLPMS.Msg("请检查邮箱格式")
  645. }
  646. }
  647. }
  648. else {
  649. var r = $('#insert_person').form('validate');
  650. if (r) {
  651. var param = ZLPMS.FormToObject('insert_person');
  652. //勾选自动生成账户
  653. if ($("#AutoAccount").prop("checked")) {
  654. if (phone == null || phone == "") {
  655. top.ZLPMS.Msg("联系电话不能为空!");
  656. return;
  657. }
  658. var phone = $('#contactPhone').val();
  659. //手机正则验证
  660. //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}$/;(第一版本)
  661. /* 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}$/;*/
  662. if (true) {
  663. $.post("/PersonManager/AutoAccount", param, function (data) {
  664. if (data == 1) {
  665. top.ZLPMS.CloseWindow(index);
  666. top.ZLPMS.Msg("人员创建成功!生成账号成功(密码为:123)");
  667. $("#person").datagrid("load")
  668. }
  669. else if (data == -1) {
  670. top.ZLPMS.CloseWindow(index);
  671. top.ZLPMS.Msg("人员信息创建成功,但账号已经被使用,请另行创建账号");
  672. }
  673. else if (data == -2) {
  674. top.ZLPMS.Msg("电话号码已经被使用");
  675. }
  676. else {
  677. top.ZLPMS.Msg("添加失败,请联系管理员");
  678. }
  679. })
  680. }
  681. else {
  682. top.ZLPMS.Msg("请查看电话号码格式")
  683. }
  684. }
  685. //没有勾选
  686. else {
  687. $.post('/PersonManager/SavePerson?type=1', param, function (data) {
  688. if (data == 0) {
  689. top.ZLPMS.CloseWindow(index);
  690. top.ZLPMS.Msg("添加失败");
  691. }
  692. else {
  693. top.ZLPMS.CloseWindow(index);
  694. top.ZLPMS.Msg("添加成功");
  695. $("#person").datagrid("load")
  696. }
  697. });
  698. }
  699. }
  700. }
  701. }
  702. return null;
  703. }
  704. }
  705. //修改人员的窗口
  706. function Update_Person() {
  707. var PersonID = $("#person").datagrid("getSelected");
  708. personnelObj.list = $("#person").datagrid("getChecked");
  709. if (personnelObj.list.length == 0) {
  710. if (PersonID == null) {
  711. top.ZLPMS.Msg("请选择一行数据!"); return
  712. }
  713. else {
  714. var url = "/PersonManager/UpdateInfoWindow?ID=" + PersonID["ID"] + "&Type=1";
  715. }
  716. }
  717. else {
  718. //获取选中的人员ID
  719. var RYID = "";
  720. for (var i = 0; i < personnelObj.list.length; i++) {
  721. if (i == personnelObj.list.length - 1) {
  722. RYID += personnelObj.list[i].ID
  723. }
  724. else {
  725. RYID += personnelObj.list[i].ID + ","
  726. }
  727. };
  728. url = "/PersonManager/UpdateInfoWindow?ID=-1&Type=2&ChannelID=" + personnelObj.list[0]["渠道ID"] + "&RYID=" + RYID
  729. }
  730. //打开弹窗
  731. top.ZLPMS.OpenWindow({
  732. title: '修改人员',
  733. url: url,
  734. area: ['1000px', '500px'],
  735. yes: function (index, layero) {
  736. Update_Forms.Submit(index, layero);
  737. $('#person').datagrid('reload');
  738. },
  739. });
  740. }
  741. //修改人员
  742. var Update_Forms = {
  743. //表单提交
  744. Submit: function (index, layero) {
  745. var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
  746. iframeWin.Update_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
  747. $("#person").datagrid("reload")
  748. },
  749. //读取数据
  750. PostData: function (index) {
  751. var name = $("#name").val();
  752. var phone = $("#contactPhone").val();
  753. var pwd1 = $("#password1").val();
  754. var pwd2 = $("#password2").val();
  755. var RYID = $("#RYID").val();
  756. if (RYID.length == 0) {//单个修改
  757. if (name == null || name == "") {
  758. top.ZLPMS.Msg("姓名不能为空!");
  759. return;
  760. }
  761. //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}$/;(第一版本)
  762. /* 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}$/;*/
  763. if (true) {
  764. var email = $('#email').val();
  765. //如果填写了邮箱
  766. if (email.length > 0) {
  767. var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  768. if (pattern.test(email)) {
  769. var r = $('#update_person').form('validate');
  770. if (r) {//post到后台
  771. var param = ZLPMS.FormToObject('update_person');
  772. $.post('/PersonManager/SavePerson?type=2', param, function (data) {
  773. if (data == 1) {
  774. top.ZLPMS.Msg("修改成功", 1);
  775. $("#person").datagrid("reload")
  776. top.ZLPMS.CloseWindow(index);
  777. } else if (data == -1) {
  778. top.ZLPMS.Msg("电话号码已经被使用请勿重复输入", 2);
  779. top.ZLPMS.CloseWindow(index);
  780. } else {
  781. top.ZLPMS.Msg("修改失败,请联系管理员", 2);
  782. top.ZLPMS.CloseWindow(index);
  783. }
  784. });
  785. }
  786. }
  787. else {
  788. top.ZLPMS.Msg("请查看邮箱格式")
  789. }
  790. }
  791. else {
  792. var r = $('#update_person').form('validate');
  793. if (r) {//post到后台
  794. var param = ZLPMS.FormToObject('update_person');
  795. $.post('/PersonManager/SavePerson?type=2', param, function (data) {
  796. if (data == 1) {
  797. top.ZLPMS.Msg("修改成功", 1);
  798. $("#person").datagrid("reload")
  799. top.ZLPMS.CloseWindow(index);
  800. } else if (data == -1) {
  801. top.ZLPMS.Msg("电话号码已经被使用请勿重复输入", 2);
  802. top.ZLPMS.CloseWindow(index);
  803. } else {
  804. top.ZLPMS.Msg("修改失败,请联系管理员", 2);
  805. top.ZLPMS.CloseWindow(index);
  806. }
  807. });
  808. }
  809. }
  810. }
  811. else {
  812. top.ZLPMS.Msg("请查看电话号码格式")
  813. }
  814. }
  815. else {//批量修改
  816. var r = $('#update_person').form('validate');
  817. if (r) {//post到后台
  818. var param = ZLPMS.FormToObject('update_person');
  819. var RYID = escape(RYID)
  820. $.post('/PersonManager/Batch_Save?RYID=' + RYID, param, function (data) {
  821. if (data > 0) {
  822. top.ZLPMS.Msg("修改成功", 1);
  823. $("#person").datagrid("reload")
  824. top.ZLPMS.CloseWindow(index);
  825. } else {
  826. top.ZLPMS.Msg("修改失败,请联系管理员", 2);
  827. top.ZLPMS.CloseWindow(index);
  828. }
  829. });
  830. }
  831. }
  832. }
  833. }
  834. //判断是否删除人员
  835. function Delete_Person() {
  836. personnelObj.personnelId = $('#person').datagrid("getSelected");
  837. personnelObj.list = $("#person").datagrid("getChecked");
  838. if (personnelObj.personnelId != null || personnelObj.list != "") {
  839. if (personnelObj.list.length > 0) {
  840. top.ZLPMS.Confirm('您确定要删除选中的记录吗?', 3, function () {
  841. //获取选中的人员ID
  842. var RYID = "";
  843. for (var i = 0; i < personnelObj.list.length; i++) {
  844. if (i == personnelObj.list.length - 1) {
  845. RYID += personnelObj.list[i].ID
  846. }
  847. else {
  848. RYID += personnelObj.list[i].ID + ","
  849. }
  850. };
  851. //执行删除
  852. $.ajax({
  853. url: "/PersonManager/Delete_Batch",
  854. type: 'get',
  855. dataType: "text",
  856. data: { id: RYID },
  857. success: function (data) {
  858. top.ZLPMS.Msg("选中" + personnelObj.list.length + "条记录</br>" + "成功删除" + data + "条记录")
  859. $('#person').datagrid('clearChecked');
  860. $("#person").datagrid('reload')
  861. }
  862. })
  863. });
  864. }
  865. else {
  866. //确认删除对话框
  867. top.ZLPMS.Confirm('您确定要删除选中的记录吗?', 3, function () {
  868. //执行删除
  869. Person_Update_Forms.Del(personnelObj.personnelId["ID"]);
  870. $('#person').datagrid('clearSelections');
  871. $('#person').datagrid('reload');
  872. });
  873. }
  874. } else {
  875. top.ZLPMS.Msg("请选择一行数据");
  876. }
  877. };
  878. //执行删除操作
  879. var Person_Update_Forms = {
  880. Del: function (id) {
  881. var PersonID = $("#person").datagrid("getSelected");
  882. if (PersonID == "" || PersonID == null) {
  883. top.ZLPMS.Msg("请选择一行数据!");
  884. }
  885. else {
  886. $.ajax({
  887. url: '/PersonManager/Delete_Person/' + id,
  888. method: "post",
  889. success: function (data) {
  890. if (data != 0) {
  891. top.ZLPMS.Msg("删除成功");
  892. $('#person').datagrid('clearSelections');
  893. $('#person').datagrid('reload');
  894. }
  895. else {
  896. top.ZLPMS.Msg("删除失败");
  897. }
  898. }
  899. })
  900. }
  901. }
  902. };
  903. //生成单个账户的弹窗
  904. function Account_Window() {
  905. personnelObj.personnelId = $("#person").datagrid("getSelected");
  906. if (personnelObj.personnelId == null || personnelObj.personnelId == "") {
  907. top.ZLPMS.Msg("请选择一行数据!");
  908. }
  909. else {
  910. $.post("/PersonManager/CheckAccount/" + personnelObj.personnelId["ID"], {}, function (data) {
  911. if (data > 0) {
  912. top.ZLPMS.Msg("该用户已经拥有账户!", 2)
  913. }
  914. else {
  915. top.ZLPMS.OpenWindow({
  916. title: '创建账户',
  917. url: '/PersonManager/Account_Window/' + personnelObj.personnelId["ID"],
  918. area: ['700px', '300px'],
  919. yes: function (index, layero) {
  920. Add_Account_Forms.Submit(index, layero);
  921. $('#person').datagrid('reload');
  922. },
  923. });
  924. }
  925. })
  926. }
  927. }
  928. //创建单个账号
  929. var Add_Account_Forms = {
  930. Submit: function (index, layero) {
  931. var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
  932. iframeWin.Add_Account_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
  933. $("#person").datagrid("load")
  934. },
  935. //读取数据
  936. PostData: function (index) {
  937. //执行提交验证
  938. var name = $("#name").val();
  939. var account = $("#contactPhone").val();
  940. var pwd1 = $("#password1").val();
  941. var pwd2 = $("#password2").val();
  942. /* 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}$/;*/
  943. /* pattern.test(account)*/
  944. if (true) {
  945. if (name == null || name == "") {
  946. top.ZLPMS.Msg("姓名不能为空!");
  947. }
  948. else if (account == null || account == "") {
  949. top.ZLPMS.Msg("账号不能为空!");
  950. }
  951. else if (pwd1.length == 0 || pwd2.length == 0) {
  952. top.ZLPMS.Msg("密码不能为空!");
  953. }
  954. else if (pwd1 != pwd2) {
  955. top.ZLPMS.Msg("密码不相同!");
  956. }
  957. else {
  958. var email = $('#email').val();
  959. if (email.length > 0) {
  960. var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  961. if (pattern.test(email)) {
  962. var r = $('#add_account').form('validate');
  963. if (r) {//post到后台
  964. var role = $("#role").combobox("getValues").join(",");
  965. var url = '/PersonManager/Add_Account?role=' + role;
  966. var param = ZLPMS.FormToObject('add_account');
  967. $.post(url, param, function (data) {
  968. if (data == 1) {
  969. top.ZLPMS.CloseWindow(index);
  970. top.ZLPMS.Msg("生成账号成功");
  971. }
  972. else if (data == -1) {
  973. top.ZLPMS.CloseWindow(index);
  974. top.ZLPMS.Msg("账号已经被使用,请重新输入");
  975. }
  976. else if (data == -2) {
  977. top.ZLPMS.CloseWindow(index);
  978. top.ZLPMS.Msg("该人员已经拥有账户,请勿重新输入!");
  979. }
  980. else {
  981. top.ZLPMS.CloseWindow(index);
  982. top.ZLPMS.Msg("数据异常,请重新输入", 2);
  983. }
  984. });
  985. }
  986. }
  987. else {
  988. top.ZLPMS.Msg("请查看邮箱格式")
  989. }
  990. }
  991. else {
  992. var r = $('#add_account').form('validate');
  993. if (r) {//post到后台
  994. var role = $("#role").combobox("getValues").join(",");
  995. var url = '/PersonManager/Add_Account?role=' + role;
  996. var param = ZLPMS.FormToObject('add_account');
  997. $.post(url, param, function (data) {
  998. if (data == 1) {
  999. top.ZLPMS.CloseWindow(index);
  1000. top.ZLPMS.Msg("生成账号成功");
  1001. }
  1002. else if (data == -1) {
  1003. top.ZLPMS.CloseWindow(index);
  1004. top.ZLPMS.Msg("账号已经被使用,请重新输入");
  1005. }
  1006. else if (data == -2) {
  1007. top.ZLPMS.CloseWindow(index);
  1008. top.ZLPMS.Msg("该人员已经拥有账户,请重新输入");
  1009. } else {
  1010. top.ZLPMS.CloseWindow(index);
  1011. top.ZLPMS.Msg("数据异常,请重新输入", 2);
  1012. }
  1013. });
  1014. }
  1015. }
  1016. }
  1017. }
  1018. else {
  1019. top.ZLPMS.Msg("请查看账号格式是否有误(电话号码)")
  1020. }
  1021. }
  1022. }
  1023. //修改系统账户的弹窗
  1024. function Update_Account() {
  1025. personnelObj.personnelId = $("#person").datagrid("getSelected");
  1026. if (personnelObj.personnelId == null) {
  1027. top.ZLPMS.Msg("请选择一行数据!");
  1028. }
  1029. else {
  1030. $.ajax({
  1031. url: "/PersonManager/GetSysAccountInfo/" + personnelObj.personnelId["ID"],
  1032. method: 'GET',
  1033. success: function (data) {
  1034. if (data.length > 0) {
  1035. top.ZLPMS.OpenWindow({
  1036. title: '修改账户',
  1037. url: '/PersonManager/Account_Window_Update/' + personnelObj.personnelId["ID"],
  1038. area: ['700px', '300px'],
  1039. yes: function (index, layero) {
  1040. Update_Account_Forms.Submit(index, layero);
  1041. $('#person').datagrid('reload');
  1042. },
  1043. });
  1044. }
  1045. else {
  1046. top.ZLPMS.Msg("该人员没有账户!", 2);
  1047. //弹出错误消息
  1048. }
  1049. }
  1050. })
  1051. }
  1052. }
  1053. //执行修改系统账户操作
  1054. var Update_Account_Forms = {
  1055. //表单提交
  1056. Submit: function (index, layero) {
  1057. var iframeWin = top.window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
  1058. iframeWin.Update_Account_Forms.PostData(index);//调用子页面的方法,得到子页面返回的ids
  1059. $("#person").datagrid("load")
  1060. },
  1061. //读取数据
  1062. PostData: function (index) {
  1063. //执行提交验证
  1064. var name = $("#name").val();
  1065. var account = $("#account").val();
  1066. var pwd1 = $("#password1").val();
  1067. var pwd2 = $("#password2").val();
  1068. if (name == null || name == "") {
  1069. top.ZLPMS.Msg("姓名不能为空!");
  1070. }
  1071. else if (account == null || account == "") {
  1072. top.ZLPMS.Msg("账号不能为空!");
  1073. }
  1074. else if (pwd1.length == 0 || pwd2.length == 0) {
  1075. top.ZLPMS.Msg("密码不能为空!");
  1076. } else if (pwd1 != pwd2) {
  1077. top.ZLPMS.Msg("密码不相同!");
  1078. }
  1079. else {
  1080. var email = $('#email').val();
  1081. if (email.length > 0) {
  1082. var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  1083. if (pattern.test(email)) {
  1084. var r = $('#update_account').form('validate');
  1085. if (r) {//post到后台
  1086. var url = '/PersonManager/Update_Account';
  1087. var param = ZLPMS.FormToObject('update_account');
  1088. $.post(url, param, function (data) {
  1089. if (data == 1 || data == 2) {
  1090. top.ZLPMS.CloseWindow(index);
  1091. top.ZLPMS.Msg("账号修改成功");
  1092. }
  1093. else if (data == -1) {
  1094. top.ZLPMS.CloseWindow(index);
  1095. top.ZLPMS.Msg("账号已经被使用,请重新输入");
  1096. } else {
  1097. top.ZLPMS.CloseWindow(index);
  1098. top.ZLPMS.Msg("数据异常,请重新输入", 2);
  1099. }
  1100. });
  1101. }
  1102. }
  1103. else {
  1104. top.ZLPMS.Msg("请查看邮箱格式")
  1105. }
  1106. }
  1107. else {
  1108. var r = $('#update_account').form('validate');
  1109. if (r) {//post到后台
  1110. var role = $("#role").combobox("getValues").join(",");
  1111. var url = '/PersonManager/Update_Account?role=' + role;
  1112. var param = ZLPMS.FormToObject('update_account');
  1113. $.post(url, param, function (data) {
  1114. if (data == 1 || data == 2) {
  1115. top.ZLPMS.CloseWindow(index);
  1116. top.ZLPMS.Msg("账号修改成功");
  1117. }
  1118. else if (data == -1) {
  1119. top.ZLPMS.CloseWindow(index);
  1120. top.ZLPMS.Msg("账号已经被使用,请重新输入");
  1121. } else {
  1122. top.ZLPMS.CloseWindow(index);
  1123. top.ZLPMS.Msg("数据异常,请重新输入", 2);
  1124. }
  1125. });
  1126. }
  1127. }
  1128. }
  1129. }
  1130. }
  1131. //启用/停用
  1132. function Active() {
  1133. personnelObj.personnelId = $("#person").datagrid("getSelected");
  1134. if (personnelObj.personnelId == null) {
  1135. top.ZLPMS.Msg("请选择一行数据!");
  1136. }
  1137. else {
  1138. //确认删除对话框
  1139. top.ZLPMS.Confirm('确定变更账号状态吗?', 3, function () {
  1140. //激活/停用账户
  1141. $.post("/PersonManager/ChangeActive?id=" + personnelObj.personnelId["ID"], function (data) {
  1142. if (data == 1) {
  1143. top.ZLPMS.Msg("状态变更成功!");
  1144. $('#person').datagrid('reload');
  1145. } else {
  1146. top.ZLPMS.Msg("数据异常,请联系管理员", 2);
  1147. }
  1148. });
  1149. });
  1150. }
  1151. }
  1152. //按批量生成账户
  1153. function Account_Window_Batch() {
  1154. personnelObj.list = $("#person").datagrid("getChecked");
  1155. var Data = [];
  1156. var dataid = {};
  1157. var dataA = [];
  1158. var RYID = "";
  1159. for (var i = 0; i < personnelObj.list.length; i++) {
  1160. if (i == personnelObj.list.length - 1) {
  1161. RYID += personnelObj.list[i].ID
  1162. }
  1163. else {
  1164. RYID += personnelObj.list[i].ID + ","
  1165. }
  1166. };
  1167. if (personnelObj.list.length == 0) {
  1168. top.ZLPMS.Msg("请至少选择一条记录")
  1169. }
  1170. else {
  1171. $.ajax({
  1172. url: "/PersonManager/Add_Account_Batch",
  1173. type: 'get',
  1174. dataType: "text",
  1175. data: { id: RYID },
  1176. success: function (data) {
  1177. top.ZLPMS.Msg("选中" + personnelObj.list.length + "条记录</br>" + "成功添加" + data + "个账户")
  1178. $("#person").datagrid('reload')
  1179. }
  1180. })
  1181. }
  1182. }
  1183. //简码
  1184. function changename() {
  1185. var val = $("#name").val();
  1186. if (val) {//获取简码
  1187. var code = makePy(val);
  1188. $("#simple").val(code);
  1189. }
  1190. }
  1191. //清空项目筛选条件
  1192. function Clear() {
  1193. $("#cProject").combobox("clear")
  1194. }
  1195. function Select() {
  1196. DataBindPeron()
  1197. }