Parcourir la source

合同部分bug及需求

ellisran il y a 8 mois
Parent
commit
4753e2d0ce

+ 1 - 1
app/extend/helper.js

@@ -1516,7 +1516,7 @@ module.exports = {
 
     async ossFileGet(path) {
         // 判断开头是否带app,否则加上
-        if (!_.includes(path, 'app/')) {
+        if (!_.includes(path, 'app/') && !_.includes(path, 'sp/contract/')) {
             path = 'app/' + path;
         }
         const result = await this.ctx.app.fujianOss.get(this.ctx.app.config.fujianOssFolder + path);

+ 46 - 2
app/public/js/contract_detail.js

@@ -7,6 +7,7 @@ $(document).ready(function() {
             {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: 'readOnly.code', cellType: 'tree'},
             {title: '合同编号', colSpan: '1', rowSpan: '2', field: 'c_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
             {title: '项目名称/合同名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 240, formatter: '@', readOnly: 'readOnly.code'},
+            {title: '创建人', colSpan: '1', rowSpan: '2', field: 'username', hAlign: 1, width: 80, formatter: '@', readOnly: true},
             {title: '合同金额', colSpan: '1', rowSpan: '2', field: 'total_price', hAlign: 2, width: 120, formatter: '@', readOnly: true},
         ],
         emptyRows: 0,
@@ -41,7 +42,12 @@ $(document).ready(function() {
     const contractCol = {
         getValue: {
             status: function (data) {
-                return data.c_code ? (data.settle_code ? '已结算' : data.yf_price !== data.total_price ? '履行中' : '已完成') : '';
+                return data.c_code ? (data.settle_code ? '● 已结算' : data.yf_price < data.total_price ? '● 履行中' : '● 已完成') : '';
+            }
+        },
+        foreColor: {
+            status: function (data) {
+                return data.c_code ? (data.settle_code ? '#6c757d' : data.yf_price < data.total_price ? '#da9500' : '#28a745') : '';
             }
         },
         readOnly: {
@@ -60,7 +66,7 @@ $(document).ready(function() {
         contractSpreadSetting.cols.push({title: '累计应回', colSpan: '1', rowSpan: '2', field: 'yf_price', hAlign: 2, width: 120, formatter: '@', readOnly: true});
         contractSpreadSetting.cols.push({title: '回款进度', colSpan: '1', rowSpan: '2', formatter: '@', readOnly: true, field: 'stackedBar', hAlign: 0, width: 200, cellType: 'stackedBar', stackedBarCover: true, bc_type: 'grid', getTip: getStackedBarTip});
     }
-    contractSpreadSetting.cols.push({title: '合同状态', colSpan: '1', rowSpan: '2', field: 'status', hAlign: 1, width: 100, formatter: '@', readOnly: true, getValue:'getValue.status'});
+    contractSpreadSetting.cols.push({title: '合同状态', colSpan: '1', rowSpan: '2', field: 'status', hAlign: 1, width: 100, formatter: '@', readOnly: true, getValue:'getValue.status', foreColor:'foreColor.status'});
     contractSpreadSetting.cols.push({title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 120, formatter: '@', readOnly: !permission_edit, cellType: 'ellipsisAutoTip', scrollHeightClass: '.sjs-height-1'});
 
     const contractSpread = SpreadJsObj.createNewSpread($('#contract-spread')[0]);
@@ -121,6 +127,27 @@ $(document).ready(function() {
             }
             return [tree, node, count];
         },
+        // setAllForeColor: function (sheet) {
+        //     for(var i = 0; i < sheet.zh_tree.nodes.length; i++){
+        //         if (!sheet.zh_tree.nodes[i].c_code) continue;
+        //         const value = contractCol.getValue.status(sheet.zh_tree.nodes[i]);
+        //         console.log(i, value);
+        //         this.setForeColor(sheet, i, value);
+        //     }
+        // },
+        // setForeColor: function (sheet, row, value = null, col = 7, color = '') {
+        //     value = value !== null ? value : sheet.getValue(row, col);
+        //     if (!value) return;
+        //     if (value === '已结算') {
+        //         color = '#6c757d';
+        //     } else if (value === '已完成') {
+        //         color = '#28a745';
+        //     } else if (value === '履行中') {
+        //         color = '#da9500';
+        //     }
+        //     console.log(sheet.getCell(row, col).text(), color);
+        //     sheet.getCell(row, col).foreColor(color);
+        // },
         /**
          * 刷新顶部按钮是否可用
          * @param sheet
@@ -1376,6 +1403,7 @@ $(document).ready(function() {
         SpreadJsObj.loadTopAndSelect(contractSheet, ckBillsSpread);
         checkShowLast(result.contractTree.length);
         contractTreeSpreadObj.refreshOperationValid(contractSheet);
+        // contractTreeSpreadObj.setAllForeColor(contractSheet);
         console.log(contractTree);
     });
 
@@ -1731,6 +1759,10 @@ $(document).ready(function() {
             const refreshNode = contractTree.loadPostData(result.node);
             contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
             contractTreeSpreadObj.setContractPays(result.pays, node);
+            // const selection = contractSheet.getSelections();
+            // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
+            // const row = sel ? sel.row : -1;
+            // contractTreeSpreadObj.setForeColor(contractSheet, row);
             $('#cons-addpay').modal('hide');
         })
     });
@@ -1792,6 +1824,10 @@ $(document).ready(function() {
             const refreshNode = contractTree.loadPostData(result.node);
             contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
             contractTreeSpreadObj.setContractPays(result.pays, node);
+            // const selection = contractSheet.getSelections();
+            // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
+            // const row = sel ? sel.row : -1;
+            // contractTreeSpreadObj.setForeColor(contractSheet, row);
             $('#cons-addpay').modal('hide');
         })
     });
@@ -1861,6 +1897,10 @@ $(document).ready(function() {
             contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
             const newNode = SpreadJsObj.getSelectObject(contractSheet);
             contractTreeSpreadObj.changeContractTab(newNode, true);
+            // const selection = contractSheet.getSelections();
+            // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
+            // const row = sel ? sel.row : -1;
+            // contractTreeSpreadObj.setForeColor(contractSheet, row);
             $('#cons-close').modal('hide');
             $('a[href*="#cons-unlock"]').show();
             $('a[href*="#cons-close"]').hide();
@@ -1883,6 +1923,10 @@ $(document).ready(function() {
             contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
             const newNode = SpreadJsObj.getSelectObject(contractSheet);
             contractTreeSpreadObj.changeContractTab(newNode, true);
+            // const selection = contractSheet.getSelections();
+            // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
+            // const row = sel ? sel.row : -1;
+            // contractTreeSpreadObj.setForeColor(contractSheet, row);
             $('#cons-unlock').modal('hide');
             $('a[href*="#cons-unlock"]').hide();
             $('a[href*="#cons-close"]').show();

+ 16 - 5
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -62,6 +62,9 @@ const SpreadJsObj = {
             if (col.getValue && Object.prototype.toString.apply(col.getValue) === "[object String]") {
                 col.getValue = getEvent(col.getValue);
             }
+            if (col.foreColor && Object.prototype.toString.apply(col.foreColor) === "[object String]") {
+                col.foreColor = getEvent(col.foreColor);
+            }
         }
     },
 
@@ -464,11 +467,19 @@ const SpreadJsObj = {
     },
     _getForeColor: function (sheet, data, row, col) {
         let foreColor = sheet.getDefaultStyle().foreColor;
-        if (sheet.zh_setting.tree.getForeColor && Object.prototype.toString.apply(sheet.zh_setting.tree.getForeColor) === "[object Function]") {
-            foreColor = sheet.zh_setting.tree.getColor(sheet, data, row, col, foreColor);
-        }
-        if (sheet.zh_setting.getForeColor && Object.prototype.toString.apply(sheet.zh_setting.getForeColor) === "[object Function]") {
-            foreColor = sheet.zh_setting.getForeColor(sheet, data, row, col, foreColor);
+        if (col.foreColor) {
+            if (Object.prototype.toString.apply(col.foreColor) === "[object Function]") {
+                foreColor = col.foreColor(data, foreColor);
+            } else {
+                foreColor = col.foreColor || foreColor;
+            }
+        } else {
+            if (sheet.zh_setting.tree.getForeColor && Object.prototype.toString.apply(sheet.zh_setting.tree.getForeColor) === "[object Function]") {
+                foreColor = sheet.zh_setting.tree.getForeColor(sheet, data, row, col, foreColor);
+            }
+            if (sheet.zh_setting.getForeColor && Object.prototype.toString.apply(sheet.zh_setting.getForeColor) === "[object Function]") {
+                foreColor = sheet.zh_setting.getForeColor(sheet, data, row, col, foreColor);
+            }
         }
         return foreColor;
     },

+ 4 - 0
app/service/contract.js

@@ -76,6 +76,7 @@ module.exports = app => {
                 throw err;
             }
             const createData = await this.ctx.service.contract.getDataById(insertId);
+            createData.username = this.ctx.session.sessionUser.name;
             const updateData = await this.ctx.service.contractTree.getNextsData(options, !node.c_code ? node.contract_id : node[this.setting.pid], node[this.setting.order] + 1);
             if (!node.c_code) {
                 const parent = await this.ctx.service.contractTree.getDataById(node.id);
@@ -136,6 +137,9 @@ module.exports = app => {
         async getListByUsers(options, user) {
             const _ = this._;
             const list = await this.getAllDataByCondition({ where: options });
+            for (const l of list) {
+                l.username = (await this.ctx.service.projectAccount.getAccountInfoById(l.uid)).name;
+            }
             if (user.is_admin) {
                 return list;
             }