修改
This commit is contained in:
@ -323,18 +323,21 @@
|
||||
<script setup name="SupplierInput" lang="ts">
|
||||
import { ComponentInternalInstance, getCurrentInstance, onMounted, ref, reactive, toRefs, computed } from 'vue';
|
||||
import { ElFormInstance } from 'element-plus';
|
||||
import { listSupplierInput, getSupplierInput, delSupplierInput } from '@/api/supplierInput/supplierInput';
|
||||
import { listSupplierInput, getSupplierInput, delSupplierInput } from '@/api/supplierInput/supplierInput/index';
|
||||
import { SupplierInputVO, SupplierInputQuery, SupplierInputForm, PageData, DialogOption } from '@/api/supplierInput/supplierInput/types';
|
||||
import Pagination from '@/components/Pagination/index.vue';
|
||||
import RightToolbar from '@/components/RightToolbar/index.vue';
|
||||
import FileUpload from '@/components/FileUpload/index.vue';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status'));
|
||||
// 组件引用
|
||||
const fileUploadRef = ref<InstanceType<typeof FileUpload> | null>(null);
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const supplierInputFormRef = ref<ElFormInstance>();
|
||||
|
||||
// 获取用户 store
|
||||
const userStore = useUserStoreHook();
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
// 基础数据
|
||||
const supplierInputList = ref<SupplierInputVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
@ -393,6 +396,7 @@ const initFormData: any = {
|
||||
const data = reactive<PageData<SupplierInputForm, SupplierInputQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
projectId: currentProject.value?.id,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
supplierType: undefined,
|
||||
@ -506,7 +510,7 @@ const cancel = () => {
|
||||
|
||||
/** 表单重置:清空所有字段 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
form.value = { ...initFormData, projectId: currentProject.value?.id };
|
||||
fileUrl.value = '';
|
||||
form.value.inputFile = '';
|
||||
supplierInputFormRef.value?.resetFields();
|
||||
@ -606,8 +610,6 @@ const handleUpdate = async (row?: SupplierInputVO) => {
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = () => {
|
||||
console.log(1);
|
||||
|
||||
supplierInputFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (!valid) return;
|
||||
if (form.value.supplierType === '劳务') {
|
||||
@ -662,10 +664,29 @@ const handleDelete = async (row?: SupplierInputVO) => {
|
||||
const handleExport = () => {
|
||||
proxy?.download('supplierInput/supplierInput/export', { ...queryParams.value }, `supplierInput_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
/** 页面挂载时查询列表 */
|
||||
//调用projectId并获取列表
|
||||
onMounted(() => {
|
||||
getList();
|
||||
// 若需要依赖项目ID,可先判断项目是否已选中,再调用接口
|
||||
if (currentProject.value?.id) {
|
||||
queryParams.value.projectId = currentProject.value.id;
|
||||
form.value.projectId = currentProject.value.id;
|
||||
getList(); // 首次进入自动调取listSupplierInput接口
|
||||
} else {
|
||||
// 若项目未选中,可提示或后续监听项目变化时再加载(已有监听逻辑)
|
||||
getList();
|
||||
}
|
||||
});
|
||||
// 监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
(nid, oid) => {
|
||||
queryParams.value.projectId = nid;
|
||||
form.value.projectId = nid;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
onUnmounted(() => {
|
||||
listeningProject();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user