problem description
pass parameters from one api to another api, but two tables in another api
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
< template >
<div class="fill" v-loading="twoloading">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="-sharpcccccc" class="tabtop13" align="center">
<tr align="center">
<td :rowspan="twoData.length+1" width="120px"></td>
<td width="100px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr align="center" v-for="(p, index) of twoData">
<td>{{enumFfacYtype[p.roject_name]}}
<!--<el-select placeholder="" v-model="p.project_key" :clearable="true" @change="ResetscaleTwo(p.project_key, index)">-->
<!--<el-option key="1" label="" value="water"></el-option>-->
<!--<el-option key="2" label="" value="electric"></el-option>-->
<!--<el-option key="3" label="" value="agri_insurance"></el-option>-->
<!--</el-select>-->
</td>
<td><el-input placeholder="" v-model="p.scale"></el-input></td>
<td><el-input-number :min="0" :controls="false" style="width: 110px" v-model="p.unit_price"></el-input-number></td>
<td><el-input-number :min="0" :controls="false" style="width: 110px" v-model="p.uscale "></el-input-number></td>
<td><el-input-number :min="0" :controls="false" style="width: 110px" v-model="p.funds"></el-input-number></td>
<td>
<el-button type="text" icon="el-icon-delete" @click="twoDelete(index)" style="font-size: 20px;color:red;"></el-button>
</td>
</tr>
</table>
</div>
<div class="fill">
<el-row type="flex" class="row-bg" justify="left">
<el-col :span="3"><el-button @click="twoNew"></el-button></el-col>
<el-col :span="3"><el-button @click="getTwoData"></el-button></el-col>
<el-col :span="3"><el-button @click="submitTwo"></el-button></el-col>
</el-row>
</div>
<div class="fill" v-loading="threeloading">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="-sharpcccccc" class="tabtop13" align="center">
<tr align="center">
<td :rowspan="threeData.length+2" width="120px"><div class="d-flex">
<div style="width: 160px"><el-date-picker v-model="create_time" type="date" style="width: 100%;" placeholder="" value-format="yyyy-MM"></el-date-picker></div>
<span class="pl-1 pr-1"></span>
<div style="width: 160px"><el-date-picker v-model="update_time" type="date" style="width: 100%;" placeholder="" value-format="yyyy-MM"></el-date-picker></div>
</div></td>
<td rowspan="2" width="100px"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td></td>
<!--<td rowspan="2"></td>-->
</tr>
<tr align="center">
<td :rowspan="threeData.length+2"></td>
</tr>
<tr align="center" v-for="(p, index) of threeData">
<td>{{enumFfacYtype[p.roject_name]}}</td>
<td><el-input placeholder="" v-model="p.unit_price"></el-input></td>
<td><el-input placeholder="" v-model="p.scale"></el-input></td>
<td><el-input placeholder="" v-model="p.funds"></el-input></td>
<td><el-button></el-button></td>
<!--<td><el-select placeholder="" v-model="p.is_normal">-->
<!--<el-option key="1" label="" value="0"></el-option>-->
<!--<el-option key="2" label="" value="1"></el-option>-->
<!--</el-select></td>-->
</tr>
</table>
</div>
<div class="fill">
<el-row type="flex" class="row-bg" justify="left">
<el-col :span="6"><el-button @click="threeNew"></el-button></el-col>
<el-col :span="3"><el-button @click="getTwoData"></el-button></el-col>
<el-col :span="3"><el-button @click="submitThree"></el-button></el-col>
</el-row>
</div>
< / div >
< / template >
< script >
import {getBusinessFacilities, getFacProduce, getSource, postSource, putSource, deleteSource,
deleteProject, getProject, getProjectt, putProject, putProjectt, postProject, postProjectt} from "@/api/credit"
import SelectProject from"@ / components/SelectProject"
import {enumCapitalSourceKey, enumFfacYtype} from"@ / utils/enum"
export default {
components: {
SelectProject
},
props: {},
data() {
return {
enumCapitalSourceKey,
enumFfacYtype,
twoloading: false,
threeloading: false,
isput: false,
Twoisput: false,
threeisput: false,
twoData: [],
threeData: [],
update_time: "",
create_time: "",
tableData: [],
tempData: []
}
},
computed: {},
watch: {},
created() {
this.form = JSON.parse(localStorage.getItem("detail"))
this.getData()
},
mounted() {
},
methods: {
getData() {
this.getBussinData()
this.getFacPData()
},
getFacPData() {
this.tempData = []
this.twoData = []
getFacProduce({
service_id: this.form.service_id,
customer_id: this.form.customer_id
}, {service_id: "eq", customer_id: "eq"}).then(res => {
if (res.data) {
this.tempData = res.data
// for (let i = 0; i < this.tempData.length; iPP) {
// this.getTwoData(this.tempData[i].id, i)
// }
}
}).catch(err => {
console.log(err)
})
},
getBussinData() {
this.tableData = []
this.twoData = []
this.threeData = []
getBusinessFacilities({
service_id: this.form.service_id,
customer_id: this.form.customer_id
}, {service_id: "eq", customer_id: "eq"}).then(res => {
if (res.data) {
this.tableData = res.data
for (let i = 0; i < this.tableData.length; iPP) {
this.getTwoData(this.tableData[i].id, i)
}
for (let t = 0; t < this.tableData.length; tPP) {
this.getThreeData(this.tableData[t].id, t)
}
}
}).catch(err => {
console.log(err)
})
},
getTwoData(id, i) {
this.twoloading = true
getProject({
customer_id: this.form.customer_id,
customer_related_id: this.form.customer_related_id,
id: id
}, {id: "eq", customer_id: "eq", customer_related_id: "eq"}).then(res => {
if (res.data) {
let tem = []
tem = res.data
for (let p = 0; p < tem.length; pPP) {
tem[p].roject_name = this.tableData[i].fac_type
tem[p].id = this.tableData[i].id
// tem[p].fac_name = this.tempData[i].fac_name
// tem[p].id = this.tempData[i].id
this.twoData.push(tem[p])
}
this.Twoisput = true
} else {
this.twoData.push({
roject_name: this.tableData[i].fac_type,
id: this.tableData[i].id
// fac_name: this.tempData[i].fac_name
// // id: this.tempData[i].id
})
}
}).catch(err => {
console.log(err)
}).then(() => {
this.twoloading = false
})
},
getThreeData(id, t) {
this.threeloading = true
getProjectt({
customer_id: this.form.customer_id,
customer_related_id: this.form.customer_related_id,
id: id
}, {id: "eq", customer_id: "eq", customer_related_id: "eq"}).then(res => {
if (res.data) {
let tem = []
tem = res.data
for (let p = 0; p < tem.length; pPP) {
tem[p].roject_name = this.tableData[t].fac_type
tem[p].id = this.tableData[t].id
this.threeData.push(tem[p])
}
this.threeisput = true
// this.create_time = this.threeData[0].create_time
// this.update_time = this.threeData[0].update_time
} else {
this.threeData.push({
roject_name: this.tableData[t].fac_type,
id: this.tableData[t].id
})
}
}).catch(err => {
console.log(err)
}).then(() => {
this.threeloading = false
})
},
twoNew() {
if (this.Twoisput) {
this.twoData = [{}]
}
this.twoData.push({})
this.Twoisput = false
},
threeNew() {
// if (this.threeisput) {
// this.threeData = [{}]
// }
this.threeData.push({})
this.threeisput = false
},
submitThree() {
this.threeloading = true
let i = 1
for (let t = 0; t < this.threeData.length; tPP) {
if (this.threeData[t].unit_price) {
this.$delete(this.threeData[t], "roject_name")
this.threeData[t].customer_id = this.form.customer_id
this.threeData[t].customer_related_id = this.form.id
this.threeData[t].customer_name = this.form.farm_name
this.threeData[t].id = this.id
// this.threeData[t].create_time = this.create_time
// this.threeData[t].update_time = this.update_time
} else {
i = 0
this.threeloading = false
return this.$message.warning("")
}
}
if (i === 1) {
if (!this.threeisput) {
postProjectt(this.threeData).then(res => {
if (res.data) {
this.$message.success("")
} else {
this.$message.error("")
}
}).catch(err => {
console.log(err)
this.$message.error("")
}).then(() => {
this.getThreeData()
})
} else {
for (let p of this.threeData) {
putProjectt(p.id, p).then(res => {
if (res.data) {
this.$message.success("")
}
}).catch(err => {
console.log(err)
this.$message.error("")
}).then(() => {
this.getThreeData()
})
}
}
}
},
submitTwo() {
this.twoloading = true
let i = 1
for (let t = 0; t < this.twoData.length; tPP) {
if (this.twoData[t].scale && this.twoData[t].unit_price && this.twoData[t].funds) {
this.$delete(this.twoData[t], "roject_name")
this.twoData[t].customer_id = this.form.customer_id
this.twoData[t].customer_related_id = this.form.id
this.twoData[t].id = this.id
this.twoData[t].customer_name = this.form.farm_name
} else {
i = 0
this.twoloading = false
return this.$message.warning("")
}
}
if (i === 1) {
if (!this.Twoisput) {
postProject(this.twoData).then(res => {
if (res.data) {
this.$message.success("")
} else {
this.$message.error("")
}
}).catch(err => {
console.log(err)
this.$message.error("")
}).then(() => {
this.getTwoData()
})
} else {
for (let p of this.twoData) {
putProject(p.id, p).then(res => {
if (res.data) {
this.$message.success("")
}
}).catch(err => {
console.log(err)
this.$message.error("")
}).then(() => {
this.getTwoData()
})
}
}
}
}
}
}
< / script >
< style scoped >
< / style >
what result do you expect? What is the error message actually seen?
can give me more answers. Why does it have this problem? Cannot read property "fac_type" of undefined,. I"ve already made it worth it.