@javaguns/flow-ui
Version:
``` <template> <a-spin :spinning="loading"> <FlowDesigner ref="flowDesigner" top="50px"> </FlowDesigner> </a-spin> </template> <script lang="ts" setup> import { ref, provide, onMounted } from 'vue'; import { FlowDesigner, LoadingKey } from '@j
220 lines (219 loc) • 9.28 kB
JavaScript
import { defineComponent as k, getCurrentInstance as A, ref as H, inject as N, toRef as g, computed as U, openBlock as u, createElementBlock as p, Fragment as b, renderList as T, createElementVNode as c, createVNode as i, unref as s, withCtx as w, createBlock as y, createCommentVNode as J } from "vue";
import "../../style/condition.css";
import { pluginManager as v, getId as h } from "@javaguns/utils";
import { IconDeleteOutline as Q, IconPlusOutline as I } from "@javaguns/icon";
import { BaseColumnsKey as S, FormColumnsKey as W } from "../../../utils/injection-key.mjs";
import X from "../../../hooks/useDrawer.mjs";
import f from "../../common/flowSelect.vue.mjs";
import Y from "../../common/flowComponent.vue.mjs";
const Z = { class: "flow-condition-box" }, ee = { class: "flow-condition-group" }, oe = { class: "flow-condition-option" }, le = { class: "flow-condition-value" }, ne = ["onClick"], ae = ["onClick"], te = /* @__PURE__ */ c("span", { style: { "margin-left": "5px" } }, "且条件", -1), de = {
key: 0,
class: "flow-condition-group-connector"
}, ue = /* @__PURE__ */ c("span", { style: { "margin-left": "5px" } }, "或条件", -1), se = k({ name: "flow-branch-condition" }), ve = /* @__PURE__ */ k({
...se,
props: {
node: { default: () => ({}) },
baseColumns: {},
formColumns: {}
},
setup(G, { expose: x }) {
const F = v.getComponent("Form"), $ = v.getComponent("FormItem");
v.getComponent("Input");
const { optTypes: K, valueTypes: R, dynamicValueTypes: E, flowValueTypes: B } = X(), m = G, q = A(), D = H(), V = N(S, g([])), r = N(W, g([])), O = U(() => (n) => {
if (n.options)
return n.options;
if (n.columnValue) {
const o = r.value.filter((a) => a.fieldId == n.columnValue).map((a) => a);
return o && o.length > 0 && o[0].options && o[0].options.options ? o[0].options.options : [];
} else
return [];
}), j = U(() => {
const n = [];
if (V.value.length > 0)
for (let o = 0; o < V.value.length; o++) {
const a = V.value[o];
n.push({ name: a.fieldName, value: a.fieldId });
}
if (r.value.length > 0)
for (let o = 0; o < r.value.length; o++) {
const a = r.value[o];
n.push({ name: a.fieldName, value: a.fieldId });
}
return n;
}), L = (n, o) => {
var e;
const t = [...V.value, ...r.value].filter((d) => d.fieldId == n).map((d) => d)[0];
o.columnType = t.fieldFrom, o.columnCode = t.fieldType, o.columnId = t.fieldId, o.columnKey = t.fieldKey, o.columnName = t.fieldName, o.conditionValue = [], o.conditionValueName = [], o.options = (e = t.options) == null ? void 0 : e.options;
}, M = (n) => {
n == 1 && m.node.conditionGroup && m.node.conditionGroup.push({
id: h(),
connector: "OR",
conditions: [
{
id: h(),
// 位置编码,用户后台easyrules特殊判断
columnId: 1,
columnName: "姓名",
columnValue: "姓名",
columnType: 1,
columnKey: "userName",
columnCode: "input",
optType: "eq",
optCode: "==",
optName: "等于",
valueType: "1",
conditionValue: [],
conditionValueName: []
}
]
});
}, P = (n, o) => {
n == 1 && m.node.conditionGroup && m.node.conditionGroup.forEach((a) => {
o.id == a.id && a.conditions.push({
id: h(),
columnId: 1,
columnName: "姓名",
columnValue: "姓名",
columnType: 1,
columnKey: "userName",
columnCode: "input",
optType: "eq",
optCode: "==",
optName: "等于",
valueType: "1",
conditionValue: [],
conditionValueName: []
});
});
}, z = (n, o, a) => {
n == 1 && m.node.conditionGroup && m.node.conditionGroup.forEach((t, e) => {
o.id == t.id && t.conditions.forEach((d, l) => {
var _;
a.id == d.id && (t.conditions.splice(l, 1), t.conditions.length == 0 && ((_ = m.node.conditionGroup) == null || _.splice(e, 1)));
});
});
}, C = async () => {
try {
const n = q.proxy.$refs.formRef;
for (let o = 0; o < n.length; o++)
await n[o].validate();
return !0;
} catch (n) {
return console.log("Failed:", n), !1;
}
};
return x({
valid: C
}), (n, o) => (u(), p("div", Z, [
(u(!0), p(b, null, T(m.node.conditionGroup, (a, t) => (u(), p("div", { key: t }, [
c("div", ee, [
i(s(F), {
ref_for: !0,
ref_key: "formRef",
ref: D,
model: a
}, {
default: w(() => [
(u(!0), p(b, null, T(a.conditions, (e, d) => (u(), p("div", {
class: "flow-condition-item",
key: d
}, [
i(f, {
modelValue: e.columnValue,
"onUpdate:modelValue": (l) => e.columnValue = l,
mode: "simple",
datas: j.value,
valueName: "value",
style: { width: "40%" },
onChange: (l) => L(l, e)
}, null, 8, ["modelValue", "onUpdate:modelValue", "datas", "onChange"]),
c("div", oe, [
i(f, {
modelValue: e.optType,
"onUpdate:modelValue": (l) => e.optType = l,
label: e.optName,
"onUpdate:label": (l) => e.optName = l,
code: e.optCode,
"onUpdate:code": (l) => e.optCode = l,
mode: "simple",
datas: s(K),
style: { width: "26%" }
}, null, 8, ["modelValue", "onUpdate:modelValue", "label", "onUpdate:label", "code", "onUpdate:code", "datas"]),
i(f, {
modelValue: e.valueType,
"onUpdate:modelValue": (l) => e.valueType = l,
mode: "simple",
datas: s(R),
style: { width: "26%" },
onChange: (l) => e.conditionValue = []
}, null, 8, ["modelValue", "onUpdate:modelValue", "datas", "onChange"]),
c("div", le, [
e.valueType == 2 ? (u(), y(f, {
key: 0,
modelValue: e.conditionValue,
"onUpdate:modelValue": (l) => e.conditionValue = l,
label: e.conditionValueName,
"onUpdate:label": (l) => e.conditionValueName = l,
datas: s(E)
}, null, 8, ["modelValue", "onUpdate:modelValue", "label", "onUpdate:label", "datas"])) : e.valueType == 3 ? (u(), y(f, {
key: 1,
modelValue: e.conditionValue,
"onUpdate:modelValue": (l) => e.conditionValue = l,
label: e.conditionValueName,
"onUpdate:label": (l) => e.conditionValueName = l,
datas: s(B)
}, null, 8, ["modelValue", "onUpdate:modelValue", "label", "onUpdate:label", "datas"])) : (u(), y(s($), {
key: 2,
name: ["conditions", d, "conditionValue"],
prop: "conditions." + d + ".conditionValue",
"hide-label": "",
rules: [{ required: !0, message: "不能为空" }]
}, {
default: w(() => [
i(Y, {
comp: e.columnCode,
modelValue: e.conditionValue,
"onUpdate:modelValue": (l) => e.conditionValue = l,
code: e.conditionValueName,
"onUpdate:code": (l) => e.conditionValueName = l,
options: O.value(e),
onChange: C
}, null, 8, ["comp", "modelValue", "onUpdate:modelValue", "code", "onUpdate:code", "options"])
]),
_: 2
}, 1032, ["name", "prop"]))
])
]),
c("div", {
class: "flow-condition-del",
onClick: (l) => z(1, a, e)
}, [
i(s(Q))
], 8, ne)
]))), 128)),
c("div", {
class: "flow-condition-add",
onClick: (e) => P(1, a)
}, [
i(s(I)),
te
], 8, ae)
]),
_: 2
}, 1032, ["model"])
]),
n.node.conditionGroup && n.node.conditionGroup.length > 1 && t != n.node.conditionGroup.length - 1 ? (u(), p("div", de, "或")) : J("", !0)
]))), 128)),
c("div", {
class: "flow-condition-add",
onClick: o[0] || (o[0] = (a) => M(1))
}, [
i(s(I)),
ue
])
]));
}
});
export {
ve as default
};