You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.0 KiB
111 lines
3.0 KiB
2 weeks ago
|
<template>
|
||
|
<a-modal v-model:open="visible" :title="title" @ok="handleOk" width="50%">
|
||
|
<a-form :model="form" layout="vertical" ref="formRef" :rules="rules">
|
||
|
<a-row :gutter="[16, 16]">
|
||
|
<a-col :span="24">
|
||
|
<a-form-item label="所属计划" name="plan">
|
||
|
<a-select v-model:value="form.plan" :options="planOptions" placeholder="请选择" />
|
||
|
</a-form-item>
|
||
|
</a-col>
|
||
|
</a-row>
|
||
|
<a-row :gutter="[16, 16]">
|
||
|
<a-col :span="24">
|
||
|
<a-form-item label="监理人员" name="ioPerson">
|
||
|
<a-select v-model:value="form.ioPerson" :options="ioPersonOptions" placeholder="请选择" />
|
||
|
</a-form-item>
|
||
|
</a-col>
|
||
|
</a-row>
|
||
|
</a-form>
|
||
|
</a-modal>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { reactive, ref } from 'vue';
|
||
|
import { message } from 'ant-design-vue';
|
||
|
import { getInfo, add, update } from './api';
|
||
|
import { getStationList } from '@/api/common/index';
|
||
|
export default {
|
||
|
setup(props, { emit }) {
|
||
|
const title = ref('新增');
|
||
|
const visible = ref(false);
|
||
|
const form = reactive({
|
||
|
plan: null,
|
||
|
ioPerson: null,
|
||
|
});
|
||
|
//下拉框
|
||
|
const planOptions = ref([])
|
||
|
const ioPersonOptions = ref([]);
|
||
|
const showModal = async (type, id, projectId) => {
|
||
|
visible.value = true;
|
||
|
if (type == 1) {
|
||
|
title.value = '新增';
|
||
|
} else if (type == 2) {
|
||
|
title.value = '编辑';
|
||
|
const data = await getInfo(id);
|
||
|
for (let i in form) {
|
||
|
form[i] = data[i];
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const handleOk = () => {
|
||
|
formRef.value.validate().then((valid) => {
|
||
|
if (valid) {
|
||
|
if (title.value == '新增') {
|
||
|
let params = {};
|
||
|
for (let i in form) {
|
||
|
params[i] = form[i];
|
||
|
}
|
||
|
delete params.id;
|
||
|
add(params).then((_) => {
|
||
|
message.success('新增成功');
|
||
|
emit('success');
|
||
|
closeModal();
|
||
|
});
|
||
|
} else {
|
||
|
let params = {};
|
||
|
for (let i in form) {
|
||
|
params[i] = form[i];
|
||
|
}
|
||
|
update(params).then((_) => {
|
||
|
message.success('编辑成功');
|
||
|
emit('success');
|
||
|
closeModal();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
const closeModal = () => {
|
||
|
formRef.value.resetFields();
|
||
|
visible.value = false;
|
||
|
};
|
||
|
const formRef = ref();
|
||
|
const rules = {
|
||
|
plan: [{ required: true, message: '请选择' }],
|
||
|
ioPerson: [{ required: true, message: '请选择' }],
|
||
|
};
|
||
|
return {
|
||
|
visible,
|
||
|
title,
|
||
|
form,
|
||
|
showModal,
|
||
|
handleOk,
|
||
|
planOptions,
|
||
|
ioPersonOptions,
|
||
|
closeModal,
|
||
|
formRef,
|
||
|
rules,
|
||
|
};
|
||
|
},
|
||
|
};
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/* 可选样式调整 */
|
||
|
.ant-modal-body {
|
||
|
max-width: 600px;
|
||
|
margin: 0 auto;
|
||
|
}
|
||
|
</style>
|