ProductInfoManage.module.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/zlpms.js" />
  2. function viewModel() {
  3. //初始化
  4. this.init = function () {
  5. $('#productInfo').datagrid({
  6. fit: true,
  7. toolbar: '#tb',
  8. rownumbers: true,
  9. pagination: false,
  10. singleSelect: true,
  11. border:false,
  12. columns: [[
  13. { field: '编码', title: '编码', width: 60, align: 'center' },
  14. { field: '名称', title: '名称', width: 200, align: 'left', halign: 'center' },
  15. {
  16. field: '状态', title: '启用', width: 40, align: 'center', styler: function (value, row, index) {
  17. }
  18. },
  19. { field: '负责人', title: '负责人', width: 80, align: 'center' },
  20. { field: '说明', title: '说明', width: 250, align: 'left', halign: 'center' }
  21. ]],
  22. onSelect: function (rowIndex, rowData) {
  23. Refresh("1");
  24. }
  25. });
  26. $('#productFunction').treegrid({
  27. idField: 'ID',
  28. treeField: '名称',
  29. method: 'GET',
  30. fit: true,
  31. toolbar: '#tb2',
  32. rownumbers: true,
  33. border: false,
  34. columns: [[
  35. { field: '编码', title: '编码', width: 60, align: 'center' },
  36. { field: '名称', title: '名称', width: 200 },
  37. { field: '类型', title: '类型', width: 150, align: 'center', halign: 'center' },
  38. { field: '开发方式', title: '开发方式', width: 80, align: 'center' },
  39. { field: '开发状态', title: '开发状态', width: 80, align: 'center' },
  40. { field: '研发人', title: '负责人', width: 80, align: 'center' },
  41. { field: '测试人NEW', title: '测试人', width: 80, align: 'center' },
  42. { field: '说明', title: '说明', width: 250, align: 'left', halign: 'center' }
  43. ]],
  44. onSelect: function (rowIndex, rowData) {
  45. }
  46. });
  47. //产品线按钮
  48. //增加
  49. $('#btn-add').click(function () {
  50. top.ZLPMS.OpenWindow({
  51. title: '新建产品线',
  52. url: '/Product/ProductInfoEdit',
  53. area: ['650px', '500px'],
  54. yes: function (index, layero) {
  55. Forms.Submit(index, layero);
  56. },
  57. });
  58. });
  59. //修改
  60. $('#btn-edit').click(function () {
  61. var Node = $('#productInfo').datagrid("getSelected");
  62. if (Node != null) {
  63. //打开编辑窗口
  64. top.ZLPMS.OpenWindow({
  65. title: '修改产品线',
  66. url: '/Product/ProductInfoEdit/' + Node["ID"],
  67. area: ['650px', '500px'],
  68. yes: function (index, layero) {
  69. Forms.Submit(index, layero);
  70. },
  71. });
  72. } else {
  73. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  74. }
  75. });
  76. //删除
  77. $('#btn-del').click(function () {
  78. var Node = $('#productInfo').datagrid("getSelected");
  79. if (Node != null) {
  80. //确认删除对话框
  81. top.ZLPMS.Confirm('您确定要删除选择的记录吗?删除后不可还原,如果不使用建议禁用模块', 3, function () {
  82. //执行删除
  83. var url = '/Product/PostDelProduct';
  84. $.post(url, { "id": Node["ID"] }, function (data) {
  85. if (data.code == 200) {
  86. //刷新
  87. top.ZLPMS.Msg(data.msg);
  88. Refresh("0");
  89. } else {
  90. ZLPMS.Msg(data.msg, 2);
  91. }
  92. });
  93. });
  94. } else {
  95. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  96. }
  97. });
  98. //刷新
  99. $('#btn-ref').click(function () {
  100. Refresh("0");
  101. });
  102. //产品功能按钮
  103. //新建
  104. $('#fbtn-add').click(function () {
  105. var Node = $('#productInfo').datagrid("getSelected");
  106. var Node2 = $('#productFunction').datagrid("getSelected");
  107. var url='/Product/ProductFunEdit?ProID=' + Node["ID"] ;
  108. if(Node2){
  109. url+='&ParentId=' + Node2["ID"];
  110. }
  111. if (Node != null) {
  112. top.ZLPMS.OpenWindow({
  113. title: '新建产品功能',
  114. url: url,
  115. area: ['650px', '500px'],
  116. yes: function (index, layero) {
  117. FunForms.Submit(index, layero);
  118. },
  119. });
  120. } else {
  121. top.ZLPMS.Msg("请选择一行产品线后执行操作", 0);
  122. }
  123. });
  124. //修改
  125. $('#fbtn-edit').click(function () {
  126. var Node = $('#productFunction').treegrid("getSelected");
  127. var Node2 = $('#productInfo').datagrid("getSelected");
  128. if (Node != null && Node2!=null) {
  129. //打开编辑窗口
  130. top.ZLPMS.OpenWindow({
  131. title: '修改产品功能',
  132. url: '/Product/ProductFunEdit/' + Node.ID + '?ProID=' + Node2["ID"],
  133. area: ['650px', '500px'],
  134. yes: function (index, layero) {
  135. FunForms.Submit(index, layero);
  136. },
  137. });
  138. } else {
  139. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  140. }
  141. });
  142. //删除
  143. $('#fbtn-del').click(function () {
  144. var Node = $('#productFunction').datagrid("getSelected");
  145. if (Node != null) {
  146. //确认删除对话框
  147. top.ZLPMS.Confirm('您确定要删除选择的记录吗?删除后不可还原,如果不使用建议禁用模块', 3, function () {
  148. //执行删除
  149. var url = '/Product/PostDelProductFun';
  150. $.post(url, { "id": Node.ID }, function (data) {
  151. if (data.code == 200) {
  152. //刷新
  153. top.ZLPMS.Msg(data.msg);
  154. Refresh("1");
  155. } else {
  156. ZLPMS.Msg(data.msg, 2);
  157. }
  158. });
  159. });
  160. } else {
  161. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  162. }
  163. });
  164. //刷新
  165. $('#fbtn-ref').click(function () {
  166. Refresh("1");
  167. });
  168. },
  169. //绑定数据(产品线)
  170. this.bindData = function (id) {
  171. this.id = id;
  172. //加载修改内容
  173. $.ajax({
  174. url: '/Product/GetProductInfo/' + id,
  175. method: 'GET',
  176. success: function (data) {
  177. if (data.code == 200) {
  178. $('#id').val(id);
  179. $('#Coding').textbox('setValue', data.obj[0].编码);
  180. $('#name').textbox('setValue', data.obj[0].名称);
  181. $('#remark').textbox('setValue', data.obj[0].说明);
  182. $('#PerInChargeID').combobox('setValue', data.obj[0].负责人ID);
  183. if (data.obj[0].产品流程状态 != null) {
  184. var array = data.obj[0].产品流程状态.split(",");
  185. for (var i = 0; i < array.length; i++) {
  186. var xz = array[i];
  187. /* $("'#item"+ xz + "'").prop("checked", true);*/
  188. $('#item' + xz).prop("checked", true)
  189. }
  190. }
  191. //设置值
  192. ZLPMS.SetFormVal('ff', { "isactive": data.obj[0].状态 == 1 ? true : false });
  193. } else {
  194. //弹出错误消息
  195. ZLPMS.Alert(data.msg, 1);
  196. }
  197. }
  198. })
  199. },
  200. this.loadmenus = function () {
  201. $('#PerInChargeID').combobox({
  202. url: '/PersonManager/GetPersonByJob?Nature=1&job=10',
  203. method: 'GET',
  204. valueField: 'ID',
  205. textField: '姓名',
  206. editable: true,
  207. onSelect: function (record) {
  208. $('#PerInCharge').val(record.姓名);
  209. }
  210. });
  211. //绑定清空事件
  212. $('#clear').click(function () {
  213. $('#PerInCharge').combobox('clear');
  214. });
  215. //绑定产品状态
  216. $.ajax({
  217. url: '/ProManager/SelectNature/?ID=DD2C3294-4FBB-4616-A046-07D3CAF52414',
  218. method: 'GET',
  219. async: false,
  220. success: function (data) {
  221. if (data!=null) {
  222. $("#ProductStatus").html("");//先清空在渲染否则还是之前的
  223. var select = $("#ProductStatus");
  224. for (var i = 0; i < data.length; i++) {
  225. var check;
  226. if (data[i].是否默认 == 1) {
  227. check = "checked";
  228. }
  229. else {
  230. check = "";
  231. }
  232. select.append("<input type=\"checkbox\" id=item" + data[i].代码 + " value=" + data[i].代码 +" name=\"ProductStatus\" title=\"" + data[i].名称 + "\" " + check +"\> ");
  233. }
  234. }
  235. }
  236. })
  237. },
  238. //绑定数据(产品功能)
  239. this.FunbindData = function (id) {
  240. this.id = id;
  241. //加载修改内容
  242. $.ajax({
  243. url: '/Product/GetProductFunInfo/' + id,
  244. method: 'GET',
  245. success: function (data) {
  246. if (data.code == 200) {
  247. $('#id').val(id);
  248. $('#parentid').combotree('setValue', data.obj[0].上级ID);
  249. $('#Coding').textbox('setValue', data.obj[0].编码);
  250. $('#name').textbox('setValue', data.obj[0].名称);
  251. $('#DevelopmentModeID').combobox('setValue', data.obj[0].开发方式);
  252. $('#DevelopmentStatusID').combobox('setValue', data.obj[0].状态);
  253. $('#remark').textbox('setValue', data.obj[0].说明);
  254. $('#ProType').combobox('setValue', data.obj[0].类型);
  255. $('#ResearchPerID').combobox('setValue', data.obj[0].研发人ID);
  256. if (data.obj[0].测试人IDNEW) {
  257. $('#TestPerID').combobox('setValues', data.obj[0].测试人IDNEW.split(','));
  258. }
  259. } else {
  260. //弹出错误消息
  261. ZLPMS.Alert(data.msg, 1);
  262. }
  263. }
  264. })
  265. },
  266. this.Funloadmenus = function (ProID, ParentId) {
  267. $('#parentid').combotree({
  268. url: '/Product/GetProdutFunTree?ProID=' + ProID,
  269. method: 'GET',
  270. editable: true,
  271. onLoadSuccess: function () {
  272. if (ParentId) {
  273. $('#parentid').combotree('setValue', ParentId);
  274. }
  275. }
  276. });
  277. $('#ProType').combobox({
  278. valueField: 'ID',
  279. textField: '名称',
  280. editable: false,
  281. data: [{
  282. ID: 0,
  283. 名称: '产品模块'
  284. }, {
  285. ID: 1,
  286. 名称: '产品功能'
  287. }],
  288. onLoadSuccess: function () {
  289. $('#ProType').combobox('setValue', 0);
  290. }
  291. });
  292. $('#DevelopmentModeID').combobox({
  293. url: '/Product/GetCodeCombobox?ClassificationID=00C5F8B0-8C61-46E5-9A82-67E6AAA912A9',
  294. valueField: '代码',
  295. textField: '显示名',
  296. editable: false,
  297. });
  298. $('#DevelopmentStatusID').combobox({
  299. url: '/Product/GetCodeCombobox?ClassificationID=FD59AB3D-1749-4C0E-A658-647071C04200',
  300. valueField: '代码',
  301. textField: '显示名',
  302. editable: false,
  303. });
  304. $('#ResearchPerID').combobox({
  305. url: '/PersonManager/GetPersonByJob?Nature=1',
  306. method: 'GET',
  307. valueField: 'ID',
  308. textField: '姓名',
  309. editable: true,
  310. onChange: function (NewValue, OldValue) {
  311. }
  312. });
  313. var job = '5,6';
  314. $('#TestPerID').combobox({
  315. url: '/PersonManager/GetPersonByJob?Nature=1',
  316. method: 'GET',
  317. valueField: 'ID',
  318. textField: '姓名',
  319. editable: true,
  320. limitToList:true,
  321. multiple: true,
  322. onChange: function (NewValue, OldValue) {
  323. }
  324. });
  325. }
  326. }
  327. function Refresh(_mode) {
  328. if (_mode == "0") {
  329. var search = $("#dtn-search").val();
  330. var Params = {
  331. Search: search,
  332. States: "1,0"
  333. }
  334. $('#productInfo').datagrid({
  335. url: '/Product/ProductInfoDataGrid',
  336. method: 'GET',
  337. queryParams: Params,
  338. onLoadSuccess: function () {
  339. }
  340. });
  341. }
  342. if (_mode == "1") {
  343. var search = $("#fdtn-search").val();
  344. var Node = $('#productInfo').datagrid("getSelected");
  345. $('#productFunction').treegrid("clearSelections");
  346. var Params = {
  347. ProductId: Node["ID"],
  348. Search: search,
  349. States: ""
  350. }
  351. $('#productFunction').treegrid({
  352. url: '/Product/productFunctionTree',
  353. method: 'GET',
  354. queryParams: Params,
  355. onLoadSuccess: function (data) {
  356. if (data == "") {
  357. var body = $(this).data().datagrid.dc.body2;
  358. body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 35px; text-align: center;"><h1>暂无数据</h1></td></tr>');
  359. }
  360. }
  361. });
  362. }
  363. };
  364. //表单操作(产品线)
  365. var Forms = {
  366. //表单提交
  367. Submit: function (index, layero) {
  368. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  369. var param = iframeWin.Forms.PostData();//调用子页面的方法,得到子页面返回的ids
  370. if (param != null) {
  371. var url = '/Product/PostSaveProduct';
  372. $.post(url, param, function (data) {
  373. if (data.code == 200) {
  374. top.ZLPMS.CloseWindow(index);
  375. top.ZLPMS.Msg(data.msg);
  376. //刷新
  377. Refresh("0");
  378. } else {
  379. ZLPMS.Msg(data.msg, 2);
  380. }
  381. });
  382. }
  383. },
  384. //加载数据
  385. Load: function (data) {
  386. $('#ff').form('load', data);
  387. },
  388. //读取数据
  389. PostData: function () {
  390. //执行提交验证
  391. var r = $('#ff').form('validate');
  392. if (r) {//post到后台
  393. var param = ZLPMS.FormToObject('ff');
  394. return param;
  395. }
  396. return null;
  397. }
  398. };
  399. //表单操作(产品功能)
  400. var FunForms = {
  401. //表单提交
  402. Submit: function (index, layero) {
  403. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  404. var param = iframeWin.FunForms.PostData();//调用子页面的方法,得到子页面返回的ids
  405. if (param != null) {
  406. var url = '/Product/PostSaveProductFun';
  407. $.post(url, param, function (data) {
  408. if (data.code == 200) {
  409. top.ZLPMS.CloseWindow(index);
  410. top.ZLPMS.Msg(data.msg);
  411. //刷新
  412. Refresh("1");
  413. } else {
  414. ZLPMS.Msg(data.msg, 2);
  415. }
  416. });
  417. }
  418. },
  419. //加载数据
  420. Load: function (data) {
  421. $('#ff').form('load', data);
  422. },
  423. //读取数据
  424. PostData: function () {
  425. //执行提交验证
  426. var r = $('#ff').form('validate');
  427. if (r) {//post到后台
  428. var param = ZLPMS.FormToObject('ff');
  429. param.TestPerID = $('#TestPerID').combobox('getValues').join(",")
  430. param.ResearchPerID = $('#ResearchPerID').combobox('getValue');
  431. param.TestPer = $('#TestPerID').combobox('getText');
  432. param.ResearchPer = $('#ResearchPerID').combobox('getText');
  433. return param;
  434. }
  435. return null;
  436. }
  437. }
  438. //搜索框
  439. var doSearch={
  440. Product :function() {
  441. Refresh("0");
  442. },
  443. Funtion: function () {
  444. Refresh("1");
  445. }
  446. }