1
This commit is contained in:
1 parent
b324eaabf5
commit
af7acf6a58
5 files changed
+943
-293
No files matched your search
@@ -1,200 +1,140 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible"
|
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||||
:close-on-click-modal="false" draggable>
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
|
||||||
<el-row :gutter="24">
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="编号" prop="code">
|
|
||||||
<el-input v-model="form.code" placeholder="请输入编号"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item label="单据日期" prop="dDate">
|
<el-form-item label="出入库数量" prop="quantity">
|
||||||
<el-date-picker type="date" placeholder="请选择单据日期" v-model="form.dDate" :value-format="dateStr"></el-date-picker>
|
<el-input v-model="form.quantity" placeholder="请输入出入库数量" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item label="仓库id" prop="warehouseId">
|
<el-form-item label="累计进货数量" prop="totalNumber">
|
||||||
<el-input v-model="form.warehouseId" placeholder="请输入仓库id"/>
|
<el-input v-model="form.totalNumber" placeholder="请输入累计进货数量" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item label="经办人id" prop="handlerUserId">
|
<el-form-item label="累计总金额" prop="totalAmount">
|
||||||
<el-select v-model="form.handlerUserId" placeholder="请选择经办人id">
|
<el-input v-model="form.totalAmount" placeholder="请输入累计总金额" />
|
||||||
<el-option label="请选择">0</el-option>
|
</el-form-item>
|
||||||
</el-select>
|
</el-col>
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item label="审批状态" prop="checkStatus">
|
<el-form-item label="货商" prop="supplierId">
|
||||||
<el-input v-model="form.checkStatus" placeholder="请输入审批状态"/>
|
<el-input v-model="form.supplierId" placeholder="请输入货商" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
<el-col :span="12" class="mb20">
|
||||||
<el-form-item label="审批人id" prop="checkUserId">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-select v-model="form.checkUserId" placeholder="请选择审批人id">
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
<el-option label="请选择">0</el-option>
|
</el-form-item>
|
||||||
</el-select>
|
</el-col>
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="审核日期" prop="checkTime">
|
|
||||||
<el-input v-model="form.checkTime" placeholder="请输入审核日期"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="商户编号" prop="merchantId">
|
|
||||||
<el-input v-model="form.merchantId" placeholder="请输入商户编号"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="部门id" prop="deptId">
|
|
||||||
<el-input v-model="form.deptId" placeholder="请输入部门id"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="出入库数量" prop="quantity">
|
|
||||||
<el-input v-model="form.quantity" placeholder="请输入出入库数量"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="累计进货数量" prop="totalNumber">
|
|
||||||
<el-input v-model="form.totalNumber" placeholder="请输入累计进货数量"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="累计总金额" prop="totalAmount">
|
|
||||||
<el-input v-model="form.totalAmount" placeholder="请输入累计总金额"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="货商" prop="supplierId">
|
|
||||||
<el-input v-model="form.supplierId" placeholder="请输入货商"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="备注" prop="remark">
|
|
||||||
<el-input v-model="form.remark" placeholder="请输入备注"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="mb20">
|
|
||||||
<el-form-item label="订单编号" prop="orderNumber">
|
|
||||||
<el-input v-model="form.orderNumber" placeholder="请输入订单编号"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="订单编号" prop="orderNumber">
|
||||||
|
<el-input v-model="form.orderNumber" placeholder="请输入订单编号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="visible = false">取消</el-button>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="SmErpCgDdDialog">
|
<script setup lang="ts" name="SmErpCgDdDialog">
|
||||||
import { useDict } from '/@/hooks/dict';
|
import { useDict } from "/@/hooks/dict"
|
||||||
import { useMessage } from "/@/hooks/message";
|
import { useMessage } from "/@/hooks/message"
|
||||||
import { getObj, addObj, putObj } from '/@/api/supermarket/smErpCgDd'
|
import { getObj, addObj, putObj } from "/@/api/supermarket/smErpCgDd"
|
||||||
import { rule } from '/@/utils/validate';
|
import { rule } from "/@/utils/validate"
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(["refresh"])
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref()
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
// 定义字典
|
// 定义字典
|
||||||
const { check_status } = useDict('check_status')
|
const { check_status } = useDict("check_status")
|
||||||
|
|
||||||
// 提交表单数据
|
// 提交表单数据
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id:'',
|
id: "",
|
||||||
code: '',
|
code: "",
|
||||||
dDate: '',
|
dDate: "",
|
||||||
warehouseId: '',
|
warehouseId: "",
|
||||||
handlerUserId: '',
|
handlerUserId: "",
|
||||||
checkStatus: '',
|
checkStatus: "",
|
||||||
checkUserId: '',
|
checkUserId: "",
|
||||||
checkTime: '',
|
checkTime: "",
|
||||||
merchantId: '',
|
merchantId: "",
|
||||||
deptId: '',
|
deptId: "",
|
||||||
quantity: '',
|
quantity: "",
|
||||||
totalNumber: '',
|
totalNumber: "",
|
||||||
totalAmount: '',
|
totalAmount: "",
|
||||||
supplierId: '',
|
supplierId: "",
|
||||||
remark: '',
|
remark: "",
|
||||||
orderNumber: '',
|
orderNumber: "",
|
||||||
});
|
})
|
||||||
|
|
||||||
// 定义校验规则
|
// 定义校验规则
|
||||||
const dataRules = ref({
|
const dataRules = ref({})
|
||||||
})
|
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = (id: string) => {
|
const openDialog = (id: string) => {
|
||||||
visible.value = true
|
visible.value = true
|
||||||
form.id = ''
|
form.id = ""
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dataFormRef.value?.resetFields();
|
dataFormRef.value?.resetFields()
|
||||||
});
|
})
|
||||||
|
|
||||||
// 获取smErpCgDd信息
|
// 获取smErpCgDd信息
|
||||||
if (id) {
|
if (id) {
|
||||||
form.id = id
|
form.id = id
|
||||||
getsmErpCgDdData(id)
|
getsmErpCgDdData(id)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||||
if (!valid) return false;
|
if (!valid) return false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true
|
||||||
form.id ? await putObj(form) : await addObj(form);
|
form.id ? await putObj(form) : await addObj(form)
|
||||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||||
visible.value = false;
|
visible.value = false
|
||||||
emit('refresh');
|
emit("refresh")
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error(err.msg);
|
useMessage().error(err.msg)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
// 初始化表单数据
|
// 初始化表单数据
|
||||||
const getsmErpCgDdData = (id: string) => {
|
const getsmErpCgDdData = (id: string) => {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
loading.value = true
|
loading.value = true
|
||||||
getObj(id).then((res: any) => {
|
getObj(id)
|
||||||
Object.assign(form, res.data)
|
.then((res: any) => {
|
||||||
}).finally(() => {
|
Object.assign(form, res.data)
|
||||||
loading.value = false
|
})
|
||||||
})
|
.finally(() => {
|
||||||
};
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog
|
openDialog,
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="layout-padding">
|
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
|
||||||
<el-row>
|
|
||||||
<div class="mb8" style="width: 100%">
|
|
||||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
|
||||||
v-auth="'supermarket_smErpCgDd_add'">
|
|
||||||
新 增
|
|
||||||
</el-button>
|
|
||||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
|
||||||
v-auth="'supermarket_smErpCgDd_del'" @click="handleDelete(selectObjs)">
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
<right-toolbar v-model:showSearch="showSearch" :export="'supermarket_smErpCgDd_export'"
|
|
||||||
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
|
||||||
@queryTable="getDataList"></right-toolbar>
|
|
||||||
</div>
|
|
||||||
</el-row>
|
|
||||||
<el-table :data="state.dataList" v-loading="state.loading" border
|
|
||||||
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
|
||||||
@selection-change="selectionChangHandle"
|
|
||||||
@sort-change="sortChangeHandle">
|
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
|
||||||
<el-table-column type="index" label="#" width="40" />
|
|
||||||
<el-table-column prop="code" label="编号" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="dDate" label="单据日期" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="warehouseId" label="仓库id" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="handlerUserId" label="经办人id" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="checkStatus" label="审批状态" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<dict-tag :options="check_status" :value="scope.row.checkStatus"></dict-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="checkUserId" label="审批人id" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="checkTime" label="审核日期" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="merchantId" label="商户编号" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="deptId" label="部门id" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="quantity" label="出入库数量" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="totalNumber" label="累计进货数量" show-overflow-tooltip/>
|
|
||||||
<el-table-column prop="totalAmount" 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="orderNumber" label="订单编号" show-overflow-tooltip/>
|
|
||||||
<el-table-column label="操作" width="150">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'supermarket_smErpCgDd_edit'"
|
|
||||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
|
||||||
<el-button icon="delete" text type="primary" v-auth="'supermarket_smErpCgDd_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 编辑、新增 -->
|
|
||||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts" name="systemSmErpCgDd">
|
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
|
||||||
import { fetchList, delObjs } from "/@/api/supermarket/smErpCgDd";
|
|
||||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
|
||||||
import { useDict } from '/@/hooks/dict';
|
|
||||||
|
|
||||||
// 引入组件
|
|
||||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
|
||||||
// 定义查询字典
|
|
||||||
|
|
||||||
const { check_status } = useDict('check_status')
|
|
||||||
// 定义变量内容
|
|
||||||
const formDialogRef = ref()
|
|
||||||
// 搜索变量
|
|
||||||
const queryRef = ref()
|
|
||||||
const showSearch = ref(true)
|
|
||||||
// 多选变量
|
|
||||||
const selectObjs = ref([]) as any
|
|
||||||
const multiple = ref(true)
|
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
|
||||||
queryForm: {},
|
|
||||||
pageList: fetchList
|
|
||||||
})
|
|
||||||
|
|
||||||
// table hook
|
|
||||||
const {
|
|
||||||
getDataList,
|
|
||||||
currentChangeHandle,
|
|
||||||
sizeChangeHandle,
|
|
||||||
sortChangeHandle,
|
|
||||||
downBlobFile,
|
|
||||||
tableStyle
|
|
||||||
} = useTable(state)
|
|
||||||
|
|
||||||
// 清空搜索条件
|
|
||||||
const resetQuery = () => {
|
|
||||||
// 清空搜索条件
|
|
||||||
queryRef.value?.resetFields()
|
|
||||||
// 清空多选
|
|
||||||
selectObjs.value = []
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出excel
|
|
||||||
const exportExcel = () => {
|
|
||||||
downBlobFile('/supermarket/smErpCgDd/export', Object.assign(state.queryForm, { ids: selectObjs }), 'smErpCgDd.xlsx')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多选事件
|
|
||||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
|
||||||
selectObjs.value = objs.map(({ id }) => id);
|
|
||||||
multiple.value = !objs.length;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除操作
|
|
||||||
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>
|
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-row>
|
||||||
|
<div class="mb8" style="width: 100%">
|
||||||
|
<el-button icon="folder-add" type="primary" class="ml10" @click="handleClickCreateCgPlan" v-auth="'supermarket_smErpCgDd_add'">
|
||||||
|
新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
:disabled="multiple"
|
||||||
|
icon="Delete"
|
||||||
|
type="primary"
|
||||||
|
v-auth="'supermarket_smErpCgDd_del'"
|
||||||
|
@click="handleDelete(selectObjs)"
|
||||||
|
>
|
||||||
|
删 除
|
||||||
|
</el-button>
|
||||||
|
<right-toolbar
|
||||||
|
v-model:showSearch="showSearch"
|
||||||
|
:export="'supermarket_smErpCgDd_export'"
|
||||||
|
@exportExcel="exportExcel"
|
||||||
|
class="ml10 mr20"
|
||||||
|
style="float: right"
|
||||||
|
@queryTable="getDataList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
:data="state.dataList"
|
||||||
|
v-loading="state.loading"
|
||||||
|
border
|
||||||
|
:cell-style="tableStyle.cellStyle"
|
||||||
|
:header-cell-style="tableStyle.headerCellStyle"
|
||||||
|
@selection-change="selectionChangHandle"
|
||||||
|
@sort-change="sortChangeHandle"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
|
<el-table-column type="index" label="#" width="40" />
|
||||||
|
<el-table-column prop="code" label="编号" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="dDate" label="单据日期" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="warehouseId" label="仓库id" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="handlerUserId" label="经办人id" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="checkStatus" label="审批状态" show-overflow-tooltip>
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="check_status" :value="scope.row.checkStatus"></dict-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="checkUserId" label="审批人id" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="checkTime" label="审核日期" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="merchantId" label="商户编号" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="deptId" label="部门id" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="quantity" label="出入库数量" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="totalNumber" label="累计进货数量" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="totalAmount" 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="orderNumber" label="订单编号" show-overflow-tooltip />
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button icon="edit-pen" text type="primary" v-auth="'supermarket_smErpCgDd_edit'" @click="handleClickEditCgPlan">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'supermarket_smErpCgDd_del'" @click="handleDelete([scope.row.id])">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="systemSmErpCgDd">
|
||||||
|
import { useRouter } from "vue-router"
|
||||||
|
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||||
|
import { fetchList, delObjs } from "/@/api/supermarket/smErpCgDd"
|
||||||
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||||
|
import { useDict } from "/@/hooks/dict"
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const { check_status } = useDict("check_status")
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 多选变量
|
||||||
|
const selectObjs = ref([]) as any
|
||||||
|
const multiple = ref(true)
|
||||||
|
|
||||||
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
|
queryForm: {},
|
||||||
|
pageList: fetchList,
|
||||||
|
})
|
||||||
|
|
||||||
|
// table hook
|
||||||
|
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
|
||||||
|
|
||||||
|
// 清空搜索条件
|
||||||
|
// const resetQuery = () => {
|
||||||
|
// // 清空搜索条件
|
||||||
|
// queryRef.value?.resetFields()
|
||||||
|
// // 清空多选
|
||||||
|
// selectObjs.value = []
|
||||||
|
// getDataList()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
downBlobFile("/supermarket/smErpCgDd/export", Object.assign(state.queryForm, { ids: selectObjs }), "smErpCgDd.xlsx")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选事件
|
||||||
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
|
selectObjs.value = objs.map(({ id }) => id)
|
||||||
|
multiple.value = !objs.length
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击创建采购清单
|
||||||
|
const handleClickCreateCgPlan = () => router.push({ path: "/supermarketerp/smErpCgDd/smErpCgDdOption" })
|
||||||
|
// 点击编辑采购清单
|
||||||
|
const handleClickEditCgPlan = (id: string) => router.push({ path: "/supermarketerp/smErpCgDd/smErpCgDdOption", query: { id } })
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
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>
|
||||||
@@ -0,0 +1,704 @@
|
|||||||
|
<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">
|
||||||
|
<div class="flex flex-wrap">
|
||||||
|
<el-form-item label="采购订单编号" prop="code">
|
||||||
|
<el-input v-model.trim="baseDataForm.code" placeholder="请输入采购订单编号" disabled style="width: 200px" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="单据日期" prop="dDate">
|
||||||
|
<el-date-picker
|
||||||
|
style="width: 200px"
|
||||||
|
v-model.trim="baseDataForm.dDate"
|
||||||
|
type="date"
|
||||||
|
placeholder="请选择单据日期"
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="仓库id" prop="warehouseId">
|
||||||
|
<el-input v-model.trim="baseDataForm.warehouseId" placeholder="请输入仓库id" disabled style="width: 200px" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="经办人id" prop="handlerUserId">
|
||||||
|
<el-input v-model.trim="baseDataForm.handlerUserId" placeholder="请选择经办人id" maxlength="50" style="width: 200px" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="审批状态" prop="checkStatus">
|
||||||
|
<el-input v-model="baseDataForm.checkStatus" placeholder="请输入审批状态" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="审批人id" prop="checkUserId">
|
||||||
|
<el-input v-model="baseDataForm.checkUserId" placeholder="请选择审批人id" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="审核日期" prop="checkTime">
|
||||||
|
<el-date-picker
|
||||||
|
style="width: 200px"
|
||||||
|
v-model.trim="baseDataForm.checkTime"
|
||||||
|
type="date"
|
||||||
|
placeholder="请选择审核日期"
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="商户编号" prop="merchantId">
|
||||||
|
<el-input v-model="baseDataForm.merchantId" placeholder="请输入商户编号" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="部门id" prop="deptId">
|
||||||
|
<el-input v-model="baseDataForm.deptId" placeholder="请输入部门id" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="货商" prop="supplierId">
|
||||||
|
<el-select v-model.trim="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="warehouseId">
|
||||||
|
<el-input v-model.trim="baseDataForm.warehouseId" placeholder="请输入仓库id" />
|
||||||
|
</el-form-item> -->
|
||||||
|
|
||||||
|
<el-form-item label="经办人" prop="handlerUserId">
|
||||||
|
<el-input v-model.trim="baseDataForm.handlerUserId" placeholder="请输入经办人" maxlength="20" style="width: 200px" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" maxlength="50" style="width: 200px" />
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row class="my-3">
|
||||||
|
<el-button @click="addEvent">新增(顶部)</el-button>
|
||||||
|
<el-button @click="pushEvent">新增(尾部)</el-button>
|
||||||
|
<el-button @click="insertEvent">
|
||||||
|
在第
|
||||||
|
<el-input-number
|
||||||
|
@click.stop
|
||||||
|
v-model="state.insertedRowNumber"
|
||||||
|
:min="0"
|
||||||
|
:max="state.editableTableData.length"
|
||||||
|
:precision="0"
|
||||||
|
size="small"
|
||||||
|
controls-position="right"
|
||||||
|
style="min-width: 50px; margin: 0 5px"
|
||||||
|
/>
|
||||||
|
行新增
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
|
||||||
|
<el-button @click="clearData">清空数据</el-button>
|
||||||
|
<el-button @click="handleClickSpuSelect">商品选择</el-button>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<vxe-table
|
||||||
|
ref="editableTableRef"
|
||||||
|
border
|
||||||
|
:loading="loading"
|
||||||
|
show-overflow
|
||||||
|
max-height="400"
|
||||||
|
:edit-config="{
|
||||||
|
trigger: 'click',
|
||||||
|
mode: 'cell',
|
||||||
|
beforeEditMethod({ row, column }:any) {
|
||||||
|
// 禁止编辑
|
||||||
|
if (column.property === '') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
}"
|
||||||
|
:column-config="{ resizable: true }"
|
||||||
|
:row-config="{ isHover: true }"
|
||||||
|
:resizable-config="{ dragMode: 'fixed' }"
|
||||||
|
:data="state.editableTableData"
|
||||||
|
:edit-rules="validRules"
|
||||||
|
@checkbox-all="selectChangeEvent"
|
||||||
|
@checkbox-change="selectChangeEvent"
|
||||||
|
size="mini"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<vxe-column type="checkbox" width="40" fixed="left" />
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
|
||||||
|
<vxe-column field="unitId" title="包装单位" :edit-render="{}">
|
||||||
|
<template #edit="{ row }">
|
||||||
|
<el-select v-model="row.unitId" placeholder="请选择包装单位">
|
||||||
|
<el-option
|
||||||
|
v-if="row.erpUnitVos?.length > 0"
|
||||||
|
v-for="item in row.erpUnitVos"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.unit"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span v-if="row.unitId">{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
|
||||||
|
<span v-else style="color: #c0c4cf">请选择</span>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
|
||||||
|
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
|
<template #edit="{ row }">
|
||||||
|
<el-input v-model="row.quantity" />
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
|
||||||
|
<vxe-column field="unitPrice" title="进价">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
|
||||||
|
<vxe-column field="totalAmount" title="累计总金额">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{
|
||||||
|
row.unitId && row.quantity
|
||||||
|
? Number(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice) * row.quantity
|
||||||
|
: ""
|
||||||
|
}}
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
|
||||||
|
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
|
<template #edit="{ row }">
|
||||||
|
<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">
|
||||||
|
<el-tooltip effect="dark" content="返回列表页面" placement="top">
|
||||||
|
<el-button type="primary" plain @click="router.back()">取消</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip v-if="!baseDataForm.id" effect="dark" content="保存并清空数据" placement="top">
|
||||||
|
<el-button type="primary" plain @click="onContinueAdd">继续添加</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip effect="dark" content="保存并返回列表页面" placement="top">
|
||||||
|
<el-button type="primary" plain @click="onSave">保存</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</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> -->
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="SmErpCgPlanDialog">
|
||||||
|
import { ref, reactive, computed, onMounted } from "vue"
|
||||||
|
import { useRouter, useRoute } from "vue-router"
|
||||||
|
import { useDict } from "/@/hooks/dict"
|
||||||
|
import { useMessage } from "/@/hooks/message"
|
||||||
|
import { getObj, addObj, putObj, getPlanCode, getCgPlanSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/smErpCgPlan"
|
||||||
|
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||||
|
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||||
|
import { storePrice } from "/@/utils/formatMoney"
|
||||||
|
|
||||||
|
// 基本表单数据类型
|
||||||
|
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 loading = ref(false) // 采购计划加载
|
||||||
|
const spuListLoading = ref(false) // 对话框商品列表加载
|
||||||
|
const baseDataFormRef = ref() // 基本数据表单ref
|
||||||
|
const editableTableRef = ref<VxeTableInstance<RowVO>>() // 可编辑表格ref
|
||||||
|
const spuMultipleTableRef = ref() // 对话框多选表格ref
|
||||||
|
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||||
|
|
||||||
|
// 基本信息表单数据
|
||||||
|
const baseDataForm = reactive<FormVO>({
|
||||||
|
id: undefined,
|
||||||
|
planCode: "",
|
||||||
|
orderNumber: "",
|
||||||
|
planDate: "",
|
||||||
|
supplierId: "",
|
||||||
|
handlerUserId: "",
|
||||||
|
remark: "",
|
||||||
|
})
|
||||||
|
const state = reactive<{
|
||||||
|
editableTableData: RowVO[]
|
||||||
|
erpSpuItemsMemo: RowVO[]
|
||||||
|
selectedRowsErpSpuIds: string[]
|
||||||
|
insertedRowNumber: number
|
||||||
|
erpSpuSimpleAll: any
|
||||||
|
spuSelectDialogVisible: boolean
|
||||||
|
spuDataList: any[]
|
||||||
|
selectedSpuObjs: any[]
|
||||||
|
}>({
|
||||||
|
editableTableData: [], // 可编辑表格数据
|
||||||
|
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||||
|
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
|
||||||
|
insertedRowNumber: 0, // 可编辑表格插入行的行号
|
||||||
|
erpSpuSimpleAll: [], // 简要商品列表
|
||||||
|
|
||||||
|
spuSelectDialogVisible: false, // 商品选择对话框开关
|
||||||
|
spuDataList: [], // 商品列表
|
||||||
|
selectedSpuObjs: [], // 已选中的商品列表项
|
||||||
|
})
|
||||||
|
|
||||||
|
// 基本信息表单校验规则
|
||||||
|
const dataRules = ref({
|
||||||
|
planCode: [{ required: true, message: "采购计划编号不能为空", trigger: "blur" }],
|
||||||
|
planDate: [{ required: true, message: "采购计划单据日期不能为空", trigger: "blur" }],
|
||||||
|
supplierId: [{ required: true, message: "货商不能为空", trigger: "blur" }],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 可编辑表格校验规则
|
||||||
|
const validRules = ref<VxeTablePropTypes.EditRules<RowVO>>({
|
||||||
|
unitId: [{ required: true, message: "必须选择" }],
|
||||||
|
quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
const getInitData = async () => {
|
||||||
|
baseDataForm.id = undefined
|
||||||
|
const id = route.query.id as string
|
||||||
|
if (id) {
|
||||||
|
loading.value = true
|
||||||
|
// 获取采购计划数据 & 获取简要商品列表
|
||||||
|
const [cgPlanData, erpSpuSimpleAll] = await Promise.allSettled([getObj(id), getErpSpuSimpleAll()])
|
||||||
|
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||||
|
.finally(() => (loading.value = false))
|
||||||
|
|
||||||
|
if (cgPlanData && cgPlanData.code === 0) {
|
||||||
|
Object.assign(baseDataForm, {
|
||||||
|
id: cgPlanData.data.id,
|
||||||
|
planCode: cgPlanData.data.planCode,
|
||||||
|
orderNumber: cgPlanData.data.orderNumber,
|
||||||
|
planDate: cgPlanData.data.planDate,
|
||||||
|
supplierId: cgPlanData.data.supplierId,
|
||||||
|
handlerUserId: cgPlanData.data.handlerUserId,
|
||||||
|
remark: cgPlanData.data.remark,
|
||||||
|
})
|
||||||
|
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()]).then((results) =>
|
||||||
|
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
||||||
|
)
|
||||||
|
supplierTypeOptions && supplierTypeOptions.code === 0 && (supplierTypeDict.value = supplierTypeOptions.data)
|
||||||
|
planCode && planCode.code === 0 && (baseDataForm.planCode = 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 addEvent = () => {
|
||||||
|
const newRow: RowVO = {
|
||||||
|
id: "",
|
||||||
|
erpSpuId: "",
|
||||||
|
quantity: null,
|
||||||
|
unitPrice: null,
|
||||||
|
totalAmount: null,
|
||||||
|
remark: "",
|
||||||
|
unitId: "",
|
||||||
|
}
|
||||||
|
state.editableTableData.unshift(newRow)
|
||||||
|
nextTick(() => {
|
||||||
|
const $table = editableTableRef.value
|
||||||
|
if ($table) {
|
||||||
|
$table.setEditRow(newRow)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 底部表格行新增
|
||||||
|
const pushEvent = () => {
|
||||||
|
const newRow: RowVO = {
|
||||||
|
id: "",
|
||||||
|
erpSpuId: "",
|
||||||
|
quantity: null,
|
||||||
|
unitPrice: null,
|
||||||
|
totalAmount: null,
|
||||||
|
remark: "",
|
||||||
|
unitId: "",
|
||||||
|
}
|
||||||
|
state.editableTableData.push(newRow)
|
||||||
|
nextTick(() => {
|
||||||
|
const $table = editableTableRef.value
|
||||||
|
if ($table) {
|
||||||
|
$table.setEditRow(newRow)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在指定行插入
|
||||||
|
const insertEvent = () => {
|
||||||
|
const newRow: RowVO = {
|
||||||
|
id: "",
|
||||||
|
erpSpuId: "",
|
||||||
|
quantity: null,
|
||||||
|
unitPrice: null,
|
||||||
|
totalAmount: null,
|
||||||
|
remark: "",
|
||||||
|
unitId: "",
|
||||||
|
}
|
||||||
|
state.editableTableData.splice(state.insertedRowNumber, 0, newRow)
|
||||||
|
nextTick(() => {
|
||||||
|
const $table = editableTableRef.value
|
||||||
|
if ($table) {
|
||||||
|
$table.setEditRow(newRow)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除选中的行
|
||||||
|
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 handleClickSpuSelect = async () => {
|
||||||
|
state.selectedSpuObjs = [...state.editableTableData]
|
||||||
|
|
||||||
|
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 addedItems = state.selectedSpuObjs
|
||||||
|
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
|
||||||
|
.map((addItem) => {
|
||||||
|
if (state.erpSpuItemsMemo.some((item: any) => item.erpSpuId === addItem.erpSpuId)) return addItem
|
||||||
|
return { ...addItem, isNew: true }
|
||||||
|
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
|
||||||
|
// 仅添加新勾选的项
|
||||||
|
state.editableTableData = [...state.editableTableData, ...addedItems]
|
||||||
|
|
||||||
|
// 筛选取消勾选的项
|
||||||
|
const removedItems = state.editableTableData.filter(
|
||||||
|
(item: any) => !state.selectedSpuObjs.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)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
state.spuSelectDialogVisible = 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,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 点击继续添加
|
||||||
|
const onContinueAdd = async () => {
|
||||||
|
console.log("baseDataForm", baseDataForm)
|
||||||
|
console.log("state.editableTableData", state.editableTableData)
|
||||||
|
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击保存
|
||||||
|
const onSave = async () => {
|
||||||
|
console.log("baseDataForm", baseDataForm)
|
||||||
|
console.log("state.editableTableData", state.editableTableData)
|
||||||
|
;(await baseDataFormValidate()) &&
|
||||||
|
checkSelectSpu() &&
|
||||||
|
(await editableTableValidate()) &&
|
||||||
|
(await submitData()) &&
|
||||||
|
clearData() &&
|
||||||
|
router.replace({ path: "/supermarketerp/smErpCgDd/index" })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验基本数据表单 成功返回 true 失败返回 undefined
|
||||||
|
const baseDataFormValidate = async () => {
|
||||||
|
const valid = await baseDataFormRef.value.validate().catch(() => {})
|
||||||
|
return valid
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验是否选择了商品 成功返回 true 失败返回 false
|
||||||
|
const checkSelectSpu = () => {
|
||||||
|
if (state.editableTableData.length <= 0) {
|
||||||
|
useMessage().warning("请选择商品")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验可编辑表格 成功返回 true 失败返回 false
|
||||||
|
const editableTableValidate = async () => {
|
||||||
|
// 全量校验
|
||||||
|
const $table = editableTableRef.value
|
||||||
|
if ($table) {
|
||||||
|
const errMap = await $table.validate(true)
|
||||||
|
if (errMap) {
|
||||||
|
console.log("全量校验失败!")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
console.log("全量校验成功!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交数据 成功返回 true 失败返回 false
|
||||||
|
const submitData = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
|
const _pa = {
|
||||||
|
...baseDataForm,
|
||||||
|
items: cgPlanSpuItems.value,
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("提交的数据:", _pa)
|
||||||
|
|
||||||
|
const res = baseDataForm.id
|
||||||
|
? await putObj(_pa).finally(() => (loading.value = false))
|
||||||
|
: await addObj(_pa).finally(() => (loading.value = false))
|
||||||
|
if (res.code === 0) {
|
||||||
|
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
useMessage().error(res.msg)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg)
|
||||||
|
loading.value = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空填写的数据 返回 true
|
||||||
|
const clearData = () => {
|
||||||
|
for (const key in baseDataForm) {
|
||||||
|
if (key === "planCode" || key === "id") continue
|
||||||
|
baseDataForm[key] = ""
|
||||||
|
}
|
||||||
|
state.insertedRowNumber = 0
|
||||||
|
state.editableTableData = []
|
||||||
|
state.selectedRowsErpSpuIds = []
|
||||||
|
state.selectedSpuObjs = []
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getInitData()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -106,7 +106,6 @@ import { fetchList, delObjs } from "/@/api/supermarketerp/smErpCgPlan"
|
|||||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const formDialogRef = ref()
|
|
||||||
// 搜索变量
|
// 搜索变量
|
||||||
const queryRef = ref()
|
const queryRef = ref()
|
||||||
const showSearch = ref(true)
|
const showSearch = ref(true)
|
||||||
|
|||||||
Reference in new issue
Block a user