{
	"client": "pc",
	"framework": "tfp",
	"positionType": "float",
	"pageType": "dialog",
	"bgColorMode": "light",
	"title": "路径",
	"type": "Page",
	"components": [
		{
			"id": "divFooter",
			"type": "Panel",
			"styles": {
				"left": "0",
				"height": "50px",
				"right": "0",
				"bottom": "0",
				"position": "absolute",
				"overflow": "auto"
			},
			"components": [
				{
					"id": "button_submit",
					"type": "Button",
					"buttonType": "primary",
					"value": "确定",
					"theme": "round",
					"styles": {
						"float": "right",
						"cursor": "pointer",
						"text-align": "center"
					},
					"onClick": "button_submit_onClick()"
				},
				{
					"type": "Button",
					"buttonType": "default",
					"value": "取消",
					"theme": "round",
					"onClick": "tfp.closeCurDialog()",
					"styles": {
						"float": "right",
						"cursor": "pointer",
						"text-align": "center",
						"margin-left": "10px"
					},
					"id": "button_close"
				},
				{
					"type": "Label",
					"id": "labelMsg",
					"value": "",
					"styles": {
						"height": "30px",
						"line-height": "30px",
						"position": "absolute",
						"z-index": 1,
						"top": "10px",
						"left": "13px",
						"color": "#FF0000"
					}
				}
			],
			"style": "display:flex; justify-content:center; align-items:center;"
		},
		{
			"type": "Text",
			"id": "iptPath",
			"dataType": "text",
			"styles": {
				"height": "30px",
				"line-height": "30px",
				"padding-left": "2px",
				"padding-right": "2px",
				"position": "absolute",
				"z-index": 1,
				"top": "10px",
				"left": "10px",
				"right": "10px",
				"width": "480px"
			},
			"placeHolder": "请输入服务路径"
		},
		{
			"type": "Panel",
			"id": "divContent",
			"styles": {
				"font-size": "0",
				"position": "absolute",
				"z-index": 1,
				"top": "50px",
				"left": "10px",
				"right": "10px",
				"bottom": "50px",
				"border": "1px solid #CCCCCC"
			},
			"components": [],
			"style": "overflow-y: scroll;"
		},
		{
			"type": "Service",
			"id": "serviceGet",
			"autoShowError": true,
			"path": "dev/service/proj/getFileList",
			"argSettings": []
		},
		{
			"type": "Service",
			"id": "serviceProj",
			"autoShowError": true,
			"path": "dev/service/proj/getList"
		}
	],
	"width": "502px",
	"height": "503px",
	"id": "page1",
	"cssFiles": [
		"/node_modules/tfp/src/components/pathpicker/PathPicker.css"
	],
	"jsFuncs": [
		{
			"name": "page1_onLoad",
			"comment": "页面加载时",
			"editType": "code",
			"args": [],
			"code": "      dialogArgs = JSON.parse(tfp.getDialogArgs());\n      if(dialogArgs.onlyDir) onlyDir = true;\n      if(dialogArgs.path) $(\"#iptPath\").val(dialogArgs.path);\n      if(!dialogArgs.filename) dialogArgs.filename = \"\";\n      $(\"#iptPath\").focus();\n\n      let listServerFile = false, listClientFile = false;\n      if(dialogArgs.listServerFile) listServerFile = true;\n      if(dialogArgs.listClientFile) listClientFile = true;\n      if(dialogArgs.fileTypes) {\n        for(var i=0;i<dialogArgs.fileTypes.length;i++) {\n          let fileType = dialogArgs.fileTypes[i];\n          if(fileType==\"html\" || fileType==\"tfp\" || fileType==\"js\" || fileType==\"css\") {\n            listClientFile = true;\n            exts.push(\".\"+fileType);\n          } else if(fileType==\"image\" || fileType==\"photo\") {\n            listClientFile = true;\n            exts.push(\".jpg\");\n            exts.push(\".png\");\n            exts.push(\".gif\");\n          } else if(fileType==\"service\") {\n            listServerFile = true;\n            exts.push(\".js\");\n            exts.push(\".tbs\");\n          } else if(fileType==\"model\") {\n            listServerFile = true;\n            exts.push(\".json\");\n            exts.push(\".tdm\");\n          }\n        }\n      }\n\n      if(listServerFile) addNode(\"dir\", $(\"#divContent\"), \"后台文件\", \"app\", 5, true);\n      if(listClientFile) addNode(\"dir\", $(\"#divContent\"), \"前端文件\", \"web/app\", 5, true);\n      \n        serviceProj.request(null, function(req, res) {\n          if(res.code!=0) {\n            let errMsg = res.message;\n            if(errMsg.indexOf(\"ECONNREFUSED\")>=0) errMsg = \"连接服务器失败！\";\n            $(\"#labelMsg\").text(errMsg);\n            return;\n          }\n\n          for(var i=0;i<res.ret.length;i++) {\n            if(listServerFile) addNode(\"dir\", $(\".node-items[node-path='app']\"), \n              res.ret[i], \"app/\"+res.ret[i], 10);\n            if(listClientFile) addNode(\"dir\", $(\".node-items[node-path='web/app']\"), \n              res.ret[i], \"web/app/\"+res.ret[i], 10);\n          }\n        })\n"
		},
		{
			"name": "addNode",
			"comment": "",
			"editType": "code",
			"args": [
				{
					"name": "type",
					"type": "string",
					"required": false
				},
				{
					"name": "parent",
					"type": "string",
					"required": false
				},
				{
					"name": "nodeName",
					"type": "string",
					"required": false
				},
				{
					"name": "nodePath",
					"type": "string",
					"required": false
				},
				{
					"name": "prefix",
					"type": "string",
					"required": false
				},
				{
					"name": "haveLoad",
					"type": "string",
					"required": false
				}
			],
			"code": "      var nodeHtml = \"\";\n      var _haveLoad = false;\n      if(haveLoad) _haveLoad = true;\n      if(type==\"dir\") {\n        nodeHtml = \"<div class='node' node-type='dir' \"\n          +\"node-prefix='\"+prefix+\"' node-path='\"+nodePath+\"' have-load-data='\"+_haveLoad+\"'>\";\n        nodeHtml += \"<img src='../tree/images/\"+(_haveLoad ? \"toggle\" : \"expand\" )\n          +\"-dark.png' style='margin-left:\"+prefix+\"px;' />\";\n        nodeHtml += \"<label>\"+nodeName+\"</label>\";\n        nodeHtml += \"</div>\";\n        nodeHtml += \"<div class='node-items' node-path='\"+nodePath+\"' \"\n          + (_haveLoad ? \" style='display:block;'\" : \"\") +\">\";\n        nodeHtml += \"</div>\";\n      } else {\n        nodeHtml = \"<div class='node' node-type='file' node-path='\"+nodePath+\"'>\";\n        nodeHtml += \"<label style='margin-left:\"+prefix+\"px;'> · \"+nodeName+\"</label>\";\n        nodeHtml += \"</div>\";\n      }\n      parent.append(nodeHtml);\n\n      let newNode = parent.find(\".node\").last();\n\n      newNode.click(function() {\n        if($(this).attr(\"node-type\")==\"file\") {\n          let filePath = \"/\"+$(this).attr(\"node-path\");\n          //if(filePath.startsWith(\"web/\")) filePath = filePath.substr(3);\n          $(\"#iptPath\").val(filePath);\n          $(\".node\").css(\"background-color\", \"\");\n          $(this).css(\"background-color\", \"#dddddd\");\n          return;\n        }\n        let nodePath = $(this).attr(\"node-path\");\n        if(onlyDir && nodePath!=\"app\" && nodePath!=\"web/app\") {\n          let filePath = \"/\";\n          if(dialogArgs.filename==\"\") {\n            filePath += nodePath;\n          } else {\n            filePath += nodePath+\"/\"+dialogArgs.filename;\n          }\n          $(\"#iptPath\").val(filePath);\n          $(\".node\").css(\"background-color\", \"\");\n          $(this).css(\"background-color\", \"#dddddd\");\n        }\n        if($(this).find(\"img\").attr(\"src\")==\"../tree/images/expand-dark.png\") {\n          $(this).find(\"img\").attr(\"src\", \"../tree/images/toggle-dark.png\");\n          if($(this).attr(\"have-load-data\")==\"false\") {\n            let curNode = $(this);\n            var prefix = parseInt($(this).attr(\"node-prefix\"))+10;\n            let args = {\n              dir: nodePath\n            };\n            if(!args.dir) {\n              \n            }\n            if(exts.length>0) args.exts = exts;\n            if(onlyDir) args.onlyDir = true;\n              serviceGet.request(args, function(req, res) {\n              if(res.code!=0) {\n                let errMsg = res.message;\n                if(errMsg.indexOf(\"ECONNREFUSED\")>=0) errMsg = \"连接服务器失败！\";\n                $(\"#labelMsg\").text(errMsg);\n                return;\n              }\n              var parent = $(\".node-items[node-path='\"+nodePath+\"']\");\n              for(var i=0;i<res.dirs.length;i++) {\n                var dir = res.dirs[i];\n                addNode(\"dir\", parent, dir.name, nodePath+'/'+dir.name, prefix);\n              }\n              if(!onlyDir) {\n                for(var i=0;i<res.files.length;i++) {\n                  var file = res.files[i];\n                  addNode(\"file\", parent, file.name, nodePath+'/'+file.name, prefix);\n                }\n              }\n              curNode.attr(\"have-load-data\", \"true\");\n              $(\".node-items[node-path='\"+nodePath+\"']\").show();\n            });\n          } else {\n            $(\".node-items[node-path='\"+nodePath+\"']\").show();\n          }\n        } else {\n          $(this).find(\"img\").attr(\"src\", \"../tree/images/expand-dark.png\");\n          $(\".node-items[node-path='\"+nodePath+\"']\").hide();\n        }\n      });\n\n      newNode.dblclick(function() {\n        if($(this).attr(\"node-type\")==\"file\") {\n          let filePath = $(this).attr(\"node-path\");\n          if(filePath.startsWith(\"web/\")) filePath = filePath.substr(3);\n          $(\"#iptPath\").val(filePath);\n          onButtonOKClick();\n        }\n      });\n"
		},
		{
			"name": "button_submit_onClick",
			"comment": "点击时",
			"editType": "code",
			"args": [],
			"code": "      var filePath = $(\"#iptPath\").val();\n      if( (listServerFile && filePath.indexOf(\"/app/\")==0) || (listClientFile && filePath.indexOf(\"/web/\")==0)) {\n        filePath = filePath.substr(5);\n      }\n      if(filePath.trim()==\"\") {\n        $(\"#labelMsg\").text(\"请输入文件路径！\");\n        $(\"#iptPath\").focus();\n        return;\n      }\n\n      tfp.closeCurDialog(filePath);\n"
		}
	],
	"onLoad": "page1_onLoad()",
	"jsGlobalVars": [
		{
			"name": "exts",
			"type": "array",
			"value": "[]"
		},
		{
			"name": "dialogArgs",
			"type": "undefined",
			"value": ""
		},
		{
			"name": "onlyDir",
			"type": "bool",
			"value": "false"
		},
		{
			"name": "listServerFile",
			"type": "bool",
			"value": "false"
		},
		{
			"name": "listClientFile",
			"type": "bool",
			"value": "false"
		}
	]
}