laiguoran 3 vuotta sitten
vanhempi
commit
7292e08b65

+ 8 - 8
app/public/js/material_list.js

@@ -427,7 +427,7 @@ $(document).ready(() => {
         const index = gclGatherData.indexOf(select);
         const leafXmjSheet = leafXmjSpread.getActiveSheet();
         const leafXmjSelect = SpreadJsObj.getSelectObject(leafXmjSheet);
-        const gcl = gclGatherData[index].leafXmjs;
+        const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
         // const leafXmjIndex = gcl.indexOf(leafXmjSelect);
         // const xmj = gcl[leafXmjIndex];
         // const data = {
@@ -467,10 +467,10 @@ $(document).ready(() => {
             $('#addgl').modal('hide');
         });
         // postData(window.location.pathname + '/save', {type: 'add', postData: data}, function (result) {
-            // // 添加到materialList里
-            // materialListData = result;
-            // loadMaterialData(index, leafXmjIndex);
-            // $('#addgl').modal('hide');
+        //     // 添加到materialList里
+        //     materialListData = result;
+        //     loadMaterialData(index, leafXmjIndex);
+        //     $('#addgl').modal('hide');
         // });
         $('#materialBills').find('input:disabled').prop('checked', true);
     });
@@ -576,7 +576,7 @@ $(document).ready(() => {
                 const sheet = ledgerSpread.getActiveSheet();
                 const select = SpreadJsObj.getSelectObject(sheet);
                 const index = gclGatherData.indexOf(select);
-                const gcl = gclGatherData[index].leafXmjs;
+                const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                 const datas = [];
                 for (const xmj of gcl) {
                     const data = {
@@ -674,7 +674,7 @@ $(document).ready(() => {
                     const ledgerSheet = ledgerSpread.getActiveSheet();
                     const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
                     const index = gclGatherData.indexOf(ledgerSelect);
-                    const gcl = gclGatherData[index].leafXmjs;
+                    const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                     const datas = [];
                     for (const xmj of gcl) {
                         const data = {
@@ -799,7 +799,7 @@ $(document).ready(() => {
                 const ledgerSheet = ledgerSpread.getActiveSheet();
                 const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
                 const index = gclGatherData.indexOf(ledgerSelect);
-                const gcl = gclGatherData[index].leafXmjs;
+                const gcl = gclGatherData[index].leafXmjs.filter(item => item.gather_qty !== null && item.gather_qty !== undefined);
                 const datas = [];
                 for (const xmj of gcl) {
                     const data2 = {

+ 6 - 2
app/public/js/setting.js

@@ -452,7 +452,7 @@ function checkUserForm(status) {
             if ($('#add-user input[name="name"]').val() == '') {
                 throw '姓名不能为空';
             }
-            if (_.findIndex(unitList, $('#add-user select[name="company"]').val()) === -1) {
+            if (_.findIndex(unitList, { name: $('#add-user select[name="company"]').val() }) === -1) {
                 throw '请选择单位名称';
             }
             if ($('#add-user input[name="role"]').val() == '') {
@@ -473,7 +473,7 @@ function checkUserForm(status) {
             if ($('#edit-user input[name="name"]').val() == '') {
                 throw '姓名不能为空';
             }
-            if (_.findIndex(unitList, $('#edit-user select[name="company"]').val()) === -1) {
+            if (_.findIndex(unitList, { name: $('#edit-user select[name="company"]').val() }) === -1) {
                 throw '请选择单位名称';
             }
             if ($('#edit-user input[name="role"]').val() == '') {
@@ -502,6 +502,10 @@ function checkUnitForm() {
         if ($('#add-company select[name="type"]').val() == 0) {
             throw '请选择类型';
         }
+        // 检测同名
+        if (_.findIndex(unitList, { name: $('#add-company input[name="name"]').val() }) !== -1) {
+            throw '已存在对应的单位名称';
+        }
     } catch (err) {
         toastr.error(err);
         return false;

+ 40 - 1
app/service/material_list.js

@@ -334,6 +334,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 const list = [];
+                const listGcl = [];
                 // const delList = [];
                 // const mb_idList = [];
                 for (const xmj of datas.xmjs) {
@@ -363,15 +364,30 @@ module.exports = app => {
                             is_join: xmj.is_join,
                         };
                         list.push(newLists);
+                        if (this._.findIndex(listGcl, { gcl_id: xmj.gcl_id }) === -1) {
+                            const newListGcl = {
+                                tid: this.ctx.tender.id,
+                                order: this.ctx.material.order,
+                                mid: this.ctx.material.id,
+                                mb_id: mb,
+                                gcl_id: xmj.gcl_id,
+                                quantity: 0,
+                                expr: '',
+                            };
+                            listGcl.push(newListGcl);
+                        }
                     }
                 }
+                // 维护list_gcl表
+
 
                 // 删除工料清单关联
                 // if (delList.length > 0) await transaction.delete(this.tableName, { id: delList });
                 // 新增工料清单关联
                 if (list.length > 0) {
                     const result = await transaction.insert(this.tableName, list);
-                    if (result.affectedRows === 0) {
+                    const result2 = await transaction.insert(this.ctx.service.materialListGcl.tableName, listGcl);
+                    if (result.affectedRows === 0 || result2.affectedRows === 0) {
                         throw '新增工料数据失败';
                     }
                 }
@@ -405,8 +421,13 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 判断是否可删
+                const listGcl = [];
                 for (const xmj of datas.xmjs) {
                     await transaction.delete(this.tableName, { tid: this.ctx.tender.id, mid: this.ctx.material.id, mb_id: datas.mb_id, gcl_id: xmj.gcl_id, xmj_id: xmj.xmj_id, mx_id: xmj.mx_id });
+                    if (this._.indexOf(listGcl, xmj.gcl_id) === -1) {
+                        await transaction.delete(this.service.materialListGcl.tableName, { tid: this.ctx.tender.id, mid: this.ctx.material.id, mb_id: datas.mb_id, gcl_id: xmj.gcl_id });
+                        listGcl.push(xmj.gcl_id);
+                    }
                 }
                 // await transaction.delete(this.tableName, { id });
                 await this.calcQuantityByML(transaction, datas.mb_id);
@@ -437,6 +458,8 @@ module.exports = app => {
             try {
                 const mb_id = datas.mb_id;
                 const updateDatas = [];
+                const updateListGcl = [];
+                const listGcl = [];
                 for (const xmj of datas.xmjs) {
                     const udata = {
                         row: {
@@ -453,8 +476,24 @@ module.exports = app => {
                         },
                     };
                     updateDatas.push(udata);
+                    if (this._.indexOf(listGcl, xmj.gcl_id) === -1) {
+                        listGcl.push(xmj.gcl_id);
+                        updateListGcl.push({
+                            row: {
+                                expr: datas.expr,
+                                quantity: datas.quantity,
+                            },
+                            where: {
+                                tid: this.ctx.tender.id,
+                                mid: this.ctx.material.id,
+                                mb_id,
+                                gcl_id: xmj.gcl_id,
+                            },
+                        });
+                    }
                 }
                 if (updateDatas.length > 0) await transaction.updateRows(this.tableName, updateDatas);
+                if (updateListGcl.length > 0) await transaction.updateRows(this.service.materialListGcl.tableName, updateListGcl);
                 await this.calcQuantityByML(transaction, mb_id);
                 await transaction.commit();
                 return await this.getMaterialData(this.ctx.tender.id, this.ctx.material.id);

+ 1 - 1
app/view/material/list.ejs

@@ -55,7 +55,7 @@
                             </li>
                             <li class="ml-auto">
                             <% if (!material.readOnly || material.status === auditConst.status.checked) { %>
-                            <button class="btn btn-sm btn-primary" id="user_all_material">应用调差工料至其他清单明细</button>
+                            <!--<button class="btn btn-sm btn-primary" id="user_all_material">应用调差工料至其他清单明细</button>-->
                             <% } %>
                             </li>
                         </ul>

+ 1 - 1
app/view/setting/user_modal.ejs

@@ -40,7 +40,7 @@
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
                     <!--<input class="form-control form-control-sm" name="company" value="" type="text">-->
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option>请选择</option>
                         <% for (const u of unitList) { %>

+ 1 - 1
app/view/setting/user_permission_modal.ejs

@@ -39,7 +39,7 @@
                 </div>
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option>请选择</option>
                         <% for (const u of unitList) { %>

+ 1 - 1
app/view/setting/user_unit_modal.ejs

@@ -39,7 +39,7 @@
                 </div>
                 <div class="form-group">
                     <label>单位名称<b class="text-danger">*</b></label>
-                    <input value="" name="account_group" type="hidden">
+                    <input value="7" name="account_group" type="hidden">
                     <select class="form-control form-control-sm" name="company">
                         <option value="0">请选择</option>
                         <% for (const u of unitList) { %>