diff --git a/H5/bgcFormSubTableBtn/bgcSubTableBtn_m_api.s3js b/H5/bgcFormSubTableBtn/bgcSubTableBtn_m_api.s3js new file mode 100644 index 0000000..69dbb10 --- /dev/null +++ b/H5/bgcFormSubTableBtn/bgcSubTableBtn_m_api.s3js @@ -0,0 +1,5 @@ +var newWidgetApi = (function() { + var newWidgetApi = function() { + this.basePath = "http://bgcSubTableBtn.v5.cmp/v1.0.0"; + } +})(); diff --git a/H5/bgcFormSubTableBtn/js/bgcSubTableBtn.js b/H5/bgcFormSubTableBtn/js/bgcSubTableBtn.js new file mode 100644 index 0000000..2dc6655 --- /dev/null +++ b/H5/bgcFormSubTableBtn/js/bgcSubTableBtn.js @@ -0,0 +1,195 @@ +(function () { + // >>> step1. 定义控件唯一标识(命名空间) + var scopeName = "field_88661234567890123656"; + + // >>> step2. 实现自定义控件渲染及交互逻辑 + var BgcSubTableBtn = function (options) { + this.customWidgetType = scopeName; + this._create(options); + }; + BgcSubTableBtn.prototype = { + constructor: BgcSubTableBtn, + _create: function (options) { + this._options = options; + this._widgetId = options.privateId; + this._widgetProxy = options.adaptation; + this._wrapper = document.getElementById(this._widgetId); + this._field = this._widgetProxy.childrenGetData(this._widgetId); + this._tunnelId = 'Event' + this._widgetId; + if (!this._wrapper) return console.warn('没有找到组件渲染的容器'); + this.clicked = 0; + this._update(); + console.log(this._widgetProxy); + }, + _update: function (field) { + if (field) this._field = field; + this._destroy(); + this._buildRendering(); + this._postCreate(); + }, + + _buildRendering: function () { + var elemId = 'section-' + this._widgetId; + var btnId = 'section-' + this._widgetId + '-btn'; + var tpl = '
' + + '' + + '
'; + this._wrapper.innerHTML = tpl; + this._el = this._wrapper.querySelector('#' + elemId); + this._btnEl = this._wrapper.querySelector('#' + btnId); + }, + _postCreate: function () { + this._fieldElement = this._wrapper.querySelector('.' + this._widgetId + '__'); + + if (this._fieldElement) { + this._unbindTouchStart = this._bind(this._fieldElement, 'touchstart', this.onTouchStart.bind(this)); + this._unbindTouchEnd = this._bind(this._fieldElement, 'touchend', this.onTouchEnd.bind(this)); + this._unbindTouchMove = this._bind(this._fieldElement, 'touchmove', this.onTouchMove.bind(this)); + } + + this._unbindTap = this._bind(this._btnEl, 'click', this.onClick.bind(this)); // 改为 click + this._unbindUpdate = this._listen(this._tunnelId, this._update.bind(this)); + }, + _destroy: function () { + // 取消相关绑定事件 + if (this._fieldElement) { + this._unbindTouchStart && this._unbindTouchStart(); + this._unbindTouchEnd && this._unbindTouchEnd(); + this._unbindTouchMove && this._unbindTouchMove(); + } + this._unbindTap && this._unbindTap(); + this._unbindUpdate && this._unbindUpdate(); + this._el = this._btnEl = this._fieldElement = null; + }, + _bind: function (el, evt, cb) { + el.addEventListener(evt, cb, false); + return function () { + el.removeEventListener(evt, cb, false); + } + }, + _listen: function (evt, cb) { + var hub = this._widgetProxy.ObserverEvent; + hub.listen(evt, cb); + return function () { + hub.remove(evt, cb); + } + }, + onTouchStart: function () { + if (this._fieldElement) { + this._fieldElement.style.backgroundColor = "#005297"; + } + }, + + onTouchEnd: function () { + if (this._fieldElement) { + this._fieldElement.style.backgroundColor = "#008BFF"; + } + }, + + onTouchMove: function () { + if (this._fieldElement) { + this._fieldElement.style.backgroundColor = "#005297"; + } + }, + onClick: function () { + + var tableName = this._options.formMessage.tableName; + + + var formId = this._options.getData.formdata.rawData.content.contentDataId; + var formsons = this._options.getData.formdata.formsons; + var formmains = this._options.getData.formdata.formmains[tableName]; + + var assetsNo = ''; + var mainTableMap = formmains.elements; + var boundConfigs = [] + let subTableKeys = Object.keys(formsons) + subTableKeys.forEach((key)=>{ + let formson = formsons[key] + if (formson.display === '地块范围定位列表') { + let subTableList = formson.records; + + for (let i = 0; i < subTableList.length; i++) { + let subTableMap = subTableList[i].elements + + let subKeys = Object.keys(subTableMap) + + let blockNum + let pathOrder + let lat + let lng + subKeys.forEach((k) => { + let display = subTableMap[k].display; + let value = subTableMap[k].value; + if (display === '地块序号') blockNum = value; + if (display === '线路顺序') pathOrder = value; + + if (display === '地块定位纬度') lat = value; + if (display === '地块定位经度') lng = value; + }); + boundConfigs.push({blockNum:blockNum,pathOrder:pathOrder,lat:lat,lng:lng}) + } + } + }) + const keys = Object.keys(mainTableMap); + keys.forEach((k) => { + let display = mainTableMap[k].display; + let value = mainTableMap[k].value; + if (display === '资产编号') assetsNo = value; + }); + + + const url = `${window.location.origin}/seeyon/rest/assetsRegion/reComputedBoundConfig`; + const params = { + subBoundConfigs: boundConfigs, + fieldDisplay: "资产边界数据", + formId: formId + }; + + fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + }, + body: JSON.stringify(params) + }) + .then(response => response.json()) + .then(data => { + console.log(data.code) + if (data.code === 0) { + console.log(formmains.elements) + formmains.elements[data.data.targetField].value = data.data.updateData; // 请确认 field0249 是你实际的字段key + } else if (data.code === "500") { + alert(data.msg); + } else { + alert("生成失败,请联系管理员"); + } + }) + .catch((e) => { + console.log(e) + alert("出现异常,生成失败,请联系管理员"); + }); + + + this._update(); + } + }; + + // >>> step3. 实现开发规范约定的init及destroy接口 + var myWidgets = {}; + // 组件初始化 + BgcSubTableBtn.init = function (options) { + var widget = new BgcSubTableBtn(options); + myWidgets[widget._widgetId] = widget; + }; + // 组件销毁 + BgcSubTableBtn.destroy = function (widgetId) { + var widget = myWidgets[widgetId]; + if (widget) widget._destroy(); + delete myWidgets[widgetId]; + }; + + // >>> step4. 注册组件实现到命名控件 + window[scopeName] = BgcSubTableBtn; +})(); \ No newline at end of file diff --git a/H5/bgcFormSubTableBtn/manifest.json b/H5/bgcFormSubTableBtn/manifest.json new file mode 100644 index 0000000..917c1d4 --- /dev/null +++ b/H5/bgcFormSubTableBtn/manifest.json @@ -0,0 +1,25 @@ +{ + "buildVersion":"1.0.0", + "iconFiles":{"default":"","multi":[]}, + "appName":"bgcSubTableBtn", + "splashscreen":[], + "update":{"checkUpdateUrl":""}, + "bundleIdentifier":"", + "serviceProvidear":"seeyon", + "team":"v5", + "cmpShellVersion":{"ios":"1.0.0","android":"1.0.0"}, + "packageType":"LIB", + "version":"1.0.0", + "entry":{ + "phone":"", + "jsapi":"bgcSubTableBtn_m_api.s3js", + "openAppMethod":"" + }, + "compatibleVersion":["1.0.0","1.0.1","2.0.0"], + "appType":"default", + "appId":"905", + "urlSchemes":"bgcSubTableBtn.v5.cmp", + "bundleName":"bgcSubTableBtn", + "supportedPlatforms":["iOS_6.0","android_4.0"], + "desc":"资产边界数据重计算" +} diff --git a/assetsMap/blue.png b/assetsMap/blue.png new file mode 100644 index 0000000..7b55099 Binary files /dev/null and b/assetsMap/blue.png differ diff --git a/assetsMap/map.html b/assetsMap/map.html index f6126d3..8d9dd44 100644 --- a/assetsMap/map.html +++ b/assetsMap/map.html @@ -68,10 +68,9 @@ .asset-item .info { font-size:12px; color:#888; margin-top:3px; line-height:1.6; } .asset-item .actions { display:flex; gap:6px; margin-top:8px; } .asset-item .actions button { - padding:5px 10px; border:1px solid #ddd; border-radius:4px; - background:#fff; cursor:pointer; font-size:12px; + padding:5px 10px; border:1px solid #e74c3c; border-radius:4px; + background:#e74c3c; color:#fff; cursor:pointer; font-size:12px; } - .asset-item .actions button:hover { border-color:#e74c3c; color:#e74c3c; } .asset-item .actions .btn-detail { background:#e74c3c; color:#fff; border-color:#e74c3c; } .empty-tip { padding:30px 16px; text-align:center; color:#ccc; font-size:14px; } @@ -79,6 +78,11 @@ .custom-marker-icon { background:none !important; border:none !important; } + /* 移动端触控优化 */ + .media-panel-overlay, .lightbox-overlay, .video-overlay, .pano-overlay { touch-action:none; } + .media-panel { touch-action:pan-y; } + .pano-viewer { touch-action:none; } + /* 筛选区折叠 */ .filter-section > div:nth-child(2) { transition:all 0.3s ease; overflow:hidden; } @@ -127,7 +131,82 @@ .switch-popup .sp-item.active { background:#fdedec; border-color:#e74c3c; } .switch-popup .sp-item:last-child { margin-bottom:0; } + /* 媒体浏览组件 */ + .gallery-link { display:inline-flex; align-items:center; gap:4px; padding:6px 0; font-size:13px; color:#e74c3c; cursor:pointer; user-select:none; } + .gallery-link:hover { text-decoration:underline; } + + .thumb-list { display:flex; flex-wrap:wrap; gap:4px; padding:4px 0; margin:4px 0; } + .thumb-item { width:56px; height:56px; border-radius:4px; overflow:hidden; cursor:pointer; position:relative; border:2px solid transparent; transition:border-color 0.2s; } + .thumb-item:hover { border-color:#3498db; } + .thumb-item img { width:100%; height:100%; object-fit:cover; } + .thumb-badge { position:absolute; bottom:2px; right:2px; background:rgba(0,0,0,0.7); color:#fff; font-size:10px; padding:1px 3px; border-radius:2px; line-height:1; } + + .lightbox-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.92); z-index:100100; display:flex; align-items:center; justify-content:center; flex-direction:column; } + .lightbox-close { position:absolute; top:16px; right:16px; background:none; border:none; color:#fff; font-size:28px; cursor:pointer; z-index:100101; width:40px; height:40px; display:flex; align-items:center; justify-content:center; } + .lightbox-close:hover { color:#e74c3c; } + .lightbox-img { max-width:90vw; max-height:80vh; object-fit:contain; } + .lightbox-nav { position:absolute; top:50%; transform:translateY(-50%); background:rgba(255,255,255,0.15); border:none; color:#fff; font-size:32px; cursor:pointer; width:48px; height:48px; display:flex; align-items:center; justify-content:center; border-radius:50%; transition:background 0.2s; } + .lightbox-nav:hover { background:rgba(255,255,255,0.35); } + .lightbox-prev { left:16px; } + .lightbox-next { right:16px; } + .lightbox-counter { color:#fff; font-size:14px; margin-top:12px; } + + .video-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.92); z-index:100100; display:flex; align-items:center; justify-content:center; flex-direction:column; } + .video-close { position:absolute; top:16px; right:16px; background:none; border:none; color:#fff; font-size:28px; cursor:pointer; z-index:100101; width:40px; height:40px; display:flex; align-items:center; justify-content:center; } + .video-close:hover { color:#e74c3c; } + .video-player { max-width:90vw; max-height:80vh; } + + .pano-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:#000; z-index:100100; overflow:hidden; } + .pano-close { position:absolute; top:16px; right:16px; background:rgba(0,0,0,0.6); border:2px solid rgba(255,255,255,0.5); color:#fff; font-size:20px; cursor:pointer; z-index:100101; width:44px; height:44px; display:flex; align-items:center; justify-content:center; border-radius:50%; } + .pano-close:hover { background:rgba(231,76,60,0.8); border-color:#fff; } + .pano-viewer { width:100%; height:100%; background-size:auto 100%; background-repeat:repeat-x; background-position:center center; cursor:grab; } + .pano-viewer.dragging { cursor:grabbing; } + .pano-hint { position:absolute; bottom:20px; left:50%; transform:translateX(-50%); color:rgba(255,255,255,0.5); font-size:13px; pointer-events:none; } + + + /* 影像资料弹框 */ + .media-panel-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.5); z-index:100000; display:flex; align-items:center; justify-content:center; } + .media-panel { width:720px; max-width:90vw; max-height:80vh; background:#fff; border-radius:12px; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 8px 32px rgba(0,0,0,0.25); } + .media-panel-header { display:flex; align-items:center; justify-content:space-between; padding:14px 20px; border-bottom:1px solid #eee; flex-shrink:0; } + .media-panel-title { font-size:16px; font-weight:bold; color:#333; } + .media-panel-close { background:none; border:none; font-size:22px; color:#888; cursor:pointer; width:36px; height:36px; display:flex; align-items:center; justify-content:center; border-radius:50%; } + .media-panel-close:hover { background:#f0f0f0; color:#333; } + + /* Tab页签 */ + .media-tabs { display:flex; border-bottom:2px solid #eee; flex-shrink:0; } + .media-tab { flex:1; padding:10px 0; text-align:center; font-size:13px; color:#888; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; transition:all 0.2s; } + .media-tab:hover { color:#333; } + .media-tab.active { color:#e74c3c; border-bottom-color:#e74c3c; font-weight:bold; } + + /* Tab内容区 */ + .media-panel-body { flex:1; overflow-y:auto; padding:16px; } + + /* 图片区 */ + .media-img-grid { display:flex; flex-wrap:wrap; gap:8px; } + .media-img-item { width:calc(25% - 6px); aspect-ratio:4/3; border-radius:6px; overflow:hidden; cursor:pointer; position:relative; border:2px solid transparent; transition:border-color 0.2s; } + .media-img-item:hover { border-color:#e74c3c; } + .media-img-item img { width:100%; height:100%; object-fit:cover; } + .media-img-item .pano-badge { position:absolute; top:4px; left:4px; background:rgba(0,0,0,0.7); color:#fff; font-size:10px; padding:2px 6px; border-radius:3px; } + + /* 视频区 */ + .media-video-grid { display:flex; flex-wrap:wrap; gap:8px; } + .media-video-item { width:calc(33.33% - 6px); aspect-ratio:16/9; border-radius:6px; overflow:hidden; cursor:pointer; position:relative; background:#000; border:2px solid transparent; transition:border-color 0.2s; } + .media-video-item:hover { border-color:#3498db; } + .media-video-item img { width:100%; height:100%; object-fit:cover; opacity:0.7; } + .media-video-item .play-icon { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:40px; height:40px; background:rgba(0,0,0,0.6); border-radius:50%; display:flex; align-items:center; justify-content:center; color:#fff; font-size:18px; } + + /* 附件区 */ + .media-file-list { display:flex; flex-direction:column; gap:4px; } + .media-file-item { display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid #eee; border-radius:6px; cursor:pointer; transition:background 0.15s; } + .media-file-item:hover { background:#f8f9fa; border-color:#e74c3c; } + .media-file-icon { width:32px; height:32px; background:#f0f0f0; border-radius:6px; display:flex; align-items:center; justify-content:center; font-size:14px; color:#666; flex-shrink:0; } + .media-file-info { flex:1; min-width:0; } + .media-file-name { font-size:13px; color:#333; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } + .media-file-size { font-size:11px; color:#999; margin-top:2px; } + .media-empty { text-align:center; padding:40px 0; color:#ccc; font-size:14px; } + @media (max-width:768px) { + /* 地图与面板布局 */ #app { display:block; width:100%; height:100%; position:relative; } #mapWrap { position:absolute; top:0; left:0; width:100%; height:45%; } #map { height:100%; width:100%; } @@ -138,14 +217,43 @@ border-radius:12px 12px 0 0; box-shadow:0 -2px 12px rgba(0,0,0,0.08); } + + /* 筛选与按钮 */ .filter-group select, .filter-group input[type="text"] { min-height:44px; font-size:15px; } .btn { min-height:44px; font-size:15px; } + .cascade-col { min-width:120px; } + .cascade-col .col-item { padding:12px 10px; font-size:14px; } + + /* 资产卡片 */ .asset-item { padding:14px 16px; min-height:80px; } .asset-item .name { font-size:15px; } .asset-item .info { font-size:13px; } - .asset-item .actions button { padding:8px 12px; font-size:13px; min-height:32px; } - .cascade-col { min-width:120px; } - .cascade-col .col-item { padding:12px 10px; font-size:14px; } + .asset-item .actions { flex-wrap:wrap; } + .asset-item .actions button { padding:8px 14px; font-size:13px; min-height:40px; flex:1; } + + /* 影像资料弹框:底部弹出式 */ + .media-panel-overlay { align-items:flex-end; } + .media-panel { width:100%; max-width:100%; max-height:75vh; border-radius:16px 16px 0 0; } + .media-panel-header { padding:16px 20px; } + .media-panel-close { width:44px; height:44px; font-size:24px; } + .media-tab { padding:12px 0; font-size:14px; min-height:44px; } + .media-panel-body { padding:12px; } + .media-img-item { width:calc(50% - 4px); } + .media-video-item { width:100%; } + .media-file-item { padding:12px; min-height:48px; } + + /* 灯箱:更大触控区域 */ + .lightbox-close { width:48px; height:48px; font-size:32px; top:12px; right:12px; } + .lightbox-nav { width:56px; height:56px; font-size:36px; } + .lightbox-counter { font-size:16px; margin-top:16px; } + + /* 视频弹框 */ + .video-close { width:48px; height:48px; font-size:32px; } + .video-player { max-width:100vw; max-height:60vh; } + + /* 全景弹框 */ + .pano-close { width:48px; height:48px; font-size:24px; } + .pano-hint { font-size:14px; bottom:24px; } } @@ -211,7 +319,7 @@
- +
@@ -233,13 +341,112 @@ 位置:{{a.address || '-'}}
面积:{{a.area || '-'}}㎡ | 管理单位:{{a.manager || '-'}} +
+
+
加载中...
+
已加载全部 {{total}} 条
+ + + + + + + + +
+ + +
+ + +
+
+
+ {{mediaPanel.assetName || '影像资料'}} + +
+
+
图片
+
视频
+ +
+
+ +
+
+
+ +
+
+ + 360° +
+
+
暂无图片
+
+ +
+
+
+ +
+
+
+
暂无视频
+
+ +
+
+
+
{{getFileExt(f.name)}}
+
+
{{f.name || '附件' + (idx+1)}}
+
{{f.size || ''}}
+
+
+
+
暂无附件
+
+ + +
+ +
+
+
拖动鼠标或触摸滑动查看全景
+
diff --git a/assetsMap/markicon.png b/assetsMap/red.png similarity index 100% rename from assetsMap/markicon.png rename to assetsMap/red.png diff --git a/seeyon/WEB-INF/assetsmap/spring/spring.xml b/seeyon/WEB-INF/assetsmap/spring/spring.xml index e833a05..ed71631 100644 --- a/seeyon/WEB-INF/assetsmap/spring/spring.xml +++ b/seeyon/WEB-INF/assetsmap/spring/spring.xml @@ -7,4 +7,9 @@ + + + + + \ No newline at end of file diff --git a/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/btn.css b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/btn.css new file mode 100644 index 0000000..a633877 --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/btn.css @@ -0,0 +1,36 @@ +.customButton_class_box { + width: 100%; + line-height: 24px; + height:24px; + color: #1f85ec; + cursor: pointer; + font-family: "Microsoft YaHei"!important; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + word-break:keep-all; + box-sizing: border-box; + -webkit-box-sizing : border-box; + -moz-box-sizing : border-box; + text-align: center; + outline: none; + border: 1px solid #1f85ec; + background-color: #fff; + border-radius: 15px; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; +} +.customInputArea{ + width: 65%; + height:auto; + color: #1f85ec; + font-family: "Microsoft YaHei"!important; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + word-break:keep-all; +} +.customButton_box_content{ + width: 100%; + height: auto; +} diff --git a/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/img/icon16.png b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/img/icon16.png new file mode 100644 index 0000000..e43def3 Binary files /dev/null and b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/css/img/icon16.png differ diff --git a/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/js/bgcSubTableBtn.js b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/js/bgcSubTableBtn.js new file mode 100644 index 0000000..8a2f593 --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/GBCFromSubTableResources/js/bgcSubTableBtn.js @@ -0,0 +1,173 @@ +(function(factory) { + var nameSpace = 'field_88661234567890123656'; + if (!window[nameSpace]) { + console.log("开始实例化计算明细表资产边界数据在主表生成") + var Builder = factory(); + window[nameSpace] = { + instance: {} + }; + window[nameSpace].init = function(options) { + window[nameSpace].instance[options.privateId] = new Builder(options); + }; + } +})(function() { + function App(options) { + var self = this; + self.initParams(options); + //初始化dom + self.initDom(); + //事件 + self.events(); + } + + App.prototype = { + initParams: function(options) { + console.log("开始初始化参数") + var self = this; + self.adaptation = options.adaptation; + self.privateId = options.privateId; + self.preUrl = options.url_prefix; + self.adaptation.formMessage = options.formMessage; + self.messageObj = options.getData; + console.log(self.messageObj) + }, + initDom: function() { + var self = this; + console.log("开始渲染dom") + dynamicLoading.css(self.preUrl + '/css/btn.css'); + self.appendChildDom(); + }, + events: function() { + var self = this; + // 监听是否数据刷新 + console.log("设置事件监听") + self.adaptation.ObserverEvent.listen('Event' + self.privateId, function() { + self.messageObj = self.adaptation.childrenGetData(self.privateId); + self.appendChildDom(); + }); + }, + computed: function(privateId,messageObj,adaptation) { + var tableName = adaptation.formMessage.tableName; + var formId = messageObj.content.contentDataId; + var formsons[] = messageObj.formdata.formsons; + var formmains = messageObj.formdata.formmains[tableName]; + var assetsNo = ''; + var mainTableMap = formmains.elements; + var boundConfigs[]; + console.log(mainTableMap) + for(let i=0; i { + let display = tableMap[k].display; + let value = tableMap[k].value; + if (display === '地块序号') boundConfig.blockNum = value; + if (display === '线路顺序') boundConfig.pathOrder = value; + + if (display === '地块定位纬度') boundConfig.lat = value; + if (display === '地块定位经度') boundConfig.lng = value; + }); + boundConfigs.push(boundConfig) + } + break; + } + } + const keys = Object.keys(tableMap); + keys.forEach((k) => { + let display = tableMap[k].display; + let value = tableMap[k].value; + if (display === '资产编号') assetsNo = value; + }); + + + const params = new URLSearchParams({ + subBoundConfigs: boundConfigs, + fieldDisplay: "资产边界数据", + formId: formId + }); + $.ajax({ + type: "POST", + url: '/seeyon/rest/assetsRegion/reComputedBoundConfig', + data: JSON.stringify(params), + dataType: "json", + contentType: 'application/json;charset=UTF-8', + success: function(res) { + // 后台解析数据后 将数据填写到表单中 + if (res.code == 0) { + var backfill = {}; + backfill.tableName = res.data.masterTableName; + // 回填主表 + backfill.tableCategory = 'formmain'; + // 后台组装的data数据 + console.log(res.data) + backfill.updateData = res.data.updateData; + adaptation.backfillFormControlData(backfill, privateId); + } else { + // 报错 + $.alert(res.message); + } + }, + complete: function() {}, + error: function(e) { + top.$.error(e.responseText); + } + }); + + }, + appendChildDom: function() { + var self = this; + var doBiz = function() { + self.computed(self.privateId, self.messageObj, self.adaptation) + } + + var domStructure = '
' + + '
' + self.messageObj.display.escapeHTML() + '
' + + '
'; + document.querySelector('#' + self.privateId).innerHTML = domStructure; + + var content = self.messageObj.formdata.content + document.querySelector('.' + self.privateId).removeEventListener('click', doBiz); + document.querySelector('.' + self.privateId).addEventListener('click', doBiz); + //渲染隐藏权限 + if (self.messageObj.auth === 'hide') { + document.querySelector('#' + self.privateId).innerHTML = + '
***
'; + } + } + + }; +function backFill(latlng, fieldName, fieldDisplay, privateId, messageObj, adaptation,tableName) { + + } + var dynamicLoading = { + css: function(path) { + if (!path || path.length === 0) { + throw new Error('argument "path" is required !'); + } + var head = document.getElementsByTagName('head')[0]; + var link = document.createElement('link'); + link.href = path; + link.rel = 'stylesheet'; + link.type = 'text/css'; + head.appendChild(link); + }, + js: function(path) { + if (!path || path.length === 0) { + throw new Error('argument "path" is required !'); + } + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.src = path; + script.type = 'text/javascript'; + head.appendChild(script); + } + } + return App; +}); \ No newline at end of file diff --git a/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/css/fileUpload.css b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/css/fileUpload.css new file mode 100644 index 0000000..c60cb7f --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/css/fileUpload.css @@ -0,0 +1,311 @@ +/* 文件上传控件样式 */ +.file-upload-box { + width: 100%; +} +.file-upload-btn { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 6px 16px; + background: #e74c3c; + color: #fff; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 13px; + font-weight: bold; + transition: background 0.2s; +} +.file-upload-btn:hover { + background: #c0392b; +} +.file-upload-btn::before { + content: "📎"; + font-size: 14px; +} + +/* 已上传文件列表 */ +.file-upload-list { + margin-top: 8px; +} +.file-upload-item { + display: flex; + align-items: center; + gap: 8px; + padding: 6px 8px; + background: #f8f9fa; + border: 1px solid #eee; + border-radius: 4px; + margin-bottom: 4px; + font-size: 12px; +} +.file-upload-item .file-icon { + width: 24px; + height: 24px; + background: #e74c3c; + color: #fff; + border-radius: 4px; + display: flex; + align-items: center; + justify-content: center; + font-size: 10px; + font-weight: bold; + flex-shrink: 0; +} +.file-upload-item .file-name { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: #333; +} +.file-upload-item .file-size { + color: #999; + font-size: 11px; + flex-shrink: 0; +} +.file-upload-item .file-del { + color: #e74c3c; + cursor: pointer; + font-size: 16px; + padding: 0 4px; + flex-shrink: 0; +} +.file-upload-item .file-del:hover { + color: #c0392b; +} + +/* 文件选择弹框 */ +.file-picker-overlay { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + background: rgba(0,0,0,0.5); + z-index: 100000; + display: flex; + align-items: center; + justify-content: center; +} +.file-picker { + width: 700px; + max-width: 90vw; + max-height: 80vh; + background: #fff; + border-radius: 12px; + display: flex; + flex-direction: column; + overflow: hidden; + box-shadow: 0 8px 32px rgba(0,0,0,0.25); +} +.file-picker-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 14px 20px; + border-bottom: 1px solid #eee; + flex-shrink: 0; +} +.file-picker-title { + font-size: 16px; + font-weight: bold; + color: #333; +} +.file-picker-close { + background: none; + border: none; + font-size: 22px; + color: #888; + cursor: pointer; + width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 50%; +} +.file-picker-close:hover { + background: #f0f0f0; + color: #333; +} + +/* 工具栏 */ +.file-picker-toolbar { + display: flex; + align-items: center; + gap: 8px; + padding: 10px 20px; + border-bottom: 1px solid #eee; + flex-shrink: 0; +} +.file-picker-toolbar .breadcrumb { + display: flex; + align-items: center; + gap: 4px; + font-size: 13px; + color: #666; + flex: 1; + overflow: hidden; +} +.file-picker-toolbar .breadcrumb-item { + cursor: pointer; + color: #e74c3c; + white-space: nowrap; +} +.file-picker-toolbar .breadcrumb-item:hover { + text-decoration: underline; +} +.file-picker-toolbar .breadcrumb-sep { + color: #ccc; +} +.file-picker-toolbar .breadcrumb-current { + color: #333; + font-weight: bold; + white-space: nowrap; +} +.file-picker-toolbar .toolbar-btn { + padding: 5px 10px; + border: 1px solid #ddd; + border-radius: 4px; + background: #fff; + cursor: pointer; + font-size: 12px; + white-space: nowrap; +} +.file-picker-toolbar .toolbar-btn:hover { + border-color: #e74c3c; + color: #e74c3c; +} +.file-picker-toolbar .toolbar-btn.upload-btn { + background: #e74c3c; + color: #fff; + border-color: #e74c3c; +} +.file-picker-toolbar .toolbar-btn.upload-btn:hover { + background: #c0392b; +} + +/* 文件列表 */ +.file-picker-body { + flex: 1; + overflow-y: auto; + padding: 12px 20px; +} +.file-picker-empty { + text-align: center; + padding: 40px 0; + color: #ccc; + font-size: 14px; +} +.file-picker-grid { + display: flex; + flex-wrap: wrap; + gap: 8px; +} +.file-picker-folder { + display: flex; + align-items: center; + gap: 8px; + padding: 10px 12px; + border: 1px solid #eee; + border-radius: 6px; + cursor: pointer; + width: calc(50% - 4px); + transition: border-color 0.15s; +} +.file-picker-folder:hover { + border-color: #e74c3c; + background: #fef8f7; +} +.file-picker-folder .folder-icon { + font-size: 24px; + flex-shrink: 0; +} +.file-picker-folder .folder-name { + font-size: 13px; + color: #333; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.file-picker-file { + display: flex; + align-items: center; + gap: 8px; + padding: 10px 12px; + border: 1px solid #eee; + border-radius: 6px; + cursor: pointer; + width: calc(50% - 4px); + transition: border-color 0.15s; +} +.file-picker-file:hover { + border-color: #e74c3c; + background: #fef8f7; +} +.file-picker-file .file-icon-sm { + width: 32px; + height: 32px; + background: #f0f0f0; + border-radius: 4px; + display: flex; + align-items: center; + justify-content: center; + font-size: 11px; + font-weight: bold; + color: #666; + flex-shrink: 0; +} +.file-picker-file .file-info { + flex: 1; + min-width: 0; +} +.file-picker-file .file-info .name { + font-size: 13px; + color: #333; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.file-picker-file .file-info .size { + font-size: 11px; + color: #999; + margin-top: 2px; +} + +/* 底部 */ +.file-picker-footer { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 20px; + border-top: 1px solid #eee; + flex-shrink: 0; +} +.file-picker-footer .selected-count { + font-size: 13px; + color: #666; +} +.file-picker-footer .footer-btns { + display: flex; + gap: 8px; +} +.file-picker-footer .footer-btns button { + padding: 8px 20px; + border: none; + border-radius: 6px; + cursor: pointer; + font-size: 13px; + font-weight: bold; +} +.file-picker-footer .btn-confirm { + background: #e74c3c; + color: #fff; +} +.file-picker-footer .btn-confirm:hover { + background: #c0392b; +} +.file-picker-footer .btn-cancel { + background: #f0f0f0; + color: #666; +} + diff --git a/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/html/fileUpload.html b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/html/fileUpload.html new file mode 100644 index 0000000..bdbeeed --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/html/fileUpload.html @@ -0,0 +1,155 @@ + + + + + + 文件选择 + + + + + +
+ +
+ +
+ + + + diff --git a/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileRef.js b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileRef.js new file mode 100644 index 0000000..15453e4 --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileRef.js @@ -0,0 +1,253 @@ +(function (factory) { + var nameSpace = 'field_88661234567890123457'; + if (!window[nameSpace]) { + var Builder = factory(); + window[nameSpace] = { instance: {} }; + window[nameSpace].init = function (options) { + window[nameSpace].instance[options.privateId] = new Builder(options); + }; + } +})(function () { + function App(options) { + var self = this; + self.adaptation = options.adaptation; + self.privateId = options.privateId; + self.preUrl = options.url_prefix; + self.adaptation.formMessage = options.formMessage; + self.messageObj = options.getData; + self.folderId = ''; // 网盘文件夹ID,从弹框返回时更新 + self.initDom(); + self.events(); + } + App.prototype = { + initDom: function () { + var self = this; + self.appendChildDom(); + }, + + events: function () { + var self = this; + self.adaptation.ObserverEvent.listen('Event' + self.privateId, function () { + self.messageObj = self.adaptation.childrenGetData(self.privateId); + self.appendChildDom(); + }); + }, + + appendChildDom: function () { + var self = this; + const params = new URLSearchParams(window.location.search); + console.log(params) + const openFrom = params.get('openFrom'); // 返回"2025" + const type = params.get('type'); + console.log(openFrom) + console.log(type) + var edit = !((openFrom != null && (openFrom =='listPending' || openFrom =='listDone' || openFrom =='listSent'))||(type != null && type =='browse')); + console.log(edit) + var domStructure = '
' + + '
'+ + '
'+ + '' + + self.messageObj.display.escapeHTML() + + '
' + + '
' + +'
' + +'
' + + (edit ? '
' : '') + + '
' + + '
'; + document.querySelector('#' + self.privateId).innerHTML = domStructure; + var fileRef = function() { + self.redirectToNewPage(self.privateId, self.messageObj, self.adaptation) + } + var attachArea = document.querySelector('.cap4-attach__items' + '.' + self.privateId); + attachArea.innerHTML = ""; + if (self.messageObj.value) { + console.log(self.messageObj.value) + var values = JSON.parse(self.messageObj.value); + var outFileDiv = document.createElement('div'); + attachArea.appendChild(outFileDiv); + values.forEach(function(item) { + // 创建一个新的 div 来包含超链接和文件名 + var fileDiv = document.createElement('div'); + fileDiv.className = "cap4-attach__att1 not-custome-btn"; + // 创建超链接元素 + var fileRightDiv = document.createElement('div'); + fileRightDiv.className = "cap4-attach__att"; + var innerArea = '
' + +'
' + +'' + + ''+item.name+''+ (edit ? '' : '') + +'
' + fileRightDiv.innerHTML = innerArea; + fileDiv.appendChild(fileRightDiv); + outFileDiv.appendChild(fileDiv); + + }); + } + + var content = self.messageObj.formdata.content; + const picker = document.querySelector('.cap4-attach__picker' + '.' + self.privateId); + if(picker) { + document.querySelector('.cap4-attach__picker' + '.' + self.privateId).removeEventListener( + 'click', fileRef); + document.querySelector('.cap4-attach__picker' + '.' + self.privateId).addEventListener( + 'click', fileRef); + } + const goNewPages = document.querySelectorAll('.goToNewPage'); + if(goNewPages.length > 0){ + goNewPages.forEach(element => { + element.addEventListener('click', function(e) { + console.log(e.currentTarget.dataset.href) + window.open(e.currentTarget.dataset.href, '_blank'); // + }); + }); + } + const deleteList = document.querySelectorAll('.ico16.' + self.privateId); + if (deleteList.length > 0) { + deleteList.forEach(element => { + element.addEventListener('click', function (e) { + console.log("触发删除操作"); + + let current = e.target; + while (current && current !== document.documentElement) { + if ( + current.classList.contains('cap4-attach__att1') && + current.classList.contains('not-custome-btn') + ) { + console.log("开始清除"); + current.remove(); + break; + } + current = current.parentElement; + } + }); + }); + } + //渲染隐藏权限 + if (self.messageObj.auth === 'hide') { + document.querySelector('#' + self.privateId).innerHTML = + '
***
'; + } + }, + + /** 打开致远弹框 */ + redirectToNewPage: function (privateId, messageObj, adaptation) { + var self = this; + // 拼接folderId参数到弹框URL + var tableName = messageObj.formdata.alldata.tableInfo.formmain.tableName + var targetObj = messageObj.formdata.formmains[adaptation.formMessage.tableName]; + var oldValue = targetObj[privateId].showValue; + if (!targetObj) return; + var assetNo; + for (var key in targetObj) { + if (targetObj.hasOwnProperty(key) && !/^auxiliary/.test(key)) { + if (targetObj[key].display === "资产编号") { + assetNo = targetObj[key].showValue; + } + } + } + + var dialogUrl = self.preUrl + '/html/fileUpload.html?bizId=' + assetNo; + var dialog = $.dialog({ + id: 'fileRefDialog', + url: dialogUrl, + width: 1080, + height: 720, + title: '关联附件', + type: 'panel', + checkMax: true, + transParams: { oldValue: oldValue}, + closeParam: { show: false, autoClose: false, handler: function () {} }, + buttons: [{ + text: '确认', + handler: function () { + var result = dialog.getReturnValue(); + console.log(result) + if (result) { + try { + var data = JSON.parse(result); + var selected = data.files || []; + + if (selected.length > 0) { + // 合并到已有文件列表 + + messageObj = adaptation.childrenGetData(privateId); + saveFiles(selected, messageObj.id, messageObj.display, privateId,messageObj, adaptation,tableName); + } + } catch (e) { + console.error('解析返回值失败:', e); + } + } + dialog.close(); + } + }, { + text: '取消', + handler: function () { dialog.close(); } + }] + }); + }, + + + }; + /** 保存文件列表到表单 */ + function saveFiles(files, fieldName, fieldDisplay, privateId, messageObj, adaptation,tableName) { + var self = this; + var param = new Object(); + param.masterId = messageObj.formdata.content.contentDataId; + param.formId = messageObj.formdata.content.contentTemplateId; + param.fieldDisplay = fieldDisplay; + param.value = files; + param.isFile = 'true'; + $.ajax({ + type: "POST", + url: '/seeyon/rest/assetsRegion/formBackFill', + data: JSON.stringify(param), + dataType: "json", + contentType: 'application/json;charset=UTF-8', + success: function(res) { + // 后台解析数据后 将数据填写到表单中 + if (res.code == 0) { + var backfill = {}; + backfill.tableName = tableName; + // 回填主表 + backfill.tableCategory = 'formmain'; + // 后台组装的data数据 + console.log(res.data) + backfill.updateData = res.data; + adaptation.backfillFormControlData(backfill, privateId); + } else { + // 报错 + $.alert(res.message); + } + }, + complete: function() {}, + error: function(e) { + top.$.error(e.responseText); + } + }); + } + var dynamicLoading = { + css: function(path) { + if (!path || path.length === 0) { + throw new Error('argument "path" is required !'); + } + var head = document.getElementsByTagName('head')[0]; + var link = document.createElement('link'); + link.href = path; + link.rel = 'stylesheet'; + link.type = 'text/css'; + head.appendChild(link); + }, + js: function(path) { + if (!path || path.length === 0) { + throw new Error('argument "path" is required !'); + } + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.src = path; + script.type = 'text/javascript'; + head.appendChild(script); + } + } + return App; +}); diff --git a/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileUploadBiz.js b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileUploadBiz.js new file mode 100644 index 0000000..4b57f38 --- /dev/null +++ b/seeyon/apps_res/cap/customeCtrlResources/fileUploadResources/js/fileUploadBiz.js @@ -0,0 +1,329 @@ +$(document).ready(async function () { + var apiBase = window.location.origin + '/seeyon/rest/fileUpload'; + var rootFolders = []; + var activeFolder = null; + var currentFilePage = 1; + var filePageSize = 10; + var searchKeyword = null; + + // ========== 初始化:获取bizId → 获取folderId → 加载文件列表 ========== + try { + // 从URL参数或window对象获取bizId + var urlParams = new URLSearchParams(window.location.search); + var bizId = urlParams.get('bizId') || window._bizId || ''; + + // 缓存folderId + var cachedFolderId = ''; + + // 如果有bizId,调接口获取folderId + if (bizId) { + cachedFolderId = await fetchFolderIdByBizId(bizId) || ''; + } + // 如果没有通过bizId获取到,尝试用URL中的folderId + if (!cachedFolderId) { + cachedFolderId = urlParams.get('folderId') || ''; + } + + // 存储到全局变量供上传和OK()使用 + window._currentFolderId = cachedFolderId; + window._bizId = bizId; + window._uploadedFiles = []; // 缓存本次上传成功的文件信息 + + // 加载文件列表 + if (cachedFolderId) { + activeFolder = { id: cachedFolderId, name: '指定文件夹' }; + var files = await fetchFiles(cachedFolderId); + renderFileList(files); + } + } catch (e) { + console.error('初始化失败:', e); + $('#file-list').html('
加载文件夹失败
'); + } + + /** + * 通过业务ID调后端接口获取网盘文件夹ID + * @param {string} bizId - 业务ID(资产编号) + * @returns {Promise} folderId + */ + async function fetchFolderIdByBizId(bizId) { + if (!bizId) return null; + try { + var res = await $.ajax({ + url: apiBase + '/folder/by-bizid?bizId=' + encodeURIComponent(bizId), + type: 'GET', + dataType: 'json' + }); + if (res.code === 0 && res.data) { + var folderId = res.data.folderId || res.data.id || ''; + console.log('[fileUploadBiz] 获取folderId:', folderId, 'bizId:', bizId); + return folderId; + } + } catch (e) { + console.error('[fileUploadBiz] 获取folderId失败:', e); + } + return null; + } + + // ========== API 调用 ========== + + async function fetchFolders(folderId) { + var res = await $.ajax({ + url: apiBase + '/folder/children?folderId=' + folderId, + type: 'GET', + dataType: 'json' + }); + if (res.code === 0 && res.data) { + return res.data.folders || []; + } + return []; + } + + async function fetchFiles(folderId, pageNum, pageSize) { + var res = await $.ajax({ + url: apiBase + '/folder/children?folderId=' + folderId, + type: 'GET', + dataType: 'json' + }); + if (res.code === 0 && res.data) { + return res.data.files || []; + } + return []; + } + + async function searchFiles(keyword) { + var res = await $.ajax({ + url: apiBase + '/file/search?keyword=' + encodeURIComponent(keyword), + type: 'GET', + dataType: 'json' + }); + if (res.code === 0 && res.data) { + return Array.isArray(res.data) ? res.data : (res.data.files || []); + } + return []; + } + + // ========== 左侧文件夹树 ========== + + function renderSidebar() { + var sidebar = $('#sideBar'); + sidebar.empty(); + rootFolders.forEach(function (folder) { + var categoryEl = $( + '
' + + '
' + (folder.name || '文件夹') + '
' + + '
' + + '
' + ); + var folderList = categoryEl.find('.folder-list'); + categoryEl.find('.category-title').click(async function () { + if (!folder.loaded) { + var subFolders = await fetchFolders(folder.id); + subFolders.forEach(function (sub) { renderFolder(sub, folderList); }); + folder.loaded = true; + } + folderList.slideToggle(); + var icon = categoryEl.find('.icon'); + icon.text(icon.text() === '▶' ? '▼' : '▶'); + }); + sidebar.append(categoryEl); + }); + } + + function renderFolder(node, container) { + var subFolderList = $('
'); + var paginationControls = $('
'); + var page = 1; + var pageSize = 10; + var hasMore = true; + + var folderItem = $( + '
' + (node.name || '文件夹') + '
' + ); + + folderItem.click(async function (e) { + e.stopPropagation(); + activeFolder = node; + // 高亮当前选中文件夹 + $('.folder-item').removeClass('active'); + folderItem.addClass('active'); + subFolderList.toggle(); + + if (subFolderList.is(':visible') && !node.loaded) { + await loadSubFolderPage(); + node.loaded = true; + } + + // 加载文件列表 + var files = await fetchFiles(node.id); + renderFileList(files); + + var icon = folderItem.find('.icon'); + icon.text(icon.text() === '▶' ? '▼' : '▶'); + }); + + async function loadSubFolderPage() { + var subFolders = await fetchFolders(node.id); + subFolderList.empty(); + subFolders.forEach(function (sub) { renderFolder(sub, subFolderList); }); + hasMore = false; // 简化:不分页子文件夹 + renderFolderPagination(); + } + + function renderFolderPagination() { + paginationControls.empty(); + var prevBtn = $(''); + var nextBtn = $(''); + var pageInfo = $('第 ' + page + ' 页'); + prevBtn.prop('disabled', page === 1); + nextBtn.prop('disabled', !hasMore); + prevBtn.click(async function () { if (page > 1) { page--; await loadSubFolderPage(); } }); + nextBtn.click(async function () { if (hasMore) { page++; await loadSubFolderPage(); } }); + paginationControls.append(prevBtn, pageInfo, nextBtn); + subFolderList.append(paginationControls); + } + + container.append(folderItem); + container.append(subFolderList); + } + + // ========== 右侧文件列表 ========== + + function renderFileList(files) { + var container = $('#file-list'); + container.empty(); + if (!files || files.length === 0) { + container.html('
此文件夹为空
'); + return; + } + files.forEach(function (f) { + var ext = (f.extension || f.name.split('.').pop() || '').toUpperCase(); + var isImage = /^(JPG|JPEG|PNG|GIF|BMP|WEBP|SVG|ICO)$/.test(ext); + var isVideo = /^(MP4|AVI|MOV|WMV|FLV|MKV|WEBM)$/.test(ext); + var previewUrl = f.previewUrl || f.preview_url || f.downloadUrl || f.download_url || ''; + var thumbHtml = ''; + + if (isImage && previewUrl) { + thumbHtml = '
'; + } else if (isVideo) { + thumbHtml = '
' + ext.substring(0, 4) + '
'; + } else { + thumbHtml = '
' + ext.substring(0, 4) + '
'; + } + + var fileItem = $( + '
' + + '' + + thumbHtml + + '
' + + '
' + (f.name || '文件') + '
' + + '
' + formatSize(f.size) + '
' + + '
' + ); + // 点击整行切换勾选 + fileItem.click(function (e) { + if (e.target.type !== 'checkbox') { + var cb = $(this).find('input[type="checkbox"]'); + cb.prop('checked', !cb.prop('checked')); + } + $(this).toggleClass('selected', $(this).find('input[type="checkbox"]').prop('checked')); + }); + container.append(fileItem); + }); + } + + function formatSize(bytes) { + if (!bytes) return ''; + bytes = parseInt(bytes); + if (bytes < 1024) return bytes + ' B'; + if (bytes < 1048576) return (bytes / 1024).toFixed(1) + ' KB'; + if (bytes < 1073741824) return (bytes / 1048576).toFixed(1) + ' MB'; + return (bytes / 1073741824).toFixed(1) + ' GB'; + } + + // ========== 搜索 ========== + + $('#searchBtn').click(async function () { + searchKeyword = $('#search').val().trim(); + if (!searchKeyword) { + // 清空搜索,重新加载当前文件夹 + if (activeFolder) { + var files = await fetchFiles(activeFolder.id); + renderFileList(files); + } + return; + } + var files = await searchFiles(searchKeyword); + renderFileList(files); + }); + + $('#search').keyup(function (e) { + if (e.key === 'Enter') $('#searchBtn').click(); + }); + + // ========== 上传文件 ========== + + $('#uploadBtn').click(function () { + var input = document.createElement('input'); + input.type = 'file'; + input.multiple = true; + input.style.display = 'none'; + input.addEventListener('change', async function () { + var fileArr = Array.from(input.files); + if (fileArr.length === 0) return; + var folderId = window._currentFolderId || 0; + for (var i = 0; i < fileArr.length; i++) { + await uploadFile(fileArr[i], folderId); + } + // 上传完成后刷新文件列表(不刷新页面,保留缓存数据) + var files = await fetchFiles(folderId); + renderFileList(files); + // 自动勾选刚上传的文件 + window._uploadedFiles.forEach(function (uf) { + var cb = document.querySelector('#file-list input[data-filekey="' + uf.fileKey + '"]'); + if (cb && !cb.checked) { + cb.checked = true; + cb.closest('.file-item').classList.add('selected'); + } + }); + input.remove(); + }); + document.body.appendChild(input); + input.click(); + }); + + async function uploadFile(file, folderId) { + var formData = new FormData(); + formData.append('file', file); + formData.append('folderId', folderId || 0); + formData.append('fileName', file.name); + try { + var res = await $.ajax({ + url: apiBase + '/upload', + type: 'POST', + data: formData, + processData: false, + contentType: false + }); + if (res.code !== 0) { + alert('上传失败:' + (res.message || '未知错误')); + return false; + } + // 缓存上传成功的文件信息供OK()返回 + if (res.data) { + window._uploadedFiles.push({ + fileKey: res.data.id || '', + fileName: res.data.name || file.name + }); + } + return true; + } catch (e) { + alert('上传失败:网络错误'); + return false; + } + } +}); diff --git a/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/css/goMapBtn.css b/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/css/goMapBtn.css index e5c4ae0..a633877 100644 --- a/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/css/goMapBtn.css +++ b/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/css/goMapBtn.css @@ -1,5 +1,5 @@ .customButton_class_box { - width: 35%; + width: 100%; line-height: 24px; height:24px; color: #1f85ec; diff --git a/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/html/boundConfig.html b/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/html/boundConfig.html index 7acb593..b86850f 100644 --- a/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/html/boundConfig.html +++ b/seeyon/apps_res/cap/customeCtrlResources/goMapBtnResources/html/boundConfig.html @@ -126,22 +126,47 @@