- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
433 行
9.1 KiB
Vue
433 行
9.1 KiB
Vue
<template>
|
||
<view class="drawer-mask" v-if="visible" @tap="close">
|
||
<view class="drawer-sheet" @tap.stop>
|
||
<!-- 标题栏 -->
|
||
<view class="drawer-head">
|
||
<text class="dh-title">选择常用备注模板</text>
|
||
<view class="dh-close clickable-hover" @tap="close">
|
||
<image class="dh-close-img" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 新增个人常用备注栏 -->
|
||
<view class="add-tpl-bar">
|
||
<input
|
||
class="add-input"
|
||
v-model="newContent"
|
||
maxlength="60"
|
||
placeholder="输入自定义常用备注,保存后可随时选用"
|
||
@confirm="handleAddTpl"
|
||
/>
|
||
<view
|
||
class="add-btn clickable-hover"
|
||
:class="{ disabled: adding || !newContent.trim() }"
|
||
@tap="handleAddTpl"
|
||
>
|
||
<text class="add-btn-txt">{{ adding ? '保存中' : '存为常用' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 模板列表(真实接口驱动) -->
|
||
<scroll-view class="drawer-body" scroll-y="true">
|
||
<view class="state-box" v-if="loading && templateList.length === 0">
|
||
<text class="state-txt">正在加载备注模板...</text>
|
||
</view>
|
||
|
||
<view class="state-box" v-else-if="templateList.length === 0">
|
||
<text class="state-txt">暂无备注模板,可在上方添加</text>
|
||
</view>
|
||
|
||
<view class="template-list" v-else>
|
||
<view
|
||
class="tpl-item clickable-hover"
|
||
v-for="tpl in templateList"
|
||
:key="tpl.id"
|
||
:class="{ active: selectedIds.includes(tpl.id) }"
|
||
@tap="toggleTpl(tpl.id)"
|
||
>
|
||
<view class="tpl-content">
|
||
<view class="mine-tag" v-if="tpl.is_mine">
|
||
<text class="mine-tag-txt">自建</text>
|
||
</view>
|
||
<text class="tpl-txt">{{ tpl.content }}</text>
|
||
</view>
|
||
<view class="tpl-right">
|
||
<view
|
||
class="del-icon-wrap clickable-hover"
|
||
v-if="tpl.is_mine"
|
||
@tap.stop="handleDeleteTpl(tpl)"
|
||
>
|
||
<image class="del-img" src="/static/icons/trash.svg" mode="aspectFit" />
|
||
</view>
|
||
<view class="check-box" :class="{ on: selectedIds.includes(tpl.id) }">
|
||
<image
|
||
class="check-img"
|
||
v-if="selectedIds.includes(tpl.id)"
|
||
src="/static/icons/check-white.svg"
|
||
mode="aspectFit"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<!-- 底部确定按钮 -->
|
||
<view class="drawer-foot">
|
||
<view class="confirm-btn clickable-hover" @tap="handleConfirm">
|
||
<text class="cb-txt">确定填入备注</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, watch } from 'vue';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
|
||
const props = defineProps({
|
||
visible: { type: Boolean, default: false }
|
||
});
|
||
|
||
const emit = defineEmits(['update:visible', 'select']);
|
||
|
||
const templateList = ref([]);
|
||
const selectedIds = ref([]);
|
||
const loading = ref(false);
|
||
const newContent = ref('');
|
||
const adding = ref(false);
|
||
const deletingId = ref(0);
|
||
|
||
async function fetchTemplates() {
|
||
if (loading.value) return;
|
||
loading.value = true;
|
||
try {
|
||
const res = await api.remarkTemplates();
|
||
templateList.value = (res && Array.isArray(res.list)) ? res.list : [];
|
||
} catch (e) {
|
||
uni.showToast({ title: (e && e.msg) ? e.msg : '获取常用备注失败', icon: 'none' });
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
watch(
|
||
() => props.visible,
|
||
(val) => {
|
||
if (val) {
|
||
fetchTemplates();
|
||
}
|
||
}
|
||
);
|
||
|
||
function toggleTpl(id) {
|
||
const pos = selectedIds.value.indexOf(id);
|
||
if (pos > -1) {
|
||
selectedIds.value.splice(pos, 1);
|
||
} else {
|
||
selectedIds.value.push(id);
|
||
}
|
||
}
|
||
|
||
async function handleAddTpl() {
|
||
const content = newContent.value.trim();
|
||
if (!content || adding.value) return;
|
||
if (!isLogin()) {
|
||
close();
|
||
toLogin();
|
||
return;
|
||
}
|
||
adding.value = true;
|
||
try {
|
||
const saved = await api.saveRemarkTemplate({ content });
|
||
newContent.value = '';
|
||
if (saved && saved.id) {
|
||
templateList.value.unshift(saved);
|
||
if (!selectedIds.value.includes(saved.id)) {
|
||
selectedIds.value.push(saved.id);
|
||
}
|
||
} else {
|
||
await fetchTemplates();
|
||
}
|
||
uni.showToast({ title: '已添加至常用备注', icon: 'success' });
|
||
} catch (e) {
|
||
uni.showToast({ title: (e && e.msg) ? e.msg : '保存常用备注失败', icon: 'none' });
|
||
} finally {
|
||
adding.value = false;
|
||
}
|
||
}
|
||
|
||
async function handleDeleteTpl(tpl) {
|
||
if (!tpl || !tpl.is_mine || deletingId.value) return;
|
||
deletingId.value = tpl.id;
|
||
try {
|
||
await api.deleteRemarkTemplate({ id: tpl.id });
|
||
templateList.value = templateList.value.filter(x => x.id !== tpl.id);
|
||
selectedIds.value = selectedIds.value.filter(id => id !== tpl.id);
|
||
uni.showToast({ title: '已删除', icon: 'none' });
|
||
} catch (e) {
|
||
uni.showToast({ title: (e && e.msg) ? e.msg : '删除备注失败', icon: 'none' });
|
||
} finally {
|
||
deletingId.value = 0;
|
||
}
|
||
}
|
||
|
||
function close() {
|
||
emit('update:visible', false);
|
||
}
|
||
|
||
function handleConfirm() {
|
||
const hits = templateList.value
|
||
.filter(item => selectedIds.value.includes(item.id))
|
||
.map(item => item.content);
|
||
if (hits.length > 0) {
|
||
emit('select', hits.join(';'));
|
||
}
|
||
selectedIds.value = [];
|
||
close();
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.drawer-mask {
|
||
position: fixed;
|
||
inset: 0;
|
||
background: rgba(0, 0, 0, 0.6);
|
||
z-index: 999;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-end;
|
||
animation: drawerFadeIn 0.22s ease-out;
|
||
}
|
||
|
||
@keyframes drawerFadeIn {
|
||
from { opacity: 0; }
|
||
to { opacity: 1; }
|
||
}
|
||
|
||
.drawer-sheet {
|
||
background-color: $yjyf-bg-card;
|
||
border-top-left-radius: 28rpx;
|
||
border-top-right-radius: 28rpx;
|
||
padding: 32rpx 32rpx calc(28rpx + env(safe-area-inset-bottom));
|
||
max-height: 78vh;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
animation: drawerSlideUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
|
||
}
|
||
|
||
@keyframes drawerSlideUp {
|
||
from { transform: translateY(100%); }
|
||
to { transform: translateY(0); }
|
||
}
|
||
|
||
.drawer-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding-bottom: 20rpx;
|
||
}
|
||
|
||
.dh-title {
|
||
font-size: 34rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.dh-close {
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.dh-close-img {
|
||
width: 32rpx;
|
||
height: 32rpx;
|
||
opacity: 0.75;
|
||
}
|
||
|
||
.add-tpl-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16rpx;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
|
||
.add-input {
|
||
flex: 1;
|
||
height: 68rpx;
|
||
padding: 0 22rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-bg-page;
|
||
font-size: 26rpx;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.add-btn {
|
||
height: 68rpx;
|
||
padding: 0 26rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-primary-bg;
|
||
border: 1rpx solid $yjyf-primary;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.add-btn.disabled {
|
||
opacity: 0.5;
|
||
}
|
||
|
||
.add-btn-txt {
|
||
font-size: 26rpx;
|
||
font-weight: 600;
|
||
color: $yjyf-primary;
|
||
}
|
||
|
||
.drawer-body {
|
||
max-height: 500rpx;
|
||
padding: 6rpx 0;
|
||
}
|
||
|
||
.state-box {
|
||
padding: 64rpx 24rpx;
|
||
text-align: center;
|
||
}
|
||
|
||
.state-txt {
|
||
font-size: 26rpx;
|
||
color: $yjyf-text-secondary;
|
||
}
|
||
|
||
.template-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 16rpx;
|
||
}
|
||
|
||
.tpl-item {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 24rpx 22rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-bg-page;
|
||
border: 2rpx solid transparent;
|
||
transition: all 0.18s ease;
|
||
}
|
||
|
||
.tpl-item.active {
|
||
background-color: $yjyf-primary-bg;
|
||
border-color: $yjyf-primary;
|
||
}
|
||
|
||
.tpl-content {
|
||
flex: 1;
|
||
padding-right: 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 10rpx;
|
||
}
|
||
|
||
.mine-tag {
|
||
height: 34rpx;
|
||
padding: 0 10rpx;
|
||
border-radius: 6rpx;
|
||
background-color: $yjyf-primary-bg;
|
||
border: 1rpx solid $yjyf-primary-border;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.mine-tag-txt {
|
||
font-size: 22rpx;
|
||
color: $yjyf-primary;
|
||
line-height: 1;
|
||
}
|
||
|
||
.tpl-txt {
|
||
font-size: $yjyf-font-body;
|
||
color: $yjyf-text-regular;
|
||
line-height: 1.45;
|
||
}
|
||
|
||
.tpl-item.active .tpl-txt {
|
||
color: $yjyf-primary;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.tpl-right {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 16rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.del-icon-wrap {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.del-img {
|
||
width: 28rpx;
|
||
height: 28rpx;
|
||
opacity: 0.7;
|
||
}
|
||
|
||
.check-box {
|
||
width: 38rpx;
|
||
height: 38rpx;
|
||
border-radius: 8rpx;
|
||
border: 2rpx solid $yjyf-text-disabled;
|
||
background-color: $yjyf-bg-card;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.check-box.on {
|
||
background-color: $yjyf-primary;
|
||
border-color: $yjyf-primary;
|
||
}
|
||
|
||
.check-img {
|
||
width: 24rpx;
|
||
height: 24rpx;
|
||
}
|
||
|
||
.drawer-foot {
|
||
padding-top: 28rpx;
|
||
}
|
||
|
||
.confirm-btn {
|
||
height: 88rpx;
|
||
background: $yjyf-gradient-primary;
|
||
border-radius: $yjyf-radius-sm;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: $yjyf-shadow-button;
|
||
}
|
||
|
||
.cb-txt {
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 600;
|
||
color: $yjyf-text-inverse;
|
||
letter-spacing: 2rpx;
|
||
}
|
||
|
||
.clickable-hover:active {
|
||
opacity: 0.85;
|
||
}
|
||
</style>
|