Commit 1590718250be525e226fd060d41edb943711ef1a

Authored by 徐欣
1 parent cb46ce67

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

src/pages/approval/ApprovalSetting/subpages/components/DefaultFlowNewOrEdit.tsx
... ... @@ -85,7 +85,8 @@ export default function DefaultSettingNewOrEdit(props: Props) {
85 85 // idOrCode to idOrCode__bizType
86 86 newCondVals.forEach((n) => {
87 87 if (n.flowTriggerDto.type === TriggerType.门店) {
88   - const value = JSON.parse(n.value).map((i: FlowSetting.CondValItem) => ({
  88 + // 注意 || 和 ?? 的区别
  89 + const value = JSON.parse(n.value || '[]').map((i: FlowSetting.CondValItem) => ({
89 90 idOrCode: `${i.idOrCode}__${i.bizType}`,
90 91 name: i.name,
91 92 bizType: i.bizType,
... ... @@ -120,7 +121,7 @@ export default function DefaultSettingNewOrEdit(props: Props) {
120 121 const bizTypeSet = new Set<number>();
121 122 shopCondVals.forEach((s) => {
122 123 try {
123   - const options = JSON.parse(s.value);
  124 + const options = JSON.parse(s.value || '[]');
124 125 options.forEach((o: FlowSetting.CondValItem) => {
125 126 bizTypeSet.add(o.bizType!);
126 127 });
... ... @@ -135,7 +136,7 @@ export default function DefaultSettingNewOrEdit(props: Props) {
135 136 const bizTypeSet = new Set<number>();
136 137 shopCondVals.forEach((s) => {
137 138 try {
138   - const options = JSON.parse(s.value);
  139 + const options = JSON.parse(s.value || '[]');
139 140 options.forEach((o: FlowSetting.CondValItem) => {
140 141 bizTypeSet.add(o.bizType!);
141 142 });
... ... @@ -162,7 +163,7 @@ export default function DefaultSettingNewOrEdit(props: Props) {
162 163 // idOrCode__bizType to idOrCode
163 164 conditionVals.forEach((n) => {
164 165 if (n.flowTriggerDto.type === TriggerType.门店) {
165   - const value = JSON.parse(n.value).map((i: FlowSetting.CondValItem) => ({
  166 + const value = JSON.parse(n.value || '[]').map((i: FlowSetting.CondValItem) => ({
166 167 idOrCode: i.idOrCode.split('__')[0]!,
167 168 name: i.name,
168 169 bizType: i.bizType,
... ... @@ -347,7 +348,7 @@ export default function DefaultSettingNewOrEdit(props: Props) {
347 348 conditionVals.forEach((c) => {
348 349 const { flowTriggerDto: fd, value: v } = c;
349 350 const { type: t } = fd ?? {}; // 触发条件信息
350   - const oData = JSON.parse(v || '{}');
  351 + const oData = JSON.parse(v || '[]');
351 352 if (t === TriggerType.报销类型) {
352 353 rpTypes = oData.length > 0 ? oData.map((i: ApprovalSetting.CondValItem) => i.idOrCode) : [];
353 354 } else {
... ...