right.nav.frame.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. var prefix = server;
  2. var factoryId = getQueryStringByName("factoryId");
  3. var plantId = getQueryStringByName("plantId");
  4. var statusId = getQueryStringByName("statusId");
  5. layui.use(["form", "layer", "laydate"], function () {
  6. var form = layui.form;
  7. var layer = layui.layer;
  8. var laydate = layui.laydate;
  9. laydate.render({
  10. elem: "#time", //指定元素
  11. value: new Date(dateFormat("yyyy-MM-dd", new Date())), //初始值填充
  12. });
  13. bindFactory();
  14. getProcesses();
  15. getMacModels();
  16. getPlants(factoryId);
  17. getStandardStatus();
  18. // 园区改变时重新加载
  19. form.on("select(factoryId)", function (data) {
  20. const facId = data.value;
  21. getPlants(facId);
  22. });
  23. // 厂房改变时重新加载
  24. form.on("select(plantId)", function (data) {
  25. const plantId = data.value;
  26. getFloors(plantId);
  27. });
  28. form.on("select(floorId)", function (data) {
  29. const plantId = data.value;
  30. getLines(plantId);
  31. });
  32. form.on("switch(changeScroll)", function (data) {
  33. parent.autoScrollBool = this.checked;
  34. parent.autoScroll(this.checked);
  35. });
  36. form.on("submit(*)", function (data) {
  37. if (!data.field.processSelect || data.field.processSelect.length <= 0) {
  38. alert("请至少选择一种设备类型");
  39. return;
  40. }
  41. var params = {
  42. factory: data.field.factory,
  43. plant: data.field.plant,
  44. floor: data.field.floorSelect,
  45. recipe: data.field.recipe,
  46. types: data.field.processSelect,
  47. maccode: data.field.maccode,
  48. macModels: data.field.macModelSelect,
  49. lines: data.field.lineSelect,
  50. status: data.field.statusSelect,
  51. time: data.field.time,
  52. shift: data.field.shift,
  53. };
  54. parent.showLoading();
  55. parent.initChartAndMachines(params);
  56. laydate.render({
  57. elem: "#time", //指定元素
  58. value: params.time, //初始值填充
  59. });
  60. // layer.load();
  61. // hideNav();
  62. return false;
  63. });
  64. window.renderForm = function () {
  65. form.render();
  66. };
  67. // 获取园区
  68. function bindFactory() {
  69. // $.ajaxSettings.async = false;
  70. axios.get(prefix + "/eap/api/factoryregion/GetSelect").then((res) => {
  71. if (res) {
  72. for (var i = 0; i < res.length; i++) {
  73. if (res[i].value) {
  74. var option = $("<option>");
  75. option.val(res[i].value);
  76. option.text(res[i].label);
  77. $("select[name=factory]").append(option);
  78. }
  79. }
  80. $("select[name=factory]").val(factoryId);
  81. }
  82. });
  83. }
  84. // 获取制程
  85. function getProcesses() {
  86. axios
  87. .get(prefix + "/eap/api/RmsTProcess/get", {
  88. params: {
  89. filter: "",
  90. pageIndex: 1,
  91. pageSize: 1000,
  92. },
  93. })
  94. .then((res) => {
  95. if (res && res.data) {
  96. var datas = res.data;
  97. var selectedValues = [];
  98. for (var i = 0; i < datas.length; i++) {
  99. if (datas[i]) {
  100. var option = $("<option>");
  101. option.attr("value", datas[i].fCode);
  102. option.text(datas[i].fCode);
  103. option.prop("selected", true);
  104. $("#processSelect").append(option);
  105. selectedValues.push(datas[i].fCode);
  106. }
  107. }
  108. $("#processSelect").val(selectedValues);
  109. form.render();
  110. }
  111. });
  112. }
  113. // 获取设备型号
  114. function getMacModels() {
  115. axios
  116. .get(prefix + "/eap/api/macmodel/GetMacModels", {
  117. params: {
  118. filter: "",
  119. pageIndex: 1,
  120. pageSize: 1000,
  121. },
  122. })
  123. .then((res) => {
  124. if (res && res.length > 0) {
  125. var datas = res;
  126. var selectedValues = [];
  127. for (var i = 0; i < datas.length; i++) {
  128. if (datas[i]) {
  129. var option = $("<option>");
  130. option.attr("value", datas[i].value);
  131. option.text(datas[i].label);
  132. option.prop("selected", true);
  133. $("#macModelSelect").append(option);
  134. selectedValues.push(datas[i].value);
  135. }
  136. }
  137. $("#macModelSelect").val(selectedValues);
  138. form.render();
  139. }
  140. });
  141. }
  142. // 根据园区ID获取该园区下的厂房
  143. function getPlants(factoryId) {
  144. $("select[name=plant]").empty();
  145. axios
  146. .get(prefix + "/eap/api/factoryregion/GetPlantsSelect", {
  147. params: {
  148. factoryId: factoryId,
  149. },
  150. })
  151. .then((res) => {
  152. if (res) {
  153. for (var i = 0; i < res.length; i++) {
  154. if (res[i].value) {
  155. var option = $("<option>");
  156. option.val(res[i].value);
  157. option.text(res[i].label);
  158. $("select[name=plant]").append(option);
  159. }
  160. }
  161. if (plantId) {
  162. $("select[name=plant]").val(plantId);
  163. }
  164. getFloors($("select[name=plant]").val());
  165. }
  166. });
  167. }
  168. // 根据园区ID和厂房ID获取该厂房下的楼层车间
  169. function getFloors(plantId) {
  170. axios
  171. .get(prefix + "/eap/api/FactoryRegion/GetFloorsSelect", {
  172. params: {
  173. plantId: plantId,
  174. },
  175. })
  176. .then((res) => {
  177. $("#floorSelect").empty();
  178. if (res && res.length > 0) {
  179. var datas = res;
  180. var selectedValues = [];
  181. $("#floorSelect")
  182. .empty()
  183. .append(' <option value="">-- 请选择楼层车间 --</option>');
  184. for (var i = 0; i < datas.length; i++) {
  185. if (datas[i]) {
  186. var option = $("<option>");
  187. option.attr("value", datas[i].value);
  188. option.text(datas[i].label);
  189. option.prop("selected", true);
  190. $("#floorSelect").append(option);
  191. selectedValues.push(datas[i].value);
  192. }
  193. }
  194. $("#floorSelect").val(selectedValues);
  195. getLines(selectedValues);
  196. }
  197. });
  198. }
  199. // 根据园区ID获取该园区下的线体
  200. function getLines(floorIds) {
  201. var ids = floorIds.join(",");
  202. $("#lineSelect").empty();
  203. axios
  204. .get(prefix + "/eap/api/FactoryRegion/GetLinesSelect", {
  205. params: {
  206. ids: ids,
  207. },
  208. })
  209. .then((res) => {
  210. if (res && res.length > 0) {
  211. var datas = res;
  212. var selectedValues = [];
  213. $("#lineSelect")
  214. .empty()
  215. .append(' <option value="">-- 请选择线体 --</option>');
  216. for (var i = 0; i < datas.length; i++) {
  217. if (datas[i]) {
  218. var option = $("<option>");
  219. option.attr("value", datas[i].value);
  220. option.text(datas[i].label);
  221. option.prop("selected", true);
  222. $("#lineSelect").append(option);
  223. selectedValues.push(datas[i].value);
  224. }
  225. }
  226. $("#lineSelect").val(selectedValues);
  227. }
  228. form.render();
  229. });
  230. }
  231. // 获取所有的状态
  232. function getStandardStatus() {
  233. axios
  234. .get(prefix + "/eap/api/ConstItem/GetStatndardStatuses", {
  235. params: {
  236. filter: "",
  237. pageIndex: 1,
  238. pageSize: 1000,
  239. },
  240. })
  241. .then((res) => {
  242. if (res && res.length > 0) {
  243. var datas = res;
  244. var selectedValues = [];
  245. for (var i = 0; i < datas.length; i++) {
  246. if (datas[i] && datas[i].value) {
  247. var option = $("<option>");
  248. option.attr("value", datas[i].value);
  249. option.text(datas[i].label);
  250. option.prop("selected", true);
  251. $("#statusSelect").append(option);
  252. selectedValues.push(datas[i].value);
  253. }
  254. }
  255. if (statusId) {
  256. if (statusId > 0) {
  257. $("#statusSelect").val(statusId);
  258. } else if (statusId == 0) {
  259. var otherValues = [];
  260. selectedValues.forEach((item) => {
  261. if (item != 1 && item != 3 && item != 4 && item != 6) {
  262. otherValues.push(item);
  263. }
  264. });
  265. $("#statusSelect").val(otherValues);
  266. } else {
  267. $("#statusSelect").val(selectedValues);
  268. }
  269. } else {
  270. $("#statusSelect").val(selectedValues);
  271. }
  272. form.render();
  273. }
  274. });
  275. }
  276. });
  277. function setRefreshDate(date) {
  278. $("#lastDate").val(dateFormat("yyyy-MM-dd HH:mm:ss", date));
  279. // window.renderForm();
  280. }