MaiXinRong 3 minggu lalu
induk
melakukan
bd144647ce

+ 1 - 0
app/controller/quality_controller.js

@@ -138,6 +138,7 @@ module.exports = app => {
             const pos = await this.ctx.service.pos.getAllDataByCondition({
                 where: condition,
                 columns: ['id', 'tid', 'lid', 'name'],
+                orders: [['porder', 'ASC']],
             });
             // const quality = spec && spec.loadStatus ? await this.ctx.service.quality.getAllDataByCondition({
             //     where: { tid: this.ctx.tender.id, rela_type: 'pos' },

+ 3 - 0
app/controller/sub_proj_setting_controller.js

@@ -249,6 +249,8 @@ module.exports = app => {
                     const groupList = accountList.filter(item1 => item1.company === item.name);
                     return { id: item.id, name: item.name, groupList };
                 }).filter(x => { return x.groupList.length > 0; });
+
+                const subProjects = await this.ctx.service.subProject.getAllDataByCondition({ where: { project_id: this.ctx.session.sessionProject.id, is_folder: 0, is_delete: 0 }});
                 const renderData = {
                     pageInfo,
                     accountGroup,
@@ -260,6 +262,7 @@ module.exports = app => {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.setting.sp_permission),
                     permissionBlock: ctx.service.subProjPermission.PermissionBlock,
                     accountList,
+                    subProjects,
                 };
                 await this.layout('sp_setting/user.ejs', renderData, 'sp_setting/user_modal.ejs');
             } catch (error) {

+ 1 - 1
app/lib/bills_pos_convert.js

@@ -61,7 +61,7 @@ class BillsPosConvert {
     _loadPosData(pos) {
         this.bpcPos.loadDatas(pos);
     }
-    loadData (ledger, pos, change) {
+    loadData(ledger, pos, change) {
         this._loadLedgerData(ledger);
         this._loadPosData(pos);
         this.bpcChange = change;

+ 1 - 1
app/public/js/quality_info.js

@@ -43,7 +43,7 @@ $(document).ready(() => {
                 if (!parent) return;
                 const cur = parent.children ? parent.children.find(x => { return x.name === node.name }) : null;
                 if (!cur) {
-                    xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', name: node.name, rela_type: 'pos', rela_name: node.name, pid: [node.id]}, parent);
+                    xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', code: parent.code + '-' + (parent.children.length + 1), name: node.name, rela_type: 'pos', rela_name: node.name, pid: [node.id]}, parent);
                 } else {
                     cur.pid.push(node.id);
                 }

+ 5 - 1
app/public/js/quality_rule.js

@@ -563,7 +563,7 @@ $(() => {
                     if (!parent) return;
                     const cur = parent.children ? parent.children.find(x => { return x.name === node.name }) : null;
                     if (!cur) {
-                        xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: '', name: node.name, rela_type: 'type', rela_name: node.name, pid: [node.id]}, parent);
+                        xmjTree.addNode({ id: node.id, tender_id: node.tid, rela_id: parent.id, code: parent.code + '-' + (parent.children.length + 1), name: node.name, rela_type: type, rela_name: node.name, pid: [node.id]}, parent);
                     } else {
                         cur.pid.push(node.id);
                     }
@@ -573,6 +573,10 @@ $(() => {
             for (const node of ledgerTree.children) {
                 recursiveLoad(node);
             }
+            for (const node of ledgerTree.nodes) {
+                if (!node.children || node.children.length === 0 || node.rela_type !== 'xmj' || node.children[0].rela_type !== 'pos') continue;
+
+            }
             xmjTree.sortTreeNode(false);
 
             const items = getSelectGroup();

+ 45 - 1
app/public/js/sp_setting_permission.js

@@ -248,5 +248,49 @@ $(document).ready(() => {
         postData(`/sp/${spid}/setting/user/permission/update`, { update: updateData }, function() {
             window.location.reload();
         })
-    })
+    });
+
+    $('#copy-user-batch').on('show.bs.modal', function() {
+        $('#cub-sp-all')[0].checked = false;
+        for (const c of $('[name=cub-sp-check]')) {
+            c.checked = false;
+        }
+        $('#cub-user-all')[0].checked = false;
+        for (const c of $('[name=cub-user-check]')) {
+            c.checked = false;
+        }
+    });
+    $('#cub-sp-all').click(function() {
+        for (const c of $('[name=cub-sp-check]')) {
+            c.checked = this.checked;
+        }
+    });
+    $('#cub-user-all').click(function() {
+        for (const c of $('[name=cub-user-check]')) {
+            c.checked = this.checked;
+        }
+    });
+    $('#copy-user-batch-ok').click(function() {
+        const spCheck = $('[name=cub-sp-check]:checked');
+        if (spCheck.length === 0) {
+            toastr.warning('未选择项目');
+            return;
+        }
+        const userCheck = $('[name=cub-user-check]:checked');
+        if (userCheck.length === 0) {
+            toastr.warning('未选择账号');
+            return;
+        }
+        const copyData = { spid: [], uid: [] };
+        for (const sp of spCheck) {
+            copyData.spid.push(sp.getAttribute('spid'));
+        }
+        for (const u of userCheck) {
+            copyData.uid.push(parseInt(u.getAttribute('uid')));
+        }
+        postData(`/sp/${spid}/setting/user/permission/update`, { copy: copyData }, function(result) {
+            toastr.success('设置成功');
+            $('#copy-user-batch').modal('hide');
+        });
+    });
 });

+ 21 - 0
app/service/sub_proj_permission.js

@@ -341,11 +341,32 @@ module.exports = app => {
             return updateData;
         }
 
+        async _copyUserPermission(copyData) {
+            const copyPermission = await this.getAllDataByCondition({ where: { spid: this.ctx.subProject.id, uid: copyData.uid }});
+            if (copyPermission.length === 0) throw '选择的用户不存在';
+
+            const insertData = [];
+            for (const spid of copyData.spid) {
+                const exist = await this.getAllDataByCondition({ columns: ['uid'], where: { spid } });
+                copyPermission.forEach(cp => {
+                    if (exist.find(x => { return x.uid === cp.uid; })) return;
+
+                    const idata = { id: this.uuid.v4(), spid, pid: cp.pid, uid: cp.uid };
+                    for (const prop in cp) {
+                        if (prop.indexOf('_permission') > 1) idata[prop] = cp[prop];
+                    }
+                    insertData.push(idata);
+                });
+            }
+            await this.db.insert(this.tableName, insertData);
+        }
+
         async updatePermission(subProject, data) {
             const result = {};
             if (data.add) result.add = await this._addUser(subProject, data.add);
             if (data.del) result.del = await this._delUser(subProject, data.del);
             if (data.update) result.update = await this._updateUserPermission(data.update);
+            if (data.copy) await this._copyUserPermission(data.copy);
             return result;
         }