define(function(require, exports, module) {
require("./addpicture.css")
let Window = require("system/views/pages/window");
let tpl = require("./addpicture.tpl");
let uploadpictureWindow = require("system/views/pages/uploadwindow/uploadpictureWindow");
let bizService = require("system/service/bizservice");
let Service = require('apps/rht/etp/etp0603/etp0603service');
let rhtComm = require('apps/rht/comm/rhtComm');
let navigatorSort = [];
let currentCheckedNode = ""; //已选中树节点
let rootPath = "upload_picture"; //根目录
let upIns;
let deleteType = "1"; // 0 1 代表软删除与硬删除
let treeNodes = ""; //所有的节点信息
let checkedPicture = []; //当前已经选择的图片
let rtnetp0603info = [];
function UploadPicture(args) {
let self = (upIns = this);
this.options = {
title: "图片空间",
content: tpl,
width: 800,
height: 536,
modal: true,
closed: true,
closable: true,
minimizable: false,
maximizable: false,
collapsible: false,
resizable: false,
data: null,
onBeforeClose: function() {}
};
this.args = args;
this.imgSrc = this.args.imgSrc
rootPath = this.args.rootPath;
this.selectItem = false;
this.imageServer = rhtComm.getRhtOptionValue('*','SYS','SYS_IMAGE_SERVER','');
Window.call(this, this.options);
}
inherits(UploadPicture, Window);
UploadPicture.prototype.init = function() {
let self = this;
// let tree = {
// data: [],
// actions: {
// onClick: function(event, treeNode) {
// upIns.showPicture(treeNode.imgsrc || "");
// currentCheckedNode = treeNode;
// upIns.pictureClick();
// upIns.createNavigator(treeNodes, treeNode.id);
// }
// }
// };
// this.register("tree", "tree_upload", tree);
setTimeout(function() {
let eventsOpts = [
{
elements: $(".upload"),
eventsType: "click",
eventFn: upIns.uploadingFile
},
// {
// elements: $(".createFolder"),
// eventsType: "click",
// eventFn: upIns.createFolder
// },
// {
// elements: $(".deletefile"),
// eventsType: "click",
// eventFn: upIns.deleteFile
// },
{
elements: $("#window_confirm"),
eventsType: "click",
eventFn: upIns.windowConfirm
},
{
elements: $("#window_cancel"),
eventsType: "click",
eventFn: upIns.windowCancel
}
];
// upIns.refreshZtree();
eventsOpts.forEach(function(val) {
upIns.bindingEvents(val);
});
// upIns.bindingSearch();
// upIns.bindCreateTpl();
upIns.showPicture(upIns.imgSrc)
}, 500);
};
// function getLowerCaseData(dataRow) {
// let data = {};
// for (let key in dataRow) {
// data[key.toLowerCase()] = dataRow[key];
// }
// return data;
// }
// //导航查找排列
// function findTreeNavigation(dataSource, treeId) {
// dataSource.forEach(function(val) {
// if (val.id === treeId) {
// navigatorSort.push(val);
// if (val.pId) {
// findTreeNavigation(dataSource, val.pId);
// }
// }
// });
// return navigatorSort;
// }
// //刷新ztree数据
// UploadPicture.prototype.refreshZtree = function() {
// let param = { rootpath: rootPath };
// /*
// bizService.fileQuery(param, function(type, res) {
// checkedPicture = [];
// res.forEach(function(val, index) {
// val.pId = val.pid;
// });
// treeNodes = res;
// upIns.vm["tree_upload"].reset(res);
// //定位到查找的文件夹地方
// let domNode = upIns.vm["tree_upload"].getNodesByFilter(function(node) {
// return node.name.indexOf(currentCheckedNode.name) > -1;
// }, true);
// upIns.vm["tree_upload"].setSelect(domNode);
// res.forEach(function(val) {
// if (val.id === currentCheckedNode.id) {
// //刷新视图层
// upIns.showPicture(val.imgsrc);
// }
// });
// upIns.pictureClick();
// });
// */
// Service.queryPicture(param, function(type, res) {
// checkedPicture = [];
// res.forEach(function(val, index) {
// val.pId = val.pid;
// });
// treeNodes = res;
// upIns.vm["tree_upload"].reset(res);
// //定位到查找的文件夹地方
// let domNode = upIns.vm["tree_upload"].getNodesByFilter(function(node) {
// return node.name.indexOf(currentCheckedNode.name) > -1;
// }, true);
// upIns.vm["tree_upload"].setSelect(domNode);
// res.forEach(function(val) {
// if (val.id === currentCheckedNode.id) {
// //刷新视图层
// upIns.showPicture(val.imgsrc);
// }
// });
// upIns.pictureClick();
// });
// };
//navigator 导航
// UploadPicture.prototype.createNavigator = function(dataSource, treeId) {
// navigatorSort = [];
// let sList = findTreeNavigation(dataSource, treeId).reverse();
// let navp = $(".file_path");
// let cSpan = [];
// navp.children().remove();
// sList.forEach(function(val, index) {
// let str = "" + val.name + " > ";
// if (index === sList.length - 1) {
// str = "" + val.name + "";
// }
// cSpan.push(str);
// });
// navp.append(cSpan.join(""));
// //计算总长度是否超出
// let allSpan = navp.find("span");
// let allSpanWidth = 50;
// let navWidth = navp.width();
// let z = 0;
// for (let i = allSpan.length - 1; i > -1; i--) {
// let spanWidth = allSpan.eq(i).width();
// allSpanWidth += spanWidth;
// if (allSpanWidth > navWidth) {
// z = i + 1;
// break;
// }
// }
// if (navp.width() < allSpanWidth) {
// navp
// .find("span:first")
// .before(
// '