Showing
1 changed file
with
56 additions
and
2 deletions
| ... | @@ -797,6 +797,51 @@ export default { | ... | @@ -797,6 +797,51 @@ export default { |
| 797 | // }); | 797 | // }); |
| 798 | }); | 798 | }); |
| 799 | 799 | ||
| 800 | + /** | ||
| 801 | + * 实时检查表单数据是否正确 | ||
| 802 | + * @param node_name | ||
| 803 | + * @param node_name | ||
| 804 | + * @param userTags | ||
| 805 | + * @param field_auths | ||
| 806 | + */ | ||
| 807 | + function checkFormDataError(node_name, userTags, field_auths) { | ||
| 808 | + let { nodes } = editor.editorState.graph.save(); | ||
| 809 | + let avail_count = field_auths.filter((ele) => { | ||
| 810 | + if ((ele.visible.checked && !ele.visible.disabled )|| (ele.editable.checked && !ele.editable.disabled)) { | ||
| 811 | + return ele; | ||
| 812 | + } | ||
| 813 | + }); | ||
| 814 | + if (!node_name) { // 节点名称为空,错误提示 | ||
| 815 | + nodes.forEach((ele: any, idx: number) => { | ||
| 816 | + if (ele.id === state.detailModel.id) { | ||
| 817 | + ele.desc = 'https://cdn.ipadbiz.cn/oa/flow/icons-error1.png'; | ||
| 818 | + editor.updateModel(ele); // 更新流程图信息 | ||
| 819 | + } | ||
| 820 | + }); | ||
| 821 | + } else if (!userTags.length) { // 负责人为空,错误提示 | ||
| 822 | + nodes.forEach((ele: any, idx: number) => { | ||
| 823 | + if (ele.id === state.detailModel.id) { | ||
| 824 | + ele.desc = 'https://cdn.ipadbiz.cn/oa/flow/icons-error1.png'; | ||
| 825 | + editor.updateModel(ele); // 更新流程图信息 | ||
| 826 | + } | ||
| 827 | + }); | ||
| 828 | + } else if (!avail_count.length) { // 字段权限为空,错误提示 | ||
| 829 | + nodes.forEach((ele: any, idx: number) => { | ||
| 830 | + if (ele.id === state.detailModel.id) { | ||
| 831 | + ele.desc = 'https://cdn.ipadbiz.cn/oa/flow/icons-error1.png'; | ||
| 832 | + editor.updateModel(ele); // 更新流程图信息 | ||
| 833 | + } | ||
| 834 | + }); | ||
| 835 | + } else { | ||
| 836 | + nodes.forEach((ele: any, idx: number) => { | ||
| 837 | + if (ele.id === state.detailModel.id) { | ||
| 838 | + ele.desc = ''; | ||
| 839 | + editor.updateModel(ele); // 更新流程图信息 | ||
| 840 | + } | ||
| 841 | + }); | ||
| 842 | + } | ||
| 843 | + } | ||
| 844 | + | ||
| 800 | /************* 监听表单数据变化 **************/ | 845 | /************* 监听表单数据变化 **************/ |
| 801 | watch( | 846 | watch( |
| 802 | () => state.node_name, | 847 | () => state.node_name, |
| ... | @@ -806,8 +851,9 @@ export default { | ... | @@ -806,8 +851,9 @@ export default { |
| 806 | state.node_tree[state.detailModel.id].name = newValue; | 851 | state.node_tree[state.detailModel.id].name = newValue; |
| 807 | } | 852 | } |
| 808 | } | 853 | } |
| 854 | + checkFormDataError(newValue, state.userTags, state.field_auths); | ||
| 809 | }, | 855 | }, |
| 810 | - { immediate: true } | 856 | + // { immediate: true } |
| 811 | ); | 857 | ); |
| 812 | watch( | 858 | watch( |
| 813 | () => state.userTags, | 859 | () => state.userTags, |
| ... | @@ -817,10 +863,18 @@ export default { | ... | @@ -817,10 +863,18 @@ export default { |
| 817 | state.node_tree[state.detailModel.id].user = newValue; | 863 | state.node_tree[state.detailModel.id].user = newValue; |
| 818 | } | 864 | } |
| 819 | } | 865 | } |
| 866 | + checkFormDataError(state.node_name, newValue, state.field_auths); | ||
| 820 | }, | 867 | }, |
| 821 | // { immediate: true } | 868 | // { immediate: true } |
| 822 | ); | 869 | ); |
| 823 | watch( | 870 | watch( |
| 871 | + () => state.field_auths, | ||
| 872 | + (newValue, oldValue) => { | ||
| 873 | + checkFormDataError(state.node_name, state.userTags, newValue); | ||
| 874 | + }, | ||
| 875 | + { deep: true } | ||
| 876 | + ); | ||
| 877 | + watch( | ||
| 824 | () => state.more_attr, | 878 | () => state.more_attr, |
| 825 | (newValue, oldValue) => { | 879 | (newValue, oldValue) => { |
| 826 | if (newValue !== oldValue) { | 880 | if (newValue !== oldValue) { |
| ... | @@ -1889,7 +1943,7 @@ export default { | ... | @@ -1889,7 +1943,7 @@ export default { |
| 1889 | * @return {void} No return value. | 1943 | * @return {void} No return value. |
| 1890 | */ | 1944 | */ |
| 1891 | const noticeError = (checkResult) => { | 1945 | const noticeError = (checkResult) => { |
| 1892 | - let { nodes, edges } = editor.editorState.graph.save(); | 1946 | + let { nodes } = editor.editorState.graph.save(); |
| 1893 | let available_keys = _.map(nodes, 'id'); // 画布上存在的有效节点ID | 1947 | let available_keys = _.map(nodes, 'id'); // 画布上存在的有效节点ID |
| 1894 | let raw_keys = _.intersection(checkResult.data, available_keys); // 取交集有效ID | 1948 | let raw_keys = _.intersection(checkResult.data, available_keys); // 取交集有效ID |
| 1895 | let node_keys = Object.keys(state.node_tree); // 现在本地的ID都是有效的值 | 1949 | let node_keys = Object.keys(state.node_tree); // 现在本地的ID都是有效的值 | ... | ... |
-
Please register or login to post a comment