完成廠商crud
This commit is contained in:
parent
0aea9d189a
commit
2c1c677902
@ -354,7 +354,7 @@
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
||||
if (rel.code == "0000")
|
||||
location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization");
|
||||
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + localStorage.getItem("JWT-Authorization");
|
||||
}, null, "POST").send();
|
||||
}
|
||||
</script>
|
@ -141,7 +141,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
|
||||
<button type="button" class="btn btn-secondary" id="OpeFirmCanBtn" data-dismiss="modal">關閉</button>
|
||||
<button type="button" class="btn btn-primary" id="OpeFirmSendBtn" e-prevent>儲存</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -217,6 +217,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
確定刪除這一筆嗎?
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" id="confirmDelCanBtn" data-dismiss="modal">關閉</button>
|
||||
<button type="button" class="btn btn-primary" id="confirmDelBtn" e-prevent>儲存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
pageAct.sub_system_tag = null;
|
||||
@ -324,9 +343,10 @@
|
||||
{
|
||||
"title": "功能",
|
||||
"data": "id",
|
||||
"render": function () {
|
||||
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
|
||||
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn", null, ["btn", "btn-danger"]));
|
||||
"render": function (data) {
|
||||
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }, null, null, {id: data});
|
||||
btnDiv.append(creBtnHtml("修改", "opeFirmEdiBtn", null, ["btn", "btn-info"], { "toggle": "modal", "target": "#opeFirmModal"}));
|
||||
btnDiv.append(creBtnHtml("刪除", "opeFirmDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
|
||||
return btnDiv.outerHtml();
|
||||
}
|
||||
},
|
||||
@ -419,9 +439,9 @@
|
||||
{
|
||||
"title": "功能",
|
||||
"data": "id",
|
||||
"render": function () {
|
||||
"render": function (data) {
|
||||
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
|
||||
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn", null, ["btn", "btn-danger"]));
|
||||
btnDiv.append(creBtnHtml("刪除", "opeRecDelBtn", null, ["btn", "btn-danger"], { "id": data }));
|
||||
return btnDiv.outerHtml();
|
||||
}
|
||||
},
|
||||
@ -539,11 +559,11 @@
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
||||
if (rel.code == "0000")
|
||||
location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization");
|
||||
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + localStorage.getItem("JWT-Authorization");
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
function selSysMain() {
|
||||
function selSysMain(tag = null) {
|
||||
let url = baseApiUrl + "/operation/MaiSysList";
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, null, function (res) {
|
||||
@ -557,7 +577,7 @@
|
||||
strHtml += `<option value='${roleObj.system_value}'>${roleObj.system_key}</option>`;
|
||||
|
||||
if (index == 0)
|
||||
pageAct.selSysMain = roleObj.system_value
|
||||
pageAct.selSysMain = tag ?? roleObj.system_value
|
||||
})
|
||||
$("#selSysMain").html(strHtml);
|
||||
selSysSub();
|
||||
@ -582,6 +602,8 @@
|
||||
|
||||
function event() {
|
||||
onEvent('click', '#newForm', function () {
|
||||
pageAct.opeFirmAct = 'add';
|
||||
$('#opeFirmModal input').map(function (i, v) { $(v).val('') });
|
||||
selSysMain();
|
||||
});
|
||||
|
||||
@ -590,40 +612,87 @@
|
||||
selSysSub();
|
||||
});
|
||||
|
||||
onEvent('click', '#opeFirmEdiBtn', function () {
|
||||
let url = baseApiUrl + "/operation/OpeFirRead";
|
||||
pageAct.opeFirmId = $(this).parent().data('id')
|
||||
objSendData.Data = { id: pageAct.opeFirmId };
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
pageAct.opeFirmAct = 'edit';
|
||||
selSysMain(res.data.device_system_category_layer2);
|
||||
$('#opeFirmForm select[id=selSysMain]').val(res.data.device_system_category_layer2).change();
|
||||
$('#opeFirmForm select[id=selSysSub]').val(res.data.device_system_category_layer3).change();
|
||||
$('#opeFirmForm input[id=inpName]').val(res.data.name);
|
||||
$('#opeFirmForm input[id=inpConPer]').val(res.data.contact_person);
|
||||
$('#opeFirmForm input[id=inpPhone]').val(res.data.phone);
|
||||
$('#opeFirmForm input[id=inpEmail]').val(res.data.email);
|
||||
$('#opeFirmForm input[id=inpTaxIdNum]').val(res.data.tax_id_number);
|
||||
$('#opeFirmForm input[id=inpRemark]').val(res.data.remark);
|
||||
}
|
||||
}, null, "POST").send()
|
||||
});
|
||||
|
||||
onEvent("click", "#OpeFirmSendBtn", function () {
|
||||
let form = $("#opeFirmForm");
|
||||
console.log(form);
|
||||
|
||||
$(form).validate({
|
||||
rules: {
|
||||
selSysMain: { required: true },
|
||||
selSysSub: { required: true },
|
||||
name: { required: true, maxlength: 50 }
|
||||
inpName: { required: true, maxlength: 50 }
|
||||
}
|
||||
});
|
||||
//if ($(form).valid()) {
|
||||
// console.log($('#selSysMain').val());
|
||||
// let url = baseApiUrl + "/operation/SaveOpeFirm";
|
||||
// let sendData = {
|
||||
// device_system_category_layer2: $('#selSysMain').val(),
|
||||
// device_system_category_layer3: $('#selSysSub').val(),
|
||||
// name: $("#inpName").val(),
|
||||
// contact_person: $("#inpConPer").val(),
|
||||
// phone: $("#inpPhone").val(),
|
||||
// email: $("#inpEmail").val(),
|
||||
// tax_id_number: $("#inpTaxIdNum").val(),
|
||||
// remark: $("#inpRemark").val()
|
||||
// };
|
||||
// objSendData.Data = sendData;
|
||||
// //$("#opeFirmModal").modal("hide");
|
||||
// //ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
// // if (!res || res.code != "0000" || !res.data) {
|
||||
if ($(form).valid()) {
|
||||
let url = baseApiUrl + "/operation/" + (pageAct.opeFirmAct == "add" ? 'SaveOpeFirm' : 'EdtOneOpeFirm');
|
||||
let sendData = {
|
||||
device_system_category_layer2: $('#selSysMain').val(),
|
||||
device_system_category_layer3: $('#selSysSub').val(),
|
||||
name: $("#inpName").val() || null,
|
||||
contact_person: $("#inpConPer").val() || null,
|
||||
phone: $("#inpPhone").val() || null,
|
||||
email: $("#inpEmail").val() || null,
|
||||
tax_id_number: $("#inpTaxIdNum").val() || null,
|
||||
remark: $("#inpRemark").val() || null
|
||||
};
|
||||
|
||||
// // } else {
|
||||
// // toast_ok(common.AddSuc);
|
||||
// // $("#opeFirmModal").modal("hide");
|
||||
// // }
|
||||
// //}, null, "POST").send();
|
||||
//}
|
||||
if (pageAct.opeFirmAct == "edit")
|
||||
sendData.id = pageAct.opeFirmId;
|
||||
|
||||
objSendData.Data = sendData;
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
//toast_ok(common.AddSuc);
|
||||
//$("#opeFirmModal").modal("hide");
|
||||
$("#OpeFirmCanBtn").click();
|
||||
refTable();
|
||||
}
|
||||
}, null, "POST").send();
|
||||
}
|
||||
});
|
||||
|
||||
onEvent("click", "#opeFirmDelBtn", function () {
|
||||
pageAct.opeFirmId = $(this).parent().data('id');
|
||||
});
|
||||
|
||||
onEvent("click", "#confirmDelBtn", function () {
|
||||
objSendData.Data = { id: pageAct.opeFirmId };
|
||||
let url = baseApiUrl + "/operation/" + (pageAct.work_type == null ? "DelOpeFirm" : "DelOpeRecord");
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
//toast_ok(common.AddSuc);
|
||||
//$("#delModal").modal("hide");
|
||||
$("#confirmDelCanBtn").click();
|
||||
refTable();
|
||||
}
|
||||
}, null, "DELETE").send();
|
||||
});
|
||||
}
|
||||
</script>
|
@ -2586,6 +2586,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
"n4js/historybaja",
|
||||
"lib/statistics/flot/flot.bundle",
|
||||
"lib/statistics/peity/peity.bundle",
|
||||
"lib/jquery-validation/dist/jquery.validate",
|
||||
"lib/jquery-validation/dist/additional-methods.min",
|
||||
"lib/jquery-validation/dist/localization/messages_zh_TW",
|
||||
], loadedMasterPack);
|
||||
}
|
||||
/**
|
||||
|
@ -104,9 +104,6 @@
|
||||
[
|
||||
"lib/app.bundle",
|
||||
"lib/app.menu",
|
||||
"lib/jquery-validation/dist/jquery.validate",
|
||||
"lib/jquery-validation/dist/additional-methods.min",
|
||||
"lib/jquery-validation/dist/localization/messages_zh_TW",
|
||||
/*"lib/notifications/sweetalert2/sweetalert2.bundle",*/
|
||||
], loadedMasterPack);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = fileName;
|
||||
apiResult.Data = "history/" + fileName;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
|
||||
[HttpGet]
|
||||
[Route("api/df")]
|
||||
public ActionResult DownloadFile(string fileName, string token)
|
||||
public ActionResult DownloadFile(string path, string fileName, string token)
|
||||
{
|
||||
var jwt = new JwtSecurityTokenHandler().ReadJwtToken(token);
|
||||
if (jwt == null)
|
||||
@ -147,7 +147,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
else if (fileName == null)
|
||||
return NotFound("找不到文件");
|
||||
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", "history");
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", path);
|
||||
return File(System.IO.File.ReadAllBytes(Path.Combine(filePath, fileName)), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = fileName;
|
||||
apiResult.Data = "operation/" + fileName;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
BIN
FrontendWebApi/wwwroot/excel/operation/廠商資料.xlsx
Normal file
BIN
FrontendWebApi/wwwroot/excel/operation/廠商資料.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user