From a869d02d89dd34ca325fb03bff64fc9b3dafd17d Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期六, 17 一月 2026 16:18:48 +0800
Subject: [PATCH] ai事件、智能抓拍添加公司和库区联动处理

---
 fzzy-igdss-web/src/main/resources/static/security/snap/snapRecord.js |  226 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 190 insertions(+), 36 deletions(-)

diff --git a/fzzy-igdss-web/src/main/resources/static/security/snap/snapRecord.js b/fzzy-igdss-web/src/main/resources/static/security/snap/snapRecord.js
index 354e850..25cf58b 100644
--- a/fzzy-igdss-web/src/main/resources/static/security/snap/snapRecord.js
+++ b/fzzy-igdss-web/src/main/resources/static/security/snap/snapRecord.js
@@ -1,6 +1,40 @@
 var layer;
 var laypage;
 
+// 鐩戝惉鏀跺偍鍏徃 Select2 鍙樺寲
+$(document).ready(function() {
+    // 鐩戝惉鏀跺偍鍏徃涓嬫媺妗嗗彉鍖�
+    $('select[name="key"]').on('change', function() {
+        var selectedParentId = $(this).val();
+        if(selectedParentId) {
+            getSelectData(selectedParentId);
+        } else {
+            // 濡傛灉娓呯┖浜嗘敹鍌ㄥ叕鍙搁�夋嫨锛屼篃娓呯┖搴撳尯閫夐」
+            var $deptSelect = $('select[name="deptId"]');
+            $deptSelect.empty()
+                .append('<option value="">鎵�鏈�</option>')
+                .select2({
+                    placeholder: "璇烽�夋嫨搴撳尯",
+                    allowClear: true,
+                    width: 'resolve'
+                });
+        }
+    });
+
+    // 鍦ㄧ偣鍑诲簱鍖轰笅鎷夋鏃讹紝浠呴獙璇佽�屼笉鍙戣捣鏂拌姹�
+    $('select[name="deptId"]').on('select2:opening', function(e) {
+        var selectedParentId = $('select[name="key"]').val();
+        if(!selectedParentId) {
+            e.preventDefault();
+            layer.msg('璇峰厛閫夋嫨鏀跺偍鍏徃');
+            return false;
+        }
+
+        // 涓嶅湪姝ゅ鍙戣捣璇锋眰锛屼緷璧� change 浜嬩欢鏃剁殑棰勫姞杞�
+        return true;
+    });
+});
+
 $(function () {
     // 鍒濆鍖栧垎椤�
     layui.use(['laypage', 'layer'], function () {
@@ -15,6 +49,67 @@
     initImagePreview();
 });
 
+
+// 淇敼 getSelectData 鍑芥暟锛屾敮鎸� Select2 鐨勬暟鎹牸寮�
+function getSelectData(parentId) {
+    if(!parentId) {
+        return layer.msg('璇烽�夋嫨鏀跺偍鍏徃');
+    }
+
+    $.ajax({
+        url: "../../system/dept-new/getDeptByUserType",
+        type: 'POST',
+        dataType: "json",
+        contentType: "application/json;charset=UTF-8",
+        data: parentId,
+        success: function (response) {
+            if (response) {
+                deptList = response;
+                // 閲嶆柊鍒濆鍖� Select2 鎴栨洿鏂伴�夐」
+                updateDeptSelect2Options(deptList);
+            } else {
+                layer.msg(response.msg || '鏁版嵁鍔犺浇澶辫触');
+            }
+        },
+        error: function (xhr, status, error) {
+            layer.msg('鏁版嵁鍔犺浇澶辫触');
+        }
+    });
+}
+
+// 鏇存柊 Select2 涓嬫媺妗嗛�夐」
+function updateDeptSelect2Options(deptList) {
+    var $deptSelect = $('select[name="deptId"]');
+
+    // 淇濆瓨褰撳墠閫変腑鐨勫��
+    var currentVal = $deptSelect.val();
+
+    // 娓呯┖鐜版湁閫夐」
+    $deptSelect.empty();
+
+    // 娣诲姞"鎵�鏈�"閫夐」
+    $deptSelect.append('<option value="">鎵�鏈�</option>');
+
+    // 娣诲姞鍔ㄦ�佹暟鎹�夐」
+    if(deptList && deptList.length > 0) {
+        deptList.forEach(function(dept) {
+            $deptSelect.append('<option value="' + dept.id + '">' + dept.kqmc + '</option>');
+        });
+    }
+
+    // 閲嶆柊鍒濆鍖� Select2
+    $deptSelect.select2({
+        placeholder: "璇烽�夋嫨搴撳尯",
+        allowClear: true,
+        width: 'resolve'
+    });
+
+    // 鎭㈠涔嬪墠鐨勯�夋嫨
+    if(currentVal) {
+        $deptSelect.val(currentVal).trigger('change');
+    }
+}
+
 /**
  * 鍒濆鍖栧垎椤电粍浠�
  */
@@ -24,7 +119,9 @@
         count: typeof totalItems !== 'undefined' ? totalItems : 0,
         limit: typeof pageSize !== 'undefined' ? pageSize : 6,
         curr: typeof currentPage !== 'undefined' ? currentPage : 1,
-        layout: ['count', 'prev', 'page', 'next', 'refresh', 'skip'],
+        layout: ['prev', 'page', 'next', ],
+        // prev: '<i class="layui-icon layui-icon-left"></i>',
+        // next: '<i class="layui-icon layui-icon-right"></i>',
         jump: function (obj, first) {
             if (!first) {
                 searchRecord(obj.curr, obj.limit)
@@ -45,7 +142,9 @@
         count: totalCount,
         limit: pageSize,
         curr: currentPage,
-        layout: ['count', 'prev', 'page', 'next', 'refresh', 'skip'],
+        layout: ['prev', 'page', 'next', ],
+        // prev: '<i class="layui-icon layui-icon-left"></i>',
+        // next: '<i class="layui-icon layui-icon-right"></i>',
         jump: function (obj, first) {
             if (!first) {
                 searchRecord(obj.curr, obj.limit)
@@ -94,7 +193,8 @@
     // 娣诲姞琛ㄥ崟鏌ヨ鏉′欢
     var form = document.getElementById('snapRecord-form');
     if (form) {
-        var inputs = form.querySelectorAll('input[name], select[name]');
+        // 澶勭悊鏅�氳緭鍏ユ鍜岄�夋嫨妗�
+        var inputs = form.querySelectorAll('input[name]:not([type="hidden"]), select[name]');
         inputs.forEach(function(input) {
             if (input.value) { // 鍙坊鍔犻潪绌哄��
                 params[input.name] = input.value;
@@ -136,42 +236,95 @@
     // 鐢熸垚鍥剧墖鍗$墖
     var html = '';
     records.forEach(function(record) {
+        //鏍囩灞曠ず
+        var tagsHtml = '';
+        if (record.tags) {
+            var tags = record.tags.split(',');
+            tags.forEach(function(tag) {
+                tagsHtml += `
+            <span class="tag-person">
+                <i class="layui-icon layui-icon-note"></i>
+                <span>${tag.trim()}</span>
+            </span>
+        `;
+            });
+        }
+
         html += `
-            <div class="gallery-item">
-                <img  src="${record.imgName || '/logo-sm.png'}" alt="${record.id}"
-                     data-url="${record.imgName || '/logo-sm.png'}" data-id="${record.id}"
-                     class="gallery-img" onclick="showSnapRecordPreview(this.getAttribute('data-url'))">
-                <div class="gallery-info">
-                    <div class="gallery-header">
-                        <h3 class="gallery-title">${record.id}</h3>
-                    </div>
-                    <div class="gallery-meta">
-                        <div class="meta-item">
-                            <i class="layui-icon layui-icon-home"></i>
-                            <span>${record.deptId || ''}</span>
-                        </div>
-                        <div class="meta-item">
-                            <i class="layui-icon layui-icon-video"></i>
-                            <span>${record.cameraId || ''}</span>
-                        </div>
-                        <div class="meta-item">
-                            <i class="layui-icon layui-icon-date"></i>
-                            <span>${formatDate(record.snapTime)}</span>
-                        </div>
-                    </div>
-                    <div class="gallery-tags">
-                        <span class="tag-person">
-                            <i class="layui-icon layui-icon-face-smile"></i>
-                            <span>娴嬭瘯鏍囩</span>
-                        </span>
-                    </div>
+    <div class="gallery-item">
+        <img  src="${record.imgName || '/logo-sm.png'}" alt="${record.id}"
+             data-url="${record.imgName || '/logo-sm.png'}" data-id="${record.id}"
+             class="gallery-img" onclick="showSnapRecordPreview(this.getAttribute('data-url'))">
+        <div class="gallery-info">
+            <div class="gallery-header">
+                <div class="gallery-tags">
+                    ${tagsHtml}
                 </div>
             </div>
-        `;
+            <div class="gallery-meta">
+                 <div style="display: flex; align-items: center; gap: 15px;width: 100%">
+                     <div class="meta-item" style="width: 50%">
+                        <i class="layui-icon layui-icon-video"></i>
+                        <span>${getCameraName(record.cameraId) || record.cameraId || ''}</span>
+                    </div>
+                    <div class="meta-item" style="width: 50%">
+                        <i class="layui-icon layui-icon-date"></i>
+                        <span>${formatDate(record.snapTime)}</span>
+                    </div>
+                 </div>
+              
+                 <div class="meta-item">
+                    <i class="layui-icon layui-icon-home"></i>
+                    <span>${getDeptName(record.deptId) || record.deptId || ''}</span>
+                 </div>  
+                                   
+            </div>        
+        </div>
+    </div>
+`;
+
     });
 
     container.innerHTML = html;
 }
+
+
+/**
+ * 鏍规嵁鎽勫儚澶碔D鑾峰彇鎽勫儚澶村悕绉�
+ * @param {string} cameraId - 鎽勫儚澶碔D
+ * @returns {string|null} 鎽勫儚澶村悕绉版垨null
+ */
+function getCameraName(cameraId) {
+    // 纭繚cameraList瀛樺湪涓斾负鏁扮粍
+    if (typeof cameraList !== 'undefined' && Array.isArray(cameraList) && cameraId) {
+        // 鏌ユ壘鍖归厤鐨勬憚鍍忓ご瀵硅薄
+        var camera = cameraList.find(function(item) {
+            return item.id === cameraId;
+        });
+        // 杩斿洖鎽勫儚澶村悕绉帮紝濡傛灉鎵句笉鍒板垯杩斿洖null
+        return camera ? camera.name : null;
+    }
+    return null;
+}
+
+/**
+ * 鏍规嵁搴撳尯ID鑾峰彇搴撳尯鍚嶇О
+ * @param {string} deptId - 鎽勫儚澶碔D
+ * @returns {string|null} 鎽勫儚澶村悕绉版垨null
+ */
+function getDeptName(deptId) {
+    // 纭繚deptList瀛樺湪涓斾负鏁扮粍
+    if (typeof deptList !== 'undefined' && Array.isArray(deptList) && deptId) {
+        // 鏌ユ壘鍖归厤鐨勬憚鍍忓ご瀵硅薄
+        var dept = deptList.find(function(item) {
+            return item.id === deptId;
+        });
+        // 杩斿洖鎽勫儚澶村悕绉帮紝濡傛灉鎵句笉鍒板垯杩斿洖null
+        return dept ? dept.kqmc : null;
+    }
+    return null;
+}
+
 
 /**
  * 鏍煎紡鍖栨棩鏈�
@@ -184,8 +337,9 @@
         String(d.getMonth() + 1).padStart(2, '0') + '-' +
         String(d.getDate()).padStart(2, '0') + ' ' +
         String(d.getHours()).padStart(2, '0') + ':' +
-        String(d.getMinutes()).padStart(2, '0') + ':' +
-        String(d.getSeconds()).padStart(2, '0');
+        String(d.getMinutes()).padStart(2, '0')
+        // + ':' +
+        // String(d.getSeconds()).padStart(2, '0');
 }
 
 /**
@@ -277,6 +431,6 @@
     });
 }
 function openConf() {
-    var url = ctx + "com.fzzy.igds.SnapConf.d";
-    $.modal.openTab("鎶撴媿閰嶇疆", url);
+    var url = ctx + "com.fzzy.igds.ConfByDept.d";
+    $.modal.openTab("搴撳尯閰嶇疆", url);
 }

--
Gitblit v1.9.3