123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- var prefix = server;
- var factoryId = getQueryStringByName("factoryId");
- var plantId = getQueryStringByName("plantId");
- var statusId = getQueryStringByName("statusId");
- layui.use(["form", "layer", "laydate"], function () {
- var form = layui.form;
- var layer = layui.layer;
- var laydate = layui.laydate;
- laydate.render({
- elem: "#time", //指定元素
- value: new Date(dateFormat("yyyy-MM-dd", new Date())), //初始值填充
- });
- bindFactory();
- getProcesses();
- getMacModels();
- getPlants(factoryId);
- getStandardStatus();
- // 园区改变时重新加载
- form.on("select(factoryId)", function (data) {
- const facId = data.value;
- getPlants(facId);
- });
- // 厂房改变时重新加载
- form.on("select(plantId)", function (data) {
- const plantId = data.value;
- getFloors(plantId);
- });
- form.on("select(floorId)", function (data) {
- const plantId = data.value;
- getLines(plantId);
- });
- form.on("switch(changeScroll)", function (data) {
- parent.autoScrollBool = this.checked;
- parent.autoScroll(this.checked);
- });
- form.on("submit(*)", function (data) {
- if (!data.field.processSelect || data.field.processSelect.length <= 0) {
- alert("请至少选择一种设备类型");
- return;
- }
- var params = {
- factory: data.field.factory,
- plant: data.field.plant,
- floor: data.field.floorSelect,
- recipe: data.field.recipe,
- types: data.field.processSelect,
- maccode: data.field.maccode,
- macModels: data.field.macModelSelect,
- lines: data.field.lineSelect,
- status: data.field.statusSelect,
- time: data.field.time,
- shift: data.field.shift,
- };
- parent.showLoading();
- parent.initChartAndMachines(params);
- laydate.render({
- elem: "#time", //指定元素
- value: params.time, //初始值填充
- });
- // layer.load();
- // hideNav();
- return false;
- });
- window.renderForm = function () {
- form.render();
- };
- // 获取园区
- function bindFactory() {
- // $.ajaxSettings.async = false;
- axios.get(prefix + "/eap/api/factoryregion/GetSelect").then((res) => {
- if (res) {
- for (var i = 0; i < res.length; i++) {
- if (res[i].value) {
- var option = $("<option>");
- option.val(res[i].value);
- option.text(res[i].label);
- $("select[name=factory]").append(option);
- }
- }
- $("select[name=factory]").val(factoryId);
- }
- });
- }
- // 获取制程
- function getProcesses() {
- axios
- .get(prefix + "/eap/api/RmsTProcess/get", {
- params: {
- filter: "",
- pageIndex: 1,
- pageSize: 1000,
- },
- })
- .then((res) => {
- if (res && res.data) {
- var datas = res.data;
- var selectedValues = [];
- for (var i = 0; i < datas.length; i++) {
- if (datas[i]) {
- var option = $("<option>");
- option.attr("value", datas[i].fCode);
- option.text(datas[i].fCode);
- option.prop("selected", true);
- $("#processSelect").append(option);
- selectedValues.push(datas[i].fCode);
- }
- }
- $("#processSelect").val(selectedValues);
- form.render();
- }
- });
- }
- // 获取设备型号
- function getMacModels() {
- axios
- .get(prefix + "/eap/api/macmodel/GetMacModels", {
- params: {
- filter: "",
- pageIndex: 1,
- pageSize: 1000,
- },
- })
- .then((res) => {
- if (res && res.length > 0) {
- var datas = res;
- var selectedValues = [];
- for (var i = 0; i < datas.length; i++) {
- if (datas[i]) {
- var option = $("<option>");
- option.attr("value", datas[i].value);
- option.text(datas[i].label);
- option.prop("selected", true);
- $("#macModelSelect").append(option);
- selectedValues.push(datas[i].value);
- }
- }
- $("#macModelSelect").val(selectedValues);
- form.render();
- }
- });
- }
- // 根据园区ID获取该园区下的厂房
- function getPlants(factoryId) {
- $("select[name=plant]").empty();
- axios
- .get(prefix + "/eap/api/factoryregion/GetPlantsSelect", {
- params: {
- factoryId: factoryId,
- },
- })
- .then((res) => {
- if (res) {
- for (var i = 0; i < res.length; i++) {
- if (res[i].value) {
- var option = $("<option>");
- option.val(res[i].value);
- option.text(res[i].label);
- $("select[name=plant]").append(option);
- }
- }
- if (plantId) {
- $("select[name=plant]").val(plantId);
- }
- getFloors($("select[name=plant]").val());
- }
- });
- }
- // 根据园区ID和厂房ID获取该厂房下的楼层车间
- function getFloors(plantId) {
- axios
- .get(prefix + "/eap/api/FactoryRegion/GetFloorsSelect", {
- params: {
- plantId: plantId,
- },
- })
- .then((res) => {
- $("#floorSelect").empty();
- if (res && res.length > 0) {
- var datas = res;
- var selectedValues = [];
- $("#floorSelect")
- .empty()
- .append(' <option value="">-- 请选择楼层车间 --</option>');
- for (var i = 0; i < datas.length; i++) {
- if (datas[i]) {
- var option = $("<option>");
- option.attr("value", datas[i].value);
- option.text(datas[i].label);
- option.prop("selected", true);
- $("#floorSelect").append(option);
- selectedValues.push(datas[i].value);
- }
- }
- $("#floorSelect").val(selectedValues);
- getLines(selectedValues);
- }
- });
- }
- // 根据园区ID获取该园区下的线体
- function getLines(floorIds) {
- var ids = floorIds.join(",");
- $("#lineSelect").empty();
- axios
- .get(prefix + "/eap/api/FactoryRegion/GetLinesSelect", {
- params: {
- ids: ids,
- },
- })
- .then((res) => {
- if (res && res.length > 0) {
- var datas = res;
- var selectedValues = [];
- $("#lineSelect")
- .empty()
- .append(' <option value="">-- 请选择线体 --</option>');
- for (var i = 0; i < datas.length; i++) {
- if (datas[i]) {
- var option = $("<option>");
- option.attr("value", datas[i].value);
- option.text(datas[i].label);
- option.prop("selected", true);
- $("#lineSelect").append(option);
- selectedValues.push(datas[i].value);
- }
- }
- $("#lineSelect").val(selectedValues);
- }
- form.render();
- });
- }
- // 获取所有的状态
- function getStandardStatus() {
- axios
- .get(prefix + "/eap/api/ConstItem/GetStatndardStatuses", {
- params: {
- filter: "",
- pageIndex: 1,
- pageSize: 1000,
- },
- })
- .then((res) => {
- if (res && res.length > 0) {
- var datas = res;
- var selectedValues = [];
- for (var i = 0; i < datas.length; i++) {
- if (datas[i] && datas[i].value) {
- var option = $("<option>");
- option.attr("value", datas[i].value);
- option.text(datas[i].label);
- option.prop("selected", true);
- $("#statusSelect").append(option);
- selectedValues.push(datas[i].value);
- }
- }
- if (statusId) {
- if (statusId > 0) {
- $("#statusSelect").val(statusId);
- } else if (statusId == 0) {
- var otherValues = [];
- selectedValues.forEach((item) => {
- if (item != 1 && item != 3 && item != 4 && item != 6) {
- otherValues.push(item);
- }
- });
- $("#statusSelect").val(otherValues);
- } else {
- $("#statusSelect").val(selectedValues);
- }
- } else {
- $("#statusSelect").val(selectedValues);
- }
- form.render();
- }
- });
- }
- });
- function setRefreshDate(date) {
- $("#lastDate").val(dateFormat("yyyy-MM-dd HH:mm:ss", date));
- // window.renderForm();
- }
|