Commit 6d5daeefd02f68568cedc83e8d739bcf3837bb00

Authored by 徐欣
1 parent 32033702

feat(approval): 流程配置门店交互 bug 修复

src/pages/approval/FlowSetting/subpages/ConditionSetting/components/CustomFlowNewOrEdit.tsx
... ... @@ -102,7 +102,8 @@ export default function CustomFlowNewOrEdit(props: Props) {
102 102 // idOrCode to idOrCode__bizType
103 103 newCondVals.forEach((n) => {
104 104 if (n.flowTriggerDto.type === TriggerType.门店) {
105   - const value = JSON.parse(n.value).map((i: FlowSetting.CondValItem) => ({
  105 + // 注意 || 和 ?? 的区别
  106 + const value = JSON.parse(n.value || '[]').map((i: FlowSetting.CondValItem) => ({
106 107 idOrCode: `${i.idOrCode}__${i.bizType}`,
107 108 name: i.name,
108 109 bizType: i.bizType,
... ... @@ -138,7 +139,7 @@ export default function CustomFlowNewOrEdit(props: Props) {
138 139 const bizTypeSet = new Set<number>();
139 140 shopCondVals.forEach((s) => {
140 141 try {
141   - const options = JSON.parse(s.value);
  142 + const options = JSON.parse(s.value || '[]');
142 143 options.forEach((o: FlowSetting.CondValItem) => {
143 144 bizTypeSet.add(o.bizType!);
144 145 });
... ... @@ -153,7 +154,7 @@ export default function CustomFlowNewOrEdit(props: Props) {
153 154 const bizTypeSet = new Set<number>();
154 155 shopCondVals.forEach((s) => {
155 156 try {
156   - const options = JSON.parse(s.value);
  157 + const options = JSON.parse(s.value || '[]');
157 158 options.forEach((o: FlowSetting.CondValItem) => {
158 159 bizTypeSet.add(o.bizType!);
159 160 });
... ... @@ -181,7 +182,7 @@ export default function CustomFlowNewOrEdit(props: Props) {
181 182 // idOrCode__bizType to idOrCode
182 183 conditionVals.forEach((n) => {
183 184 if (n.flowTriggerDto.type === TriggerType.门店) {
184   - const value = JSON.parse(n.value).map((i: FlowSetting.CondValItem) => ({
  185 + const value = JSON.parse(n.value || '[]').map((i: FlowSetting.CondValItem) => ({
185 186 idOrCode: i.idOrCode.split('__')[0]!,
186 187 name: i.name,
187 188 bizType: i.bizType,
... ... @@ -360,7 +361,7 @@ export default function CustomFlowNewOrEdit(props: Props) {
360 361 conditionVals.forEach((c) => {
361 362 const { flowTriggerDto: fd, value: v } = c;
362 363 const { type: t } = fd ?? {}; // 触发条件信息
363   - const oData = JSON.parse(v || '{}');
  364 + const oData = JSON.parse(v || '[]');
364 365 if (t === TriggerType.报销类型) {
365 366 rpTypes = oData.length > 0 ? oData.map((i: FlowSetting.CondValItem) => i.idOrCode) : [];
366 367 } else {
... ...