소스 검색

修复管理员修改用户重复判断

ellisran 3 달 전
부모
커밋
ae7b46bb70

+ 4 - 1
app/service/change_apply_audit.js

@@ -1233,7 +1233,10 @@ module.exports = app => {
                 const auditors = await this.getAuditGroupByList(caId, times);
                 const now_audit = this._.find(auditors, { aid: data.old_aid });
                 if (data.operate !== 'del') {
-                    const exist = await this.getDataByCondition({ caid: caId, times, aid: data.new_aid });
+                    // const exist = await this.getDataByCondition({ caid: caId, times, aid: data.new_aid });
+                    // if (exist) throw '该审核人已存在,请勿重复添加';
+                    const groupAuditors = this._.flattenDeep(this.ctx.change.userGroups);
+                    const exist = this._.find(groupAuditors, { aid: data.new_aid });
                     if (exist) throw '该审核人已存在,请勿重复添加';
                 }
                 if (data.operate === 'add') {

+ 2 - 1
app/service/change_audit.js

@@ -1287,7 +1287,8 @@ module.exports = app => {
                 const auditors = await this.getAuditGroupByList(cid, times);
                 const now_audit = this._.find(auditors, { uid: data.old_aid });
                 if (data.operate !== 'del') {
-                    const exist = await this.getDataByCondition({ cid, times, uid: data.new_aid });
+                    const groupAuditors = this._.flattenDeep(this.ctx.change.userGroups);
+                    const exist = this._.find(groupAuditors, { uid: data.new_aid });
                     if (exist) throw '该审核人已存在,请勿重复添加';
                 }
                 if (data.operate === 'add') {

+ 4 - 1
app/service/change_plan_audit.js

@@ -1304,7 +1304,10 @@ module.exports = app => {
                 const auditors = await this.getAuditGroupByList(cpId, times);
                 const now_audit = this._.find(auditors, { aid: data.old_aid });
                 if (data.operate !== 'del') {
-                    const exist = await this.getDataByCondition({ cpid: cpId, times, aid: data.new_aid });
+                    // const exist = await this.getDataByCondition({ cpid: cpId, times, aid: data.new_aid });
+                    // if (exist) throw '该审核人已存在,请勿重复添加';
+                    const groupAuditors = this._.flattenDeep(this.ctx.change.userGroups);
+                    const exist = this._.find(groupAuditors, { aid: data.new_aid });
                     if (exist) throw '该审核人已存在,请勿重复添加';
                 }
                 if (data.operate === 'add') {

+ 4 - 1
app/service/change_project_audit.js

@@ -1369,7 +1369,10 @@ module.exports = app => {
                 const auditors = await this.getAuditGroupByList(cpId, times);
                 const now_audit = this._.find(auditors, { aid: data.old_aid });
                 if (data.operate !== 'del') {
-                    const exist = await this.getDataByCondition({ cpid: cpId, times, aid: data.new_aid });
+                    // const exist = await this.getDataByCondition({ cpid: cpId, times, aid: data.new_aid });
+                    // if (exist) throw '该审核人已存在,请勿重复添加';
+                    const groupAuditors = this._.flattenDeep(this.ctx.change.userGroups);
+                    const exist = this._.find(groupAuditors, { aid: data.new_aid });
                     if (exist) throw '该审核人已存在,请勿重复添加';
                 }
                 if (data.operate === 'add') {

+ 2 - 1
app/service/stage_audit.js

@@ -2105,7 +2105,8 @@ module.exports = app => {
                 const auditors = await this.getAuditGroupByList(stageId, times);
                 const now_audit = this._.find(auditors, { aid: data.old_aid });
                 if (data.operate !== 'del') {
-                    const exist = await this.getDataByCondition({ sid: stageId, times, aid: data.new_aid });
+                    const groupAuditors = this._.flattenDeep(this.ctx.stage.userGroups);
+                    const exist = this._.find(groupAuditors, { aid: data.new_aid });
                     if (exist) throw '该审核人已存在,请勿重复添加';
                 }
                 if (data.operate === 'add') {

+ 6 - 6
app/view/change/information_modal.ejs

@@ -312,9 +312,9 @@
                                 <% } %>
                                 <div class="<%- idx < ctx.change.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                     <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                         <% his.forEach((group, index) => { %>
-                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                                 <% if (group.endYear) { %>
                                                     <div class="timeline-item-date">
                                                         <%- group.endYear %>
@@ -467,9 +467,9 @@
                                 <% } %>
                                 <div class="<%- idx < ctx.change.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                     <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                         <% his.forEach((group, index) => { %>
-                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                                 <% if (group.endYear) { %>
                                                     <div class="timeline-item-date">
                                                         <%- group.endYear %>
@@ -636,9 +636,9 @@
                                 <% } %>
                                 <div class="<%- idx < ctx.change.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                     <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.change.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                         <% his.forEach((group, index) => { %>
-                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1 && ctx.change.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                            <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.change.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                                 <% if (his.endYear) { %>
                                                     <div class="timeline-item-date">
                                                         <%- group.endYear %>

+ 6 - 6
app/view/stage/audit_modal.ejs

@@ -156,7 +156,7 @@
                                 <% } %>
                                 <div class="<%- idx < ctx.stage.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                     <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                    <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                         <% his.forEach((group, index) => { %>
                                         <% if (index === 0) { %>
                                         <li class="timeline-list-item pb-2">
@@ -188,7 +188,7 @@
                                             </div>
                                         </li>
                                         <% } %>
-                                        <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                        <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                             <% if (group.endYear) { %>
                                             <div class="timeline-item-date">
                                                 <%- group.endYear %>
@@ -335,7 +335,7 @@
                                 <% } %>
                             <div class="<%- idx < ctx.stage.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                 <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                     <% his.forEach((group, index) => { %>
                                     <% if (index === 0) { %>
                                     <li class="timeline-list-item pb-2">
@@ -367,7 +367,7 @@
                                         </div>
                                     </li>
                                     <% } %>
-                                    <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                    <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                         <% if (group.endYear) { %>
                                         <div class="timeline-item-date">
                                             <%- group.endYear %>
@@ -516,7 +516,7 @@
                             <% } %>
                             <div class="<%- idx < ctx.stage.auditHistory.length - 1 ? 'fold-card' : '' %>">
                                 <div class="text-center text-muted"><%- idx+1 %>#</div>
-                                <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>last-auditor-list<% } %>">
+                                <ul class="timeline-list list-unstyled mt-2 <% if (idx === ctx.stage.auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                     <% his.forEach((group, index) => { %>
                                     <% if (index === 0) { %>
                                     <li class="timeline-list-item pb-2">
@@ -548,7 +548,7 @@
                                         </div>
                                     </li>
                                     <% } %>
-                                    <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1 && ctx.stage.auditHistory.length !== 1) { %>is_uncheck<% } %>">
+                                    <li class="timeline-list-item pb-2 <% if (group.status === auditConst.status.uncheck && idx === ctx.stage.auditHistory.length - 1) { %>is_uncheck<% } %>">
                                         <% if (his.endYear) { %>
                                         <div class="timeline-item-date">
                                             <%- group.endYear %>