4月3日
This commit is contained in:
parent
1ed76337c9
commit
a237a8bdb0
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -2,7 +2,7 @@ import request from '@/utils/request'
|
||||
|
||||
const v = "1.0";
|
||||
|
||||
export function accountList(query: any) {
|
||||
export function accountList(query: { status?: number, includeDisabled?: boolean, where?: any }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
@ -16,8 +16,7 @@ export function accountList(query: any) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工号,按手机号复用或创建账号后绑定到当前主体
|
||||
* 接口文档:ids(角色组ID数组)为必填项
|
||||
* 新增工号
|
||||
*/
|
||||
export function accountAdd(data: {
|
||||
phone: string
|
||||
@ -41,7 +40,6 @@ export function accountAdd(data: {
|
||||
|
||||
/**
|
||||
* 停用工号(不删除账号)
|
||||
* 接口文档:参数为 employee_id(单个)
|
||||
*/
|
||||
export function accountdelete(data: { employee_id: number }) {
|
||||
return request({
|
||||
@ -57,10 +55,9 @@ export function accountdelete(data: { employee_id: number }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新工号姓名、头像引用和角色组 ids
|
||||
* 接口文档:ids 为必填项,整体替换角色组
|
||||
* 更新工号
|
||||
*/
|
||||
export function accountUpdate(data: { employee_id: number, real_name?: string, file_id?: number, status?: number, email?: string, ids: number[] }) {
|
||||
export function accountUpdate(data: { employee_id: number, real_name?: string, file_id?: number, ids: number[] }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
|
||||
@ -3,10 +3,9 @@ import request from '@/utils/request'
|
||||
const v = "1.0";
|
||||
|
||||
/**
|
||||
* 查询当前主体可分配角色列表,按当前登录工号返回角色选中状态
|
||||
* 文档:includeDisabled / includeSystem,不支持 employee_id
|
||||
* 查询当前登录工号的下级角色列表
|
||||
*/
|
||||
export function roleList(data: { includeDisabled?: boolean, includeSystem?: boolean, employee_id?: number }) {
|
||||
export function roleList(data: { includeDisabled?: boolean, includeSystem?: boolean }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
@ -19,7 +18,10 @@ export function roleList(data: { includeDisabled?: boolean, includeSystem?: bool
|
||||
})
|
||||
}
|
||||
|
||||
export function permissionroleList(data: { role_id?: number, includeDisabled?: boolean, includeSystem?: boolean, employee_id?: number }) {
|
||||
/**
|
||||
* 查询角色权限列表(全量)
|
||||
*/
|
||||
export function permissionroleList(data: { role_id?: number, type?: string, keyword?: string, includeDisabled?: boolean }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
|
||||
@ -83,3 +83,64 @@ export function getStoreRoles(data:any) {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 查询仓货签约列表 */
|
||||
export function storeWarehouseList(data: {
|
||||
counterparty_id?: number
|
||||
auth_status?: number
|
||||
use_status?: number
|
||||
keyword?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storeWarehouse.store.list',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 发起/预览/确认签约 */
|
||||
export function storeWarehouseSign(data: {
|
||||
temp_code?: string
|
||||
action?: 'preview' | 'confirm'
|
||||
counterparty_id?: number
|
||||
remask?: string
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storeWarehouse.store.sign',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 修改签约关系使用状态 */
|
||||
export function storeWarehouseUnbind(data: {
|
||||
id?: number
|
||||
counterparty_id?: number
|
||||
use_status?: number
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storeWarehouse.store.unbind',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ export default {
|
||||
"Material": "Material",
|
||||
"Finance": "Finance",
|
||||
"Warehouse": "Warehouse",
|
||||
"Store": "Store",
|
||||
"stores": "Store",
|
||||
"Express": "Express",
|
||||
"Data": "Data",
|
||||
"Video": "Video",
|
||||
@ -55,6 +55,7 @@ export default {
|
||||
"printTemplate": "Print Template",
|
||||
'Permission': 'Permission',
|
||||
'Role':'Role',
|
||||
// 'StoreIndex':'Store',
|
||||
},
|
||||
"login": {
|
||||
"title": "Login",
|
||||
|
||||
@ -46,7 +46,7 @@ export default {
|
||||
"Material": "耗材",
|
||||
"Finance": "财务",
|
||||
"Warehouse": "仓库",
|
||||
"Store": "货主",
|
||||
"stores": "货主",
|
||||
"Express": "快递",
|
||||
"Data": "数据",
|
||||
"Video": "录像",
|
||||
@ -55,6 +55,8 @@ export default {
|
||||
"printTemplate": "打印模板",
|
||||
'Permission': '权限管理',
|
||||
'Role':'角色管理',
|
||||
// 'StoreIndex':'货主',
|
||||
|
||||
},
|
||||
"login": {
|
||||
"title": "登录",
|
||||
|
||||
@ -15,6 +15,7 @@ export const componentMap: Record<string, any> = {
|
||||
'storage/entry': () => import('@/views/storage/entry/index.vue'),
|
||||
'storage/inventory': () => import('@/views/storage/inventory/index.vue'),
|
||||
'storage/stockout': () => import('@/views/storage/stockout/index.vue'),
|
||||
'store/index': () => import('@/views/store/index.vue'),
|
||||
'role/index': () => import('@/views/system/setting/role/index.vue'),'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'),
|
||||
'system/setting/printTemplate/index': () => import('@/views/system/setting/printTemplate/index.vue'),
|
||||
// 'system/setting/printStation/index': () => import('@/views/system/setting/printStation/index.vue'),
|
||||
|
||||
@ -34,12 +34,19 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<!-- 第二列:收货图片占位 -->
|
||||
<!-- 第二列:收货图片 -->
|
||||
<el-col :span="12">
|
||||
<div class="image-placeholder">
|
||||
<div class="placeholder-content">
|
||||
<el-icon :size="48" color="#909399"><Picture /></el-icon>
|
||||
<p>收货图片占位区</p>
|
||||
<div class="receiving-images">
|
||||
<div v-if="imagesArr.length > 0" class="images-grid">
|
||||
<div v-for="(src, idx) in imagesArr" :key="idx" class="img-cell" @click="handlePreview(src)">
|
||||
<el-image :src="src" fit="cover" style="width:100%; height:100%" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="image-placeholder">
|
||||
<div class="placeholder-content">
|
||||
<el-icon :size="48" color="#909399"><Picture /></el-icon>
|
||||
<p>暂无收货图片</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
@ -57,11 +64,15 @@
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<!-- 图片预览对话框 -->
|
||||
<el-dialog v-model="previewVisible" title="图片预览" width="60%" append-to-body>
|
||||
<img :src="dialogImageUrl" alt="预览" style="width: 100%; max-height: 70vh; object-fit: contain;" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { ref, onMounted, watch, computed } from 'vue'
|
||||
import { availableFields, detailpanel } from '../receiving-config'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Picture, Check, Refresh } from '@element-plus/icons-vue'
|
||||
@ -107,6 +118,26 @@ const handleReset = () => {
|
||||
ElMessage.info('表单已重置')
|
||||
}
|
||||
|
||||
// 图片预览
|
||||
const dialogImageUrl = ref('')
|
||||
const previewVisible = ref(false)
|
||||
|
||||
const imagesArr = computed(() => {
|
||||
const r = props.row || {}
|
||||
const imgs = r.images || []
|
||||
if (!Array.isArray(imgs)) return []
|
||||
return imgs.map((it: any) => {
|
||||
if (!it) return ''
|
||||
if (typeof it === 'string') return it
|
||||
return it.file_url || it.url || it.path || ''
|
||||
}).filter((s: string) => !!s)
|
||||
})
|
||||
|
||||
const handlePreview = (src: string) => {
|
||||
dialogImageUrl.value = src
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
// 监听 row 变化,更新表单数据
|
||||
watch(() => props.row, (newRow) => {
|
||||
if (newRow) {
|
||||
@ -166,6 +197,23 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.receiving-images {
|
||||
.images-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.img-cell {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid #eef2f6;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
flex-shrink: 0;
|
||||
text-align: right;
|
||||
|
||||
@ -3,8 +3,13 @@
|
||||
<div class="header-actions">
|
||||
<div class="left-actions">
|
||||
<el-button size="small" @click="loadProductData">刷新</el-button>
|
||||
<el-radio-group v-model="matchFilter" size="small" style="margin: 0 12px;">
|
||||
<el-radio-button label="all">全部</el-radio-button>
|
||||
<el-radio-button label="matched">已匹配</el-radio-button>
|
||||
<el-radio-button label="unmatched">未匹配</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button size="small" type="primary" disabled>批量操作</el-button>
|
||||
<el-button size="small" disabled>导出</el-button>
|
||||
<!-- <el-button size="small" disabled>导出</el-button> -->
|
||||
</div>
|
||||
<div class="right-actions">
|
||||
<!-- 可以在这里添加搜索框或其他操作 -->
|
||||
@ -13,7 +18,7 @@
|
||||
|
||||
<div class="left-col">
|
||||
<UpperTable
|
||||
:data="tableData"
|
||||
:data="filteredTableData"
|
||||
:columns="productquick"
|
||||
:show-selection="true"
|
||||
:pagination="pagination"
|
||||
@ -27,10 +32,10 @@
|
||||
<template #column-images="{ row }">
|
||||
<div class="image-slot">
|
||||
<el-image
|
||||
v-if="row.images"
|
||||
v-if="row.images || row.image"
|
||||
style="width: 40px; height: 40px"
|
||||
:src="row.images"
|
||||
:preview-src-list="[row.images]"
|
||||
:src="row.images || row.image"
|
||||
:preview-src-list="[row.images || row.image]"
|
||||
fit="cover"
|
||||
/>
|
||||
<span v-else>--</span>
|
||||
@ -46,9 +51,62 @@
|
||||
{{ formatProductStorageStatus(row.storage_status).text }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-match_status="{ row }">
|
||||
<el-tag
|
||||
:type="row.system_product_id ? 'success' : 'info'"
|
||||
size="small"
|
||||
effect="light"
|
||||
>
|
||||
{{ row.system_product_id ? '已匹配' : '未匹配' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-actions="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="handleQuickLink(row)"
|
||||
>
|
||||
快速关联
|
||||
</el-button>
|
||||
</template>
|
||||
</UpperTable>
|
||||
</div>
|
||||
|
||||
<!-- 快速关联弹窗 -->
|
||||
<div v-if="quickLinkVisible" class="product-window quick-link-window" :class="{ 'is-fullscreen': isQuickFullscreen }" :style="quickLinkStyle">
|
||||
<div class="window-header" @mousedown="startQuickDrag">
|
||||
<span class="window-title">快速关联 - {{ currentRow?.item_name || currentRow?.product_name }}</span>
|
||||
<div class="window-actions">
|
||||
<el-button link :icon="isQuickFullscreen ? CopyDocument : FullScreen" @click="isQuickFullscreen = !isQuickFullscreen" :title="isQuickFullscreen ? '还原' : '最大化'" />
|
||||
<el-button link :icon="Close" @click="quickLinkVisible = false" title="关闭" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body">
|
||||
<div class="quick-link-content">
|
||||
<el-alert title="请选择需要关联的系统商品" type="info" :closable="false" show-icon style="margin-bottom: 15px;" />
|
||||
<!-- 这里可以放置商品搜索和选择列表 -->
|
||||
<div class="search-section">
|
||||
<el-input v-model="quickSearchQuery" placeholder="输入商品名称或条码搜索" class="search-input">
|
||||
<template #append>
|
||||
<el-button :icon="Search">搜索</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<div class="system-product-list">
|
||||
<!-- 占位,实际开发中会是一个表格 -->
|
||||
<el-empty description="暂无系统商品数据,请搜索或关联" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body-bottom">
|
||||
<el-button size="small" @click="quickLinkVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="confirmQuickLink" disabled>完成关联</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右键菜单 -->
|
||||
<div v-if="menuVisible" :style="{ top: menuTop + 'px', left: menuLeft + 'px' }" class="context-menu">
|
||||
<div class="menu-item" @click="handleProductDetail">货品详情</div>
|
||||
@ -108,7 +166,7 @@
|
||||
import { ref, onMounted, onUnmounted, computed, reactive, watch } from 'vue'
|
||||
import { productdetail, productquick, productsnapshop, windowtopbar, formatProductStorageStatus } from '../receiving-config'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { FullScreen, Close, CopyDocument } from '@element-plus/icons-vue'
|
||||
import { FullScreen, Close, CopyDocument, Search } from '@element-plus/icons-vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as receivingApi from '@/api/storage/receiving'
|
||||
|
||||
@ -242,6 +300,16 @@ const props = defineProps<{
|
||||
const tableData = ref<any[]>([])
|
||||
const multipleSelection = ref<any[]>([])
|
||||
const saveLoading = ref(false)
|
||||
const matchFilter = ref('all')
|
||||
|
||||
const filteredTableData = computed(() => {
|
||||
if (matchFilter.value === 'matched') {
|
||||
return tableData.value.filter(item => !!item.system_product_id)
|
||||
} else if (matchFilter.value === 'unmatched') {
|
||||
return tableData.value.filter(item => !item.system_product_id)
|
||||
}
|
||||
return tableData.value
|
||||
})
|
||||
|
||||
// 分页相关
|
||||
const pagination = reactive({
|
||||
@ -254,13 +322,13 @@ const queryTime = ref(0)
|
||||
|
||||
// 监听外部数据变化
|
||||
watch(() => props.productData, (newVal) => {
|
||||
if (newVal && newVal.length > 0) {
|
||||
// 始终将父组件传入的数据同步到表格,空数组也应清空表格数据
|
||||
if (Array.isArray(newVal)) {
|
||||
tableData.value = [...newVal]
|
||||
pagination.total = props.productTotal || newVal.length
|
||||
} else if (!props.loading) {
|
||||
// 只有在非加载状态下且没有数据时才使用模拟数据
|
||||
// tableData.value = [...mockProductData]
|
||||
// pagination.total = mockProductData.length
|
||||
pagination.total = props.productTotal ?? newVal.length
|
||||
} else {
|
||||
tableData.value = []
|
||||
pagination.total = props.productTotal ?? 0
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
@ -356,6 +424,14 @@ const position = ref({ x: 350, y: 250 })
|
||||
const isDragging = ref(false)
|
||||
const dragOffset = ref({ x: 0, y: 0 })
|
||||
|
||||
// 快速关联弹窗控制
|
||||
const quickLinkVisible = ref(false)
|
||||
const isQuickFullscreen = ref(false)
|
||||
const quickPosition = ref({ x: 250, y: 150 })
|
||||
const isQuickDragging = ref(false)
|
||||
const quickDragOffset = ref({ x: 0, y: 0 })
|
||||
const quickSearchQuery = ref('')
|
||||
|
||||
const windowStyle = computed(() => {
|
||||
if (isFullscreen.value) return {}
|
||||
return {
|
||||
@ -364,6 +440,14 @@ const windowStyle = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const quickLinkStyle = computed(() => {
|
||||
if (isQuickFullscreen.value) return {}
|
||||
return {
|
||||
top: `${quickPosition.value.y}px`,
|
||||
left: `${quickPosition.value.x}px`
|
||||
}
|
||||
})
|
||||
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
@ -390,6 +474,20 @@ const handleProductDetail = () => {
|
||||
closeMenu()
|
||||
}
|
||||
|
||||
// 快速关联逻辑
|
||||
const handleQuickLink = (row: any) => {
|
||||
currentRow.value = row
|
||||
quickLinkVisible.value = true
|
||||
quickPosition.value = { x: 300, y: 150 }
|
||||
isQuickFullscreen.value = false
|
||||
quickSearchQuery.value = row.product_name || row.item_name || ''
|
||||
}
|
||||
|
||||
const confirmQuickLink = () => {
|
||||
ElMessage.success('关联成功')
|
||||
quickLinkVisible.value = false
|
||||
}
|
||||
|
||||
const toggleFullscreen = () => {
|
||||
isFullscreen.value = !isFullscreen.value
|
||||
}
|
||||
@ -420,6 +518,32 @@ const stopDrag = () => {
|
||||
window.removeEventListener('mouseup', stopDrag)
|
||||
}
|
||||
|
||||
// 快速关联弹窗拖拽
|
||||
const startQuickDrag = (e: MouseEvent) => {
|
||||
if (isQuickFullscreen.value) return
|
||||
isQuickDragging.value = true
|
||||
quickDragOffset.value = {
|
||||
x: e.clientX - quickPosition.value.x,
|
||||
y: e.clientY - quickPosition.value.y
|
||||
}
|
||||
window.addEventListener('mousemove', onQuickDrag)
|
||||
window.addEventListener('mouseup', stopQuickDrag)
|
||||
}
|
||||
|
||||
const onQuickDrag = (e: MouseEvent) => {
|
||||
if (!isQuickDragging.value) return
|
||||
quickPosition.value = {
|
||||
x: Math.max(0, e.clientX - quickDragOffset.value.x),
|
||||
y: Math.max(0, e.clientY - quickDragOffset.value.y)
|
||||
}
|
||||
}
|
||||
|
||||
const stopQuickDrag = () => {
|
||||
isQuickDragging.value = false
|
||||
window.removeEventListener('mousemove', onQuickDrag)
|
||||
window.removeEventListener('mouseup', stopQuickDrag)
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
if (activeWindowTab.value === 'basic' && basicRef.value) {
|
||||
basicRef.value.reset?.()
|
||||
@ -590,7 +714,26 @@ onUnmounted(() => {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.quick-link-content {
|
||||
padding: 20px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.search-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.system-product-list {
|
||||
flex: 1;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background-color: #fafafa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.context-menu {
|
||||
position: fixed;
|
||||
@ -623,6 +766,12 @@ onUnmounted(() => {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.left-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.left-col {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
@ -1,17 +1,9 @@
|
||||
<template>
|
||||
<div class="storage-receiving-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
width="320px"
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:preset-tree="presetTree"
|
||||
:available-fields="availableFieldsRef"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
@submit="handleSubmit"
|
||||
/>
|
||||
<scan-box ref="scanBox" width="320px" :tree-props="{ children: 'children', label: 'label' }" :auto-submit="false"
|
||||
:initial-conditions="initialConditions" :preset-tree="presetTree" :available-fields="availableFieldsRef"
|
||||
@condition-change="handleConditionChange" @reset="handleConditionReset" @condition-clear="handleConditionClear"
|
||||
@submit="handleSubmit" />
|
||||
|
||||
<div class="main-content">
|
||||
<div class="toolbar">
|
||||
@ -19,18 +11,18 @@
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<el-button size="small" @click="handleCreateReceiving">新建收货单</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-delete" @click="confirmcomplete" title="入库单入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
入库单入库
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-delete" @click="confirmcomplete" title="一键入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
一键入库
|
||||
</el-button>
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
入库单入库
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-delete" @click="confirmcomplete" title="一键入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
一键入库
|
||||
</el-button>
|
||||
<el-button size="small" :disabled="!hasSelection" @click="confirmBatchCancel">批量作废</el-button>
|
||||
<el-button type="info" size="small" icon="el-icon-printer" @click="handleOpenPrintDialog" title="打印收货单"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
打印收货单
|
||||
</el-button>
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
打印收货单
|
||||
</el-button>
|
||||
<el-button size="small" :loading="exportLoading" @click="handleExport">导出</el-button>
|
||||
</div>
|
||||
|
||||
@ -40,52 +32,50 @@
|
||||
</div>
|
||||
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="收货单列表"
|
||||
:data="list"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="pagination"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:show-selection="true"
|
||||
:loading="loading"
|
||||
:queryTime="queryTime"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@sort-change="handleSortChange"
|
||||
@refresh="loadData"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<upper-table ref="upperTable" title="收货单列表" :data="list" :columns="columns" :table-size="tableSize"
|
||||
:pagination="pagination" :show-index="true" :show-actions="true" :show-selection="true" :loading="loading"
|
||||
:queryTime="queryTime" @current-change="handleRowClick" @page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange" @sort-change="handleSortChange" @refresh="loadData"
|
||||
@selection-change="onSelectionChange">
|
||||
<template #column-status="{ row }">
|
||||
<el-tag v-if="row.status" :type="statusConfig[row.status as keyof typeof statusConfig]?.tagType || 'info'" size="small">
|
||||
<el-tag v-if="row.status" :type="statusConfig[row.status as keyof typeof statusConfig]?.tagType || 'info'"
|
||||
size="small">
|
||||
{{ statusConfig[row.status as keyof typeof statusConfig]?.text || row.status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-detail_status="{ row }">
|
||||
<el-tag v-if="row.detail_status" :type="detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.tagType || 'info'" size="small">
|
||||
<el-tag v-if="row.detail_status"
|
||||
:type="detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.tagType || 'info'"
|
||||
size="small">
|
||||
{{ detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-storage_status="{ row }">
|
||||
<el-tag v-if="row.storage_status" :type="storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.tagType || 'info'" size="small">
|
||||
{{ storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status }}
|
||||
<el-tag v-if="row.storage_status"
|
||||
:type="storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.tagType || 'info'"
|
||||
size="small">
|
||||
{{ storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status
|
||||
}}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-delivery_method="{ row }">
|
||||
<el-tag v-if="row.delivery_method" :type="deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.tagType || 'info'" size="small">
|
||||
{{ deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text || row.delivery_method }}
|
||||
<el-tag v-if="row.delivery_method"
|
||||
:type="deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.tagType || 'info'"
|
||||
size="small">
|
||||
{{ deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text ||
|
||||
row.delivery_method }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-loading_method="{ row }">
|
||||
<el-tag v-if="row.loading_method" :type="loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.tagType || 'info'" size="small">
|
||||
{{ loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method }}
|
||||
<el-tag v-if="row.loading_method"
|
||||
:type="loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.tagType || 'info'"
|
||||
size="small">
|
||||
{{ loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method
|
||||
}}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@ -107,17 +97,9 @@
|
||||
|
||||
<div class="detail-container">
|
||||
<KeepAlive>
|
||||
<component
|
||||
:is="activeComponent"
|
||||
:id="selectedReceivingId"
|
||||
:row="selectedRow"
|
||||
:product-data="productData"
|
||||
:product-total="productTotal"
|
||||
:loading="productLoading"
|
||||
@refresh-product="loadProductData"
|
||||
@page-change="handleProductPageChange"
|
||||
@page-size-change="handleProductSizeChange"
|
||||
/>
|
||||
<component :is="activeComponent" :id="selectedReceivingId" :row="selectedRow" :product-data="productData"
|
||||
:product-total="productTotal" :loading="productLoading" @refresh-product="loadProductData"
|
||||
@page-change="handleProductPageChange" @page-size-change="handleProductSizeChange" />
|
||||
</KeepAlive>
|
||||
</div>
|
||||
</div>
|
||||
@ -130,26 +112,17 @@
|
||||
</div>
|
||||
|
||||
<!-- 打印对话框 -->
|
||||
<el-dialog
|
||||
v-model="printDialogVisible"
|
||||
title="批量打印收货单"
|
||||
width="1135px"
|
||||
custom-class="print-dialog"
|
||||
>
|
||||
<el-dialog v-model="printDialogVisible" title="批量打印收货单" width="1135px" custom-class="print-dialog">
|
||||
<div class="print-dialog-layout">
|
||||
<!-- 左侧待打印列表 -->
|
||||
<div class="print-batch-list">
|
||||
<div class="list-title">打印队列 ({{ selectionRows.length }})</div>
|
||||
<div
|
||||
v-for="(row, index) in selectionRows"
|
||||
:key="row.id"
|
||||
class="batch-item"
|
||||
:class="{ active: currentPrintIndex === index }"
|
||||
@click="switchPrintItem(index)"
|
||||
>
|
||||
<div v-for="(row, index) in selectionRows" :key="row.id" class="batch-item"
|
||||
:class="{ active: currentPrintIndex === index }" @click="switchPrintItem(index)">
|
||||
<span class="item-index">{{ index + 1 }}</span>
|
||||
<span class="item-number">{{ row.receiving_number }}</span>
|
||||
<el-tag size="small" :type="printStatusMap[row.id] === 'done' ? 'success' : printStatusMap[row.id] === 'error' ? 'danger' : 'info'">
|
||||
<el-tag size="small"
|
||||
:type="printStatusMap[row.id] === 'done' ? 'success' : printStatusMap[row.id] === 'error' ? 'danger' : 'info'">
|
||||
{{ printStatusMap[row.id] === 'done' ? '已打印' : printStatusMap[row.id] === 'error' ? '失败' : '待打印' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
@ -172,15 +145,9 @@
|
||||
|
||||
<!-- 模板画布预览 -->
|
||||
<div class="print-canvas-area">
|
||||
<div v-if="previewInfo.width && previewInfo.height"
|
||||
class="preview-page"
|
||||
:style="{ width: previewInfo.width + 'mm', height: previewInfo.height + 'mm', position: 'relative' }"
|
||||
>
|
||||
<div
|
||||
v-for="(item, idx) in previewObjects"
|
||||
:key="item.id"
|
||||
:style="computePreviewItemStyle(item, idx)"
|
||||
>
|
||||
<div v-if="previewInfo.width && previewInfo.height" class="preview-page"
|
||||
:style="{ width: previewInfo.width + 'mm', height: previewInfo.height + 'mm', position: 'relative' }">
|
||||
<div v-for="(item, idx) in previewObjects" :key="item.id" :style="computePreviewItemStyle(item, idx)">
|
||||
<template v-if="item.type === 'text'">
|
||||
<span>{{ getPreviewValue(item) }}</span>
|
||||
</template>
|
||||
@ -190,25 +157,29 @@
|
||||
<template v-else-if="item.type === 'qrcode'">
|
||||
<img
|
||||
:src="'https://ye4s.wms.gztbyc.com/qrcode/build?text=' + encodeURIComponent(getPreviewValue(item) || '')"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; object-fit: contain;"
|
||||
/>
|
||||
alt="" style="width: 100%; height: 100%; object-fit: contain;" />
|
||||
</template>
|
||||
<template v-else-if="item.type === 'image'">
|
||||
<img :src="item.content" alt="" style="width: 100%; height: 100%; object-fit: fill;" />
|
||||
</template>
|
||||
<template v-else-if="item.type === 'table'">
|
||||
<table style="border: 1px solid #000; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0" width="100%" height="auto">
|
||||
<table style="border: 1px solid #000; border-collapse: collapse;" border="1" cellspacing="0"
|
||||
cellpadding="0" width="100%" height="auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<td v-for="c in item.rows" :key="c.id" :style="{ width: c.width + 'mm', fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.headerHeight || 4) + 'mm' }">{{ c.title }}</td>
|
||||
<td v-for="c in item.rows" :key="c.id"
|
||||
:style="{ width: c.width + 'mm', fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.headerHeight || 4) + 'mm' }">
|
||||
{{ c.title }}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- 如果有 details 数据则遍历显示,否则显示一行占位 -->
|
||||
<tr v-for="(detailItem, dIdx) in (printForm.details && printForm.details.length ? printForm.details : [printForm])" :key="dIdx">
|
||||
<td v-for="c in item.rows" :key="c.id + '_v'" :style="{ fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.rowHeight || 4) + 'mm' }">
|
||||
{{ detailItem[c.field_code] || '' }}
|
||||
<tr
|
||||
v-for="(detailItem, dIdx) in (printForm.details && printForm.details.length ? printForm.details : [printForm])"
|
||||
:key="dIdx">
|
||||
<td v-for="c in item.rows" :key="c.id + '_v'"
|
||||
:style="{ fontSize: '3mm', textAlign: 'center', border: '1px solid #000', height: (item.rowHeight || 4) + 'mm' }">
|
||||
{{ detailItem[c.field_code] || '' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -231,29 +202,25 @@
|
||||
<div>
|
||||
<el-button @click="printDialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="printing" @click="doPrint">
|
||||
{{ currentPrintIndex < selectionRows.length - 1 ? '打印并切换下一个' : '打印当前单据' }}
|
||||
</el-button>
|
||||
{{ currentPrintIndex < selectionRows.length - 1 ? '打印并切换下一个' : '打印当前单据' }} </el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 新建收货单对话框 -->
|
||||
<el-dialog
|
||||
v-model="createDialogVisible"
|
||||
title="新建收货单"
|
||||
width="600px"
|
||||
align-center
|
||||
@closed="handleCreateDialogClosed"
|
||||
>
|
||||
<el-dialog v-model="createDialogVisible" title="新建收货单" width="600px" align-center
|
||||
@closed="handleCreateDialogClosed">
|
||||
<el-form :model="createForm" label-width="100px" size="small">
|
||||
<el-row :gutter="20">
|
||||
<el-col v-for="field in addReceivingFieldsRef" :key="field.prop" :span="field.type === 'textarea' ? 24 : 12">
|
||||
<el-form-item :label="field.label">
|
||||
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]" :placeholder="'请选择' + field.label" style="width: 100%" :filterable="field.filterable">
|
||||
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]"
|
||||
:placeholder="'请选择' + field.label" style="width: 100%" :filterable="field.filterable">
|
||||
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3" :placeholder="'请输入' + field.label" />
|
||||
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3"
|
||||
:placeholder="'请输入' + field.label" />
|
||||
<el-input v-else v-model="createForm[field.prop]" :placeholder="'请输入' + field.label" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -269,6 +236,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed, watch, h } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
@ -297,6 +265,10 @@ import JsBarcode from 'jsbarcode'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const route = useRoute()
|
||||
|
||||
// 用于将初始条件传入 ScanBox(用于根据 URL 参数填充)
|
||||
const initialConditions = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
|
||||
const presetTree = ref<any[]>([])
|
||||
@ -321,6 +293,8 @@ const selectedReceivingId = ref<number | string | null>(null)
|
||||
const quickSearch = ref('')
|
||||
const currentSort = reactive({ prop: '', order: '' })
|
||||
const currentCondition = ref<any>(null)
|
||||
// 保存原始条件(可能包含 operator 等信息)
|
||||
const currentConditionRaw = ref<any>(null)
|
||||
|
||||
const componentMap: Record<string, any> = {
|
||||
details: Details,
|
||||
@ -336,8 +310,27 @@ const selectedRow = computed(() => {
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
// 先加载筛选相关数据(例如 store options、presetTree),保证 ScanBox options 可用
|
||||
loadFilterData()
|
||||
|
||||
// 如果 URL 带有 id 参数,则构建初始筛选条件并应用
|
||||
const idParam = route.query.id || route.query.receiving_number || route.query.q
|
||||
const id = Array.isArray(idParam) ? idParam[0] : idParam
|
||||
if (id) {
|
||||
// 设置 ScanBox 的初始条件以在 UI 中显示
|
||||
initialConditions.value = {
|
||||
type: 'custom',
|
||||
conditions: {
|
||||
receiving_number: { value: String(id), operator: 'eq', field: 'receiving_number', type: 'text' }
|
||||
}
|
||||
}
|
||||
|
||||
// 直接使用包含 operator 的完整条件触发搜索(避免丢失 operator)
|
||||
handleConditionChange(initialConditions.value)
|
||||
} else {
|
||||
// 无 URL 参数时正常加载列表
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
@ -398,8 +391,48 @@ async function loadFilterData() {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeToWhere(condition: any) {
|
||||
if (!condition) return {}
|
||||
|
||||
// 如果是字符串或简单值,直接返回为搜索值
|
||||
if (typeof condition === 'string' || typeof condition === 'number') {
|
||||
return { receiving_number: condition }
|
||||
}
|
||||
|
||||
// 如果来自 ScanBox 的 preset(包含 conditions)
|
||||
if (condition.conditions && typeof condition.conditions === 'object') {
|
||||
const where: any = {}
|
||||
Object.keys(condition.conditions).forEach(k => {
|
||||
const c = condition.conditions[k]
|
||||
where[k] = c && c.value !== undefined ? c.value : c
|
||||
})
|
||||
return where
|
||||
}
|
||||
|
||||
// 普通自定义条件对象,键 -> { value, operator, ... }
|
||||
if (typeof condition === 'object') {
|
||||
const where: any = {}
|
||||
Object.keys(condition).forEach(k => {
|
||||
const c = condition[k]
|
||||
if (c && c.value !== undefined) {
|
||||
where[k] = c.value
|
||||
} else {
|
||||
where[k] = c
|
||||
}
|
||||
})
|
||||
return where
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
function handleConditionChange(condition: any) {
|
||||
currentCondition.value = condition // 保存完整条件(含 operator),供 loadData 使用
|
||||
// 保留原始条件(含 operator)以备需要
|
||||
currentConditionRaw.value = condition
|
||||
|
||||
// 将复杂条件规范化为后端期望的 where 映射
|
||||
currentCondition.value = normalizeToWhere(condition)
|
||||
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
@ -444,12 +477,16 @@ const productData = ref<any[]>([])
|
||||
const productLoading = ref(false)
|
||||
const productTotal = ref(0)
|
||||
const productPagination = reactive({ currentPage: 1, pageSize: 20 })
|
||||
// 用于取消过期请求的版本号,解决快速切换行时的竞态条件
|
||||
const productLoadVersion = ref(0)
|
||||
|
||||
async function handleRowClick(row: any) {
|
||||
selectedReceivingId.value = row?.id || null
|
||||
// 切换行时立即清空明细数据,并递增版本号使旧请求结果失效
|
||||
productData.value = []
|
||||
productTotal.value = 0
|
||||
|
||||
if (!selectedReceivingId.value) {
|
||||
productData.value = []
|
||||
productTotal.value = 0
|
||||
return
|
||||
}
|
||||
// 重置分页
|
||||
@ -458,39 +495,46 @@ async function handleRowClick(row: any) {
|
||||
}
|
||||
|
||||
async function loadProductData() {
|
||||
const version = ++productLoadVersion.value
|
||||
productLoading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const params = {
|
||||
id: selectedReceivingId.value,
|
||||
pagination: {
|
||||
page: productPagination.currentPage,
|
||||
pageSize: productPagination.pageSize
|
||||
pagination: {
|
||||
page: productPagination.currentPage,
|
||||
pageSize: productPagination.pageSize
|
||||
}
|
||||
}
|
||||
const res: any = await receivingApi.getReceivingDetail(params)
|
||||
// 版本不匹配说明用户已切换到其他行,丢弃此响应避免覆盖新数据
|
||||
if (version !== productLoadVersion.value) return
|
||||
if (res && res.code === 200 && res.data) {
|
||||
// 这里的路径需要匹配实际返回的数据结构 res.data.receiving.details
|
||||
// 兼容多种返回结构:res.data.receiving.details / res.data.list / res.data.details
|
||||
const receivingData = res.data.receiving || {}
|
||||
if (Array.isArray(receivingData.details)) {
|
||||
productData.value = receivingData.details
|
||||
productTotal.value = receivingData.pagination?.total || receivingData.details.length || 0
|
||||
} else {
|
||||
// 兼容处理
|
||||
productData.value = []
|
||||
productTotal.value = 0
|
||||
}
|
||||
const details = Array.isArray(receivingData.details)
|
||||
? receivingData.details
|
||||
: Array.isArray(res.data.list)
|
||||
? res.data.list
|
||||
: Array.isArray(res.data.details)
|
||||
? res.data.details
|
||||
: []
|
||||
const total = receivingData.pagination?.total ?? res.data.pagination?.total ?? details.length
|
||||
|
||||
productData.value = details
|
||||
productTotal.value = total
|
||||
} else {
|
||||
productData.value = []
|
||||
productTotal.value = 0
|
||||
}
|
||||
} catch (e) {
|
||||
if (version !== productLoadVersion.value) return
|
||||
console.error('获取收货单详情失败', e)
|
||||
productData.value = []
|
||||
productTotal.value = 0
|
||||
} finally {
|
||||
productLoading.value = false
|
||||
// queryTime.value = Date.now() - start // 这里queryTime是给主表的,子表可能需要单独传
|
||||
if (version === productLoadVersion.value) {
|
||||
productLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -690,7 +734,7 @@ async function handleOpenPrintDialog() {
|
||||
ElMessage.warning(`只有“已完成”状态的单据才能打印。当前选中包含 ${invalidRows.length} 个非已完成单据。`)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// 重置打印状态
|
||||
currentPrintIndex.value = 0
|
||||
printStatusMap.value = {}
|
||||
@ -730,37 +774,37 @@ async function loadPrintFormData(index: number) {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// 2. 清空旧明细字段
|
||||
const detailFields = ['product_name', 'barcode', 'box_quantity', 'boxes_per_pallet', 'actual_quantity', 'remark']
|
||||
detailFields.forEach(f => formData[f] = '')
|
||||
|
||||
// 3. 获取详情填充第一个商品的明细(如果有的话)
|
||||
try {
|
||||
const res: any = await receivingApi.getReceivingDetail({
|
||||
const res: any = await receivingApi.getReceivingDetail({
|
||||
id: mainRow.id,
|
||||
pagination: { page: 1, pageSize: 1000 }
|
||||
pagination: { page: 1, pageSize: 1000 }
|
||||
})
|
||||
if (res && res.code === 200) {
|
||||
const details = res.data.receiving?.details || []
|
||||
|
||||
|
||||
// 翻译并整理明细列表
|
||||
const processedDetails = details.map((item: any) => {
|
||||
const newItem = { ...item }
|
||||
// 尝试对明细字段进行翻译(如果有配置)
|
||||
const detailConfig = printFormConfig.find(g => g.group === '商品明细')
|
||||
if (detailConfig) {
|
||||
detailConfig.fields.forEach((field: any) => {
|
||||
const val = newItem[field.prop]
|
||||
if (field.type === 'select' && field.options) {
|
||||
const opt = field.options.find((o: any) => o.value === val)
|
||||
newItem[field.prop] = opt ? opt.label : val
|
||||
} else if (val === undefined || val === null) {
|
||||
newItem[field.prop] = ''
|
||||
}
|
||||
})
|
||||
}
|
||||
return newItem
|
||||
const newItem = { ...item }
|
||||
// 尝试对明细字段进行翻译(如果有配置)
|
||||
const detailConfig = printFormConfig.find(g => g.group === '商品明细')
|
||||
if (detailConfig) {
|
||||
detailConfig.fields.forEach((field: any) => {
|
||||
const val = newItem[field.prop]
|
||||
if (field.type === 'select' && field.options) {
|
||||
const opt = field.options.find((o: any) => o.value === val)
|
||||
newItem[field.prop] = opt ? opt.label : val
|
||||
} else if (val === undefined || val === null) {
|
||||
newItem[field.prop] = ''
|
||||
}
|
||||
})
|
||||
}
|
||||
return newItem
|
||||
})
|
||||
|
||||
// 将明细列表挂载到 formData,通常命名为 details 以便模板遍历
|
||||
@ -807,10 +851,10 @@ async function loadPrintOptions() {
|
||||
for (const node of nodes) {
|
||||
if (node.type !== 'category') {
|
||||
// 保存原始节点数据,特别是 template_content 等后端需要的字段
|
||||
result.push({
|
||||
result.push({
|
||||
...node,
|
||||
id: node.id,
|
||||
name: node.title || node.name || node.template_name || String(node.id)
|
||||
id: node.id,
|
||||
name: node.title || node.name || node.template_name || String(node.id)
|
||||
})
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
@ -832,7 +876,7 @@ async function handleStationChange(val: string | number) {
|
||||
printSettings.printer = ''
|
||||
printerOptions.value = []
|
||||
if (!val) return
|
||||
|
||||
|
||||
printerLoading.value = true
|
||||
try {
|
||||
const res: any = await stationApi.getComputerPrinter(String(val))
|
||||
@ -912,23 +956,23 @@ async function confirmcomplete() {
|
||||
ElMessage.warning('请先选择要操作的收货单')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量完成 ${selectionRows.value.length} 个收货单的收货吗?`, '确认完成', { type: 'success' })
|
||||
|
||||
|
||||
for (const row of selectionRows.value) {
|
||||
console.log('正在执行完成收货,请求数据:', { id: row.id, type: 'complete' })
|
||||
// 传递 id 标识单号,以及 type: 'complete' 来表示完成收货操作(补全请求数据)
|
||||
const res: any = await receivingApi.completeReceiving({ id: row.id, type: 'complete' })
|
||||
console.log('完成收货接口返回数据:', res)
|
||||
|
||||
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success(`收货单 ${row.receiving_number} 已完成`)
|
||||
} else {
|
||||
ElMessage.error(`收货单 ${row.receiving_number} 操作失败: ${res.message || '系统错误'}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
selectionRows.value = []
|
||||
loadData()
|
||||
} catch (e) {
|
||||
@ -944,19 +988,19 @@ async function confirmBatchCancel() {
|
||||
ElMessage.warning('请先选择要操作的收货单')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个收货单吗?`, '确认作废', { type: 'warning' })
|
||||
|
||||
|
||||
const ids = selectionRows.value.map(row => row.id)
|
||||
const res: any = await receivingApi.batchCancelReceiving({ ids })
|
||||
|
||||
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('批量作废成功')
|
||||
} else {
|
||||
ElMessage.error(res.message || '批量作废失败')
|
||||
}
|
||||
|
||||
|
||||
selectionRows.value = []
|
||||
loadData()
|
||||
} catch (e) {
|
||||
@ -982,55 +1026,97 @@ function printReceiving() {
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
if (list.value.length === 0) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
if (selectionRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要导出的收货单')
|
||||
return
|
||||
}
|
||||
exportLoading.value = true
|
||||
try {
|
||||
// 1. 准备表头
|
||||
const headers = columns.value.map(col => col.label)
|
||||
|
||||
// 2. 准备数据行,应用配置中的 formatter(如果有)
|
||||
const data = list.value.map(row => {
|
||||
return columns.value.map(col => {
|
||||
if (col.formatter && typeof col.formatter === 'function') {
|
||||
return col.formatter(row)
|
||||
}
|
||||
|
||||
const val = row[col.prop]
|
||||
|
||||
// 针对特定字段进行硬编码翻译(如果 formatter 没处理)
|
||||
if (col.prop === 'status') {
|
||||
return statusConfig[val as keyof typeof statusConfig]?.text || val
|
||||
}
|
||||
if (col.prop === 'detail_status') {
|
||||
return detailStatusConfig[val as keyof typeof detailStatusConfig]?.text || val
|
||||
}
|
||||
if (col.prop === 'storage_status') {
|
||||
return storageStatusConfig[val as keyof typeof storageStatusConfig]?.text || val
|
||||
}
|
||||
if (col.prop === 'delivery_method') {
|
||||
return deliveryMethodConfig[val]?.text || val
|
||||
}
|
||||
if (col.prop === 'loading_method') {
|
||||
return loadingMethodConfig[val]?.text || val
|
||||
}
|
||||
|
||||
return val === null || val === undefined ? '' : val
|
||||
// 遍历勾选的收货单,每个收货单生成一个 excel 文件
|
||||
for (const row of selectionRows.value) {
|
||||
const productExportData: any[] = [] // 商品明细行
|
||||
const receivingExportData: any[] = [] // 收货单摘要行(无明细时回退)
|
||||
|
||||
// 收货单摘要行(按 receivingColumns 字段)
|
||||
receivingExportData.push({
|
||||
'收货单号': row.receiving_number,
|
||||
'收货状态': statusConfig[row.status as keyof typeof statusConfig]?.text || row.status || '',
|
||||
'匹配状态': detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status || '',
|
||||
'入库状态': storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status || '',
|
||||
'货主': row.store_name || '',
|
||||
'商品种类': row.total_items ?? '',
|
||||
'总数量': row.total_quantity ?? '',
|
||||
'总箱数': row.total_boxes ?? '',
|
||||
'总托盘数': row.total_pallets ?? '',
|
||||
'车牌号': row.license_plate || '',
|
||||
'物流单号': row.tracking_number || '',
|
||||
'来货方式': deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text || row.delivery_method || '',
|
||||
'装卸方式': loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method || '',
|
||||
'创建人': row.creator_name || '',
|
||||
'收货开始': row.receiving_start_time || '',
|
||||
'收货结束': row.receiving_end_time || '',
|
||||
'创建时间': row.created_at || '',
|
||||
'备注': row.remark || ''
|
||||
})
|
||||
})
|
||||
|
||||
// 3. 创建工作簿和工作表
|
||||
const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
|
||||
const wb = XLSX.utils.book_new()
|
||||
XLSX.utils.book_append_sheet(wb, ws, '收货单列表')
|
||||
// 获取该收货单的商品明细
|
||||
try {
|
||||
const res: any = await receivingApi.getReceivingDetail({
|
||||
id: row.id,
|
||||
pagination: { page: 1, pageSize: 10000 }
|
||||
})
|
||||
|
||||
// 4. 导出文件
|
||||
const fileName = `收货单列表_${new Date().getTime()}.xlsx`
|
||||
XLSX.writeFile(wb, fileName)
|
||||
|
||||
ElMessage.success('导出成功')
|
||||
if (res && res.code === 200 && res.data) {
|
||||
// 兼容多种返回结构
|
||||
const receivingData = res.data.receiving || {}
|
||||
const list = Array.isArray(receivingData.details)
|
||||
? receivingData.details
|
||||
: Array.isArray(res.data.list)
|
||||
? res.data.list
|
||||
: Array.isArray(res.data.details)
|
||||
? res.data.details
|
||||
: []
|
||||
|
||||
// 按 productquick 列导出商品明细,附带收货单号作为关联
|
||||
list.forEach((item: any) => {
|
||||
productExportData.push({
|
||||
'收货单号': row.receiving_number,
|
||||
'货主': row.store_name || '',
|
||||
'商品名称': item.product_name || '',
|
||||
'条码': item.barcode || '',
|
||||
'匹配状态': item.system_product_id ? '已匹配' : '未匹配',
|
||||
'实收数量': item.actual_quantity ?? '',
|
||||
'箱数': item.box_quantity ?? '',
|
||||
'箱规': item.boxes_per_pallet ?? '',
|
||||
'批次号': item.batch_number || '',
|
||||
'生产日期': item.production_date || '',
|
||||
'有效期': item.expiry_date || '',
|
||||
'入库状态': storageStatusConfig[item.storage_status as keyof typeof storageStatusConfig]?.text || item.storage_status || '',
|
||||
'库位': item.space_id || '',
|
||||
'备注': item.remark || ''
|
||||
})
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(`获取收货单 ${row.receiving_number} 商品明细失败,跳过`, e)
|
||||
}
|
||||
|
||||
// 优先导出商品明细;若该收货单无明细,则回退导出收货单摘要
|
||||
const exportData = productExportData.length > 0 ? productExportData : receivingExportData
|
||||
const sheetName = productExportData.length > 0 ? '收货单商品明细' : '收货单摘要'
|
||||
|
||||
if (exportData.length > 0) {
|
||||
const ws = XLSX.utils.json_to_sheet(exportData)
|
||||
const wb = XLSX.utils.book_new()
|
||||
XLSX.utils.book_append_sheet(wb, ws, sheetName)
|
||||
|
||||
// 文件名使用收货单号
|
||||
const fileName = `${row.receiving_number}.xlsx`
|
||||
XLSX.writeFile(wb, fileName)
|
||||
}
|
||||
}
|
||||
|
||||
ElMessage.success('导出完成')
|
||||
} catch (e) {
|
||||
console.error('导出 Excel 失败:', e)
|
||||
ElMessage.error('导出失败')
|
||||
@ -1062,10 +1148,11 @@ async function handleExport() {
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap:15px;
|
||||
gap: 15px;
|
||||
height: 30px;
|
||||
align-items: center;
|
||||
}
|
||||
@ -1095,18 +1182,20 @@ async function handleExport() {
|
||||
padding: 0 10px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
background-color: #fafafa;
|
||||
|
||||
|
||||
.detail-tab {
|
||||
margin-bottom: -1px;
|
||||
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__nav-wrap::after) {
|
||||
height: 1px;
|
||||
}
|
||||
@ -1129,9 +1218,15 @@ async function handleExport() {
|
||||
color: #909399;
|
||||
background-color: #fff;
|
||||
|
||||
.empty-tip { text-align: center;
|
||||
font-size: 14px;
|
||||
.el-icon { font-size: 48px; margin-bottom: 10px;} }
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
|
||||
.el-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1168,14 +1263,25 @@ async function handleExport() {
|
||||
border-bottom: 1px dotted #eee;
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover { background-color: #f0f7ff; }
|
||||
&:hover {
|
||||
background-color: #f0f7ff;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: #e6f7ff;
|
||||
border-left: 3px solid #1890ff;
|
||||
}
|
||||
|
||||
.item-index { color: #999; font-size: 12px; }
|
||||
.item-number { flex: 1; font-weight: 500; font-family: monospace; }
|
||||
.item-index {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.item-number {
|
||||
flex: 1;
|
||||
font-weight: 500;
|
||||
font-family: monospace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1195,7 +1301,10 @@ async function handleExport() {
|
||||
background-color: #fafafa;
|
||||
flex-shrink: 0;
|
||||
|
||||
.el-select { flex: 1; min-width: 130px; }
|
||||
.el-select {
|
||||
flex: 1;
|
||||
min-width: 130px;
|
||||
}
|
||||
}
|
||||
|
||||
.print-canvas-area {
|
||||
|
||||
@ -63,6 +63,15 @@ export function formatDateTime(dateStr: string): string {
|
||||
|
||||
export const receivingColumns = [
|
||||
{ prop: 'receiving_number', label: '收货单号', width: '110', fixed: 'left' },
|
||||
{
|
||||
prop: 'images',
|
||||
label: '收货图片',
|
||||
width: '120',
|
||||
align: 'center',
|
||||
imgs: (row: any) => {
|
||||
return row.images || []
|
||||
}
|
||||
},
|
||||
{ prop: 'status', label: '收货状态', width: '90', align: 'center' },
|
||||
{ prop: 'detail_status', label: '匹配状态', width: '90', align: 'center' },
|
||||
{ prop: 'storage_status', label: '入库状态', width: '90', align: 'center' },
|
||||
@ -269,8 +278,10 @@ export const productdetail = [
|
||||
]
|
||||
|
||||
export const productquick = [
|
||||
{ prop: 'images', label: '图片', width: '80', align: 'center', fixed: 'left' },
|
||||
{ prop: 'product_name', label: '商品名称', width: '200', fixed: 'left' },
|
||||
{ prop: 'barcode', label: '条码', width: '150' },
|
||||
{ prop: 'match_status', label: '匹配状态', width: '100', align: 'center' },
|
||||
{ prop: 'actual_quantity', label: '收货数量', width: '100', align: 'right' },
|
||||
{ prop: 'box_quantity', label: '箱数', width: '100', align: 'right' },
|
||||
{ prop: 'boxes_per_pallet', label: '箱规', width: '100', align: 'right' },
|
||||
@ -280,6 +291,7 @@ export const productquick = [
|
||||
{ prop: 'storage_status', label: '入库', width: '80', align: 'center' },
|
||||
{ prop: 'space_id', label: '库位', width: '120' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' },
|
||||
{ prop: 'actions', label: '操作', width: '120', align: 'center', fixed: 'right' },
|
||||
]
|
||||
|
||||
|
||||
|
||||
623
src/views/store/index.vue
Normal file
623
src/views/store/index.vue
Normal file
@ -0,0 +1,623 @@
|
||||
<template>
|
||||
<div class="store-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
width="320px"
|
||||
title="货主筛选"
|
||||
:preset-tree="presetTree"
|
||||
:available-fields="availableFields"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleReset"
|
||||
/>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" @click="openSignDialog">
|
||||
<el-icon><Plus /></el-icon> 发起签约
|
||||
</el-button>
|
||||
<el-button size="small" @click="loadList">
|
||||
<el-icon><Refresh /></el-icon> 刷新
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<el-input
|
||||
v-model="queryForm.keyword"
|
||||
placeholder="搜索主体名或备注"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleSearch"
|
||||
>
|
||||
<template #prefix>
|
||||
<el-icon><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="tableRef"
|
||||
:data="list"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handleSizeChange"
|
||||
>
|
||||
<template #column-counterparty_name="{ row }">
|
||||
<span>{{ row.store_remask }}</span>
|
||||
<span v-if="row.store_remask && row.store_remask !== row.store_name" class="real-name">({{ row.store_name }})</span>
|
||||
</template>
|
||||
<template #column-current_subject_role="{ row }">
|
||||
<el-tag size="small" :type="row.current_subject_role === 'warehouse' ? 'primary' : 'warning'" effect="light">
|
||||
{{ row.current_subject_role === 'warehouse' ? '仓库方' : '货主方' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #column-auth_status="{ row }">
|
||||
<el-tag size="small" :type="getAuthStatusType(row.auth_status)" effect="light">
|
||||
{{ row.auth_status_label || getAuthStatusLabel(row.auth_status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #column-use_status="{ row }">
|
||||
<el-tag size="small" :type="row.use_status === 1 ? 'success' : 'info'" effect="light">
|
||||
{{ row.use_status === 1 ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #column-is_auth_valid="{ row }">
|
||||
<el-tag size="small" :type="row.is_auth_valid ? 'success' : 'warning'" effect="plain">
|
||||
{{ row.is_auth_valid ? '有效' : '无效' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #column-remaining_days="{ row }">
|
||||
<span :class="row.remaining_days <= 7 && row.remaining_days > 0 ? 'text-warning' : ''">
|
||||
{{ row.remaining_days > 0 ? row.remaining_days + '天' : '—' }}
|
||||
</span>
|
||||
</template>
|
||||
<template #column-apply_time="{ row }">
|
||||
{{ formatDate(row.apply_time) }}
|
||||
</template>
|
||||
<template #column-actions="{ row }">
|
||||
<el-button
|
||||
v-if="row.use_status === 1"
|
||||
size="small"
|
||||
type="danger"
|
||||
link
|
||||
@click.stop="handleUnbind(row, 0)"
|
||||
>解约</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
size="small"
|
||||
type="success"
|
||||
link
|
||||
@click.stop="handleUnbind(row, 1)"
|
||||
>启用</el-button>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
|
||||
<div class="detail-panel" v-if="selectedRow">
|
||||
<div class="panel-header">
|
||||
<span>签约单详情:{{ selectedRow.id }}</span>
|
||||
<div class="header-ops">
|
||||
<el-button size="small" type="primary" @click="handleViewDetail(selectedRow)">更多详情</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<el-descriptions :column="3" border size="small">
|
||||
<el-descriptions-item label="签约ID">{{ selectedRow.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="当前角色">
|
||||
<el-tag size="small" :type="selectedRow.current_subject_role === 'warehouse' ? 'primary' : 'warning'">
|
||||
{{ selectedRow.current_subject_role === 'warehouse' ? '仓库方' : '货主方' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="签约状态">
|
||||
<el-tag size="small" :type="getAuthStatusType(selectedRow.auth_status)">
|
||||
{{ selectedRow.auth_status_label }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货主">{{ selectedRow.store_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ selectedRow.remask || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请时间">{{ formatDate(selectedRow.apply_time) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="授权有效期" :span="2">
|
||||
{{ formatDate(selectedRow.auth_start) }} 至 {{ formatDate(selectedRow.auth_end) }} ({{ selectedRow.remaining_days }}天)
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="审核意见">{{ selectedRow.review_comment || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
<div class="detail-panel empty" v-else>
|
||||
<el-empty description="请选择数据查看详情" :image-size="60" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 发起签约弹窗 -->
|
||||
<el-dialog
|
||||
v-model="signDialog.visible"
|
||||
:title="signDialog.title"
|
||||
width="480px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="resetSignDialog"
|
||||
>
|
||||
<!-- Step 1: 发起 -->
|
||||
<template v-if="signDialog.step === 1">
|
||||
<el-form :model="signForm" label-width="100px" size="small">
|
||||
<el-form-item label="对方主体ID" required>
|
||||
<el-input v-model.number="signForm.counterparty_id" placeholder="请输入对方主体ID" />
|
||||
</el-form-item>
|
||||
<el-form-item label="通用名备注">
|
||||
<el-input v-model="signForm.remask" placeholder="给对方主体的通用名称(可选)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<!-- Step 2: 预览/确认 -->
|
||||
<template v-else-if="signDialog.step === 2">
|
||||
<div class="sign-preview">
|
||||
<el-descriptions :column="1" border size="small">
|
||||
<el-descriptions-item label="临时码">
|
||||
<el-tag type="info" size="small">{{ signDialog.tempCode }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="signDialog.contract" label="签约ID">
|
||||
{{ signDialog.contract.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="signDialog.contract" label="货主">
|
||||
{{ signDialog.contract.store_name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="signDialog.contract" label="仓库">
|
||||
{{ signDialog.contract.warehouse_name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="signDialog.contract" label="签约状态">
|
||||
<el-tag size="small" :type="getAuthStatusType(signDialog.contract.auth_status)">
|
||||
{{ signDialog.contract.auth_status_label }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div v-if="signDialog.mode === 'initiate'" class="sign-tip">
|
||||
<el-alert type="info" :closable="false" show-icon>
|
||||
<template #default>已生成临时码,点击「预览」可查看签约详情,点击「确认签约」立即生效。</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
<div v-else-if="signDialog.mode === 'confirm'" class="sign-tip">
|
||||
<el-alert type="success" :closable="false" show-icon>
|
||||
<template #default>签约已确认生效!</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<!-- Step 1 底部 -->
|
||||
<template v-if="signDialog.step === 1">
|
||||
<el-button size="small" @click="signDialog.visible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="signDialog.loading" @click="doInitiateSign">
|
||||
发起签约
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- Step 2 底部 -->
|
||||
<template v-else-if="signDialog.step === 2">
|
||||
<el-button size="small" @click="signDialog.visible = false">关闭</el-button>
|
||||
<el-button
|
||||
v-if="signDialog.mode === 'initiate'"
|
||||
size="small"
|
||||
:loading="signDialog.loading"
|
||||
@click="doPreviewSign"
|
||||
>预览</el-button>
|
||||
<el-button
|
||||
v-if="signDialog.mode !== 'confirm'"
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="signDialog.loading"
|
||||
@click="doConfirmSign"
|
||||
>确认签约</el-button>
|
||||
<el-button
|
||||
v-if="signDialog.mode === 'confirm'"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="handleSignSuccess"
|
||||
>完成</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 详情弹窗 -->
|
||||
<el-dialog
|
||||
v-model="detailDialog.visible"
|
||||
title="签约详情"
|
||||
width="560px"
|
||||
align-center
|
||||
>
|
||||
<el-descriptions v-if="detailDialog.row" :column="2" border size="small">
|
||||
<el-descriptions-item label="签约ID">{{ detailDialog.row.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="当前角色">
|
||||
<el-tag size="small" :type="detailDialog.row.current_subject_role === 'warehouse' ? 'primary' : 'warning'" effect="light">
|
||||
{{ detailDialog.row.current_subject_role === 'warehouse' ? '仓库方' : '货主方' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货主名称">{{ detailDialog.row.store_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="货主备注">{{ detailDialog.row.store_remask || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库名称">{{ detailDialog.row.warehouse_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库备注">{{ detailDialog.row.warehouse_remask || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="签约状态">
|
||||
<el-tag size="small" :type="getAuthStatusType(detailDialog.row.auth_status)" effect="light">
|
||||
{{ detailDialog.row.auth_status_label || getAuthStatusLabel(detailDialog.row.auth_status) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="使用状态">
|
||||
<el-tag size="small" :type="detailDialog.row.use_status === 1 ? 'success' : 'info'" effect="light">
|
||||
{{ detailDialog.row.use_status === 1 ? '启用' : '禁用' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="授权有效">
|
||||
<el-tag size="small" :type="detailDialog.row.is_auth_valid ? 'success' : 'warning'" effect="plain">
|
||||
{{ detailDialog.row.is_auth_valid ? '有效' : '无效' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="剩余天数">{{ detailDialog.row.remaining_days > 0 ? detailDialog.row.remaining_days + '天' : '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="授权开始">{{ formatDate(detailDialog.row.auth_start) || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="授权截止">{{ formatDate(detailDialog.row.auth_end) || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请原因" :span="2">{{ detailDialog.row.apply_reason || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核意见" :span="2">{{ detailDialog.row.review_comment || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="申请时间">{{ formatDate(detailDialog.row.apply_time) || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ formatDate(detailDialog.row.review_time) || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="打印次数">{{ detailDialog.row.print_quantity }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{ detailDialog.row.remask || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="detailDialog.visible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search, Plus, Refresh } from '@element-plus/icons-vue'
|
||||
import { storeWarehouseList, storeWarehouseSign, storeWarehouseUnbind } from '@/api/store'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree } from './store-config'
|
||||
|
||||
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
||||
const loading = ref(false)
|
||||
const list = ref<any[]>([])
|
||||
const selectedRow = ref<any>(null)
|
||||
const tableRef = ref<any>(null)
|
||||
const scanBox = ref<any>(null)
|
||||
|
||||
const pagination = reactive({ page: 1, page_size: 20, total: 0 })
|
||||
const queryForm = reactive<{
|
||||
keyword: string
|
||||
auth_status: number | undefined
|
||||
use_status: number | undefined
|
||||
}>({ keyword: '', auth_status: undefined, use_status: undefined })
|
||||
|
||||
const columns = ref(defaultColumns)
|
||||
const availableFields = reactive(defaultAvailableFields)
|
||||
const presetTree = ref<any[]>(defaultPresetTree)
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const params: any = {
|
||||
page: pagination.page,
|
||||
page_size: pagination.page_size,
|
||||
...currentCondition.value
|
||||
}
|
||||
if (queryForm.keyword) params.keyword = queryForm.keyword
|
||||
|
||||
const res = await storeWarehouseList(params) as any
|
||||
if (res?.data) {
|
||||
list.value = res.data.list || []
|
||||
pagination.total = res.data.total || 0
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error('获取列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const currentCondition = ref<any>({})
|
||||
function handleConditionChange(condition: any) {
|
||||
const where: any = {}
|
||||
|
||||
// 处理 ScanBox 的自定义筛选条件
|
||||
if (condition) {
|
||||
Object.keys(condition).forEach(k => {
|
||||
const c = condition[k]
|
||||
// ScanBox 传出的是 { value, operator } 或直接是值
|
||||
if (c && typeof c === 'object' && c.value !== undefined) {
|
||||
if (c.value !== '' && c.value !== null) {
|
||||
where[k] = c.value
|
||||
}
|
||||
} else if (c !== '' && c !== null && c !== undefined) {
|
||||
where[k] = c
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
currentCondition.value = where
|
||||
pagination.page = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
queryForm.keyword = ''
|
||||
currentCondition.value = {}
|
||||
if (scanBox.value?.reset) scanBox.value.reset()
|
||||
pagination.page = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
pagination.page = page
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handleSizeChange(size: number) {
|
||||
pagination.page_size = size
|
||||
pagination.page = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handleRowClick(row: any) {
|
||||
selectedRow.value = row
|
||||
}
|
||||
|
||||
// ─── 状态辅助 ────────────────────────────────────────────────────────────────
|
||||
function getAuthStatusType(status: number) {
|
||||
const map: Record<number, string> = { 1: 'warning', 2: 'success', 3: 'danger', 4: 'info' }
|
||||
return (map[status] || 'info') as any
|
||||
}
|
||||
|
||||
function getAuthStatusLabel(status: number) {
|
||||
const map: Record<number, string> = { 1: '待审核', 2: '已通过', 3: '已拒绝', 4: '已终止' }
|
||||
return map[status] || '未知'
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string | null | undefined) {
|
||||
if (!dateStr) return ''
|
||||
return new Date(dateStr).toLocaleString('zh-CN', { hour12: false }).replace(/\//g, '-')
|
||||
}
|
||||
|
||||
// ─── 禁用/启用 ────────────────────────────────────────────────────────────────
|
||||
async function handleUnbind(row: any, targetStatus: number) {
|
||||
const actionLabel = targetStatus === 0 ? '禁用' : '启用'
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认要${actionLabel}与「${row.counterparty_remask || row.counterparty_name}」的签约关系吗?`,
|
||||
`${actionLabel}签约`,
|
||||
{ type: targetStatus === 0 ? 'warning' : 'info', confirmButtonText: actionLabel, cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await storeWarehouseUnbind({
|
||||
id: row.id,
|
||||
counterparty_id: row.counterparty_id,
|
||||
use_status: targetStatus
|
||||
}) as any
|
||||
if (res?.flag === 'success' || res?.code === 200) {
|
||||
ElMessage.success(`${actionLabel}成功`)
|
||||
loadList()
|
||||
} else {
|
||||
ElMessage.error(res?.message || `${actionLabel}失败`)
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('操作失败')
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 发起签约 ────────────────────────────────────────────────────────────────
|
||||
const signDialog = reactive({
|
||||
visible: false,
|
||||
title: '发起签约',
|
||||
step: 1, // 1=填写信息, 2=临时码/预览/确认
|
||||
loading: false,
|
||||
mode: '', // initiate / preview / confirm
|
||||
tempCode: '',
|
||||
contract: null as any
|
||||
})
|
||||
|
||||
const signForm = reactive({ counterparty_id: undefined as number | undefined, remask: '' })
|
||||
|
||||
function openSignDialog() {
|
||||
resetSignDialog()
|
||||
signDialog.visible = true
|
||||
}
|
||||
|
||||
function resetSignDialog() {
|
||||
signDialog.step = 1
|
||||
signDialog.title = '发起签约'
|
||||
signDialog.loading = false
|
||||
signDialog.mode = ''
|
||||
signDialog.tempCode = ''
|
||||
signDialog.contract = null
|
||||
signForm.counterparty_id = undefined
|
||||
signForm.remask = ''
|
||||
}
|
||||
|
||||
async function doInitiateSign() {
|
||||
if (!signForm.counterparty_id) {
|
||||
ElMessage.warning('请输入对方主体ID')
|
||||
return
|
||||
}
|
||||
signDialog.loading = true
|
||||
try {
|
||||
const res = await storeWarehouseSign({
|
||||
counterparty_id: signForm.counterparty_id,
|
||||
remask: signForm.remask || undefined
|
||||
}) as any
|
||||
if (res?.flag === 'success' || res?.code === 200) {
|
||||
signDialog.mode = res.data?.mode || 'initiate'
|
||||
signDialog.tempCode = res.data?.temp_code || ''
|
||||
signDialog.contract = res.data?.contract || null
|
||||
signDialog.step = 2
|
||||
signDialog.title = '签约预览'
|
||||
} else {
|
||||
ElMessage.error(res?.message || '发起签约失败')
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('发起签约失败')
|
||||
} finally {
|
||||
signDialog.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doPreviewSign() {
|
||||
if (!signDialog.tempCode) return
|
||||
signDialog.loading = true
|
||||
try {
|
||||
const res = await storeWarehouseSign({ temp_code: signDialog.tempCode, action: 'preview' }) as any
|
||||
if (res?.flag === 'success' || res?.code === 200) {
|
||||
signDialog.mode = res.data?.mode || 'preview'
|
||||
signDialog.contract = res.data?.contract || null
|
||||
} else {
|
||||
ElMessage.error(res?.message || '预览失败')
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('预览失败')
|
||||
} finally {
|
||||
signDialog.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doConfirmSign() {
|
||||
if (!signDialog.tempCode) return
|
||||
signDialog.loading = true
|
||||
try {
|
||||
const res = await storeWarehouseSign({ temp_code: signDialog.tempCode, action: 'confirm' }) as any
|
||||
if (res?.flag === 'success' || res?.code === 200) {
|
||||
signDialog.mode = 'confirm'
|
||||
signDialog.contract = res.data?.contract || null
|
||||
signDialog.title = '签约成功'
|
||||
} else {
|
||||
ElMessage.error(res?.message || '确认签约失败')
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('确认签约失败')
|
||||
} finally {
|
||||
signDialog.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSignSuccess() {
|
||||
signDialog.visible = false
|
||||
loadList()
|
||||
}
|
||||
|
||||
// ─── 详情 ────────────────────────────────────────────────────────────────────
|
||||
const detailDialog = reactive({ visible: false, row: null as any })
|
||||
|
||||
function handleViewDetail(row: any) {
|
||||
detailDialog.row = row
|
||||
detailDialog.visible = true
|
||||
}
|
||||
|
||||
// ─── 初始化 ───────────────────────────────────────────────────────────────────
|
||||
onMounted(loadList)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.store-container {
|
||||
display: flex;
|
||||
height: calc(100vh - 100px);
|
||||
width: 100%;
|
||||
background-color: #f0f2f5;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
gap: 10px;
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
|
||||
|
||||
.toolbar-left, .toolbar-right {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
flex: 3;
|
||||
min-height: 300px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.detail-panel {
|
||||
flex: 2;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 1px 6px rgba(0,0,0,0.05);
|
||||
|
||||
&.empty {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
flex: 1;
|
||||
padding: 16px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.real-name {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #e6a23c;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.sign-preview {
|
||||
.sign-tip {
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
42
src/views/store/store-config.ts
Normal file
42
src/views/store/store-config.ts
Normal file
@ -0,0 +1,42 @@
|
||||
export const columns = [
|
||||
{ prop: 'counterparty_name', label: '对方主体', minWidth: 140 },
|
||||
{ prop: 'current_subject_role', label: '当前角色', width: 90, align: 'center' },
|
||||
{ prop: 'auth_status', label: '签约状态', width: 100, align: 'center' },
|
||||
{ prop: 'use_status', label: '使用状态', width: 90, align: 'center' },
|
||||
{ prop: 'is_auth_valid', label: '授权有效', width: 90, align: 'center' },
|
||||
{ prop: 'remaining_days', label: '剩余天数', width: 90, align: 'center' },
|
||||
{ prop: 'apply_time', label: '申请时间', width: 160, align: 'center' },
|
||||
{ prop: 'actions', label: '操作', width: 120, align: 'center', fixed: 'right' }
|
||||
]
|
||||
|
||||
export const availableFields = [
|
||||
{ label: '对方主体', value: 'counterparty_id', type: 'number' },
|
||||
{
|
||||
label: '签约状态',
|
||||
value: 'auth_status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '待审核', value: 1 },
|
||||
{ label: '已通过', value: 2 },
|
||||
{ label: '已拒绝', value: 3 },
|
||||
{ label: '已终止', value: 4 }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '使用状态',
|
||||
value: 'use_status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
export const presetTree: any[] = []
|
||||
|
||||
export default {
|
||||
columns,
|
||||
availableFields,
|
||||
presetTree
|
||||
}
|
||||
@ -305,7 +305,14 @@ const textMap: Record<string, string> = {
|
||||
create: '新增工号'
|
||||
}
|
||||
|
||||
const rules = accountRules
|
||||
const rules = computed(() => {
|
||||
const baseRules = { ...accountRules }
|
||||
// 编辑状态下,手机号不可修改且允许为空(不校验必填)
|
||||
if (dialogStatus.value === 'update') {
|
||||
baseRules.phone = baseRules.phone.filter(r => !r.required)
|
||||
}
|
||||
return baseRules
|
||||
})
|
||||
|
||||
const flattenRoles = (rawRoles: any[]) => {
|
||||
const tempMap = new Map<number, any>()
|
||||
@ -367,7 +374,6 @@ const createData = async () => {
|
||||
await dataForm.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
try {
|
||||
// 按接口文档,accountAdd 需传 phone, real_name, ids(必填), username, password, email
|
||||
const { phone, real_name, username, password, email, role_ids } = temp
|
||||
await accountAdd({ phone, real_name, ids: role_ids, username, password, email })
|
||||
dialogFormVisible.value = false
|
||||
@ -396,9 +402,15 @@ const updateData = async () => {
|
||||
await dataForm.value.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
try {
|
||||
// 按接口文档,accountUpdate 需传 employee_id, real_name, file_id, ids(必填) 等
|
||||
const { employee_id, real_name, file_id, email, role_ids } = temp
|
||||
await accountUpdate({ employee_id: employee_id!, real_name, file_id, email, ids: role_ids })
|
||||
const { employee_id, real_name, file_id, role_ids } = temp
|
||||
// 接口文档 setting.account.update 仅支持 employee_id, real_name, file_id, ids
|
||||
// 手机号 (phone) 在接口中不可修改,因此更新时不传
|
||||
await accountUpdate({
|
||||
employee_id: employee_id!,
|
||||
real_name,
|
||||
file_id,
|
||||
ids: role_ids
|
||||
})
|
||||
dialogFormVisible.value = false
|
||||
ElMessage.success('更新成功')
|
||||
getList()
|
||||
@ -414,7 +426,6 @@ const handleDelete = (row: any) => {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
// 按接口文档,accountdelete 需传 employee_id: number(单个)
|
||||
await accountdelete({ employee_id: row.employee_id })
|
||||
ElMessage.success('已停用')
|
||||
getList()
|
||||
@ -428,7 +439,7 @@ const handleEnable = (row: any) => {
|
||||
type: 'info'
|
||||
}).then(async () => {
|
||||
// 启用时保留原有角色组,ids 必传
|
||||
await accountUpdate({ employee_id: row.employee_id, status: 1, ids: row.role_ids || [] })
|
||||
await accountUpdate({ employee_id: row.employee_id, ids: row.role_ids || [] })
|
||||
ElMessage.success('已启用')
|
||||
getList()
|
||||
})
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="标题" prop="meta_title" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="名称" prop="name" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="组件" prop="component" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="路径 (Path)" prop="path" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column label="类型" prop="type" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
@ -97,6 +98,9 @@
|
||||
<el-form-item label="权限路径" prop="path">
|
||||
<el-input v-model="tempCreate.path" placeholder="必填,如:setting.account.list" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组件" prop="component">
|
||||
<el-input v-model="tempCreate.component" placeholder="组件路径或名称(可选)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="页面标题" prop="meta_title">
|
||||
<el-input v-model="tempCreate.meta_title" placeholder="如:工号管理" />
|
||||
</el-form-item>
|
||||
@ -142,6 +146,9 @@
|
||||
<el-form-item label="权限路径" prop="path">
|
||||
<el-input v-model="tempUpdate.path" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组件" prop="component">
|
||||
<el-input v-model="tempUpdate.component" />
|
||||
</el-form-item>
|
||||
<el-form-item label="权限名称" prop="name">
|
||||
<el-input v-model="tempUpdate.name" />
|
||||
</el-form-item>
|
||||
@ -390,6 +397,7 @@ const createData = async () => {
|
||||
path: tempCreate.path,
|
||||
type: tempCreate.type,
|
||||
name: tempCreate.name,
|
||||
component: tempCreate.component,
|
||||
parent_id: tempCreate.parent_id || 0,
|
||||
meta_title: tempCreate.meta_title,
|
||||
sort: tempCreate.sort
|
||||
@ -418,6 +426,7 @@ const updateData = async () => {
|
||||
path: tempUpdate.path,
|
||||
type: tempUpdate.type,
|
||||
name: tempUpdate.name,
|
||||
component: tempUpdate.component,
|
||||
parent_id: tempUpdate.parent_id || 0,
|
||||
sort: tempUpdate.sort,
|
||||
status: tempUpdate.status
|
||||
|
||||
@ -6,6 +6,7 @@ export const permissionRules = {
|
||||
export const defaultCreateTemp = {
|
||||
parent_id: undefined as number | undefined,
|
||||
type: 'web_pages',
|
||||
component: '',
|
||||
path: '',
|
||||
meta_title: '',
|
||||
name: '',
|
||||
@ -16,6 +17,7 @@ export const defaultUpdateTemp = {
|
||||
permission_id: undefined as number | undefined,
|
||||
parent_id: undefined as number | undefined,
|
||||
type: 'web_pages',
|
||||
component: '',
|
||||
path: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
<el-dialog
|
||||
:title="dialogStatus === 'create' ? '新增角色' : '编辑角色'"
|
||||
v-model="dialogVisible"
|
||||
width="560px"
|
||||
width="600px"
|
||||
align-center
|
||||
@close="handleDialogClose"
|
||||
>
|
||||
@ -108,6 +108,17 @@
|
||||
<el-radio :label="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="分配权限" v-if="dialogStatus === 'create'">
|
||||
<div class="perm-tree-wrapper" v-loading="permLoadingLocal">
|
||||
<el-tree
|
||||
ref="permTreeRef"
|
||||
:data="createPermTree"
|
||||
show-checkbox
|
||||
node-key="permission_id"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
@ -185,7 +196,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
|
||||
import { roleList, roleAdd, roleDelete, roleUpdate,permissionroleList } from '@/api/setting/role'
|
||||
import { roleList, roleAdd, roleDelete, roleUpdate, permissionroleList } from '@/api/setting/role'
|
||||
import { permissionList } from '@/api/setting/permission'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
@ -269,9 +280,8 @@ const getList = async () => {
|
||||
try {
|
||||
const res = await roleList({
|
||||
includeDisabled: listQuery.includeDisabled,
|
||||
includeSystem: true,
|
||||
keyword: listQuery.keyword
|
||||
} as any)
|
||||
includeSystem: true
|
||||
})
|
||||
const raw = res.data?.roles || []
|
||||
|
||||
// 1. Flatten directly and remove duplicates created by backend nesting logic
|
||||
@ -321,7 +331,7 @@ const handleSelectionChange = (val: any[]) => {
|
||||
|
||||
const handleBatchDelete = () => {
|
||||
if (!selectedIds.value.length) return
|
||||
ElMessageBox.confirm('确认删除选中角色吗?(软删除)', '提示', { type: 'warning' }).then(async () => {
|
||||
ElMessageBox.confirm('确认删除选中角色吗?', '提示', { type: 'warning' }).then(async () => {
|
||||
await roleDelete({ ids: selectedIds.value })
|
||||
ElMessage.success('批量删除成功')
|
||||
getList()
|
||||
@ -346,9 +356,13 @@ const temp = reactive({ ...defaultRoleTemp })
|
||||
|
||||
const rules = roleRules
|
||||
|
||||
const permLoadingLocal = ref(false)
|
||||
const createPermTree = ref<any[]>([])
|
||||
const permTreeRef = ref()
|
||||
|
||||
const resetTemp = () => { Object.assign(temp, defaultRoleTemp) }
|
||||
|
||||
const handleCreate = () => {
|
||||
const handleCreate = async () => {
|
||||
resetTemp()
|
||||
dialogStatus.value = 'create'
|
||||
if (currentNodeId.value !== 0) {
|
||||
@ -357,6 +371,18 @@ const handleCreate = () => {
|
||||
temp.pid = undefined
|
||||
}
|
||||
dialogVisible.value = true
|
||||
|
||||
// 获取默认权限(不传 role_id)
|
||||
permLoadingLocal.value = true
|
||||
try {
|
||||
const res = await permissionList({})
|
||||
createPermTree.value = buildPermTree(res.data?.permissions || [])
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
} finally {
|
||||
permLoadingLocal.value = false
|
||||
}
|
||||
|
||||
nextTick(() => dataFormRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
@ -385,12 +411,17 @@ const createData = async () => {
|
||||
if (!valid) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
// 获取选中的权限 ID
|
||||
const checkedKeys = permTreeRef.value?.getCheckedKeys() || []
|
||||
const halfCheckedKeys = permTreeRef.value?.getHalfCheckedKeys() || []
|
||||
const allCheckedKeys = [...checkedKeys, ...halfCheckedKeys]
|
||||
|
||||
await roleAdd({
|
||||
role_code: temp.role_code,
|
||||
role_name: temp.role_name,
|
||||
description: temp.description || undefined,
|
||||
pid: temp.pid || 0,
|
||||
permission_ids: temp.permission_ids
|
||||
permission_ids: allCheckedKeys
|
||||
})
|
||||
ElMessage.success('新增成功')
|
||||
dialogVisible.value = false
|
||||
@ -440,10 +471,14 @@ const selectedPermIds = ref<number[]>([])
|
||||
const permTableRef = ref()
|
||||
|
||||
const permFilter = reactive({ type: '', keyword: '' })
|
||||
const isRestoringSelection = ref(false)
|
||||
|
||||
const buildPermTree = (data: any[]): any[] => {
|
||||
const map = new Map<number, any>()
|
||||
data.forEach(item => { map.set(item.permission_id, { ...item, children: [] }) })
|
||||
// 过滤掉名称为空的权限,确保只显示有意义的权限条目
|
||||
const validData = data.filter(item => item.name && item.name.trim() !== '')
|
||||
|
||||
validData.forEach(item => { map.set(item.permission_id, { ...item, children: [] }) })
|
||||
const roots: any[] = []
|
||||
map.forEach(item => {
|
||||
const pid = item.parent_id
|
||||
@ -463,7 +498,7 @@ const buildPermTree = (data: any[]): any[] => {
|
||||
return roots
|
||||
}
|
||||
|
||||
const applyPermFilter = () => {
|
||||
const applyPermFilter = async () => {
|
||||
const { type, keyword } = permFilter
|
||||
const kw = keyword.trim().toLowerCase()
|
||||
const filtered = allPerms.value.filter(p => {
|
||||
@ -471,12 +506,15 @@ const applyPermFilter = () => {
|
||||
if (kw && ![p.path, p.name, p.meta_title].some(v => v && v.toLowerCase().includes(kw))) return false
|
||||
return true
|
||||
})
|
||||
isRestoringSelection.value = true
|
||||
filteredPerms.value = buildPermTree(filtered)
|
||||
nextTick(() => restorePermSelection())
|
||||
await nextTick()
|
||||
restorePermSelection()
|
||||
}
|
||||
|
||||
const restorePermSelection = () => {
|
||||
if (!permTableRef.value) return
|
||||
isRestoringSelection.value = true
|
||||
permTableRef.value.clearSelection()
|
||||
const selectInTree = (nodes: any[]) => {
|
||||
nodes.forEach(node => {
|
||||
@ -487,9 +525,11 @@ const restorePermSelection = () => {
|
||||
})
|
||||
}
|
||||
selectInTree(filteredPerms.value)
|
||||
isRestoringSelection.value = false
|
||||
}
|
||||
|
||||
const handlePermSelectionChange = (rows: any[]) => {
|
||||
if (isRestoringSelection.value) return
|
||||
// 只更新当前可见节点的选中状态,不影响折叠的节点
|
||||
const flatVisible: any[] = []
|
||||
const flattenFiltered = (nodes: any[]) => {
|
||||
@ -508,11 +548,20 @@ const selectAllPerms = () => {
|
||||
nodes.forEach(n => { flatAll.push(n); if (n.children) flattenAll(n.children) })
|
||||
}
|
||||
flattenAll(filteredPerms.value)
|
||||
flatAll.forEach(n => permTableRef.value?.toggleRowSelection(n, true))
|
||||
const newIds = flatAll.map(n => n.permission_id)
|
||||
selectedPermIds.value = Array.from(new Set([...selectedPermIds.value, ...newIds]))
|
||||
restorePermSelection()
|
||||
}
|
||||
|
||||
const deselectAllPerms = () => {
|
||||
permTableRef.value?.clearSelection()
|
||||
const flatAll: any[] = []
|
||||
const flattenAll = (nodes: any[]) => {
|
||||
nodes.forEach(n => { flatAll.push(n); if (n.children) flattenAll(n.children) })
|
||||
}
|
||||
flattenAll(filteredPerms.value)
|
||||
const removeIds = new Set(flatAll.map(n => n.permission_id))
|
||||
selectedPermIds.value = selectedPermIds.value.filter(id => !removeIds.has(id))
|
||||
restorePermSelection()
|
||||
}
|
||||
|
||||
const handleAssignPermission = async (row: any) => {
|
||||
@ -523,8 +572,13 @@ const handleAssignPermission = async (row: any) => {
|
||||
permDialogVisible.value = true
|
||||
permLoading.value = true
|
||||
try {
|
||||
// 获取所有权限列表
|
||||
const res = await permissionroleList({ role_id: currentRoleId.value ?? undefined })
|
||||
// 获取权限列表(使用 setting.role.permission 接口)
|
||||
const res = await permissionroleList({
|
||||
role_id: currentRoleId.value ?? undefined,
|
||||
type: permFilter.type || undefined,
|
||||
keyword: permFilter.keyword || undefined,
|
||||
includeDisabled: false
|
||||
})
|
||||
allPerms.value = res.data?.permissions || []
|
||||
// 记录已选权限 ID
|
||||
currentRolePermIds.value = allPerms.value.filter((p: any) => p.selected).map((p: any) => p.permission_id)
|
||||
@ -641,6 +695,15 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.perm-tree-wrapper {
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 4px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.perm-tree-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
583
src/接口文档.txt
583
src/接口文档.txt
File diff suppressed because it is too large
Load Diff
228
src/接口文档1.txt
Normal file
228
src/接口文档1.txt
Normal file
@ -0,0 +1,228 @@
|
||||
storage.receiving.getReceivingDetail接口返回以下数据:
|
||||
{
|
||||
"flag": "success",
|
||||
"code": 200,
|
||||
"message": "查询成功",
|
||||
"data": {
|
||||
"receiving": {
|
||||
"id": 137,
|
||||
"receiving_number": "R20546019",
|
||||
"creator_id": 55,
|
||||
"creator_snapshot": "{\"name\":\"陈庆\",\"employees_id\":55,\"id\":55}",
|
||||
"status": "completed",
|
||||
"detail_status": "partial_matched",
|
||||
"storage_status": "none",
|
||||
"delivery_method": "other",
|
||||
"license_plate": null,
|
||||
"tracking_number": null,
|
||||
"loading_method": "without_pallet",
|
||||
"video_device_id": null,
|
||||
"total_items": 4,
|
||||
"total_quantity": 4488,
|
||||
"total_boxes": 26,
|
||||
"total_pallets": 0,
|
||||
"warehouse_id": 1000028,
|
||||
"remark": "【完成收货】4/3/2026, 4:16:23 PM 陈庆",
|
||||
"store_name": "加碗饭",
|
||||
"store_id": 1000167,
|
||||
"receiving_start_time": "2026-04-03T07:56:55.000Z",
|
||||
"receiving_end_time": "2026-04-03T08:16:23.000Z",
|
||||
"is_deleted": false,
|
||||
"created_at": "2026-04-03T07:56:55.000Z",
|
||||
"updated_at": "2026-04-03T08:16:23.000Z",
|
||||
"details": [
|
||||
{
|
||||
"id": 146,
|
||||
"receiving_id": 137,
|
||||
"product_name": "新商品",
|
||||
"barcode": "6975773697976",
|
||||
"product_snapshot": null,
|
||||
"system_product_id": null,
|
||||
"actual_quantity": 2000,
|
||||
"box_quantity": 10,
|
||||
"boxes_per_pallet": 200,
|
||||
"pallet_quantity": 0,
|
||||
"receiving_time": null,
|
||||
"receiving_status": "pending",
|
||||
"storage_status": "none",
|
||||
"stored_quantity": 0,
|
||||
"batch_number": "",
|
||||
"production_date": null,
|
||||
"expiry_date": null,
|
||||
"remark": "",
|
||||
"space_id": 1,
|
||||
"creator_id": "00000000000000000055",
|
||||
"box_width": "0.00",
|
||||
"box_length": "0.00",
|
||||
"box_height": "0.00",
|
||||
"weight": 113,
|
||||
"created_at": "2026-04-03T07:57:57.000Z",
|
||||
"updated_at": "2026-04-03T08:02:58.000Z",
|
||||
"images": [
|
||||
{
|
||||
"id": 89386,
|
||||
"file_id": 108395,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receivingItem",
|
||||
"business_id": "146",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T08:00:56.000Z"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 147,
|
||||
"receiving_id": 137,
|
||||
"product_name": "新商品",
|
||||
"barcode": "6975773697976",
|
||||
"product_snapshot": null,
|
||||
"system_product_id": null,
|
||||
"actual_quantity": 1040,
|
||||
"box_quantity": 13,
|
||||
"boxes_per_pallet": 80,
|
||||
"pallet_quantity": 0,
|
||||
"receiving_time": null,
|
||||
"receiving_status": "pending",
|
||||
"storage_status": "none",
|
||||
"stored_quantity": 0,
|
||||
"batch_number": "",
|
||||
"production_date": null,
|
||||
"expiry_date": null,
|
||||
"remark": "",
|
||||
"space_id": 1,
|
||||
"creator_id": "00000000000000000055",
|
||||
"box_width": "0.00",
|
||||
"box_length": "0.00",
|
||||
"box_height": "0.00",
|
||||
"weight": 396,
|
||||
"created_at": "2026-04-03T08:03:44.000Z",
|
||||
"updated_at": "2026-04-03T08:07:34.000Z",
|
||||
"images": [
|
||||
{
|
||||
"id": 89387,
|
||||
"file_id": 108396,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receivingItem",
|
||||
"business_id": "147",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T08:06:13.000Z"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 148,
|
||||
"receiving_id": 137,
|
||||
"product_name": "新商品",
|
||||
"barcode": "6977375877350",
|
||||
"product_snapshot": null,
|
||||
"system_product_id": null,
|
||||
"actual_quantity": 399,
|
||||
"box_quantity": 1,
|
||||
"boxes_per_pallet": 400,
|
||||
"pallet_quantity": 0,
|
||||
"receiving_time": null,
|
||||
"receiving_status": "pending",
|
||||
"storage_status": "none",
|
||||
"stored_quantity": 0,
|
||||
"batch_number": "",
|
||||
"production_date": null,
|
||||
"expiry_date": null,
|
||||
"remark": "",
|
||||
"space_id": 1,
|
||||
"creator_id": "00000000000000000056",
|
||||
"box_width": "0.00",
|
||||
"box_length": "0.00",
|
||||
"box_height": "0.00",
|
||||
"weight": 52,
|
||||
"created_at": "2026-04-03T08:03:57.000Z",
|
||||
"updated_at": "2026-04-03T08:11:50.000Z",
|
||||
"images": [
|
||||
{
|
||||
"id": 89388,
|
||||
"file_id": 108397,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receivingItem",
|
||||
"business_id": "148",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T08:09:03.000Z"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 149,
|
||||
"receiving_id": 137,
|
||||
"product_name": "加碗饭-雅屏蔚蓝香型香水40ml",
|
||||
"barcode": "6977375877336",
|
||||
"product_snapshot": "{\"store_id\":1000167,\"store_name\":\"加碗饭\",\"updated_at\":\"2026-04-03T08:14:28.330Z\"}",
|
||||
"system_product_id": 143280,
|
||||
"actual_quantity": 1049,
|
||||
"box_quantity": 3,
|
||||
"boxes_per_pallet": 400,
|
||||
"pallet_quantity": 0,
|
||||
"receiving_time": null,
|
||||
"receiving_status": "pending",
|
||||
"storage_status": "none",
|
||||
"stored_quantity": 0,
|
||||
"batch_number": "",
|
||||
"production_date": null,
|
||||
"expiry_date": null,
|
||||
"remark": "",
|
||||
"space_id": 1,
|
||||
"creator_id": "00000000000000000055",
|
||||
"box_width": "0.00",
|
||||
"box_length": "0.00",
|
||||
"box_height": "0.00",
|
||||
"weight": 51,
|
||||
"created_at": "2026-04-03T08:13:40.000Z",
|
||||
"updated_at": "2026-04-03T08:14:28.000Z",
|
||||
"images": [
|
||||
{
|
||||
"id": 89389,
|
||||
"file_id": 108398,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receivingItem",
|
||||
"business_id": "149",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T08:14:11.000Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"id": 89384,
|
||||
"file_id": 108393,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receiving",
|
||||
"business_id": "137",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T07:57:18.000Z"
|
||||
},
|
||||
{
|
||||
"id": 89385,
|
||||
"file_id": 108394,
|
||||
"warehouse_id": 1000028,
|
||||
"business_type": "receiving",
|
||||
"business_id": "137",
|
||||
"display_order": 0,
|
||||
"created_by": "陈庆",
|
||||
"created_at": "2026-04-03T07:57:23.000Z"
|
||||
}
|
||||
],
|
||||
"pagination": {
|
||||
"total": 4,
|
||||
"currentPage": 1,
|
||||
"pageSize": 20,
|
||||
"totalPages": 1,
|
||||
"hasPrevious": false,
|
||||
"hasNext": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timestamp": 1775208054
|
||||
}
|
||||
2039
src/需求文档.txt
2039
src/需求文档.txt
File diff suppressed because it is too large
Load Diff
36
日志.md
36
日志.md
@ -171,4 +171,38 @@ stock获取回收站商品接口复用了商品信息接口stock.warehouse.list
|
||||
|
||||
三、后续计划
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
-----
|
||||
2026.4.2
|
||||
一、今日完成
|
||||
功能:添加权限和角色配置文件,包含验证规则和默认模板
|
||||
|
||||
-创建了 permission-config.ts,用于定义权限规则、创建和更新权限的默认模板,以及权限类型的映射。
|
||||
-创建了 role-config.ts,用于定义角色规则、默认角色模板,以及权限类型的映射。
|
||||
优化账号管理、权限管理、角色管理相关使用逻辑,排除修改送功能设计问题。
|
||||
新增收货单excel导出功能。
|
||||
优化PDA下载使用逻辑。
|
||||
|
||||
二、问题记录
|
||||
无
|
||||
三、后续计划
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
-----
|
||||
2026.4.3
|
||||
一、今日完成
|
||||
-优化收货单页面及相关接口功能。
|
||||
-优化角色管理、权限管理、用户管理,修复接口使用问题。
|
||||
-添加了用于使用临时代码发起和确认合同的对话框。
|
||||
-创建了配置文件 `store-config.ts`,用于表格列和可用筛选字段。
|
||||
-新增“货主”页面及相关接口功能。
|
||||
|
||||
二、问题记录
|
||||
无
|
||||
|
||||
三、后续计划
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
完善收货单、货主功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user