1393 lines
33 KiB
Vue
1393 lines
33 KiB
Vue
<template>
|
||
<view class="page">
|
||
<!-- #ifdef APP -->
|
||
<statusBar></statusBar>
|
||
<!-- #endif -->
|
||
|
||
<!-- 导航栏 -->
|
||
<uni-nav-bar
|
||
:fixed="true"
|
||
:statusBar="true"
|
||
:border="false"
|
||
title="AI销冠系统"
|
||
leftIcon="left"
|
||
@clickLeft="goBack"
|
||
color="#333"
|
||
backgroundColor="#FFFFFF">
|
||
</uni-nav-bar>
|
||
|
||
<view class="content">
|
||
<!-- 标签页 -->
|
||
<view class="tabs">
|
||
<view
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'status' }"
|
||
@click="switchTab('status')">
|
||
<text>服务状态</text>
|
||
</view>
|
||
<view
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'reception' }"
|
||
@click="switchTab('reception')">
|
||
<text>开始接待</text>
|
||
</view>
|
||
<view
|
||
class="tab-item"
|
||
:class="{ active: activeTab === 'tag' }"
|
||
@click="switchTab('tag')">
|
||
<text>标签管理</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 服务状态列表 -->
|
||
<service-list-furniture v-if="activeTab === 'status'" class="service-status-container"></service-list-furniture>
|
||
|
||
<!-- 开始接待表单 -->
|
||
<common-begin-reception
|
||
v-if="activeTab === 'reception'"
|
||
:initial-data="receptionForm"
|
||
@cancel="onReceptionCancel"
|
||
@save-success="onReceptionSaveSuccess"
|
||
@save-error="onReceptionSaveError"
|
||
/>
|
||
|
||
<!-- 标签管理 -->
|
||
<scroll-view
|
||
class="service-status-list tag-list"
|
||
scroll-y
|
||
v-if="activeTab === 'tag' && tagViewMode === 'list'"
|
||
@scrolltolower="onTagListReachBottom">
|
||
<view class="service-status-toolbar">
|
||
<text class="toolbar-total">共{{ tagTotal }}条</text>
|
||
<input
|
||
class="toolbar-input"
|
||
v-model="tagQuery.tagType"
|
||
placeholder="标签分类"
|
||
placeholder-style="color: #b0b0b0"
|
||
confirm-type="search"
|
||
@confirm="onTagListSearch"
|
||
/>
|
||
<input
|
||
class="toolbar-input"
|
||
v-model="tagQuery.tagName"
|
||
placeholder="标签名称"
|
||
placeholder-style="color: #b0b0b0"
|
||
confirm-type="search"
|
||
@confirm="onTagListSearch"
|
||
/>
|
||
<view class="toolbar-actions">
|
||
<view class="toolbar-btn toolbar-btn--refresh" @click="onTagListRefresh">
|
||
<uni-icons type="refresh" size="18" color="#2A68FF"></uni-icons>
|
||
</view>
|
||
<view class="toolbar-btn toolbar-btn--add" @click="showAddTag">
|
||
<uni-icons type="plus" size="18" color="#2A68FF"></uni-icons>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view
|
||
class="service-card tag-card-item"
|
||
v-for="(item, index) in tagList"
|
||
:key="index"
|
||
:class="{ 'tag-card-item--active': selectedTagItem && selectedTagItem.id === item.id }">
|
||
<view class="card-header">
|
||
<view class="staff-info" @click.stop="onTagItemClick(item)">
|
||
<view class="staff-avatar">
|
||
<text class="avatar-text">{{ (item.tagName || item.name || '标').charAt(0) }}</text>
|
||
</view>
|
||
<text class="staff-name">{{ item.tagName || item.name || '未命名标签' }}</text>
|
||
</view>
|
||
<view class="tag-card-action-btn" @click.stop="onTagActionBtnClick(item)">
|
||
<uni-icons type="more-filled" size="20" color="#999"></uni-icons>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="customer-info" @click.stop="onTagItemClick(item)">
|
||
<text class="customer-name" v-if="item.industry">所属行业:{{ item.industry }}</text>
|
||
</view>
|
||
|
||
<view class="customer-tags" v-if="item.tagDetail || item.detail || item.remark" @click.stop="onTagItemClick(item)">
|
||
<view
|
||
class="tag-item tag-blue"
|
||
v-if="item.tagDetail || item.detail">
|
||
<text>详情:{{ item.tagDetail || item.detail }}</text>
|
||
</view>
|
||
<view
|
||
class="tag-item tag-orange"
|
||
v-if="item.remark">
|
||
<text>备注:{{ item.remark }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 操作菜单 -->
|
||
<view
|
||
class="tag-action-menu"
|
||
v-if="selectedTagItem && selectedTagItem.id === item.id && showTagActionMenu"
|
||
@click.stop>
|
||
<view class="tag-action-menu-item" @click="editTag(item)">
|
||
<text>编辑</text>
|
||
</view>
|
||
<view class="tag-action-menu-divider"></view>
|
||
<view class="tag-action-menu-item tag-action-menu-item--danger" @click="deleteTag(item)">
|
||
<text>删除</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 遮罩层,点击关闭菜单 -->
|
||
<view
|
||
class="tag-action-menu-mask"
|
||
v-if="showTagActionMenu"
|
||
@click="closeTagActionMenu">
|
||
</view>
|
||
<view class="service-status-empty" v-if="!tagLoading && !tagList.length">
|
||
<text>暂无标签</text>
|
||
</view>
|
||
<view class="service-status-loading-more" v-if="tagLoading && tagList.length">
|
||
<text>正在加载更多...</text>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<!-- 标签管理 - 添加/编辑标签表单 -->
|
||
<view class="tag-management" v-if="activeTab === 'tag' && (tagViewMode === 'add' || tagViewMode === 'edit')">
|
||
<!-- 添加标签表单 -->
|
||
<scroll-view
|
||
class="tag-form"
|
||
scroll-y>
|
||
<view class="form-card">
|
||
<view class="form-item" v-if="tagViewMode === 'add'">
|
||
<text class="form-item__label">所属行业</text>
|
||
<input
|
||
class="form-item__input"
|
||
v-model="tagForm.industry"
|
||
placeholder="请输入所属行业"
|
||
placeholder-style="color: #9ca3af"
|
||
/>
|
||
</view>
|
||
<view class="form-item tag-select-wrapper">
|
||
<text class="form-item__label">标签分类</text>
|
||
<view
|
||
class="tag-select"
|
||
@click.stop="toggleTagTypeDropdown"
|
||
>
|
||
<text
|
||
:class="tagForm.tagType ? 'form-item__picker-text' : 'form-item__picker-placeholder'"
|
||
>
|
||
{{ tagForm.tagType || "请选择标签分类" }}
|
||
</text>
|
||
<uni-icons type="bottom" size="16" color="#9ca3af"></uni-icons>
|
||
</view>
|
||
<view
|
||
v-if="showTagTypeDropdown"
|
||
class="tag-select-dropdown"
|
||
@click.stop
|
||
>
|
||
<view
|
||
class="tag-select-dropdown__item"
|
||
v-for="option in tagTypeOptions"
|
||
:key="option"
|
||
@click="selectTagType(option)"
|
||
>
|
||
<text :class="{'active': option === tagForm.tagType}">
|
||
{{ option }}
|
||
</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="form-item">
|
||
<text class="form-item__label">标签名</text>
|
||
<input
|
||
class="form-item__input"
|
||
v-model="tagForm.name"
|
||
placeholder="请输入标签名"
|
||
placeholder-style="color: #9ca3af"
|
||
/>
|
||
</view>
|
||
<view class="form-item form-item--textarea">
|
||
<text class="form-item__label">详情</text>
|
||
<textarea
|
||
class="form-item__textarea"
|
||
v-model="tagForm.detail"
|
||
placeholder="请输入详情"
|
||
placeholder-style="color: #9ca3af"
|
||
:maxlength="500"
|
||
auto-height
|
||
/>
|
||
</view>
|
||
<view class="form-item form-item--textarea">
|
||
<text class="form-item__label">备注</text>
|
||
<textarea
|
||
class="form-item__textarea"
|
||
v-model="tagForm.remark"
|
||
placeholder="请输入备注"
|
||
placeholder-style="color: #9ca3af"
|
||
:maxlength="500"
|
||
auto-height
|
||
/>
|
||
</view>
|
||
<view class="form-item form-item--switch">
|
||
<text class="form-item__label">是否启用</text>
|
||
<switch
|
||
:checked="tagForm.enabled"
|
||
@change="onEnabledChange"
|
||
color="#007AFF"
|
||
/>
|
||
</view>
|
||
</view>
|
||
<view class="form-actions">
|
||
<view class="form-btn form-btn--cancel" @click="cancelAddTag">
|
||
<text class="form-btn__text">取消</text>
|
||
</view>
|
||
<view class="form-btn form-btn--save" @click="saveTag">
|
||
<text class="form-btn__text">{{ tagViewMode === 'edit' ? '更新' : '保存' }}</text>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
<view
|
||
v-if="showTagTypeDropdown"
|
||
class="tag-select-mask"
|
||
@click="closeTagTypeDropdown"
|
||
></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
// #ifdef APP
|
||
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
|
||
// #endif
|
||
import { getApiUrl } from "@/common/config.js";
|
||
import CommonBeginReception from "./common_begin_reception.vue";
|
||
import ServiceListFurniture from "./serviceListFurniture.vue";
|
||
|
||
export default {
|
||
// #ifdef APP
|
||
components: {
|
||
statusBar,
|
||
CommonBeginReception,
|
||
ServiceListFurniture
|
||
},
|
||
// #endif
|
||
// #ifndef APP
|
||
components: {
|
||
CommonBeginReception,
|
||
ServiceListFurniture
|
||
},
|
||
// #endif
|
||
data() {
|
||
return {
|
||
activeTab: 'status',
|
||
receptionForm: {
|
||
id: "",
|
||
customerName: "",
|
||
contact: "",
|
||
customerSource: "",
|
||
gender: "女",
|
||
age: "",
|
||
dealershipId: "",
|
||
dealershipName: "",
|
||
salesId: "",
|
||
salesName: "",
|
||
salesPhone: "",
|
||
recordingCount: 0,
|
||
intendedModel: "",
|
||
infoCard: "",
|
||
remark: "",
|
||
detailedAddress: "",
|
||
contactCount: 0
|
||
},
|
||
// 标签管理
|
||
tagViewMode: 'list', // 'list' 或 'add' 或 'edit'
|
||
tagList: [],
|
||
tagLoading: false,
|
||
tagTotal: 0,
|
||
tagPage: {
|
||
current: 1,
|
||
size: 10
|
||
},
|
||
tagQuery: {
|
||
industry: '',
|
||
tagType: '',
|
||
tagName: ''
|
||
},
|
||
tagForm: {
|
||
id: '',
|
||
industry: '家居行业',
|
||
tagType: '',
|
||
name: '',
|
||
detail: '',
|
||
remark: '',
|
||
enabled: true
|
||
},
|
||
tagTypeOptions: ["接待客户", "质检SOP", "客户画像"],
|
||
showTagTypeDropdown: false,
|
||
selectedTagItem: null,
|
||
showTagActionMenu: false
|
||
}
|
||
},
|
||
onLoad() {
|
||
// 加载当前登录用户信息,填充销售姓名和电话
|
||
this.loadCurrentUserInfo();
|
||
},
|
||
methods: {
|
||
/**
|
||
* 加载当前登录用户信息,填充销售姓名和电话
|
||
*/
|
||
loadCurrentUserInfo() {
|
||
try {
|
||
// 从本地存储获取登录响应信息
|
||
const loginResponse = uni.getStorageSync('backend-login-response') || {};
|
||
|
||
// 填充销售姓名
|
||
if (loginResponse.userName) {
|
||
this.receptionForm.salesName = loginResponse.userName;
|
||
}
|
||
|
||
// 填充销售电话:如果电话为空,则使用姓名作为电话
|
||
if (loginResponse.phone) {
|
||
this.receptionForm.salesPhone = loginResponse.phone;
|
||
} else if (loginResponse.userName) {
|
||
// 如果电话为空,使用姓名作为电话
|
||
this.receptionForm.salesPhone = loginResponse.userName;
|
||
}
|
||
|
||
// 如果有 userId,也可以填充到 salesId
|
||
if (loginResponse.userId) {
|
||
this.receptionForm.salesId = String(loginResponse.userId);
|
||
}
|
||
} catch (e) {
|
||
console.error('加载当前登录用户信息失败:', e);
|
||
}
|
||
},
|
||
goBack() {
|
||
uni.navigateBack();
|
||
},
|
||
switchTab(tab) {
|
||
this.activeTab = tab;
|
||
if (tab === 'reception') {
|
||
// 切换到开始接待标签页时,重置表单数据
|
||
this.resetReceptionForm();
|
||
} else if (tab === 'tag') {
|
||
this.tagViewMode = 'list';
|
||
// 当进入标签管理页面时,请求接口填充数据
|
||
this.fetchTagList();
|
||
}
|
||
},
|
||
resetReceptionForm() {
|
||
// 重置表单数据
|
||
this.receptionForm = {
|
||
id: "",
|
||
customerName: "",
|
||
contact: "",
|
||
customerSource: "",
|
||
gender: "女",
|
||
age: "",
|
||
dealershipId: "",
|
||
dealershipName: "",
|
||
salesId: "",
|
||
salesName: "",
|
||
salesPhone: "",
|
||
recordingCount: 0,
|
||
intendedModel: "",
|
||
infoCard: "",
|
||
remark: "",
|
||
detailedAddress: "",
|
||
contactCount: 0
|
||
};
|
||
// 重新加载当前登录用户信息
|
||
this.loadCurrentUserInfo();
|
||
},
|
||
onReceptionCancel() {
|
||
// 组件内部已处理取消逻辑,这里只需要重置表单数据
|
||
this.resetReceptionForm();
|
||
},
|
||
onReceptionSaveSuccess({ action, data }) {
|
||
// 保存成功后,更新本地表单数据
|
||
if (data) {
|
||
this.receptionForm = {
|
||
...this.receptionForm,
|
||
...data
|
||
};
|
||
}
|
||
// 重置表单
|
||
this.resetReceptionForm();
|
||
// 如果是开始接待操作,可以在这里处理后续逻辑
|
||
if (action === 'start') {
|
||
// 可以在这里添加开始接待后的逻辑,比如跳转到接待页面等
|
||
console.log('开始接待成功', data);
|
||
}
|
||
},
|
||
onReceptionSaveError({ action, error }) {
|
||
// 保存失败时的处理
|
||
console.error('保存失败:', error);
|
||
},
|
||
// 标签管理相关方法
|
||
onTagListSearch() {
|
||
if (this.activeTab !== 'tag') {
|
||
this.activeTab = 'tag';
|
||
}
|
||
this.tagPage.current = 1;
|
||
this.fetchTagList({ force: true });
|
||
},
|
||
onTagListRefresh() {
|
||
this.tagPage.current = 1;
|
||
this.fetchTagList({ force: true });
|
||
},
|
||
onTagListReachBottom() {
|
||
// 已在加载中或全部加载完成则不再触发
|
||
if (this.tagLoading) return;
|
||
if (this.tagList.length >= this.tagTotal) return;
|
||
this.tagPage.current += 1;
|
||
this.fetchTagList();
|
||
},
|
||
async fetchTagList({ force = false } = {}) {
|
||
if (this.tagLoading && !force) {
|
||
return;
|
||
}
|
||
this.tagLoading = true;
|
||
try {
|
||
const queryParams = {
|
||
current: this.tagPage.current,
|
||
size: this.tagPage.size
|
||
};
|
||
const trimmedTagType = this.tagQuery?.tagType?.trim();
|
||
const trimmedTagName = this.tagQuery?.tagName?.trim();
|
||
if (trimmedTagType) {
|
||
queryParams.tagType = trimmedTagType;
|
||
}
|
||
if (trimmedTagName) {
|
||
queryParams.tagName = trimmedTagName;
|
||
}
|
||
// 后端接口不支持 GET,改为 POST 传参
|
||
const url = getApiUrl('/api/industryTags/list');
|
||
|
||
// 获取认证信息
|
||
let tenantId = '';
|
||
let token = '';
|
||
try {
|
||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||
token = uni.getStorageSync('backend-token') || '';
|
||
} catch (e) {
|
||
console.error('获取认证信息失败:', e);
|
||
}
|
||
|
||
// 构建请求头
|
||
const headers = {
|
||
'Content-Type': 'application/json'
|
||
};
|
||
if (token) {
|
||
headers['Authorization'] = `Bearer ${token}`;
|
||
}
|
||
if (tenantId) {
|
||
headers['X-Tenant-Id'] = tenantId;
|
||
}
|
||
|
||
const res = await uni.request({
|
||
url,
|
||
method: 'POST',
|
||
data: queryParams,
|
||
header: headers,
|
||
timeout: 30000 // 增加超时时间到30秒
|
||
});
|
||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||
const records = Array.isArray(res.data.data) ? res.data.data : [];
|
||
// 第一页或强制刷新时重置列表,否则追加
|
||
if (this.tagPage.current === 1 || force) {
|
||
this.tagList = records;
|
||
} else {
|
||
this.tagList = this.tagList.concat(records);
|
||
}
|
||
this.tagTotal = Number(res.data.total) || 0;
|
||
} else {
|
||
this.tagList = [];
|
||
this.tagTotal = 0;
|
||
uni.showToast({
|
||
title: res.data?.message || '获取标签列表失败',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
} catch (error) {
|
||
console.error('获取标签列表失败:', error);
|
||
// 根据错误类型提供更详细的错误信息
|
||
let errorMessage = '获取标签列表失败,请稍后重试';
|
||
if (error.errMsg) {
|
||
if (error.errMsg.includes('timeout')) {
|
||
errorMessage = '请求超时,请检查网络连接后重试';
|
||
} else if (error.errMsg.includes('fail')) {
|
||
errorMessage = '网络请求失败,请检查网络连接';
|
||
}
|
||
}
|
||
uni.showToast({
|
||
title: errorMessage,
|
||
icon: 'none',
|
||
duration: 3000
|
||
});
|
||
} finally {
|
||
this.tagLoading = false;
|
||
}
|
||
},
|
||
showAddTag() {
|
||
this.tagViewMode = 'add';
|
||
this.showTagTypeDropdown = false;
|
||
this.tagForm = {
|
||
id: '',
|
||
industry: '家居行业',
|
||
tagType: '',
|
||
name: '',
|
||
detail: '',
|
||
remark: '',
|
||
enabled: true
|
||
};
|
||
},
|
||
onTagItemClick(item) {
|
||
// 点击卡片内容区域,不做任何操作(保留用于其他可能的交互)
|
||
},
|
||
onTagActionBtnClick(item) {
|
||
// 如果已经选中当前项,则关闭菜单
|
||
if (this.selectedTagItem && this.selectedTagItem.id === item.id && this.showTagActionMenu) {
|
||
this.closeTagActionMenu();
|
||
return;
|
||
}
|
||
|
||
// 显示菜单
|
||
this.selectedTagItem = item;
|
||
this.showTagActionMenu = true;
|
||
},
|
||
closeTagActionMenu() {
|
||
this.showTagActionMenu = false;
|
||
this.selectedTagItem = null;
|
||
},
|
||
editTag(item) {
|
||
this.closeTagActionMenu();
|
||
this.tagViewMode = 'edit';
|
||
this.showTagTypeDropdown = false;
|
||
this.tagForm = {
|
||
id: item.id || '',
|
||
industry: item.industry || '家居行业',
|
||
tagType: item.tagType || '',
|
||
name: item.tagName || item.name || '',
|
||
detail: item.tagDetail || item.detail || '',
|
||
remark: item.remark || '',
|
||
enabled: item.enabled !== undefined ? item.enabled : (item.isEnabled !== undefined ? item.isEnabled : true)
|
||
};
|
||
},
|
||
async deleteTag(item) {
|
||
this.closeTagActionMenu();
|
||
const tagId = item.id;
|
||
if (!tagId) {
|
||
uni.showToast({
|
||
title: '无法获取标签ID',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
|
||
uni.showModal({
|
||
title: '确认删除',
|
||
content: `确定要删除标签"${item.tagName || item.name || '未命名标签'}"吗?`,
|
||
success: async (res) => {
|
||
if (res.confirm) {
|
||
try {
|
||
uni.showLoading({
|
||
title: '删除中...'
|
||
});
|
||
|
||
const deleteUrl = getApiUrl(`/api/industryTags/delete/${tagId}`);
|
||
|
||
// 获取认证信息
|
||
let tenantId = '';
|
||
let token = '';
|
||
try {
|
||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||
token = uni.getStorageSync('backend-token') || '';
|
||
} catch (e) {
|
||
console.error('获取认证信息失败:', e);
|
||
}
|
||
|
||
// 构建请求头
|
||
const headers = {};
|
||
if (token) {
|
||
headers['Authorization'] = `Bearer ${token}`;
|
||
}
|
||
if (tenantId) {
|
||
headers['X-Tenant-Id'] = tenantId;
|
||
}
|
||
|
||
const deleteRes = await uni.request({
|
||
url: deleteUrl,
|
||
method: 'DELETE',
|
||
header: headers,
|
||
timeout: 30000 // 增加超时时间到30秒
|
||
});
|
||
|
||
uni.hideLoading();
|
||
|
||
if (deleteRes.statusCode === 200 && deleteRes.data && deleteRes.data.success) {
|
||
uni.showToast({
|
||
title: deleteRes.data?.message || '删除成功',
|
||
icon: 'success'
|
||
});
|
||
// 删除成功后刷新列表
|
||
this.tagPage.current = 1;
|
||
this.fetchTagList({ force: true });
|
||
} else {
|
||
uni.showToast({
|
||
title: deleteRes.data?.message || '删除失败',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
} catch (error) {
|
||
uni.hideLoading();
|
||
console.error('删除标签失败:', error);
|
||
// 根据错误类型提供更详细的错误信息
|
||
let errorMessage = '删除失败,请重试';
|
||
if (error.errMsg) {
|
||
if (error.errMsg.includes('timeout')) {
|
||
errorMessage = '请求超时,请检查网络连接后重试';
|
||
} else if (error.errMsg.includes('fail')) {
|
||
errorMessage = '网络请求失败,请检查网络连接';
|
||
}
|
||
}
|
||
uni.showToast({
|
||
title: errorMessage,
|
||
icon: 'none',
|
||
duration: 3000
|
||
});
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
cancelAddTag() {
|
||
this.tagViewMode = 'list';
|
||
this.showTagTypeDropdown = false;
|
||
this.tagForm = {
|
||
id: '',
|
||
industry: '家居行业',
|
||
tagType: '',
|
||
name: '',
|
||
detail: '',
|
||
remark: '',
|
||
enabled: true
|
||
};
|
||
},
|
||
toggleTagTypeDropdown() {
|
||
this.showTagTypeDropdown = !this.showTagTypeDropdown;
|
||
},
|
||
selectTagType(option) {
|
||
this.tagForm.tagType = option;
|
||
this.showTagTypeDropdown = false;
|
||
},
|
||
closeTagTypeDropdown() {
|
||
this.showTagTypeDropdown = false;
|
||
},
|
||
onEnabledChange(e) {
|
||
this.tagForm.enabled = e.detail.value;
|
||
},
|
||
async saveTag() {
|
||
// 表单验证
|
||
if (!this.tagForm.name || !this.tagForm.name.trim()) {
|
||
uni.showToast({
|
||
title: "请输入标签名",
|
||
icon: "none"
|
||
});
|
||
return;
|
||
}
|
||
|
||
try {
|
||
uni.showLoading({
|
||
title: this.tagViewMode === 'edit' ? "更新中..." : "保存中..."
|
||
});
|
||
|
||
const payload = {
|
||
industry: this.tagForm.industry?.trim() || '',
|
||
tagType: this.tagForm.tagType?.trim() || '',
|
||
tagName: this.tagForm.name.trim(),
|
||
tagDetail: this.tagForm.detail?.trim() || '',
|
||
remark: this.tagForm.remark?.trim() || '',
|
||
enabled: this.tagForm.enabled !== undefined ? this.tagForm.enabled : true
|
||
};
|
||
|
||
// 如果是编辑模式,添加id
|
||
if (this.tagViewMode === 'edit' && this.tagForm.id) {
|
||
payload.id = this.tagForm.id;
|
||
}
|
||
|
||
// 根据模式选择不同的接口
|
||
const url = this.tagViewMode === 'edit'
|
||
? getApiUrl('/api/industryTags/update')
|
||
: getApiUrl('/api/industryTags/add');
|
||
|
||
const method = this.tagViewMode === 'edit' ? 'PUT' : 'POST';
|
||
|
||
// 获取认证信息
|
||
let tenantId = '';
|
||
let token = '';
|
||
try {
|
||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||
token = uni.getStorageSync('backend-token') || '';
|
||
} catch (e) {
|
||
console.error('获取认证信息失败:', e);
|
||
}
|
||
|
||
// 构建请求头
|
||
const headers = {
|
||
"Content-Type": "application/json"
|
||
};
|
||
if (token) {
|
||
headers['Authorization'] = `Bearer ${token}`;
|
||
}
|
||
if (tenantId) {
|
||
headers['X-Tenant-Id'] = tenantId;
|
||
}
|
||
|
||
const res = await uni.request({
|
||
url: url,
|
||
method: method,
|
||
data: payload,
|
||
header: headers,
|
||
timeout: 30000 // 增加超时时间到30秒
|
||
});
|
||
|
||
const { statusCode, data } = res;
|
||
if (statusCode === 200 && data && (data.success || data.code === 200)) {
|
||
uni.showToast({
|
||
title: data?.message || (this.tagViewMode === 'edit' ? "更新成功" : "保存成功"),
|
||
icon: "success"
|
||
});
|
||
// 保存成功后返回列表并刷新
|
||
this.tagViewMode = 'list';
|
||
this.tagPage.current = 1;
|
||
this.fetchTagList({ force: true });
|
||
} else {
|
||
throw new Error(data?.message || (this.tagViewMode === 'edit' ? "更新失败" : "保存失败"));
|
||
}
|
||
} catch (error) {
|
||
console.error("保存标签失败:", error);
|
||
// 根据错误类型提供更详细的错误信息
|
||
let errorMessage = error?.message || (this.tagViewMode === 'edit' ? "更新失败,请重试" : "保存失败,请重试");
|
||
if (error.errMsg) {
|
||
if (error.errMsg.includes('timeout')) {
|
||
errorMessage = '请求超时,请检查网络连接后重试';
|
||
} else if (error.errMsg.includes('fail')) {
|
||
errorMessage = '网络请求失败,请检查网络连接';
|
||
}
|
||
}
|
||
uni.showToast({
|
||
title: errorMessage,
|
||
icon: "none",
|
||
duration: 3000
|
||
});
|
||
} finally {
|
||
uni.hideLoading();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
page {
|
||
background-color: #F5F5F5;
|
||
}
|
||
|
||
.page {
|
||
min-height: 100vh;
|
||
background-color: #F5F5F5;
|
||
}
|
||
|
||
.content {
|
||
padding-top: 0; /* 移除padding-top,因为tab页和scroll-view都使用绝对定位 */
|
||
margin-top: 0;
|
||
position: relative;
|
||
min-height: 100vh; /* 确保content有足够高度 */
|
||
}
|
||
|
||
/* 隐藏导航栏占位区域(红色区域) */
|
||
::v-deep .uni-navbar__placeholder {
|
||
display: none !important;
|
||
height: 0 !important;
|
||
}
|
||
|
||
::v-deep .uni-navbar__placeholder-view {
|
||
display: none !important;
|
||
height: 0 !important;
|
||
}
|
||
|
||
/* 隐藏导航栏底部边框 */
|
||
::v-deep .uni-navbar--border {
|
||
border-bottom: none !important;
|
||
}
|
||
|
||
/* 标签页 - 使用绝对定位紧贴导航栏,消除红色空白区域 */
|
||
.tabs {
|
||
display: flex;
|
||
background-color: #FFFFFF;
|
||
border-bottom: 1px solid #E0E0E0;
|
||
padding: 0 16rpx;
|
||
margin-top: 0;
|
||
position: absolute;
|
||
top: 88rpx;
|
||
left: 0;
|
||
right: 0;
|
||
z-index: 10; /* 确保标签页在最上层 */
|
||
height: 72rpx; /* 明确设置标签页高度 */
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
|
||
.tab-item {
|
||
padding: 24rpx 32rpx;
|
||
position: relative;
|
||
}
|
||
|
||
.tab-item text {
|
||
font-size: 30rpx;
|
||
color: #666;
|
||
}
|
||
|
||
.tab-item.active text {
|
||
color: #333;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.tab-item.active::after {
|
||
content: '';
|
||
position: absolute;
|
||
bottom: 0;
|
||
left: 32rpx;
|
||
right: 32rpx;
|
||
height: 4rpx;
|
||
background-color: #007AFF;
|
||
border-radius: 2rpx;
|
||
}
|
||
|
||
/* 服务状态列表容器 */
|
||
.service-status-container {
|
||
/* 使用绝对定位,从tab页底部开始,高度计算:100vh - 导航栏(88rpx) - tab页(72rpx) - 底部导航栏(96rpx) */
|
||
position: absolute;
|
||
top: 160rpx; /* 导航栏(88rpx) + tab页(72rpx) = 160rpx */
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 96rpx; /* 底部导航栏高度 */
|
||
}
|
||
|
||
/* 标签管理列表区:使用绝对定位,与服务状态列表保持一致 */
|
||
.tag-list {
|
||
/* 使用绝对定位,从tab页底部开始,高度计算:100vh - 导航栏(88rpx) - tab页(72rpx) - 底部导航栏(96rpx) */
|
||
position: absolute;
|
||
top: 160rpx; /* 导航栏(88rpx) + tab页(72rpx) = 160rpx */
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 96rpx; /* 底部导航栏高度 */
|
||
background-color: #F5F5F5;
|
||
padding: 24rpx 16rpx 0 16rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 标签管理工具栏样式 */
|
||
.service-status-toolbar {
|
||
display: flex;
|
||
flex-wrap: nowrap;
|
||
align-items: center;
|
||
gap: 8rpx;
|
||
padding: 12rpx 8rpx;
|
||
margin-bottom: 24rpx;
|
||
background-color: #F8F8FA;
|
||
border-radius: 8rpx;
|
||
border: 1px solid #EFEFF2;
|
||
overflow-x: auto;
|
||
min-height: 64rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.toolbar-total {
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
white-space: nowrap;
|
||
flex-shrink: 0;
|
||
margin-right: 8rpx;
|
||
line-height: 1.2;
|
||
padding: 0 4rpx;
|
||
}
|
||
|
||
.toolbar-input {
|
||
flex: 1;
|
||
min-width: 120rpx;
|
||
max-width: 200rpx;
|
||
height: 56rpx;
|
||
line-height: 56rpx;
|
||
background-color: #F5F6FA;
|
||
border-radius: 8rpx;
|
||
padding: 0 12rpx;
|
||
font-size: 24rpx;
|
||
border: 1px solid transparent;
|
||
box-sizing: border-box;
|
||
flex-shrink: 1;
|
||
}
|
||
|
||
.toolbar-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-left: auto;
|
||
flex-shrink: 0;
|
||
gap: 8rpx;
|
||
}
|
||
|
||
.toolbar-btn {
|
||
padding: 0 12rpx;
|
||
height: 56rpx;
|
||
min-width: 56rpx;
|
||
color: #2A68FF;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 4rpx;
|
||
font-size: 24rpx;
|
||
font-weight: 400;
|
||
line-height: 1;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 标签卡片样式 */
|
||
.service-card.tag-card-item {
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
background-color: #FFFFFF;
|
||
border-radius: 16rpx;
|
||
padding: 32rpx;
|
||
margin-bottom: 24rpx;
|
||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
|
||
overflow: visible;
|
||
position: relative;
|
||
}
|
||
|
||
.card-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 20rpx;
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
padding: 0;
|
||
margin: 0;
|
||
/* 确保头部内容在卡片padding范围内 */
|
||
}
|
||
|
||
.staff-info {
|
||
display: flex;
|
||
align-items: center;
|
||
flex: 1;
|
||
min-width: 0;
|
||
margin: 0;
|
||
padding: 0;
|
||
}
|
||
|
||
.staff-avatar {
|
||
width: 64rpx;
|
||
height: 64rpx;
|
||
background-color: #2196F3;
|
||
border-radius: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-right: 16rpx;
|
||
margin-left: 0;
|
||
margin-top: 0;
|
||
margin-bottom: 0;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.avatar-text {
|
||
font-size: 32rpx;
|
||
color: #FFFFFF;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.staff-name {
|
||
font-size: 32rpx;
|
||
font-weight: 500;
|
||
color: #333;
|
||
}
|
||
|
||
.customer-tags {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin-bottom: 20rpx;
|
||
gap: 12rpx;
|
||
box-sizing: border-box;
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
padding: 0;
|
||
/* 确保标签容器不会超出卡片padding范围 */
|
||
width: 100%;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.customer-info {
|
||
margin-bottom: 16rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8rpx;
|
||
box-sizing: border-box;
|
||
margin-left: 0;
|
||
margin-right: 0;
|
||
padding: 0;
|
||
/* 确保信息容器不会超出卡片padding范围 */
|
||
width: 100%;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.customer-name,
|
||
.customer-phone {
|
||
font-size: 28rpx;
|
||
color: #555;
|
||
}
|
||
|
||
.tag-item {
|
||
padding: 8rpx 16rpx;
|
||
border-radius: 8rpx;
|
||
box-sizing: border-box;
|
||
word-wrap: break-word;
|
||
word-break: break-all;
|
||
/* 确保标签项不会超出卡片padding范围,允许换行 */
|
||
display: inline-block;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.tag-blue {
|
||
background-color: #E3F2FD;
|
||
}
|
||
|
||
.tag-blue text {
|
||
font-size: 24rpx;
|
||
color: #1976D2;
|
||
}
|
||
|
||
.tag-orange {
|
||
background-color: #FFF3E0;
|
||
}
|
||
|
||
.tag-orange text {
|
||
font-size: 24rpx;
|
||
color: #F57C00;
|
||
}
|
||
|
||
/* 标签管理样式 - 添加表单 */
|
||
.tag-management {
|
||
/* 使用绝对定位,从tab页底部开始,高度计算:100vh - 导航栏(88rpx) - tab页(72rpx) - 底部导航栏(96rpx) */
|
||
position: absolute;
|
||
top: 160rpx; /* 导航栏(88rpx) + tab页(72rpx) = 160rpx */
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 96rpx; /* 底部导航栏高度 */
|
||
background-color: #F5F5F5;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 标签卡片操作菜单 */
|
||
.tag-card-item {
|
||
position: relative;
|
||
}
|
||
|
||
.tag-card-action-btn {
|
||
width: 60rpx;
|
||
height: 60rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
margin-left: auto;
|
||
margin-right: 0;
|
||
margin-top: 0;
|
||
margin-bottom: 0;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
position: relative;
|
||
padding: 0;
|
||
/* 确保按钮在卡片padding范围内,距离右边框32rpx */
|
||
}
|
||
|
||
.tag-card-action-btn uni-icons {
|
||
display: block;
|
||
margin: 0;
|
||
padding: 0;
|
||
line-height: 1;
|
||
}
|
||
|
||
.tag-card-action-btn:active {
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.tag-action-menu {
|
||
position: absolute;
|
||
top: 60rpx;
|
||
right: 32rpx;
|
||
width: 160rpx;
|
||
background-color: #FFFFFF;
|
||
border-radius: 12rpx;
|
||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
|
||
z-index: 100;
|
||
overflow: hidden;
|
||
margin-right: 0;
|
||
}
|
||
|
||
.tag-action-menu-item {
|
||
padding: 24rpx 32rpx;
|
||
font-size: 28rpx;
|
||
color: #333;
|
||
text-align: center;
|
||
background-color: #FFFFFF;
|
||
}
|
||
|
||
.tag-action-menu-item:active {
|
||
background-color: #F5F5F5;
|
||
}
|
||
|
||
.tag-action-menu-item--danger {
|
||
color: #FF5722;
|
||
}
|
||
|
||
.tag-action-menu-divider {
|
||
height: 1rpx;
|
||
background-color: #E0E0E0;
|
||
margin: 0 16rpx;
|
||
}
|
||
|
||
.tag-action-menu-mask {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background-color: transparent;
|
||
z-index: 99;
|
||
}
|
||
|
||
.tag-form {
|
||
height: 100%;
|
||
padding: 32rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 表单卡片样式 */
|
||
.form-card {
|
||
background-color: #FFFFFF;
|
||
border-radius: 24rpx;
|
||
padding: 32rpx;
|
||
margin-bottom: 32rpx;
|
||
box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.06);
|
||
}
|
||
|
||
/* 表单项样式 */
|
||
.form-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
margin-bottom: 32rpx;
|
||
}
|
||
|
||
.form-item:last-child {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
/* 表单项标签样式 */
|
||
.form-item__label {
|
||
font-size: 28rpx;
|
||
color: #333333;
|
||
font-weight: 500;
|
||
margin-bottom: 16rpx;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
/* 输入框样式 */
|
||
.form-item__input {
|
||
width: 100%;
|
||
height: 88rpx;
|
||
background-color: #F9FAFB;
|
||
border: 2rpx solid #E5E7EB;
|
||
border-radius: 16rpx;
|
||
padding: 0 24rpx;
|
||
font-size: 28rpx;
|
||
color: #333333;
|
||
box-sizing: border-box;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.form-item__input:focus {
|
||
border-color: #007AFF;
|
||
background-color: #FFFFFF;
|
||
box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
|
||
}
|
||
|
||
/* 文本域样式 */
|
||
.form-item__textarea {
|
||
width: 100%;
|
||
min-height: 160rpx;
|
||
background-color: #F9FAFB;
|
||
border: 2rpx solid #E5E7EB;
|
||
border-radius: 16rpx;
|
||
padding: 20rpx 24rpx;
|
||
font-size: 28rpx;
|
||
color: #333333;
|
||
box-sizing: border-box;
|
||
line-height: 1.6;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.form-item__textarea:focus {
|
||
border-color: #007AFF;
|
||
background-color: #FFFFFF;
|
||
box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
|
||
}
|
||
|
||
/* 标签选择器样式 */
|
||
.tag-select-wrapper {
|
||
position: relative;
|
||
}
|
||
|
||
.tag-select {
|
||
width: 100%;
|
||
height: 88rpx;
|
||
background-color: #F9FAFB;
|
||
border: 2rpx solid #E5E7EB;
|
||
border-radius: 16rpx;
|
||
padding: 0 24rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
box-sizing: border-box;
|
||
cursor: pointer;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.tag-select:active {
|
||
border-color: #007AFF;
|
||
background-color: #FFFFFF;
|
||
box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
|
||
}
|
||
|
||
.form-item__picker-text {
|
||
font-size: 28rpx;
|
||
color: #333333;
|
||
flex: 1;
|
||
}
|
||
|
||
.form-item__picker-placeholder {
|
||
font-size: 28rpx;
|
||
color: #9CA3AF;
|
||
flex: 1;
|
||
}
|
||
|
||
/* 下拉菜单样式 */
|
||
.tag-select-dropdown {
|
||
position: absolute;
|
||
top: 100%;
|
||
left: 0;
|
||
right: 0;
|
||
background-color: #FFFFFF;
|
||
border: 2rpx solid #E5E7EB;
|
||
border-radius: 16rpx;
|
||
margin-top: 8rpx;
|
||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.12);
|
||
z-index: 100;
|
||
overflow: hidden;
|
||
max-height: 400rpx;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.tag-select-dropdown__item {
|
||
padding: 24rpx;
|
||
border-bottom: 1rpx solid #F3F4F6;
|
||
transition: background-color 0.2s ease;
|
||
}
|
||
|
||
.tag-select-dropdown__item:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.tag-select-dropdown__item:active {
|
||
background-color: #F9FAFB;
|
||
}
|
||
|
||
.tag-select-dropdown__item text {
|
||
font-size: 28rpx;
|
||
color: #333333;
|
||
}
|
||
|
||
.tag-select-dropdown__item text.active {
|
||
color: #007AFF;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 下拉菜单遮罩 */
|
||
.tag-select-mask {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background-color: transparent;
|
||
z-index: 99;
|
||
}
|
||
|
||
/* 开关类型表单项 - 横向布局 */
|
||
.form-item--switch {
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.form-item--switch .form-item__label {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
/* 开关样式 */
|
||
.form-item switch {
|
||
margin-left: auto;
|
||
transform: scale(0.9);
|
||
}
|
||
|
||
/* 表单操作按钮区域 */
|
||
.form-actions {
|
||
display: flex;
|
||
gap: 24rpx;
|
||
padding-top: 16rpx;
|
||
}
|
||
|
||
.form-btn {
|
||
flex: 1;
|
||
height: 88rpx;
|
||
border-radius: 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.form-btn--cancel {
|
||
background-color: #F3F4F6;
|
||
color: #6B7280;
|
||
}
|
||
|
||
.form-btn--cancel:active {
|
||
background-color: #E5E7EB;
|
||
opacity: 0.8;
|
||
}
|
||
|
||
.form-btn--save {
|
||
background-color: #007AFF;
|
||
color: #FFFFFF;
|
||
}
|
||
|
||
.form-btn--save:active {
|
||
background-color: #0056CC;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.form-btn__text {
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
}
|
||
</style>
|