123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- $(document).ready(function () {
- initLineSelect();
- initRecipeTable();
- });
- var recipeTable;
- var size;
- var number;
- function initRecipeTable() {
- var queryUrl = '/Recipe/GetRecipes';
- recipeTable = $("#recipe_table").bootstrapTable({
- url: queryUrl,
- columns: [
- { field: "id", title: "ID", visible: false },
- { field: "productionLineId", title: "线别ID", visible: false },
- { field: "productionLineName", title: "线别" },
- { field: "moduleType", title: "机种" },
- { field: "theoryCapacity", title: "理论产能(pcs)" },
- { field: "theoryTT", title: "理论节拍(s)" },
- { field: "theoryRefueledTime", title: "换料标准(min)" },
- { field: "createTime", title: "创建时间" },
- {
- title: '操作',
- field: "id",
- formatter: operation,
- width: 200
- }
- ],
- pagination: true,
- pageNumber: 1,
- pageSize: size,
- pageList: [10, 25, 50, 100],
- smartDisplay: false,
- sidePagination: "server",
- queryParams: function (params) {
- var temp = {
- pageNumber: (params.offset / params.limit) + 1,
- pageSize: params.limit,
- keyword: $("#keyword").val()
- };
- number = temp.pageNumber;
- return temp;
- }
- });
- }
- function initLineSelect() {
- $.ajax({
- url: "/ProductionLine/GetProductionLines",
- method: "GET",
- headers: { "Content-Type": "application/json" },
- async: true,
- success: function (result) {
- if (result.code === 0) {
- for (var i = 0; i < result.data.length; i++) {
- var id = result.data[i].id;
- var value = result.data[i].name;
- $("#Line").append("<option value=" + id + ">" + value + "</option>");
- }
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- }
- function operation(value, row, index) {
- var htm =
- "<a class='label' onclick='modelUpdateRecipe(\"" + value + "\")'> <i class='fa fa-edit'> 编辑</i></a >" +
- "<a class='label' onclick='deleteRecipe(\"" + value + "\")'> <i class='fa fa-trash-o'> 删除</i></a >";
- return htm;
- }
- function refreshRecipeTable() {
- recipeTable.bootstrapTable("refreshOptions", { pageNubmer: 1 });
- }
- function selectPageRecipeTable() {
- recipeTable.bootstrapTable("selectPage", number);
- }
- function modelCreateRecipe() {
- $("#Id").val("");
- $("#modal_recipe_add").modal("show");
- }
- function saveRecipe() {
- var id = $("#Id").val();
- var url;
- if (id === null || id === "") {
- url = "/Recipe/CreateRecipe";
- } else {
- url = "/Recipe/UpdateRecipe/" + id;
- }
- var ModuleType = $("#ModuleType").val();
- var TheoryCapacity = $("#TheoryCapacity").val();
- var TheoryTT = $("#TheoryTT").val();
- var ProductionLineId = $("#Line").val();
- var TheoryRefueledTime = $("#TheoryRefueledTime").val();
- $.ajax({
- url: url,
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- async: true,
- data: JSON.stringify({
- "moduleType": ModuleType,
- "productionLineId": ProductionLineId,
- "theoryCapacity": parseInt(TheoryCapacity),
- "theoryTT": parseFloat(TheoryTT),
- "theoryRefueledTime": parseFloat(TheoryRefueledTime)
- }),
- success: function (result) {
- if (result.code === 0) {
- $("#modal_recipe_add").modal("hide");
- if (id === null || id === "") {
- refreshRecipeTable();
- } else {
- selectPageRecipeTable();
- }
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- }
- function modelUpdateRecipe(id) {
- $("#Id").val(id);
- $.ajax({
- url: "/Recipe/" + id,
- method: "GET",
- headers: { "Content-Type": "application/json" },
- async: true,
- success: function (result) {
- if (result.code === 0) {
- $("#ModuleType").val(result.data.moduleType);
- $("#TheoryCapacity").val(result.data.theoryCapacity);
- $("#TheoryTT").val(result.data.theoryTT);
- $("#Line").val(result.data.productionLineId);
- $("#TheoryRefueledTime").val(result.data.theoryRefueledTime)
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- $("#modal_recipe_add").modal("show");
- }
- function deleteRecipe(id) {
- $.ajax({
- url: "/Recipe/DeleteRecipe/" + id,
- method: "POST",
- headers: { "Content-Type": "application/json" },
- async: true,
- success: function (result) {
- if (result.code === 0) {
- if (id === null || id === "") {
- refreshRecipeTable();
- } else {
- selectPageRecipeTable();
- }
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- }
|