123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>{{ title }}</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-
- </head>
- <style>
- .input-cond-delete {
- background: #E43030;
- border: 1px solid #CFCFCF;
- box-sizing: border-box;
- border-radius: 5px;
- margin-left: 5px;
- width: 65px;
- height: 33px;
- font-size: 16px;
- text-align: center;
- line-height: 16px;
- color: #FFFFFF;
- }
- .input-cond-add {
- background: #008CBA;
- border: 1px solid #CFCFCF;
- box-sizing: border-box;
- border-radius: 5px;
- margin-left: 5px;
- width: 65px;
- height: 33px;
- font-size: 16px;
- text-align: center;
- line-height: 16px;
- color: #FFFFFF;
- }
- </style>
- <body>
- <div id="ERP_header">
- <!-- 匯入共同使用的 header.html 內容 -->
- {% include 'ERP_header.html' %}
- </div>
- 請先輸入欲查詢之內部料號 :
- <input list="insert_BOM_module" id="company_id" style="height: 25px;" onChange="get_sqltables()">
- <datalist id="insert_BOM_module">
- <option value="">可輸入名稱查找內部料號</option>
- {% for data in Component_id_name_salesnum %}
- {% if data[2] == "" or data[2] == None %}
- <option value="{{data[0]}}">{{data[1]}}, (無原廠料號)</option>
- {% else %}
- <option value="{{data[0]}}">{{data[1]}}, {{data[2]}}</option>
- {% endif %}
- {% endfor %}
- </datalist>
- <hr>
- <!-- <span style="font-weight: bold;">erp 資料庫所有的資料表 :</span>
- <div id="result_all_tables"></div>
- <br> -->
- <span style="font-weight: bold;">所有包含 "某內部料號" 資料的資料表 :</span>
- <div id="result_id_tables"></div>
- <br>
- <span style="font-weight: bold;">名稱為 "某內部料號" 資料的資料表 :</span>
- <div id="result_id_BOM"></div>
- <br>
- <hr>
- 選擇新的供應商編號:
- <select id="BOM_supplier" onChange="">
- <option value="00"></option>
- {% for data in Supplier_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select>
- <input type="button" class="input-cond-add" value="OK" onclick="select_supplier()">
- <div id="replace_id">
- </div>
- <br>
- <hr>
- [請務必謹慎使用] 新的內部料號:
- <!-- 會計科目:
- <select id="accountingsubjects" onChange="">
- <option value="00"></option>
- {% for data in AccountingSubjects_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select>
- 類別:
- <select id="category" onChange="renewSN();">
- <option value="00"></option>
- {% for data in Category_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select>
- 流水號:
- <input id="serialnumber" style="height: 25px; width: 45px; color: crimson;" readonly>
- 供應商:
- <select id="supplier" onChange="">
- <option value="00"></option>
- {% for data in Supplier_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select> -->
- <input id="new_company_id" style="height: 25px;" onChange="">
- <input type="button" class="input-cond-add" style="width: 125px;" value="更新內部料號" onclick="update_company_id()"><br>
- <br>
- <br>
- <br>
- <hr>
- 批次更新內部料號
- <input type="button" class="input-cond-add" style="width: auto;" value="批次更新供應商" onclick="batch_tt()"><br>
-
- <script>
- var sql = ''; // sql 指令
- var data = ''; // 輸出
- var new_company_id_exist = true; // 新的內部料號是否已存在判斷。true 存在 false 不存在
- function batch_tt() {
- batch_select_supplier("01010001T23", "01010001T02");
- batch_select_supplier("04010004T23", "04010004T22");
- batch_select_supplier("04010128T23", "04010128T22");
- batch_select_supplier("04010153T48", "04010153TE2");
- batch_select_supplier("04010154T48", "04010154TE2");
- batch_select_supplier("04010157T48", "04010157TB1");
- batch_select_supplier("04010158T48", "04010158TF3");
- batch_select_supplier("04010159T48", "04010159TF3");
- batch_select_supplier("04010160T48", "04010160TE8");
- batch_select_supplier("04010161T48", "04010161TB1");
- batch_select_supplier("04010163T48", "04010163TE2");
- batch_select_supplier("04010164T48", "04010164TA6");
- batch_select_supplier("04010165T48", "04010165TF2");
- batch_select_supplier("04010171T48", "04010171T01");
- batch_select_supplier("04010172T48", "04010172T01");
- batch_select_supplier("04010173T48", "04010173T01");
- batch_select_supplier("04010174T48", "04010174TB1");
- batch_select_supplier("04010175T37", "04010175TB1");
- batch_select_supplier("04010176T37", "04010176TB1");
- batch_select_supplier("04010177T37", "04010177TB1");
- batch_select_supplier("04010178T37", "04010178TB1");
- batch_select_supplier("04010179T37", "04010179TB1");
- batch_select_supplier("04010180T37", "04010180TB1");
- batch_select_supplier("04010181T37", "04010181TB1");
- batch_select_supplier("04010182T37", "04010182TB1");
- batch_select_supplier("04010183T37", "04010183TB1");
- batch_select_supplier("04010184T37", "04010184TB1");
- batch_select_supplier("04010185T37", "04010185TB1");
- batch_select_supplier("04010186T37", "04010186TB1");
- batch_select_supplier("04010187T37", "04010187TB1");
- }
- function batch_select_supplier(old_id, new_id) {
- // var old_id = [];
- // var new_id = [];
- var comfirm_update_company_sup = confirm('將原內部料號 ' + old_id +
- ' \n取代成 ' + new_id + '\n請注意此動作不可復原!')
- if (comfirm_update_company_sup) {
- $.ajax({
- type:"GET",
- url:"/update_companyid_table_" + old_id + "_" + new_id,
- dataType:"JSON",
- data:'',
- async:false,
- success:function (res) {
- console.log(res.new_company_id)
- console.log(res.has_id_table_list)
- alert("更新內部料號供應商 " + old_id + " 之 Table: 成功")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("更新內部料號供應商 " + old_id + " 之 Table: 未成功")
- } else {
- console.log("更新內部料號供應商之 Table thrownError" + thrownError)
- }
- }
- })
- }
- }
- function update_company_id() {
- var search_company_id = $("#company_id").val();
- var new_company_id = $("#new_company_id").val();
- if (search_company_id == '' || new_company_id == '') {
- alert("請輸入欲取代內部料號和新內部料號")
- } else {
- sql = 'SELECT 內部料號 FROM 零件表 WHERE 內部料號 = "' + new_company_id + '"';
- var sql_data = { "sql":sql };
- console.log("sql_data: ", sql_data)
- $.ajax({
- type:"GET",
- url:"/sql_get",
- dataType:"JSON",
- data:sql_data,
- async:false,
- success:function (res) {
- new_company_id_exist = true;
- console.log("res.labels: " + res.labels)
- console.log("res.labels.length: " + res.labels.length)
- console.log(typeof(res.labels.length))
- // 判斷內部料號是否存在 (有無回傳值)
- if (res.labels.length == 0) {
- new_company_id_exist = false
- }
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("更新內部料號 " + company_id + ": 未成功")
- } else {
- console.log("更新內部料號 thrownError" + thrownError)
- }
- }
- })
- if (new_company_id_exist == true) {
- alert(new_company_id + " 此內部料號已存在, 請重新輸入 !")
- } else {
- console.log("new_company_id_exist: " + new_company_id_exist)
- console.log("將 " + search_company_id + " 取代成 " + new_company_id)
- var confirm_update_company_id = confirm("[請謹慎使用]\n確定將內部料號 " + search_company_id + " 取代成 " + new_company_id + " ?")
- if (confirm_update_company_id) {
- $.ajax({
- type:"GET",
- url:"/update_companyid_table_" + search_company_id + "_" + new_company_id,
- dataType:"JSON",
- data:'',
- async:false,
- success:function (res) {
- alert("更新內部料號 " + search_company_id + " 之 Table: 成功")
- console.log(res.new_company_id)
- console.log(res.has_id_table_list)
- location.reload()
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("更新內部料號 " + search_company_id + " 之 Table: 未成功")
- } else {
- console.log("更新內部料號之 Table thrownError" + thrownError)
- }
- }
- })
- }
- }
-
-
-
-
- }
- }
- function get_sqltables() {
- var search_company_id = $("#company_id").val();
- console.log("search_company_id: " + search_company_id)
- if (search_company_id != '') {
- data = '';
- $.ajax({
- type:"GET",
- url:"/search_companyid_table_" + search_company_id,
- dataType:"JSON",
- data:'',
- async:false,
- success:function (res) {
- // // erp 資料庫所有的資料表 :
- // var sectorSelect = document.getElementById("result_all_tables");
- // if (res.sql_data != '') {
- // sectorSelect.innerHTML = String(res.sql_data).replaceAll(",", "<br>");
- // } else {
- // sectorSelect.innerHTML = "erp 資料庫無資料表";
- // }
- // 所有包含 "某內部料號" 資料的資料表 :
- var sectorSelect = document.getElementById("result_id_tables");
- if (res.has_id_table_list != '') {
- sectorSelect.innerHTML = String(res.has_id_table_list).replaceAll(",", "<br>");
- } else {
- sectorSelect.innerHTML = "無 " + search_company_id + " 內容之資料表";
- }
- // 名稱為 "某內部料號" 資料的資料表 :
- var sectorSelect = document.getElementById("result_id_BOM");
- if (res.has_table_list != '') {
- sectorSelect.innerHTML = String(res.has_table_list).replaceAll(",", "<br>");
- } else {
- sectorSelect.innerHTML = "無 " + search_company_id + " 資料表";
- }
- var replace_data = '調整供應商為';
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("查詢內部料號 " + search_company_id + " 之 Table: 未成功")
- } else {
- console.log("查詢內部料號之 Table thrownError" + thrownError)
- }
- }
- })
- }
- }
-
- function select_supplier() {
- var search_company_id = $("#company_id").val();
- var supplier_select = $("#BOM_supplier").val();
- var new_company_id = search_company_id.slice(0, 8) + supplier_select;
- var select_supplier_data = '將原內部料號 ' + search_company_id + ' 取代成 ' + new_company_id;
- var comfirm_update_company_sup = confirm('將原內部料號 ' + search_company_id + ' \n取代成 ' + new_company_id + '\n請注意此動作不可復原!')
- if (comfirm_update_company_sup) {
- console.log(search_company_id + ' → ' + new_company_id)
- $.ajax({
- type:"GET",
- url:"/update_companyid_table_" + search_company_id + "_" + new_company_id,
- dataType:"JSON",
- data:'',
- async:false,
- success:function (res) {
- console.log(res.new_company_id)
- console.log(res.has_id_table_list)
- alert("更新內部料號供應商 " + search_company_id + " 之 Table: 成功")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("更新內部料號供應商 " + search_company_id + " 之 Table: 未成功")
- } else {
- console.log("更新內部料號供應商之 Table thrownError" + thrownError)
- }
- }
- })
-
- }
- }
-
- function renewSN() {
- var accountingsubjects_select = $("#accountingsubjects").val();
- var category_select = $("#category").val();
- $.get('/sn_get/' + accountingsubjects_select + '/' + category_select, '', function (res) {
- // console.log(res.new_sn)
- $('#serialnumber').val(res.new_sn)
- }, 'json');
- }
- </script>
- </body>
- </html>
|