123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <!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">
- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
- <script>
- $(function(){
-
- });
- </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>
- 待測試!!! <br>
- 請選擇欲更新的圖片內部料號 :
- <input list="insert_PR_id_item" id="PR_id" style="height: 25px;" onChange="loadOldImg(event)">
- <datalist id="insert_PR_id_item">
- {% 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>
- <br>
- <span id="showOldImg_filename"></span><br>
- <img id="showOldImg" width="180">
- <script>
- var sql = '';
- var sql_data = { "sql":sql };
- var loadOldImg = function(event) {
- var reader = new FileReader();
- reader.onload = function(){
- var showImg = document.getElementById('PR_id');
- showImg.src = reader.result;
- };
- reader.readAsDataURL(event.target.files[0]);
- };
- // var loadOldImg = function(event) {
- // var reader = new FileReader();
- // reader.onload = function(evt){
- // var new_PR_id = document.getElementById("PR_id");
- // console.log("new_PR_id: " + new_PR_id);
- // sql = 'SELECT `圖片` FROM `規格表` WHERE `內部料號`="' + new_PR_id + '"'
- // sql_data = { "sql":sql };
- // $.get('/sql_get', sql_data, function (res) {
- // if (res.labels[0] != '') {
- // var showImg = document.getElementById('showOldImg');
- // showImg.src = 'C:/Users/USER/Rita/ERP_Rita/static/Component_IMG/' + res.labels[0][0];
- // var showImg_filename = document.getElementById('showOldImg_filename');
- // showImg_filename.value = res.labels[0][0];
- // } else {
- // showImg_filename.value = '無圖片上傳';
- // }
-
- // }, 'json');
- // var showImg = document.getElementById('05070001T01_showImg');
- // showImg.src = reader.result;
- // };
- // reader.readAsDataURL(event.target.files[0]);
- // };
- function get_id_updatePicure(id) {
- var new_PR_id = document.getElementById(id).value;
- sql = 'SELECT `圖片` FROM `規格表` WHERE `內部料號`="' + new_PR_id + '"'
- sql_data = { "sql":sql };
- $.get('/sql_get', sql_data, function (res) {
- if (res.labels[0] != '') {
- var showImg = document.getElementById('showOldImg');
- showImg.src = 'C:/Users/USER/Rita/ERP_Rita/static/Component_IMG/' + res.labels[0][0];
- var showImg_filename = document.getElementById('showOldImg_filename');
- showImg_filename.value = res.labels[0][0];
- } else {
- showImg_filename.value = '無圖片上傳';
- }
-
- }, 'json');
- }
- </script>
- <br>
- <br>
- <span id="picture_exist"></span>
- <br>
- <br>
- <hr>
- 圖片上傳至 ERP 檔案內儲存, 測試 OK
- <form action="upload" method="post" enctype="multipart/form-data">
- <input type="file" id="05070001T01_loadImg" multiple="" accept="image/*" name="file[]" onchange="loadImg(event)"><br/>
- <img id="05070001T01_showImg" width="60"><br>
- <input type="submit" value="Upload">
- </form>
- <script>
-
- var loadImg = function(event) {
- var reader = new FileReader();
- reader.onload = function(){
- var showImg = document.getElementById('05070001T01_showImg');
- showImg.src = reader.result;
- };
- reader.readAsDataURL(event.target.files[0]);
- };
- function UploadImg(id) {
- // 取得檔案名稱
- var fileName = document.getElementById( id + '_loadImg').value;
- alert("fileName: " + String(fileName).substr(12))
- // 上傳圖片
- $.get('/upload/' + String(fileName).substr(12), '', function (res) {
- alert("UPLOAD success!")
- }, 'json');
- }
- </script>
- </body>
- </html>
|