Bladeren bron

Merge branch 'master' of http://192.168.1.12:3000/smartcost/smartconstruct

Conflicts:
	modules/pm/models/project.js
TonyKang 8 jaren geleden
bovenliggende
commit
3f70e1702e

+ 5 - 27
modules/pm/models/project.js

@@ -2,28 +2,6 @@
  * Created by Mai on 2017/1/18.
  */
 
-// 对Date的扩展,将 Date 转化为指定格式的String
-// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
-// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
-// 例子:
-// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
-// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
-Date.prototype.Format = function (fmt) {
-    var o = {
-        "M+": this.getMonth() + 1, //月份
-        "d+": this.getDate(), //日
-        "h+": this.getHours(), //小时
-        "m+": this.getMinutes(), //分
-        "s+": this.getSeconds(), //秒
-        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
-        "S": this.getMilliseconds() //毫秒
-    };
-    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
-    for (var k in o)
-        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
-    return fmt;
-};
-
 /*/
 var mongoose = require("mongoose");
 
@@ -33,14 +11,14 @@ var Schema = mongoose.Schema;
 var ProjectSchema = new Schema({
     "name": String,
     "projType": String,
-    "lastDateTime": String,
-    "createDateTime": String,
+    "lastDateTime": Date,
+    "createDateTime": Date,
     "id": Number,
     "parentId": Number,
     "nextId": Number,
     "userId": Number,
     "deleted": Boolean,
-    'deleteDateTime': String,
+    'deleteDateTime': Date,
     'deleteFullFolder': Array
 });
 var Projects = db.model("projects", ProjectSchema);
@@ -108,12 +86,12 @@ ProjectsDAO.prototype.updateUserProjects = function(userId, datas, callback){
             } else if (data.updateType === 'new') {
                 data.updateData['userId'] = userId;
                 if (data.updateData.projType === 'Tender') {
-                    data.updateData['createDateTime'] = new Date().Format("yyyy-MM-dd");
+                    data.updateData['createDateTime'] = new Date();
                 }
                 newProject = new Projects(data.updateData);
                 newProject.save(updateAll);
             } else if (data.updateType === 'delete') {
-                data.updateData['deleteDateTime'] = new Date().Format("yyyy-MM-dd");
+                data.updateData['deleteDateTime'] = new Date();
                 Projects.update({userId: userId, id: data.updateData.id}, data.updateData, updateAll);
             }
         }

+ 0 - 1
modules/pm/routes/pm_route.js

@@ -4,7 +4,6 @@
 
 var express = require('express');
 var pmRouter = express.Router();
-var htmlPath = require('path').join(__dirname,'../../','web/pm/html/');
 var pmController = require('./../controllers/pm_controller');
 
 pmRouter.get('/pm', function(req, res){

+ 21 - 0
public/dateUtil.js

@@ -0,0 +1,21 @@
+// 对Date的扩展,将 Date 转化为指定格式的String
+// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
+// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
+// 例子:
+// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
+// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
+Date.prototype.Format = function (fmt) {
+    var o = {
+        "M+": this.getMonth() + 1, //月份
+        "d+": this.getDate(), //日
+        "h+": this.getHours(), //小时
+        "m+": this.getMinutes(), //分
+        "s+": this.getSeconds(), //秒
+        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+        "S": this.getMilliseconds() //毫秒
+    };
+    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+    for (var k in o)
+        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+    return fmt;
+};

+ 13 - 0
server.js

@@ -44,6 +44,19 @@ app.use('/', users);
 var pmRouter = require('./modules/pm/routes/pm_route');
 app.use('/', pmRouter);
 
+app.get('/main',  function(req, res) {
+    if (!req.session.userAccount) {
+        res.redirect('/login');
+    }
+    else {
+        res.render('main/html/main.html',
+            {
+                userAccount: req.session.userAccount,
+                userID: req.session.userID
+            });
+    }
+});
+
 var apiRouter = express.Router();
 
 app.use('/api', apiRouter);

+ 14 - 7
web/css/main.css

@@ -26,12 +26,12 @@ body {
   width:100%;
   z-index: 999
 }
-.in-1{padding-left:0rem!important}
-.in-2{padding-left:1rem!important}
-.in-3{padding-left:1.5rem!important}
-.in-4{padding-left:2rem!important}
-.in-5{padding-left:2.5rem!important}
-.in-6{padding-left:3rem!important}
+.in-1{padding-left:0px!important}
+.in-2{padding-left:21px!important}
+.in-3{padding-left:42px!important}
+.in-4{padding-left:63px!important}
+.in-5{padding-left:84px!important}
+.in-6{padding-left:105px!important}
 .main {
     position: relative;
     background: #f7f7f9;
@@ -62,6 +62,9 @@ body {
     background: #fff;
     color: #333
 }
+.main-nav .nav-tabs{
+  border-bottom: none
+}
 .content {
     border-left: 1px solid #ccc;
     margin-left: 29px;
@@ -219,9 +222,13 @@ body {
     overflow: auto;
 }
 .poj-list span.poj-icon {
-  padding-right:10px;
+  padding-right:7px;
   color:#ccc
 }
+.poj-list a.tree-open,.poj-list a.tree-close{
+  width:15px;
+  display: inline-block;
+}
 .print-toolsbar{
   padding:5px
 }

File diff suppressed because it is too large
+ 2627 - 0
web/main/html/main.html


+ 1 - 1
web/pm/html/project-management.html

@@ -455,6 +455,7 @@
     <script src="lib/tether/tether.min.js"></script>
     <script src="lib/bootstrap/bootstrap.min.js"></script>
     <script src="lib/global.js"></script>
+    <script src="public/dateUtil.js"></script>
     <script src="web/scripts/tree_table.js"></script>
     <script src="web/pm/js/pm_ajax.js"></script>
     <script src="web/pm/js/pm_main.js" charset="UTF-8"></script>
@@ -577,5 +578,4 @@
 <script type="text/javascript">
     autoFlashHeight();
 </script>
-
 </html>

+ 51 - 0
web/pm/js/pm_main.js

@@ -1,8 +1,59 @@
 /**
  * Created by Mai on 2017/2/24.
  */
+
 var Tree = null, movetoZTree = null, copytoZTree = null;
 var ProjTreeSetting = {
+    columns: [
+        {
+            head: '',
+            data: '',
+            width: '40',
+            event: {}
+        },
+        {
+            head: '工程列表',
+            data: 'name',
+            width: '78%',
+            event: {
+                getText: function (html, node, text) {
+                    html.push((node && node.data && node.data.projType === 'Folder') ? '&nbsp;' : '');
+                    html.push('<a ');
+                    if (node && node.data && node.data.projType === 'Tender') {
+                        html.push('href="/main?project=', node.id(), '"');
+                    }
+                    html.push('>', text, '<a>');
+                },
+                getIcon: function (html, node) {
+                    if (node.data.projType === 'Folder') {
+                        html.push('<i class ="tree-icon fa fa-folder-open-o"></i>');
+                    } else {
+                        html.push('<span class="poj-icon">└</span>');
+                    }
+                }
+            }
+        },
+        {
+            head: '最近使用',
+            data: 'lastDateTime',
+            width: '10%',
+            event: {
+                getText: function (html, node, text) {
+                    html.push(text ? new Date(text).Format('yyyy-MM-dd') : '');
+                }
+            }
+        },
+        {
+            head: '创建日期',
+            data: 'createDateTime',
+            width: '10%',
+            event: {
+                getText: function (html, node, text) {
+                    html.push(text ? new Date(text).Format('yyyy-MM-dd') : '');
+                }
+            }
+        }
+    ],
     viewEvent: {
         beforeSelect: function (node) {
             if (node && node.row) {

+ 19 - 75
web/scripts/tree_table.js

@@ -14,33 +14,14 @@
  		},
  		columns: [
  		{
- 			head: '',
- 			data: '<i class="fa fa-sort" data-toggle="tooltip" data-placement="top" title="长安拖动"></i>',
- 			static: true,
- 			width: '40'
- 		},
- 		{
  			head: '工程列表',
  			data: 'name',
  			static: false,
- 			width: '78%',
-			url: '/tender',
-			urlParam: [{
-				name: 'id',
-				value: 'id'
-			}]
- 		},
- 		{
- 			head: '最近使用',
- 			data: 'lastDateTime',
- 			static: false,
- 			width: '10%'
- 		},
- 		{
- 			head: '创建日期',
- 			data: 'createDateTime',
- 			static: false,
- 			width: '10%'
+ 			width: '100%',
+            event: {
+                getText: null,
+                getIcon: null
+            }
  		}
  		],
  		dataTemp: {
@@ -445,67 +426,31 @@
  			obj.append(tbody);
  			return tbody;
  		},
-		/*_makeTreeExpandBtn: function (obj, node){
- 			var span = $('<a href="#" class="tree-open" title="收起"><i class="fa fa-minus-square-o mr-1"></i></a>'),
- 				btn = $('i', span);
- 			obj.append(span);
- 			node.expandBtn = span;
- 			btn.bind('click', {node: node}, function(e){
- 				e.data.node.expand(!e.data.proj.expand());
- 			});
- 			if (node.children.length === 0) {
- 				span.hide();
- 			} else {
- 				span.show();
- 			}
- 			return span;
- 		},*/
  		_makeTableRowCell: function (obj, node, columns, index) {
- 			var html = [], td, i;
+ 			var html = [], td, i, url;
 
  			html.push('<td ');
  			if (index === node.setting.tree.btnColumn){
  				html.push('class=', 'in-', node.depth().toString(), '>');
-                // to Do 此部分中Folder与Tender的区别应由外部控制
- 				if (node.children.length !== 0) {
- 					html.push('<a href="#" class="tree-open" title="收起"><i class="fa fa-minus-square-o mr-1"></i></a>');
- 				} else if (node.data.projType === 'Folder') {
- 					html.push('<a href="#" class="tree-open" title="收起"><i class="in-2"></i></a>');
- 				} else {
-                    if (node.parent === node.tree._root) {
-                        html.push('<span class="in-1 poj-icon">└</span>');
-                    } else {
-                        html.push('<span class="in-3 poj-icon">└</span>');
-                    }
-                }
-                if (node.data.projType === 'Folder') {
-     				html.push('<i class="tree-icon fa fa-folder-open-o"></i>');
+                if (node.children.length !== 0) {
+                    html.push('<a href="#" class="tree-open" title="收起"><i class="fa fa-minus-square-o mr-1"></i></a>');
                 } else {
-         			html.push('<i class="tree-icon"></i>');
+                    html.push('<a href="#" class="tree-open" title="收起"><i></i></a>');
                 }
  			} else {
  				html.push('>');
  			}
 
- 			if (!columns.static) {
- 				//html.push('&nbsp;', node.data[columns.data]);
-                if (node.data.projType === 'Folder') {
-    				html.push('&nbsp;');
+            if (columns.event.getIcon) {
+                columns.event.getIcon(html, node);
+            }
+
+ 			if (columns.name !== '') {
+                if (columns.event.getText) {
+                    columns.event.getText(html, node, node.data[columns.data]);
+                } else {
+                    html.push(node.data[columns.name]);
                 }
-				html.push('<a ');
-				if (columns.url) {
-					html.push('href="', columns.url);
-					if (columns.urlParam){
-						html.push('?');
-						columns.urlParam.forEach(function(item){
-							html.push(item.name, '=', node.data[item.value]);
-						})
-					}
-					html.push('"');
-				}
-				html.push('>');
-				html.push(node.data[columns.data]);
-				html.push('</a>');
  			}
  			html.push('</td>');
 
@@ -535,7 +480,6 @@
  			tr.attr('id', node.domId());
  			node.row = tr;
  			_view._makeTableRowCells(tr, node);
-            //tr.click(_event._selectProj(node));
  			tr.click(function(){
                 _event._selectProj(node);
  			});
@@ -558,7 +502,7 @@
  			});	*/
  			return tr;
  		},
-        _moveRowDomBefore(node, destination) {
+        _moveRowDomBefore: function (node, destination) {
             var moveNodesRowDomBefore = function (nodes) {
                 nodes.forEach(function (node) {
                     node.row.insertBefore(destination);