You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

312 lines
14 KiB

  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-03-25 17:19
  5. * 描 述:采购申请表
  6. */
  7. var refreshGirdData;
  8. var selectedRow;
  9. var bootstrap = function ($, learun) {
  10. "use strict";
  11. var startTime;
  12. var endTime;
  13. var processId = '';
  14. var page = {
  15. init: function () {
  16. page.initGird();
  17. page.bind();
  18. },
  19. bind: function () {
  20. // 时间搜索框
  21. $('#datesearch').lrdate({
  22. dfdata: [
  23. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  24. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  25. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  26. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }
  27. ],
  28. // 月
  29. mShow: false,
  30. premShow: false,
  31. // 季度
  32. jShow: false,
  33. prejShow: false,
  34. // 年
  35. ysShow: false,
  36. yxShow: false,
  37. preyShow: false,
  38. yShow: false,
  39. // 默认
  40. dfvalue: '2',
  41. selectfn: function (begin, end) {
  42. startTime = begin;
  43. endTime = end;
  44. page.search();
  45. }
  46. });
  47. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  48. page.search(queryJson);
  49. }, 220, 400);
  50. $('#PACreateUserId').lrUserSelect(0);
  51. $('#PACreateDeptId').lrselect({
  52. type: 'tree',
  53. // 展开最大高度
  54. maxHeight: 200,
  55. // 是否允许搜索
  56. allowSearch: true,
  57. // 访问数据接口地址
  58. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree'
  59. });
  60. // 刷新
  61. $('#lr_refresh').on('click', function () {
  62. location.reload();
  63. });
  64. // 新增
  65. $('#lr_add').on('click', function () {
  66. learun.layerForm({
  67. id: 'formAss_PurchaseApply',
  68. title: '新增',
  69. url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/Form',
  70. width: 1000,
  71. height: 600,
  72. callBack: function (id) {
  73. var res = false;
  74. // 验证数据
  75. res = top[id].validForm();
  76. // 保存数据
  77. if (res) {
  78. //processId = learun.newGuid();
  79. //res = top[id].save(processId, refreshGirdData);
  80. res = top[id].save('', function () {
  81. page.search();
  82. });
  83. }
  84. return res;
  85. }
  86. });
  87. });
  88. // 编辑
  89. $('#lr_edit').on('click', function () {
  90. var keyValue = $('#gridtable').jfGridValue('PAId');
  91. selectedRow = $('#gridtable').jfGridGet('rowdata');
  92. if (learun.checkrow(keyValue)) {
  93. if (selectedRow.PAStatus == 1) {//提交
  94. learun.alert.warning("当前采购申请记录已提交,请等待审批!");
  95. return false;
  96. }
  97. else if (selectedRow.PAStatus == 2) {//审批通过
  98. learun.alert.warning("当前采购申请记录已通过审批,无法编辑!");
  99. return false;
  100. }
  101. learun.layerForm({
  102. id: 'formAss_PurchaseApply',
  103. title: '编辑',
  104. url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/Form?keyValue=' + keyValue,
  105. width: 1000,
  106. height: 600,
  107. callBack: function (id) {
  108. var res = false;
  109. // 验证数据
  110. res = top[id].validForm();
  111. // 保存数据
  112. if (res) {
  113. res = top[id].save('', function () {
  114. page.search();
  115. });
  116. }
  117. return res;
  118. }
  119. });
  120. }
  121. });
  122. // 删除
  123. $('#lr_delete').on('click', function () {
  124. var keyValue = $('#gridtable').jfGridValue('PAId');
  125. selectedRow = $('#gridtable').jfGridGet('rowdata');
  126. if (learun.checkrow(keyValue)) {
  127. if (selectedRow.PAStatus !== 0) {
  128. learun.alert.warning("当前采购申请记录已提交,无法删除!");
  129. return false;
  130. }
  131. learun.layerConfirm('是否确认删除该项!', function (res) {
  132. if (res) {
  133. learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/DeleteForm', { keyValue: keyValue }, function () {
  134. //refreshGirdData();
  135. page.search();
  136. });
  137. }
  138. });
  139. }
  140. });
  141. // 提交
  142. $('#lr_submit').on('click', function () {
  143. var keyValue = $('#gridtable').jfGridValue('PAId');
  144. selectedRow = $('#gridtable').jfGridGet('rowdata');
  145. if (learun.checkrow(keyValue)) {
  146. if (selectedRow.PAStatus !== 0) {
  147. learun.alert.warning("当前采购申请记录已提交!");
  148. return false;
  149. }
  150. learun.layerConfirm('是否确认提交该项!', function (res) {
  151. if (res) {
  152. processId = learun.newGuid();
  153. learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/ModifyPAStatus', { keyValue: keyValue, pastatus: 1, processId: processId }, function (res) {
  154. selectedRow.PAProcessId = processId;
  155. refreshGirdData(res, selectedRow);
  156. });
  157. }
  158. });
  159. }
  160. });
  161. // 查看
  162. $('#lr_view').on('click', function () {
  163. var keyValue = $('#gridtable').jfGridValue('PAId');
  164. selectedRow = $('#gridtable').jfGridGet('rowdata');
  165. if (learun.checkrow(keyValue)) {
  166. if (selectedRow.PAStatus == 0) {
  167. learun.alert.warning("当前采购申请记录未提交,请提交后再查看!");
  168. return false;
  169. }
  170. learun.layerForm({
  171. id: 'formviewAss_PurchaseApply',
  172. title: '查看',
  173. url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/FormView?keyValue=' + keyValue,
  174. width: 1000,
  175. height: 600,
  176. btn: null
  177. });
  178. }
  179. });
  180. $('#lr_print').on('click',
  181. function () {
  182. var processId = $('#gridtable').jfGridValue('PAProcessId');
  183. learun.httpSync(
  184. 'get', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/GetFirstTaskByProcessId',
  185. { processId: processId }, function (data) {
  186. var taskId = data.taskId;
  187. learun.frameTab.open({ F_ModuleId: processId + taskId, F_Icon: 'fa magic', F_FullName: '查看流程进度', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/NWFContainerForm?tabIframeId=' + processId + taskId + '&type=look' + "&processId=" + processId + "&taskId=" + taskId });
  188. })
  189. });
  190. },
  191. // 初始化列表
  192. initGird: function () {
  193. $('#gridtable').lrAuthorizeJfGrid({
  194. url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/GetPageList',
  195. headData: [
  196. { label: "采购申请单号", name: "PACode", width: 200, align: "left" },
  197. {
  198. label: "申请人", name: "PACreateUserId", width: 100, align: "left",
  199. formatterAsync: function (callback, value, row, op, $cell) {
  200. learun.clientdata.getAsync('user', {
  201. key: value,
  202. callback: function (_data) {
  203. callback(_data.name);
  204. }
  205. });
  206. }
  207. },
  208. { label: "联系方式", name: "PACreateUserPhone", width: 100, align: "left" },
  209. {
  210. label: "申请部门", name: "PACreateDeptId", width: 100, align: "left",
  211. formatterAsync: function (callback, value, row, op, $cell) {
  212. learun.clientdata.getAsync('custmerData', {
  213. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'classdata',
  214. key: value,
  215. keyId: 'id',
  216. callback: function (_data) {
  217. callback(_data['name']);
  218. }
  219. });
  220. }
  221. },
  222. {
  223. label: "资产属性", name: "PAssType", width: 100, align: "left",
  224. formatterAsync: function (callback, value, row, op, $cell) {
  225. learun.clientdata.getAsync('dataItem', {
  226. key: value,
  227. code: 'AssType',
  228. callback: function (_data) {
  229. callback(_data.text);
  230. }
  231. });
  232. }
  233. },
  234. { label: "所需总金额", name: "PAPrice", width: 100, align: "left" },
  235. { label: "期望采购时间", name: "PAName", width: 130, align: "left" },
  236. { label: "申请时间", name: "PACreateTime", width: 130, align: "left" },
  237. {
  238. label: "审批状态", name: "PAStatus", width: 100, align: "left",
  239. formatter: function (cellvalue, row) {
  240. if (cellvalue == 1) {
  241. return '<span class=\"label label-warning\">审批中</span>';
  242. } else if (cellvalue == 2) {
  243. return '<span class=\"label label-success\" >审批通过</span>';
  244. } else {
  245. return '<span class=\"label label-default\" >草稿</span>';
  246. }
  247. }
  248. },
  249. { label: "审核意见", name: "POpinion", width: 130, align: "left" },
  250. {
  251. label: "采购状态", name: "PStatus", width: 100, align: "left",
  252. formatter: function (cellvalue, row) {
  253. if (cellvalue == 1) {
  254. return '<span class=\"label label-warning\" >采购中</span>';
  255. } else if (cellvalue == 2) {
  256. return '<span class=\"label label-success\" >已采购</span>';
  257. } else {
  258. return '<span class=\"label label-default\" >未采购</span>';
  259. }
  260. }
  261. },
  262. { label: "是否入库", name: "PIsInStorage", width: 130, align: "left" },
  263. ],
  264. mainId: 'PAId',
  265. isPage: true,
  266. sidx: 'PACreateTime',
  267. sord: 'DESC'
  268. });
  269. },
  270. search: function (param) {
  271. param = param || {};
  272. param.StartTime = startTime;
  273. param.EndTime = endTime;
  274. //param.PACreateUserId = learun.clientdata.get(['userinfo']).userId;
  275. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  276. }
  277. };
  278. refreshGirdData = function (res, postData) {
  279. if (res.code == 200) {
  280. // 发起流程
  281. //learun.workflowapi.create({
  282. // isNew: true,
  283. // schemeCode: 'Ass_PurchaseApply',// 填写流程对应模板编号
  284. // processId: processId,
  285. // processName: '采购申请',// 对应流程名称
  286. // processLevel: '1',
  287. // description: '',
  288. // formData: JSON.stringify(postData),
  289. // callback: function (res, data) {
  290. // }
  291. //});
  292. var postData = {
  293. schemeCode: 'Ass_PurchaseApply',// 填写流程对应模板编号
  294. processId: processId,
  295. level: '1',
  296. };
  297. learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/CreateFlow', postData, function (data) {
  298. learun.loading(false);
  299. });
  300. page.search();
  301. }
  302. };
  303. page.init();
  304. }