mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-09 04:04:29 +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;
|
let result = true;
|
||||||
for (const { op, value, range, field } of cond) {
|
for (const { op, value, range, field } of cond) {
|
||||||
const [sourceId, fieldKey] = field;
|
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)) {
|
if (!compiledCond(op, fieldValue, value, range)) {
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep, union } from 'lodash-es';
|
||||||
|
|
||||||
import type { AppCore } from '@tmagic/schema';
|
import type { AppCore } from '@tmagic/schema';
|
||||||
import { getDepNodeIds, getNodes, replaceChildNode } from '@tmagic/utils';
|
import { getDepNodeIds, getNodes, replaceChildNode } from '@tmagic/utils';
|
||||||
@ -48,28 +48,20 @@ export const createDataSourceManager = (app: AppCore) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataSourceManager.on('change', (sourceId: string) => {
|
dataSourceManager.on('change', (sourceId: string) => {
|
||||||
const dep = dsl.dataSourceDeps?.[sourceId];
|
const dep = dsl.dataSourceDeps?.[sourceId] || {};
|
||||||
const condDep = dsl.dataSourceCondDeps?.[sourceId];
|
const condDep = dsl.dataSourceCondDeps?.[sourceId] || {};
|
||||||
|
|
||||||
if (condDep) {
|
const nodeIds = union([...Object.keys(condDep), ...Object.keys(dep)]);
|
||||||
dataSourceManager.emit(
|
|
||||||
'update-data',
|
|
||||||
getNodes(Object.keys(condDep), dsl.items).map((node) => {
|
|
||||||
const newNode = cloneDeep(node);
|
|
||||||
newNode.condResult = dataSourceManager.compliedConds(node);
|
|
||||||
return newNode;
|
|
||||||
}),
|
|
||||||
sourceId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dep) {
|
dataSourceManager.emit(
|
||||||
dataSourceManager.emit(
|
'update-data',
|
||||||
'update-data',
|
getNodes(nodeIds, dsl.items).map((node) => {
|
||||||
getNodes(Object.keys(dep), dsl.items).map((node) => dataSourceManager.compiledNode(node)),
|
const newNode = cloneDeep(node);
|
||||||
sourceId,
|
newNode.condResult = dataSourceManager.compliedConds(node);
|
||||||
);
|
return dataSourceManager.compiledNode(newNode);
|
||||||
}
|
}),
|
||||||
|
sourceId,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return dataSourceManager;
|
return dataSourceManager;
|
||||||
|
@ -175,7 +175,7 @@ const dataSourceFieldsConfig: FormConfig = [
|
|||||||
if (model.type === 'number') return 'number';
|
if (model.type === 'number') return 'number';
|
||||||
if (model.type === 'boolean') return 'select';
|
if (model.type === 'boolean') return 'select';
|
||||||
|
|
||||||
return 'string';
|
return 'text';
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{ text: 'true', value: true },
|
{ text: 'true', value: true },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user