Commit ca6aac0b authored by ztf's avatar ztf

新建项目相关组件

parent 2a213f2d
<template>
<div class="project">
<dee-as-com
:lay-config="{
typeName: 'ExtProgram',
layKey: 'defaultCreate'
}"
:form="form"
@on-submit="toSubmit"
@on-cancel="cancel"
/>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
name: 'CreateProject',
componentName: '新建项目',
props: {
basicData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// eslint-disable-next-line vue/no-dupe-keys
form: {},
formData: this.basicData,
subTypeName: 'ExtProgram',
projectCategory: ''
}
},
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('是子项')
this.form.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)
console.log('params', params)
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>
<!--
* @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-09-11 11:05:24
* @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-09-11 18:30:49
-->
<template>
<div>
<el-select v-model="project" placeholder="请选择" @change="handleChange">
<el-option
v-for="item in projectList"
:key="item.value"
:label="item.name"
:value="item.name"
/>
</el-select></div>
</template>
<script>
import { post } from '@/utils/http'
export default {
name: 'ExtProject',
componentName: '所属项目',
props: {
value: {
type: [Object, Array, String],
default: () => null
},
form: {
type: Object,
default: () => {}
}
},
data() {
return {
project: '',
projectList: [],
programId: ''
}
},
watch: {
'form.extProgram.id': {
immediate: true,
deep: true,
handler(val) {
if (val) {
console.log('改变了', val)
this.getProjectList(val)
}
}
}
},
methods: {
getProjectList(programId) {
const params = {
'searchItems': {
'children': [],
'items': [{
'fieldName': 'id',
'operator': 'EQ',
'value': programId
}
],
'operator': 'AND'
},
'sortItem': [{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}],
openProps: [{
name: 'extProgramProjectLinks',
openProps: [{
name: 'target'
}]
}]
}
post(`/ExtProgram/search`, params).then((res) => {
if (res.items.content) {
this.projectList = []
res.items.content.forEach(list => {
list.extProgramProjectLinks.forEach(item => {
this.projectList.push(item.target)
})
})
}
})
},
handleChange(val) {
console.log('val', val)
this.$emit('input', val)
}
}
}
</script>
<style lang="scss" scoped>
</style>
......@@ -18,6 +18,10 @@ export default {
itemObj: {
type: Object,
default: () => {}
},
basicData: {
type: Object,
default: () => ({})
}
},
layoutConfigData: [
......@@ -39,6 +43,10 @@ export default {
}
},
mounted() {
console.log('value', this.value)
console.log('this.form', this.form)
console.log('itemObj', this.itemObj)
console.log('basicData', this.basicData)
},
methods: {
......
......@@ -2,23 +2,23 @@
* @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-08-29 11:42:37
* @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-09-10 11:42:34
* @LastEditTime: 2024-09-12 09:21:12
-->
<template>
<div>
<div class="select-project">
<!-- 这里要判断是项目还是子项,显示的是项目的关联的收入合同里面的 -->
<el-select v-if="showSelect" v-model="project" placeholder="请选择" @change="handleChange">
<!-- <el-select v-if="showSelect" v-model="project" placeholder="请选择" @change="handleChange">
<el-option
v-for="item in projectList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-select> -->
<!--input输入-->
<el-input v-else v-model="project" placeholder="请输入" @input="handleChange" />
<el-input v-model="project" placeholder="请输入" @input="handleChange" />
<img
v-if="showIcon"
class="icon"
......@@ -63,6 +63,10 @@ export default {
}
},
watch: {
value(val) {
this.project = val
this.$emit('input', val)
},
'form.projectCategory': {
immediate: true,
deep: true,
......
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