vue3 使用watch 监听多个数据
// 监听时间选择 watch( [ internalSubmTimer, internalTimer, externalSubmTimer, externaTimer, callbackTimer, ], (newValue, oldValue) => { Object.keys(newValue).forEach(function (key) { if (newValue[key]) { disposeTime(key, newValue[key]); } else { disposeTime(key, newValue[key]); } }); } ); // 统一处理时间 const disposeTime = (Timetype, timers) => { const [start, end] = timers || ["", ""]; let timeobj = { 0: "内审提交时间", 1: "内审时间", 2: "外审提交时间", 3: "外审时间", 4: "回调时间", }; switch (timeobj[Timetype]) { case "内审提交时间": form.value.internalAuditSubmissionStartTime = start; form.value.internalAuditSubmissionEndTime = end; break; case "内审时间": form.value.internalAuditStartTime = start; form.value.internalAuditEndTime = end; break; case "外审提交时间": form.value.externalAuditSubmissionStartTime = start; form.value.externalAuditSubmissionEndTime = end; break; case "外审时间": form.value.externalAuditStartTime = start; form.value.externalAuditEndTime = end; break; case "回调时间": form.value.notifyStartTime = start; form.value.notifyEndTime = end; break; default: } };
因为后台表格筛选用到了五六个 el-date-picker 时间日期选择器,所以为了方便,就这样统一处理了