张诺
8 天以前 1a73c77e1d14205014f6a77a8954de480d436c0e
src/views/procureMent/components/ProductionDialog.vue
@@ -1,7 +1,7 @@
<template>
  <div>
    <el-dialog
      v-model="dialogVisible"
      v-model="dialogFormVisible"
      :title="title"
      width="600"
      :close-on-click-modal="false"
@@ -81,8 +81,8 @@
    default: "",
  },
});
const emit = defineEmits(["update:visible", "success"]);
const dialogVisible = defineModel("dialogFormVisible", {
const emit = defineEmits(["update:dialogFormVisible", "success"]);
const dialogFormVisible = defineModel("dialogFormVisible", {
  required: true,
  type: Boolean,
});
@@ -109,11 +109,8 @@
};
// 关闭弹窗
const handleClose = () => {
  dialogVisible.value = false;
  dialogFormVisible.value = false;
  console.log(form.value);
  // formRef.value?.resetFields()
  // Object.assign(form, {
  // })
};
const handleReset = () => {
  if (!formRef.value) return;
@@ -146,108 +143,5 @@
};
</script>
<style lang="less" scoped>
</style>
<!-- <template>
  <el-dialog
    v-model="dialogFormVisible"
    title="采购登记新增"
    width="500px"
    :close-on-click-modal="false"
    @close="handleClose"
  >
  </el-dialog>
</template>
<script setup>
import { ref, reactive, defineProps, defineEmits } from 'vue'
import { ElMessage } from 'element-plus'
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  }
})
const emit = defineEmits(['update:visible', 'success'])
const dialogFormVisible = ref(false)
const formRef = ref(null)
// 表单数据
const form = reactive({
  supplierName: '',
  category: '',
  unit: '',
  purchaseAmount: '',
  priceBeforeTax: '',
  totalBeforeTax: '',
  calorificValue: '',
  registrant: '',
  registrationDate: ''
})
// 表单验证规则
// 监听visible变化
watch(() => props.visible, (val) => {
  dialogFormVisible.value = val
})
// 监听dialogFormVisible变化
watch(() => dialogFormVisible.value, (val) => {
  emit('update:visible', val)
})
// 提交表单
const handleSubmit = async () => {
  if (!formRef.value) return
  await formRef.value.validate((valid) => {
    if (valid) {
      try {
        emit('success', { ...form })
        handleClose()
        ElMessage.success('保存成功')
      } catch (error) {
        console.error('保存失败:', error)
        ElMessage.error('保存失败')
      }
    }
  })
}
// 取消
const handleCancel = () => {
  handleClose()
}
</script>
<style scoped>
.production-form {
  padding: 20px;
}
.dialog-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
}
:deep(.el-form-item__label) {
  font-weight: normal;
}
:deep(.el-input),
:deep(.el-date-picker) {
  width: 100%;
}
:deep(.el-dialog__body) {
  padding-top: 10px;
}
</style> -->
<style lang="sass" scoped>
</style>