123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- <!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">
- <!-- 0127 更新 -->
- <!-- 新 Bootstrap4 核心 CSS 文件 -->
- <!-- <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css"> -->
- <!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> -->
- <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
- <!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
- <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
- <!-- <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script> -->
- <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
- <!-- <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> -->
- <!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> -->
- <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> -->
- <!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> -->
- <!-- <script src="../static/js/bootstrap.min.js"></script> -->
- <!-- 舊的, 網頁讀取有問題 -->
- <!-- 新 Bootstrap4 核心 CSS 文件
- <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
- jQuery文件。务必在bootstrap.min.js 之前引入
- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
- popper.min.js 用于弹窗、提示、下拉菜单
- <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
- 最新的 Bootstrap4 核心 JavaScript 文件
- <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
- 可用來建立使用者小圖示
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
- <script>
- // var standard_title_list = ['id', 'name', 'type', 'unit', 'picture', 'pictureID', 'version', 'path', 'size', 'material',
- // 'workV', 'workI', 'maxI', 'power', 'workTemp', 'remark', ];
- var standard_title_list = ['id', 'name', 'type', 'unit', 'picture', 'pictureID', 'path', 'size', 'material',
- 'workV', 'workI', 'maxI', 'power', 'workTemp', 'remark', ];
- </script>
- </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>
- 會計科目:
- <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="">
- <option value="00"></option>
- {% for data in Category_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select>
- 流水號:
- <input id="serialnumber" placeholder="0001" style="height: 25px; width: 45px;">
- 供應商:
- <select id="supplier" onChange="">
- <option value="00"></option>
- {% for data in Supplier_data %}
- <option value="{{data[0]}}">{{data[0]}}-{{data[1]}}</option>
- {% endfor %}
- </select><br>
- 零件名稱:
- <select id="component_name_select" onChange="">
- <option value="00"></option>
- {% for data in Component_data %}
- <option value="{{data[0]}}">{{data[0]}}</option>
- {% endfor %}
- </select>
- <input id="component_name_input" placeholder="零件關鍵字輸入" style="height: 25px; width: 120px;">
- <input type="button" id="search_component_table" value="零件表查詢" onclick="search_component_table();">
- <input type="button" id="search_component_standard_table" value="(零件)規格表查詢" onclick="search_component_standard_table();">
- <!-- <input type="button" id="search_component_stock_table" value="(零件)庫存表查詢" onclick="search_component_stock_table();" style="display: none;"> -->
- <!-- <input type="button" id="search_component_import_table" value="(零件)進貨表查詢" onclick="search_component_import_table();" style="display: none;"> -->
- <!-- <input type="button" id="search_component_export_table" value="(零件)銷貨表查詢" onclick="search_component_export_table();" style="display: none;"> -->
- <br>
- <a id="create_component_table_item" href="/create_component_table_item">(零件)新增零件</a>
- <a id="create_BOM" href="/create_BOM">建立 BOM 表</a>
- <!-- <a id="update_Picture" href="/update_Picture" disabled="true"><s>更新圖片</s></a> -->
- <br>
- <br>
- <br>
- <script>
- // // (零件)銷貨表查詢
- // function search_component_export_table() {
- // var sql = 'SELECT 銷貨表.* FROM 零件表';
- // sql += ' INNER JOIN 銷貨表';
- // sql += ' ON 零件表.內部料號 = 銷貨表.內部料號';
- // search_relation_insertdata(sql)
- // }
- // // (零件)進貨表查詢
- // function search_component_import_table() {
- // var sql = 'SELECT 進貨表.* FROM 零件表';
- // sql += ' INNER JOIN 進貨表';
- // sql += ' ON 零件表.內部料號 = 進貨表.內部料號';
- // search_relation_insertdata(sql)
- // }
- // // (零件)庫存表查詢
- // function search_component_stock_table() {
- // var sql = 'SELECT 庫存表.時間, 庫存表.內部料號, 庫存表.數量 FROM 零件表';
- // sql += ' INNER JOIN 庫存表';
- // sql += ' ON 零件表.內部料號 = 庫存表.內部料號';
- // search_relation_insertdata(sql)
- // }
-
- // (零件)規格表查詢
- function search_component_standard_table() {
- var accountingsubjects_select = $("#accountingsubjects").val();
- var category_select = $("#category").val();
- var serialnumber_select = $("#serialnumber").val();
- serialnumber_select = serialnumber_select.padStart(4, '0')
- var supplier_select = $("#supplier").val();
- var component_name_select = $("#component_name_select").val();
- var component_name_input = $("#component_name_input").val();
- var AND_list = [];
- console.log(accountingsubjects_select, category_select, serialnumber_select, supplier_select)
- sql = 'SELECT 零件表.內部料號, 零件表.名稱, 規格表.原廠料號, 規格表.單位, 規格表.圖片, 規格表.圖號, ' +
- '規格表.檔案路徑, 規格表.尺寸, 規格表.`封裝/材質`, 規格表.工作電壓, 規格表.工作電流, 規格表.最大電流, ' +
- '規格表.功率, 規格表.工作溫度, 規格表.備註 ' +
- 'FROM 零件表 ' +
- 'INNER JOIN 規格表 ON 零件表.內部料號 = 規格表.內部料號';
- // 篩選 會計科目/類別/供應商 關鍵字
- if (accountingsubjects_select != '00') {
- AND_list.push('會計科目 = "' + accountingsubjects_select + '"')
- }
- if (category_select != '00') {
- AND_list.push('類別 = "' + category_select + '"')
- }
- if (serialnumber_select != '0000') {
- AND_list.push('流水號 = "' + serialnumber_select + '"')
- }
- if (supplier_select != '00') {
- AND_list.push('供應商 = "' + supplier_select + '"')
- }
- if (component_name_select != '00') {
- AND_list.push('零件表.名稱 = "' + component_name_select + '"')
- } else if (component_name_input != '') {
- AND_list.push('零件表.名稱 LIKE "%' + component_name_input + '%"')
- }
- console.log("AND_list: ", AND_list)
- if (AND_list != '') {
- sql += ' WHERE ' + AND_list.join(' AND ');
- }
-
- var sql_data = { "sql":sql };
- console.log("sql_data: ", sql_data)
- $.get('/sql_get', sql_data, function (res) {
- var data = " ";
- if (res.labels == '') {
- data += '-- 規格表無符合關鍵字之資料 --'
- } else {
- data += '查詢結果: 共 ' + res.labels.length + ' 筆<br>'
- data += '<table class="table table-bordered" style="margin-top: 10px;">';
- data += '<tr>';
- for (let fields = 0; fields < res.sql_field.length; fields++) {
- if (res.sql_field[fields][0] !== '版次') {
- data += '<th>' + res.sql_field[fields][0] + '</th>';
- if (fields == 0) {
- data += '<th>零件名稱</th>';
- }
- }
- }
- data += '<th>' + '修改' + '</th>';
- data += '</tr>';
- for (let items = 0; items < res.labels.length; items++) {
- data += '<tr>';
- for (let item = 0; item < res.labels[items].length; item++) {
- // console.log("res.labels[items][item]: ", res.labels[items][item], typeof(res.labels[items][item]))
- if (res.labels[items][item] == null) {
- data += '<td id="' + res.labels[items][0] + '_' + standard_title_list[item] + '">' + '' + '</td>';
- } else {
- if (standard_title_list[item] == 'picture') {
- data += '<td id="' + res.labels[items][0] + '_' + standard_title_list[item] + '">' +
- '<img src="../static/Component_IMG/' + res.labels[items][item] + '" width="60" alt="' + res.labels[items][item] + '" onclick="imgZoomIn(\'' + res.labels[items][item] + '\')">' +
- '</td>';
- } else {
- data += '<td id="' + res.labels[items][0] + '_' + standard_title_list[item] + '">' + res.labels[items][item] + '</td>';
- }
-
- }
- };
- data += '<td><input type="button" class="input-cond-add" value="修改" onclick="update_standard(\'' + res.labels[items][0] + '\')"></td>';
- data += '</tr>';
- };
- data += '</table>';
- }
- var sectorSelect = document.getElementById("result");
- sectorSelect.innerHTML = data;
- }, 'json');
- }
- // 規格表 圖片 圖片放大
- function imgZoomIn(imgName) {
- // alert("imgName: " + imgName)
- data = '<img src="../static/Component_IMG/' + imgName + '" width="466" alt="' + imgName + '">';
- var sectorSelect = document.getElementById("ImgZoomIn_Modal_body");
- sectorSelect.innerHTML = data;
-
- setTimeout(function(){ $('#ImgZoomIn_Modal').modal('show'); }, 300)
- }
- // 規格表 內容修改
- function update_standard(company_id) {
- console.log("修改 " + company_id)
- for (let i = 2; i < standard_title_list.length; i++) {
- // 跳過 picure
- if (standard_title_list[i] != 'picture') {
- var target_id = document.getElementById(company_id + '_' + standard_title_list[i]);
- console.log("target_id: " + standard_title_list[i]);
- var old_name = target_id.innerText;
- console.log(standard_title_list[i] + ' old_name: ', old_name)
- target_id.innerHTML = "";
- textarea = '';
- if (standard_title_list[i] == 'unit' || standard_title_list[i] == 'version' || standard_title_list[i] == 'material' ||
- standard_title_list[i] == 'workV' || standard_title_list[i] == 'workI' || standard_title_list[i] == 'power' || standard_title_list[i] == 'maxI') {
- textarea += '<input id="'+ company_id + '_' + standard_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 50px">';
- } else if (standard_title_list[i] == 'picture') {
- textarea += old_name;
- console.log(target_id.innerHTML)
- } else {
- textarea += '<input id="'+ company_id + '_' + standard_title_list[i] + '_ta' + '" value="' + old_name + '" style="height: 25px; width: 150px">';
- }
- if (i == standard_title_list.length-1) {
- textarea += '<input type="button" value="OK" onclick="ComfirmUpdate_standard(\'' + company_id + '\')">';
- }
- target_id.insertAdjacentHTML('beforeend', textarea);
- }
- }
- }
- // 規格表 修改確認
- function ComfirmUpdate_standard(company_id) {
- // var standard_title_list = ['id', 'name', 'type', 'unit', 'picture', 'pictureID', 'version', 'path', 'size', 'material',
- // 'workV', 'workI', 'maxI', 'power', 'workTemp', 'remark', ];
- var new_type_value = $('#' + company_id + '_type_ta').val();
- var new_unit_value = $('#' + company_id + '_unit_ta').val();
- // var new_picture_value = $('#' + company_id + '_picture_ta').val();
- var new_pictureID_value = $('#' + company_id + '_pictureID_ta').val();
- var new_version_value = $('#' + company_id + '_version_ta').val();
- var new_path_value = $('#' + company_id + '_path_ta').val();
- var new_size_value = $('#' + company_id + '_size_ta').val();
- var new_material_value = $('#' + company_id + '_material_ta').val();
- var new_workV_value = $('#' + company_id + '_workV_ta').val();
- var new_workI_value = $('#' + company_id + '_workI_ta').val();
- var new_maxI_value = $('#' + company_id + '_maxI_ta').val();
- var new_power_value = $('#' + company_id + '_power_ta').val();
- var new_workTemp_value = $('#' + company_id + '_workTemp_ta').val();
- var new_remark_value = $('#' + company_id + '_remark_ta').val();
- sql = 'UPDATE 規格表 SET ' +
- '`原廠料號` = "' + new_type_value + '"' +
- ', `單位` = "' + new_unit_value + '"' +
- // ', `圖片` = "' + new_picture_value + '"' +
- ', `圖號` = "' + new_pictureID_value + '"' +
- ', `檔案路徑` = "' + new_path_value + '"' +
- ', `尺寸` = "' + new_size_value + '"' +
- ', `封裝/材質` = "' + new_material_value + '"' +
- ', `工作電壓` = "' + new_workV_value + '"' +
- ', `工作電流` = "' + new_workI_value + '"' +
- ', `功率` = "' + new_power_value + '"' +
- ', `最大電流` = "' + new_maxI_value + '"' +
- ', `工作溫度` = "' + new_workTemp_value + '"' +
- ', `備註` = "' + new_remark_value + '"' +
- ' WHERE `內部料號` = "' + company_id + '";'
- console.log('sql: ' + sql)
- var sql_data = { "sql":sql };
- $.ajax({
- type:"GET",
- url:"/sql_get",
- dataType:"JSON",
- data:sql_data,
- success:function (res) {
- search_component_standard_table();
- alert("規格表: 修改成功 !")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("規格表: 內部料號 " + company_id + " 修改未成功")
- } else {
- console.log("修改規格表內容 thrownError" + thrownError)
- }
- }
- })
-
- }
- // 各資料表←關聯→零件表, 程式
- function search_relation_insertdata(sql) {
- var accountingsubjects_select = $("#accountingsubjects").val();
- var category_select = $("#category").val();
- var serialnumber_select = $("#serialnumber").val();
- serialnumber_select = serialnumber_select.padStart(4, '0')
- var supplier_select = $("#supplier").val();
- var component_name_select = $("#component_name_select").val();
- var component_name_input = $("#component_name_input").val();
- var AND_list = [];
- console.log(accountingsubjects_select, category_select, serialnumber_select, supplier_select)
- var sql = sql;
- // 篩選 會計科目/類別/供應商 關鍵字
- if (accountingsubjects_select != '00') {
- AND_list.push('會計科目 = "' + accountingsubjects_select + '"')
- }
- if (category_select != '00') {
- AND_list.push('類別 = "' + category_select + '"')
- }
- if (serialnumber_select != '0000') {
- AND_list.push('流水號 = "' + serialnumber_select + '"')
- }
- if (supplier_select != '00') {
- AND_list.push('供應商 = "' + supplier_select + '"')
- }
- if (component_name_select != '00') {
- AND_list.push('零件表.名稱 = "' + component_name_select + '"')
- } else if (component_name_input != '') {
- AND_list.push('零件表.名稱 LIKE "%' + component_name_input + '%"')
- }
- console.log("AND_list: ", AND_list)
- if (AND_list != '') {
- sql += ' WHERE ' + AND_list.join(' AND ');
- }
- if (sql.match('INNER JOIN 庫存表')) {
- sql += ' ORDER BY 時間 DESC LIMIT 1'
- }
-
- var sql_data = {
- "sql":sql
- };
- console.log("sql_data: ", sql_data)
- $.get('/sql_get', sql_data, function (res) {
- // console.log("res: " + res)
- // console.log("res.labels:" + res.labels)
- // console.log("res.labels[0]:" + res.labels[0])
- // console.log("res.labels[0][0]:" + res.labels[0][0])
- // console.log("res.sql_field:" + res.sql_field)
- // console.log("res.sql_field[0]:" + res.sql_field[0])
- var data = " ";
- if (res.labels == '') {
- data += '-- 無符合關鍵字之資料 --'
- } else {
- data += '<table class="table table-bordered" style="margin-top: 10px;">';
- data += '<tr>';
- for (let fields = 0; fields < res.sql_field.length; fields++) {
- data += '<th>' + res.sql_field[fields][0] + '</th>';
- }
- data += '</tr>';
- for (let items = 0; items < res.labels.length; items++) {
- data += '<tr>';
- for (let item = 0; item < res.labels[items].length; item++) {
- // console.log("res.labels[items][item]: ", res.labels[items][item], typeof(res.labels[items][item]))
- data += '<td>' + res.labels[items][item] + '</td>';
- };
- data += '</tr>';
- };
- data += '</table>';
- }
- var sectorSelect = document.getElementById("result");
- sectorSelect.innerHTML = data;
- }, 'json');
- }
-
- // 修改確認
- function ComfirmUpdate_component(company_id) {
- console.log("修改完成: " + company_id)
- // var new_name = document.getElementById(company_id + '_5_ta');
- // var new_name_value = new_name.val();
- var new_name_value = $('#' + company_id + '_5_ta').val();
- console.log("new_name_value: " + new_name_value)
-
- // 零件表名稱修改
- sql = "";
- sql += "UPDATE 零件表 SET 名稱 = '" + new_name_value.replaceAll("'", "''") + "' WHERE 內部料號 = '" + company_id + "';"
- console.log('sql: ' + sql)
- var sql_data = { "sql":sql };
- $.get('/sql_get', sql_data, function (res) {
- // console.log(res)
- search_component_table();
- }, 'json');
- }
- // 修改
- function update_component(company_id) {
- console.log("修改 " + company_id)
- var target_id = document.getElementById(company_id + '_5');
- var old_name = target_id.innerText.replaceAll('"', '"').replaceAll("'", "'");
- console.log('old_name: ', old_name)
- target_id.innerHTML = "";
- textarea = '';
- textarea += '<input type="text" id="'+ company_id + '_5_ta' + '" value=\"' + old_name + '\" style="height: 25px; width:auto">';
- textarea += '<input type="button" value="OK" onclick="ComfirmUpdate_component(\'' + company_id + '\')">';
- target_id.insertAdjacentHTML('beforeend', textarea);
- }
-
- // 刪除
- function delete_component(company_id) {
- var delete_data = confirm("確定要刪除內部料號 " + company_id + " 的資料嗎?\n(會同步刪除規格表對應資料)")
- if (delete_data) {
- // 刪除零件表
- // var sql = 'DELETE FROM 零件表 WHERE 內部料號 = "' + company_id + '";'
- // var sql_data = { "sql":sql };
- // $.ajax({
- // type:"GET",
- // url:"/sql_get",
- // dataType:"JSON",
- // data:sql_data,
- // async:false,
- // success:function (res) {
- // search_component_table()
- // alert("零件表: 零件刪除成功!")
- // },
- // error: function (thrownError) {
- // if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- // alert("零件表: 無內部料號 " + company_id + " 之資料")
- // } else {
- // alert("零件表刪除錯誤: " + thrownError)
- // }
- // }
- // })
- // 刪除規格表
- // var sql = 'DELETE FROM 規格表 WHERE 內部料號 = "' + company_id + '";'
- // var sql_data = { "sql":sql };
- // $.ajax({
- // type:"GET",
- // url:"/sql_get",
- // dataType:"JSON",
- // data:sql_data,
- // async:false,
- // success:function (res) {
- // alert("規格表: 零件刪除成功!")
- // },
- // error: function (thrownError) {
- // if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- // alert("規格表: 無內部料號 " + company_id + " 之資料")
- // } else {
- // alert("規格表刪除錯誤: " + thrownError)
- // }
- // }
- // })
- // 刪除資料表
- var sql = 'DROP TABLE ' + company_id + ';';
- var sql_data = { "sql":sql };
- $.ajax({
- type:"GET",
- url:"/sql_get",
- dataType:"JSON",
- data:sql_data,
- async:false,
- success:function (res) {
- alert("BOM 表: " + company_id + " 刪除成功!")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("BOM 表: 無內部料號 " + company_id + " 之資料表")
- } else {
- alert("零件表 BOM 表刪除錯誤: " + thrownError)
- }
- }
- })
- $.ajax({
- type:"GET",
- url:"/delete_companyid_table_" + company_id,
- dataType:"JSON",
- data:"",
- async:false,
- success:function (res) {
- alert("BOM 表: " + res.exist_BOM + " \n之 " + company_id + " 刪除成功!")
- },
- error: function (thrownError) {
- if (thrownError.statusText == "INTERNAL SERVER ERROR") {
- alert("BOM 表內刪除零件 : 無內部料號 " + company_id + " 之項目")
- } else {
- alert("BOM 表內刪除零件錯誤: " + thrownError)
- }
- }
- })
-
- search_component_table();
- }
-
- }
- // 零件表查詢
- function search_component_table(){
- var accountingsubjects_select = $("#accountingsubjects").val();
- var category_select = $("#category").val();
- var serialnumber_select = $("#serialnumber").val();
- serialnumber_select = serialnumber_select.padStart(4, '0')
- var supplier_select = $("#supplier").val();
- var component_name_select = $("#component_name_select").val();
- var component_name_input = $("#component_name_input").val();
- var AND_list = [];
- console.log(accountingsubjects_select, category_select, serialnumber_select, supplier_select)
- // sql = 'SELECT * FROM 零件表';
- sql = 'SELECT 內部料號, 會計科目表.會計科目_名稱, 類別表.類別_名稱, 流水號, 供應商.公司, 名稱' +
- ' FROM (' +
- '(零件表 ' +
- 'INNER JOIN 供應商' +
- ' ON 供應商.供應商 = 零件表.供應商' +
- ')' +
- ' INNER JOIN 類別表' +
- ' ON 類別表.類別_編號 = 零件表.類別' +
- ') ' +
- 'INNER JOIN 會計科目表 ' +
- 'ON 會計科目表.會計科目_編號 = 零件表.會計科目' +
- '' ;
- // 篩選 會計科目/類別/供應商 關鍵字
- if (accountingsubjects_select != '00') {
- AND_list.push('會計科目 = "' + accountingsubjects_select + '"')
- }
- if (category_select != '00') {
- AND_list.push('類別 = "' + category_select + '"')
- }
- if (serialnumber_select != '0000') {
- AND_list.push('流水號 = "' + serialnumber_select + '"')
- }
- if (supplier_select != '00') {
- AND_list.push('零件表.供應商 = "' + supplier_select + '"')
- }
- if (component_name_select != '00') {
- AND_list.push('名稱 = \'' + component_name_select + '\'')
- } else if (component_name_input != '') {
- AND_list.push('名稱 LIKE \'%' + component_name_input + '%\'')
- }
- console.log("AND_list: ", AND_list)
- if (AND_list != '') {
- sql += ' WHERE ' + AND_list.join(' AND ');
- }
-
- var sql_data = {
- "sql":sql
- };
- console.log("sql_data: ", sql_data)
- $.get('/sql_get', sql_data, function (res) {
- // console.log("res: " + res)
- // console.log("res.labels:" + res.labels)
- // console.log("res.labels[0]:" + res.labels[0])
- // console.log("res.labels[0][0]:" + res.labels[0][0])
- // console.log("res.sql_field:" + res.sql_field)
- // console.log("res.sql_field[0]:" + res.sql_field[0])
- var data = " ";
- if (res.labels == '') {
- data += '-- 零件表無符合關鍵字之資料 --'
- } else {
- data += '查詢結果: 共 ' + res.labels.length + ' 筆<br>'
- data += '<table class="table table-bordered" style="margin-top: 10px;">';
- data += '<tr>';
- // console.log("res.sql_field: " + res.sql_field)
- for (let fields = 0; fields < res.sql_field.length; fields++) {
- data += '<th>' + res.sql_field[fields][0] + '</th>';
- // console.log("res.sql_field[" + fields + "][0]: " + res.sql_field[fields][0])
- }
- data += '<th>修改</th>';
- data += '<th>刪除</th>';
- data += '</tr>';
- for (let items = 0; items < res.labels.length; items++) {
- data += '<tr>';
- for (let item = 0; item < res.labels[items].length; item++) {
- // data += '<td id="' + res.Component_id[items] + '_' + item + '">' + res.labels[items][item] + '</td>';
- data += '<td id="' + res.labels[items][0] + '_' + item + '">' + res.labels[items][item] + '</td>';
- };
- data += '<td><input type="button" class="input-cond-add" value="修改" onclick="update_component(\'' + res.labels[items][0] + '\')"></td>';
- data += '<td><input type="button" class="input-cond-delete" value="刪除" onclick="delete_component(\'' + res.labels[items][0] + '\')"></td>';
- data += '</tr>';
- };
- data += '</table>';
- }
- var sectorSelect = document.getElementById("result");
- sectorSelect.innerHTML = data;
- }, 'json');
- }
-
-
- </script>
- <!-- modal 圖片放大 -->
- <div class="modal fade" id="ImgZoomIn_Modal">
- <div class="modal-dialog modal-dialog-centered" style="width: 600px;">
- <div class="modal-content">
- <!-- 互動視窗 標題 -->
- <!-- <div class="modal-header">
- <h4 id="Modal_title_ImgZoomIn" class="modal-title">乾燥入料儲豆槽 DI1 狀態</h4>
- <button type="button" class="close" data-dismiss="modal">×</button>
- </div> -->
- <!-- 互動視窗 內容 -->
- <div class="modal-body" id="ImgZoomIn_Modal_body">
- <!-- 圖片 ImgZoomIn -->
- </div>
- </div>
- </div>
- </div>
- <div id="result">
- <!-- <table>
- </table> -->
- </div>
-
-
-
-
- </body>
- </html>
|