添加新增项目对话框

main
A 2022-07-01 15:01:40 +08:00
parent c644e022fb
commit 58244c8af9
2 changed files with 356 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import Home from '@/views/Home.vue'
import {createWebHistory} from "vue-router/dist/vue-router.esm-browser" import {createWebHistory} from "vue-router/dist/vue-router.esm-browser"
import Login from "@/views/Login.vue" import Login from "@/views/Login.vue"
import Project from "@/views/Project.vue"; import Project from "@/views/Project.vue";
import Dialog from "@/views/Dialog.vue";
import OngoingProject from "../views/OngoingProject"; import OngoingProject from "../views/OngoingProject";
import ClosedProject from "../views/ClosedProject"; import ClosedProject from "../views/ClosedProject";
const routes = [ const routes = [
@ -27,7 +28,11 @@ const routes = [
name: 'Login', name: 'Login',
component: Login, component: Login,
}, },
{
path: '/dialog',
name: 'dialog',
component: Dialog,
},
] ]
const router = createRouter({ const router = createRouter({

350
src/views/Dialog.vue Normal file
View File

@ -0,0 +1,350 @@
<template>
<div class="dialog">
<h1>对话框</h1>
<!-- Form -->
<el-button @click="dialogFormVisible = true">新建项目</el-button>
<el-dialog title="新建项目" v-model="dialogFormVisible" :width="'1050px'" center>
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="110px"
class="demo-ruleForm">
<!-- 第1行 -->
<el-row>
<el-col :span="24">
<el-form-item label="项目名称" prop="project_name">
<el-input v-model="ruleForm.project_name"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 第2行 -->
<el-row>
<el-col :span="6">
<el-form-item label="英文简称" prop="project_abbreviation">
<el-input v-model="ruleForm.project_abbreviation"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目主类" prop="project_class_id">
<el-select v-model="ruleForm.project_class_id" placeholder="请选择">
<el-option label="项目主类1" value="项目主类1"></el-option>
<el-option label="项目主类2" value="项目主类2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目子类" prop="project_subclass_id">
<el-select v-model="ruleForm.project_subclass_id" placeholder="请选择">
<el-option label="项目子类1" value="项目子类1"></el-option>
<el-option label="项目子类2" value="项目子类2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="重要程度" prop="project_importance">
<el-select v-model="ruleForm.project_importance" placeholder="请选择">
<el-option label="极其重要" value="极其重要"></el-option>
<el-option label="很重要" value="很重要"></el-option>
<el-option label="较为重要" value="较为重要"></el-option>
<el-option label="不太重要" value="不太重要"></el-option>
<el-option label="不重要" value="不重要"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- 第3行 -->
<el-row>
<el-col :span="6">
<el-form-item label="合同额" prop="contract_amount">
<el-input v-model="ruleForm.contract_amount" ></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="预期完成度" prop="expected_completion" >
<el-input v-model="ruleForm.expected_completion">
<template #suffix>
<span>%</span>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="计划总人月" prop="project_man_month">
<el-input v-model="ruleForm.project_man_month"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目启动日期" required>
<el-form-item prop="project_start_time">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.project_start_time"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form-item>
</el-col>
</el-row>
<!-- 第4行 -->
<el-row>
<el-col :span="6">
<el-form-item label="计划上线日期" required>
<el-form-item prop="project_online_time">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.project_online_time"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="计划初验日期" required>
<el-form-item prop="project_first_test_time">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.project_first_test_time"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="计划终验日期" required>
<el-form-item prop="project_final_test_time">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.project_final_test_time"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="计划结项日期" required>
<el-form-item prop="project_end_time">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.project_end_time"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form-item>
</el-col>
</el-row>
<!-- 第5行 -->
<el-row>
<el-col :span="6">
<el-form-item label="财务编码" prop="financial_code">
<el-input v-model="ruleForm.financial_code"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属部门" prop="project_department">
<el-input v-model="ruleForm.project_department"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属区域" prop="project_area">
<el-input v-model="ruleForm.project_area"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属公司" prop="project_company">
<el-input v-model="ruleForm.project_company"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 第6行 -->
<el-row>
<el-col :span="24">
<el-form-item label="项目描述" prop="project_description">
<el-input type="textarea" v-model="ruleForm.project_description"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 按钮 -->
<template #footer>
<span class="dialog-footer" >
<el-button type="primary" @click="submitForm('ruleForm')"></el-button>
<el-button @click="resetForm('ruleForm')"></el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
let validateAbbreviation = (rule,value,callback) => {//
var reg = new RegExp("^[A-Za-z0-9]+$");
if(!value){//callback,
return callback()
}else{
if(!reg.test(value)){
callback(new Error("只能输入字母和数字"))
}
}
}
let validateAmount = (rule,value,callback) => {//0,2
var reg = new RegExp("^(([0-9]|([1-9][0-9]{0,9}))((\\.[0-9]{1,2})?))$");
if(!value){//callback,
return callback()
}else{
if(!reg.test(value)){
callback(new Error("请输入正确的合同额"))
}
}
}
let validateFinancial = (rule,value,callback) => {//
var reg = new RegExp("^\\d+$|^\\d+[.]?\\d+$");
if(!value){//callback,
return callback()
}else{
if(!reg.test(value)){
callback(new Error("请输入正确的财务编码"))
}
}
}
return {
dialogFormVisible: false,
formLabelWidth: '120px',
ruleForm: {
project_name:'', //
project_abbreviation: '',//
project_class_id: '',//
project_subclass_id: '',//
project_importance:'' ,//
contract_amount: '',//
expected_completion: '',//
project_man_month: '',//
project_start_time: '',//
project_online_time: '',//线
project_first_test_time: '',//
project_final_test_time: '',//
project_end_time: '',//
financial_code: '',//
project_department: '',//
project_area: '',//
project_company: '',//
project_description: '',//
},
rules: {
project_name: [//
{ required: true, message: '请输入项目名称', trigger: 'blur' }
],
project_abbreviation: [//
{ validator: validateAbbreviation }
//
],
project_class_id: [//
{ required: true, message: '请选择项目主类', trigger: 'change' },
],
project_subclass_id: [//
{ required: true, message: '请选择项目子类', trigger: 'change' },
],
project_importance: [//
{ required: true, message: '请选择重要程度', trigger: 'change' },
],
contract_amount: [//
{ validator: validateAmount }//
//0
],
expected_completion: [//
{ required: true, message: '请输入预期完成度', trigger: 'blur' },
{ validator:function(rule,value,callback){
//0-100
if(!/(^[1-9]\d$)|(^\d$)|(^100$)/.test(value)){
callback(new Error("请输入正确的完成度"));
}else{
//
callback();
}
}, trigger: 'blur'
},
],
project_man_month: [//
{ required: true, message: '请输入计划总人月', trigger: 'blur' },
{ validator:function(rule,value,callback){
//>0
if(!/^[1-9]*[1-9][0-9]*$/.test(value)){
callback(new Error("请输入正确的人月数"));
}else{
//
callback();
}
}, trigger: 'blur'
},
],
project_start_time: [//
{ type: 'date',required: true, message: '请选择计划总人月', trigger: 'change' },
],
project_online_time: [//线
{ type: 'date',required: true, message: '请选择计划上线日期', trigger: 'change' },
],
project_first_test_time: [//
{ type: 'date',required: true, message: '请选择计划初验日期', trigger: 'change' },
],
project_final_test_time: [//
{ type: 'date',required: true, message: '请选择计划终验日期', trigger: 'change' },
],
project_end_time: [//
{ type: 'date',required: true, message: '请选择计划结项日期', trigger: 'change' },
],
financial_code: [//
{ validator: validateFinancial }
//
],
project_department: [//
{ required: true, message: '请输入所属部门', trigger: 'blur' },
],
project_area: [//
{ required: true, message: '请输入所属区域', trigger: 'blur' },
],
project_company: [//
{ required: true, message: '请输入所属公司', trigger: 'blur' },
],
project_description: [//
//
],
},
}
},
methods: {
//
submitForm(formName){
//
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!')
//
} else {
console.log('error submit!!')
return false
}
})
},
//
resetForm(formName) {
this.$refs[formName].resetFields()
},
},
}
</script>