Commit ab2b5e19 authored by ztf's avatar ztf

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

parent ca6aac0b
...@@ -39,6 +39,7 @@ export default { ...@@ -39,6 +39,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler(val) { handler(val) {
//
console.log('监听项目分类', val) console.log('监听项目分类', val)
if (val) { if (val) {
if (val === 'program') { if (val === 'program') {
...@@ -89,13 +90,23 @@ export default { ...@@ -89,13 +90,23 @@ export default {
}) })
} else if (this.projectCategory === 'childProject') { } else if (this.projectCategory === 'childProject') {
console.log('是子项') console.log('是子项')
this.form.parentId = this.form.extProject.id const parentId = this.form.extProject.id
delete this.form.extProgram delete this.form.extProgram
delete this.form.extProject delete this.form.extProject
delete this.form.dxType delete this.form.dxType
this.form.subTypeName = 'DxContextProject' delete this.form.projectCategory
this.form.operator = 'ADD' const params = {
const params = Object.assign(this.formData, this.form) 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) console.log('params', params)
post('/DxContextProject/recursion', params).then(res => { post('/DxContextProject/recursion', params).then(res => {
this.$utils.showMessageSuccess(`添加成功`) 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 @@ ...@@ -2,7 +2,7 @@
* @Author: zhangtianfeng 3232807530@qq.com * @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-09-11 11:05:24 * @Date: 2024-09-11 11:05:24
* @LastEditors: zhangtianfeng 3232807530@qq.com * @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-09-11 18:30:49 * @LastEditTime: 2024-09-12 11:06:53
--> -->
<template> <template>
<div> <div>
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
componentName: '所属项目', componentName: '所属项目',
props: { props: {
value: { value: {
type: [Object, Array, String], type: [Object, Array, String, Number],
default: () => null default: () => null
}, },
form: { form: {
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
deep: true, deep: true,
handler(val) { handler(val) {
if (val) { if (val) {
console.log('改变了', val) // console.log('改变了', val)
this.getProjectList(val) this.getProjectList(val)
} }
} }
...@@ -89,8 +89,10 @@ export default { ...@@ -89,8 +89,10 @@ export default {
}) })
}, },
handleChange(val) { handleChange(val) {
console.log('val', val) console.log('projectList', this.projectList)
this.$emit('input', val) const valObj = this.projectList.find((item) => { return item.name === val })
console.log('点击事件', valObj)
this.$emit('input', valObj.id)
} }
} }
} }
......
<template> <template>
<div class="link" @click="ToRelatedPage">{{ currentValue }}</div> <div :class="currentValue.class" @click="ToRelatedPage">{{ currentValue.name }}</div>
</template> </template>
<script> <script>
...@@ -11,15 +11,7 @@ export default { ...@@ -11,15 +11,7 @@ export default {
type: [Object, String], type: [Object, String],
default: () => {} default: () => {}
}, },
form: { scope: {
type: Object,
default: () => {}
},
itemObj: {
type: Object,
default: () => {}
},
basicData: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
} }
...@@ -39,27 +31,64 @@ export default { ...@@ -39,27 +31,64 @@ export default {
], ],
data() { data() {
return { 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() { mounted() {
console.log('value', this.value) // this.getCurrentValue()
console.log('this.form', this.form)
console.log('itemObj', this.itemObj)
console.log('basicData', this.basicData)
}, },
methods: { 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() { ToRelatedPage() {
console.log('this.form列表数据', this.form) if (this.form.subTypeName !== 'ExtProgram') {
const name = this.form.name console.log('this.form列表数据', this.form)
const id = this.form.id const name = this.form.name
const pageNumber = '7cbdc38f-0122-4e78-b162-57601a33bb7a' const id = this.form.id
const title = '项目要素' const pageNumber = '7cbdc38f-0122-4e78-b162-57601a33bb7a'
this.$router.push({ const title = '项目要素'
path: `/page/${pageNumber}/${id}?title=${title}&id=${id}&name=${name}`, this.$router.push({
query: { name: name, id: id } 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