完成新建项目对话框

main
wuyize 2022-07-01 17:03:36 +08:00
parent 58244c8af9
commit a07b43605b
4 changed files with 446 additions and 372 deletions

View File

@ -0,0 +1,401 @@
<template>
<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="projectName">
<el-input v-model="ruleForm.projectName"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 第2行 -->
<el-row>
<el-col :span="6">
<el-form-item label="英文简称" prop="projectAbbreviation">
<el-input v-model="ruleForm.projectAbbreviation"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目主类" prop="projectClassId" >
<el-select v-model="ruleForm.projectClassId" placeholder="请选择" @change="onProjectClassChange">
<el-option
v-for="item in projectClasses"
:label="item.projectClassName"
:value="item.projectClassId"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目子类" prop="projectSubclassId">
<el-select v-model="ruleForm.projectSubclassId" placeholder="请选择">
<el-option
v-for="item in currentProjectSubClasses"
:label="item.projectClassName"
:value="item.projectClassId"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="重要程度" prop="projectImportance">
<el-select v-model="ruleForm.projectImportance" 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="contractAmount">
<el-input v-model="ruleForm.contractAmount"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="预期完成度" prop="expectedCompletion">
<el-input v-model="ruleForm.expectedCompletion">
<template #suffix>
<span>%</span>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="计划总人月" prop="projectManMonth">
<el-input v-model="ruleForm.projectManMonth"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="项目启动日期" required>
<el-form-item prop="projectStartTime">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.projectStartTime"
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="projectOnlineTime">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.projectOnlineTime"
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="projectFirstTestTime">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.projectFirstTestTime"
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="projectFinalTestTime">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.projectFinalTestTime"
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="projectEndTime">
<el-date-picker
type="date"
placeholder="选择日期"
v-model="ruleForm.projectEndTime"
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="financialCode">
<el-input v-model="ruleForm.financialCode"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属部门" prop="projectDepartment">
<el-input v-model="ruleForm.projectDepartment"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属区域" prop="projectArea">
<el-input v-model="ruleForm.projectArea"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="所属公司" prop="projectCompany">
<el-input v-model="ruleForm.projectCompany"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 第6行 -->
<el-row>
<el-col :span="24">
<el-form-item label="项目描述" prop="projectDescription">
<el-input type="textarea" v-model="ruleForm.projectDescription"></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>
</template>
<script>
import {ElMessage} from "element-plus";
import request from "../utils/request";
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',
currentProjectSubClasses: [],
ruleForm: {
projectName: '', //
projectAbbreviation: '',//
projectClassId: '',//
projectSubclassId: '',//
projectImportance: '',//
contractAmount: '',//
expectedCompletion: '',//
projectManMonth: '',//
projectStartTime: '',//
projectOnlineTime: '',//线
projectFirstTestTime: '',//
projectFinalTestTime: '',//
projectEndTime: '',//
financialCode: '',//
projectDepartment: '',//
projectArea: '',//
projectCompany: '',//
projectDescription: '',//
},
rules: {
projectName: [//
{required: true, message: '请输入项目名称', trigger: 'blur'}
],
projectAbbreviation: [//
{validator: validateAbbreviation}
//
],
projectClassId: [//
{required: true, message: '请选择项目主类', trigger: 'change'},
],
projectSubclassId: [//
{required: true, message: '请选择项目子类', trigger: 'change'},
],
projectImportance: [//
{required: true, message: '请选择重要程度', trigger: 'change'},
],
contractAmount: [//
{validator: validateAmount}//
//0
],
expectedCompletion: [//
{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'
},
],
projectManMonth: [//
{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'
},
],
projectStartTime: [//
{type: 'date', required: true, message: '请选择计划总人月', trigger: 'change'},
],
projectOnlineTime: [//线
{type: 'date', required: true, message: '请选择计划上线日期', trigger: 'change'},
],
projectFirstTestTime: [//
{type: 'date', required: true, message: '请选择计划初验日期', trigger: 'change'},
],
projectFinalTestTime: [//
{type: 'date', required: true, message: '请选择计划终验日期', trigger: 'change'},
],
projectEndTime: [//
{type: 'date', required: true, message: '请选择计划结项日期', trigger: 'change'},
],
financialCode: [//
{validator: validateFinancial}
//
],
projectDepartment: [//
{required: true, message: '请输入所属部门', trigger: 'blur'},
],
projectArea: [//
{required: true, message: '请输入所属区域', trigger: 'blur'},
],
projectCompany: [//
{required: true, message: '请输入所属公司', trigger: 'blur'},
],
projectDescription: [//
//
],
},
}
},
props: {
dialogFormVisible: Boolean,
projectClasses: Array,
projectSubClasses: Array
},
methods: {
onProjectClassChange(val) {
this.ruleForm.projectSubclassId = ''
this.currentProjectSubClasses = []
for (const record of this.projectSubClasses) {
if (record.classFatherId === val)
this.currentProjectSubClasses.push(record)
}
},
//
submitForm(formName) {
console.log(this.projectClasses)
let form = this.ruleForm
form.projectFinalTestTime = form.projectFinalTestTime.getTime() / 1000
form.projectEndTime = form.projectEndTime.getTime() / 1000
form.projectFirstTestTime = form.projectFirstTestTime.getTime() / 1000
form.projectOnlineTime = form.projectOnlineTime.getTime() / 1000
form.projectStartTime = form.projectStartTime.getTime() / 1000
request({
url: 'project/create',
method: 'post',
data: form
}).then(response => {
console.log(response)
if (response.data.code === 200) {
//console.log(response.data.data.records)
ElMessage({
message: '成功',
type: 'success',
})
}
}).catch(function (error) {
console.log(error)
})
//
this.$refs[formName].validate((valid) => {
if (valid) {
console.log('submit')
ElMessage({
message: 'submit',
type: 'success',
})
//
} else {
console.log('error submit!!')
return false
}
})
},
//
resetForm(formName) {
this.$refs[formName].resetFields()
},
},
}
</script>

View File

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

View File

@ -1,350 +0,0 @@
<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>

View File

@ -4,7 +4,7 @@
<div style="margin: 0 40px 0 40px;
display: flex;flex-direction: row;justify-content: space-between">
<p style="font-family: 'Segoe UI',sans-serif;font-size: 20px;font-weight: bold;color: #606266">在途项目</p>
<el-button type="primary">新增项目</el-button>
<el-button type="primary" @click.native="onCreateProject">新增项目</el-button>
</div>
<div style="flex: 1; margin: 30px 30px 10px 30px; background-color: white; border-radius: 10px;padding: 20px;
display: flex;flex-direction: column;justify-content: space-between">
@ -21,13 +21,16 @@
<el-table-column prop="projectSubclassName" label="项目类型" min-width="10%"/>
<el-table-column label="项目进度" min-width="35%">
<template #default="scope">
<el-progress :text-inside="true" :stroke-width="18" :status="scope.row.completeNum===scope.row.totalNum ? 'success' : ''"
<el-progress :text-inside="true" :stroke-width="18"
:status="scope.row.completeNum===scope.row.totalNum ? 'success' : ''"
:percentage="scope.row.completeNum*100/scope.row.totalNum"></el-progress>
</template>
</el-table-column>
<el-table-column min-width="10%" align="right">
<template #default="scope">
<el-button :v-show=" this.$store.state.staff.staffId===scope.row.projectCreator" type="primary" plain @click="onCloseProject(scope.row)"></el-button>
<el-button :v-show=" this.$store.state.staff.staffId===scope.row.projectCreator" type="primary" plain
@click="onCloseProject(scope.row)">结项
</el-button>
</template>
</el-table-column>
</el-table>
@ -44,6 +47,9 @@
</el-pagination>
</div>
</div>
<CreateProjectDialog v-model:dialogFormVisible="dialogFormVisible" :projectClasses="projectClasses"
:projectSubClasses="projectSubClasses"></CreateProjectDialog>
</template>
<script setup>
// table
@ -66,17 +72,24 @@ onMounted(() => {
import router from "../router";
import request from "../utils/request";
import {ElMessage} from "element-plus";
import CreateProjectDialog from "../components/CreateProjectDialog"
export default {
name: "OngoingProject",
components: {
CreateProjectDialog
},
data() {
return {
dialogFormVisible: false,
total: 0,
currentPage: 1,
pageSize: 10,
projectClass: [],
projectClasses: [],
projectSubClasses: [],
tableData: [],
staffId: Number
@ -102,7 +115,12 @@ export default {
mounted() {
},
methods: {
onCreateProject() {
this.getProjectClass()
this.dialogFormVisible = true
},
//
handleSizeChange(val) {
this.redirect()
@ -157,12 +175,21 @@ export default {
})
},
getProjectClass() {
const that = this;
request({
url: 'projectType',
url: 'project/type',
method: 'get',
}).then(response => {
if(response.code===200) {
if (response.data.code === 200) {
console.log(response.data.data.records)
that.projectClasses = []
that.projectSubClasses = []
for (const record of response.data.data.records) {
if (record.classFatherId === 0)
that.projectClasses.push(record)
else
that.projectSubClasses.push(record)
}
}
}).catch(function (error) {
console.log(error)