这是我通过点击列表得到初始数据的方法
rowClick (row) {
if (row) {
console.log(row)
this.rowList = row
this.slideOutAttr.selectedAssignId = row.assignId
this.slideOutAttr.visiblity = true
this.slideOutAttr.size = window.innerWidth * 0.6
}
},
然后我去赋值:
watch: {
'visible': {
handler: function (newVal, oldVal) {
console.log(newVal)
if (newVal) {
console.log(this.rowList)
if (this.rowList.customerId && this.rowList.customerId !== '') {
getAvailable(this.rowList.customerId).then(res => {
this.codeList.availableList = res.data
console.log(this.codeList.availableList)
})
this.goodsList = []
if (this.rowList.customerId !== '') {
getAvailable(this.rowList.customerId).then(res => {
this.goodsList.push(res.data)
console.log(this.goodsList)
})
}
this.assignInfoList = this.rowList
console.log(this.assignInfoList)
this.serialNo = this.assignInfoList.orderAssignInnerList.length
} else {
this.assignInfoList = {
orderAssignInnerList: []
}
this.serialNo = 0
}
this.currentSelectId = 0
this.tempId = 0
this.orderAssignInnerList = []
this.addNewDetail()
}
},
deep: true
}
},
tableRowClassName (row) {
// 把每一行的索引放进row
row.row.index = row.rowIndex
},
generateId () {
this.tempId = --this.tempId;
},
generateSerialNumber () {
this.serialNo = ++this.serialNo;
},
// 信息-添加行
addNewDetail () {
const that = this
that.generateId();
that.generateSerialNumber();
console.log(that.assignInfoList.orderAssignInnerList)
that.assignInfoList.orderAssignInnerList.push({
detailId: that.tempId,
serialNumber: that.serialNo
})
console.log(that.tempId)
console.log(that.serialNo)
// console.log(that.orderAssignInnerList)
},
然后就发现数据出现了错误:
表格里面我下拉框选择数据会发现数据填写在下一行 错位了,同时序号的初始化没有生效,不刷新会一直增加