Spinner Model Controls(三)

本文详细介绍了Swing组件中的JSpinner编辑器的使用方法与定制技巧,包括如何选择不同的编辑器类型(如DefaultEditor、DateEditor、ListEditor、NumberEditor)以及它们的属性设置,以实现对日期、列表、数值等不同类型数据的有效输入与显示。通过实例展示了如何灵活配置编辑器以适应特定需求。

14.4 JSpinner编辑器

对于每一个JSpinner可用的模型,都有一个附属支持的JSpinner内联类可用。在其中模型允许我们控制对于组件哪些可以选择,微调编辑器允许我们控制如何显示与编辑每一个可选中的值。

14.4.1 JSpinner.DefaultEditor类

JSpinner的setEditor()方法允许我们使得任意的JComponent作为JSpiner的编辑顺。虽然我们一定可以做到,但是更为通常的情况是,我们将会使用一个JSpinner.DefaultEditor的一个子类。他提供了当我们使用基于JFormattedTextField的简单编辑器时所需要的基本功能。他只有一个构造函数:

public JSpinner.DefaultEditor(JSpinner spinner)
JSpinner spinner = new JSpinner();
JComponent editor = JSpinner.DefaultEditor(spinner);
spinner.setEditor(editor);

如表14-6所示,编辑器有两个属性。


不知道我们正在使用的是哪一种模型类型,我们在这个级别上也许会做的就是修改JFormattedTextField的一些显示特点。然而更通常的情况是,我们将会修改模型编辑器的自定义方面。

14.4.2 JSpinner.DateEditor类

DateEditor允许我们使用java.text包的SimpleDateFormat类的各种方面来自定义日期显示。查看SimpleDateFormat的Javadoc可以了解可用的格式模型的完整列表。如果我们不喜欢默认的显示输出,我们可以通过向第二个构造函数传递一个新的格式来修改。

public JSpinner.DateEditor(JSpinner spinner)
SpinnerModel model = new SpinnerDateModel();
JSpinner spinner = new JSpinner(model);
JComponent editor = JSpinner.DateEditor(spinner);
spinner.setEditor(editor);
public JSpinner.DateEditor(JSpinner spinner, String dateFormatPattern)
SpinnerModel model = new SpinnerDateModel();
JSpinner spinner = new JSpinner(model);
JComponent editor = JSpinner.DateEditor(spinner, "MMMM yyyy");
spinner.setEditor(editor);

默认格式为M/d/yy h:mm a,或者对于2004年的圣诞节的某一时刻为12/25/04 12:34 PM。后一个示例将显示December 2004.

表14-7显示了编辑器的两个属性。


14.4.3 JSpinner.ListEditor类

当使用SpinnerListModel时,ListEditor并没有提供特殊的格式化支持。相反,他提供了类型支持。因为模型的所有条目都已知,编辑器尝试匹配用户已经输入的以这些条目中的一个开始的条目。他只有一个构造函数,但是我们绝不应访问这个函数。

public JSpinner.ListEditor(JSpinner spinner)

如表14-8所示,ListEditor只有一个属性。


14.4.4 JSpinner.NumberEditor类

NumberEditor的工作方式类似于DateEditor,允许我们输入字符串来自定义显示格式。与使用SimpleDateFormat不同,NumberEditor与java.text包中的DecimalFormat类相关联。类似于DateEditor,他有两个构造函数:

public JSpinner.NumberEditor(JSpinner spinner)
SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25);
JSpinner spinner = new JSpinner(model);
JComponent editor = JSpinner.NumberEditor(spinner);
spinner.setEditor(editor);
public JSpinner.NumberEditor(JSpinner spinner, String decimalFormatPattern)
SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25);
JSpinner spinner = new JSpinner(model);
JComponent editor = JSpinner.NumberEditor(spinner, "#,##0.###");
spinner.setEditor(editor);

第二个构造函数的使用显示了默认格式化字符串。如果数字足够大,则编辑器会尝试显示逗号,如果值是一个完整的数字,则他不会显示十进制。

如表14-9所示,编辑器有两个属性。


14.5 小结

在本章中,我们了解了Swing的JSpinner组件。当我们的选项集合限制为确定的值集合或是值范围,JSpinner允许我们通过在不同的选项之间进行微调来选择值。我们了解了如何提供选项集合:使用SpinnerDateModel与DateEditor选择日期集合,使用SpinnerListModel与ListEditor或是使用SpinnerNumberModel与NumberEditor。

第15章停止探讨由一个值范围内选择并且继承探讨用户在不同的文本组件中输入完整的内容。


以下mrprncrud.vue的style比照mrmncrud.vue,其餘功能不變: mrprncrud.vue: <div class="prncrud-container"> <div class="prncrud-controls"> <input v-model="searchQuery" placeholder="搜索處方名稱..." class="search-input" @input="filterPRNTags" /> </div> <div class="form-section"> <form @submit.prevent="createPRNTag" class="create-form"> <input v-model="newPRNTag.prnname" placeholder="輸入新處方名稱" required class="form-input" :disabled="isLoading" /> <button type="submit" class="form-btn create-btn" :disabled="isLoading">創建</button> </form> </div> <div class="prncrud-content"> <div v-if="isLoading" class="loading">加載中...</div> <div v-else> <div class="prncrud-list" v-if="filteredTags.length > 0"> <div v-for="tag in filteredTags" :key="tag.id" class="prncrud-item"> <div class="tag-info"> <span class="tag-id">ID: {{ tag.id }}</span> <span class="tag-name">{{ tag.prnname }}</span> </div> <div class="tag-actions"> <button @click="editPRNTag(tag)" class="action-btn edit-btn">編輯</button> <button @click="deletePRNTag(tag.id)" class="action-btn delete-btn">刪除</button> </div> </div> </div> <div v-else class="no-tags">沒有找到匹配的處方標籤</div> </div> </div> <div v-if="editingTag" class="edit-modal"> <div class="modal-content"> <h3>編輯處方名稱</h3> <form @submit.prevent="updatePRNTag"> <input v-model="editingTag.prnname" required class="form-input" :disabled="isLoading" /> <div class="modal-actions"> <button type="submit" class="form-btn save-btn">保存</button> <button type="button" @click="cancelEdit" class="form-btn cancel-btn">取消</button> </div> </form> </div> </div> </div> </template> <script> import { secureFetch } from '../utils/request'; export default { name: 'mrprncrud', emits: ['tag-updated'], data() { return { prnTags: [], filteredTags: [], searchQuery: '', newPRNTag: { prnname: '' }, editingTag: null, isLoading: false }; }, methods: { async fetchPRNTags() { this.isLoading = true; try { const response = await fetch('PRNTag/?format=json'); if (!response.ok) throw new Error('獲取數據失敗'); this.prnTags = await response.json(); this.filterPRNTags(); } catch (error) { console.error('獲取處方標籤失敗:', error); alert('加載數據失敗,請重試'); } finally { this.isLoading = false; } }, filterPRNTags() { const query = this.searchQuery.trim().toLowerCase(); this.filteredTags = query ? this.prnTags.filter(tag => tag.prnname.toLowerCase().includes(query) || tag.id.toString().includes(query) ) : [...this.prnTags]; }, async createPRNTag() { if (!this.newPRNTag.prnname.trim()) { alert('處方名稱不能為空'); return; } this.isLoading = true; try { const response = await secureFetch('PRNTag/?format=json', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.newPRNTag) }); if (!response.ok) throw new Error('創建失敗'); await this.fetchPRNTags(); this.newPRNTag.prnname = ''; this.$emit('tag-updated'); } catch (error) { console.error('創建處方標籤失敗:', error); alert(error.message); } finally { this.isLoading = false; } }, editPRNTag(tag) { this.editingTag = { ...tag }; }, async updatePRNTag() { if (!this.editingTag.prnname.trim()) { alert('處方名稱不能為空'); return; } this.isLoading = true; try { const response = await secureFetch(`PRNTag/${this.editingTag.id}/?format=json`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.editingTag) }); if (!response.ok) throw new Error('更新失敗'); await this.fetchPRNTags(); this.editingTag = null; this.$emit('tag-updated'); } catch (error) { console.error('更新處方標籤失敗:', error); alert(error.message); } finally { this.isLoading = false; } }, async deletePRNTag(id) { if (!confirm('確定要刪除這個處方標籤嗎?')) return; this.isLoading = true; try { const response = await secureFetch(`PRNTag/${id}/?format=json`, { method: 'DELETE' }); if (!response.ok) throw new Error('刪除失敗'); await this.fetchPRNTags(); this.$emit('tag-updated'); } catch (error) { console.error('刪除處方標籤失敗:', error); alert(error.message); } finally { this.isLoading = false; } }, cancelEdit() { this.editingTag = null; } }, mounted() { this.fetchPRNTags(); } }; </script> <style scoped> .prncrud-container { height: 100%; display: flex; flex-direction: column; } .prncrud-controls { padding: 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; } .search-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; } .prncrud-content { flex: 1; overflow-y: auto; padding: 10px; } .prncrud-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: white; border: 1px solid #eee; border-radius: 4px; margin-bottom: 5px; } .edit-btn { background-color: #2196F3; color: white; } .delete-btn { background-color: #f44336; color: white; } </style> mrmncrud.vue: <div class="mncrud-container"> <div class="mncrud-controls"> <input v-model="searchQuery" placeholder="搜索本草名稱..." class="search-input" @input="filterMNTags" /> </div> <!-- 创建表单 --> <div class="form-section"> <form @submit.prevent="createMNTag" class="create-form"> <input v-model="newMNTag.mnname" placeholder="輸入新本草名稱" required class="form-input" :disabled="isLoading" /> <button type="submit" class="form-btn create-btn" :disabled="isLoading">創建</button> </form> </div> <div class="mncrud-content"> <div v-if="isLoading" class="loading"> <div class="loading-spinner"></div> <span>加載中...</span> </div> <div v-else> <!-- 标签列表 --> <div class="mncrud-list" v-if="filteredTags.length > 0"> <div v-for="tag in filteredTags" :key="tag.id" class="mncrud-item"> <div class="tag-info"> <span class="tag-id">ID: {{ tag.id }}</span> <span class="tag-name">{{ tag.mnname }}</span> </div> <div class="tag-actions"> <button @click="editMNTag(tag)" class="action-btn edit-btn">編輯</button> <button @click="deleteMNTag(tag.id)" class="action-btn delete-btn">刪除</button> </div> </div> </div> <div v-else class="no-tags"> 沒有找到匹配的本草標籤 </div> </div> </div> <!-- 编辑模态框 --> <div v-if="editingTag" class="edit-modal"> <div class="modal-content"> <h3>編輯本草名稱</h3> <form @submit.prevent="updateMNTag"> <input v-model="editingTag.mnname" required class="form-input" :disabled="isLoading" /> <div class="modal-actions"> <button type="submit" class="form-btn save-btn">保存</button> <button type="button" @click="cancelEdit" class="form-btn cancel-btn">取消</button> </div> </form> </div> </div> </div> </template> <script> import { secureFetch } from '../utils/request'; export default { name: 'mrmncrud', data() { return { mnTags: [], filteredTags: [], searchQuery: '', newMNTag: { mnname: '' }, editingTag: null, isLoading: false }; }, methods: { async fetchMNTags() { this.isLoading = true; try { const response = await fetch('MNTag/?format=json'); if (!response.ok) throw new Error('获取数据失败'); this.mnTags = await response.json(); this.filterMNTags(); } catch (error) { console.error('获取本草标签失败:', error); alert('加载数据失败,请重试'); } finally { this.isLoading = false; } }, filterMNTags() { const query = this.searchQuery.trim().toLowerCase(); if (!query) { this.filteredTags = [...this.mnTags]; } else { this.filteredTags = this.mnTags.filter(tag => tag.mnname.toLowerCase().includes(query) || tag.id.toString().includes(query) ); } }, async createMNTag() { if (!this.newMNTag.mnname.trim()) { alert('本草名称不能为空'); return; } this.isLoading = true; try { const response = await secureFetch('MNTag/?format=json', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.newMNTag), }); if (!response.ok) throw new Error('创建失败'); await this.fetchMNTags(); this.newMNTag.mnname = ''; this.$emit('tag-updated'); } catch (error) { console.error('创建本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } }, editMNTag(tag) { this.editingTag = { ...tag }; }, async updateMNTag() { if (!this.editingTag.mnname.trim()) { alert('本草名称不能为空'); return; } this.isLoading = true; try { const response = await secureFetch(`MNTag/${this.editingTag.id}/?format=json`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.editingTag), }); if (!response.ok) throw new Error('更新失败'); await this.fetchMNTags(); this.editingTag = null; this.$emit('tag-updated'); } catch (error) { console.error('更新本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } }, cancelEdit() { this.editingTag = null; }, async deleteMNTag(id) { if (!confirm('确定要删除这个本草标签吗?')) return; this.isLoading = true; try { const response = await secureFetch(`MNTag/${id}/?format=json`, { method: 'DELETE' }); if (!response.ok) throw new Error('删除失败'); await this.fetchMNTags(); this.$emit('tag-updated'); } catch (error) { console.error('删除本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } } }, mounted() { this.fetchMNTags(); } }; </script> <style scoped> .mncrud-container { height: 100%; display: flex; flex-direction: column; } .mncrud-controls { padding: 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; } .search-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; } .mncrud-content { flex: 1; overflow-y: auto; padding: 10px; } .form-section { padding: 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; } .create-form { display: flex; gap: 10px; } .form-input { flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 4px; } .form-btn { padding: 8px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; } .create-btn { background-color: #4CAF50; color: white; } .mncrud-list { display: flex; flex-direction: column; gap: 10px; } .mncrud-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: white; border: 1px solid #eee; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } .tag-info { display: flex; flex-direction: column; } .tag-id { font-size: 0.8rem; color: #666; } .tag-name { font-weight: 500; } .tag-actions { display: flex; gap: 5px; } .action-btn { padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; } .edit-btn { background-color: #2196F3; color: white; } .delete-btn { background-color: #f44336; color: white; } .no-tags { padding: 20px; text-align: center; color: #666; font-style: italic; } .edit-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; } .modal-content { background: white; padding: 20px; border-radius: 8px; width: 90%; max-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); } .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; } .save-btn { background-color: #4CAF50; color: white; } .cancel-btn { background-color: #9E9E9E; color: white; } .loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; } .loading-spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-radius: 50%; border-top: 4px solid #3498db; width: 30px; height: 30px; animation: spin 1s linear infinite; margin-bottom: 10px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style>
最新发布
10-17
以上mrviewer.vue中的本草關聯功能以前述病態關聯功能為範例進行修改, mrmncrud.vue: <template> <div class="mncrud-container"> <div class="mncrud-controls"> <input v-model="searchQuery" placeholder="搜索本草名稱..." class="search-input" @input="filterMNTags" /> </div> <!-- 创建表单 --> <div class="form-section"> <form @submit.prevent="createMNTag" class="create-form"> <input v-model="newMNTag.mnname" placeholder="輸入新本草名稱" required class="form-input" :disabled="isLoading" /> <button type="submit" class="form-btn create-btn" :disabled="isLoading">創建</button> </form> </div> <div class="mncrud-content"> <div v-if="isLoading" class="loading"> <div class="loading-spinner"></div> <span>加載中...</span> </div> <div v-else> <!-- 标签列表 --> <div class="mncrud-list" v-if="filteredTags.length > 0"> <div v-for="tag in filteredTags" :key="tag.id" class="mncrud-item"> <div class="tag-info"> <span class="tag-id">ID: {{ tag.id }}</span> <span class="tag-name">{{ tag.mnname }}</span> </div> <div class="tag-actions"> <button @click="editMNTag(tag)" class="action-btn edit-btn">編輯</button> <button @click="deleteMNTag(tag.id)" class="action-btn delete-btn">刪除</button> </div> </div> </div> <div v-else class="no-tags"> 沒有找到匹配的本草標籤 </div> </div> </div> <!-- 编辑模态框 --> <div v-if="editingTag" class="edit-modal"> <div class="modal-content"> <h3>編輯本草名稱</h3> <form @submit.prevent="updateMNTag"> <input v-model="editingTag.mnname" required class="form-input" :disabled="isLoading" /> <div class="modal-actions"> <button type="submit" class="form-btn save-btn">保存</button> <button type="button" @click="cancelEdit" class="form-btn cancel-btn">取消</button> </div> </form> </div> </div> </div> </template> <script> export default { name: 'mrmncrud', data() { return { mnTags: [], filteredTags: [], searchQuery: '', newMNTag: { mnname: '' }, editingTag: null, isLoading: false }; }, methods: { async fetchMNTags() { this.isLoading = true; try { const response = await fetch('MNTag/?format=json'); if (!response.ok) throw new Error('获取数据失败'); this.mnTags = await response.json(); this.filterMNTags(); } catch (error) { console.error('获取本草标签失败:', error); alert('加载数据失败,请重试'); } finally { this.isLoading = false; } }, filterMNTags() { const query = this.searchQuery.trim().toLowerCase(); if (!query) { this.filteredTags = [...this.mnTags]; } else { this.filteredTags = this.mnTags.filter(tag => tag.mnname.toLowerCase().includes(query) || tag.id.toString().includes(query) ); } }, async createMNTag() { if (!this.newMNTag.mnname.trim()) { alert('本草名称不能为空'); return; } this.isLoading = true; try { const response = await fetch('MNTag/?format=json', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.newMNTag), }); if (!response.ok) throw new Error('创建失败'); await this.fetchMNTags(); this.newMNTag.mnname = ''; this.$emit('tag-updated'); } catch (error) { console.error('创建本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } }, editMNTag(tag) { this.editingTag = { ...tag }; }, async updateMNTag() { if (!this.editingTag.mnname.trim()) { alert('本草名称不能为空'); return; } this.isLoading = true; try { const response = await fetch(`MNTag/${this.editingTag.id}/?format=json`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.editingTag), }); if (!response.ok) throw new Error('更新失败'); await this.fetchMNTags(); this.editingTag = null; this.$emit('tag-updated'); } catch (error) { console.error('更新本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } }, cancelEdit() { this.editingTag = null; }, async deleteMNTag(id) { if (!confirm('确定要删除这个本草标签吗?')) return; this.isLoading = true; try { const response = await fetch(`MNTag/${id}/?format=json`, { method: 'DELETE' }); if (!response.ok) throw new Error('删除失败'); await this.fetchMNTags(); this.$emit('tag-updated'); } catch (error) { console.error('删除本草标签失败:', error); alert(error.message); } finally { this.isLoading = false; } } }, mounted() { this.fetchMNTags(); } }; </script> <style scoped> .mncrud-container { height: 100%; display: flex; flex-direction: column; } .mncrud-controls { padding: 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; } .search-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; } .mncrud-content { flex: 1; overflow-y: auto; padding: 10px; } .form-section { padding: 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; } .create-form { display: flex; gap: 10px; } .form-input { flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 4px; } .form-btn { padding: 8px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; } .create-btn { background-color: #4CAF50; color: white; } .mncrud-list { display: flex; flex-direction: column; gap: 10px; } .mncrud-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: white; border: 1px solid #eee; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } .tag-info { display: flex; flex-direction: column; } .tag-id { font-size: 0.8rem; color: #666; } .tag-name { font-weight: 500; } .tag-actions { display: flex; gap: 5px; } .action-btn { padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; } .edit-btn { background-color: #2196F3; color: white; } .delete-btn { background-color: #f44336; color: white; } .no-tags { padding: 20px; text-align: center; color: #666; font-style: italic; } .edit-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; } .modal-content { background: white; padding: 20px; border-radius: 8px; width: 90%; max-width: 400px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); } .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; } .save-btn { background-color: #4CAF50; color: white; } .cancel-btn { background-color: #9E9E9E; color: white; } .loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; } .loading-spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-radius: 50%; border-top: 4px solid #3498db; width: 30px; height: 30px; animation: spin 1s linear infinite; margin-bottom: 10px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style>
08-04
<!-- * @Description: 海淀智慧物业app- --> <template> <div class="economicdevelopment-page overflow_div page-background scoll_box dashboard-page"> <titlepage v-if="pathStr !== '/'" :title="pathName" :query="query"></titlepage> <!-- <div class="top_box" @click.stop="checkboxGroupShowFn">--> <!-- <div class="right_icon">--> <!-- <van-icon name="arrow-down" v-if="!checkboxGroupShow" />--> <!-- <van-icon name="arrow-up" v-if="checkboxGroupShow" />--> <!-- </div>--> <!-- 下拉多选查询 --> <!-- <p v-for="(item,i) of checkboxGroup" :key="i" @click.stop="deleteCheckbox(item)">--> <!-- <span>{{ item.name }}</span>--> <!-- <van-icon name="close" style="transform: scale(1.2);" />--> <!-- </p>--> <!-- <div v-if="checkboxGroup.length===0" class="placeholder">请选择小区</div>--> <!-- </div>--> <!-- 0805 增加查询项--> <div class="userLoginSearch"> <a-row :gutter="10"> <a-col :span="12"> <a-select show-search v-model="pane.szjz" :filterOption="filterOption" style="width: 100%" @change="handleStreetChange" placeholder="街镇"> <a-select-option :value="item.id" v-for="(item, i) in streetColumns" :key="i" :lable="item.departName"> {{ item.departName }} </a-select-option> </a-select> </a-col> <a-col :span="12"> <a-select show-search v-model="pane.sqmc" :filterOption="filterOption" style="width: 100%" @change="handleSQChange" placeholder="社区"> <a-select-option :value="item.id" v-for="(item, i) in townColumns" :key="i" :lable="item.departName"> {{ item.departName }} </a-select-option> </a-select> </a-col> </a-row> <a-row :gutter="10" style="margin-top: 10px;"> <a-col :span="12"> <a-input v-model="pane.xmmc" placeholder="项目名称"> <a-icon slot="suffix" type="search" style="color:#3b77b3;" /> </a-input> </a-col> <a-col :span="12" style="margin-top: 2px;"> <div class="checkboxContainer"> <span>专业化物业</span> <a-checkbox v-model="sfwzyhwyValue" @change="changeZyhwy" /> </div> </a-col> </a-row> <!-- 新增搜索与重置按钮 --> <div class="search-reset-btns" style="margin-top: 15px; display: flex; justify-content: space-between;"> <van-button type="info" block @click="reLoadData">搜索</van-button> <van-button type="default" block @click="handleReset">重置</van-button> </div> </div> <div class="tabBox"> <!-- <van-tabs v-model:active="activeName" color="#1989fa" @change="changeTab">--> <!-- <van-tab title="所有项目" name="0">--> <a-spin :spinning="spinning"> <div class="itemBox" v-for="(item, i) in listData" :key="i" @click="showDetail(item.id)"> <div class="contentBox"> <div class="imgBox"> <template v-if="item.imgUrl"> <van-image :src="item.imgUrl" width="50px" height="50px" style="border-radius: 5px;"> <template v-slot:loading> <van-loading type="spinner" size="20" /> </template> <template v-slot:error>加载失败</template> </van-image> </template> <template v-else> <div style=" width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: #f0f0f0; color: #999; font-size: 12px; " > 暂无图片 </div> </template> </div> <div class="msgBox"> <p>{{ item.xmmc ? item.xmmc : '' }}</p> <p>物业服务企业:{{ item.wyfwqy ? item.wyfwqy : '暂无企业' }}</p> <p> 更新时间: {{ item.updateTime ? item.updateTime : '暂无更新时间' }} </p> </div> <!-- <van-icon class="iconBox" name="edit" /> --> </div> <div class="typeBox" v-if="item.fwxz && item.fwxz.length > 0" :class="[ item.fwxz == 1 || item.fwxz == 2 || item.fwxz == 3 || item.fwxz == 4 || item.fwxz == 5 ? 'personalType' : 'publicType' ]" > <span v-for="(item1, i1) in item.fwxz" :key="i1"> <span v-if="item1 == 1">  商品住宅   </span> <span v-if="item1 == 2">  商住两用   </span> <span v-if="item1 == 3">  共有产权   </span> <span v-if="item1 == 4">  保障性住房(经适房、公租房等) )  </span> <span v-if="item1 == 5">  直管公房   </span> <span v-if="item1 == 6">  军产房   </span> <span v-if="item1 == 7">  供一业   </span> <span v-if="item1 == 8">  非经资产移交   </span> <span v-if="item1 == 9">  房改售房   </span> <span v-if="item1 == 10">  回迁安置房   </span> <span v-if="item1 == -99">  其他   </span> </span> </div> <!-- <div v-else></div> --> </div> <a-button class="moreBtn" @click="getprojectListMsg" :disabled="moreDisabled"> {{ moreText }} <van-icon name="arrow-down" /> </a-button> <!-- 增加一个空div 顶高度--> <div style="height: 100px;width:100%"></div> </a-spin> <!-- </van-tab>--> <!-- <van-tab title="小区列表" name="1">--> <!-- <div style="font-size: 14px">--> <!-- <div class="itemBox" v-for="(item, i) in tab2ListData" :key="i" @click="showDetail(item.id)">--> <!-- <div class="contentBox">--> <!-- <div class="imgBox">--> <!-- <!– <van-image src="" width="50px" height="50px">--> <!-- <template v-slot:loading>--> <!-- <van-loading type="spinner" size="20" />--> <!-- </template>--> <!-- </van-image> –>--> <!-- <template v-if="item.imgUrl">--> <!-- <van-image :src="item.imgUrl" width="50px" height="50px">--> <!-- <template v-slot:loading>--> <!-- <van-loading type="spinner" size="20" />--> <!-- </template>--> <!-- <template v-slot:error>加载失败</template>--> <!-- </van-image>--> <!-- </template>--> <!-- <template v-else>--> <!-- <div--> <!-- style="--> <!-- margin-top: 20px;--> <!-- width: 50px;--> <!-- height: 50px;--> <!-- display: flex;--> <!-- align-items: center;--> <!-- justify-content: center;--> <!-- background: #f0f0f0;--> <!-- color: #999;--> <!-- font-size: 12px;--> <!-- "--> <!-- >--> <!-- 暂无图片--> <!-- </div>--> <!-- </template>--> <!-- </div>--> <!-- <div class="msgBox">--> <!-- <p>{{ item.xmmc ? item.xmmc : '' }}</p>--> <!-- <p>物业服务企业:{{ item.wyfwqy ? item.wyfwqy : '暂无企业' }}</p>--> <!-- <p>--> <!-- 更新时间:--> <!-- {{ item.updateTime ? item.updateTime : '暂无更新时间' }}--> <!-- </p>--> <!-- </div>--> <!-- <!– <van-icon class="iconBox" name="edit" /> –>--> <!-- </div>--> <!-- <div--> <!-- class="typeBox"--> <!-- v-if="item.fwxz"--> <!-- :class="[--> <!-- item.fwxz == 1 || item.fwxz == 2 || item.fwxz == 3 || item.fwxz == 4 || item.fwxz == 5--> <!-- ? 'personalType'--> <!-- : 'publicType'--> <!-- ]"--> <!-- >--> <!-- <span v-for="(item1, i1) in item.fwxz" :key="i1">--> <!-- <span v-if="item1 == 1">  商品住宅   </span>--> <!-- <span v-if="item1 == 2">  商住两用   </span>--> <!-- <span v-if="item1 == 3">  共有产权   </span>--> <!-- <span v-if="item1 == 4">  保障性住房(经适房、公租房等) )  </span>--> <!-- <span v-if="item1 == 5">  直管公房   </span>--> <!-- <span v-if="item1 == 6">  军产房   </span>--> <!-- <span v-if="item1 == 7">  供一业   </span>--> <!-- <span v-if="item1 == 8">  非经资产移交   </span>--> <!-- <span v-if="item1 == 9">  房改售房   </span>--> <!-- <span v-if="item1 == 10">  回迁安置房   </span>--> <!-- <span v-if="item1 == -99">  其他   </span>--> <!-- </span>--> <!-- </div>--> <!-- <div v-else></div>--> <!-- </div>--> <!-- <a-button class="moreBtn" @click="getTab2List" :disabled="moreDisabled">--> <!-- {{ moreText }}--> <!-- <van-icon name="arrow-down" />--> <!-- </a-button>--> <!-- </div>--> <!-- </van-tab>--> <!-- </van-tabs>--> </div> <!-- <div class="container">--> <!-- <div v-for="(item,i) of notifyList" class="project_list_item">--> <!-- </div>--> <!-- </div>--> <!-- <div class="fixedBox"> 专题 <br />图层 </div> --> <!-- 顶部小区查询项弹框 --> <!-- <van-popup--> <!-- v-model="checkboxGroupShow"--> <!-- position="bottom"--> <!-- :style="{ height: '50%',zIndex:9999 }">--> <!-- <div class="my_checkbox_popup">--> <!-- <p class="cancel" @click="cancel(true)">取消</p>--> <!-- <p class="confirm" @click="comfirm">确认</p>--> <!-- </div>--> <!-- <van-checkbox-group v-model="checkboxGroupIds">--> <!-- <van-cell-group>--> <!-- <van-cell--> <!-- class="my_checkbox_popup_cell"--> <!-- v-for="(items, index) in dataOption"--> <!-- clickable--> <!-- :key="index"--> <!-- :title="items.name"--> <!-- @click="onSelect(items,index)">--> <!-- <template #right-icon>--> <!-- <van-checkbox :name="items.id" ref="CoverableCities" class="my_checkbox_popup_item" />--> <!-- </template>--> <!-- </van-cell>--> <!-- </van-cell-group>--> <!-- </van-checkbox-group>--> <!-- </van-popup>--> </div> </template> <script> import rolemixins from '@/utils/rolemixins'; import { managerListMsg, xioaquList } from '@/api/comm'; import { getSendRangeData } from '@/api/home'; import { getSqmcData } from '@/api/userState'; export default { name: 'projectList', components: {}, mixins: [rolemixins], data() { return { listData: [], tab2ListData: [], activeName: 'tab1', pathStr: this.$route.path, pathName: this.$route.meta.title ? this.$route.meta.title : '', query: {}, //分页 pane: { pageNo: 1, total: 0, pageSize: 10 }, sfwzyhwyValue: false, moreDisabled: false, moreText: '加载更多', streetColumns: [], townColumns: [], spinning: false, timer: null }; }, created() { }, activated() { }, beforeDestroy() { if (this.timer) { clearTimeout(this.timer); } }, mounted() { // this.initCheckboxGroup(); // this.getData(); this.getprojectListMsg(); this.getStreetData(); }, methods: { // 切换tab changeTab(tab) { this.activeName = tab; // this.getTab2List(); console.log('ffffff', tab); this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.pane.total = 0; this.listData = []; this.tab2ListData = []; if (tab == '0') { this.getprojectListMsg(); } else { this.getTab2List(); } }, // 获取数据列表接口 getData() { let params = { id: 1 }; }, // 获取所有项目 async getprojectListMsg() { this.spinning = true; const res = await managerListMsg(this.pane); if (res.success) { this.pane.total = res.result.total; this.listData = [...this.listData, ...res.result.records]; this.listData.forEach((item) => { if (item.fwxz && !Array.isArray(item.fwxz)) { item.fwxz = item.fwxz.split(','); } else { item.fwxz = item.fwxz || []; } }); this.$forceUpdate(); if (this.listData.length >= this.pane.total) { this.moreDisabled = true; this.moreText = '没有更多了'; } else { this.moreDisabled = false; this.moreText = '加载更多'; } } this.spinning = false; }, // 获取小区列表 getTab2List() { xioaquList(this.pane).then((res) => { this.pane.total = res.result.total; this.pane.pageNo = this.pane.pageNo + 1; if (res.code == 200) { if (res.result.records.length < this.pane.pageSize) { this.moreDisabled = true; this.moreText = '没有更多了'; this.tab2ListData = [...this.tab2ListData, ...res.result.records]; this.$forceUpdate(); } else { this.moreDisabled = false; this.moreText = '加载更多'; this.tab2ListData = [...this.tab2ListData, ...res.result.records]; this.$forceUpdate(); } } }); }, // 跳转项目信息详情 filterOption(inputValue, option) { return option.data.attrs.lable ? option.data.attrs.lable.includes(inputValue) : null; }, // 获取街镇数据以及社区数据 getStreetData() { getSendRangeData().then((res) => { this.streetColumns = res.result; }); }, // 获取社区数据 getTownData(val) { getSqmcData({ id: val }).then((res) => { this.townColumns = res.result; }); }, handleTownConfirm(val) { this.sqmcName = val.departName; this.pane.sqmc = val.id; this.townPicker = false; }, handleSearch() { console.log(this.pane); this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.listData = []; this.getprojectListMsg(); }, handleReset() { this.pane = { xmmc: '', szjz: undefined, sqmc: undefined, pageNo: 1, pageSize: 10, total: 0 }; this.moreDisabled = false; this.townColumns = []; this.moreDisabled = false this.moreText = '加载更多'; this.listData = []; this.$nextTick(() => { this.$forceUpdate }) this.getprojectListMsg(); }, showDetail(id) { this.$router.push({ path: '/listDetail', query: { id: id } }); }, changeZyhwy(e) { this.pane.sfwzyhwy = this.sfwzyhwyValue ? 1 : 0; this.reLoadData(); }, handleStreetChange(val) { // 清空社区 this.pane.sqmc = undefined; this.getTownData(val); // this.reLoadData(); }, handleSQChange(val) { this.pane.sqmc = val; // this.reLoadData(); }, reLoadData() { this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.listData = []; this.getprojectListMsg(); }, // changeXmmc(e) { // if (this.timer) { // clearTimeout(this.timer); // } // this.timer = setTimeout(() => { // this.moreDisabled = false; // this.moreText = '加载更多'; // this.listData = []; // // this.getprojectListMsg(); // }, 1000); // } // checkboxGroupShowFn() { // this.checkboxGroupShow = true; // } // initCheckboxGroup() { // this.checkboxGroupIds = []; // this.checkboxGroup = []; // }, // onSelect(items, index) { // this.$refs.CoverableCities[index].toggle(); // }, // comfirm() { // let text = []; // this.dataOption.map((its, i) => { // if (this.checkboxGroupIds.indexOf(its.id) !== -1) { // text.push(its); // } // }); // this.checkboxGroup = text; // this.$forceUpdate(); // this.cancel(false); // }, // cancel(flag) { // this.$forceUpdate(); // this.checkboxGroupShow = false; // if (flag) { // this.initCheckboxGroup(); // } // }, // deleteCheckbox(item) { // this.checkboxGroup.map((its, index) => { // if (item.id === its.id) { // this.checkboxGroup.splice(index, 1); // } // }); // this.checkboxGroupIds = this.checkboxGroup.map(its => { // return its.id; // }); // console.log(this.checkboxGroup, this.checkboxGroupIds, '----deleteCheckbox'); // } } }; </script> <style scoped lang="less"> @import '~@/assets/css/comm.less'; .economicdevelopment-page { height: 100%; .fixedBox { width: 80px; height: 80px; border-radius: 50%; box-shadow: 5px 5px 5px #ccc, -5px -5px 5px #ccc, 5px -5px 5px #ccc, -5px 5px 5px #ccc; position: absolute; bottom: 20px; right: 20px; background: #fff; font-size: 14px; text-align: center; display: flex; align-items: center; justify-content: center; } .top_box { width: auto; height: 40px; background: #fff; border: 1px solid #3b77b3; position: relative; display: flex; align-items: center; padding: 0 5px; margin: 0 10px; .right_icon { position: absolute; top: 5px; right: 10px; } p { padding: 5px 10px 20px 10px; height: 24px; background: rgba(59, 119, 179, 0.15); border-radius: 12px; border: 1px solid rgba(59, 119, 179, 0.5); color: #3b77b3; font-size: 12px; font-weight: 500; font-family: PingFangSC, PingFang SC; margin: 0 2px; span { display: inline-block; margin-right: 10px; } } div.placeholder { width: 100%; color: #d4d3d3; font-size: 16px; font-weight: normal; text-align: center; } } /deep/ .van-tabs__content { overflow-y: scroll; } .tabBox { width: auto; margin: 0 10px; margin-top: 5px; height: 88vh; overflow: hidden; overflow-y: scroll; .itemBox { width: 100%; //height: 80px; position: relative; font-size: 12px; padding: 10px; background: #fff; margin-bottom: 10px; display: flex; align-items: flex-end; margin-top: 5px; .contentBox { display: flex; justify-content: space-between; text-align: center; width: 100%; .iconBox { font-size: 26px; width: auto; height: 30px; line-height: 60px; } .msgBox { text-align: left; width: 200px; } .imgBox { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; } } .typeBox { position: absolute; height: 20px; line-height: 20px; top: 0; right: 10px; text-align: center; padding: 0 5px; max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .personalType { background: #e99d42; } .publicType { background: #a2ef4d; } } } //.container { // height: 100% !important; // padding: 0 12.5px; // //} } .my_checkbox_popup { width: 100%; height: 45px; line-height: 45px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; p { height: 100%; padding: 0 0.42667rem; font-size: 0.37333rem; background-color: transparent; border: none; cursor: pointer; } p.cancel { color: #969799; } p.confirm { color: #576b95; } } .my_checkbox_popup_cell { /deep/ .van-cell__title { padding: 8px 10px; } } .my_checkbox_popup_item { padding: 10px 15px; } .moreBtn { text-align: center; color: #1989fa; border: none; width: 100%; background: #fff; } .userLoginSearch { background-color: #fff; border-radius: 10px; padding: 10px; margin: 10px 0; .checkboxContainer { width: 100%; border-radius: 10px; border: 1px solid #3b77b3; font-size: 14px; padding: 0 8px; height: 32px; line-height: 32px; display: flex; align-items: center; justify-content: space-between; color: #3b77b3; } } .search-reset-btns { // background-color: #3c78b1; display: flex; gap: 10px; .van-button { background-color: #3c78b1; flex: 1; font-size: 14px; color: #ffffff; } } ::v-deep .ant-select-selection { border-color: #3b77b3; border-radius: 10px; color: #3b77b3; .ant-select-selection__placeholder { color: #3b77b3; } } ::v-deep .ant-input { border-color: #3b77b3; border-radius: 10px; padding-left: 8px; color: #3b77b3; &::placeholder { color: #3b77b3; } } </style> <template v-if="item.imgUrl"> <van-image :src="item.imgUrl" width="50px" height="50px" style="border-radius: 5px;"> <template v-slot:loading> <van-loading type="spinner" size="20" /> </template> <template v-slot:error>加载失败</template> </van-image> </template> <template v-else> <div style=" width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: #f0f0f0; color: #999; font-size: 12px; " > 暂无图片 </div> </template>这段代码现在是图片,换成视频,点击视频后可弹出并播放
08-08
<!-- * @Description: 海淀智慧物业app- --> <template> <div class="economicdevelopment-page overflow_div page-background scoll_box dashboard-page"> <titlepage v-if="pathStr !== '/'" :title="pathName" :query="query"></titlepage> <!-- <div class="top_box" @click.stop="checkboxGroupShowFn">--> <!-- <div class="right_icon">--> <!-- <van-icon name="arrow-down" v-if="!checkboxGroupShow" />--> <!-- <van-icon name="arrow-up" v-if="checkboxGroupShow" />--> <!-- </div>--> <!-- 下拉多选查询 --> <!-- <p v-for="(item,i) of checkboxGroup" :key="i" @click.stop="deleteCheckbox(item)">--> <!-- <span>{{ item.name }}</span>--> <!-- <van-icon name="close" style="transform: scale(1.2);" />--> <!-- </p>--> <!-- <div v-if="checkboxGroup.length===0" class="placeholder">请选择小区</div>--> <!-- </div>--> <!-- 0805 增加查询项--> <div class="userLoginSearch"> <a-row :gutter="10"> <a-col :span="12"> <a-select show-search v-model="pane.szjz" :filterOption="filterOption" style="width: 100%" @change="handleStreetChange" placeholder="街镇" > <a-select-option :value="item.id" v-for="(item, i) in streetColumns" :key="i" :lable="item.departName"> {{ item.departName }} </a-select-option> </a-select> </a-col> <a-col :span="12"> <a-select show-search v-model="pane.sqmc" :filterOption="filterOption" style="width: 100%" @change="handleSQChange" placeholder="社区" > <a-select-option :value="item.id" v-for="(item, i) in townColumns" :key="i" :lable="item.departName"> {{ item.departName }} </a-select-option> </a-select> </a-col> </a-row> <a-row :gutter="10"> <a-col :span="12"> <a-input v-model="pane.xmmc" placeholder="项目名称" @input="handleXmmcInput"> <a-icon slot="suffix" type="search" style="color: #3b77b3" /> </a-input> </a-col> <a-col :span="12" style="margin-top: 15px"> <div class="checkboxContainer"> <span>专业化物业</span> <a-checkbox v-model="sfwzyhwyValue" @change="changeZyhwy" /> </div> </a-col> </a-row> <!-- 新增搜索与重置按钮 --> <div class="search-reset-btns"> <van-button type="default" color="#3B77B3" block @click="reLoadData">搜索<van-icon style="margin-left: 10px;" name="search" /></van-button> <van-button type="default" block @click="handleReset" style="background: #f1f3f3; border-radius: 14px; border: 2px solid #3b77b380; color: #3b77b3;">重置<van-icon style="margin-left: 10px;" name="replay" /></van-button> </div> </div> <div class="tabBox"> <!-- <van-tabs v-model:active="activeName" color="#1989fa" @change="changeTab">--> <!-- <van-tab title="所有项目" name="0">--> <a-spin :spinning="spinning"> <div class="itemBox" v-for="(item, i) in listData" :key="i" @click="showDetail(item.id)"> <div class="contentBox"> <template> <div class="economicdevelopment-page overflow_div page-background scoll_box dashboard-page" style="width: 64px; height: 64px" > <!-- 其他页面内容 --> <div class="contentBox"> <!-- 左侧视频封面图,点击播放 --> <div @click.stop="openImage(item)" class="videoThumbnail"> <img v-if="item.sqImg" :src="item.sqImg.split(',')[0]" alt="" style="background-color: white" /> <img v-else src="@/assets/img/suolueErrorImg.png" alt="" style="background-color: white" /> <!-- <van-image :src="item.sqVideo" width="50px" height="50px" style="border-radius: 5px" > <template v-slot:loading> <van-loading type="spinner" size="20" /> </template> <template v-slot:error >加载失败</template> </van-image> --> </div> <!-- 项目信息 --> <div class="msgBox"> <p>{{ item.xmmc ? item.xmmc : '' }}</p> <p>物业服务企业:{{ item.wyfwqy ? item.wyfwqy : '暂无企业' }}</p> <p>更新时间: {{ item.updateTime ? item.updateTime : '暂无更新时间' }}</p> </div> </div> <!-- 其他页面内容 --> </div> </template> <!-- <div class="imgBox"> <template v-if="item.imgUrl"> <van-image :src="item.imgUrl" width="50px" height="50px" style="border-radius: 5px;"> <template v-slot:loading> <van-loading type="spinner" size="20" /> </template> <template v-slot:error>加载失败</template> </van-image> </template> <template v-else> <div style=" width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: #f0f0f0; color: #999; font-size: 12px; " > 暂无图片 </div> </template> </div> --> <div class="msgBox"> <p>{{ item.xmmc ? item.xmmc : '' }}</p> <p>物业服务企业:{{ item.wyfwqy ? item.wyfwqy : '暂无企业' }}</p> <p> 更新时间: {{ item.updateTime ? item.updateTime : '暂无更新时间' }} </p> </div> <!-- <van-icon class="iconBox" name="edit" /> --> </div> <div class="typeBox" v-if="item.fwxz && item.fwxz.length > 0" :class="[ item.fwxz == 1 || item.fwxz == 2 || item.fwxz == 3 || item.fwxz == 4 || item.fwxz == 5 ? 'personalType' : 'publicType' ]" > <span v-for="(item1, i1) in item.fwxz" :key="i1"> <span v-if="item1 == 1">  商品住宅   </span> <span v-if="item1 == 2">  商住两用   </span> <span v-if="item1 == 3">  共有产权   </span> <span v-if="item1 == 4">  保障性住房(经适房、公租房等) )  </span> <span v-if="item1 == 5">  直管公房   </span> <span v-if="item1 == 6">  军产房   </span> <span v-if="item1 == 7">  供一业   </span> <span v-if="item1 == 8">  非经资产移交   </span> <span v-if="item1 == 9">  房改售房   </span> <span v-if="item1 == 10">  回迁安置房   </span> <span v-if="item1 == -99">  其他   </span> </span> </div> <!-- <div v-else></div> --> </div> <a-button class="moreBtn" @click="getprojectListMsg" :disabled="moreDisabled"> {{ moreText }} <van-icon name="arrow-down" /> </a-button> <!-- 增加一个空div 顶高度--> <div style="height: 100px; width: 100%"></div> </a-spin> <!-- </van-tab>--> <!-- <van-tab title="小区列表" name="1">--> <!-- <div style="font-size: 14px">--> <!-- <div class="itemBox" v-for="(item, i) in tab2ListData" :key="i" @click="showDetail(item.id)">--> <!-- <div class="contentBox">--> <!-- <div class="imgBox">--> <!-- <!– <van-image src="" width="50px" height="50px">--> <!-- <template v-slot:loading>--> <!-- <van-loading type="spinner" size="20" />--> <!-- </template>--> <!-- </van-image> –>--> <!-- <template v-if="item.imgUrl">--> <!-- <van-image :src="item.imgUrl" width="50px" height="50px">--> <!-- <template v-slot:loading>--> <!-- <van-loading type="spinner" size="20" />--> <!-- </template>--> <!-- <template v-slot:error>加载失败</template>--> <!-- </van-image>--> <!-- </template>--> <!-- <template v-else>--> <!-- <div--> <!-- style="--> <!-- margin-top: 20px;--> <!-- width: 50px;--> <!-- height: 50px;--> <!-- display: flex;--> <!-- align-items: center;--> <!-- justify-content: center;--> <!-- background: #f0f0f0;--> <!-- color: #999;--> <!-- font-size: 12px;--> <!-- "--> <!-- >--> <!-- 暂无图片--> <!-- </div>--> <!-- </template>--> <!-- </div>--> <!-- <div class="msgBox">--> <!-- <p>{{ item.xmmc ? item.xmmc : '' }}</p>--> <!-- <p>物业服务企业:{{ item.wyfwqy ? item.wyfwqy : '暂无企业' }}</p>--> <!-- <p>--> <!-- 更新时间:--> <!-- {{ item.updateTime ? item.updateTime : '暂无更新时间' }}--> <!-- </p>--> <!-- </div>--> <!-- <!– <van-icon class="iconBox" name="edit" /> –>--> <!-- </div>--> <!-- <div--> <!-- class="typeBox"--> <!-- v-if="item.fwxz"--> <!-- :class="[--> <!-- item.fwxz == 1 || item.fwxz == 2 || item.fwxz == 3 || item.fwxz == 4 || item.fwxz == 5--> <!-- ? 'personalType'--> <!-- : 'publicType'--> <!-- ]"--> <!-- >--> <!-- <span v-for="(item1, i1) in item.fwxz" :key="i1">--> <!-- <span v-if="item1 == 1">  商品住宅   </span>--> <!-- <span v-if="item1 == 2">  商住两用   </span>--> <!-- <span v-if="item1 == 3">  共有产权   </span>--> <!-- <span v-if="item1 == 4">  保障性住房(经适房、公租房等) )  </span>--> <!-- <span v-if="item1 == 5">  直管公房   </span>--> <!-- <span v-if="item1 == 6">  军产房   </span>--> <!-- <span v-if="item1 == 7">  供一业   </span>--> <!-- <span v-if="item1 == 8">  非经资产移交   </span>--> <!-- <span v-if="item1 == 9">  房改售房   </span>--> <!-- <span v-if="item1 == 10">  回迁安置房   </span>--> <!-- <span v-if="item1 == -99">  其他   </span>--> <!-- </span>--> <!-- </div>--> <!-- <div v-else></div>--> <!-- </div>--> <!-- <a-button class="moreBtn" @click="getTab2List" :disabled="moreDisabled">--> <!-- {{ moreText }}--> <!-- <van-icon name="arrow-down" />--> <!-- </a-button>--> <!-- </div>--> <!-- </van-tab>--> <!-- </van-tabs>--> </div> <!-- 视频弹窗 --> <!-- <van-popup v-model:show="showVideoPopup" position="center" :style="{ width: '90%', maxHeight: '80%',backGround:'transparent' }" :closeable="true" @close.stop="closeVideo" > <div class="video-popup-content"> <video :src="currentVideoUrl" controls autoplay style="width: 100%; height: 100%; border-radius: 10px"></video> </div> </van-popup> --> <van-popup v-model:show="showImagePopup" position="center" :style="{ width: '90%', height: '80%' }" :closeable="true" @close="closeImage" > <div class="image-popup-content"> <img :src="currentImageUrls[currentIndex]" alt="查看大图" style="width: 100%; height: auto;" /> <div class="nav-buttons"> <van-button v-if="currentIndex > 0" @click="prevImage">上一张</van-button> <van-button v-if="currentIndex < currentImageUrls.length - 1" @click="nextImage">下一张</van-button> </div> </div> </van-popup> <!-- <div class="container">--> <!-- <div v-for="(item,i) of notifyList" class="project_list_item">--> <!-- </div>--> <!-- </div>--> <!-- <div class="fixedBox"> 专题 <br />图层 </div> --> <!-- 顶部小区查询项弹框 --> <!-- <van-popup--> <!-- v-model="checkboxGroupShow"--> <!-- position="bottom"--> <!-- :style="{ height: '50%',zIndex:9999 }">--> <!-- <div class="my_checkbox_popup">--> <!-- <p class="cancel" @click="cancel(true)">取消</p>--> <!-- <p class="confirm" @click="comfirm">确认</p>--> <!-- </div>--> <!-- <van-checkbox-group v-model="checkboxGroupIds">--> <!-- <van-cell-group>--> <!-- <van-cell--> <!-- class="my_checkbox_popup_cell"--> <!-- v-for="(items, index) in dataOption"--> <!-- clickable--> <!-- :key="index"--> <!-- :title="items.name"--> <!-- @click="onSelect(items,index)">--> <!-- <template #right-icon>--> <!-- <van-checkbox :name="items.id" ref="CoverableCities" class="my_checkbox_popup_item" />--> <!-- </template>--> <!-- </van-cell>--> <!-- </van-cell-group>--> <!-- </van-checkbox-group>--> <!-- </van-popup>--> </div> </template> <script> import rolemixins from '@/utils/rolemixins'; import { managerListMsg, xioaquList, xioaquVideoList } from '@/api/comm'; import { getSendRangeData } from '@/api/home'; import { getSqmcData } from '@/api/userState'; export default { name: 'projectList', components: {}, mixins: [rolemixins], data() { return { showVideoPopup: false, currentVideoUrl: null, showImagePopup: false, currentImageUrls: [], currentIndex: 0, listData: [], // 假设 listData 会从接口获取 // currentVideoUrl: 'https://www.w3schools.com/html/mov_bbb.mp4', // 一个测试视频地址 // listData: [ // { // id: 1, // xmmc: '项目A', // imgUrl: 'https://via.placeholder.com/50x50?text=Video+1', // hasVideo: true // 假设这个项目有视频 // }, // { // id: 2, // xmmc: '项目B', // imgUrl: '', // hasVideo: false // 假设这个项目没有视频 // }, // { // id: 3, // xmmc: '项目C', // imgUrl: 'https://via.placeholder.com/50x50?text=Video+2', // hasVideo: true // } // ], tab2ListData: [], activeName: 'tab1', pathStr: this.$route.path, pathName: this.$route.meta.title ? this.$route.meta.title : '', query: {}, //分页 pane: { pageNo: 1, total: 0, pageSize: 10, xmmc: '', // 项目名称 szjz: undefined, // 街镇 sqmc: undefined, // 社区 sfwzyhwy: 1 // 新增字段,1 表示专业化物业选中 }, sfwzyhwyValue: true, moreDisabled: false, moreText: '加载更多', streetColumns: [], townColumns: [], spinning: false, timer: null, }; }, created() {}, activated() {}, beforeDestroy() { if (this.timer) { clearTimeout(this.timer); } }, mounted() { // this.initCheckboxGroup(); // this.getData(); this.getprojectListMsg(); // 获取项目列表 this.getStreetData(); // 假装调用接口成功,使用假数据填充 listData // this.listData = [ // { // id: 1, // xmmc: '项目A', // imgUrl: 'https://via.placeholder.com/50x50?text=Video+1', // hasVideo: true // }, // { // id: 2, // xmmc: '项目B', // imgUrl: '', // hasVideo: false // }, // { // id: 3, // xmmc: '项目C', // imgUrl: 'https://via.placeholder.com/50x50?text=Video+2', // hasVideo: true // } // ]; }, methods: { // 获取单个项目的视频地址 async fetchVideoUrl(item) { try { const res = await xioaquVideoList({ id: item.id }); console.error('1111111==============>', { id: '1839890114125811716' }); // const res = await managerListMsg({ id: '1839890114125811716' }); console.log('接口返回:', res); // 打印调试 const data = res.data || {}; if (data.sqVideo && data.sqVideo.trim()) { item.videoUrl = data.sqVideo; } else { this.$toast('该条目无视频'); } } catch (error) { console.error('获取视频失败:', error); item.videoUrl = null; this.$toast('获取视频失败'); } }, // openVideo(item) { // if (item.sqVideo) { // this.currentVideoUrl = item.sqVideo; // this.showVideoPopup = true; // } else { // this.$toast('暂无视频'); // } // }, openImage(item) { if (item.sqImg) { this.currentImageUrls = item.sqImg.split(',').map(url => url.trim()).filter(url => url); this.currentIndex = 0; this.showImagePopup = true; } else { this.$toast('暂无图片'); } }, closeImage() { this.showImagePopup = false; this.currentImageUrls = []; this.currentIndex = 0; }, prevImage() { if (this.currentIndex > 0) { this.currentIndex--; } }, nextImage() { if (this.currentIndex < this.currentImageUrls.length - 1) { this.currentIndex++; } }, closeVideo() { this.currentVideoUrl = null; }, // 切换tab changeTab(tab) { this.activeName = tab; // this.getTab2List(); console.log('ffffff', tab); this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.pane.total = 0; this.listData = []; this.tab2ListData = []; if (tab == '0') { this.getprojectListMsg(); } else { this.getTab2List(); } }, // 获取数据列表接口 getData() { let params = { id: 1 }; }, // 获取所有项目 async getprojectListMsg() { this.spinning = true; const res = await managerListMsg(this.pane); if (res.success) { this.pane.total = res.result.total; this.listData = [...this.listData, ...res.result.records]; this.listData.forEach((item) => { if (item.fwxz && !Array.isArray(item.fwxz)) { item.fwxz = item.fwxz.split(','); } else { item.fwxz = item.fwxz || []; } }); this.$forceUpdate(); if (this.listData.length >= this.pane.total) { this.moreDisabled = true; this.moreText = '没有更多了'; } else { this.moreDisabled = false; this.moreText = '加载更多'; } this.pane.pageNo += 1; } this.spinning = false; }, // 获取小区列表 getTab2List() { xioaquList(this.pane).then((res) => { this.pane.total = res.result.total; this.pane.pageNo = this.pane.pageNo + 1; if (res.code == 200) { if (res.result.records.length < this.pane.pageSize) { this.moreDisabled = true; this.moreText = '没有更多了'; this.tab2ListData = [...this.tab2ListData, ...res.result.records]; this.$forceUpdate(); } else { this.moreDisabled = false; this.moreText = '加载更多'; this.tab2ListData = [...this.tab2ListData, ...res.result.records]; this.$forceUpdate(); } } }); }, // 跳转项目信息详情 filterOption(inputValue, option) { return option.data.attrs.lable ? option.data.attrs.lable.includes(inputValue) : null; }, handleXmmcInput(value) { // 延迟请求,避免频繁输入导致频繁搜索 if (this.searchTimer) { clearTimeout(this.searchTimer); } this.searchTimer = setTimeout(() => { this.pane.pageNo = 1; this.listData = []; this.getprojectListMsg(); // 重新加载数据 }, 500); }, // 获取街镇数据以及社区数据 getStreetData() { getSendRangeData().then((res) => { this.streetColumns = res.result; }); }, // 获取社区数据 getTownData(val) { getSqmcData({ id: val }).then((res) => { this.townColumns = res.result; }); }, handleTownConfirm(val) { this.sqmcName = val.departName; this.pane.sqmc = val.id; this.townPicker = false; }, handleSearch() { console.log(this.pane); this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.listData = []; this.getprojectListMsg(); }, handleReset() { this.pane = { xmmc: '', szjz: undefined, sqmc: undefined, pageNo: 1, pageSize: 10, total: 0 }; this.moreDisabled = false; this.townColumns = []; this.moreDisabled = false; this.moreText = '加载更多'; this.listData = []; this.$nextTick(() => { this.$forceUpdate; }); this.getprojectListMsg(); }, showDetail(id) { this.$router.push({ path: '/listDetail', query: { id: id } }); }, changeZyhwy(e) { this.pane.sfwzyhwy = this.sfwzyhwyValue ? 1 : 0; this.reLoadData(); }, handleStreetChange(val) { // 清空社区 this.pane.sqmc = undefined; this.getTownData(val); // this.reLoadData(); }, handleSQChange(val) { this.pane.sqmc = val; // this.reLoadData(); }, reLoadData() { this.pane.pageNo = 1; this.moreDisabled = false; this.moreText = '加载更多'; this.listData = []; this.getprojectListMsg(); } // changeXmmc(e) { // if (this.timer) { // clearTimeout(this.timer); // } // this.timer = setTimeout(() => { // this.moreDisabled = false; // this.moreText = '加载更多'; // this.listData = []; // // this.getprojectListMsg(); // }, 1000); // } // checkboxGroupShowFn() { // this.checkboxGroupShow = true; // } // initCheckboxGroup() { // this.checkboxGroupIds = []; // this.checkboxGroup = []; // }, // onSelect(items, index) { // this.$refs.CoverableCities[index].toggle(); // }, // comfirm() { // let text = []; // this.dataOption.map((its, i) => { // if (this.checkboxGroupIds.indexOf(its.id) !== -1) { // text.push(its); // } // }); // this.checkboxGroup = text; // this.$forceUpdate(); // this.cancel(false); // }, // cancel(flag) { // this.$forceUpdate(); // this.checkboxGroupShow = false; // if (flag) { // this.initCheckboxGroup(); // } // }, // deleteCheckbox(item) { // this.checkboxGroup.map((its, index) => { // if (item.id === its.id) { // this.checkboxGroup.splice(index, 1); // } // }); // this.checkboxGroupIds = this.checkboxGroup.map(its => { // return its.id; // }); // console.log(this.checkboxGroup, this.checkboxGroupIds, '----deleteCheckbox'); // } } }; </script> <style scoped lang="less"> @import '~@/assets/css/comm.less'; ::v-deep .van-popup{ background-color: transparent !important; } .videoError { width: 50px; height: 50px; } .economicdevelopment-page { height: 100%; .fixedBox { width: 80px; height: 80px; border-radius: 50%; box-shadow: 5px 5px 5px #ccc, -5px -5px 5px #ccc, 5px -5px 5px #ccc, -5px 5px 5px #ccc; position: absolute; bottom: 20px; right: 20px; background: #fff; font-size: 14px; text-align: center; display: flex; align-items: center; justify-content: center; } .top_box { width: auto; height: 40px; background: #fff; border: 1px solid #3b77b3; position: relative; display: flex; align-items: center; padding: 0 5px; margin: 0 10px; .right_icon { position: absolute; top: 5px; right: 10px; } p { padding: 5px 10px 20px 10px; height: 24px; background: rgba(59, 119, 179, 0.15); border-radius: 12px; border: 1px solid rgba(59, 119, 179, 0.5); color: #3b77b3; font-size: 12px; font-weight: 500; font-family: PingFangSC, PingFang SC; margin: 0 2px; span { display: inline-block; margin-right: 10px; } } div.placeholder { width: 100%; color: #d4d3d3; font-size: 16px; font-weight: normal; text-align: center; } } /deep/ .van-tabs__content { overflow-y: scroll; } .tabBox { width: auto; margin: 0 10px; margin-top: 5px; height: 65vh; overflow: hidden; overflow-y: scroll; .itemBox { width: 100%; //height: 80px; position: relative; font-size: 12px; padding: 20px 0px 15px 0px; background: #fff; margin-bottom: 10px; display: flex; align-items: flex-end; margin-top: 5px; .contentBox { display: flex; justify-content: space-around; text-align: center; width: 100%; .video-popup-content { // padding: 10px; background: #000; } .iconBox { font-size: 26px; width: auto; height: 30px; line-height: 60px; } .msgBox { text-align: left; width: 200px; } .imgBox { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; } } .typeBox { border-top-right-radius: 15px; border-bottom-left-radius: 15px; position: absolute; height: 20px; line-height: 20px; top: 0; right: 10px; text-align: center; padding: 0 5px; max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .personalType { background: #e99d42; } .publicType { background: #a2ef4d; } } } //.container { // height: 100% !important; // padding: 0 12.5px; // //} } .my_checkbox_popup { width: 100%; height: 45px; line-height: 45px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; p { height: 100%; padding: 0 0.42667rem; font-size: 0.37333rem; background-color: transparent; border: none; cursor: pointer; } p.cancel { color: #969799; } p.confirm { color: #576b95; } } .my_checkbox_popup_cell { /deep/ .van-cell__title { padding: 8px 10px; } } .my_checkbox_popup_item { padding: 10px 15px; } .moreBtn { text-align: center; color: #1989fa; border: none; width: 100%; background: #f1f3f3; } .userLoginSearch { // background-color: #fff; border-radius: 10px; padding: 10px; margin: 10px 0; .checkboxContainer { background-color: #f1f3f3; width: 100%; border-radius: 10px; border: 1px solid #3b77b3; font-size: 14px; padding: 0 8px; height: 32px; line-height: 32px; display: flex; align-items: center; justify-content: space-between; color: #3b77b3; } } .search-reset-btns { width: 100%; margin-top: 15px; justify-content: space-between; // background-color: #3c78b1; display: flex; gap: 10px; .van-button { border-radius: 14px; height: 36.69px; // background-color: transparent; flex: 1; font-size: 14px; color: #f1f3f3; img{ width: 20px; height: 20px; margin-left: 11px; } } } ::v-deep .ant-select-selection { border-color: #3b77b3; border-radius: 10px; color: #3b77b3; .ant-select-selection__placeholder { color: #3b77b3; } } ::v-deep .ant-input { border-color: #3b77b3; border-radius: 10px; padding-left: 8px; color: #3b77b3; &::placeholder { color: #3b77b3; } } </style> 为啥前面的图片有是img图片,出现了一个p标签,里面有字体内容
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值