Commit 7e901303 authored by jingnan's avatar jingnan 👀

漆料调配记录根据理论粘度字符串截取

parent 7817e807
......@@ -56,6 +56,21 @@ export default {
this.cup = this.form.viscosity && this.form.viscosity.split(' ').length > 1 ? this.form.viscosity.split(' ')[0] : this.form.viscosity
this.second = this.form.viscosity && this.form.viscosity.split(' ').length > 1 ? this.form.viscosity.split(' ')[1] : this.form.viscosity
}
},
'form.theoreticalViscosity': {
immediate: true,
deep: true,
handler: function(val) {
// 粘度里的杯根据理论粘度截取(从第一个“,“截取到第一个”杯“,有杯没有逗号的截取杯前的所有字符串)
const splitFromBei = val && val.includes('杯') ? val.split('杯')[0] + '杯' : ''
if (splitFromBei) {
const str = splitFromBei.includes(',') || splitFromBei.includes(',') ? splitFromBei : (',' + splitFromBei)
const formatVal = str.replace(/,/g, ',')
const regex = new RegExp(`,(.*?)杯`)
const result = regex.exec(formatVal)
this.cup = result ? result[1] : '' // 如果有匹配到结果则取第一个分组的内容
}
}
}
},
......
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