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.
 
 
 
 
 
 

294 lines
12 KiB

  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-09-10 16:19
  5. * 描 述:资产盘点
  6. */
  7. var acceptClick;
  8. var keyValue = request('keyValue');
  9. // 设置权限
  10. var setAuthorize;
  11. // 设置表单数据
  12. var setFormData;
  13. // 验证数据是否填写完整
  14. var validForm;
  15. // 保存数据
  16. var save;
  17. var refreshGirdData;
  18. var selectedRow;
  19. var tempdatra = new Array();
  20. //总价计算
  21. var pricecount = 0;
  22. var bootstrap = function ($, learun) {
  23. "use strict";
  24. // 设置权限
  25. setAuthorize = function (data) {
  26. };
  27. var page = {
  28. init: function () {
  29. $('.lr-form-wrap').lrscroll();
  30. $("#detailadd").on('click', function () {
  31. $('#detailaddbutton').trigger('click');
  32. });
  33. $("#detailaddbutton").lrlayerselect({
  34. treeUrl: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsType/GetAllTree',
  35. treeParentId: 'atptid',
  36. treeValueId: 'atid',
  37. treeTextId: 'aname',
  38. dataUrl: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetList',
  39. dataTreeId: 'ATId',
  40. dataValueId: 'aiid',
  41. dataTextId: 'aname',
  42. grid: [
  43. { label: '资产编号', name: 'aicodenumjy', width: 150, align: 'left' },
  44. { label: '资产名称', name: 'aname', width: 150, align: 'left' },
  45. { label: "英文名称", name: "aename", width: 100, align: "left" },
  46. {
  47. label: '所在库房', name: 'aiistorageid', width: 100, align: 'left', formatterAsync: function (callback, value, row, op, $cell) {
  48. learun.clientdata.getAsync('custmerData', {
  49. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  50. key: value,
  51. keyId: 'sid',
  52. callback: function (_data) {
  53. callback(_data['sname']);
  54. }
  55. });
  56. }
  57. },
  58. { label: '所在库位', name: 'aiistorageposition', width: 150, align: 'left' },
  59. {
  60. label: '是否在库', name: 'aiisinstorage', width: 150, align: 'left', formatter: function (val, row) {
  61. if (val) {
  62. return '在库';
  63. } else {
  64. return '否';
  65. }
  66. }
  67. },
  68. { label: "资产型号", name: "amodel", width: 150, align: "left" },
  69. { label: "生产厂家", name: "amanufacturer", width: 150, align: "left" },
  70. {
  71. label: "供应商", name: "asupplierid", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) {
  72. learun.clientdata.getAsync('custmerData', {
  73. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_SupplierData',
  74. key: value,
  75. keyId: 'sid',
  76. callback: function (_data) {
  77. callback(_data['sname']);
  78. }
  79. });
  80. }
  81. }
  82. ],
  83. select: function (values, texts) {
  84. if (values && values.length > 0) {
  85. //绑定
  86. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetDatas?keyValue=' + values, function (data) {
  87. if (data) {
  88. $.each(data, function (i, item) {
  89. var ifnewrow = true;
  90. $.each(tempdatra, function (key, val) {
  91. if (tempdatra[key].AAIAId === item.AAIAId) {
  92. ifnewrow = false;
  93. }
  94. });
  95. if (ifnewrow) {
  96. tempdatra.push(item);
  97. }
  98. })
  99. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  100. }
  101. });
  102. }
  103. },
  104. isMultiple: true
  105. });
  106. $("#detailedit").on('click', function () {
  107. Ass_ScrapItem
  108. var keyValue = $('#Ass_ScrapItem').jfGridValue('AAIId');
  109. selectedRow = $('#Ass_ScrapItem').jfGridGet('rowdata');
  110. if (learun.checkrow(keyValue)) {
  111. learun.layerForm({
  112. id: 'formitem',
  113. title: '编辑明细',
  114. url: top.$.rootUrl + '/AssetManagementSystem/Ass_ScrapItem/Form?keyValue=' + keyValue,
  115. width: 860,
  116. height: 600,
  117. callBack: function (id) {
  118. return top[id].acceptClick(refreshGirdData);
  119. }
  120. });
  121. }
  122. });
  123. $("#detaildel").on('click', function () {
  124. var keyValue = $('#Ass_ScrapItem').jfGridValue('AAIId');
  125. if (learun.checkrow(keyValue)) {
  126. learun.layerConfirm('是否确认删除该项!', function (res, index) {
  127. if (res) {
  128. $.each(tempdatra, function (key, val) {
  129. if (tempdatra[key].AAIId === keyValue) {
  130. pricecount -= tempdatra[key].AAIPrice * tempdatra[key].AAIStock;
  131. tempdatra.splice(key, 1);
  132. }
  133. });
  134. //$("#AOPrice").val(pricecount);
  135. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  136. top.layer.close(index);
  137. }
  138. });
  139. }
  140. });
  141. page.bind();
  142. page.initData();
  143. },
  144. bind: function () {
  145. $('#SPType').lrDataItemSelect({ code: 'AssScrap' });
  146. $('#Ass_ScrapItem').jfGrid({
  147. headData: [
  148. {
  149. label: '资产编号', name: 'AAICode', width: 150, align: 'left'
  150. },
  151. {
  152. label: '资产名称', name: 'AAIName', width: 150, align: 'left'
  153. },
  154. {
  155. label: '资产类别', name: 'AAITId', width: 150, align: 'left', formatterAsync: function (callback, value, row, op, $cell) {
  156. learun.clientdata.getAsync('custmerData', {
  157. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType',
  158. key: value,
  159. keyId: 'atid',
  160. callback: function (_data) {
  161. callback(_data['aname']);
  162. }
  163. });
  164. }
  165. },
  166. {
  167. label: '所在库房', name: 'AAIStorage', width: 150, align: 'left',
  168. formatterAsync: function (callback, value, row, op, $cell) {
  169. learun.clientdata.getAsync('custmerData',
  170. {
  171. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  172. key: value,
  173. keyId: 'sid',
  174. callback: function (_data) {
  175. callback(_data['sname']);
  176. }
  177. });
  178. }
  179. },
  180. {
  181. label: '所在库位', name: 'AAILocation', width: 150, align: 'left'
  182. },
  183. {
  184. label: '是否在库', name: 'AAIIsInStorage', width: 150, align: 'left', formatter: function (val) {
  185. if (val) {
  186. return '在库';
  187. } else {
  188. return '否';
  189. }
  190. }
  191. }
  192. ],
  193. height: 400,
  194. mainId: 'AAIId',
  195. reloadSelected: false
  196. });
  197. },
  198. initData: function () {
  199. if (!!keyValue) {
  200. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/GetFormData?keyValue=' + keyValue,
  201. function (data) {
  202. for (var id in data) {
  203. if (!!data[id].length && data[id].length > 0) {
  204. $('#' + id).jfGridSet('refreshdata', data[id]);
  205. tempdatra = data[id];
  206. } else {
  207. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  208. }
  209. }
  210. });
  211. } else {
  212. $("#SPNo").val(itNo);
  213. }
  214. }
  215. };
  216. refreshGirdData = function (temprow) {
  217. var ifnewrow = true;
  218. $.each(tempdatra, function (key, val) {
  219. if (tempdatra[key].AAIId === temprow.AAIId) {
  220. tempdatra[key] = temprow;
  221. ifnewrow = false;
  222. }
  223. });
  224. if (ifnewrow) {
  225. tempdatra.push(temprow);
  226. }
  227. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  228. };
  229. function sortNumber(a, b) {
  230. return a.AAIOrder - b.AAIOrder;
  231. }
  232. // 设置表单数据
  233. setFormData = function (processId) {
  234. if (!!processId) {
  235. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/GetFormDataByProcessId?processId=' + processId, function (data) {
  236. for (var id in data) {
  237. if (!!data[id] && data[id].length > 0) {
  238. $('#' + id).jfGridSet('refreshdata', data[id]);
  239. }
  240. else {
  241. if (id == 'AssScrap') {
  242. //keyValue = data[id].;
  243. }
  244. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  245. }
  246. }
  247. });
  248. }
  249. }
  250. // 验证数据是否填写完整
  251. validForm = function () {
  252. if (!$('#form').lrValidform()) {
  253. return false;
  254. }
  255. var datas = $('#Ass_ScrapItem').jfGridGet('rowdatas');
  256. if (datas == null || datas.length == 0) {
  257. learun.alert.warning("申请未包含明细!请先新增明细!");
  258. return false;
  259. }
  260. return true;
  261. };
  262. // 保存数据
  263. save = function (processId, callBack, i) {
  264. var postData = {};
  265. var formData = $('[data-table="Ass_Scrap"]').lrGetFormData();
  266. if (!!processId) {
  267. formData.ITProcessId = processId;
  268. }
  269. postData.strEntity = JSON.stringify(formData);
  270. postData.strAss_ScrapItemList = JSON.stringify($('#Ass_ScrapItem').jfGridGet('rowdatas'));
  271. $.lrSaveForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/SaveForm?keyValue=' + keyValue, postData, function (res) {
  272. // 保存成功后才回调
  273. if (!!callBack) {
  274. callBack(res, formData, i);
  275. }
  276. });
  277. };
  278. page.init();
  279. }