const valueChage = isEqual(record, state.beforEditData)
if (valueChage) {
console.log('数据变化了')
}
/** 比较两个对象数据的变化 */
const isEqual = (a, b) => {
let aProps = Reflect.ownKeys(a)
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i]
// 只比较这5个属性名
const checkName = [
'belongRack',
'belongStation',
'sourceNum',
'materialCode',
'autoNum'
]
if (checkName.includes(propName)) {
if (a[propName] !== b[propName]) {
return true
}
}
}
return false
}