Commit 3711fb14 authored by jingnan's avatar jingnan 👀

问题进展组件修改

parent 95a0f181
<template> <template>
<div class="problemProgressCom"> <div class="problemProgressCom">
<el-form ref="form" class="processForm" :inline="true" :model="formData" label-width="40px"> <el-form ref="form" class="processForm" :inline="true" :model="formData" label-width="40px">
<el-row v-for="(item, index) in formData.progresss" :key="index"> <el-row v-for="(item, index) in resultFormData" :key="index">
<el-col :span="5"> <el-col :span="5">
<el-form-item <el-form-item
label="日期" label="日期"
:prop="'progresss.' + index + '.createTime'" :prop="'progresss.' + index + '.progressTime'"
> >
<!-- :rules="{ <!-- :rules="{
required: true, message: '该项必填', trigger: 'blur' required: true, message: '该项必填', trigger: 'blur'
}" --> }" -->
<el-date-picker <el-date-picker
v-model="item.createTime" v-model="item.progressTime"
size="small" size="small"
type="date" type="date"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
...@@ -28,15 +28,15 @@ ...@@ -28,15 +28,15 @@
<!-- :rules="[ <!-- :rules="[
{required: true, message: '该项必填', trigger: 'blur'}, {required: true, message: '该项必填', trigger: 'blur'},
]" --> ]" -->
<el-input v-model="item.progressItem" autosize type="textarea" size="small" /> <el-input v-model="item.progressItem" autosize type="textarea" size="small" @change="changeVal" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<el-form-item class="btn-box"> <el-form-item class="btn-box">
<span v-if="index+1 == formData.progresss.length" class="btn-item" title="新增" @click="addItem"> <span v-if="index+1 == resultFormData.length" class="btn-item" title="新增" @click="addItem" @change="changeVal">
<img src="/icons/c-add.png" alt=""> <img src="/icons/c-add.png" alt="">
</span> </span>
<span v-if="index !== 0" class="btn-item" title="删除" @click.stop="() => deleteItem(data)"> <span v-if="index !== 0" class="btn-item" title="删除" @click="deleteItem(item,index)">
<img src="/icons/c-creatbackups.png" alt=""> <img src="/icons/c-creatbackups.png" alt="">
</span> </span>
</el-form-item> </el-form-item>
...@@ -76,7 +76,7 @@ export default { ...@@ -76,7 +76,7 @@ export default {
formData: { formData: {
progresss: [ progresss: [
{ {
createTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), progressTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
progressItem: '', progressItem: '',
operator: 'ADD' operator: 'ADD'
} }
...@@ -85,32 +85,30 @@ export default { ...@@ -85,32 +85,30 @@ export default {
} }
}, },
computed: {}, computed: {
resultFormData() {
return this.formData.progresss.filter(item => item.operator !== 'REMOVE')
}
},
watch: { watch: {
value: { value: {
immediate: true, immediate: true,
deep: true, deep: true,
handler(v) { handler(v) {
if (v) { if (v) {
// this.selVal = this.value this.$set(this.formData, 'progresss', this.value.map(item => {
this.$set(this.formData, 'progresss', this.value) if (!item.operator) {
}
}
},
formData: {
immediate: true,
deep: true,
handler() {
this.$emit('input', this.formData.progresss.map(item => {
if (item.id) { if (item.id) {
item.operator = 'MODIFY' item.operator = 'MODIFY'
} else { } else {
item.operator = 'ADD' item.operator = 'ADD'
} }
}
return item return item
})) }))
} }
} }
}
}, },
created() { created() {
// 初始化数据 // 初始化数据
...@@ -118,16 +116,18 @@ export default { ...@@ -118,16 +116,18 @@ export default {
methods: { methods: {
addItem() { addItem() {
this.formData.progresss.push({ this.formData.progresss.push({
createTime: moment(new Date()).format('YYYY-MM-DD'), progressTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
progressItem: '', progressItem: '',
operator: 'ADD' operator: 'ADD'
}) })
this.changeVal()
}, },
deleteItem(item, index) { deleteItem(item, index) {
this.formData.progresss.splice(index, 1) item.operator = 'REMOVE'
this.changeVal()
}, },
changeVal() { changeVal() {
this.$emit('input', this.selVal) this.$emit('input', this.formData.progresss)
} }
} }
} }
......
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