Index - 副本.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. var Frm;
  2. var F_CONTRGRPNO = "";
  3. var F_NOS = "";
  4. var bootstrap = function ($, learun) {
  5. Frm = learun;
  6. function httpHeaders() {
  7. var headers = {
  8. token: top.$.lcoreUser.token
  9. }
  10. return headers;
  11. }
  12. var page = {
  13. init: function () {
  14. page.bind();
  15. page.getLine('WTP');
  16. },
  17. bind: function () {
  18. // 仓库与区域多选
  19. $('#locWareHouse').lrselect({
  20. url: top.$.rootUrl + '/BaseManager/BaseWarehouse/GetCheckWWTreeByLocation',
  21. maxHeight: 180,
  22. allowSearch: true
  23. });
  24. $('#locWareHouse').lrselectSet("WTP");
  25. $('#lr_refresh').on('click', function () {
  26. var houseCode = $("#locWareHouse").lrselectGet();
  27. page.getChartData(houseCode, $("#lineNum").val());
  28. });
  29. //滑动条滑动事件,改变数据框的显示值
  30. $("#lineNum").change(function () {
  31. $("#lineValue").val($(this).val());
  32. });
  33. //输入的数值只能在范围内
  34. $("#lineValue").keyup(function () {
  35. let curValue = Number($(this).val());
  36. if (curValue > Number($("#maxValue").text())) {
  37. curValue = Number($("#maxValue").text());
  38. $(this).val(curValue);
  39. }
  40. if (curValue < Number($("#minValue").text())) {
  41. curValue = Number($("#minValue").text());
  42. $(this).val(curValue);
  43. }
  44. $("#lineNum").val($(this).val());
  45. });
  46. //数字框选择事件,改变滑动条(点击上下选择有效)
  47. $("#lineValue").change(function () {
  48. $("#lineNum").val($(this).val());
  49. var houseCode = $("#locWareHouse").val();
  50. houseCode = houseCode.substring(0, 4);
  51. getChartData(houseCode, $("#lineNum").val());
  52. });
  53. //仓库选择事件,改变行数据(最大值和最小值)
  54. $("#locWareHouse").change(function () {
  55. var houseCode = $(this).lrselectGet();
  56. page.getLine(houseCode);
  57. });
  58. // 行数值改变事件
  59. $("#lineNum").change(function () {
  60. var houseCode = $("#locWareHouse").lrselectGet();
  61. page.getChartData(houseCode, $("#lineNum").val());
  62. });
  63. //弹框关闭事件
  64. $("#closeModal").click(function () {
  65. for (let i = 2; i < 4; i++) {
  66. $("#loc" + i).css("display", "none");
  67. }
  68. // 关闭时将选中的托盘号清空
  69. F_CONTRGRPNO = "";
  70. F_NOS = "";
  71. $("#myModal").hide();
  72. });
  73. $(".locCode").click(function () {
  74. let type = $("#locType").text();
  75. var code = $(this).text();
  76. var prm = { conCode: ' ', barCode: ' ' };
  77. if (type == "0") {
  78. prm.conCode = code;
  79. }
  80. else {
  81. prm.barCode = code;
  82. }
  83. var color = $(this).css("color");
  84. var bgColor = $(this).css("background-color");
  85. $(".locCode").css("background-color", bgColor);
  86. $(".locCode").css("color", color);
  87. $(this).css("background-color", "#2F94EE");
  88. $(this).css("color", "#FEFEFF");
  89. //$.post("GetLocDetailList", prm, function (response) {
  90. // page.showTable(eval("(" + response + ")").data);
  91. //})
  92. });
  93. },
  94. getLine: function (houseNo) {
  95. $("#lineNum").val("");//清空行数
  96. $("#lineValue").val("");
  97. $("#minValue").text("0");
  98. $("#maxValue").text("0");
  99. $.ajax({
  100. type: 'post',
  101. headers: httpHeaders(),
  102. dataType: 'json',
  103. url: top.$.rootUrl + '/FJManager/QueryCell/GetMaxLine?houseNo=' + houseNo,
  104. success: function (response) {
  105. var res = eval(response);
  106. // 如果行数存在,则行数的当前值设置为1,可选最小值设置为1
  107. if (res.data > 0) {
  108. $("#lineNum").val(1);
  109. $("#lineValue").val(1);
  110. $("#lineNum").attr("min", 1);
  111. $("#lineValue").attr("min", 1);
  112. $("#minValue").text("1");
  113. }
  114. // 如果行数不存在,则行数设置为0,可选最小值设置为0
  115. if (res.data < 1) {
  116. $("#lineNum").attr("min", 0);
  117. $("#lineValue").attr("min", 0);
  118. $("#minValue").text("0");
  119. }
  120. $("#maxValue").text(res.data); //设置可选最大值
  121. $("#lineNum").attr("max", res.data);
  122. $("#lineValue").attr("max", res.data);
  123. var houseCode = "WTP";// $("#locWareHouse").val();
  124. page.getChartData(houseCode, $("#lineNum").val());//加载储位展示图
  125. // houseCode = houseCode.substring(0, 4);
  126. }
  127. });
  128. //$.get("GetMaxLine", { houseNo: houseNo }, function (response) {//获取最大行数
  129. // var res = eval("(" + response + ")");
  130. // if (res.data > 0) { //如果行数存在,则行数的当前值设置为1,可选最小值设置为1
  131. // $("#lineNum").val(1);
  132. // $("#lineValue").val(1);
  133. // $("#lineNum").attr("min", 1);
  134. // $("#lineValue").attr("min", 1);
  135. // $("#minValue").text("1");
  136. // }
  137. // if (res.data < 1) { //如果行数不存在,则行数设置为0,可选最小值设置为0
  138. // $("#lineNum").attr("min", 0);
  139. // $("#lineValue").attr("min", 0);
  140. // $("#minValue").text("0");
  141. // }
  142. // $("#maxValue").text(res.data); //设置可选最大值
  143. // $("#lineNum").attr("max", res.data);
  144. // $("#lineValue").attr("max", res.data);
  145. // var houseCode = $("#locWareHouse").val();
  146. // houseCode = houseCode.substring(0, 4);
  147. // getChartData(houseCode, $("#lineNum").val());//加载储位展示图
  148. //})
  149. },
  150. getChartData: function (houseNo, line) {
  151. houseNo='hjhouse';
  152. $.ajax({
  153. type: 'post',
  154. headers: httpHeaders(),
  155. dataType: 'json',
  156. url: top.$.rootUrl + '/FJManager/QueryCell/GetLocList?houserNo=' + houseNo + "&line=" + line,
  157. success: function (response) {
  158. var res = eval(response);
  159. page.showChart(eval(res.data.json), res.data.y + 1, res.data.x + 1); //加载储位展示图(坐标加1,显示需要)
  160. }
  161. });
  162. //$.post("GetLocList", { houserNo: houseNo, line: line }, function (response) {
  163. // var res = eval("(" + response + ")");
  164. // showChart(eval("(" + res.data.json + ")"), res.data.y + 1, res.data.x + 1); //加载储位展示图(坐标加1,显示需要)
  165. //})
  166. },
  167. showChart: function (data, layerList, slotCnt) {
  168. var chart = echarts.init(document.getElementById("echart"));
  169. if (layerList > 1 && slotCnt > 1) {
  170. page.setChart(data, layerList, slotCnt);//Echart所需要的设置
  171. chart.setOption(option);//Echart所需要的设置
  172. chart.off('click');//点击事件之前,要释放之前的点击事件
  173. chart.on('click', function (params) {//点击事件
  174. /// 获取选中的货位号
  175. /// alert(params.data.fNo);
  176. if (params.data.F_CNTRGRPNO != ' ') {
  177. $(".locaddrto").remove();
  178. var houseCode = $("#locWareHouse").val();
  179. houseCode = houseCode.substring(0, 4);
  180. //页面初始加载,添加目标地址信息
  181. //$.post("GetAddrtoList", { WarehouseCode: houseCode }, function (response) {
  182. // var res = eval("(" + response + ")");
  183. // var houseSelect = $("#locAddrto");
  184. // for (let house in res.data) {
  185. // houseSelect.append($("<option class='locaddrto' value='" + res.data[house] + "'>" + res.data[house] + "</option>"));
  186. // }
  187. //})
  188. F_CONTRGRPNO = params.data.F_CNTRGRPNO;
  189. F_NOS = params.data.fNo;
  190. Frm.layerForm({
  191. id: 'form',
  192. title: '货位明细',
  193. url: top.$.rootUrl + '/FJManager/QueryCell/Form?WarehouseCode=' + houseCode + "&contrgrpno=" + params.data.F_CNTRGRPNO,
  194. width: 1100,
  195. height: 500,
  196. btn: ['关闭'],
  197. //callBack: function (id) {
  198. // return top[id].acceptClick(refreshGirdData);
  199. //}
  200. });
  201. }
  202. });
  203. }
  204. else {
  205. //没有图标数据的时候,默认展示一个空的表格
  206. var dataHide = [
  207. {
  208. name: "b1",
  209. id: 31,
  210. hashMode: "设备",
  211. value: [0, 0, 0, 0],
  212. itemStyle: { normal: { color: "#715881" } }
  213. }];
  214. page.setChart(dataHide, 0, 0);
  215. chart.setOption(option);
  216. }
  217. },
  218. setChart: function (data, layerList, slotCnt) {
  219. function renderItem(params, api) {
  220. var start = api.coord([api.value(2), api.value(1)]);
  221. var rectShape = echarts.graphic.clipRectByRect({
  222. x: start[0],
  223. y: start[1],
  224. width: api.size([100, 1])[0] * ((api.value(3) - api.value(2)) / 100),
  225. height: api.size([100, 1])[1] * (api.value(1) - api.value(0))
  226. }, {
  227. x: params.coordSys.x,
  228. y: params.coordSys.y,
  229. width: params.coordSys.width,
  230. height: params.coordSys.height
  231. });
  232. return (
  233. rectShape && {
  234. type: "rect",
  235. shape: rectShape,
  236. style: api.style({
  237. //text: `${data[params.dataIndex].name}`
  238. })
  239. }
  240. );
  241. }
  242. option = {
  243. tooltip: {
  244. formatter: function (params) {
  245. return (
  246. // params.marker +
  247. // params.name +
  248. // ": " +
  249. // params.value[2] +
  250. // "~" +
  251. // params.value[3] + '<br/>' + params.marker + `hashMode:${params.data.hashMode}`
  252. params.marker + params.data.STATE + "<br/>"
  253. + params.marker + params.data.fNo + "<br/>"
  254. + params.marker + params.data.F_COL + "行" + params.data.F_LAYER + "列" + params.data.F_DEPTH + "层" //光标悬浮显示内容
  255. );
  256. }
  257. },
  258. title: {
  259. // text: "Profile",
  260. left: "center"
  261. },
  262. grid: {
  263. // height: chartHeight
  264. },
  265. xAxis: {
  266. min: 0,
  267. splitNumber: slotCnt,
  268. max: slotCnt
  269. },
  270. yAxis: [{
  271. position: "left",
  272. max: layerList,
  273. min: 0,
  274. splitNumber: layerList
  275. }
  276. //,
  277. //{
  278. // position: "left",
  279. // data: layerList
  280. //}
  281. ],
  282. series: [{
  283. type: "custom",
  284. itemStyle: {
  285. //normal: {
  286. // opacity: 1
  287. //},
  288. //borderColor: 'red',
  289. //borderWidth: 3
  290. },
  291. renderItem: renderItem,
  292. encode: {
  293. x: [1, 2],
  294. y: 0
  295. },
  296. data: data,
  297. }]
  298. };
  299. }
  300. };
  301. page.init();
  302. };