Browse Source

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 3 years ago
parent
commit
5724fc052f

+ 14 - 15
app/public/js/path_tree.js

@@ -337,22 +337,21 @@ const createNewPathTree = function (type, setting) {
             });
             for (const data of datas) {
                 const keyName = itemsPre + data[this.setting.id];
-                if (!this.items[keyName]) {
-                    const item = JSON.parse(JSON.stringify(data));
-                    item.children = [];
-                    item.expanded = true;
-                    item.visible = true;
-                    this.items[keyName] = item;
-                    this.datas.push(item);
-                    if (item[setting.pid] === setting.rootId) {
-                        this.children.push(item);
-                    } else {
-                        const parent = this.getParent(item);
-                        if (parent) {
-                            parent.children.push(item);
-                        }
-                    }
+                if (this.items[keyName]) throw '数据错误';
+
+                const item = JSON.parse(JSON.stringify(data));
+                item.children = [];
+                item.expanded = true;
+                item.visible = true;
+                if (item[setting.pid] === setting.rootId) {
+                    this.children.push(item);
+                } else {
+                    const parent = this.getParent(item);
+                    if (!parent) continue;
+                    parent.children.push(item);
                 }
+                this.items[keyName] = item;
+                this.datas.push(item);
             }
             this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
             this.sortTreeNode(true);

+ 9 - 0
app/service/material.js

@@ -380,11 +380,20 @@ module.exports = app => {
                 this.ctx.material.decimal.up = newUp;
                 this.ctx.material.decimal.tp = newTp;
                 const m_tp = await this.ctx.service.materialBills.calcMaterialMTp(transaction);
+                let update_calc = false;
+                if (this.ctx.material.ex_calc) {
+                    const ex_calc = JSON.parse(this.ctx.material.ex_calc);
+                    const zdy = this._.find(ex_calc, { code: 'zdy' });
+                    zdy.value = this.ctx.helper.round(zdy.value, newTp);
+                    this.ctx.material.ex_calc = JSON.stringify(ex_calc);
+                    update_calc = true;
+                }
                 const [ex_tp, ex_expr] = await this.ctx.service.materialExponent.calcMaterialExTp(transaction);
                 const updateData = {
                     id: this.ctx.material.id,
                     decimal: JSON.stringify(this.ctx.material.decimal),
                 };
+                if (update_calc) updateData.ex_calc = this.ctx.material.ex_calc;
                 await transaction.update(this.tableName, updateData);
                 await transaction.commit();
                 return true;

+ 36 - 0
app/service/project_account.js

@@ -583,6 +583,10 @@ module.exports = app => {
                 if (accountData.account === undefined) {
                     throw '不存在对应账号';
                 }
+                const projectData = await this.ctx.service.project.getProjectById(accountData.project_id);
+                if (!projectData) {
+                    throw '不存在对应项目';
+                }
                 // 加密密码
                 const encryptPassword = account ? crypto.createHmac('sha1', account).update(password)
                     .digest().toString('base64') : crypto.createHmac('sha1', accountData.account).update(password)
@@ -615,6 +619,11 @@ module.exports = app => {
                     }, SmsAliConst.template.mmcz);
                 }
 
+                // 判断是否更改了账号
+                if (accountData.account !== account) {
+                    await this.syncAccount(projectData.code, accountData.account, account);
+                }
+
                 this.transaction.commit();
             } catch (error) {
                 this.transaction.rollback();
@@ -823,6 +832,33 @@ module.exports = app => {
             const sql = 'Select `account`, `name`, `company`, `role`, `mobile`, `telephone`, `is_admin` as `isAdmin`, `account_group` as `accountGroup` From ' + this.tableName + ' where project_id = ?';
             return await this.db.query(sql, [project_id]);
         }
+
+        /**
+         * 同步修改项目管理的账号
+         * @param {String} code - 项目编号
+         * @param {String} account - 旧账号
+         * @param {String} newAccount - 新账号
+         * @return {Promise} -
+         */
+        async syncAccount(code, account, newAccount) {
+            return new Promise(resolve => {
+                this.ctx.curl(`${app.config.managementProxyPath}/api/external/jl/account/update`, {
+                    method: 'POST',
+                    data: {
+                        token: this.ctx.helper.createJWT({ code, account, newAccount }),
+                    },
+                }).then(({ status, data }) => {
+                    if (status === 200) {
+                        const result = JSON.parse(data.toString());
+                        if (!result || result.code !== 0) {
+                            return resolve();
+                        }
+                        return resolve();
+                    }
+                    return resolve();
+                });
+            });
+        }
     }
 
     return ProjectAccount;

+ 3 - 3
app/view/revise/history.ejs

@@ -64,15 +64,15 @@
                         <div class="sjs-sh-2" style="overflow:auto">
                             <div class="form-group mt-2">
                                 <label >提交人</label>
-                                <input id="user-name" type="" class="form-control form-control-sm" value="<%- revise.user_name %>" disabled>
+                                <input id="user-name" class="form-control form-control-sm" value="<%- revise.user_name %>" disabled>
                             </div>
                             <div class="form-group">
                                 <label >修订内容<b class="text-danger">*</b></label>
-                                <textarea id="content" class="form-control form-control-sm" value="编写错漏5" rows="12" readonly=""><%- revise.content %></textarea>
+                                <textarea id="content" class="form-control form-control-sm" rows="12" readonly=""><%- revise.content %></textarea>
                             </div>
                             <div class="form-group">
                                 <label >审批完成</label>
-                                <input id="end-time" type="" class="form-control form-control-sm" value="<%- (revise.end_time ? ctx.moment(revise.end_time).format('YYYY-MM-DD HH:mm:ss') : '') %>" disabled>
+                                <input id="end-time" class="form-control form-control-sm" value="<%- (revise.end_time ? ctx.moment(revise.end_time).format('YYYY-MM-DD HH:mm:ss') : '') %>" disabled>
                             </div>
                         </div>
                     </div>

+ 2 - 2
config/config.default.js

@@ -229,7 +229,7 @@ module.exports = appInfo => {
     config.syncUrl = 'http://sync.jl.smartcost.com.cn/';
 
     // 项目管理跳转路径
-    config.managementPath = 'http://pm.6jlzf.cn';
-    config.managementProxyPath = 'http://pm.6jlzf.cn';
+    config.managementPath = 'http://pm.smartcost.com.cn/';
+    config.managementProxyPath = 'http://pm.smartcost.com.cn/';
     return config;
 };

+ 2 - 2
config/config.uat.js

@@ -83,7 +83,7 @@ module.exports = appInfo => {
     config.syncUrl = 'http://sync.jluat.smartcost.com.cn/';
 
     // 项目管理跳转路径
-    config.managementPath = 'http://pmqa.smartcost.com.cn';
-    config.managementProxyPath = 'http://192.168.1.76:2020';
+    config.managementPath = 'https://pmuat.smartcost.com.cn';
+    config.managementProxyPath = 'https://pmuat.smartcost.com.cn';
     return config;
 };