<template>
|
<div>
|
<el-dialog
|
v-model="isShow"
|
title="新增工艺路线"
|
width="400"
|
@close="closeModal"
|
>
|
<el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
|
<el-form-item
|
label="工序名称:"
|
prop="name"
|
:rules="[
|
{
|
required: true,
|
message: '请输入工序名称',
|
},
|
{
|
max: 100,
|
message: '最多100个字符',
|
}
|
]">
|
<el-select v-model="formState.productModelId" placeholder="选择零件" size="small">
|
<el-option v-for="item in warehouse" :key="item.id" :label="item.label" :value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="备注" prop="description">
|
<el-input v-model="formState.description" type="textarea" />
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button type="primary" @click="handleSubmit">确认</el-button>
|
<el-button @click="closeModal">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import {ref, computed, getCurrentInstance, onMounted} from "vue";
|
import {add} from "@/api/productionManagement/productionProcess.js";
|
|
const props = defineProps({
|
visible: {
|
type: Boolean,
|
required: true,
|
},
|
});
|
|
const emit = defineEmits(['update:visible', 'completed']);
|
|
// 响应式数据(替代选项式的 data)
|
const formState = ref({
|
name: '',
|
remark: '',
|
});
|
|
const isShow = computed({
|
get() {
|
return props.visible;
|
},
|
set(val) {
|
emit('update:visible', val);
|
},
|
});
|
|
const productModels = ref([])
|
|
let { proxy } = getCurrentInstance()
|
|
const closeModal = () => {
|
isShow.value = false;
|
};
|
|
const handleSubmit = () => {
|
proxy.$refs["formRef"].validate(valid => {
|
if (valid) {
|
add(formState.value).then(res => {
|
// 关闭模态框
|
isShow.value = false;
|
// 告知父组件已完成
|
emit('completed');
|
proxy.$modal.msgSuccess("提交成功");
|
})
|
}
|
})
|
};
|
|
const findProductModelOptions = () => {
|
|
}
|
|
defineExpose({
|
closeModal,
|
handleSubmit,
|
isShow,
|
});
|
|
onMounted(() => {
|
findProductModelOptions()
|
})
|
</script>
|