public static string GetImageUrlButtonGroupHtml(SiteInfo siteInfo, string attributeName) { return($@" <div class=""btn-group btn-group-sm""> <button class=""btn"" onclick=""{ModalUploadImage.GetOpenWindowString(siteInfo.Id, attributeName)}""> 上传 </button> <button class=""btn"" onclick=""{ModalSelectImage.GetOpenWindowString(siteInfo, attributeName)}""> 选择 </button> <button class=""btn"" onclick=""{ModalCuttingImage.GetOpenWindowStringWithTextBox(siteInfo.Id, attributeName)}""> 裁切 </button> <button class=""btn"" onclick=""{ModalMessage.GetOpenWindowStringToPreviewImage(siteInfo.Id, attributeName)}""> 预览 </button> </div> "); }
private static string ParseImage(IAttributes attributes, SiteInfo siteInfo, int channelId, TableStyleInfo styleInfo, StringBuilder extraBuilder) { var btnAddHtml = string.Empty; if (channelId > 0) { btnAddHtml = $@" <button class=""btn"" onclick=""add_{styleInfo.AttributeName}('',true);return false;""> 新增 </button> "; } extraBuilder.Append($@" <div class=""btn-group btn-group-sm""> <button class=""btn"" onclick=""{ModalUploadImage.GetOpenWindowString(siteInfo.Id, styleInfo.AttributeName)}""> 上传 </button> <button class=""btn"" onclick=""{ModalSelectImage.GetOpenWindowString(siteInfo, styleInfo.AttributeName)}""> 选择 </button> <button class=""btn"" onclick=""{ModalCuttingImage.GetOpenWindowStringWithTextBox(siteInfo.Id, styleInfo.AttributeName)}""> 裁切 </button> <button class=""btn"" onclick=""{ModalMessage.GetOpenWindowStringToPreviewImage(siteInfo.Id, styleInfo.AttributeName)}""> 预览 </button> {btnAddHtml} </div> "); var attributeName = styleInfo.AttributeName; var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); extraBuilder.Append($@" <script type=""text/javascript""> function select_{styleInfo.AttributeName}(obj, index){{ var cmd = ""{ModalSelectImage.GetOpenWindowString(siteInfo, styleInfo.AttributeName)}"".replace('{attributeName}', '{attributeName}_' + index).replace('return false;', ''); eval(cmd); }} function upload_{attributeName}(obj, index){{ var cmd = ""{ModalUploadImage.GetOpenWindowString(siteInfo.Id, attributeName)}"".replace('{attributeName}', '{attributeName}_' + index).replace('return false;', ''); eval(cmd); }} function cutting_{attributeName}(obj, index){{ var cmd = ""{ModalCuttingImage.GetOpenWindowStringWithTextBox(siteInfo.Id, attributeName)}"".replace('{attributeName}', '{attributeName}_' + index).replace('return false;', ''); eval(cmd); }} function preview_{attributeName}(obj, index){{ var cmd = ""{ModalMessage.GetOpenWindowStringToPreviewImage(siteInfo.Id, attributeName)}"".replace(/{attributeName}/g, '{attributeName}_' + index).replace('return false;', ''); eval(cmd); }} function delete_{attributeName}(obj){{ $(obj).parent().parent().parent().remove(); }} var index_{attributeName} = 0; function add_{attributeName}(val,foucs){{ index_{attributeName}++; var inputHtml = '<input id=""{attributeName}_'+index_{attributeName}+'"" name=""{extendAttributeName}"" type=""text"" class=""form-control"" value=""'+val+'"" />'; var btnHtml = '<div class=""btn-group btn-group-sm"">'; btnHtml += '<button class=""btn"" href=""javascript:;"" onclick=""select_{attributeName}(this, '+index_{attributeName}+');return false;"">选择</button>'; btnHtml += '<button class=""btn"" href=""javascript:;"" onclick=""upload_{attributeName}(this, '+index_{attributeName}+');return false;"">上传</button>'; btnHtml += '<button class=""btn"" href=""javascript:;"" onclick=""cutting_{attributeName}(this, '+index_{attributeName}+');return false;"">裁切</button>'; btnHtml += '<button class=""btn"" href=""javascript:;"" onclick=""preview_{attributeName}(this, '+index_{attributeName}+');return false;"">预览</button>'; btnHtml += '<button class=""btn"" href=""javascript:;"" onclick=""delete_{attributeName}(this);return false;"">删除</button>'; btnHtml += '</div>'; var div = $('.{extendAttributeName}').length == 0 ? $('#{attributeName}').parent().parent() : $('.{extendAttributeName}:last'); div.after('<div class=""form-group form-row {extendAttributeName}""><label class=""col-sm-1 col-form-label text-right""></label><div class=""col-sm-6"">' + inputHtml + '</div><div class=""col-sm-5"">' + btnHtml + '</div></div>'); if (foucs) $('#{attributeName}_'+index_{attributeName}).focus(); }} "); var extendValues = attributes.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (!string.IsNullOrEmpty(extendValue)) { extraBuilder.Append($"add_{attributeName}('{extendValue}',false);"); } } } extraBuilder.Append("</script>"); return($@"<input id=""{attributeName}"" name=""{attributeName}"" type=""text"" class=""form-control"" value=""{attributes.GetString(attributeName)}"" />"); }