You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

define(function(require, exports, module) {
var Window = require('system/views/pages/window');
var tpl = require('text!apps/edp/frs/frs008/view.tpl');
var sendWindow = require('apps/edp/frs/frs008/send');
var Router = require(Store.mainRouter);
function ViewWindow(options, callback) {
this.options = {
title: '查看',
content: tpl,
width: 800,
height: 600,
modal: true,
closed: true,
closable: true,
draggable: true,
data: null
}
this.callback = callback;
this.sender = "";
this.senderid = "";
this.theme = "回复主题:";
this.content="回复:";
_.extend(this.options, options);
Window.call(this, this.options);
}
inherits(ViewWindow, Window);
ViewWindow.prototype.init = function() {};
ViewWindow.prototype.customerize = function($container) {
var self = this;
self.options.data.re = 1;
self.optionscopy = self.options;
var data = self.options.data;
this.$emailReSend = this.getElement('button.resend');
this.$emailFinish = this.getElement('button.finish');
this.$emailReSend.hide();
this.$emailReSend.click(function() {
self.close();
params = {
data: {
sender: [{
username:self.sender,
userid:self.senderid,
}],
content:self.content,
theme: self.theme,
re: 1,
}
}
self.sendwindow = new sendWindow(params);
self.sendwindow.open();
});
this.$emailFinish.click(function() {
self.close();
});
this.$content = this.getElement(".Content");
this.$theme = this.getElement(".Theme");
this.$sendDate = this.getElement(".SendDate");
this.$sender = this.getElement(".Sender");
this.$addresseeName = this.getElement(".AddresseeName");
this.$accessoryname = this.getElement(".Accessoryname");
//content
this.$content.html(data.content);
this.$theme.text(data.theme);
this.$sendDate.text(data.senddate);
this.$sender.text(data.sender);
if (data.category == 1) {
this.$content.find('a').on('click', function() {
var data_node = JSON.parse($(this).attr('data-node'));
self.linknode(data_node);
});
}
//回复使用的变量
self.content+=data.content;
self.theme += data.theme;
self.sender = data.sender;
self.senderid = data.senderid;
var AddresseeNameText = "";
var rebutton = this.$emailReSend;
var AddresseeJson = data.addresseeList;
Store.logOn = Store.Cache.getJSON('userInfo');
$.each(AddresseeJson, function(i) {
AddresseeNameText += "<span name=" + AddresseeJson[i].addresseeid + ">" +
AddresseeJson[i].addresseename + ";" + "</span>";
if (AddresseeJson[i].addresseeid === Store.logOn.userId) {
rebutton.show();
}
});
this.$addresseeName.html(AddresseeNameText);
//附件
if (data.accessoryList != undefined) {
var AccessoryText = "";
var AccessoryJson = data.accessoryList;
$.each(AccessoryJson, function(i) {
AccessoryText += "<div><span name=" + AccessoryJson[i].fileid + ">" +
AccessoryJson[i].filename + " </span>" + '<a>下载</a></div>';
});
this.$accessoryname.html(AccessoryText);
} else {
var AccessoryText = "无附件";
this.$accessoryname.html(AccessoryText);
}
//下载事件绑定
this.$accessoryname.find('div a').click(function() {
var fileid = $(this).parent('div').find('span').attr('name');
self.downfile(fileid);
});
};
ViewWindow.prototype.downfile = function(fileid) {
var self = this;
params = {
fileId: fileid,
}
Store.services.fileExists(params, function(isok, data) {
if (isok) {
if (data.FileIsExist == 1) {
var sUrl = Store.host + "file/download.action?fileId=" + fileid;
window.open(sUrl, "_blank");
} else {
Store.messager.tip(data.FileIdIsExist || '文件被删除!');
}
} else {
Store.messager.tip(data.returnMessage || '文件id不存在');
}
});
};
ViewWindow.prototype.linknode = function(node) {
this.close();
Router.dispatch(node);
};
//view start
return ViewWindow;
});