库存盘点
This commit is contained in:
1 parent
9cc989ed77
commit
cdc44f8284
4 files changed
+135
-405
No files matched your search
@@ -79,6 +79,7 @@
|
||||
:column-config="{ resizable: true }"
|
||||
:row-config="{ isHover: true }"
|
||||
:resizable-config="{ dragMode: 'fixed' }"
|
||||
:checkbox-config="{ highlight: true, range: true }"
|
||||
:data="vxeTableData"
|
||||
:edit-rules="validRules"
|
||||
@checkbox-all=""
|
||||
@@ -342,7 +343,7 @@ const onSave = async () => {
|
||||
// 清空填写的数据
|
||||
const clearData = () => {
|
||||
for (const key in baseDataForm) {
|
||||
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
|
||||
if (["id", "inventoryCode", "inventoryDate", "inventoryType", "orderType"].includes(key)) continue
|
||||
baseDataForm[key] = ""
|
||||
}
|
||||
vxeTableData.value = []
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="条码录入" width="60%" :close-on-click-modal="false" draggable @close="">
|
||||
<!-- <el-row>
|
||||
<el-form :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="商品名称" prop="name">
|
||||
<el-input placeholder="请输入商品名称" v-model="state.queryForm.productName" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row> -->
|
||||
|
||||
<!-- <el-table v-loading="state.loading" :data="state.dataList" @row-click="handleRowClick" :row-style="{ cursor: 'pointer' }">
|
||||
<el-table-column type="index" label="#" width="50" align="center" />
|
||||
<el-table-column prop="productName" label="商品名称" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="brandId" label="商品品牌" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="categoryId" label="商品分类" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="merchantId" label="商户" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="sliderPicUrls" label="商品轮播图" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<preview-image @click.stop :src="scope.row.sliderPicUrls" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="上架状态" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="spu_status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="barcode" label="商品条码" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="supplierId" label="供货商" width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="sort" label="排序字段" align="center" show-overflow-tooltip /> -->
|
||||
|
||||
<!-- <el-table-column prop="price" label="商品价格" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ displayPrice(scope.row.price) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="marketPrice" label="市场价" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ displayPrice(scope.row.marketPrice) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="costPrice" label="成本价" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="stock" label="库存" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="salesCount" label="商品销量" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="创建时间" align="center" show-overflow-tooltip /> -->
|
||||
<!-- </el-table> -->
|
||||
|
||||
<!-- <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" /> -->
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="SmSpuDialog">
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { getObj } from "/@/api/supermarket/smSpu"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义字典
|
||||
const { spu_status } = useDict("spu_status")
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: "",
|
||||
erpSpuId: "",
|
||||
description: "<p></p>",
|
||||
sliderPicUrls: "",
|
||||
sort: "",
|
||||
status: "0",
|
||||
giveIntegral: 0,
|
||||
deptId: "",
|
||||
salesCount: "",
|
||||
erpSpuName: "",
|
||||
})
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
sliderPicUrls: [{ required: true, message: "请上传轮播图", trigger: "blur" }],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true
|
||||
form.id = ""
|
||||
|
||||
dataFormRef.value?.resetFields()
|
||||
|
||||
// 获取smSpu信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
// getsmSpuData(id)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
// console.log(form)
|
||||
// const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
// if (!valid) return false
|
||||
// try {
|
||||
// loading.value = true
|
||||
// form.id ? await putObj(form) : await addObj(form)
|
||||
// useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
// visible.value = false
|
||||
// emit("refresh")
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg)
|
||||
// } finally {
|
||||
// loading.value = false
|
||||
// }
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
const getsmSpuData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
// pageList: getOnlineSpuPage,
|
||||
})
|
||||
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
|
||||
|
||||
const resetQuery = () => {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 点击选择库存商品
|
||||
const handleClickSelectSpu = () => {
|
||||
loading.value = true
|
||||
resetQuery()
|
||||
dialogVisible.value = true
|
||||
try {
|
||||
getDataList()
|
||||
} catch (error) {
|
||||
state.dataList = []
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
// 线上商品列表表格行点击
|
||||
const handleRowClick = (row: any) => {
|
||||
dialogVisible.value = false
|
||||
form.erpSpuId = row.id
|
||||
form.erpSpuName = row.productName
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="w-full h-full">
|
||||
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
|
||||
<div v-if="disabled" ref="baseDataInfoRef">
|
||||
<div v-if="disabled" ref="baseInfoRef">
|
||||
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
|
||||
<div style="width: 33.33%; height: 28px; line-height: 28px">
|
||||
<span class="font-bold">单据编号:</span>
|
||||
@@ -11,17 +11,13 @@
|
||||
<span class="font-bold">单据日期:</span>
|
||||
<span>{{ baseDataForm.inventoryDate }}</span>
|
||||
</div>
|
||||
<div style="width: 33.33%; height: 28px; line-height: 28px">
|
||||
<span class="font-bold">经办人:</span>
|
||||
<span>{{ baseDataForm.handlerUserId }}</span>
|
||||
</div>
|
||||
<div style="width: 33.33%; height: 28px; line-height: 28px">
|
||||
<span class="font-bold">备注:</span>
|
||||
<span>{{ baseDataForm.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-form v-else ref="baseDataFormRef" :model="baseDataForm" :rules="dataRules" label-width="100px">
|
||||
<el-form v-else ref="baseFormRef" :model="baseDataForm" :rules="dataRules" label-width="100px">
|
||||
<div class="flex flex-wrap">
|
||||
<el-form-item label="单据编号" prop="inventoryCode">
|
||||
<el-input v-model.trim="baseDataForm.inventoryCode" readonly style="width: 200px" :disabled="disabled" />
|
||||
@@ -29,14 +25,14 @@
|
||||
<el-form-item label="单据日期" prop="inventoryDate">
|
||||
<el-input v-model="baseDataForm.inventoryDate" readonly style="width: 200px" :disabled="disabled" />
|
||||
</el-form-item>
|
||||
<el-form-item label="经办人" prop="handlerUserId">
|
||||
<!-- <el-form-item label="经办人" prop="handlerUserId">
|
||||
<SelectHandlerUser
|
||||
v-model.trim="baseDataForm.handlerUserId"
|
||||
placeholder="请选择经办人"
|
||||
style="width: 200px"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" style="width: 200px" :disabled="disabled" />
|
||||
</el-form-item>
|
||||
@@ -45,15 +41,15 @@
|
||||
|
||||
<el-row v-if="!disabled" class="my-3">
|
||||
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
|
||||
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
|
||||
<el-button @click="removeRow">删除选中</el-button>
|
||||
<el-button type="danger" plain @click="clearData">清空数据</el-button>
|
||||
<!-- <el-button @click="handleClickBarCodeEnter">条码录入</el-button> -->
|
||||
</el-row>
|
||||
|
||||
<vxe-table
|
||||
ref="editableTableRef"
|
||||
ref="vxeTableRef"
|
||||
border
|
||||
:loading="loading"
|
||||
show-overflow
|
||||
max-height="410"
|
||||
:edit-config="{
|
||||
trigger: 'click',
|
||||
@@ -70,7 +66,8 @@
|
||||
:column-config="{ resizable: true }"
|
||||
:row-config="{ isHover: true }"
|
||||
:resizable-config="{ dragMode: 'fixed' }"
|
||||
:data="state.editableTableData"
|
||||
:checkbox-config="{ highlight: true, range: true }"
|
||||
:data="vxeTableData"
|
||||
:edit-rules="validRules"
|
||||
class="editableTable-style"
|
||||
:cell-class-name="
|
||||
@@ -81,19 +78,19 @@
|
||||
return null
|
||||
}
|
||||
"
|
||||
@checkbox-all="selectChangeEvent"
|
||||
@checkbox-change="selectChangeEvent"
|
||||
@checkbox-all=""
|
||||
@checkbox-change=""
|
||||
@edit-change="handleEditChange"
|
||||
size="mini"
|
||||
align="center"
|
||||
>
|
||||
<vxe-column type="checkbox" width="40" fixed="left" />
|
||||
<vxe-column type="seq" width="50" fixed="left" />
|
||||
<vxe-column field="productCode" title="货号编码" />
|
||||
<vxe-column field="productCode" title="货号" />
|
||||
<vxe-column field="productName" title="商品名称">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.productName">{{ row.productName }}</span>
|
||||
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
|
||||
<span v-else>{{ row.erpSpuId && erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="unitId" title="包装单位" min-width="60">
|
||||
@@ -183,15 +180,10 @@
|
||||
<el-tooltip v-if="!disabled" effect="dark" content="保存并返回列表页面" placement="top">
|
||||
<el-button type="primary" plain @click="onSave">保存</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="disabled" effect="dark" content="打印清单" placement="top">
|
||||
<el-button type="success" plain @click="printEvent">打印</el-button>
|
||||
</el-tooltip>
|
||||
</el-row>
|
||||
|
||||
<!-- 商品选择对话框 -->
|
||||
<select-dialog ref="erpSpuSelectDialogRef" @getSelectedRows="getSelectedRows" />
|
||||
|
||||
<barCodeEnter ref="barCodeEnterRef" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -200,9 +192,8 @@
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
||||
import { getStockTakingDeatil, addObj, putObj } from "/@/api/supermarketerp/stockTaking"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import barCodeEnter from "./barCodeEnter.vue"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { tablePrint } from "../supermarketUtils"
|
||||
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
|
||||
@@ -211,89 +202,105 @@ const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formId: string | undefined
|
||||
formId: string
|
||||
disabled: boolean
|
||||
}>(),
|
||||
{
|
||||
formId: undefined,
|
||||
disabled: true,
|
||||
formId: "",
|
||||
disabled: false,
|
||||
},
|
||||
)
|
||||
const emit = defineEmits(["close"])
|
||||
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const loading = ref(false)
|
||||
const disabled = ref(false)
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const barCodeEnterRef = ref() // 条码录入对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const baseDataInfoRef = ref() // 基本信息ref
|
||||
// 基本信息表单数据
|
||||
const baseFormRef = ref() // 基本表单ref
|
||||
const vxeTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const baseInfoRef = ref() // 基本信息ref
|
||||
const baseDataForm = reactive<any>({
|
||||
id: "",
|
||||
inventoryCode: "",
|
||||
inventoryDate: formatDate(new Date(), "YYYY-mm-dd"),
|
||||
handlerUserId: "",
|
||||
remark: "",
|
||||
inventoryType: "7",
|
||||
orderType: "",
|
||||
})
|
||||
const state = reactive<{
|
||||
editableTableData: any[]
|
||||
erpSpuItemsMemo: any[]
|
||||
selectedRowsErpSpuIds: string[]
|
||||
erpSpuSimpleAll: any
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
|
||||
erpSpuSimpleAll: [], // 简要商品列表
|
||||
})
|
||||
const vxeTableData = ref<any>([])
|
||||
const erpSpuSimpleAll = ref<any>([])
|
||||
|
||||
// 基本信息表单校验规则
|
||||
const dataRules = ref({
|
||||
inventoryCode: [{ required: true, message: "单据编号不能为空", trigger: "blur" }],
|
||||
inventoryDate: [{ required: true, message: "单据日期不能为空", trigger: "blur" }],
|
||||
handlerUserId: [{ required: true, message: "经办人不能为空", trigger: "blur" }],
|
||||
})
|
||||
|
||||
// 可编辑表格校验规则
|
||||
const validRules = ref<VxeTablePropTypes.EditRules<any>>({
|
||||
pdPrice: [{ required: true, message: "请输入" }],
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getInitData()
|
||||
})
|
||||
|
||||
// 初始化数据
|
||||
const getInitData = async () => {
|
||||
baseDataForm.id = undefined
|
||||
baseDataForm.id = ""
|
||||
const id = props.formId
|
||||
disabled.value = props.disabled
|
||||
if (id) {
|
||||
loading.value = true
|
||||
// 获取清单数据
|
||||
const [cgPlanData] = await Promise.allSettled([getStockTakingDeatil({ id })])
|
||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||
.finally(() => (loading.value = false))
|
||||
const [cgPlanData] = await Promise.allSettled([getStockTakingDeatil({ id })]).then((results) =>
|
||||
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
||||
)
|
||||
|
||||
if (cgPlanData && cgPlanData.code === 0) {
|
||||
Object.assign(baseDataForm, cgPlanData.data)
|
||||
state.editableTableData = cgPlanData.data.items
|
||||
state.erpSpuItemsMemo = cgPlanData.data.items
|
||||
vxeTableData.value = cgPlanData.data.items
|
||||
}
|
||||
} else {
|
||||
// 获取采购入库编号
|
||||
const [planCode] = await Promise.allSettled([getPlanCode({ type: 7 })])
|
||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||
.finally(() => (loading.value = false))
|
||||
|
||||
const [planCode] = await Promise.allSettled([getPlanCode({ type: 7 })]).then((results) =>
|
||||
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
||||
)
|
||||
planCode && planCode.code === 0 && (baseDataForm.inventoryCode = planCode.data)
|
||||
}
|
||||
|
||||
// 获取简要商品列表
|
||||
loading.value = true
|
||||
const [erpSpuSimpleAll] = await Promise.allSettled([getErpSpuSimpleAll()])
|
||||
const [erpSpuSimpleAllData] = await Promise.allSettled([getErpSpuSimpleAll()])
|
||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||
.finally(() => (loading.value = false))
|
||||
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
||||
erpSpuSimpleAllData && erpSpuSimpleAllData.code === 0 && (erpSpuSimpleAll.value = erpSpuSimpleAllData.data)
|
||||
}
|
||||
|
||||
// 点击商品选择
|
||||
const handleClickSpuSelect = () => erpSpuSelectDialogRef.value.openDialog()
|
||||
|
||||
// 获取被选择的商品行
|
||||
const getSelectedRows = (selectionRows: any) => {
|
||||
console.log("被选择的商品行", selectionRows)
|
||||
|
||||
// 筛选新勾选的项
|
||||
const addedItems = selectionRows
|
||||
.filter((item: any) => !vxeTableData.value.some((vxeTableItem: any) => vxeTableItem.erpSpuId === item.erpSpuId))
|
||||
.map((addItem: any) => {
|
||||
// const index = vxeTableDataMemo.value.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
|
||||
// if (index !== -1) return vxeTableDataMemo.value[index]
|
||||
return { ...addItem, isNew: true }
|
||||
})
|
||||
vxeTableData.value.push(...addedItems)
|
||||
|
||||
console.log("vxeTableData.value", vxeTableData.value)
|
||||
}
|
||||
|
||||
// 删除选中的行
|
||||
const removeRow = () => {
|
||||
const $table = vxeTableRef.value
|
||||
if ($table) {
|
||||
const selectRecords = $table.getCheckboxRecords()
|
||||
if (selectRecords.length > 0) {
|
||||
vxeTableData.value = vxeTableData.value.filter((item: any) => !selectRecords.some((row) => row.erpSpuId === item.erpSpuId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算账面数量
|
||||
@@ -357,69 +364,9 @@ const handleRealNumberChange = (row: any) => {
|
||||
row._cachedLoss = null
|
||||
}
|
||||
|
||||
// 删除选中的行
|
||||
const removeSelectRowEvent = () => {
|
||||
const $table = editableTableRef.value
|
||||
if ($table) {
|
||||
const selectRecords = $table.getCheckboxRecords()
|
||||
if (selectRecords.length > 0) {
|
||||
state.editableTableData = state.editableTableData.filter((item) => !selectRecords.some((row) => row.erpSpuId === item.erpSpuId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 可编辑表格行勾选
|
||||
const selectChangeEvent: VxeTableEvents.CheckboxChange<any> = ({ checked }) => {
|
||||
const $table = editableTableRef.value
|
||||
if ($table) {
|
||||
const records = $table.getCheckboxRecords()
|
||||
console.log(checked ? "勾选事件" : "取消事件", records)
|
||||
state.selectedRowsErpSpuIds = records.map((item) => item.erpSpuId)
|
||||
}
|
||||
}
|
||||
|
||||
// 点击商品选择
|
||||
const handleClickSpuSelect = () => erpSpuSelectDialogRef.value.openDialog()
|
||||
|
||||
// 点击条码录入
|
||||
const handleClickBarCodeEnter = () => barCodeEnterRef.value.openDialog()
|
||||
|
||||
// 获取被选择的商品行
|
||||
const getSelectedRows = (selectionRows: any) => {
|
||||
console.log("被选择的商品行", selectionRows)
|
||||
|
||||
// 筛选新勾选的项
|
||||
const addedItems = selectionRows
|
||||
.filter((item: any) => !state.editableTableData.some((editableTableItem: any) => editableTableItem.erpSpuId === item.erpSpuId))
|
||||
.map((addItem: any) => {
|
||||
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
|
||||
if (index !== -1) return state.erpSpuItemsMemo[index]
|
||||
return { ...addItem, isNew: true }
|
||||
})
|
||||
// 仅添加新勾选的项
|
||||
state.editableTableData = [...state.editableTableData, ...addedItems]
|
||||
|
||||
// 筛选取消勾选的项
|
||||
const removedItems = state.editableTableData.filter(
|
||||
(item: any) => !selectionRows.some((selectedItem: any) => selectedItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// 仅移除取消勾选的项
|
||||
state.editableTableData = state.editableTableData.filter(
|
||||
(item: any) => !removedItems.some((removeItem: any) => removeItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// state.editableTableData.push(item)
|
||||
// nextTick(() => {
|
||||
// const $table = editableTableRef.value
|
||||
// if ($table) {
|
||||
// $table.setRow(item)
|
||||
// }
|
||||
// })
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
}
|
||||
|
||||
// 整理数据
|
||||
const pdPlanItems = computed(() => {
|
||||
return state.editableTableData.map((item: any) => {
|
||||
const settledTableItems = computed(() => {
|
||||
return vxeTableData.value.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
unitPrice: Number(
|
||||
@@ -454,31 +401,29 @@ const { formValidate, submitData } = useSmProcessFormAction()
|
||||
// 点击继续添加
|
||||
const onContinueAdd = async () => {
|
||||
console.log("baseDataForm", baseDataForm)
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData.length)) &&
|
||||
(await submitData(baseDataForm, pdPlanItems, loading, putObj, addObj)) &&
|
||||
console.log("vxeTableData", vxeTableData.value)
|
||||
;(await formValidate(baseFormRef, vxeTableRef, vxeTableData.value.length)) &&
|
||||
(await submitData(baseDataForm, settledTableItems.value, loading, putObj, addObj)) &&
|
||||
clearData()
|
||||
}
|
||||
|
||||
// 点击保存
|
||||
const onSave = async () => {
|
||||
console.log("baseDataForm", baseDataForm)
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData.length)) &&
|
||||
(await submitData(baseDataForm, pdPlanItems, loading, putObj, addObj)) &&
|
||||
console.log("vxeTableData", vxeTableData.value)
|
||||
;(await formValidate(baseFormRef, vxeTableRef, vxeTableData.value.length)) &&
|
||||
(await submitData(baseDataForm, settledTableItems.value, loading, putObj, addObj)) &&
|
||||
clearData() &&
|
||||
emit("close")
|
||||
}
|
||||
|
||||
// 清空填写的数据 返回 true
|
||||
// 清空填写的数据
|
||||
const clearData = () => {
|
||||
for (const key in baseDataForm) {
|
||||
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
|
||||
if (["id", "inventoryCode", "inventoryDate", "inventoryType", "orderType"].includes(key)) continue
|
||||
baseDataForm[key] = ""
|
||||
}
|
||||
state.editableTableData = []
|
||||
state.erpSpuItemsMemo = []
|
||||
state.selectedRowsErpSpuIds = []
|
||||
vxeTableData.value = []
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -520,13 +465,9 @@ const handleEditChange = ({ row, column }: any) => {
|
||||
}
|
||||
|
||||
// 点击打印
|
||||
const printEvent = () => {
|
||||
tablePrint(editableTableRef.value, baseDataInfoRef.value, state.editableTableData, 23, "库存盘点")
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getInitData()
|
||||
})
|
||||
// const printEvent = () => {
|
||||
// tablePrint(vxeTableRef.value, baseInfoRef.value, vxeTableData.value, 23, "库存盘点")
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div v-if="!processFormState.showForm" class="layout-padding-auto layout-padding-view">
|
||||
<div v-if="!showForm" class="layout-padding-auto layout-padding-view">
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="单据编号" prop="inventoryCode">
|
||||
@@ -15,14 +15,9 @@
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="经办人" prop="handlerUserId">
|
||||
<!-- <el-form-item label="经办人" prop="handlerUserId">
|
||||
<SelectHandlerUser v-model.trim="state.queryForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批状态" prop="checkStatus">
|
||||
<el-select v-model="state.queryForm.checkStatus" placeholder="请选择审批状态">
|
||||
<el-option :label="item.label" :value="item.value" v-for="(item, index) in check_status" :key="index" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
@@ -31,7 +26,7 @@
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="create()">新 增</el-button>
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="create">新 增</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" @click="handleDelete(selectObjs)">删 除</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
@@ -57,83 +52,83 @@
|
||||
<el-table-column prop="inventoryCode" label="单据编号" show-overflow-tooltip />
|
||||
<el-table-column prop="inventoryDate" label="单据日期" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="productName" label="入库商品" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="handlerUserName" label="经办人" show-overflow-tooltip />
|
||||
<el-table-column prop="checkStatus" label="审批状态" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="check_status" :value="row.checkStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="handlerUserName" label="经办人" show-overflow-tooltip /> -->
|
||||
<el-table-column prop="supplierId" label="货商" show-overflow-tooltip />
|
||||
<el-table-column prop="remark" label="备注" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="totalAmount" label="入库总金额" show-overflow-tooltip /> -->
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.checkStatus == '2' || scope.row.checkStatus == '3'"
|
||||
icon="MessageBox"
|
||||
text
|
||||
type="success"
|
||||
@click="edit(scope.row)"
|
||||
>
|
||||
详情
|
||||
</el-button>
|
||||
<el-button v-else icon="edit-pen" text type="primary" @click="edit(scope.row)">编辑</el-button>
|
||||
<el-button icon="edit-pen" text type="primary" @click="edit(scope.row)">编辑</el-button>
|
||||
<el-button icon="delete" text type="primary" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
v-if="scope.row.checkStatus == '1' && scope.row.taskId"
|
||||
link
|
||||
icon="VideoPlay"
|
||||
@click="deal(scope.row)"
|
||||
>
|
||||
开始处理
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<sm-form v-else :formId="processFormState.formId" :disabled="processFormState.formDisabled" @close="formClose" />
|
||||
|
||||
<!-- 审批抽屉 -->
|
||||
<process-drawer ref="processDrawerRef" @task-submit-event="taskSubmitEvent" />
|
||||
<sm-form v-else :formId="formId" :disabled="formDisabled" @close="formClose" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { fetchList } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import ProcessDrawer from "/@/components/processDrawer/index.vue"
|
||||
import { tableRow, useSmProcessTableAction } from "/@/hooks/smProcessTableAction"
|
||||
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
|
||||
const SmForm = defineAsyncComponent(() => import("./form.vue"))
|
||||
|
||||
const { check_status } = useDict("check_status")
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
const processFormState = reactive<{ formId: string | undefined; formDisabled: boolean; showForm: boolean }>({
|
||||
formId: undefined,
|
||||
formDisabled: true,
|
||||
showForm: false,
|
||||
})
|
||||
const processDrawerRef = ref<InstanceType<typeof ProcessDrawer> | null>(null)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {
|
||||
inventoryType: "7",
|
||||
},
|
||||
pageList: fetchList,
|
||||
})
|
||||
const showForm = ref(false)
|
||||
const formDisabled = ref(false)
|
||||
const formId = ref("")
|
||||
|
||||
// 新增
|
||||
const create = () => {
|
||||
formDisabled.value = false
|
||||
formId.value = ""
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm("此操作将永久删除")
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids)
|
||||
getDataList()
|
||||
useMessage().success("删除成功")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑
|
||||
const edit = (row: any) => {
|
||||
if (!row.id) return useMessage().warning("清单id不存在")
|
||||
formId.value = row.id
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
// 表单关闭
|
||||
const formClose = () => {
|
||||
showForm.value = false
|
||||
formId.value = ""
|
||||
formDisabled.value = false
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
|
||||
|
||||
// 清空搜索条件
|
||||
@@ -147,7 +142,7 @@ const resetQuery = () => {
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
// downBlobFile("/supermarket/smErpInventoryRecords/export", Object.assign(state.queryForm, { ids: selectObjs }), "采购入库.xlsx")
|
||||
// downBlobFile("/supermarket/smErpInventoryRecords/export", Object.assign(state.queryForm, { ids: selectObjs }), "库存盘点.xlsx")
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
@@ -155,37 +150,4 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id)
|
||||
multiple.value = !objs.length
|
||||
}
|
||||
|
||||
const { create, edit, close } = useSmProcessTableAction(processFormState)
|
||||
|
||||
const formClose = () => {
|
||||
close()
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 点击开始处理
|
||||
const deal = (row: tableRow) => {
|
||||
if (!row.processInstanceId) return useMessage().warning("流程id不存在")
|
||||
processDrawerRef.value && processDrawerRef.value.openProcessDrawer(row)
|
||||
}
|
||||
// 审批提交事件
|
||||
const taskSubmitEvent = () => {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm("此操作将永久删除")
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
// await delObjs(ids)
|
||||
// getDataList()
|
||||
// useMessage().success("删除成功")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user