|
@@ -1036,6 +1036,28 @@ class SystemEventFu {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 清空 viewmodel 里下属的所有属性
|
|
|
+ * @param viewModel VM对象
|
|
|
+ * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
|
|
|
+ * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
|
|
|
+ */
|
|
|
+export function clearViewModel(viewModel, propertyKey, ignoreProps) {
|
|
|
+ let data = viewModel.data
|
|
|
+
|
|
|
+ if (propertyKey) {
|
|
|
+ data = _.get(data, propertyKey)
|
|
|
+ }
|
|
|
+
|
|
|
+ _.forOwn(data, (value, key) => {
|
|
|
+ let targetKey = propertyKey ? propertyKey + "." + key : key
|
|
|
+ if (ignoreProps && _.indexOf(ignoreProps, targetKey) >= 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ viewModel.set(targetKey, '')
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
export function clearViewModelByLookup(sender, lookup) {
|
|
|
if (_.isPlainObject(lookup)) {
|
|
|
const parentScope = lookupScope(sender)
|