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.
 
 
 
 
 
 

307 lines
14 KiB

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