myBusi.js
5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// 商机信息页面 Vue 应用
const utils = new publicMethod()
new Vue({
el: '#app',
data: {
isWorker: true,
detail: {
records: []
},
searchKeyword: '',
activeTab: 'all',
tagId: 'all',
filterTags: [
{ id: 'all', name: '全部', selected: true, nodeId: '355:535' },
{ id: '3', name: '成单待审核', selected: false, nodeId: '355:537' },
{ id: '4', name: '已成单', selected: false, nodeId: '355:540' },
{ id: '5', name: '已关闭', selected: false, nodeId: '355:543' }
],
businessList: []
},
computed: {
},
methods: {
addressShow(value){
if(!value || value==':'){
return '--'
}
return value.split(":")[1]
},
switchTime(value){
return utils.detailTime(new Date(value).getTime(),true)
},
queryBusiList(){
let status
if(this.activeTab == 'all'){
status = ''
}else{
if(this.activeTab == '3,4,5'){
if(this.tagId == 'all'){
status = '3,4,5'
}else{
status = this.tagId
}
}else{
status = this.activeTab
}
}
utils.httpRequest({
url: '/opportunity/list',
data: {
customerPhone: this.searchKeyword,
status: status,
pageNum: 1,
pageSize: 1000
}
}).then(res=>{
if(res.code == 200){
this.detail = res.data
}
})
},
// 切换标签页
switchTab(tab) {
this.activeTab = tab
this.updateActiveIndicator(tab)
if(tab == '3,4,5'){
this.tagId = 'all'
}
this.queryBusiList()
},
// 更新活跃指示器位置
updateActiveIndicator(tab) {
const indicator = document.querySelector('.active-indicator');
const tabTexts = document.querySelectorAll('.tab-text');
let targetIndex = 0;
switch(tab) {
case 'all': targetIndex = 0; break;
case '1': targetIndex = 1; break;
case '2': targetIndex = 2; break;
case '3,4,5': targetIndex = 3; break;
}
if (indicator && tabTexts[targetIndex]) {
const targetTab = tabTexts[targetIndex];
const targetLeft = targetTab.offsetLeft;
const targetWidth = targetTab.offsetWidth;
indicator.style.left = targetLeft + 'px';
indicator.style.width = targetWidth + 'px';
}
},
// 选择筛选标签
selectFilterTag(tagId) {
this.tagId = tagId
this.queryBusiList()
},
// 查看商机详情
viewBusinessDetail(business) {
console.log('查看商机详情:', business);
// 实际项目中这里应该跳转到详情页面
window.location.href = `busiDetail.html?id=${business.id}`;
},
// 跳转到收集商机页面
navigateToCollect() {
window.location.href = 'addBusi.html';
},
// 搜索功能
handleSearch() {
console.log('搜索关键词:', this.searchKeyword);
// 防抖处理,避免频繁搜索
if (this.searchTimer) {
clearTimeout(this.searchTimer);
}
this.searchTimer = setTimeout(() => {
this.performSearch();
}, 300);
},
// 执行搜索
performSearch() {
this.queryBusiList()
},
getStatusCalss(status){
if(status == '1'){
return 'pending'
}else if(status == '2'){
return 'follow-up'
}else if(status == '5'){
return 'closed'
}else{
return 'completed'
}
},
loginOut(){
localStorage.removeItem('userInfo')
localStorage.removeItem('tokenInfo')
location.replace('login.html?platform='+localStorage.getItem('platform'))
}
},
// 监听搜索关键词变化
watch: {
searchKeyword: {
handler(newVal, oldVal) {
if (newVal !== oldVal) {
this.handleSearch();
}
}
}
},
// 生命周期钩子
mounted() {
this.isWorker = localStorage.getItem('platform')=='gw'
// 延迟更新指示器位置,确保DOM已渲染
this.$nextTick(() => {
this.updateActiveIndicator(this.activeTab);
});
this.queryBusiList()
},
beforeDestroy() {
// 清理定时器
if (this.searchTimer) {
clearTimeout(this.searchTimer);
}
}
});