From 609de6292570ffce0714e709a0071cb61fbc0067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=89=E7=A5=A5=20=E8=A9=B9?= Date: Wed, 21 Aug 2024 19:03:35 +0800 Subject: [PATCH] updates --- Views/Home/ModalList.cshtml | 180 +---------------- wwwroot/assets/javascript/custom/modallist.js | 184 +++++++++++++----- 2 files changed, 145 insertions(+), 219 deletions(-) diff --git a/Views/Home/ModalList.cshtml b/Views/Home/ModalList.cshtml index 91714695..4c463f51 100644 --- a/Views/Home/ModalList.cshtml +++ b/Views/Home/ModalList.cshtml @@ -23,12 +23,12 @@ -

主項目清單

+

範本類型清單

@@ -199,173 +199,7 @@
- -
-
- Footer Menus -
- -
- -
- -
    -
  1. -
    -
    -
    - -
    -
    -
    -

    - 會員電子報上稿製作 -

    -

    - 協助代為租用多IP發信系統,減少擋信機率 - .年約優惠方案$961美元,匯率$32 - .每月最多發送份數共60,000份 - .超過平台每月6萬封發報限制,則以額外購買額度 0.06元/封 計算 -

    -

    - 單價 NT$3,500, 數量 10, 單位 次 - 小計 NT$35,000 - AC(N) -

    -
    -
    - - - -
    -
    - -
    -
    - -
  2. - -
  3. -
    -
    -
    - -
    -
    -
    -

    - 會員電子報上稿製作 -

    -

    - 協助代為租用多IP發信系統,減少擋信機率 - .年約優惠方案$961美元,匯率$32 - .每月最多發送份數共60,000份 - .超過平台每月6萬封發報限制,則以額外購買額度 0.06元/封 計算 -

    -

    - 單價 NT$3,500, 數量 10, 單位 次 - 小計 NT$35,000 - AC(N) -

    -
    -
    -
    -
    - -
    -
    - -
  4. -
- - - -
- -
-
- Footer Menus -
- -
- -
- -
    -
  1. -
    -
    -
    - -
    -
    -
    -

    - 會員電子報上稿製作 -

    -

    - 協助代為租用多IP發信系統,減少擋信機率 - .年約優惠方案$961美元,匯率$32 - .每月最多發送份數共60,000份 - .超過平台每月6萬封發報限制,則以額外購買額度 0.06元/封 計算 -

    -

    - 單價 NT$3,500, 數量 10, 單位 次 - 小計 NT$35,000 - AC(N) -

    -
    -
    - - - -
    -
    - -
    -
    - -
  2. - -
  3. -
    -
    -
    - -
    -
    -
    -

    - 會員電子報上稿製作 -

    -

    - 協助代為租用多IP發信系統,減少擋信機率 - .年約優惠方案$961美元,匯率$32 - .每月最多發送份數共60,000份 - .超過平台每月6萬封發報限制,則以額外購買額度 0.06元/封 計算 -

    -

    - 單價 NT$3,500, 數量 10, 單位 次 - 小計 NT$35,000 - AC(N) -

    -
    -
    -
    -
    - -
    -
    - -
  4. -
- - -
+
@@ -403,7 +237,11 @@
- +
+
+ +
+
@@ -467,7 +305,7 @@ diff --git a/wwwroot/assets/javascript/custom/modallist.js b/wwwroot/assets/javascript/custom/modallist.js index c145b715..c538f12e 100644 --- a/wwwroot/assets/javascript/custom/modallist.js +++ b/wwwroot/assets/javascript/custom/modallist.js @@ -16,7 +16,7 @@ var deledMainItems = []; var deledSubItems = []; var preSubItem_name = ''; - +var hasBind = 'N'; $(document).ready(function () { deptList(); loadModelQuotationDataTable(); @@ -69,21 +69,47 @@ $(document).ready(function () { var modelSubItem_subTotal = modelSubItem_price * modelSubItem_number; - + if (method == 'edit') { + var datauid = $('#modelSubItem_uid').val(); + + var htmlObj = $('#modelItem_div').find('[data-uid="' + parent_data_uid + '"]').find('ol').find('[data-model-subitem-uid="' + datauid + '"]'); + + $(htmlObj).find('[data-name="subItem_uid"]').val(subItem_uid); + $(htmlObj).find('[data-name="model-subItem_uid"]').val(modelSubItem_uid); + $(htmlObj).find('[data-name="model-subitem-name"]').val(modelSubItem_name); + $(htmlObj).find('[data-name="model-subitem-price"]').val(modelSubItem_price); + $(htmlObj).find('[data-name="model-subitem-unitType"]').val(modelSubItem_unitType); + $(htmlObj).find('[data-name="model-subitem-number"]').val(modelSubItem_number); + $(htmlObj).find('[data-name="model-subitem-hasAC"]').val(modelSubItem_hasAC); + $(htmlObj).find('[data-name="model-subitem-subTotal"]').val(modelSubItem_subTotal); + $(htmlObj).find('[data-name="model-subitem-descript"]').val(modelSubItem_descript); + $(htmlObj).children().children().find('[data-name="subname"]').text(modelSubItem_name); + $(htmlObj).children().children().find('[data-name="subdesc"]').text(modelSubItem_descript); + + var detailData = ''; + detailData += '單價 NT$' + AppendComma(modelSubItem_price) + ', 數量 ' + modelSubItem_number + ', 單位 ' + modelSubItem_unitType + '\r\n'; + detailData += '小計 NT$' + AppendComma(modelSubItem_subTotal) + '\r\n'; + detailData += 'AC(' + modelSubItem_hasAC + ')'; + + $(htmlObj).children().children().find('[data-name="subsummy"]').text(detailData); + + $('#modelSubItemModal').modal('toggle'); + } if (method == 'add') { var datauid = Math.floor(Math.random() * 999999999); var htmlCode = ''; htmlCode += '
  • '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; - htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; + htmlCode += ' '; htmlCode += '
    '; htmlCode += '
    '; htmlCode += '
    '; @@ -92,12 +118,12 @@ $(document).ready(function () { htmlCode += '
    '; htmlCode += '
    '; htmlCode += '

    '; - htmlCode += ' ' + modelSubItem_name + '\r\n'; + htmlCode += ' ' + modelSubItem_name; htmlCode += '


    '; htmlCode += '

    '; - htmlCode += ' ' + modelSubItem_descript + '\r\n'; + htmlCode += ' ' + modelSubItem_descript; htmlCode += '


    '; - htmlCode += '

    '; + htmlCode += '

    '; htmlCode += ' 單價 NT$' + AppendComma(modelSubItem_price) + ', 數量 ' + modelSubItem_number + ', 單位 ' + modelSubItem_unitType + '\r\n'; htmlCode += ' 小計 NT$' + AppendComma(modelSubItem_subTotal) + '\r\n'; htmlCode += ' AC(' + modelSubItem_hasAC + ')'; @@ -127,6 +153,12 @@ $(document).ready(function () { var mainItem_uid = $('#parent_mainItem_uid').val(); var method = $('#modelMainItem_method').val(); var modelMainItem_name = $('#modelMainItem_name').val(); + var modelMainItem_ac = $('#modelMainItem_ac').val(); + + if (modelMainItem_ac.isNumber() == false) { + alert('AC必須為數字!'); + return; + } if (modelMainItem_name == "") { alert('主項目名稱不得為空白!'); @@ -138,7 +170,7 @@ $(document).ready(function () { $(obj).prop('data-main-uid', mainItem_uid); $(obj).find("[data-name='mainItem_name']").val(modelMainItem_name); $(obj).find("[data-span='mainItem_name']").text(modelMainItem_name); - + $(obj).find("[data-name='modelMainItem_ac']").val(modelMainItem_ac); $('#modelMainItemModal').modal('toggle'); } @@ -150,6 +182,7 @@ $(document).ready(function () { htmlCode += '

    '; htmlCode += '
    '; htmlCode += ' '; + htmlCode += ' '; htmlCode += ' ' + modelMainItem_name + ''; htmlCode += '
    '; htmlCode += ' '; @@ -175,6 +208,9 @@ $(document).ready(function () { }); + + + //新增主項目鈕 $('#addModelMainItemBtn').on('click', function () { @@ -260,6 +296,48 @@ $(document).ready(function () { }); }); +//次項目編輯鈕 +function editSubItemButton(obj) { + var divObj = $(obj).parent().parent().parent(); + + var model_subitem_uid = $(obj).parent().parent().parent().attr('data-model-subitem-uid'); + var subItem_name = $(divObj).find("[data-name='model-subitem-name']").val(); + var parent_item_uid = $(divObj).find("[data-name='model-subItem_uid']").val(); + var modelSubItem_price = $(divObj).find("[data-name='model-subitem-price']").val(); + var modelSubItem_unitType = $(divObj).find("[data-name='model-subitem-unitType']").val(); + var modelSubItem_number = $(divObj).find("[data-name='model-subitem-number']").val(); + var modelSubItem_hasAC = $(divObj).find("[data-name='model-subitem-hasAC']").val(); + var modelSubItem_descript = $(divObj).find("[data-name='model-subitem-descript']").val(); + var modelMainItem_uid = $(divObj).parent().parent().attr("data-uid"); + var parent_mainItem_uid = $(divObj).parent().parent().attr("data-main-uid"); + + + + $('#modelSubItem_method').val('edit'); + $('#modelSubItem_uid').val(model_subitem_uid); + $('#parent_Item_uid').val(parent_item_uid); + $('#model_parent_data_uid').val(modelMainItem_uid); + $('#modelSubItem_name').val(subItem_name); + $('#modelSubItem_descript').val(modelSubItem_descript); + $('#modelSubItem_price').val(modelSubItem_price); + $('#modelSubItem_unitType').val(modelSubItem_unitType); + $('#modelSubItem_number').val(modelSubItem_number); + + if (modelSubItem_hasAC == 'Y') { + $('#modelSubItem_hasAC').prop('checked', true).trigger('change'); + } else { + $('#modelSubItem_hasAC').prop('checked', false).trigger('change'); + } + + $('#modelSubItem_name').typeahead('destroy'); + + loadSubItemTypeahead(parent_mainItem_uid); + + setTimeout(function () { preSubItem_name = subItem_name; }, 1000); + + $('#modelSubItemModal').modal('toggle'); +} + function addSubItem(obj) { var modelMainItem_uid = $(obj).parent().parent().attr("data-uid"); var modelMainItem_name = $(obj).parent().parent().find("[data-name='mainItem_name']").val(); @@ -366,41 +444,12 @@ function loadSubItemTypeahead(mainItem_uid) { ); preSubItem_name = ''; - $('#modelSubItem_name').bind('typeahead:select', function (ev, suggestion) { - var modelSubItem_descript = $('#modelSubItem_descript').val(); - - if (preSubItem_name != '') { - if (suggestion != preSubItem_name) { - if (confirm('確定要用新項目覆蓋目前資料?')) { - $('#parent_Item_uid').val(subItem_map[suggestion].id); - preSubItem_name = suggestion; - - $('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change'); - $('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change'); - $('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change'); - } else { - $('#modelSubItem_name').typeahead('val', preSubItem_name); - //suggestion = preSubItem_name; - //$('#modelSubItem_name').val(preSubItem_name).trigger('change');; - } - } - } else { - $('#parent_Item_uid').val(subItem_map[suggestion].id); - preSubItem_name = suggestion; - - $('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change'); - $('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change'); - $('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change'); - - } - - - - console.log('Selection: ' + suggestion); - console.log('Selection key: ' + subItem_map[suggestion].id); - - }); + if (hasBind == 'N') { + bindTypeHead(); + hasBind = 'Y'; + } + //$('#modelMainItem_name').bind('typeahead:autocomplete', function (ev, suggestion) { // console.log('Selection: ' + suggestion); // console.log('Selection key: ' + mainItem_map[suggestion].id); @@ -421,6 +470,45 @@ function loadSubItemTypeahead(mainItem_uid) { }); } +function bindTypeHead() { + $('#modelSubItem_name').bind('typeahead:select', function (ev, suggestion) { + var modelSubItem_descript = $('#modelSubItem_descript').val(); + + if (preSubItem_name != '') { + if (suggestion != preSubItem_name) { + if (confirm('確定要用新項目覆蓋目前資料?')) { + $('#parent_Item_uid').val(subItem_map[suggestion].id); + preSubItem_name = suggestion; + + $('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change'); + $('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change'); + $('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change'); + $('#modelSubItem_number').val('').trigger('change'); + } else { + $('#modelSubItem_name').typeahead('val', preSubItem_name); + //suggestion = preSubItem_name; + //$('#modelSubItem_name').val(preSubItem_name).trigger('change');; + } + } + } else { + $('#parent_Item_uid').val(subItem_map[suggestion].id); + preSubItem_name = suggestion; + + $('#modelSubItem_price').val(subItem_map[suggestion].price).trigger('change'); + $('#modelSubItem_unitType').val(subItem_map[suggestion].unitType).trigger('change'); + $('#modelSubItem_descript').val(subItem_map[suggestion].descript).trigger('change'); + + } + + + + console.log('Selection: ' + suggestion); + console.log('Selection key: ' + subItem_map[suggestion].id); + + }); + +} + function loadMainItemTypeahead() { var formData = { dept_uid: $('#dept_select').val()