|
|
@@ -289,8 +289,14 @@ export default {
|
|
289
|
289
|
console.log('打标签', order)
|
|
290
|
290
|
//打开模态窗
|
|
291
|
291
|
this.tagModalVisible = true;
|
|
292
|
|
- this.getAllTags();
|
|
293
|
|
- this.currentTags = order.tags.map(tag => tag.id);
|
|
|
292
|
+ // 先获取标签列表,然后再设置当前标签
|
|
|
293
|
+ await this.getAllTags();
|
|
|
294
|
+ // 确保 order.tags 存在且是数组
|
|
|
295
|
+ if (order && order.tags && Array.isArray(order.tags) && order.tags.length > 0) {
|
|
|
296
|
+ this.currentTags = order.tags.map(tag => tag && tag.id ? tag.id : null).filter(id => id !== null);
|
|
|
297
|
+ } else {
|
|
|
298
|
+ this.currentTags = [];
|
|
|
299
|
+ }
|
|
294
|
300
|
this.currentOrder = order
|
|
295
|
301
|
} else if (btnType == 'share') {
|
|
296
|
302
|
//一键分享
|
|
|
@@ -333,26 +339,72 @@ export default {
|
|
333
|
339
|
|
|
334
|
340
|
//获取全部标签
|
|
335
|
341
|
async getAllTags() {
|
|
336
|
|
- const res = await uni.$u.api.getClueTagGroupVoList({ tagGroupApplication: '2' })
|
|
337
|
|
- console.log('全部标签', res.data[0].clueTagDataList)
|
|
338
|
|
- this.tagList = res.data[0].clueTagDataList;
|
|
|
342
|
+ try {
|
|
|
343
|
+ const res = await uni.$u.api.getClueTagGroupVoList({ tagGroupApplication: '2' })
|
|
|
344
|
+ console.log('全部标签', res)
|
|
|
345
|
+ // 确保数据结构正确
|
|
|
346
|
+ if (res && res.data && res.data.length > 0 && res.data[0].clueTagDataList) {
|
|
|
347
|
+ this.tagList = res.data[0].clueTagDataList || [];
|
|
|
348
|
+ } else {
|
|
|
349
|
+ this.tagList = [];
|
|
|
350
|
+ console.warn('标签数据格式不正确', res);
|
|
|
351
|
+ }
|
|
|
352
|
+ } catch (error) {
|
|
|
353
|
+ console.error('获取标签列表失败:', error);
|
|
|
354
|
+ this.tagList = [];
|
|
|
355
|
+ uni.$u.toast('获取标签列表失败');
|
|
|
356
|
+ }
|
|
339
|
357
|
},
|
|
340
|
358
|
cancelTag() {
|
|
341
|
359
|
this.tagModalVisible = false;
|
|
|
360
|
+ // 重置状态
|
|
|
361
|
+ this.currentTags = [];
|
|
|
362
|
+ this.currentOrder = {};
|
|
342
|
363
|
},
|
|
343
|
364
|
async confirmTag() {
|
|
344
|
|
- console.log('确认打标签', this.currentTags)
|
|
345
|
|
- // 这里可以添加打标签的逻辑
|
|
346
|
|
- const allTags = this.currentTags.map(tag => tag).join(',');
|
|
347
|
|
- console.log('allTags', allTags)
|
|
348
|
|
- await uni.$u.api.updateTags({
|
|
349
|
|
- id: this.currentOrder.id,
|
|
350
|
|
- allTags: allTags,
|
|
351
|
|
- })
|
|
352
|
|
- this.tagModalVisible = false;
|
|
353
|
|
- uni.$u.toast('标签更新成功');
|
|
354
|
|
- //更新当前订单的标签
|
|
355
|
|
- this.currentOrder.tags = this.tagList.filter(tag => this.currentTags.includes(tag.id));
|
|
|
365
|
+ try {
|
|
|
366
|
+ console.log('确认打标签', this.currentTags)
|
|
|
367
|
+ // 确保 currentTags 是数组且不为空
|
|
|
368
|
+ if (!Array.isArray(this.currentTags)) {
|
|
|
369
|
+ this.currentTags = [];
|
|
|
370
|
+ }
|
|
|
371
|
+ // 过滤掉无效值
|
|
|
372
|
+ const validTags = this.currentTags.filter(tag => tag !== null && tag !== undefined && tag !== '');
|
|
|
373
|
+ const allTags = validTags.join(',');
|
|
|
374
|
+ console.log('allTags', allTags)
|
|
|
375
|
+
|
|
|
376
|
+ if (!this.currentOrder || !this.currentOrder.id) {
|
|
|
377
|
+ uni.$u.toast('订单信息错误');
|
|
|
378
|
+ return;
|
|
|
379
|
+ }
|
|
|
380
|
+
|
|
|
381
|
+ await uni.$u.api.updateTags({
|
|
|
382
|
+ id: this.currentOrder.id,
|
|
|
383
|
+ allTags: allTags,
|
|
|
384
|
+ })
|
|
|
385
|
+ this.tagModalVisible = false;
|
|
|
386
|
+ uni.$u.toast('标签更新成功');
|
|
|
387
|
+
|
|
|
388
|
+ //更新当前订单的标签
|
|
|
389
|
+ if (this.currentOrder && Array.isArray(this.tagList)) {
|
|
|
390
|
+ this.currentOrder.tags = this.tagList.filter(tag => tag && tag.id && validTags.includes(tag.id));
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
|
393
|
+ // 更新列表中的订单标签
|
|
|
394
|
+ const orderIndex = this.orderList.findIndex(item =>
|
|
|
395
|
+ item.id === this.currentOrder.id ||
|
|
|
396
|
+ (item.receiptId && this.currentOrder.receiptId && item.receiptId === this.currentOrder.receiptId)
|
|
|
397
|
+ );
|
|
|
398
|
+ if (orderIndex !== -1 && this.currentOrder.tags) {
|
|
|
399
|
+ this.$set(this.orderList, orderIndex, {
|
|
|
400
|
+ ...this.orderList[orderIndex],
|
|
|
401
|
+ tags: this.currentOrder.tags
|
|
|
402
|
+ });
|
|
|
403
|
+ }
|
|
|
404
|
+ } catch (error) {
|
|
|
405
|
+ console.error('更新标签失败:', error);
|
|
|
406
|
+ uni.$u.toast('标签更新失败');
|
|
|
407
|
+ }
|
|
356
|
408
|
},
|
|
357
|
409
|
|
|
358
|
410
|
// 确认跟进细节按钮点击事件
|
|
|
@@ -642,10 +694,17 @@ export default {
|
|
642
|
694
|
<u-modal showCancelButton :show="tagModalVisible" title="选择标签" @confirm="confirmTag" @cancel="cancelTag">
|
|
643
|
695
|
<view class="slot-content">
|
|
644
|
696
|
<u-checkbox-group class="tagCheckboxGroup" v-model="currentTags" placement="column">
|
|
645
|
|
- <u-checkbox :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in tagList" :key="item.id"
|
|
646
|
|
- :label="item.name" :name="item.id">
|
|
|
697
|
+ <u-checkbox
|
|
|
698
|
+ v-for="(item, index) in tagList"
|
|
|
699
|
+ :key="item && item.id ? item.id : index"
|
|
|
700
|
+ :customStyle="{ marginBottom: '8px' }"
|
|
|
701
|
+ :label="item && item.name ? item.name : '未知标签'"
|
|
|
702
|
+ :name="item && item.id ? item.id : ''">
|
|
647
|
703
|
</u-checkbox>
|
|
648
|
704
|
</u-checkbox-group>
|
|
|
705
|
+ <view v-if="tagList.length === 0" style="text-align: center; padding: 40rpx 0; color: #999;">
|
|
|
706
|
+ 暂无可用标签
|
|
|
707
|
+ </view>
|
|
649
|
708
|
</view>
|
|
650
|
709
|
</u-modal>
|
|
651
|
710
|
|