浏览代码

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

Tony Kang 2 年之前
父节点
当前提交
059b9cc709

+ 2 - 2
app/const/construction.js

@@ -20,12 +20,12 @@ const logJson = {
 };
 const status = {
     uncheck: 1, // 待提交
-    checking: 2, // 审签
+    checking: 2, // 审签
     checked: 3, // 已审签
 };
 const statusString = [];
 statusString[status.uncheck] = '待提交';
-statusString[status.checking] = '审签';
+statusString[status.checking] = '审签';
 statusString[status.checked] = '已审签';
 
 const statusClass = [];

+ 6 - 0
app/controller/construction_controller.js

@@ -345,6 +345,12 @@ module.exports = app => {
                         if (!logInfo.shenpi_uid) throw '请选择审签人再提交';
                         responseData.data = await ctx.service.constructionLog.start(logInfo.id);
                         break;
+                    case 'checkNo':
+                        if (logInfo.report_uid !== ctx.session.sessionUser.accountId) {
+                            throw '非当前填报人无法提交日志';
+                        }
+                        responseData.data = await ctx.service.constructionLog.checkNo(logInfo.id);
+                        break;
                     default: throw '参数有误';
                 }
                 ctx.body = responseData;

+ 4 - 4
app/public/js/construction_index.js

@@ -25,12 +25,12 @@ const tenderListSpec = (function(){
         html.push('</td>');
 
         // 创建时间
-        html.push('<td style="width:150px" class="text-center">');
+        html.push('<td style="width:300px" class="text-center">');
         html.push(node.create_time ? moment(node.create_time).format('YYYY-MM-DD HH:mm:ss') : '');
         html.push('</td>');
         // 设置
         if (is_admin) {
-            html.push('<td style="width: 100px" class="text-center">');
+            html.push('<td style="width: 200px" class="text-center">');
             if (!node.cid) {
                 html.push('<a href="#add-cy" data-toggle="modal" data-target="#add-cy" data-tid="' + node.id +
                     '" class="btn btn-outline-primary btn-sm get-audits">成员管理</a>');
@@ -45,9 +45,9 @@ const tenderListSpec = (function(){
         html.push('<table class="table table-hover table-bordered">');
         html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
         html.push('<th class="text-center" style="min-width: 300px;">', '标段名称', '</th>');
-        html.push('<th class="text-center" style="width: 150px;">', '创建时间', '</th>');
+        html.push('<th class="text-center" style="width: 300px;">', '创建时间', '</th>');
         if (is_admin) {
-            html.push('<th class="text-center" style="width: 100px">', '设置', '</th>');
+            html.push('<th class="text-center" style="width: 200px">', '设置', '</th>');
         }
         html.push('</tr>', '</thead>');
         return html.join('');

+ 18 - 13
app/public/js/construction_info.js

@@ -110,9 +110,9 @@ $(function () {
         });
     });
 
-    $('#start-btn').click(function () {
+    $('body').on('click', '#start-btn', function () {
         // 判断是否已选择审签人,有则提交
-        const username = $('#show-shenpi span').text();
+        const username = $('#show-shenpi span').text() || $('#show-shenpi-input').val();
         if (username == '') {
             toastr.error('请选择审签人再提交');
             return false;
@@ -123,18 +123,23 @@ $(function () {
     });
 
     $('#edit-start').click(function () {
-       $('#edit-end').show();
-       $('#edit-start').hide();
-       $('.edit-input').removeAttr('readonly');
-       $('.edit-textarea').removeAttr('readonly');
+        // $('#edit-end').show();
+        $('#edit-start').hide();
+        $('.edit-input').removeAttr('readonly');
+        $('.edit-textarea').removeAttr('readonly');
+        $(this).siblings('span').hide();
+        $(this).parents('.title-main').append('<a href="javascript:void(0);" id="start-btn" class="btn btn-sm btn-primary pull-right mr-2">提交审签</a>');
+        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'checkNo' }, function (result) {
+            // window.location.reload();
+        });
     });
 
-    $('#edit-end').click(function () {
-        $('#edit-start').show();
-        $('#edit-end').hide();
-        $('.edit-input').attr('readonly', true);
-        $('.edit-textarea').attr('readonly', true);
-    });
+    // $('#edit-end').click(function () {
+    //     $('#edit-start').show();
+    //     $('#edit-end').hide();
+    //     $('.edit-input').attr('readonly', true);
+    //     $('.edit-textarea').attr('readonly', true);
+    // });
 
     $('#check-btn').click(function () {
         postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'checked' }, function (result) {
@@ -205,7 +210,7 @@ $(function () {
     function getAllList() {
         let html = '';
         for(const [index,att] of attData.entries()) {
-            html += `<tr>
+            html += `<tr class="text-center">
         <td width="5%">${index+1}</td>
         <td class="text-left"><a href="${att.filepath}" target="_blank">${att.filename}${att.fileext}</a></td>
         <td width="15%">${moment(att.upload_time).format("YYYY-MM-DD HH:mm:ss")}</td>

+ 38 - 4
app/public/js/construction_list.js

@@ -34,7 +34,7 @@ $(function () {
         const codeDate = $('#code-date').datepicker({
             onSelect: function (formattedDate, date, inst) {
                 const showDate = date ? moment(date[date.length - 1]).format('YYYYMMDD') : '';
-                const showCode = showDate ? showDate + getCodeByDate(showDate) : '';
+                const showCode = showDate ? showDate + getCodeByDate(showDate, getDatesFromStringAndConvert(formattedDate)) : '';
                 if (!showCode) {
                     $('#existMsg').hide();
                 }
@@ -42,7 +42,7 @@ $(function () {
             }
         }).data('datepicker');
         codeDate.selectDate(new Date());
-        $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD')));
+        $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD'), getDatesFromStringAndConvert(moment().format('YYYY-MM-DD'))));
 
         $('#add-log input[name="log-type"]').on('click', function () {
             const type = parseInt($(this).val());
@@ -55,7 +55,7 @@ $(function () {
                 codeDate.clear();
                 $('#code-date').val(moment().format('YYYY-MM-DD'));
                 codeDate.selectDate(new Date());
-                $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD')));
+                $('#show-code').val(moment().format('YYYYMMDD') + getCodeByDate(moment().format('YYYYMMDD'), getDatesFromStringAndConvert(moment().format('YYYY-MM-DD'))));
             }
         });
 
@@ -108,12 +108,14 @@ $(function () {
             })
         });
 
-        function getCodeByDate(date) {
+        function getCodeByDate(date, dates) {
             let num = '001';
             if (date) {
                 const dateInfo = _.find(dateCodeList, { date_code: date });
                 if (dateInfo) {
                     num = convertToThreeDigits(dateInfo.num + 1);
+                }
+                if (_.intersection(_.map(dateCodeList, 'date_code'), dates).length !== 0) {
                     $('#existMsg').show();
                 } else {
                     $('#existMsg').hide();
@@ -124,6 +126,38 @@ $(function () {
             return num;
         }
 
+        function getDatesFromStringAndConvert(dateString) {
+            const dates = [];
+            const dateParts = dateString.split(' ~ ');
+
+            dateParts.forEach(datePart => {
+                const date = new Date(datePart);
+                if (!isNaN(date.getTime())) {
+                    dates.push(date);
+                } else {
+                    console.error('Invalid date format in the input string:', datePart);
+                }
+            });
+
+            if (dates.length === 1) {
+                return [dates[0].toISOString().slice(0, 10).replace(/-/g, '')];
+            }
+
+            const startDate = dates[0];
+            const endDate = dates[1];
+            const currentDate = new Date(startDate);
+            const endDatePlusOneDay = new Date(endDate);
+            endDatePlusOneDay.setDate(endDatePlusOneDay.getDate() + 1);
+
+            while (currentDate < endDatePlusOneDay) {
+                const formattedDate = currentDate.toISOString().slice(0, 10).replace(/-/g, '');
+                dates.push(formattedDate);
+                currentDate.setDate(currentDate.getDate() + 1);
+            }
+
+            return dates.slice(2);
+        }
+
         function convertToThreeDigits(number) {
             // 将数字转换为字符串
             let numStr = String(number);

+ 4 - 0
app/service/construction_log.js

@@ -143,6 +143,10 @@ module.exports = app => {
             return await this.db.update(this.tableName, { id, status: constructionConst.status.checked, checked_time: new Date() });
         }
 
+        async checkNo(id) {
+            return await this.db.update(this.tableName, { id, status: constructionConst.status.uncheck });
+        }
+
         async deleteLog(id) {
             const transaction = await this.db.beginTransaction();
             try {

+ 6 - 8
app/view/construction/info.ejs

@@ -5,19 +5,17 @@
                 <a href="/construction/<%- ctx.constructionTender.id %>/list" class="mr-2"><i class="fa fa-chevron-left mr-2"></i>
                     <span>返回</span></a><%- (ctx.constructionTender.name.length > 20 ? ctx.constructionTender.name.substring(0,20) + '...' : ctx.constructionTender.name) %> / <%- logInfo.code %></div>
             <div>
-                <span class="pull-right <%- constructionConst.statusClass[logInfo.status] %>"><%- constructionConst.statusString[logInfo.status] %></span>
                 <% if (ctx.session.sessionUser.accountId === logInfo.shenpi_uid && logInfo.status === constructionConst.status.checking) { %>
-                <span class=" pull-right mr-2">|</span>
                 <a href="javascript:void(0);" id="check-btn" class="btn btn-sm btn-success pull-right mr-2">确认审签</a>
-                <% } %>
-                <% if (ctx.session.sessionUser.accountId === logInfo.report_uid && logInfo.status === constructionConst.status.uncheck) { %>
-                <span class=" pull-right mr-2">|</span>
+                <% } else if (ctx.session.sessionUser.accountId === logInfo.report_uid && logInfo.status === constructionConst.status.uncheck) { %>
                 <a href="javascript:void(0);" id="start-btn" class="btn btn-sm btn-primary pull-right mr-2">提交审签</a>
+                <% } else { %>
+                <span class="pull-right <%- constructionConst.statusClass[logInfo.status] %>"><%- constructionConst.statusString[logInfo.status] %></span>
                 <% } %>
                 <!-- 提交审签后,可再次编辑,提供取消按钮 -->
                 <% if (logInfo.report_uid === ctx.session.sessionUser.accountId && logInfo.status === constructionConst.status.checking) { %>
                 <span class=" pull-right mr-2">|</span>
-                <a href="javascript:void(0);" id="edit-end" class="btn btn-sm btn-secondary pull-right mr-2" style="display: none">取消</a>
+                <!--<a href="javascript:void(0);" id="edit-end" class="btn btn-sm btn-secondary pull-right mr-2" style="display: none">取消</a>-->
                 <a href="javascript:void(0);" id="edit-start" data-target="#" class="btn btn-sm btn-outline-primary pull-right mr-2">编辑</a>
                 <% } %>
             </div>
@@ -60,7 +58,7 @@
                                 </div>
                                 <div class="col-6 form-group row mb-2">
                                     <label class="col-form-label col-2  text-right px-0">审签人:</label>
-                                    <% if (logInfo.status === constructionConst.status.uncheck && logInfo.report_uid === ctx.session.sessionUser.accountId) { %>
+                                    <% if (logInfo.status === constructionConst.status.uncheck && logInfo.report_uid === ctx.session.sessionUser.accountId && logInfo.start_time === null) { %>
                                         <div class="dropdown text-right align-middle pt-1" id="show-shenpi-btn" <% if (logInfo.shenpi_uid) { %>style="display: none" <% } %>>
                                             <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                 选择审批人
@@ -91,7 +89,7 @@
                                             <label class="col-form-label"><span><%- logInfo.shenpi_username %></span><i class="fa fa-remove text-danger px-1 remove-shenpi-btn" style="cursor: pointer"></i></label>
                                         </div>
                                     <% } else { %>
-                                    <input type="text" class="form-control form-control-sm col" value="<%- logInfo.shenpi_username %>" readonly>
+                                    <input type="text" id="show-shenpi-input" class="form-control form-control-sm col" value="<%- logInfo.shenpi_username %>" readonly>
                                     <% } %>
                                 </div>
                             </div>

+ 1 - 1
app/view/construction/list_modal.ejs

@@ -30,7 +30,7 @@
                     <label>日志编号</label>
                     <input class="form-control form-control-sm" id="show-code" placeholder="" type="text" value="" readonly>
                     <div class="text-warning m-1" id="existMsg" style="display: none">
-                        日已存在日志文件,请注意核查哦。
+                        日期/周期内已存在日志文件,请注意核查哦。
                     </div>
                 </div>
             </div>