From 0d794d748f61b5c719d665bfcae24a4d9b2b6224 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-JIE70N9>
Date: 星期四, 08 五月 2025 15:02:49 +0800
Subject: [PATCH] 请验图片处理

---
 HTML/views/QualityControl/InspectionRequest.html |  148 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 142 insertions(+), 6 deletions(-)

diff --git a/HTML/views/QualityControl/InspectionRequest.html b/HTML/views/QualityControl/InspectionRequest.html
index 3119fd9..fd0a743 100644
--- a/HTML/views/QualityControl/InspectionRequest.html
+++ b/HTML/views/QualityControl/InspectionRequest.html
@@ -22,6 +22,13 @@
 		.layui-table-grid-down {
 			display: none;
 		}
+
+        /* 鏍峰紡鐢ㄤ簬缇庡寲鍥剧墖灞曠ず */
+        .layui-table-cell img {
+            max-width: 100px;
+            max-height: 100px;
+        }
+    
 	</style>
 	<script>
 		// 杩欓噷鏄渶瑕佸湪椤甸潰娓叉煋涔嬪墠鎵ц鐨勪唬鐮�
@@ -119,6 +126,21 @@
 							<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>鎼滅储
 						</button>
 
+					</div>
+
+					<div style="display: none;" id="UploadImageView">
+
+						<div  id="UploadImage" style="margin-left: 35px;margin-top: 30px;">
+							<label>涓婁紶鍥剧墖:</label><button type="button" class="layui-btn" id="uploadBtn" style="margin-left: 20px;" >娴忚</button>
+							<button type="button" class="layui-btn" id="upload" style="margin-left: 20px;">涓婁紶</button>
+								
+						</div>
+					</div>
+
+					<div style="display: none;" id="ImagesShowView">
+						<div id="ImagesShow">
+
+						</div>
 					</div>
 
 					<!-- 纭鍑哄簱鍙e脊绐� -->
@@ -223,6 +245,10 @@
 							var html = ''; 
 							switch (d.Status) {
 								case "0" :
+									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addClass" lay-event="upImage">
+									<i class="layui-icon layui-icon-add"></i>涓婁紶</a> `;
+									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addClass" lay-event="ViewImage">
+										<i class="layui-icon layui-icon-add"></i>鏌ョ湅</a> `;
 									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addClass" lay-event="add">
 											<i class="layui-icon layui-icon-add"></i>璇烽獙</a> `;
 									html += `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del">
@@ -287,13 +313,14 @@
 			base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
 		}).extend({
 			index: 'lib/index' //涓诲叆鍙fā鍧�
-		}).use(['index', 'table', 'laypage', 'element', 'layer', 'laydate'], function () {
+		}).use(['index', 'table', 'laypage', 'element', 'layer', 'laydate','upload'], function () {
 			var table = layui.table,
 				form = layui.form,
-				element = layui.element;
-			laypage = layui.laypage,
-				layer = layui.layer;
-			laydate = layui.laydate;
+				element = layui.element,
+				laypage = layui.laypage,
+				layer = layui.layer,
+				laydate = layui.laydate,
+				upload	= layui.upload;
 			var h1 = GetTableTabHeight();
 			laydate.render({
 				elem: '#StartTime'
@@ -379,7 +406,8 @@
 				{ field: 'Status', title: '鎵ц鐘舵��', align: 'center', width: 90, templet: '#templetStatus' },
 				{ field: 'RequestTime', title: '璇烽獙鏃ユ湡', align: 'center', width: 165, templet: '#templetCompleteTime' },
 				{ field: 'RequestUser', title: '璇烽獙浜�', align: 'center', width: 165 },
-				// { field: 'UDF1', title: '鑷畾涔�1', align: 'center', width: 100 },
+				{ field: 'UDF5', title: '鍥剧墖', align: 'center', width: 100 ,templet: function (d) {
+					return d.image ? '<img src="' + d.image + '" alt="鍥剧墖">' : '鏃犲浘鐗�';}},
 				// { field: 'UDF2', title: '鑷畾涔�2', align: 'center', width: 100 },
 				// { field: 'UDF3', title: '鑷畾涔�3', align: 'center', width: 100 },
 				// { field: 'UDF4', title: '鑷畾涔�4', align: 'center', width: 100 },
@@ -495,6 +523,65 @@
 			table.on('tool(InspectionRequest)', function (obj) {
 				var data = obj.data;
 				switch (obj.event) {
+					case "upImage":
+					layer.open({
+								type:1,
+								title: '涓婁紶鍥剧墖',
+								content: $('#UploadImageView'),
+								maxmin: true,
+								area: ['350px','215px'],
+								btn: ['纭畾'],
+								success: function(index, layero){
+									upload.render({
+										elem: '#uploadBtn',
+										url: IP + '/BllQuality/UploadImage',
+										accept: 'images',
+										exts:'jpg|png|gif',
+										multiple: false,
+										size: 1024 * 5, // 5MB
+										auto: false,
+										bindAction: '#upload',
+										headers: { ToKen: $.cookie('token') },
+										xhrFields: {
+											withCredentials: true // 鎼哄甫cookie
+										},
+										before: function(){
+											this.data = {
+												qualityId:data.Id
+											};
+										layer.load(1, {shade: [0.5, '#000']});
+										},
+										done: function(res){
+										layer.closeAll('loading');
+										if(res.code == 0){
+											layer.msg('涓婁紶鎴愬姛', {icon: 1});
+											// 涓婁紶鎴愬姛鍚庣殑鍥炶皟锛屽鍒锋柊琛ㄦ牸绛�
+											// table.reload('LAY-app-content-list');
+										} else {
+											layer.msg(res.msg || '涓婁紶澶辫触', {icon: 2});
+										}
+										},
+										error: function(){
+										layer.closeAll('loading');
+										layer.msg('涓婁紶澶辫触', {icon: 2});
+										}
+									});
+								}
+							});
+					break;
+					case "ViewImage":
+					layer.open({
+									type:1,
+									title: '鏌ョ湅鍥剧墖',
+									content: $('#ImagesShowView'),
+									maxmin: true,
+									area: ['650px','315px'],
+									btn: ['纭畾'],
+									success: function(index, layero){
+										getImage(data.Id);
+									}
+								});
+					break;
 					case "add":
 						layer.confirm('纭畾瑕佸彂璧疯楠岋紵', function (index) {
 							var param = {
@@ -627,6 +714,55 @@
 				}
 			});
 
+			function getImage(id)
+				{	
+					var param = {
+						Id:id
+					}
+					sendData(IP + "/BllQuality/GetImage", param, 'post', function (res) {
+						if (res.code == 0) { //鎴愬姛
+							$("#ImagesShow").html('');	
+							res.data.forEach(function (item) {
+								$("#ImagesShow").append('<div>'+
+								'<a href='+item+' target="_blank" class="image-item"><img src="'+ item + '"  /></a>'+
+								'<button class="layui-btn layui-btn-primary layui-btn-sm delete-btn" data-type="customCols" data_Url='+item+' >鍒犻櫎</button>'+
+								'</div>');
+							})
+							$('.delete-btn').on('click',  function ( ) {
+								var item = $(this);
+								var QualityId = id;
+								var imageUrl = item.attr('data_Url');
+								layer.confirm('纭畾鍒犻櫎鍚楋紵', function (index) {
+									var param = {
+										QualityId: QualityId,
+										ImageUrl: imageUrl
+									}
+									sendData(IP + "/BllQuality/DeleteImage", param, 'post', function (res) {
+										if (res.code == 0) { //鎴愬姛
+											layer.msg(res.msg, {
+												icon: 1,
+												time: 1000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+											}, function () {
+												getImage(id);
+											});
+											} else {
+												layer.msg(res.msg, {
+													icon: 2,
+													time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+												});
+											}
+									});
+								})});
+						} else { //涓嶆垚鍔�
+							$("#ImagesShow").html('');
+								res.msg, {
+								icon: 2,
+								time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+								}
+						}
+					})
+				}
+
 			// 鍙栨牱鏄庣粏鍗曟満浜嬩欢
 			table.on('tool(SamplingDetails)', function (obj) {
 				var data = obj.data;

--
Gitblit v1.8.0