提交
This commit is contained in:
1 parent
33c038b8d9
commit
54b27a3f0e
253 files changed
+30060
-14298
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">出入库管理</h2>
|
||||
<h2 class="title-bar-heading">地磅出入库</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
@@ -34,30 +34,12 @@
|
||||
<el-option v-for="item in statusOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="filterExpanded" id="db-inv-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="车牌号">
|
||||
<el-input v-model="filters.vehicleNo" placeholder="车牌号" clearable @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="车牌号">
|
||||
<el-input v-model="filters.vehicleNo" placeholder="车牌号" clearable @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="filterExpanded"
|
||||
aria-controls="db-inv-filter-extra"
|
||||
@click="filterExpanded = !filterExpanded"
|
||||
>
|
||||
{{ filterExpanded ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="filterExpanded" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-start" />
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleResetFilters">
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
@@ -123,18 +105,12 @@
|
||||
本周
|
||||
</el-button>
|
||||
</div>
|
||||
<el-input
|
||||
<ListQuickSearchInput
|
||||
v-model="searchKeyword"
|
||||
class="db-toolbar-quick-search-input"
|
||||
placeholder="计划号 / 单号 / 往来单位 / 产品 / 车牌"
|
||||
clearable
|
||||
@keyup.enter="handleQuickSearch"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="db-quick-search-icon" @click="handleQuickSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增记录
|
||||
@@ -173,11 +149,7 @@
|
||||
!canDeleteByCreator(selectedRows[0])
|
||||
"
|
||||
:title="
|
||||
selectedRows.length === 1 && !canDeleteRecord(selectedRows[0])
|
||||
? '仅支持删除当天及之后日期的记录'
|
||||
: selectedRows.length === 1 && !canDeleteByCreator(selectedRows[0])
|
||||
? CREATOR_DELETE_TIP
|
||||
: ''
|
||||
selectedRows.length === 1 ? getDeleteRecordDisabledTitle(selectedRows[0]) : ''
|
||||
"
|
||||
@click="handleToolbarDelete"
|
||||
>
|
||||
@@ -428,7 +400,7 @@
|
||||
<el-dialog
|
||||
v-model="modalOpen"
|
||||
:title="editingRecord ? '修改记录' : '新增记录'"
|
||||
width="640px"
|
||||
width="740px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@@ -440,8 +412,9 @@
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="form-grid-2"
|
||||
label-position="right"
|
||||
label-width="100px"
|
||||
class="db-dialog-form form-grid-2"
|
||||
scroll-to-error
|
||||
>
|
||||
<el-form-item label="日期" prop="date">
|
||||
@@ -539,13 +512,7 @@
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="!canDeleteRecord(viewingRecord) || !canDeleteByCreator(viewingRecord)"
|
||||
:title="
|
||||
!canDeleteRecord(viewingRecord)
|
||||
? '仅支持删除当天及之后日期的记录'
|
||||
: canDeleteByCreator(viewingRecord)
|
||||
? ''
|
||||
: CREATOR_DELETE_TIP
|
||||
"
|
||||
:title="viewingRecord ? getDeleteRecordDisabledTitle(viewingRecord) : ''"
|
||||
@click="handleViewDelete"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
@@ -565,8 +532,6 @@
|
||||
*/
|
||||
import type { TableColumnCtx } from 'element-plus'
|
||||
import {
|
||||
ArrowDownBold,
|
||||
ArrowUpBold,
|
||||
Check,
|
||||
Close,
|
||||
CopyDocument,
|
||||
@@ -579,9 +544,11 @@
|
||||
Search,
|
||||
} from '@element-plus/icons-vue'
|
||||
import DbCrmCustomerSelect from '@/components/business/db/DbCrmCustomerSelect.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { canDeleteByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import DbCrmProductSelect from '@/components/business/db/DbCrmProductSelect.vue'
|
||||
import DbInventoryRelatedViewDialog from '@/components/business/db/DbInventoryRelatedViewDialog.vue'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
@@ -657,6 +624,13 @@
|
||||
const relatedData = ref<InventoryRelatedData>({ plan: null, weighing: null })
|
||||
const viewingRecord = ref<InventoryRecord | null>(null)
|
||||
|
||||
async function refreshRelatedViewIfOpen(editedId?: string) {
|
||||
if (!relatedModalOpen.value || !viewingRecord.value?.id) return
|
||||
if (editedId && viewingRecord.value.id !== editedId) return
|
||||
syncViewRowFromFlatList(viewingRecord, allRecords.value)
|
||||
relatedData.value = await inventoryApi.getRelated(viewingRecord.value.id)
|
||||
}
|
||||
|
||||
const filters = reactive({
|
||||
batchNo: '',
|
||||
businessType: '' as '' | '入库' | '出库',
|
||||
@@ -664,7 +638,6 @@
|
||||
vehicleNo: ''
|
||||
})
|
||||
|
||||
const filterExpanded = ref(false)
|
||||
const businessTypeOptions: Array<'入库' | '出库'> = ['入库', '出库']
|
||||
const statusOptions = ['待处理', '待入库', '待出库', '待三方填写', '已完成']
|
||||
|
||||
@@ -995,12 +968,23 @@
|
||||
}
|
||||
|
||||
const canDeleteRecord = (row: InventoryRecord) => {
|
||||
if (row.status === '已完成') return false
|
||||
const dateStr = row.date || ''
|
||||
if (!dateStr) return false
|
||||
return dateStr >= formatYmd(new Date())
|
||||
}
|
||||
|
||||
const getDeleteRecordDisabledTitle = (row: InventoryRecord) => {
|
||||
if (row.status === '已完成') return '已完成的记录不能删除'
|
||||
if (!canDeleteByCreator(row)) return CREATOR_DELETE_TIP
|
||||
return '仅支持删除当天及之后日期的记录,历史数据不可删除'
|
||||
}
|
||||
|
||||
const handleDelete = async (row: InventoryRecord) => {
|
||||
if (row.status === '已完成') {
|
||||
$modal.msgWarning('已完成的记录不能删除')
|
||||
return
|
||||
}
|
||||
if (!canDeleteRecord(row)) {
|
||||
$modal.msgWarning('仅支持删除当天及之后日期的记录,历史数据不可删除')
|
||||
return
|
||||
@@ -1068,6 +1052,7 @@
|
||||
}
|
||||
|
||||
if (editingRecord.value) {
|
||||
const editedId = editingRecord.value.id
|
||||
const updateData = cleanData({
|
||||
date: formData.date,
|
||||
partnerCompany: formData.partnerCompany,
|
||||
@@ -1086,7 +1071,8 @@
|
||||
openedFromPlan.value = false
|
||||
router.replace('/db/plans')
|
||||
} else {
|
||||
loadData()
|
||||
await loadData()
|
||||
await refreshRelatedViewIfOpen(editedId)
|
||||
}
|
||||
} else {
|
||||
const createData: InventoryCreate = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">计划管理</h2>
|
||||
<h2 class="title-bar-heading">地磅计划</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
@@ -119,18 +119,12 @@
|
||||
本周
|
||||
</el-button>
|
||||
</div>
|
||||
<el-input
|
||||
<ListQuickSearchInput
|
||||
v-model="searchKeyword"
|
||||
class="db-toolbar-quick-search-input"
|
||||
placeholder="往来单位 / 计划号 / 产品"
|
||||
clearable
|
||||
@keyup.enter="handleQuickSearch"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="db-quick-search-icon" @click="handleQuickSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增计划
|
||||
@@ -154,8 +148,12 @@
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="selectedRows.length !== 1 || !canDeleteByCreator(selectedRows[0])"
|
||||
:title="selectedRows.length === 1 && !canDeleteByCreator(selectedRows[0]) ? CREATOR_DELETE_TIP : ''"
|
||||
:disabled="
|
||||
selectedRows.length !== 1 ||
|
||||
!canDeletePlanRecord(selectedRows[0]) ||
|
||||
!canDeleteByCreator(selectedRows[0])
|
||||
"
|
||||
:title="selectedRows.length === 1 ? getDeletePlanDisabledTitle(selectedRows[0]) : ''"
|
||||
@click="handleToolbarDelete"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
@@ -356,8 +354,9 @@
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="form-grid-2"
|
||||
label-position="right"
|
||||
label-width="100px"
|
||||
class="db-dialog-form form-grid-2"
|
||||
scroll-to-error
|
||||
>
|
||||
<el-form-item label="计划号" prop="planNo">
|
||||
@@ -474,8 +473,8 @@
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="!canDeleteByCreator(viewingRecord)"
|
||||
:title="canDeleteByCreator(viewingRecord) ? '' : CREATOR_DELETE_TIP"
|
||||
:disabled="!canDeletePlanRecord(viewingRecord) || !canDeleteByCreator(viewingRecord)"
|
||||
:title="viewingRecord ? getDeletePlanDisabledTitle(viewingRecord) : ''"
|
||||
@click="handleViewDelete"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
@@ -504,6 +503,7 @@
|
||||
Search,
|
||||
} from '@element-plus/icons-vue'
|
||||
import DbCrmCustomerSelect from '@/components/business/db/DbCrmCustomerSelect.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import DbCrmProductSelect from '@/components/business/db/DbCrmProductSelect.vue'
|
||||
@@ -511,6 +511,7 @@
|
||||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||||
import { $modal } from '@/utils/modal'
|
||||
import { canDeleteByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import {
|
||||
planApi,
|
||||
type Plan,
|
||||
@@ -832,6 +833,14 @@
|
||||
const loadingRelated = ref(false)
|
||||
const viewingRecord = ref<Plan | null>(null)
|
||||
|
||||
async function refreshRelatedViewIfOpen(editedId?: string) {
|
||||
if (!relatedModalOpen.value || !viewingRecord.value?.id) return
|
||||
if (editedId && viewingRecord.value.id !== editedId) return
|
||||
const records = await fetchFilteredPlans()
|
||||
syncViewRowFromFlatList(viewingRecord, records)
|
||||
relatedData.value = await planApi.getRelated(viewingRecord.value.id)
|
||||
}
|
||||
|
||||
const handleView = async (record: Plan) => {
|
||||
viewingRecord.value = record
|
||||
loadingRelated.value = true
|
||||
@@ -875,7 +884,23 @@
|
||||
relatedModalOpen.value = false
|
||||
}
|
||||
|
||||
const executionCompletedStatuses = ['已入库', '已出库']
|
||||
|
||||
const canDeletePlanRecord = (row: Plan) => {
|
||||
return !row.executionStatus || !executionCompletedStatuses.includes(row.executionStatus)
|
||||
}
|
||||
|
||||
const getDeletePlanDisabledTitle = (row: Plan) => {
|
||||
if (!canDeletePlanRecord(row)) return '已完成的计划不能删除'
|
||||
if (!canDeleteByCreator(row)) return CREATOR_DELETE_TIP
|
||||
return ''
|
||||
}
|
||||
|
||||
const handleDelete = async (row: Plan) => {
|
||||
if (!canDeletePlanRecord(row)) {
|
||||
$modal.msgWarning('已完成的计划不能删除')
|
||||
return
|
||||
}
|
||||
if (!canDeleteByCreator(row)) {
|
||||
$modal.msgWarning(CREATOR_DELETE_TIP)
|
||||
return
|
||||
@@ -960,14 +985,18 @@
|
||||
}
|
||||
|
||||
if (editingPlan.value) {
|
||||
const editedId = editingPlan.value.id
|
||||
await planApi.update(editingPlan.value.id, payload as PlanUpdate)
|
||||
$modal.msgSuccess('更新成功')
|
||||
modalOpen.value = false
|
||||
await loadData()
|
||||
await refreshRelatedViewIfOpen(editedId)
|
||||
} else {
|
||||
await planApi.create(payload as PlanCreate)
|
||||
$modal.msgSuccess('创建成功')
|
||||
modalOpen.value = false
|
||||
loadData()
|
||||
}
|
||||
modalOpen.value = false
|
||||
loadData()
|
||||
} catch (error) {
|
||||
console.error('保存计划失败', error)
|
||||
} finally {
|
||||
|
||||
@@ -32,30 +32,12 @@
|
||||
<el-form-item label="供货单位">
|
||||
<el-input v-model="filters.supplier" placeholder="供货单位" clearable @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="filterExpanded" id="db-weigh-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="收货单位">
|
||||
<el-input v-model="filters.consignee" placeholder="收货单位" clearable @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="收货单位">
|
||||
<el-input v-model="filters.consignee" placeholder="收货单位" clearable @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="filterExpanded"
|
||||
aria-controls="db-weigh-filter-extra"
|
||||
@click="filterExpanded = !filterExpanded"
|
||||
>
|
||||
{{ filterExpanded ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="filterExpanded" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-start" />
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleResetFilters">
|
||||
<el-icon><RefreshLeft /></el-icon>
|
||||
@@ -121,25 +103,19 @@
|
||||
本周
|
||||
</el-button>
|
||||
</div>
|
||||
<el-input
|
||||
<ListQuickSearchInput
|
||||
v-model="searchKeyword"
|
||||
class="db-toolbar-quick-search-input"
|
||||
placeholder="车牌号 / 货物 / 计划号 / 出入库单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuickSearch"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="db-quick-search-icon" @click="handleQuickSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增地磅单
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
:disabled="selectedRows.length !== 1"
|
||||
:disabled="selectedRows.length !== 1 || selectedRows[0]?.isVoided === 1"
|
||||
@click="handleToolbarEdit"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>
|
||||
@@ -395,8 +371,9 @@
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="form-grid-2"
|
||||
label-position="right"
|
||||
label-width="100px"
|
||||
class="db-dialog-form form-grid-2"
|
||||
scroll-to-error
|
||||
>
|
||||
<el-form-item label="车牌号" prop="vehicleNo">
|
||||
@@ -522,7 +499,12 @@
|
||||
:sections="relatedViewSections"
|
||||
>
|
||||
<template v-if="viewingRecord" #hero-actions>
|
||||
<el-button class="btn-main" type="primary" @click="handleEdit(viewingRecord)">
|
||||
<el-button
|
||||
v-if="viewingRecord.isVoided === 0"
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
@click="handleEdit(viewingRecord)"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>
|
||||
编辑
|
||||
</el-button>
|
||||
@@ -548,8 +530,6 @@
|
||||
*/
|
||||
import type { TableColumnCtx } from 'element-plus'
|
||||
import {
|
||||
ArrowDownBold,
|
||||
ArrowUpBold,
|
||||
Check,
|
||||
Close,
|
||||
Download,
|
||||
@@ -559,6 +539,7 @@
|
||||
Search,
|
||||
} from '@element-plus/icons-vue'
|
||||
import DbCrmCustomerSelect from '@/components/business/db/DbCrmCustomerSelect.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import DbCrmProductSelect from '@/components/business/db/DbCrmProductSelect.vue'
|
||||
@@ -566,6 +547,7 @@
|
||||
import { buildWeighingRelatedSections } from '@/components/business/db/db-related-view'
|
||||
import PlVehicleSelect from '@/components/business/pl/PlVehicleSelect.vue'
|
||||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import { $modal } from '@/utils/modal'
|
||||
import { inventoryApi } from '@/api/db/inventory'
|
||||
import { planApi } from '@/api/db/plans'
|
||||
@@ -627,7 +609,6 @@
|
||||
businessType: '' as '' | '入库' | '出库'
|
||||
})
|
||||
|
||||
const filterExpanded = ref(false)
|
||||
const businessTypeOptions: Array<'入库' | '出库'> = ['入库', '出库']
|
||||
|
||||
const pad2 = (n: number) => String(n).padStart(2, '0')
|
||||
@@ -645,6 +626,13 @@
|
||||
const relatedData = ref<WeighingRelatedData>({ plan: null, inventory: null })
|
||||
const viewingRecord = ref<WeighingRecord | null>(null)
|
||||
|
||||
async function refreshRelatedViewIfOpen(editedId?: string) {
|
||||
if (!relatedModalOpen.value || !viewingRecord.value?.id) return
|
||||
if (editedId && viewingRecord.value.id !== editedId) return
|
||||
syncViewRowFromFlatList(viewingRecord, allData.value)
|
||||
relatedData.value = await weighingApi.getRelated(viewingRecord.value.id)
|
||||
}
|
||||
|
||||
const relatedViewSections = computed(() => buildWeighingRelatedSections(relatedData.value))
|
||||
|
||||
const formRef = ref()
|
||||
@@ -1013,6 +1001,7 @@
|
||||
if (!valid) return
|
||||
saving.value = true
|
||||
try {
|
||||
let editedId: string | undefined
|
||||
const hasGrossWeight = formData.grossWeight && formData.grossWeight > 0
|
||||
const hasTareWeight = formData.tareWeight && formData.tareWeight > 0
|
||||
if (hasGrossWeight && hasTareWeight) {
|
||||
@@ -1045,6 +1034,7 @@
|
||||
}
|
||||
|
||||
if (editingRecord.value) {
|
||||
editedId = editingRecord.value.id
|
||||
await weighingApi.update(editingRecord.value.id, {
|
||||
productId: formData.productId,
|
||||
vehicleNo: submitData.vehicleNo,
|
||||
@@ -1073,7 +1063,8 @@
|
||||
$modal.msgSuccess('保存成功')
|
||||
}
|
||||
modalOpen.value = false
|
||||
loadData()
|
||||
await loadData()
|
||||
if (editedId) await refreshRelatedViewIfOpen(editedId)
|
||||
} catch (error) {
|
||||
console.error('保存地磅单失败', error)
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user