|
|
@@ -1,22 +1,32 @@
|
|
|
-document.addEventListener('DOMContentLoaded', function() {
|
|
|
+document.addEventListener('DOMContentLoaded', function () {
|
|
|
// 模拟数据 - 实际应用中可能来自API
|
|
|
- const allOptions = Array.from({length: 100}, (_, i) => ({
|
|
|
- id: i + 1,
|
|
|
- name: `选项 ${i + 1}`,
|
|
|
- category: i % 5 === 0 ? '热门' : '常规'
|
|
|
- }));
|
|
|
-
|
|
|
- // 添加一些特殊选项
|
|
|
- allOptions.push(
|
|
|
- {id: 101, name: 'JavaScript', category: '技术'},
|
|
|
- {id: 102, name: 'Python', category: '技术'},
|
|
|
- {id: 103, name: 'Java', category: '技术'},
|
|
|
- {id: 104, name: 'React', category: '前端'},
|
|
|
- {id: 105, name: 'Vue', category: '前端'},
|
|
|
- {id: 106, name: 'Angular', category: '前端'},
|
|
|
- {id: 107, name: 'Node.js', category: '后端'},
|
|
|
- {id: 108, name: 'Express', category: '后端'}
|
|
|
- );
|
|
|
+ const allOptions = [];
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: "/silos/cms/books/info/queryPage",
|
|
|
+ type: "POST",
|
|
|
+ dataType: "json",
|
|
|
+ contentType: 'application/json;charset=UTF-8',
|
|
|
+ data: JSON.stringify({
|
|
|
+ contentsName: $("#bookInfoId").val(),
|
|
|
+ pageNo: 1,
|
|
|
+ pageRows: 10,
|
|
|
+ }),
|
|
|
+ success: function (res) {
|
|
|
+ const data = res.data.dataList;
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ let newObj = {
|
|
|
+ id: data[i].isbn,
|
|
|
+ name: data[i].title,
|
|
|
+ category: data[i].categoryCode
|
|
|
+ };
|
|
|
+ allOptions.push(newObj);
|
|
|
+ filteredOptions =allOptions;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (e) {
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
// DOM元素
|
|
|
const dropdownHeader = document.querySelector('.dropdown-header');
|
|
|
@@ -48,7 +58,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
nextBtn.addEventListener('click', goToNextPage);
|
|
|
|
|
|
// 点击外部关闭下拉框
|
|
|
- document.addEventListener('click', function(e) {
|
|
|
+ document.addEventListener('click', function (e) {
|
|
|
if (!dropdownHeader.contains(e.target) && !dropdownList.contains(e.target)) {
|
|
|
closeDropdown();
|
|
|
}
|
|
|
@@ -174,7 +184,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
|
// 添加移除标签事件监听
|
|
|
document.querySelectorAll('.remove-tag').forEach(btn => {
|
|
|
- btn.addEventListener('click', function(e) {
|
|
|
+ btn.addEventListener('click', function (e) {
|
|
|
e.stopPropagation();
|
|
|
const id = parseInt(this.getAttribute('data-id'));
|
|
|
removeOption(id);
|