master
嘉祥 詹 2024-08-16 23:08:54 +08:00
parent 2fe6d5c533
commit 8d4d2a016b
4 changed files with 238 additions and 11 deletions

View File

@ -23,6 +23,38 @@ namespace QuotationMaker.Controllers
this._httpContextAccessor = httpContextAccessor; this._httpContextAccessor = httpContextAccessor;
} }
[Route("authModalQuotationList")]
public ActionResult AuthModalQuotationList(IFormCollection obj)
{
modelQuotationListResult ret = new modelQuotationListResult();
authToken token = new authToken(this._httpContextAccessor);
if (token.user_isLogin == false)
{
HttpContext.Response.Cookies.Delete("token_key");
ret.ret = "no";
ret.err_code = "99999";
ret.message = "非登入狀態!";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
if (token.user_perm != "system")
{
ret.ret = "no";
ret.err_code = "90001";
ret.message = "此帳號無此api使用權限!";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
string dept_uid = obj["dept_uid"].ToString();
string modelProj_uid = obj["modelProj_uid"].ToString();
ret.modelQuotations = conn.Query<modelQuotation>("select * from modelQuotation where modelProj_uid = @modelProj_uid and dept_uid = @dept_uid", new { modelProj_uid = modelProj_uid, dept_uid = dept_uid }).ToList();
ret.ret = "yes";
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
}
[Route("addEditDelGetModelProj")] [Route("addEditDelGetModelProj")]
public ActionResult AddEditDelGetModelProj(IFormCollection obj) { public ActionResult AddEditDelGetModelProj(IFormCollection obj) {
modelProjListResult ret = new modelProjListResult(); modelProjListResult ret = new modelProjListResult();

View File

@ -4,7 +4,13 @@ using Dapper;
using static DbTableClass; using static DbTableClass;
public class resultClass public class resultClass
{ {
public class modelQuotationListResult
{
public string ret = "no";
public string err_code = "0000";
public string message = "";
public List<modelQuotation> modelQuotations = new List<modelQuotation>();
}
public class modelProjListResult public class modelProjListResult
{ {
public string ret = "no"; public string ret = "no";

View File

@ -112,3 +112,54 @@
</div> </div>
</form><!-- /.modal --> </form><!-- /.modal -->
<!-- .modal -->
<form id="clientModelQuotationForm" name="clientModelQuotationForm">
<div class="modal fade" id="clientModelQuotationListModal" tabindex="-1" role="dialog" aria-labelledby="clientModelQuotationListModalLabel" data-backdrop="static"
data-keyboard="false" aria-hidden="true">
<!-- .modal-dialog -->
<div class="modal-dialog modal-lg" role="document">
<!-- .modal-content -->
<div class="modal-content">
<!-- .modal-header -->
<div class="modal-header">
<h6 id="clientNewModalLabel" class="modal-title inline-editable">
<span class="sr-only">範本列表</span> <input id="modelQuotationTitle" type="text" class="form-control form-control-lg" placeholder="範本列表" required="">
</h6>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
</button>
</div><!-- /.modal-header -->
<!-- .modal-body -->
<div class="modal-body">
<input type="hidden" id="modelQuotation_method" />
<input type="hidden" id="parent_modelProj_uid" />
<!-- .page-section -->
<div class="page-section">
<button type="button" id="modelQuotationListNewBtn" class="btn btn-primary btn-floated position-absolute" title="Add new client"><i class="fa fa-plus"></i></button>
<!-- .card -->
<div class="card card-fluid">
<!-- .card-body -->
<div class="card-body">
<!-- .table -->
<table id="dt-responsive-modelQuotation" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th> 範本名稱 </th>
<th> 建立日期 </th>
<th style="width: 25px;"> </th>
</tr>
</thead>
</table><!-- /.table -->
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.page-section -->
</div><!-- /.modal-body -->
<!-- .modal-footer -->
<div class="modal-footer">
<button type="button" id="modelQuotationSaveBtn" style="visibility:hidden;" class="btn btn-primary">儲存</button> <button id="closeBtn" type="button" class="btn btn-light" data-dismiss="modal">關閉</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->

View File

@ -1,8 +1,13 @@
var modelProjTable; var modelProjTable;
var modelProjRowPos; var modelProjRowPos;
var modelProjRowID; var modelProjRowID;
var modelQuotationTable;
var modelQuotationRowPos;
var modelQuotationRowID;
$(document).ready(function () { $(document).ready(function () {
deptList(); deptList();
loadModelQuotationDataTable();
$('#modelProjNewBtn').on('click', function () { $('#modelProjNewBtn').on('click', function () {
$("#modelProj_method").val('add'); $("#modelProj_method").val('add');
@ -70,6 +75,139 @@ $(document).ready(function () {
}); });
}); });
function loadModelQuotationDataTable() {
var dataTables = {
init: function init() {
this.bindUIActions();
},
bindUIActions: function bindUIActions() {
// event handlers
this.table = this.handleDataTables();
// add buttons
//this.table.buttons().container().appendTo('#dt-buttons').unwrap();
},
handleDataTables: function handleDataTables() {
//$('#myTable').append("<tfoot><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tfoot>");
return $('#dt-responsive-subItem').DataTable({
dom: '<\'text-muted\'Bif>\n <\'table-responsive\'trl>\n <\'mt-4\'p>',
lengthChange: true,
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
pageLength: 25,
buttons: [
//{
// text: '休假設定',
// action: function (e, dt, node, config) {
// vacationBtnFun();
// }
//},
//'excelHtml5'
],
language: {
paginate: {
previous: '<i class="fa fa-lg fa-angle-left"></i>',
next: '<i class="fa fa-lg fa-angle-right"></i>'
},
buttons: {
copyTitle: 'Data copied',
copyKeys: 'Use your keyboard or menu to select the copy command'
}
},
autoWidth: false,
rowId: 'modelQuotation_uid',
deferRender: true,
initComplete: function () {
modelQuotationTable = $('#dt-responsive-modelQuotation').dataTable();
$('#dt-responsive-modelQuotation').on('click', 'a', function () {
buttonModelQuotationClick(this);
});
$('#dt-responsive-modelQuotation').on('click', 'button', function () {
buttonModelQuotationClick(this);
});
},
order: [[0, 'desc']],
info: true,
search: "搜尋:",
searching: true,
columns: [
{ data: 'modelQuotation_name', className: 'align-top text-left', orderable: true, searchable: true },
{ data: 'modelQuotation_createdate', className: 'align-top text-right', orderable: true, searchable: true },
{ data: 'modelQuotation_uid', className: 'align-top text-center', orderable: false, searchable: false }
],
columnDefs: [
{
targets: 0,
className: 'align-middle text-left',
orderable: false,
searchable: true,
render: function render(data, type, row, meta) {
return '<a href="javascript: void(0);" data-uid="' + row.modelQuotation_name + '" data-method="preview" >' + row.modelQuotation_name + '</a>';
}
},
{
targets: 1,
className: 'align-middle text-right',
orderable: true,
searchable: true,
render: function render(data, type, row, meta) {
return (new Date(row.modelQuotation_createdate)).format("yyyy/MM/dd hh:mm:ss");
}
},
{
targets: 2,
className: 'align-middle text-center',
orderable: false,
searchable: false,
render: function render(data, type, row, meta) {
var ret = '';
ret += '<button type="button" data-uid="' + row.modelQuotation_uid + '" data-method="edit" class="btn btn-sm btn-icon btn-secondary" ><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
ret += '<button type="button" data-uid="' + row.modelQuotation_uid + '" data-method="del" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
return ret;
}
}
],
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.childRowImmediate,
type: ''
}
}
});
},
handleSearchRecords: function handleSearchRecords() {
var self = this;
$('#table-search, #filterBy').on('keyup change focus', function (e) {
var filterBy = $('#filterBy').val();
var hasFilter = filterBy !== '';
var value = $('#table-search').val();
self.table.search('').columns().search('').draw();
if (hasFilter) {
self.table.columns(filterBy).search(value).draw();
} else {
self.table.search(value).draw();
}
});
}
}
dataTables.init();
}
function loadDataTable() { function loadDataTable() {
var dataTables = { var dataTables = {
init: function init() { init: function init() {
@ -156,7 +294,7 @@ function loadDataTable() {
render: function render(data, type, row, meta) { render: function render(data, type, row, meta) {
return '<a href="javascript: void(0);" data-uid="' + row.modelProj_name + '" data-method="preview" >' + row.modelProj_name + '</a>'; return '<a href="javascript: void(0);" data-uid="' + row.modelProj_uid + '" data-method="preview" >' + row.modelProj_name + '</a>';
} }
}, },
@ -262,29 +400,29 @@ function buttonClick(obj) {
modelProjRowPos = modelProjTable.fnGetPosition($('#' + uid)[0]); modelProjRowPos = modelProjTable.fnGetPosition($('#' + uid)[0]);
if (type == "preview") { if (type == "preview") {
var mainItem_name = obj.innerText.trim(); var modelProj_name = obj.innerText.trim();
var formData = { var formData = {
dept_uid: dept_uid, dept_uid: dept_uid,
mainItem_uid: uid modelProj_uid: uid
} }
$.ajax({ $.ajax({
url: "/AuthApi/authSubItemList", url: "/AuthApi/authModalQuotationList",
type: "post", type: "post",
data: formData, data: formData,
success: function (data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") { if (data.ret == "yes") {
var obj = data.subItems; var obj = data.modelQuotations;
$('#dt-responsive-subItem').dataTable().fnClearTable(); $('#dt-responsive-modelQuotation').dataTable().fnClearTable();
if (obj.length > 0) { if (obj.length > 0) {
$('#dt-responsive-subItem').dataTable().fnAddData(obj); $('#dt-responsive-modelQuotation').dataTable().fnAddData(obj);
} }
$('#mainItemTitle').val(mainItem_name + ' 的子項目列表').trigger('change'); $('#modelQuotationTitle').val(modelProj_name + ' 的範本列表').trigger('change');
$('#subItemList_mainItem_uid').val(uid); $('#parent_modelProj_uid').val(uid);
$('#clientSubItemListModal').modal('toggle'); $('#clientModelQuotationListModal').modal('toggle');
} else { } else {
alert(data.message); alert(data.message);