修改采购计划新增

This commit is contained in:
weiwei committed 2025-02-17 10:22:16 +08:00
1 parent 43c5fdbb25
commit 21b39800da
2 files changed
+33 -57

No files matched your search

@@ -60,8 +60,8 @@
行新增
</el-button>
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
<el-button @click="handleClickSpuSelect">商品选择</el-button>
<el-button @click="clearData">重置数据</el-button>
<el-button @click="handleClickSpuSelect">商品选择</el-button>
</el-row>
<vxe-table
@@ -248,7 +248,7 @@
<script setup lang="ts" name="SmErpCgPlanDialog">
import { ref, reactive, computed, onMounted } from "vue"
import { useRouter } from "vue-router"
import { useRouter, useRoute } from "vue-router"
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj, getPlanCode, getCgPlanSpuPage } from "/@/api/supermarketerp/smErpCgPlan"
@@ -279,6 +279,7 @@ interface RowVO {
}
const router = useRouter()
const route = useRoute()
const loading = ref(false) // 采购计划加载
const spuListLoading = ref(false) // 对话框商品列表加载
const baseDataFormRef = ref() // 基本数据表单ref
@@ -325,7 +326,21 @@ const validRules = ref<VxeTablePropTypes.EditRules<RowVO>>({
quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }],
})
// 初始化数据
const getInitData = async () => {
const id = route.query.id as string
if (id) {
// 获取数据
loading.value = true
getObj(id)
.then((res: any) => {
Object.assign(baseDataForm, res.data)
})
.finally(() => {
loading.value = false
})
}
// 获取货商选项 & 获取采购计划编号
const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode()]).then((results) =>
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
@@ -551,7 +566,7 @@ const onSave = async () => {
(await editableTableValidate()) &&
(await submitData()) &&
clearData() &&
router.back()
router.replace({ path: "/supermarketerp/smErpCgPlan/index" })
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
@@ -614,7 +629,7 @@ const submitData = async () => {
}
}
// 清空填写的数据
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "planCode") continue
@@ -624,6 +639,7 @@ const clearData = () => {
state.editableTableData = []
state.selectedRowsErpSpuIds = []
state.selectedSpuObjs = []
return true
}
onMounted(() => {
@@ -640,17 +656,4 @@ onMounted(() => {
// loading.value = false
// }
// }
// 初始化表单数据
// const getsmErpCgPlanData = (id: string) => {
// // 获取数据
// loading.value = true
// getObj(id)
// .then((res: any) => {
// Object.assign(form, res.data)
// })
// .finally(() => {
// loading.value = false
// })
// }
</script>
+13 -40
View File
@@ -27,13 +27,7 @@
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button
icon="folder-add"
type="primary"
class="ml10"
@click="handleClickCreateCgPlan"
v-auth="'supermarket_smErpCgPlan_add'"
>
<el-button icon="folder-add" type="primary" class="ml10" @click="handleClickCreateCgPlan" v-auth="'supermarket_smErpCgPlan_add'">
新 增
</el-button>
<el-button
@@ -56,6 +50,7 @@
/>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
@@ -89,17 +84,11 @@
text
type="primary"
v-auth="'supermarket_smErpCgPlan_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
@click="handleClickEditCgPlan(scope.row.id)"
>
编辑
</el-button>
<el-button
icon="delete"
text
type="primary"
v-auth="'supermarket_smErpCgPlan_del'"
@click="handleDelete([scope.row.id])"
>
<el-button icon="delete" text type="primary" v-auth="'supermarket_smErpCgPlan_del'" @click="handleDelete([scope.row.id])">
删除
</el-button>
</template>
@@ -107,21 +96,16 @@
</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="systemSmErpCgPlan">
import { useRouter } from "vue-router"
import { BasicTableProps, useTable } from "/@/hooks/table"
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpCgPlan"
import { useMessage, useMessageBox } from "/@/hooks/message"
// 引入组件
// const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义变量内容
const router = useRouter()
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
@@ -135,9 +119,7 @@ const state: BasicTableProps = reactive<BasicTableProps>({
pageList: fetchList,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
@@ -150,11 +132,7 @@ const resetQuery = () => {
// 导出excel
const exportExcel = () => {
downBlobFile(
"/supermarket/smErpCgPlan/export",
Object.assign(state.queryForm, { ids: selectObjs }),
"smErpCgPlan.xlsx",
)
downBlobFile("/supermarket/smErpCgPlan/export", Object.assign(state.queryForm, { ids: selectObjs }), "smErpCgPlan.xlsx")
}
// 多选事件
@@ -163,6 +141,11 @@ const selectionChangHandle = (objs: { id: string }[]) => {
multiple.value = !objs.length
}
// 点击创建采购清单
const handleClickCreateCgPlan = () => router.push({ path: "/createCgPlan" })
// 点击编辑采购清单
const handleClickEditCgPlan = (id: string) => router.push({ path: "/createCgPlan", query: { id } })
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
@@ -179,14 +162,4 @@ const handleDelete = async (ids: string[]) => {
useMessage().error(err.msg)
}
}
// ==========================================================
import { useRouter } from "vue-router"
const router = useRouter()
// 点击创建采购清单
const handleClickCreateCgPlan = () => {
router.push("/createCgPlan")
}
</script>