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.
 
 
 
 
 
 

296 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. console.log(values);
  86. //绑定
  87. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsInfoItem/GetDatas?keyValue=' + values, function (data) {
  88. console.log(data);
  89. if (data) {
  90. $.each(data, function (i, item) {
  91. var ifnewrow = true;
  92. $.each(tempdatra, function (key, val) {
  93. if (tempdatra[key].AAIAId === item.AAIAId) {
  94. ifnewrow = false;
  95. }
  96. });
  97. if (ifnewrow) {
  98. tempdatra.push(item);
  99. }
  100. })
  101. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  102. }
  103. });
  104. }
  105. },
  106. isMultiple: true
  107. });
  108. $("#detailedit").on('click', function () {
  109. Ass_ScrapItem
  110. var keyValue = $('#Ass_ScrapItem').jfGridValue('AAIId');
  111. selectedRow = $('#Ass_ScrapItem').jfGridGet('rowdata');
  112. if (learun.checkrow(keyValue)) {
  113. learun.layerForm({
  114. id: 'formitem',
  115. title: '编辑明细',
  116. url: top.$.rootUrl + '/AssetManagementSystem/Ass_ScrapItem/Form?keyValue=' + keyValue,
  117. width: 860,
  118. height: 600,
  119. callBack: function (id) {
  120. return top[id].acceptClick(refreshGirdData);
  121. }
  122. });
  123. }
  124. });
  125. $("#detaildel").on('click', function () {
  126. var keyValue = $('#Ass_ScrapItem').jfGridValue('AAIId');
  127. if (learun.checkrow(keyValue)) {
  128. learun.layerConfirm('是否确认删除该项!', function (res, index) {
  129. if (res) {
  130. $.each(tempdatra, function (key, val) {
  131. if (tempdatra[key].AAIId === keyValue) {
  132. pricecount -= tempdatra[key].AAIPrice * tempdatra[key].AAIStock;
  133. tempdatra.splice(key, 1);
  134. }
  135. });
  136. //$("#AOPrice").val(pricecount);
  137. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  138. top.layer.close(index);
  139. }
  140. });
  141. }
  142. });
  143. page.bind();
  144. page.initData();
  145. },
  146. bind: function () {
  147. $('#SPType').lrDataItemSelect({ code: 'AssScrap' });
  148. $('#Ass_ScrapItem').jfGrid({
  149. headData: [
  150. {
  151. label: '资产编号', name: 'AAICode', width: 150, align: 'left'
  152. },
  153. {
  154. label: '资产名称', name: 'AAIName', width: 150, align: 'left'
  155. },
  156. {
  157. label: '资产类别', name: 'AAITId', width: 150, align: 'left', formatterAsync: function (callback, value, row, op, $cell) {
  158. learun.clientdata.getAsync('custmerData', {
  159. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_AssetsType',
  160. key: value,
  161. keyId: 'atid',
  162. callback: function (_data) {
  163. callback(_data['aname']);
  164. }
  165. });
  166. }
  167. },
  168. {
  169. label: '所在库房', name: 'AAIStorage', width: 150, align: 'left',
  170. formatterAsync: function (callback, value, row, op, $cell) {
  171. learun.clientdata.getAsync('custmerData',
  172. {
  173. url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'Ass_StorageData',
  174. key: value,
  175. keyId: 'sid',
  176. callback: function (_data) {
  177. callback(_data['sname']);
  178. }
  179. });
  180. }
  181. },
  182. {
  183. label: '所在库位', name: 'AAILocation', width: 150, align: 'left'
  184. },
  185. {
  186. label: '是否在库', name: 'AAIIsInStorage', width: 150, align: 'left', formatter: function (val) {
  187. if (val) {
  188. return '在库';
  189. } else {
  190. return '否';
  191. }
  192. }
  193. }
  194. ],
  195. height: 400,
  196. mainId: 'AAIId',
  197. reloadSelected: false
  198. });
  199. },
  200. initData: function () {
  201. if (!!keyValue) {
  202. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/GetFormData?keyValue=' + keyValue,
  203. function (data) {
  204. for (var id in data) {
  205. if (!!data[id].length && data[id].length > 0) {
  206. $('#' + id).jfGridSet('refreshdata', data[id]);
  207. tempdatra = data[id];
  208. } else {
  209. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  210. }
  211. }
  212. });
  213. } else {
  214. $("#SPNo").val(itNo);
  215. }
  216. }
  217. };
  218. refreshGirdData = function (temprow) {
  219. var ifnewrow = true;
  220. $.each(tempdatra, function (key, val) {
  221. if (tempdatra[key].AAIId === temprow.AAIId) {
  222. tempdatra[key] = temprow;
  223. ifnewrow = false;
  224. }
  225. });
  226. if (ifnewrow) {
  227. tempdatra.push(temprow);
  228. }
  229. $('#Ass_ScrapItem').jfGridSet('refreshdata', tempdatra.sort(sortNumber));
  230. };
  231. function sortNumber(a, b) {
  232. return a.AAIOrder - b.AAIOrder;
  233. }
  234. // 设置表单数据
  235. setFormData = function (processId) {
  236. if (!!processId) {
  237. $.lrSetForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/GetFormDataByProcessId?processId=' + processId, function (data) {
  238. for (var id in data) {
  239. if (!!data[id] && data[id].length > 0) {
  240. $('#' + id).jfGridSet('refreshdata', data[id]);
  241. }
  242. else {
  243. if (id == 'AssScrap') {
  244. //keyValue = data[id].;
  245. }
  246. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  247. }
  248. }
  249. });
  250. }
  251. }
  252. // 验证数据是否填写完整
  253. validForm = function () {
  254. if (!$('#form').lrValidform()) {
  255. return false;
  256. }
  257. var datas = $('#Ass_ScrapItem').jfGridGet('rowdatas');
  258. if (datas == null || datas.length == 0) {
  259. learun.alert.warning("申请未包含明细!请先新增明细!");
  260. return false;
  261. }
  262. return true;
  263. };
  264. // 保存数据
  265. save = function (processId, callBack, i) {
  266. var postData = {};
  267. var formData = $('[data-table="Ass_Scrap"]').lrGetFormData();
  268. if (!!processId) {
  269. formData.ITProcessId = processId;
  270. }
  271. postData.strEntity = JSON.stringify(formData);
  272. postData.strAss_ScrapItemList = JSON.stringify($('#Ass_ScrapItem').jfGridGet('rowdatas'));
  273. $.lrSaveForm(top.$.rootUrl + '/AssetManagementSystem/AssScrap/SaveForm?keyValue=' + keyValue, postData, function (res) {
  274. // 保存成功后才回调
  275. if (!!callBack) {
  276. callBack(res, formData, i);
  277. }
  278. });
  279. };
  280. page.init();
  281. }