提交 9c71634b authored 作者: lidongxu's avatar lidongxu

feat(newterminal.vue): 新增:创建终端页面

上级 8a026383
<template> <template>
<!-- 新建终端 --> <div class="terminal-info-container">
<p class="title">录入终端信息</p>
<div class="content">
<!-- 终端名称输入 -->
<van-field v-model="terminalName"
label="终端名称:"
label-align="top"
placeholder="请输入"
class="input-field" />
<!-- 门头照上传 -->
<div class="header-photo-section">
<van-field label="门头照"
label-align="top">
<template #input>
<van-uploader :max-count="2"
accept="image/*"
v-model="form.posPhotos"
:after-read="posPhotosRead"
preview-size="120"
@delete="deletePosPhotos">
</van-uploader>
</template>
</van-field>
</div>
<!-- 门店类型选择 -->
<van-field :model-value="form.selectedType.join('')"
label="门店类型"
label-align="top"
placeholder="请选择"
@click="showTypePopup = true" />
<van-popup v-model:show="showTypePopup"
position="bottom"
@close="showTypePopup = false">
<van-picker v-model="form.selectedType"
:columns="typeOptions"
@confirm="handleTypeConfirm"
@cancel="showTypePopup = false" />
</van-popup>
</div>
<!-- 操作按钮 -->
<div class="button-group">
<van-button type="danger"
block
@click="handleCreateTask">
创建任务
</van-button>
<van-button type="info"
block
@click="handleCancel">
取消
</van-button>
</div>
</div>
</template> </template>
<script setup> <script setup>
import { uploadFileToOSSAPI } from '@/api'
import { v4 as uuidv4 } from 'uuid';
const form = ref({
selectedType: []
})
const terminalName = ref('');
const headerPhotoUrl = ref('');
const typeOptions = ref([
{
text: 'KA',
value: 'KA'
}, {
text: 'BC',
value: 'BC'
},
{
text: 'CVS',
value: 'CVS'
},
{
text: '零食',
value: '零食'
},
{
text: '批发',
value: '批发'
}
]); // 示例类型
const selectedType = ref('');
const showTypePopup = ref(false);
// 门头照上传逻辑
// POS 两张照片
const posPhotosRead = async (file) => {
// 处理上传的文件
const date = new Date()
const month = date.getMonth() + 1
const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${employeeNo}/${uuidv4()}.png`, file.file)
// 判断 objectUrl
const index = form.value.posPhotos.findIndex(o => o.objectUrl)
form.value.posPhotos[index] = {
url: pictureUrl
}
}
// 删除 照片
const deletePosPhotos = async () => {
if (isInitializing.value) return
await createExamine({
id: form.value.id,
posPhotos: form.value.posPhotos.map(o => o.url),
employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: employeeNo, // 稽查人工号
})
showNotify({ type: 'success', message: 'POS 照片删除成功' })
}
// 确认门店类型
const handleTypeConfirm = (val) => {
form.selectedType = val;
showTypePopup.value = false;
};
// 创建任务(可根据需求对接接口)
const handleCreateTask = () => {
console.log('创建任务:', {
terminalName: terminalName.value,
headerPhoto: headerPhotoUrl.value,
storeType: selectedType.value,
});
// 此处可补充接口请求逻辑
};
// 取消操作
const handleCancel = () => {
console.log('取消操作');
// 可重置表单等逻辑
terminalName.value = '';
headerPhotoUrl.value = '';
selectedType.value = 'KA';
};
</script> </script>
<style scoped></style> <style lang="scss"
\ No newline at end of file scoped>
.terminal-info-container {
padding: 20px;
box-sizing: border-box;
background-color: #f8f8f8;
min-height: 100vh;
.title {
font-size: 14px;
font-weight: bold;
margin-top: 0;
margin-bottom: 10px;
}
.content {
background-color: white;
}
.input-field {
margin-bottom: 12px;
}
.header-photo-section {
margin-bottom: 12px;
.header-photo-label {
display: block;
cursor: pointer;
.header-photo-placeholder {
width: 80px;
height: 80px;
border: 1px dashed #ccc;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
background-color: #f8f8f8;
}
}
.preview-image {
width: 80px;
height: 80px;
margin-top: 8px;
border-radius: 4px;
}
}
.button-group {
display: flex;
flex-direction: column;
gap: 12px;
margin-top: 24px;
van-button {
flex: 1;
}
}
}
</style>
\ No newline at end of file
...@@ -48,6 +48,9 @@ ...@@ -48,6 +48,9 @@
<van-empty v-if="showEmpty" <van-empty v-if="showEmpty"
description="未找到匹配的结果" description="未找到匹配的结果"
class="empty-tip" /> class="empty-tip" />
<van-floating-bubble icon="plus"
@click="addNewTerminal" />
</div> </div>
</template> </template>
...@@ -81,11 +84,20 @@ const loading = ref(false); ...@@ -81,11 +84,20 @@ const loading = ref(false);
const finished = ref(true); const finished = ref(true);
const showEmpty = ref(false); const showEmpty = ref(false);
const router = useRouter();
// 监听结果列表变化,控制空状态显示 // 监听结果列表变化,控制空状态显示
watch(resultList, (newVal) => { watch(resultList, (newVal) => {
showEmpty.value = newVal.length === 0 && searchVal.value.trim() !== ''; showEmpty.value = newVal.length === 0 && searchVal.value.trim() !== '';
}); });
/*******新增终端********/
const addNewTerminal = () => {
router.push({
path: '/newTerminal'
})
}
// 搜索处理 // 搜索处理
const handleSearch = () => { const handleSearch = () => {
if (!searchVal.value.trim()) { if (!searchVal.value.trim()) {
...@@ -140,7 +152,7 @@ const handleClear = () => { ...@@ -140,7 +152,7 @@ const handleClear = () => {
padding: 0 20px; padding: 0 20px;
border-bottom: 2px solid #e5e5e5; border-bottom: 2px solid #e5e5e5;
span{ span {
font-size: 14px; font-size: 14px;
} }
...@@ -149,9 +161,10 @@ const handleClear = () => { ...@@ -149,9 +161,10 @@ const handleClear = () => {
height: auto !important; height: auto !important;
background-color: transparent; background-color: transparent;
::v-deep(.van-search__content){ ::v-deep(.van-search__content) {
background-color: white; background-color: white;
.van-cell{
.van-cell {
height: auto; height: auto;
} }
} }
......
...@@ -665,7 +665,6 @@ const deletePosPhotos = async () => { ...@@ -665,7 +665,6 @@ const deletePosPhotos = async () => {
employeeNo: employeeNo, // 稽查人工号 employeeNo: employeeNo, // 稽查人工号
}) })
showNotify({ type: 'success', message: 'POS 照片删除成功' }) showNotify({ type: 'success', message: 'POS 照片删除成功' })
} }
// POS 金额修改 // POS 金额修改
......
...@@ -39,6 +39,11 @@ export const constantMobileRoutes = [ ...@@ -39,6 +39,11 @@ export const constantMobileRoutes = [
path: 'logistics', // 物流信息页面 path: 'logistics', // 物流信息页面
component: () => import('@/views/mobile/pages/other/logistics'), component: () => import('@/views/mobile/pages/other/logistics'),
name: 'logistics' name: 'logistics'
},
{
path: 'newTerminal',
component: () => import('@/views/mobile/pages/audit_activity/sales_point_inspection/examine/newTerminal'),
name: 'newTerminal'
} }
] ]
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论