diff --git a/src/api/admin/user.ts b/src/api/admin/user.ts
index 724310e..416043b 100644
--- a/src/api/admin/user.ts
+++ b/src/api/admin/user.ts
@@ -142,3 +142,12 @@ export function validatePhone(rule: any, value: any, callback: any, isEdit: bool
}
})
}
+
+// 获取简要用户信息
+export function getSimpleUserAll(params: { name?: string; mobile?: string }) {
+ return request({
+ url: "/admin/user/getSimpleUserAll",
+ method: "get",
+ params,
+ })
+}
diff --git a/src/api/supermarketerp/common.ts b/src/api/supermarketerp/common.ts
index 2e3eefc..1fb2b86 100644
--- a/src/api/supermarketerp/common.ts
+++ b/src/api/supermarketerp/common.ts
@@ -10,8 +10,8 @@ export function getPlanCode(params: { type: 1 | 2 }) {
})
}
-// 获取采购计划和订单所选择的商品的列表
-export function getCgPlanSpuPage() {
+// 获取erp商品列表
+export function getErpSpuPage() {
return request({
url: "/supermarket/smErpCgPlan/erpSpuPage",
method: "get",
diff --git a/src/components/Select/SelectHandlerUser.vue b/src/components/Select/SelectHandlerUser.vue
new file mode 100644
index 0000000..c8025b6
--- /dev/null
+++ b/src/components/Select/SelectHandlerUser.vue
@@ -0,0 +1,82 @@
+
+ e && getOptions()"
+ >
+
+
+
+
+
+
+
diff --git a/src/components/index.ts b/src/components/index.ts
index 6c169e8..227f315 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -22,6 +22,7 @@ import SelectDept from "/@/components/Select/SelectDept.vue"
import SelectCtcg from "/@/components/Select/SelectCtcg.vue"
import SelectCtcgol from "/@/components/Select/SelectCtcgol.vue"
import SelectHardGroup from "/@/components/Select/selectHardGroup.vue"
+import SelectHandlerUser from "/@/components/Select/SelectHandlerUser.vue"
// 第三方组件
import ElementPlus from "element-plus"
@@ -66,6 +67,7 @@ export default {
app.component("SelectCtcg", SelectCtcg)
app.component("SelectCtcgol", SelectCtcgol)
app.component("SelectHardGroup", SelectHardGroup)
+ app.component("SelectHandlerUser", SelectHandlerUser)
// 导入全部的elmenet-plus的图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
diff --git a/src/views/supermarketerp/components/erpSpuSelectDialog.vue b/src/views/supermarketerp/components/erpSpuSelectDialog.vue
new file mode 100644
index 0000000..00732c2
--- /dev/null
+++ b/src/views/supermarketerp/components/erpSpuSelectDialog.vue
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确认
+
+
+
+
+
diff --git a/src/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue b/src/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue
new file mode 100644
index 0000000..197a131
--- /dev/null
+++ b/src/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确认
+
+
+
+
+
diff --git a/src/views/supermarketerp/smErpCgDd/smErpCgDdOption.vue b/src/views/supermarketerp/smErpCgDd/smErpCgDdOption.vue
index ddecd0d..c7156ef 100644
--- a/src/views/supermarketerp/smErpCgDd/smErpCgDdOption.vue
+++ b/src/views/supermarketerp/smErpCgDd/smErpCgDdOption.vue
@@ -12,16 +12,14 @@
-
-
-
+
-
-
{{ row.productName }}
@@ -155,18 +147,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -182,182 +162,43 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 取消
- 确认
-
-
+
-
diff --git a/src/views/supermarketerp/smErpCgPlan/cgPlanOption.vue b/src/views/supermarketerp/smErpCgPlan/cgPlanOption.vue
index 341144e..0c97a44 100644
--- a/src/views/supermarketerp/smErpCgPlan/cgPlanOption.vue
+++ b/src/views/supermarketerp/smErpCgPlan/cgPlanOption.vue
@@ -11,7 +11,7 @@
-
+
@@ -158,71 +158,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 取消
- 确认
-
-
+
@@ -231,47 +172,23 @@
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/smErpCgPlan"
-import { getPlanCode, getCgPlanSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
+import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgPlan"
+import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
+import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
import { storePrice } from "/@/utils/formatMoney"
import { formatDate } from "/@/utils/formatTime"
-// 基本表单数据类型
-interface FormVO {
- id: string | undefined
- planCode: string
- orderNumber: string
- planDate: string
- supplierId: string
- handlerUserId: string
- remark: 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 router = useRouter()
const route = useRoute()
+const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
const loading = ref(false) // 采购计划加载
-const spuListLoading = ref(false) // 对话框商品列表加载
const baseDataFormRef = ref() // 基本数据表单ref
-const editableTableRef = ref>() // 可编辑表格ref
-const spuMultipleTableRef = ref() // 对话框多选表格ref
+const editableTableRef = ref>() // 可编辑表格ref
const supplierTypeDict = ref([]) // 货商下拉选项
-
// 基本信息表单数据
-const baseDataForm = reactive({
+const baseDataForm = reactive({
id: undefined,
planCode: "",
orderNumber: "",
@@ -281,24 +198,19 @@ const baseDataForm = reactive({
remark: "",
})
const state = reactive<{
- editableTableData: RowVO[]
- erpSpuItemsMemo: RowVO[]
+ editableTableData: any[]
+ erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
- spuSelectDialogVisible: boolean
- spuDataList: any[]
- selectedSpuObjs: any[]
+ erpSpuSelectDialogVisible: boolean
}>({
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
-
- spuSelectDialogVisible: false, // 商品选择对话框开关
- spuDataList: [], // 商品列表
- selectedSpuObjs: [], // 已选中的商品列表项
+ erpSpuSelectDialogVisible: false, // 商品选择对话框开关
})
// 基本信息表单校验规则
@@ -309,7 +221,7 @@ const dataRules = ref({
})
// 可编辑表格校验规则
-const validRules = ref>({
+const validRules = ref>({
unitId: [{ required: true, message: "必须选择" }],
quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }],
})
@@ -349,19 +261,9 @@ const getInitData = async () => {
planCode && planCode.code === 0 && (baseDataForm.planCode = planCode.data)
}
-// 可编辑表格行勾选
-const selectChangeEvent: VxeTableEvents.CheckboxChange = ({ checked }) => {
- const $table = editableTableRef.value
- if ($table) {
- const records = $table.getCheckboxRecords()
- console.log(checked ? "勾选事件" : "取消事件", records)
- state.selectedRowsErpSpuIds = records.map((item) => item.erpSpuId)
- }
-}
-
// 顶部表格行新增
const addEvent = () => {
- const newRow: RowVO = {
+ const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
@@ -381,7 +283,7 @@ const addEvent = () => {
// 底部表格行新增
const pushEvent = () => {
- const newRow: RowVO = {
+ const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
@@ -401,7 +303,7 @@ const pushEvent = () => {
// 在指定行插入
const insertEvent = () => {
- const newRow: RowVO = {
+ const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
@@ -430,86 +332,27 @@ const removeSelectRowEvent = () => {
}
}
+// 可编辑表格行勾选
+const selectChangeEvent: VxeTableEvents.CheckboxChange = ({ 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 }
@@ -519,7 +362,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(
@@ -532,7 +375,7 @@ const handleSelectDialogConfirm = () => {
// $table.setRow(item)
// }
// })
- state.spuSelectDialogVisible = false
+ state.erpSpuSelectDialogVisible = false
console.log("state.editableTableData", state.editableTableData)
}
@@ -640,8 +483,8 @@ const clearData = () => {
}
state.insertedRowNumber = 0
state.editableTableData = []
+ state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
- state.selectedSpuObjs = []
return true
}