Compare commits

...

3 Commits

2 changed files with 33 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<Dialog :title="dialogTitle" v-model="dialogVisible"> <Dialog :title="dialogTitle" v-model="dialogVisible" @close="emits">
<el-form <el-form
width="400px" width="400px"
ref="formRef" ref="formRef"
@ -20,7 +20,7 @@
</el-form-item> </el-form-item>
<el-form-item label="物料分类编码" prop="matTypeCode" > <el-form-item label="物料分类编码" prop="matTypeCode" >
<el-input v-model="formData.matTypeCode" placeholder="请输入物料分类编码" show-word-limit :disabled="formType === 'update'"/> <el-input v-model="formData.matTypeCode" placeholder="请输入物料分类编码" disabled show-word-limit />
</el-form-item> </el-form-item>
<el-form-item label="最大流水号" prop="curMaxSeq" > <el-form-item label="最大流水号" prop="curMaxSeq" >
<el-input v-model="formData.curMaxSeq" placeholder="请输入当前最大流水号" :disabled="formType === 'update'" show-word-limit/> <el-input v-model="formData.curMaxSeq" placeholder="请输入当前最大流水号" :disabled="formType === 'update'" show-word-limit/>
@ -34,7 +34,7 @@
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="emits"> </el-button>
</template> </template>
</Dialog> </Dialog>
</template> </template>
@ -112,6 +112,11 @@ const open = async (type: string, id?: number) => {
} }
defineExpose({ open }) // open defineExpose({ open }) // open
const emits = async () => {
dialogVisible.value = false
emit('success')
}
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {

View File

@ -120,6 +120,7 @@
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { nextTick } from 'vue'
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import * as MaterialApi from '@/api/heli/material' import * as MaterialApi from '@/api/heli/material'
import {getSupplierPage} from "@/api/heli/supplier"; import {getSupplierPage} from "@/api/heli/supplier";
@ -174,6 +175,8 @@ const formRef = ref() // 表单 Ref
const supplierList = ref<any[]>([]) // const supplierList = ref<any[]>([]) //
const supplierSelectList = ref<any[]>([]) const supplierSelectList = ref<any[]>([])
const supplierSelectLoading = ref(false); const supplierSelectLoading = ref(false);
const isInitialized = ref(false) // watch
const originalMatCate = ref() //
const remoteSupplierSearch = (query: string) => { const remoteSupplierSearch = (query: string) => {
if (query) { if (query) {
@ -196,9 +199,15 @@ const open = async (type: string, id?: number) => {
resetForm() resetForm()
// //
formLoading.value = true formLoading.value = true
isInitialized.value = false
try { try {
if (id) { if (id) {
formData.value = await MaterialApi.getMaterial(id) const data = await MaterialApi.getMaterial(id)
formData.value = data
//
originalMatCate.value = data.matCate
} else {
originalMatCate.value = undefined
} }
let params = { let params = {
pageNo: 1, pageNo: 1,
@ -210,6 +219,9 @@ const open = async (type: string, id?: number) => {
supplierSelectList.value = supplierData.list; supplierSelectList.value = supplierData.list;
} finally { } finally {
formLoading.value = false formLoading.value = false
nextTick(() => {
isInitialized.value = true
})
} }
} }
@ -280,8 +292,18 @@ const handleSelectedSupplier = (newValue: any) => {
/** 监听物料类型变化查询matcode并更新code */ /** 监听物料类型变化查询matcode并更新code */
watch(() => formData.value.matCate, async (newVal) => { watch(() => formData.value.matCate, async (newVal) => {
//
if (!isInitialized.value) {
return
}
//
if (!newVal) { if (!newVal) {
formData.value.code = undefined formData.value.code = undefined
originalMatCate.value = undefined
return
}
//
if (newVal === originalMatCate.value) {
return return
} }
try { try {
@ -291,6 +313,8 @@ watch(() => formData.value.matCate, async (newVal) => {
} else { } else {
formData.value.code = null formData.value.code = null
} }
//
originalMatCate.value = newVal
} catch (error) { } catch (error) {
console.error('查询matcode失败:', error) console.error('查询matcode失败:', error)
formData.value.code = null formData.value.code = null