Explorar el Código

fleat: relationship

igb hace 1 semana
padre
commit
b4476d0d41
Se han modificado 1 ficheros con 21 adiciones y 6 borrados
  1. 21 6
      relationshipAdd.php

+ 21 - 6
relationshipAdd.php

@@ -103,6 +103,16 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) {
         .selected-customer-info:hover {
             background-color: #f0f0f0;
         }
+        .customer-clear-btn {
+            margin-left: 5px;
+            color: #e74c3c;
+            font-weight: bold;
+            cursor: pointer;
+            float: right;
+        }
+        .customer-clear-btn:hover {
+            color: #c0392b;
+        }
     </style>
     <script>
         $(document).ready(function() {
@@ -202,7 +212,7 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) {
                 // 设置选中的客户ID和名称
                 $('#' + searchType + '_customer_id').val(customerId);
                 $('#' + searchType + '_customer_search').hide();
-                $('#' + searchType + '_customer_selected').text(displayText).show();
+                $('#' + searchType + '_customer_selected').text(displayText).append('<span class="customer-clear-btn" data-type="' + searchType + '">X</span>').show();
                 $('#' + searchType + '_customer_company').val(customerName);
                 
                 // 添加标题属性,便于查看完整信息
@@ -214,12 +224,17 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) {
             
             // 点击已选客户可以重新选择
             $(document).on('click', '.selected-customer-info', function() {
-                var $this = $(this);
-                var searchType = $this.attr('id').replace('_customer_selected', '');
+                // 点击整个已选区域不再执行任何操作
+            });
+            
+            // 点击X按钮清除选择的客户
+            $(document).on('click', '.customer-clear-btn', function(e) {
+                e.stopPropagation();
+                var searchType = $(this).data('type');
                 
                 // 显示搜索框,隐藏已选信息
                 $('#' + searchType + '_customer_search').val('').show();
-                $this.hide();
+                $('#' + searchType + '_customer_selected').hide();
                 
                 // 清空客户ID
                 $('#' + searchType + '_customer_id').val('');
@@ -322,7 +337,7 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) {
                                     echo textDecode($displayText);
                                 }
                             }
-                            ?></div>
+                            ?><span class="customer-clear-btn" data-type="source">X</span></div>
                             <div id="source_customer_dropdown" class="customer-dropdown"></div>
                         </div>
                         <input type="hidden" id="source_customer_id" name="source_customer_id" value="<?= $isEdit ? $relationshipData['source_customer_id'] : '' ?>" />
@@ -364,7 +379,7 @@ if (isset($_GET['id']) && is_numeric($_GET['id'])) {
                                     echo textDecode($displayText);
                                 }
                             }
-                            ?></div>
+                            ?><span class="customer-clear-btn" data-type="target">X</span></div>
                             <div id="target_customer_dropdown" class="customer-dropdown"></div>
                         </div>
                         <input type="hidden" id="target_customer_id" name="target_customer_id" value="<?= $isEdit ? $relationshipData['target_customer_id'] : '' ?>" />