浏览代码

Merge branch 'master' of http://smartcost.f3322.net:3000/MaiXinRong/IndexSystem

MaiXinRong 7 年之前
父节点
当前提交
74726a848c
共有 4 个文件被更改,包括 56 次插入36 次删除
  1. 8 0
      app/controller/lib_controller.js
  2. 28 28
      app/public/js/global.js
  3. 14 2
      app/service/quotaLib.js
  4. 6 6
      config/menu.js

+ 8 - 0
app/controller/lib_controller.js

@@ -215,12 +215,20 @@ module.exports = app => {
                 if(text === undefined || text !== '确认删除'){
                     throw '参数错误';
                 }
+                //获取指标源数据
+                const libInfo = await ctx.service.quotaLib.getLibDataById(id);
+                if(!libInfo){
+                    throw '不存在该标段';
+                }
+                //删清指标源和清单数据
                 const result = ctx.service.quotaLib.deleteLibById(id);
 
                 if (!result) {
                     throw '删除标段失败';
                 }
 
+                fs.unlinkSync(libInfo.filepath);
+
                 ctx.redirect('/lib');
             } catch (error) {
                 console.log(error);

+ 28 - 28
app/public/js/global.js

@@ -1,19 +1,18 @@
 /*全局自适应高度*/
 function autoFlashHeight(){
     var cHeader = $(".c-header").height();
-    var sBar = $(".sjs-bar").height();
     $(".sjs-height-1").height($(window).height()-cHeader-160);
     $(".sjs-height-2").height($(window).height()-cHeader-191);
-    $(".sjs-height-3").height($(window).height()-cHeader-sBar-560);
+    $(".sjs-height-3").height($(window).height()-cHeader-520);
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/
 $(function(){
-/*侧滑*/
-$(".open-sidebar").click(function(){
-    $(".slide-sidebar").animate({width:"800"}).addClass("open");
-});
-$("body").click(function(event){
+    /*侧滑*/
+    $(".open-sidebar").click(function(){
+        $(".slide-sidebar").animate({width:"800"}).addClass("open");
+    });
+    $("body").click(function(event){
         var e = event || window.event; //浏览器兼容性
         if(!$(event.target).is('a')) {
             var elem = event.target || e.srcElement;
@@ -27,27 +26,28 @@ $("body").click(function(event){
         }
 
     });
-/*侧滑*/
-/*工具提示*/
-$(function () {
-  $('[data-toggle="tooltip"]').tooltip()
-});
-/*侧栏菜单*/
-$(".bg-nav > li > a").click(function() {
-      var self = $(this);
-      var subMenu = $(this).siblings('ul.sub-menu');
-      if(subMenu.length > 0) {
-          if(subMenu.is(":visible")) {
-              self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
-              subMenu.slideUp('fast');
-              self.parent().removeClass('active');
-          }else{
-              self.parent().addClass('active');
-              self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
-              subMenu.slideDown('fast');
-          }
-      }
-  });
+    /*侧滑*/
+    /*工具提示*/
+    $(function () {
+        $('[data-toggle="tooltip"]').tooltip();
+        $('[data-toggle="popover"]').popover()
+    });
+    /*侧栏菜单*/
+    $(".bg-nav > li > a").click(function() {
+        var self = $(this);
+        var subMenu = $(this).siblings('ul.sub-menu');
+        if(subMenu.length > 0) {
+            if(subMenu.is(":visible")) {
+                self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
+                subMenu.slideUp('fast');
+                self.parent().removeClass('active');
+            }else{
+                self.parent().addClass('active');
+                self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
+                subMenu.slideDown('fast');
+            }
+        }
+    });
 });
 
 /**

+ 14 - 2
app/service/quotaLib.js

@@ -94,7 +94,19 @@ module.exports = app => {
          * @return {Boolean} - 删除结果
          */
         async deleteLibById(id) {
-            return await this.deleteById(id);
+            const conn = await this.db.beginTransaction(); // 初始化事务
+            try{
+                const libResult = await conn.deleteById(id);
+                const billsResult = await conn.delete('is_quota_bills',{lib_id: id});
+                await conn.commit(); // 提交事务
+                return true;
+            } catch(err) {
+                console.log(err);
+                await conn.rollback();
+                throw err;
+                return false;
+            }
+
         }
 
         /**
@@ -138,7 +150,7 @@ module.exports = app => {
                     RoadLength: jsonData.properties.RoadLength,
                     RoadWidth: jsonData.properties.RoadWidth,
                 };
-                // postData.push(updateData);
+
                 const libResult = await conn.insert(this.tableName, insertData);
                 const lib_id = libResult.insertId;
                 const billsData = jsonData.bills;

+ 6 - 6
config/menu.js

@@ -9,18 +9,18 @@
  */
 
 const menu = {
-    lib: {
-        name: '指标库',
-        icon: 'fa-list-ul',
-        display: true,
-        url: '/lib',
-    },
     template: {
         name: '指标模板',
         icon: 'fa-file-text-o',
         display: true,
         url: '/template',
     },
+    lib: {
+        name: '指标库',
+        icon: 'fa-list-ul',
+        display: true,
+        url: '/lib',
+    },
     compare: {
         name: '指标对比',
         icon: 'fa-search',