123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- $(document).ready(function () {
- let now = new Date();
- let year = now.getFullYear();
- let month = now.getMonth() + 1;
- let day = now.getDate();
- if (day >= 20) {
- month++
- }
- $("#selectYear").val(year);
- $("#selectMonth").val(month);
- initMonthModuleTable();
- });
- var monthModuleTable;
- $("#selectMark").change(function () {
- monthModuleTable.bootstrapTable("refreshOptions", { pageNubmer: 1 });
- });
- $("#selectYear").change(function () {
- monthModuleTable.bootstrapTable("refreshOptions", { pageNubmer: 1 });
- });
- $("#selectMonth").change(function () {
- monthModuleTable.bootstrapTable("refreshOptions", { pageNubmer: 1 });
- });
- function initMonthModuleTable() {
- var queryUrl = '/MonthModule/GetMonthModuleTypes';
- monthModuleTable = $("#table").bootstrapTable({
- url: queryUrl,
- showFooter: true,
- queryParams: function (params) {
- var param = {
- mark: $('#selectMark option:selected').val(),
- year: $('#selectYear option:selected').val(),
- month: $('#selectMonth option:selected').val()
- };
- return param;
- },
- columns: [
- { field: "id", title: "ID", visible: false },
- { field: "mark", title: "Mark", visible: false },
- { field: "year", title: "年", visible: false },
- { field: "month", title: "月", visible: false },
- { field: "moduleType", title: "机种" },
- {
- field: "planCapacity", title: "计划产能",
- footerFormatter: function (value) {
- var count = 0;
- for (var i in value) {
- count += value[i].planCapacity
- }
- $("#planTotal").text(count);
- return count;
- }
- },
- {
- field: "lastModuleCapacity", title: "上月差异",
- footerFormatter: function (value) {
- var count = 0;
- for (var i in value) {
- count += value[i].lastModuleCapacity
- }
- $("#lastTotal").text(count);
- return count;
- } },
- { field: "remark", title: "说明" },
- {
- title: '操作',
- field: "id",
- formatter: operation,
- width: 200
- }
- ]
- });
- }
- function operation(value, row, index) {
- var htm =
- "<a class='label' onclick='modelUpdate(\"" + value + "\")'> <i class='fa fa-edit'> 编辑</i></a >" +
- "<a class='label' onclick='deleted(\"" + value + "\")'> <i class='fa fa-trash-o'> 删除</i></a >";
- return htm;
- }
- function refreshTable() {
- monthModuleTable.bootstrapTable("refreshOptions", { pageNubmer: 1 });
- }
- function modelCreate() {
- $("#Id").val("");
- $('#mark').val($('#selectMark option:selected').val());
- $('#year').val($('#selectYear option:selected').val());
- $('#month').val($('#selectMonth option:selected').val());
- $("#modal_month_module_add").modal("show");
- }
- function saveMonthModule() {
- var id = $("#Id").val();
- var url;
- if (id === null || id === "") {
- url = "/MonthModule/CreateMonthModuleType";
- } else {
- url = "/MonthModule/UpdateMonthModuleType";
- }
- var ModuleType = $("#ModuleType").val();
- var PlanCapacity = $("#PlanCapacity").val();
- var LastModuleCapacity = $("#LastModuleCapacity").val();
- var mark = $('#mark').val();
- var year = $('#year').val();
- var month = $('#month').val();
- var remark = $('#remark').val();
- $.ajax({
- url: url,
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- async: true,
- data: JSON.stringify({
- "id": id,
- "moduleType": ModuleType,
- "planCapacity": parseInt(PlanCapacity),
- "lastModuleCapacity": parseInt(LastModuleCapacity),
- "mark": mark,
- "year": parseInt(year),
- "month": parseInt(month),
- "remark": remark
- }),
- success: function (result) {
- if (result.code === 0) {
- $("#modal_month_module_add").modal("hide");
- refreshTable();
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- }
- function modelUpdate(id) {
- $("#Id").val(id);
- $.ajax({
- url: "/MonthModule/GetMonthModuleTypes/" + id,
- method: "GET",
- headers: { "Content-Type": "application/json" },
- async: true,
- data: {
- "year": $('#selectYear').val(),
- "month": $('#selectMonth').val()
- },
- success: function (result) {
- if (result.code === 0) {
- $("#ModuleType").val(result.data.moduleType);
- $("#PlanCapacity").val(result.data.planCapacity);
- $("#LastModuleCapacity").val(result.data.lastModuleCapacity);
- $('#mark').val(result.data.mark);
- $('#year').val(result.data.year);
- $('#month').val(result.data.month);
- $('#remark').val(result.data.remark);
- $("#modal_month_module_add").modal("show");
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
-
- }
- function deleted(id) {
- $.ajax({
- url: "/MonthModule/DeleteMonthModuleType",
- method: "POST",
- headers: { "Content-Type": "application/json" },
- async: true,
- data: JSON.stringify({
- "id": id
- }),
- success: function (result) {
- if (result.code === 0) {
- refreshTable();
- } else if (result.code === 1) {
- alert(result.message);
- }
- }
- });
- }
|