|
|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="layout-padding">
|
|
|
|
|
<div v-loading="loading" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
|
|
|
|
|
<el-form ref="baseDataFormRef" :model="baseDataForm" :rules="dataRules" formDialogRef label-width="140px">
|
|
|
|
|
<el-form ref="baseDataFormRef" :model="baseDataForm" :rules="dataRules" formDialogRef 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" />
|
|
|
|
@@ -10,15 +10,20 @@
|
|
|
|
|
<el-form-item label="单据日期" prop="inventoryDate">
|
|
|
|
|
<el-input v-model.trim="baseDataForm.inventoryDate" readonly style="width: 200px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="关联采购订单" prop="handlerUserId">
|
|
|
|
|
<el-select v-model.trim="baseDataForm.handlerUserId" placeholder="请选择采购订单" style="width: 200px">
|
|
|
|
|
<el-option label="请选择" value="0" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="关联采购订单" prop="linkCode">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="baseDataForm.linkCode"
|
|
|
|
|
:suffix-icon="Search"
|
|
|
|
|
@click="handleClickLinkCode"
|
|
|
|
|
readonly
|
|
|
|
|
placeholder="请选择采购订单"
|
|
|
|
|
style="width: 200px"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="经办人" prop="handlerUserId">
|
|
|
|
|
<el-select v-model.trim="baseDataForm.handlerUserId" placeholder="请选择经办人id" style="width: 200px">
|
|
|
|
|
<el-option label="请选择" value="0" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<SelectHandlerUser v-model.trim="baseDataForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="审批状态" prop="checkStatus">
|
|
|
|
@@ -26,7 +31,9 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="货商" prop="supplierId">
|
|
|
|
|
<el-input v-model.trim="baseDataForm.supplierId" placeholder="请输入货商" style="width: 200px" />
|
|
|
|
|
<el-select v-model="baseDataForm.supplierId" placeholder="请选择货商" style="width: 200px">
|
|
|
|
|
<el-option v-for="item in supplierTypeDict" :key="item?.id" :label="item?.typeName" :value="item?.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
@@ -88,16 +95,10 @@
|
|
|
|
|
|
|
|
|
|
<vxe-column type="seq" width="50" fixed="left" />
|
|
|
|
|
|
|
|
|
|
<!-- <vxe-column field="planId" title="采购" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
|
|
|
|
<template #edit="{ row }">
|
|
|
|
|
<el-input v-model="row.planId" />
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column> -->
|
|
|
|
|
|
|
|
|
|
<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 && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
|
|
|
|
|
@@ -114,7 +115,7 @@
|
|
|
|
|
</el-select>
|
|
|
|
|
</template>
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<span v-if="row.unitId">{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
|
|
|
|
|
<span v-if="row.unitId">{{ row.unit ?? row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
|
|
|
|
|
<span v-else style="color: #c0c4cf">请选择</span>
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
@@ -127,7 +128,7 @@
|
|
|
|
|
|
|
|
|
|
<vxe-column field="unitPrice" title="进价">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
|
|
|
|
|
{{ row.purchasePrice ?? row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
|
|
|
|
|
@@ -146,18 +147,6 @@
|
|
|
|
|
<el-input v-model="row.remark" />
|
|
|
|
|
</template>
|
|
|
|
|
</vxe-column>
|
|
|
|
|
|
|
|
|
|
<!-- <vxe-column field="merchantId" title="商户编号" :edit-render="{ autoFocus: 'input', placeholder: '请选择' }">-->
|
|
|
|
|
<!-- <template #edit="{ row }">-->
|
|
|
|
|
<!-- <select-mch v-model="row.merchantId" />-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </vxe-column>-->
|
|
|
|
|
|
|
|
|
|
<!-- <vxe-column field="deptId" title="部门id" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">-->
|
|
|
|
|
<!-- <template #edit="{ row }">-->
|
|
|
|
|
<!-- <el-input v-model="row.deptId" />-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<!-- </vxe-column>-->
|
|
|
|
|
</vxe-table>
|
|
|
|
|
|
|
|
|
|
<el-row class="my-3">
|
|
|
|
@@ -173,130 +162,43 @@
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<!-- 商品选择对话框 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
v-model="state.spuSelectDialogVisible"
|
|
|
|
|
title="选择商品"
|
|
|
|
|
width="70%"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
draggable
|
|
|
|
|
@close="state.selectedSpuObjs = []"
|
|
|
|
|
>
|
|
|
|
|
<!-- <el-row>
|
|
|
|
|
<el-form :model="foodQueryForm" ref="queryRef" :inline="true" @keyup.enter="getDataListAndSelect">
|
|
|
|
|
<el-form-item label="商品名称" prop="name">
|
|
|
|
|
<el-input placeholder="请输入商品名称" v-model="foodQueryForm.name" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="商品分类" prop="categoryId">
|
|
|
|
|
<select-ctcg v-model="foodQueryForm.categoryId" style="width: 200px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button icon="search" type="primary" @click="getDataListAndSelect">查询</el-button>
|
|
|
|
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-row> -->
|
|
|
|
|
<erpSpuSelectDialog
|
|
|
|
|
ref="erpSpuSelectDialogRef"
|
|
|
|
|
v-model="state.erpSpuSelectDialogVisible"
|
|
|
|
|
:selectedSpuRows="state.editableTableData"
|
|
|
|
|
@getSelectedSpuRows="getSelectedSpuRows"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
ref="spuMultipleTableRef"
|
|
|
|
|
:data="state.spuDataList"
|
|
|
|
|
v-loading="spuListLoading"
|
|
|
|
|
@select="handleSelect"
|
|
|
|
|
@select-all="handleSelectAll"
|
|
|
|
|
@selection-change="selectionChangeHandle"
|
|
|
|
|
:row-key="(row:any) => row.id"
|
|
|
|
|
:reserve-selection="true"
|
|
|
|
|
@row-click="rowClick"
|
|
|
|
|
:row-style="{ cursor: 'pointer' }"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="selection" width="40" align="center" fixed="left" />
|
|
|
|
|
<el-table-column type="index" label="#" width="50" align="center" fixed="left" />
|
|
|
|
|
<el-table-column prop="productName" label="商品名称" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="barcode" label="自编码/条码" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="productCode" label="货号" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="brandId" label="品牌" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="categoryId" label="分类" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="deptId" label="商户" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="supplierId" label="货商" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="status" label="状态" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
<el-table-column prop="picUrl" label="商品封面图" align="center" show-overflow-tooltip>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<preview-image @click.stop :src="scope.row.picUrl" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="stock" label="库存" min-width="100px" align="center" show-overflow-tooltip />
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- <pagination
|
|
|
|
|
@size-change="sizeChangeHandle"
|
|
|
|
|
@current-change="currentChangeHandle"
|
|
|
|
|
v-model:current-page="foodQueryForm.current"
|
|
|
|
|
v-model:page-size="foodQueryForm.size"
|
|
|
|
|
:total="total"
|
|
|
|
|
/> -->
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
<!-- 关联采购申请单对话框 -->
|
|
|
|
|
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts" name="smErpInventoryRecordsOption">
|
|
|
|
|
<script setup lang="ts" name="cgPlanOption">
|
|
|
|
|
import { ref, reactive, computed, onMounted } from "vue"
|
|
|
|
|
import { useRouter, useRoute } from "vue-router"
|
|
|
|
|
import { useMessage } from "/@/hooks/message"
|
|
|
|
|
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
|
|
|
|
|
import { getPlanCode, getCgPlanSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
|
|
|
|
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
|
|
|
|
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
|
|
|
|
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
|
|
|
|
import { storePrice } from "/@/utils/formatMoney"
|
|
|
|
|
import { formatDate } from "/@/utils/formatTime"
|
|
|
|
|
import { useDict } from "/@/hooks/dict"
|
|
|
|
|
import { Search } from "@element-plus/icons-vue"
|
|
|
|
|
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
|
|
|
|
import linkCgCodeDialog from "/@/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue"
|
|
|
|
|
|
|
|
|
|
// 基本表单数据类型
|
|
|
|
|
interface FormVO {
|
|
|
|
|
id: string | undefined
|
|
|
|
|
inventoryCode: string
|
|
|
|
|
inventoryDate: string
|
|
|
|
|
inventoryType: string
|
|
|
|
|
sourceId: string
|
|
|
|
|
warehouseId: string
|
|
|
|
|
handlerUserId: string
|
|
|
|
|
checkStatus: string
|
|
|
|
|
checkUserId: string
|
|
|
|
|
checkTime: string
|
|
|
|
|
merchantId: string
|
|
|
|
|
deptId: string
|
|
|
|
|
supplierId: string
|
|
|
|
|
remark: string
|
|
|
|
|
orderType: string
|
|
|
|
|
totalAmount: string
|
|
|
|
|
[key: string]: string | undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 可编辑表格行数据类型
|
|
|
|
|
interface RowVO {
|
|
|
|
|
id?: string
|
|
|
|
|
erpSpuId: string
|
|
|
|
|
quantity: number | null
|
|
|
|
|
unitPrice: number | null
|
|
|
|
|
totalAmount: number | null
|
|
|
|
|
remark: string
|
|
|
|
|
unitId: string
|
|
|
|
|
}
|
|
|
|
|
const { erp_order_type, inventory_type, check_status } = useDict("erp_order_type", "inventory_type", "check_status")
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const loading = ref(false) // 采购计划加载
|
|
|
|
|
const spuListLoading = ref(false) // 对话框商品列表加载
|
|
|
|
|
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
|
|
|
|
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
|
|
|
|
const baseDataFormRef = ref() // 基本数据表单ref
|
|
|
|
|
const editableTableRef = ref<VxeTableInstance<RowVO>>() // 可编辑表格ref
|
|
|
|
|
const spuMultipleTableRef = ref() // 对话框多选表格ref
|
|
|
|
|
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
|
|
|
|
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
|
|
|
|
|
|
|
|
|
// 基本信息表单数据
|
|
|
|
|
const baseDataForm = reactive<FormVO>({
|
|
|
|
|
const baseDataForm = reactive<any>({
|
|
|
|
|
id: "",
|
|
|
|
|
inventoryCode: "",
|
|
|
|
|
inventoryDate: formatDate(new Date(), "YYYY-mm-dd"),
|
|
|
|
@@ -315,14 +217,14 @@ const baseDataForm = reactive<FormVO>({
|
|
|
|
|
totalAmount: "",
|
|
|
|
|
})
|
|
|
|
|
const state = reactive<{
|
|
|
|
|
editableTableData: RowVO[]
|
|
|
|
|
erpSpuItemsMemo: RowVO[]
|
|
|
|
|
editableTableData: any[]
|
|
|
|
|
erpSpuItemsMemo: any[]
|
|
|
|
|
selectedRowsErpSpuIds: string[]
|
|
|
|
|
insertedRowNumber: number
|
|
|
|
|
erpSpuSimpleAll: any
|
|
|
|
|
spuSelectDialogVisible: boolean
|
|
|
|
|
spuDataList: any[]
|
|
|
|
|
selectedSpuObjs: any[]
|
|
|
|
|
linkCodeVisible: boolean
|
|
|
|
|
erpSpuSelectDialogVisible: boolean
|
|
|
|
|
linkCgCodeDialogVisible: boolean
|
|
|
|
|
}>({
|
|
|
|
|
editableTableData: [], // 可编辑表格数据
|
|
|
|
|
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
|
|
|
@@ -330,20 +232,21 @@ const state = reactive<{
|
|
|
|
|
insertedRowNumber: 0, // 可编辑表格插入行的行号
|
|
|
|
|
erpSpuSimpleAll: [], // 简要商品列表
|
|
|
|
|
|
|
|
|
|
spuSelectDialogVisible: false, // 商品选择对话框开关
|
|
|
|
|
spuDataList: [], // 商品列表
|
|
|
|
|
selectedSpuObjs: [], // 已选中的商品列表项
|
|
|
|
|
linkCodeVisible: false, // 关联采购申请单对话框开关
|
|
|
|
|
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
|
|
|
|
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 基本信息表单校验规则
|
|
|
|
|
const dataRules = ref({
|
|
|
|
|
inventoryCode: [{ required: true, message: "出入库记录表编号不能为空", trigger: "blur" }],
|
|
|
|
|
inventoryDate: [{ required: true, message: "出入库记录表单据日期不能为空", trigger: "blur" }],
|
|
|
|
|
handlerUserId: [{ required: true, message: "经办人不能为空", trigger: "blur" }],
|
|
|
|
|
supplierId: [{ required: true, message: "货商不能为空", trigger: "blur" }],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 可编辑表格校验规则
|
|
|
|
|
const validRules = ref<VxeTablePropTypes.EditRules<RowVO>>({
|
|
|
|
|
const validRules = ref<VxeTablePropTypes.EditRules<any>>({
|
|
|
|
|
unitId: [{ required: true, message: "必须选择" }],
|
|
|
|
|
quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }],
|
|
|
|
|
})
|
|
|
|
@@ -355,7 +258,7 @@ const getInitData = async () => {
|
|
|
|
|
if (id) {
|
|
|
|
|
loading.value = true
|
|
|
|
|
// 获取采购计划数据 & 获取简要商品列表
|
|
|
|
|
const [cgPlanData, erpSpuSimpleAll] = await Promise.allSettled([getObj(id), getErpSpuSimpleAll()])
|
|
|
|
|
const [cgPlanData] = await Promise.allSettled([getObj(id)])
|
|
|
|
|
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
|
|
|
|
.finally(() => (loading.value = false))
|
|
|
|
|
|
|
|
|
@@ -364,30 +267,35 @@ const getInitData = async () => {
|
|
|
|
|
state.editableTableData = cgPlanData.data.items
|
|
|
|
|
state.erpSpuItemsMemo = cgPlanData.data.items
|
|
|
|
|
}
|
|
|
|
|
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取货商选项 & 获取采购计划编号
|
|
|
|
|
const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode({ type: 3 })]).then((results) =>
|
|
|
|
|
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
|
|
|
|
)
|
|
|
|
|
const [erpSpuSimpleAll, supplierTypeOptions, planCode] = await Promise.allSettled([
|
|
|
|
|
getErpSpuSimpleAll(),
|
|
|
|
|
getSupplierTypeOptions(),
|
|
|
|
|
getPlanCode({ type: 3 }),
|
|
|
|
|
]).then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
|
|
|
|
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
|
|
|
|
supplierTypeOptions && supplierTypeOptions.code === 0 && (supplierTypeDict.value = supplierTypeOptions.data)
|
|
|
|
|
planCode && planCode.code === 0 && (baseDataForm.inventoryCode = planCode.data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 可编辑表格行勾选
|
|
|
|
|
const selectChangeEvent: VxeTableEvents.CheckboxChange<RowVO> = ({ checked }) => {
|
|
|
|
|
const $table = editableTableRef.value
|
|
|
|
|
if ($table) {
|
|
|
|
|
const records = $table.getCheckboxRecords()
|
|
|
|
|
console.log(checked ? "勾选事件" : "取消事件", records)
|
|
|
|
|
state.selectedRowsErpSpuIds = records.map((item) => item.erpSpuId)
|
|
|
|
|
}
|
|
|
|
|
// 点击关联采购申请编号
|
|
|
|
|
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
|
|
|
|
|
|
|
|
|
// 获取选择的采购申请
|
|
|
|
|
const getSelectedCgPlan = (selectionRows: any) => {
|
|
|
|
|
console.log("被选择的关联数据", selectionRows)
|
|
|
|
|
|
|
|
|
|
baseDataForm.linkCode = selectionRows.planCode
|
|
|
|
|
state.editableTableData = selectionRows.items
|
|
|
|
|
state.erpSpuItemsMemo = selectionRows.items
|
|
|
|
|
state.linkCgCodeDialogVisible = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 顶部表格行新增
|
|
|
|
|
const addEvent = () => {
|
|
|
|
|
const newRow: RowVO = {
|
|
|
|
|
const newRow: any = {
|
|
|
|
|
id: "",
|
|
|
|
|
erpSpuId: "",
|
|
|
|
|
quantity: null,
|
|
|
|
@@ -407,7 +315,7 @@ const addEvent = () => {
|
|
|
|
|
|
|
|
|
|
// 底部表格行新增
|
|
|
|
|
const pushEvent = () => {
|
|
|
|
|
const newRow: RowVO = {
|
|
|
|
|
const newRow: any = {
|
|
|
|
|
id: "",
|
|
|
|
|
erpSpuId: "",
|
|
|
|
|
quantity: null,
|
|
|
|
@@ -427,7 +335,7 @@ const pushEvent = () => {
|
|
|
|
|
|
|
|
|
|
// 在指定行插入
|
|
|
|
|
const insertEvent = () => {
|
|
|
|
|
const newRow: RowVO = {
|
|
|
|
|
const newRow: any = {
|
|
|
|
|
id: "",
|
|
|
|
|
erpSpuId: "",
|
|
|
|
|
quantity: null,
|
|
|
|
@@ -456,86 +364,27 @@ const removeSelectRowEvent = () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 可编辑表格行勾选
|
|
|
|
|
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 = async () => {
|
|
|
|
|
state.selectedSpuObjs = [...state.editableTableData]
|
|
|
|
|
const handleClickSpuSelect = () => erpSpuSelectDialogRef.value.openDialog()
|
|
|
|
|
|
|
|
|
|
state.spuSelectDialogVisible = true
|
|
|
|
|
spuListLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const { code, data } = await getCgPlanSpuPage().finally(() => (spuListLoading.value = false))
|
|
|
|
|
if (code === 0) {
|
|
|
|
|
state.spuDataList = data.records.map((item: RowVO) => ({ ...item, erpSpuId: item.id }))
|
|
|
|
|
|
|
|
|
|
// 勾选已经选择的商品
|
|
|
|
|
const target = state.spuDataList.filter((row: any) => state.selectedSpuObjs.some((item: any) => row.erpSpuId === item.erpSpuId))
|
|
|
|
|
target.forEach((row: any) => nextTick(() => spuMultipleTableRef.value!.toggleRowSelection(row)))
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
state.spuDataList = []
|
|
|
|
|
spuListLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击商品列表表格行
|
|
|
|
|
const rowClick = (row: any) => {
|
|
|
|
|
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
|
|
|
|
? // state.selectedSpuObjs.indexOf(row) === -1
|
|
|
|
|
state.selectedSpuObjs.push(row)
|
|
|
|
|
: state.selectedSpuObjs.splice(
|
|
|
|
|
// state.selectedSpuObjs.indexOf(row)
|
|
|
|
|
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
|
|
|
|
1,
|
|
|
|
|
)
|
|
|
|
|
console.log("click-select", state.selectedSpuObjs)
|
|
|
|
|
spuMultipleTableRef.value.toggleRowSelection(row)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 选中商品列表表格行
|
|
|
|
|
const handleSelect = (selectedRows: any[], row: any) => {
|
|
|
|
|
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
|
|
|
|
? // state.selectedSpuObjs.indexOf(row) === -1
|
|
|
|
|
state.selectedSpuObjs.push(row)
|
|
|
|
|
: state.selectedSpuObjs.splice(
|
|
|
|
|
// state.selectedSpuObjs.indexOf(row)
|
|
|
|
|
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
|
|
|
|
1,
|
|
|
|
|
)
|
|
|
|
|
console.log("check-select", state.selectedSpuObjs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 全选和反全选商品列表表格行
|
|
|
|
|
const handleSelectAll = (selectedRows: any[]) => {
|
|
|
|
|
if (selectedRows.length > 0) {
|
|
|
|
|
selectedRows.forEach((row: any) => {
|
|
|
|
|
if (state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1) {
|
|
|
|
|
state.selectedSpuObjs.push(row)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
state.spuDataList.forEach((row: any) => {
|
|
|
|
|
const index = state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId)
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
state.selectedSpuObjs.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
console.log("checkAll-select", state.selectedSpuObjs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 商品表格多选
|
|
|
|
|
const selectionChangeHandle = (rows: any) => {
|
|
|
|
|
// console.log("onChange-selects", rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 商品选择对话框确认
|
|
|
|
|
const handleSelectDialogConfirm = () => {
|
|
|
|
|
console.log(state.editableTableData, state.selectedSpuObjs)
|
|
|
|
|
// 获取被选择的商品行
|
|
|
|
|
const getSelectedSpuRows = (selectionRows: any) => {
|
|
|
|
|
console.log("被选择的商品行", selectionRows)
|
|
|
|
|
|
|
|
|
|
// 筛选新勾选的项
|
|
|
|
|
const addedItems = state.selectedSpuObjs
|
|
|
|
|
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
|
|
|
|
|
.map((addItem) => {
|
|
|
|
|
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 }
|
|
|
|
@@ -545,7 +394,7 @@ const handleSelectDialogConfirm = () => {
|
|
|
|
|
|
|
|
|
|
// 筛选取消勾选的项
|
|
|
|
|
const removedItems = state.editableTableData.filter(
|
|
|
|
|
(item: any) => !state.selectedSpuObjs.some((selectedItem: any) => selectedItem.erpSpuId === item.erpSpuId),
|
|
|
|
|
(item: any) => !selectionRows.some((selectedItem: any) => selectedItem.erpSpuId === item.erpSpuId),
|
|
|
|
|
)
|
|
|
|
|
// 仅移除取消勾选的项
|
|
|
|
|
state.editableTableData = state.editableTableData.filter(
|
|
|
|
@@ -558,22 +407,34 @@ const handleSelectDialogConfirm = () => {
|
|
|
|
|
// $table.setRow(item)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
state.spuSelectDialogVisible = false
|
|
|
|
|
state.erpSpuSelectDialogVisible = false
|
|
|
|
|
console.log("state.editableTableData", state.editableTableData)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 整理数据
|
|
|
|
|
const cgPlanSpuItems = computed(() => {
|
|
|
|
|
return state.editableTableData.map((item: any) => {
|
|
|
|
|
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
|
|
|
|
|
return {
|
|
|
|
|
id: item.isNew ? undefined : item.id,
|
|
|
|
|
erpSpuId: item.erpSpuId,
|
|
|
|
|
quantity: item.quantity,
|
|
|
|
|
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
|
|
|
|
|
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
|
|
|
|
|
remark: item.remark,
|
|
|
|
|
unitId: item.unitId,
|
|
|
|
|
if (item.erpUnitVos) {
|
|
|
|
|
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
|
|
|
|
|
return {
|
|
|
|
|
id: item.isNew ? undefined : item.id,
|
|
|
|
|
erpSpuId: item.erpSpuId,
|
|
|
|
|
quantity: item.quantity,
|
|
|
|
|
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
|
|
|
|
|
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
|
|
|
|
|
remark: item.remark,
|
|
|
|
|
unitId: item.unitId,
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
id: item.isNew ? undefined : item.id,
|
|
|
|
|
erpSpuId: item.erpSpuId,
|
|
|
|
|
quantity: item.quantity,
|
|
|
|
|
unitPrice: item.unitPrice ? storePrice(item.unitPrice) : 0,
|
|
|
|
|
totalAmount: Number(item.unitPrice || 0) * item.quantity,
|
|
|
|
|
remark: item.remark,
|
|
|
|
|
unitId: item.unitId,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
@@ -666,8 +527,8 @@ const clearData = () => {
|
|
|
|
|
}
|
|
|
|
|
state.insertedRowNumber = 0
|
|
|
|
|
state.editableTableData = []
|
|
|
|
|
state.erpSpuItemsMemo = []
|
|
|
|
|
state.selectedRowsErpSpuIds = []
|
|
|
|
|
state.selectedSpuObjs = []
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|