123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- let arr = [{
- id: 0,
- name: "预处理"
- },
- {
- id: 1,
- name: "特征提取"
- },
- {
- id: 2,
- name: "参数优化"
- },
- {
- id: 3,
- name: "故障诊断"
- },
- {
- id: 4,
- name: "寿命预测"
- },
- {
- id: 5,
- name: "其他"
- },
- ]
- var majorId = 0;
- $(function() {
- var params = window.location.href.split("?");
- if (params.length > 1) {
- values = params[1].split("&");
-
- if (values.length > 7) {
- var funcId = values[0].replace("id=", "");
- var algorithm_type = '';
- var algorithm_name = '';
- var algorithm_format = '';
- var device_name = '';
- var create_time = '';
- var algorithm_path = '';
- var remarks = '';
- if (funcId !== "0") {
- algorithm_type = decodeURI(values[1].replace("algorithm_type=", ""));
- // console.log(algorithm_type)
- algorithm_name = decodeURI(values[2].replace("algorithm_name=", ""));
- algorithm_format = decodeURI(values[3].replace("algorithm_format=", ""));
- device_name = decodeURI(values[4].replace("device_name=", ""));
- create_time = decodeURI(values[5].replace("create_time=", ""));
- algorithm_path = decodeURI(values[6].replace("algorithm_path=", ""));
- remarks = decodeURI(values[7].replace("remarks=", ""));
- }
- }
- }
- // $("#algorithm_typeSelect").find("option:selected").val(algorithm_type);
- $("#algorithm_name").val(algorithm_name);
- $("#algorithm_format").val(algorithm_format);
- $("#device_name").val(device_name);
- $("#create_time").val(create_time);
- $("#algorithm_path").val(algorithm_path);
- $("#remarks").val(remarks);
- layui.use("form", function() {
- layui.form.render();
- });
- layui.use(["form", "layer", "upload", "laydate"], function() {
- $ = layui.jquery;
- var form = layui.form,
- layer = layui.layer;
- var upload = layui.upload;
-
- form.on("select", function(data) {
- if (data.elem.id === "algorithm_typeSelect"){
- algorithm_type = data.elem[data.elem.selectedIndex].text;
- // console.log(algorithm_type)
- }
-
-
- })
- form.on("submit(save)", function(data) {
- var func = data.field;
- func.id = funcId;
- func.algorithm_type = algorithm_type
- let url = "";
- if (func.id === "0") url = "api/algorithm/add";
- else url = "api/algorithm/edit";
- fetchJSON(url, func, "post", function(data) {
- // console.log(data)
- if (data.status === 0) {
- var index = parent.layer.getFrameIndex(window.name);
- showMsg("修改成功", 1, 2000);
- parent.layer.close(index);
- } else {
- showMsg(data.msg, 2);
- }
- });
- return false;
- });
- upload.render({
- elem: '#file',
- url: urlBase + "api/algorithm/importData",
- accept: 'file', //普通文件
- headers: {
- "token": sessionStorage.getItem("token")
- },
- data: {},
- // accept: 'file',
- done: function(res) {
- if (res.status === 0) {
- $("#algorithm_path").val(res.msg);
- } else
- showMsg(res.msg, 2);
- }
- });
- function getAirType() {
- // console.log(bet, "121111111")
- $("#algorithm_typeSelect").empty();
- $("#algorithm_typeSelect").append($("<option>", {
- value: -1,
- text: "请选择"
- }));
- for (var i = 0; i < arr.length; i++) {
- $("#algorithm_typeSelect").append(
- $("<option>", {
- value: arr[i].id,
- text: arr[i].name,
- // selected: true
- })
- );
- }
- layui.use("form", function() {
- layui.form.render('select', 'aircraft_typeFilter');
- });
- // form.render('select');
- }
- getAirType()
- });
- });
|