Commit ab2b5e19 authored by ztf's avatar ztf

修改新增和编辑项目相关组件

parent ca6aac0b
......@@ -39,6 +39,7 @@ export default {
immediate: true,
deep: true,
handler(val) {
//
console.log('监听项目分类', val)
if (val) {
if (val === 'program') {
......@@ -89,13 +90,23 @@ export default {
})
} else if (this.projectCategory === 'childProject') {
console.log('是子项')
this.form.parentId = this.form.extProject.id
const parentId = this.form.extProject.id
delete this.form.extProgram
delete this.form.extProject
delete this.form.dxType
this.form.subTypeName = 'DxContextProject'
this.form.operator = 'ADD'
const params = Object.assign(this.formData, this.form)
delete this.form.projectCategory
const params = {
parentId: parentId,
subTypeName: 'DxContextProject',
operator: 'ADD',
state: 'edit',
modelName: 'DxContextProject',
...this.form
}
// this.form.subTypeName = 'DxContextProject'
// this.form.operator = 'ADD'
// const params = Object.assign(this.formData, this.form)
console.log('params', params)
post('/DxContextProject/recursion', params).then(res => {
this.$utils.showMessageSuccess(`添加成功`)
......
<template>
<div class="project">
<dee-as-com
:lay-config="{
typeName: 'ExtProgram',
layKey: 'defaultEdit'
}"
:form="form"
:basic-data="basicDataCmp"
@on-submit="toSubmit"
@on-cancel="cancel"
/>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
name: 'EditProject',
componentName: '编辑项目',
props: {
basicData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// eslint-disable-next-line vue/no-dupe-keys
form: {},
subTypeName: 'ExtProgram',
projectCategory: ''
}
},
computed: {
basicDataCmp() {
return {
secretCode: this.basicData.secretCode,
id: this.basicData.id,
subTypeName: this.basicData.subTypeName,
// dxPlanId: this.basicData.dxPlanId,
// dxContextId: this.basicData.dxProjectItem && this.basicData.dxProjectItem.dxContextId,
// lifecycleTemplateId: this.basicData.lifecycleTemplateId,
state: this.basicData.state
}
}
},
watch: {
'form.projectCategory': {
immediate: true,
deep: true,
handler(val) {
//
console.log('监听项目分类', val)
if (val) {
if (val === 'program') {
this.projectCategory = 'program'
} else if (val === 'project') {
this.projectCategory = 'project'
} else if (val === 'childProject') {
this.projectCategory = 'childProject'
}
}
}
}
},
methods: {
toSubmit() {
console.log('进来了')
if (this.projectCategory === 'program') {
console.log('是项目群')
const params = this.form
post('/ExtProgram/recursion', params).then(res => {
this.$utils.showMessageSuccess(`添加成功`)
this.$emit('completeEven')
})
} else if (this.projectCategory === 'project') {
console.log('是项目')
const id = this.form.extProgram.id
delete this.form.extProgram
delete this.form.dxType
const params = {
subTypeName: 'DxContextProject',
id: id,
extProgramProjectLinks: [{
operator: 'ADD',
target: {
dxType: 'project',
...this.form,
operator: 'ADD',
parentId: 0,
parentName: 'Root',
state: 'edit'
}
}],
operator: 'NO_CHANGE'
}
post('/ExtProgram/recursion', params).then(res => {
this.$utils.showMessageSuccess(`添加成功`)
this.$emit('completeEven')
})
} else if (this.projectCategory === 'childProject') {
console.log('是子项')
const parentId = this.form.extProject.id
delete this.form.extProgram
delete this.form.extProject
delete this.form.dxType
delete this.form.projectCategory
const params = {
parentId: parentId,
subTypeName: 'DxContextProject',
operator: 'ADD',
state: 'edit',
modelName: 'DxContextProject',
...this.form
}
post('/DxContextProject/recursion', params).then(res => {
this.$utils.showMessageSuccess(`添加成功`)
this.$emit('completeEven')
})
}
},
cancel() {
this.$emit('cancel')
}
}
}
</script>
<style lang="scss" scoped>
.project{
height: 500px;
}
</style>
......@@ -2,7 +2,7 @@
* @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-09-11 11:05:24
* @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-09-11 18:30:49
* @LastEditTime: 2024-09-12 11:06:53
-->
<template>
<div>
......@@ -23,7 +23,7 @@ export default {
componentName: '所属项目',
props: {
value: {
type: [Object, Array, String],
type: [Object, Array, String, Number],
default: () => null
},
form: {
......@@ -46,7 +46,7 @@ export default {
deep: true,
handler(val) {
if (val) {
console.log('改变了', val)
// console.log('改变了', val)
this.getProjectList(val)
}
}
......@@ -89,8 +89,10 @@ export default {
})
},
handleChange(val) {
console.log('val', val)
this.$emit('input', val)
console.log('projectList', this.projectList)
const valObj = this.projectList.find((item) => { return item.name === val })
console.log('点击事件', valObj)
this.$emit('input', valObj.id)
}
}
}
......
<template>
<div class="link" @click="ToRelatedPage">{{ currentValue }}</div>
<div :class="currentValue.class" @click="ToRelatedPage">{{ currentValue.name }}</div>
</template>
<script>
......@@ -11,15 +11,7 @@ export default {
type: [Object, String],
default: () => {}
},
form: {
type: Object,
default: () => {}
},
itemObj: {
type: Object,
default: () => {}
},
basicData: {
scope: {
type: Object,
default: () => ({})
}
......@@ -39,27 +31,64 @@ export default {
],
data() {
return {
currentValue: this.value ? this.value.number || this.value : null
//
form: null
}
},
computed: {
currentValue() {
if (!this.form) {
return { name: null, class: 'link' }
}
const isExtProgram = this.form.subTypeName === 'ExtProgram'
const className = isExtProgram ? 'default' : 'link'
const name = this.value ? this.value.number || this.value : null
return {
name,
class: className
}
}
},
watch: {
'scope.row': {
immediate: true,
deep: true,
handler(val) {
this.form = val
console.log('this.form', this.form)
}
}
},
mounted() {
console.log('value', this.value)
console.log('this.form', this.form)
console.log('itemObj', this.itemObj)
console.log('basicData', this.basicData)
// this.getCurrentValue()
},
methods: {
// getCurrentValue() {
// if (this.form.subTypeName !== 'ExtProgram') {
// this.currentValue = {
// name: this.value ? this.value.number || this.value : null,
// class: 'link'
// }
// } else {
// this.currentValue = {
// name: this.value ? this.value.number || this.value : null,
// class: 'default'
// }
// }
// },
ToRelatedPage() {
console.log('this.form列表数据', this.form)
const name = this.form.name
const id = this.form.id
const pageNumber = '7cbdc38f-0122-4e78-b162-57601a33bb7a'
const title = '项目要素'
this.$router.push({
path: `/page/${pageNumber}/${id}?title=${title}&id=${id}&name=${name}`,
query: { name: name, id: id }
})
if (this.form.subTypeName !== 'ExtProgram') {
console.log('this.form列表数据', this.form)
const name = this.form.name
const id = this.form.id
const pageNumber = '7cbdc38f-0122-4e78-b162-57601a33bb7a'
const title = '项目要素'
this.$router.push({
path: `/page/${pageNumber}/${id}?title=${title}&id=${id}&name=${name}`,
query: { name: name, id: id }
})
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment