Browse Source

签章及变更功能调整

laiguoran 2 years atrás
parent
commit
3a1d2d9693

+ 2 - 0
app/controller/change_controller.js

@@ -714,6 +714,7 @@ module.exports = app => {
                                 cl['audit_amount_' + au.uid] = audit_amount[index - 1] ? audit_amount[index - 1] : null;
                             }
                         }
+                        cl.changed_amount = (change.status === audit.flow.status.backnew || change.status === audit.flow.status.checking || change.status === audit.flow.status.checked) && audit_amount !== '' ? audit_amount[audit_amount.length - 1] : cl.camount;
                     }
                     renderData.changeList = changeList;
                     renderData.auditList2 = auditList2;
@@ -763,6 +764,7 @@ module.exports = app => {
                                 cl['audit_amount_' + au.uid] = au.uid === ctx.session.sessionUser.accountId ? cl.spamount : (audit_amount[index - 1] ? audit_amount[index - 1] : null);
                             }
                         }
+                        cl.changed_amount = (change.status === audit.flow.status.backnew || change.status === audit.flow.status.checking || change.status === audit.flow.status.checked) && audit_amount !== '' ? audit_amount[audit_amount.length - 1] : cl.camount;
                     }
                     renderData.changeList = changeList;
                     renderData.changeLedgerList = await ctx.service.changeLedger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });

+ 1 - 1
app/controller/material_controller.js

@@ -377,8 +377,8 @@ module.exports = app => {
         async info(ctx) {
             try {
                 await this._getMaterialAuditViewData(ctx);
-                const renderData = await this._getDefaultRenderData(ctx);
                 await this._setEditTaxPermission(ctx);
+                const renderData = await this._getDefaultRenderData(ctx);
                 renderData.materialBillsData = await this._getMaterialBillsData(ctx);
                 // 取对应期的截取上期的调差金额和应耗数量
                 if (ctx.material.highOrder !== ctx.material.order) {

+ 61 - 2
app/controller/profile_controller.js

@@ -364,10 +364,16 @@ module.exports = app => {
                     if (!accountData.stamp_path) {
                         throw '不存在签章';
                     }
+                    const stamp_path_list = accountData.stamp_path.split('!;!');
+                    const spIndex = ctx.helper._.indexOf(stamp_path_list, data.src);
+                    if (spIndex === -1) {
+                        throw '不存在此签章';
+                    }
                     // 删除oss文件
-                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + accountData.stamp_path);
+                    await ctx.app.fujianOss.delete(ctx.app.config.fujianOssFolder + stamp_path_list[spIndex]);
+                    stamp_path_list.splice(spIndex, 1);
                     // 删除库
-                    result = await ctx.service.projectAccount.update({ stamp_path: null }, { id: sessionUser.accountId });
+                    result = await ctx.service.projectAccount.update({ stamp_path: stamp_path_list.length === 0 ? null : stamp_path_list.join('!;!') }, { id: sessionUser.accountId });
                 } else {
                     if (accountData.sign_path === '') {
                         throw '不存在签名';
@@ -462,6 +468,59 @@ module.exports = app => {
         }
 
         /**
+         * 上传签章图(多选)
+         *
+         * @param {object} ctx - egg全局变量
+         * @return {void}
+         */
+        async stampUpload(ctx) {
+            const responseData = {
+                err: 0, msg: '', data: null,
+            };
+            let stream;
+            try {
+                const parts = ctx.multipart({ autoFields: true });
+                const paths = [];
+                let index = 0;
+                while ((stream = await parts()) !== undefined) {
+                    // 判断用户是否选择上传文件
+                    if (!stream.filename) {
+                        throw '请选择上传的文件!';
+                    }
+                    const fileInfo = path.parse(stream.filename);
+                    const create_time = Date.parse(new Date()) / 1000;
+                    const filepath = `app/public/upload/sign/profile/qianzhang_${create_time + index.toString() + fileInfo.ext}`;
+                    // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, filepath));
+                    await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
+                    if (stream) {
+                        await sendToWormhole(stream);
+                    }
+                    paths.push(filepath);
+                    ++index;
+                }
+                // 获取账号数据
+                const accountData = await ctx.service.projectAccount.getDataByCondition({ id: ctx.session.sessionUser.accountId });
+                const stamp_path = accountData.stamp_path ? accountData.stamp_path.split('!;!') : [];
+                const stamp_path_list = ctx.helper._.concat(stamp_path, paths);
+                const result = await ctx.service.projectAccount.update({ stamp_path: stamp_path_list.join('!;!') }, { id: ctx.session.sessionUser.accountId });
+                if (result) {
+                    responseData.data = { stamp_path: stamp_path_list };
+                } else {
+                    throw '添加数据库失败';
+                }
+            } catch (err) {
+                this.log(err);
+                // 失败需要消耗掉stream 以防卡死
+                if (stream) {
+                    await sendToWormhole(stream);
+                }
+                responseData.err = 1;
+                responseData.msg = err.toString();
+            }
+            ctx.body = responseData;
+        }
+
+        /**
          * 账号安全
          *
          * @param {object} ctx - egg全局变量

+ 17 - 6
app/public/js/change_information_show.js

@@ -22,6 +22,8 @@ $(document).ready(() => {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp'},
             {title: '审批后变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.sa_tp'},
+            {title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.changed_amount'},
+            {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.changed_tp'},
         ],
         emptyRows: 0,
         headRows: 2,
@@ -90,6 +92,12 @@ $(document).ready(() => {
             sa_tp: function (data) {
                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
             },
+            changed_amount: function (data) {
+                return ZhCalc.round(data.changed_amount, findDecimal(data.unit));
+            },
+            changed_tp: function (data) {
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.changed_amount, findDecimal(data.unit))), totalPriceUnit);
+            },
         },
     };
 
@@ -122,10 +130,10 @@ $(document).ready(() => {
                 for(let i = 0; i <= rowCount - 1; i++){
                     const data = {
                         unit_price: changeSpreadSheet.getValue(i, 3),
-                        amount: parseFloat(changeSpreadSheet.getValue(i, 12 + parseInt(j)*2)),
+                        amount: parseFloat(changeSpreadSheet.getValue(i, 14 + parseInt(j)*2)),
                     };
                     const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.amount), totalPriceUnit);
-                    changeSpreadSheet.setValue(i, 13 + j*2, sum !== 0 ? sum : null);
+                    changeSpreadSheet.setValue(i, 15 + j*2, sum !== 0 ? sum : null);
                 }
             }
         },
@@ -133,27 +141,30 @@ $(document).ready(() => {
             const rowCount = changeSpreadSheet.getRowCount();
             let oSum = 0,
                 cSum = 0,
-                sSum = 0;
+                sSum = 0,
+                cdSum = 0;
             for(let i = 0; i < rowCount - 1; i++){
                 oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
                 cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
                 sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 11));
+                cdSum = ZhCalc.add(cdSum, changeSpreadSheet.getValue(i, 13));
             }
             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, sSum !== 0 ? sSum : null);
+            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13, cdSum !== 0 ? cdSum : null);
             // 用户的数据合计
             for (const j in aidList) {
                 let audit_sum = 0;
                 for(let i = 0; i < rowCount - 1; i++){
-                    audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
+                    audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 15 + j*2));
                 }
-                changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
+                changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 15 + j*2, audit_sum !== 0 ? audit_sum : null);
             }
         },
         showHideAudit: function (show = false) {
             const count = changeSpreadSetting.cols.length;
-            for (let i = 12; i < count; i++) {
+            for (let i = 14; i < count; i++) {
                 changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
             }
             changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);

+ 45 - 17
app/public/js/profile.js

@@ -120,9 +120,12 @@ $(document).ready(function() {
         });
 
         // 移除签章
-        $('#delete-stamp').click(function () {
-            postData('/profile/sign/delete', { type: 'stamp' }, function (result) {
-                $('#stamp-show').html('');
+        $('body').on('click', '.delete-stamp', function () {
+            let imgSrc = $(this).siblings('img').attr('src');
+            imgSrc = _.replace(imgSrc, fujianOssPath, '');
+            const _self = $(this);
+            postData('/profile/sign/delete', { type: 'stamp', src: imgSrc }, function (result) {
+                _self.parents('.stamp-show').remove();
                 toastr.success('移除成功');
             })
         });
@@ -141,6 +144,11 @@ $(document).ready(function() {
         // 上传签名
         $('#sign-upload').change(function () {
             const file = this.files[0];
+            const filesize = file.size;
+            if (filesize > 1 * 1024 * 1024) {
+                toastr.error('存在上传文件大小过大!');
+                return false;
+            }
             const ext = file.name.toLowerCase().split('.').splice(-1)[0];
             const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
             if (!imgStr.test(ext)) {
@@ -160,23 +168,43 @@ $(document).ready(function() {
 
         // 上传签章
         $('#stamp-upload').change(function () {
-            const file = this.files[0];
-            const ext = file.name.toLowerCase().split('.').splice(-1)[0];
-            const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
-            if (!imgStr.test(ext)) {
-                toastr.error('请上传正确的图片格式文件');
+            if ($('#show-stamp .stamp-show').length >= 5) {
+                toastr.error('最多只能5个签章');
                 return
             }
-            if ($(this).val()) {
-                const formData = new FormData();
-                formData.append('type', 'stamp');
-                formData.append('file', this.files[0]);
-                postDataWithFile('/profile/sign/upload', formData, function (result) {
-                    const html = '<img src="'+ fujianOssPath + result.stamp_path +'" width="90">';
-                    $('#stamp-show').html(html);
-                    $('#stamp-upload').val('');
-                });
+            const files = this.files;
+            const formData = new FormData();
+            for (const file of files) {
+                if (file === undefined) {
+                    toast('未选择上传文件!', 'error');
+                    return false;
+                }
+                const ext = file.name.toLowerCase().split('.').splice(-1)[0];
+                const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
+                if (!imgStr.test(ext)) {
+                    toastr.error('请上传正确的图片格式文件');
+                    return
+                }
+                const filesize = file.size;
+                if (filesize > 1 * 1024 * 1024) {
+                    toastr.error('存在上传文件大小过大!');
+                    return false;
+                }
+                formData.append('file[]', file);
             }
+            postDataWithFile('/profile/stamp/upload', formData, function (result) {
+                let html = '';
+                for (const [index, sp] of result.stamp_path.entries()) {
+                    html += '<div class="position-absolute fixed-top stamp-show" style="left:'+ (80 + index*225) + 'px;top: 280px;width: 100px">\n' +
+                        '                                    <div class="position-relative">\n' +
+                        '                                        <a href="javascript:void(0);" title="移除签章" class="position-absolute delete-stamp" style="right: 0;top: 0;color: red;font-size:20px;font-weight: bold;text-decoration:none;">×</a>\n' +
+                        '                                        <img src="'+ fujianOssPath + sp +'" width="90">\n' +
+                        '                                    </div>\n' +
+                        '                                </div>';
+                }
+                $('#show-stamp').html(html);
+                $('#stamp-upload').val('');
+            });
         })
     } catch (error) {
         console.log(error);

+ 1 - 0
app/router.js

@@ -574,6 +574,7 @@ module.exports = app => {
     // app.get('/profile/netcasign/upload', sessionAuth, 'profileController.netcasignload');
     app.post('/profile/sign/delete', sessionAuth, 'profileController.signDelete');
     app.post('/profile/sign/upload', sessionAuth, 'profileController.signUpload');
+    app.post('/profile/stamp/upload', sessionAuth, 'profileController.stampUpload');
     app.get('/profile/safe', sessionAuth, 'profileController.safe');
     app.post('/profile/save', sessionAuth, 'profileController.saveBase');
     app.post('/profile/password', sessionAuth, 'profileController.modifyPassword');

+ 26 - 18
app/view/profile/sign.ejs

@@ -40,30 +40,38 @@
                             </div>
                             <button type="button" class="btn btn-danger btn-sm" id="delete-sign">移除签名</button>
                             <div class="form-group">
-                                <label for="stamp">上传签章</label>
-                                <input type="file" class="form-control-file" id="stamp-upload">
+                                <label for="stamp">上传签章(最多上传5个)</label>
+                                <input type="file" class="form-control-file" multiple id="stamp-upload">
                                 <small class="form-text text-danger">图片大小为600x300,格式PNG透明背景。</small>
+                                <small class="form-text text-danger">点击预览签章图片上删除按钮,即可移除签章</small>
                             </div>
-                            <button type="button" class="btn btn-sm btn-danger" id="delete-stamp">移除签章</button>
-                            <div class="form-group">
-                                <label>签名图预览</label>
-                                <div>
+                            <!--<button type="button" class="btn btn-sm btn-danger" id="delete-stamp">移除签章</button>-->
+                        </form>
+                    </div>
+                    <div class="w-100">
+                        <label>签名图预览</label>
+                        <div>
+                            <div class="position-relative">
+                                <img src="/public/images/baobiao3.png">
+                                <div class="position-absolute fixed-top" id="sign-show" style="left:290px;top:320px">
+                                    <% if (accountData.sign_path !== '') { %>
+                                        <img src="/public/upload/sign/<%= accountData.sign_path %>" width="90">
+                                    <% } %>
+                                </div>
+                                <div id="show-stamp">
+                                <% if (accountData.stamp_path) { %>
+                                <% for (const [index,sp] of accountData.stamp_path.split('!;!').entries()) { %>
+                                <div class="position-absolute fixed-top stamp-show" style="left:<%- (80 + index*225) %>px;top: 280px;width: 100px">
                                     <div class="position-relative">
-                                        <img src="/public/images/baobiao3.png">
-                                        <div class="position-absolute fixed-top" id="sign-show" style="left:290px;top:320px">
-                                            <% if (accountData.sign_path !== '') { %>
-                                                <img src="/public/upload/sign/<%= accountData.sign_path %>" width="90">
-                                            <% } %>
-                                        </div>
-                                        <div class="position-absolute fixed-top" id="stamp-show" style="left:300px;top:260px">
-                                            <% if (accountData.stamp_path) { %>
-                                                <img src="<%- fujianOssPath + accountData.stamp_path %>" width="90">
-                                            <% } %>
-                                        </div>
+                                        <a href="javascript:void(0);" title="移除签章" class="position-absolute delete-stamp" style="right: 0;top: 0;color: red;font-size:20px;font-weight: bold;text-decoration:none;">×</a>
+                                        <img src="<%- fujianOssPath + sp %>" width="90">
                                     </div>
                                 </div>
+                                <% } %>
+                                <% } %>
+                                </div>
                             </div>
-                        </form>
+                        </div>
                     </div>
                 </div>
             </div>

+ 3 - 1
sql/update.sql

@@ -3,4 +3,6 @@ ADD COLUMN `push_count`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行推
 -- 以上于2022/11/2更新uat、prod,下次更新时,不可执行
 
 ALTER TABLE `zh_cooperation_confirm`
-ADD COLUMN `locked`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否锁定' AFTER `create_time`;
+ADD COLUMN `locked`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否锁定' AFTER `create_time`;
+
+ALTER TABLE `zh_project_account` CHANGE `stamp_path` `stamp_path` VARCHAR(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户签章oss地址';