zhongzewei 7 лет назад
Родитель
Сommit
9d9ed66020

+ 31 - 0
modules/all_models/compleRation_section.js

@@ -0,0 +1,31 @@
+/**
+ * Created by Zhong on 2018/3/22.
+ */
+/*补充定额库-章节树*/
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+const deleteSchema = require('../all_schemas/delete_schema');
+//补充定额章节树
+const compleRationSectionTreeSchema = new Schema({
+    //用户名
+    userId: String,
+    //编办
+    compilationId: String,
+    //标准定额库
+    //rationRepId: Number,
+    //名称
+    name: String,
+    //是否是同层第一个节点
+   // isFirst: Boolean,
+    ID: String,
+    NextSiblingID: String,
+    ParentID: String,
+    deleteInfo: deleteSchema,
+    //以下预留数据,以后开放可用
+    explanation: String,//说明
+    ruleText: String,//计算规则,
+    jobContentSituation: String,//工作内容适用情况,ALL适用本项全部定额,PARTIAL适用本项部分定额
+    annotationSituation: String,//附注适用情况,ALL适用本项全部定额,PARTIAL适用本项部分定额
+}, {versionKey: false});
+
+mongoose.model('complementary_ration_section_tree', compleRationSectionTreeSchema, 'complementary_ration_section_tree');

+ 12 - 0
modules/sys_tools/controllers/sys_controller.js

@@ -26,6 +26,18 @@ class SysTools extends BaseController{
             callback(req, res, errCode, msg, null);
         });
     }
+
+    clearFakeData(req, res){
+        sysSchedule.clearFakeData(function (err) {
+            let msg = '清除成功';
+            let errCode = 0;
+            if(err){
+                msg = '清除失败';
+                errCode = 1;
+            }
+            callback(req, res, errCode, msg, null);
+        });
+    }
 }
 
 export {SysTools as default};

+ 29 - 1
modules/sys_tools/models/sys_model.js

@@ -29,6 +29,7 @@ const unitPriceModel = mongoose.model('unit_price');
 const mixRatioModel = mongoose.model('mix_ratio');
 const feeRateFileModel = mongoose.model('fee_rate_file');
 const feeRateModel = mongoose.model('fee_rates');
+const compleRationSection = mongoose.model('complementary_ration_section_tree');
 
 //删除垃圾数据
 async function clearJunkData(callback){
@@ -136,8 +137,35 @@ async function clearJunkData(callback){
 
 }
 
+//删除假删除数据
+/*
+* 1.之前的删除造价书数据,都是做的假删除,这部分数据会一直存在并且随着项目重复使用越来越多,现要改为真删除,所以做这个清除功能。
+* 2.原假删除包括清单的所有类型(大项费用、分部、分项、补项、清单)、定额的所有类型(定额、数量单价、与定额同级的人材机)
+* */
+async function clearFakeData(callback) {
+    let functions = [];
+    //删除清单
+    functions.push(function (cb) {
+        billsModel.remove({deleteInfo: {$exists: true}}, cb);
+    });
+    //删除定额
+    functions.push(function (cb) {
+        rationModel.remove({deleteInfo: {$exists: true}}, cb);
+    });
+    //删除补充定额章节树
+    functions.push(function (cb) {
+        compleRationSection.remove({deleteInfo: {$exists: true}}, cb);
+    });
+    async.parallel(functions, async function(err, result){
+        if(callback){
+            callback(err);
+        }
+    });
+}
+
 const sysSchedule = {
-    clearJunkData: clearJunkData
+    clearJunkData,
+    clearFakeData
 };
 
 //export {sysSchedule as default}

+ 1 - 0
modules/sys_tools/routes/routes.js

@@ -15,6 +15,7 @@ let sysToolsController = new SysToolsController();
 
 module.exports = function (app) {
     router.post('/clearJunkData', sysToolsController.auth, sysToolsController.init, sysToolsController.clearJunkData);
+    router.post('/clearFakeData', sysToolsController.auth, sysToolsController.init, sysToolsController.clearFakeData);
 
     app.use("/sysTools/api", router);
 

+ 11 - 0
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -1387,6 +1387,17 @@ const billsGuidance = (function () {
                                     let pasteNode = bills.tree.selected.guidance.tree.items[target.row];
                                     pasteBlock(pasteNode);
                                 }},
+                            "del": {
+                                name: '删除',
+                                disabled: function () {
+                                    let node = bills.tree.selected.guidance.tree.items[target.row];
+                                    return !node
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    $('#delAlert').modal('show');
+                                }
+                            },
                             "insertSibling": {
                                 name: '插入行',
                                 disabled: function () {

+ 42 - 0
web/users/views/tool/index.html

@@ -50,6 +50,13 @@
             </div>
             <div class="col-xs-6 mb-30 ">
                 <div class="c-body">
+                    <h2>清除项目假删除数据
+                        <a id="clearFakeBtn" href="javascript:void(0);" class="btn btn-primary pull-right">清除</a>
+                    </h2>
+                </div>
+            </div>
+            <div class="col-xs-6 mb-30 ">
+                <div class="c-body">
                     <h2>清单模板编辑器
                         <a id="billTemplate" href="/billsTemplate/main" target="_blank" class="btn btn-primary pull-right">进入</a>
                     </h2>
@@ -117,6 +124,30 @@
         </div>
     </div>
 </div>
+<!--弹出 是否清除假删除数据-->
+<div class="modal fade" id="clearFakeModal" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">删除确认</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <div>
+                        <label>确认要清除数据库中项目假删除数据吗?(清单、定额)</label>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer" style="justify-content: center">
+                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="clearFakeY" >是</button>
+                <button type="button" class="btn btn-primary"  data-dismiss="modal">否</button>
+            </div>
+        </div>
+    </div>
+</div>
 
 <script type="text/javascript" src="/public/web/common_ajax.js"></script>
 <script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
@@ -165,6 +196,9 @@
         $('#clearJunkBtn').click(function () {
             $('#clearJunkModal').modal('show');
         });
+        $('#clearFakeBtn').click(function () {
+            $('#clearFakeModal').modal('show');
+        });
         $('#clearJunkY').click(function () {
             $.bootstrapLoading.start();
              CommonAjax.post('/sysTools/api/clearJunkData', '', function (rstData) {
@@ -173,5 +207,13 @@
              $.bootstrapLoading.end();
              })
         });
+        $('#clearFakeY').click(function () {
+            $.bootstrapLoading.start();
+             CommonAjax.post('/sysTools/api/clearFakeData', '', function (rstData) {
+             $.bootstrapLoading.end();
+             }, function () {
+             $.bootstrapLoading.end();
+             })
+        });
     });
 </script>