mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(data-source): 组件配置与条件关联了不同数据源时,编译问题
This commit is contained in:
parent
740c2a73fa
commit
36988cd3e0
@ -163,7 +163,14 @@ class DataSourceManager extends EventEmitter {
|
||||
let result = true;
|
||||
for (const { op, value, range, field } of cond) {
|
||||
const [sourceId, fieldKey] = field;
|
||||
const fieldValue = this.data[sourceId][fieldKey];
|
||||
|
||||
const dsData = this.data[sourceId];
|
||||
|
||||
if (!dsData || !fieldKey) {
|
||||
break;
|
||||
}
|
||||
|
||||
const fieldValue = dsData[fieldKey];
|
||||
if (!compiledCond(op, fieldValue, value, range)) {
|
||||
result = false;
|
||||
break;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { cloneDeep, union } from 'lodash-es';
|
||||
|
||||
import type { AppCore } from '@tmagic/schema';
|
||||
import { getDepNodeIds, getNodes, replaceChildNode } from '@tmagic/utils';
|
||||
@ -48,28 +48,20 @@ export const createDataSourceManager = (app: AppCore) => {
|
||||
}
|
||||
|
||||
dataSourceManager.on('change', (sourceId: string) => {
|
||||
const dep = dsl.dataSourceDeps?.[sourceId];
|
||||
const condDep = dsl.dataSourceCondDeps?.[sourceId];
|
||||
const dep = dsl.dataSourceDeps?.[sourceId] || {};
|
||||
const condDep = dsl.dataSourceCondDeps?.[sourceId] || {};
|
||||
|
||||
if (condDep) {
|
||||
dataSourceManager.emit(
|
||||
'update-data',
|
||||
getNodes(Object.keys(condDep), dsl.items).map((node) => {
|
||||
const newNode = cloneDeep(node);
|
||||
newNode.condResult = dataSourceManager.compliedConds(node);
|
||||
return newNode;
|
||||
}),
|
||||
sourceId,
|
||||
);
|
||||
}
|
||||
const nodeIds = union([...Object.keys(condDep), ...Object.keys(dep)]);
|
||||
|
||||
if (dep) {
|
||||
dataSourceManager.emit(
|
||||
'update-data',
|
||||
getNodes(Object.keys(dep), dsl.items).map((node) => dataSourceManager.compiledNode(node)),
|
||||
sourceId,
|
||||
);
|
||||
}
|
||||
dataSourceManager.emit(
|
||||
'update-data',
|
||||
getNodes(nodeIds, dsl.items).map((node) => {
|
||||
const newNode = cloneDeep(node);
|
||||
newNode.condResult = dataSourceManager.compliedConds(node);
|
||||
return dataSourceManager.compiledNode(newNode);
|
||||
}),
|
||||
sourceId,
|
||||
);
|
||||
});
|
||||
|
||||
return dataSourceManager;
|
||||
|
@ -175,7 +175,7 @@ const dataSourceFieldsConfig: FormConfig = [
|
||||
if (model.type === 'number') return 'number';
|
||||
if (model.type === 'boolean') return 'select';
|
||||
|
||||
return 'string';
|
||||
return 'text';
|
||||
},
|
||||
options: [
|
||||
{ text: 'true', value: true },
|
||||
|
Loading…
x
Reference in New Issue
Block a user