|
@@ -0,0 +1,961 @@
|
|
|
+import BaseWidget = require('core/BaseWidget.class');
|
|
|
+declare var InfoWindow;
|
|
|
+declare var videojs;
|
|
|
+declare var wangEditor;
|
|
|
+declare var filterXSS;
|
|
|
+
|
|
|
+ * 视频监控模块
|
|
|
+ */
|
|
|
+class ProjectNewsManagement extends BaseWidget {
|
|
|
+ baseClass = "widget-ProjectNewsManagement";
|
|
|
+ handler = null;
|
|
|
+ _tableID = "newTb";
|
|
|
+ infoWindow: any;
|
|
|
+ gifLayer: any;
|
|
|
+ prjSelID = "prjSel";
|
|
|
+ titleInputID = "titleInput";
|
|
|
+ newsCreatorID = "newsCreator";
|
|
|
+ newsDepartmentID = "newsDepartment";
|
|
|
+ searchProjSelID = "searchProjSel";
|
|
|
+ resetBtnID = "resetBtn";
|
|
|
+ searchBtnID = "searchBtn";
|
|
|
+ searchNewsStatueID = "searchNewsStatue";
|
|
|
+ searchCreatorID = "searchCreator";
|
|
|
+ searchDatetimeID = "searchDatetime";
|
|
|
+ searchTitleID = "seachTitle";
|
|
|
+ publishBtnID = "publishBtn";
|
|
|
+ qrcodeBtnID = "qrcodeBtn";
|
|
|
+ dateClearBtnID = "dateClearBtn";
|
|
|
+ _listTable = null;
|
|
|
+
|
|
|
+ _apiUrls = {
|
|
|
+ getUserInfoApi: "/base/user/getInfo",
|
|
|
+ projectList: "/tofly-sxgk/areacompany/pageFilterUser",
|
|
|
+ addNews: "/tofly-sxgk/cInfoPublish/saveOrUpdate",
|
|
|
+ newsList: "/tofly-sxgk/infopublish/page",
|
|
|
+ userList: "/base/user/pageNew",
|
|
|
+ delNews: "/tofly-sxgk/infopublish/",
|
|
|
+ getByID: "/tofly-sxgk/infopublish/",
|
|
|
+ uploadImg: "/tofly-sxgk/uploadSeparately/getInfoWithUpdateAddFile",
|
|
|
+ viewImg: "/base/file/loadImgWithNoAuth",
|
|
|
+ setStatus: "/tofly-sxgk/cInfoPublish/statusModify",
|
|
|
+ qrcodeView: "/tofly-sxgk/cInfoPublish/getOneQrcodeUrl"
|
|
|
+ };
|
|
|
+
|
|
|
+ * 启动
|
|
|
+ */
|
|
|
+ startup() {
|
|
|
+ this.setHtml(this.template.split("$$")[0]);
|
|
|
+ this.initPbsModuleList();
|
|
|
+ this.initEvent();
|
|
|
+ }
|
|
|
+
|
|
|
+ * 按钮事件
|
|
|
+ */
|
|
|
+ initEvent() {
|
|
|
+ this.domObj.find('#addBtn').off('click').on('click', this.addNews.bind(this));
|
|
|
+
|
|
|
+ this.domObj.find("#searchBtn").off('click').on('click', this.searchList.bind(this));
|
|
|
+ this.domObj.find("#titleSearchBtn").off('click').on('click', this.searchList.bind(this));
|
|
|
+ this.domObj.find("#seachTitle").off('keydown').on('keydown', e => {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ this.searchList();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.domObj.find('#' + this.publishBtnID).off('click').on('click', e => {
|
|
|
+ if (!this._listTable) {
|
|
|
+ this.toast.show('工程信息列表未初始化');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const currentSelect = this._listTable.rows('.active').data();
|
|
|
+ const id = currentSelect[0].id.toString();
|
|
|
+ if (currentSelect[0].status === 2) {
|
|
|
+ this.toast.show("该工程信息已发布");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.publishNews(id);
|
|
|
+ });
|
|
|
+ this.initSearchElement();
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于初始化搜索条件
|
|
|
+ *
|
|
|
+ */
|
|
|
+ initSearchElement() {
|
|
|
+
|
|
|
+ this.initProjectList(this.domObj.find("#" + this.searchProjSelID), false, null);
|
|
|
+
|
|
|
+ this.initUserList(this.domObj.find("#" + this.searchCreatorID), null);
|
|
|
+
|
|
|
+ this.domObj.find("#" + this.searchNewsStatueID).select2({
|
|
|
+ language: "zh-CN",
|
|
|
+ width: "element",
|
|
|
+ dropdownCssClass: "userManagementPopupDep",
|
|
|
+ allowClear: true,
|
|
|
+ placeholder: '---请选择---',
|
|
|
+ placeholderOption: "first"
|
|
|
+ });
|
|
|
+
|
|
|
+ this.initDateRangePicker();
|
|
|
+ }
|
|
|
+
|
|
|
+ * 发布
|
|
|
+ */
|
|
|
+ publishNews(id: string) {
|
|
|
+
|
|
|
+ this.popup.setSize(400, 200);
|
|
|
+ const popup = this.popup.show("发布", "<div style='text-align:center;'>确认是否发布工程信息?</div>");
|
|
|
+ popup.submitObj.off('click').on('click', (e) => {
|
|
|
+ const url = this._apiUrls.setStatus;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { ids: id, status: "2" }, url, "POST", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("发布成功");
|
|
|
+ this.popup.close();
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("发布失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("发布失败,请联系管理员")
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 撤销新闻
|
|
|
+ */
|
|
|
+ revokeNews(id) {
|
|
|
+ this.popup.setSize(400, 200);
|
|
|
+ const popup = this.popup.show("撤销", "<div style='text-align:center;'>确认是否撤销工程信息?</div>");
|
|
|
+ popup.submitObj.off('click').on('click', (e) => {
|
|
|
+ const url = this._apiUrls.setStatus;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { ids: "" + id + "", status: "3" }, url, "POST", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("撤销成功");
|
|
|
+ this.popup.close();
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("撤销失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("撤销失败,请联系管理员")
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于搜索列表
|
|
|
+ */
|
|
|
+ searchList() {
|
|
|
+ if (this._listTable) {
|
|
|
+ this._listTable.ajax.reload(null, false);
|
|
|
+ } else {
|
|
|
+ this.toast.show("宣传信息列表未初始化");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于新增新闻
|
|
|
+ */
|
|
|
+ addNews() {
|
|
|
+ const height = this.domObj.height();
|
|
|
+ const width = this.domObj.width() / 2;
|
|
|
+ this.popup.setSizeWithoutBtns(width, height);
|
|
|
+ const popup = this.popup.show("创作文章", this.template.split('$$')[1], true);
|
|
|
+
|
|
|
+ const editor = this.initEditor(popup);
|
|
|
+ let newsID = null;
|
|
|
+ this.initUserInfo(popup);
|
|
|
+ const sel = popup.domObj.find("#" + this.prjSelID);
|
|
|
+ this.initProjectList(sel, true, this.AppX.appConfig.currentPrj);
|
|
|
+
|
|
|
+ popup.domObj.find('.editPreviewBtn').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent);
|
|
|
+ const newWindow = window.open(this.root + "/newsPage/index.html");
|
|
|
+
|
|
|
+
|
|
|
+ newWindow.onload=(hand)=>{
|
|
|
+ const newPage=hand.currentTarget.document;
|
|
|
+ const text = $('<div>').html(content).html();
|
|
|
+ $(newPage.body).find('.title').append("<h2>" + title + "</h2>");
|
|
|
+ $(newPage.body).find('.content').append(text);
|
|
|
+ $(newPage.body).find('.department').text("发布单位:" + department);
|
|
|
+ $(newPage.body).find('.publishtime').text("发布时间:");
|
|
|
+ };
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ popup.domObj.find('.saveDraft').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+ const creatorID = popup.domObj.find("#" + this.newsCreatorID).data('userid');
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+ const departmentID = popup.domObj.find("#" + this.newsDepartmentID).data('partid');
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent);
|
|
|
+ if (prjID === "" || title === "" || creator === "" || department === "" || content === "") {
|
|
|
+ this.toast.show('请完善发布信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ "id": newsID,
|
|
|
+ "prjId": prjID,
|
|
|
+ "title": title,
|
|
|
+ "content": content,
|
|
|
+ "status": 1,
|
|
|
+ "publishPerson": creator,
|
|
|
+ "publishDept": department
|
|
|
+ };
|
|
|
+ const url = this._apiUrls.addNews;
|
|
|
+ this.baseAjaxSend.sendAjax(this, data, url, "POST", result => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("保存成功");
|
|
|
+ newsID = result.result.id;
|
|
|
+
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ popup.domObj.find('.savePublish').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+ const creatorID = popup.domObj.find("#" + this.newsCreatorID).data('userid');
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+ const departmentID = popup.domObj.find("#" + this.newsDepartmentID).data('partid');
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent);
|
|
|
+ if (prjID === "" || title === "" || creator === "" || department === "" || content === "") {
|
|
|
+ this.toast.show('请完善发布信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ "id": newsID,
|
|
|
+ "prjId": prjID,
|
|
|
+ "title": title,
|
|
|
+ "content": content,
|
|
|
+ "status": 1,
|
|
|
+ "publishPerson": creator,
|
|
|
+ "publishDept": department
|
|
|
+ };
|
|
|
+ const url = this._apiUrls.addNews;
|
|
|
+ this.baseAjaxSend.sendAjax(this, data, url, "POST", result => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ newsID = result.result.id;
|
|
|
+
|
|
|
+ const url = this._apiUrls.setStatus;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { ids: "" + newsID + "", status: "2" }, url, "POST", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("发布成功");
|
|
|
+ this.popup.close();
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("发布失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("发布失败,请联系管理员")
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于编辑工程信息
|
|
|
+ * @param id 新闻ID
|
|
|
+ */
|
|
|
+ editNews(id) {
|
|
|
+ const url = this._apiUrls.getByID + id;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { id: id }, url, "GET", (result) => {
|
|
|
+ const data = result.result;
|
|
|
+ const height = this.domObj.height();
|
|
|
+ const width = this.domObj.width() / 2;
|
|
|
+ this.popup.setSizeWithoutBtns(width, height);
|
|
|
+ const popup = this.popup.show("编辑", this.template.split('$$')[1], true);
|
|
|
+
|
|
|
+ const editor = this.initEditor(popup);
|
|
|
+ let newsID = data.id;
|
|
|
+
|
|
|
+ popup.domObj.find("#" + this.newsCreatorID).val(data.publishPerson);
|
|
|
+
|
|
|
+ popup.domObj.find("#" + this.newsDepartmentID).val(data.publishDept);
|
|
|
+
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val(data.title);
|
|
|
+ editor.txt.html(data.content);
|
|
|
+ const sel = popup.domObj.find("#" + this.prjSelID);
|
|
|
+ this.initProjectList(sel, true, data.prjId);
|
|
|
+
|
|
|
+ popup.domObj.find('.editPreviewBtn').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent);
|
|
|
+ const newWindow = window.open(this.root + "/newsPage/index.html");
|
|
|
+
|
|
|
+
|
|
|
+ newWindow.onload=(hand)=>{
|
|
|
+ const newPage=hand.currentTarget.document;
|
|
|
+ const text = $('<div>').html(content).html();
|
|
|
+ $(newPage.body).find('.title').append("<h2>" + title + "</h2>");
|
|
|
+ $(newPage.body).find('.content').append(text);
|
|
|
+ $(newPage.body).find('.department').text("发布单位:" + department);
|
|
|
+ $(newPage.body).find('.publishtime').text("发布时间:");
|
|
|
+ };
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ popup.domObj.find('.saveDraft').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent);
|
|
|
+ if (prjID === "" || title === "" || creator === "" || department === "" || content === "") {
|
|
|
+ this.toast.show('请完善发布信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ "id": newsID,
|
|
|
+ "prjId": prjID,
|
|
|
+ "title": title,
|
|
|
+ "content": content,
|
|
|
+ "publishPerson": creator,
|
|
|
+ "publishDept": department
|
|
|
+ };
|
|
|
+ const url = this._apiUrls.addNews;
|
|
|
+ this.baseAjaxSend.sendAjax(this, data, url, "POST", result => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("保存成功");
|
|
|
+ newsID = result.result.id;
|
|
|
+
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ popup.domObj.find('.savePublish').off("click").on("click", (ev) => {
|
|
|
+ const prjID = popup.domObj.find("#" + this.prjSelID).val().toString();
|
|
|
+ const title = popup.domObj.find("#" + this.titleInputID).val().toString();
|
|
|
+ const creator = popup.domObj.find("#" + this.newsCreatorID).val().toString();
|
|
|
+
|
|
|
+ const department = popup.domObj.find("#" + this.newsDepartmentID).val().toString();
|
|
|
+
|
|
|
+ const xsscontent = editor.txt.html();
|
|
|
+
|
|
|
+ const filterXss = new filterXSS.FilterXSS({
|
|
|
+ onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
|
|
|
+ if (name === "style") {
|
|
|
+ return name + "='" + value + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const content = filterXss.process(xsscontent)
|
|
|
+ console.log(editor.txt.html());
|
|
|
+ console.log(content);
|
|
|
+ if (prjID === "" || title === "" || creator === "" || department === "" || content === "") {
|
|
|
+ this.toast.show('请完善发布信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ "id": newsID,
|
|
|
+ "prjId": prjID,
|
|
|
+ "title": title,
|
|
|
+ "content": content,
|
|
|
+ "publishPerson": creator,
|
|
|
+ "publishDept": department
|
|
|
+ };
|
|
|
+ const url = this._apiUrls.addNews;
|
|
|
+ this.baseAjaxSend.sendAjax(this, data, url, "POST", result => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ newsID = result.result.id;
|
|
|
+
|
|
|
+ const url = this._apiUrls.setStatus;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { ids: "" + newsID + "", status: "2" }, url, "POST", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("发布成功");
|
|
|
+ this.popup.close();
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show("发布失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("发布失败,请联系管理员")
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("保存失败");
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ }, err => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于初始化日历区间插件
|
|
|
+ */
|
|
|
+ initDateRangePicker() {
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).daterangepicker({
|
|
|
+ ranges: {
|
|
|
+ '今天': [moment().hours(0).minutes(0).seconds(0), moment().hours(23).minutes(59).seconds(59)],
|
|
|
+ '近7天': [moment().subtract(6, 'days').hours(0).minutes(0).seconds(0), moment().hours(23).minutes(59).seconds(59)],
|
|
|
+ '本月': [moment().startOf('month').hours(0).minutes(0).seconds(0), moment().endOf('month').hours(23).minutes(59).seconds(59)],
|
|
|
+ '今年': [moment().startOf('year').hours(0).minutes(0).seconds(0), moment().endOf('year').hours(23).minutes(59).seconds(59)]
|
|
|
+ },
|
|
|
+ opens: "left",
|
|
|
+ autoUpdateInput: false,
|
|
|
+ startDate: moment().hours(0).minutes(0).seconds(0),
|
|
|
+ endDate: moment(new Date()),
|
|
|
+ showWeekNumbers: true,
|
|
|
+ timePicker: true,
|
|
|
+ timePicker24Hour: true,
|
|
|
+ timePickerSeconds: true,
|
|
|
+ locale: {
|
|
|
+ format: "YYYY-MM-DD HH:mm:ss",
|
|
|
+ applyLabel: '确定',
|
|
|
+ cancelLabel: '取消',
|
|
|
+ customRangeLabel: '自定义',
|
|
|
+ daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
|
|
|
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
|
|
|
+ '七月', '八月', '九月', '十月', '十一月', '十二月'
|
|
|
+ ],
|
|
|
+ firstDay: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ function (start, end) {
|
|
|
+
|
|
|
+ }.bind(this)
|
|
|
+ ).on("apply.daterangepicker", function (ev, picker) {
|
|
|
+ const dateFormat = "YYYY-MM-DD HH:mm:ss";
|
|
|
+
|
|
|
+
|
|
|
+ const start = picker.startDate;
|
|
|
+ const end = picker.endDate;
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).val(picker.startDate.format(dateFormat) + ' - ' + picker.endDate.format(dateFormat));
|
|
|
+
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).prop('title', picker.startDate.format(dateFormat) + ' - ' + picker.endDate.format(dateFormat));
|
|
|
+ const data2 = {
|
|
|
+ beginDate: start.format(dateFormat),
|
|
|
+ endDate: end.format(dateFormat)
|
|
|
+ }
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).data('begintime', picker.startDate.format(dateFormat));
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).data('endtime', picker.endDate.format(dateFormat));
|
|
|
+
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
+ this.domObj.find("#" + this.dateClearBtnID).off('click').on('click', e => {
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).val('');
|
|
|
+
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).prop('title', '');
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).data('begintime', '');
|
|
|
+ this.domObj.find('#' + this.searchDatetimeID).data('endtime', '');
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于初始化富文本编辑器
|
|
|
+ */
|
|
|
+ initEditor(popup: any): any {
|
|
|
+ const editor = new wangEditor(popup.domObj.find('#richEditor')[0]);
|
|
|
+
|
|
|
+ editor.config.menuTooltipPosition = 'down';
|
|
|
+
|
|
|
+ const contentHeight = popup.conObj.find('.content-con').height();
|
|
|
+ editor.config.height = contentHeight;
|
|
|
+
|
|
|
+ editor.config.uploadImgServer = this.apiRoot + this._apiUrls.uploadImg;
|
|
|
+ editor.config.uploadImgHeaders = {
|
|
|
+ Authorization: 'bearer ' + this.userToken
|
|
|
+ };
|
|
|
+ editor.config.pasteFilterStyle = false;
|
|
|
+
|
|
|
+ editor.config.uploadImgHooks = {
|
|
|
+
|
|
|
+
|
|
|
+ customInsert: (insertImgFn, result) => {
|
|
|
+
|
|
|
+ console.log('customInsert', result);
|
|
|
+
|
|
|
+
|
|
|
+ insertImgFn(this.apiRoot + this._apiUrls.viewImg + "?remotePath=" + result.result[0].path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ editor.create();
|
|
|
+ return editor;
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于获取登录用户的基本信息
|
|
|
+ * @param popup 弹出框
|
|
|
+ */
|
|
|
+ initUserInfo(popup: any) {
|
|
|
+ this.baseAjaxSend.sendAjax(this, {}, this._apiUrls.getUserInfoApi, "GET", (results) => {
|
|
|
+ if (results.code == 1) {
|
|
|
+ var data = results.result;
|
|
|
+ popup.domObj.find("#" + this.newsCreatorID).val(data.realName);
|
|
|
+ popup.domObj.find("#" + this.newsCreatorID).data('userid', data.id);
|
|
|
+ popup.domObj.find("#" + this.newsDepartmentID).val(data.departmentName);
|
|
|
+ popup.domObj.find("#" + this.newsDepartmentID).data("partid", data.departmentId);
|
|
|
+ } else {
|
|
|
+ console.log("获取用户信息失败");
|
|
|
+ console.error(results.message);
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ console.log("获取用户信息失败");
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于初始化用户列表,后端搜索
|
|
|
+ */
|
|
|
+ initUserList(element: any, callback: Function = null) {
|
|
|
+ const that = this;
|
|
|
+ var url = this.apiRoot + this._apiUrls.userList;
|
|
|
+ const userSelect = this.domObj.find(element).select2({
|
|
|
+ language: "zh-CN",
|
|
|
+ dropdownCssClass: "userManagementPopupDep",
|
|
|
+ allowClear: true,
|
|
|
+ placeholder: '---请选择---',
|
|
|
+ placeholderOption: "first",
|
|
|
+ ajax: {
|
|
|
+ headers: that.header,
|
|
|
+ delay: 250,
|
|
|
+ url: url,
|
|
|
+ dataType: "json",
|
|
|
+ type: "GET",
|
|
|
+ contentType: "application/json;charset=utf-8",
|
|
|
+ data: (params) => {
|
|
|
+ var query = {
|
|
|
+ current: params.page || 1,
|
|
|
+ size: 20,
|
|
|
+ realName: params.term
|
|
|
+ }
|
|
|
+ return query;
|
|
|
+ },
|
|
|
+ processResults: (data) => {
|
|
|
+ let nodes = [];
|
|
|
+ if (data.code != 1) {
|
|
|
+ console.error(data.message);
|
|
|
+ return { results: nodes };
|
|
|
+ }
|
|
|
+ data.result.records.forEach(item => {
|
|
|
+ nodes.push({ id: item.id, text: item.realName });
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ results: nodes,
|
|
|
+ pagination: {
|
|
|
+ more: data.result.current < data.result.pages
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ userSelect.on('select2:clear', (ev) => {
|
|
|
+ userSelect.val(null).trigger('change');
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用户初始化项目列表
|
|
|
+ * @param element select对象
|
|
|
+ * @param isClear 是否清空
|
|
|
+ * @param selectID 默认选中项
|
|
|
+ */
|
|
|
+ initProjectList(element: any, isClear: boolean, selectID: number) {
|
|
|
+ if (isClear) {
|
|
|
+ $(element).empty();
|
|
|
+ }
|
|
|
+ this.baseAjaxSend.sendAjax(this, { current: 1, size: 1000 }, this._apiUrls.projectList, 'GET', result => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ result.result.records.forEach(item => {
|
|
|
+ if (selectID && item.id === selectID) {
|
|
|
+ $(element).append("<option value='" + item.id + "' selected>" + item.name + "</option>");
|
|
|
+ } else {
|
|
|
+ $(element).append("<option value='" + item.id + "'>" + item.name + "</option>");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $(element).select2({
|
|
|
+ placeholder: '---请选择---',
|
|
|
+ placeholderOption: "first",
|
|
|
+ language: "zh-CN",
|
|
|
+ allowClear: true,
|
|
|
+ dropdownCssClass: "userManagementPopupDep"
|
|
|
+
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.toast.show('获取项目列表失败');
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show('获取项目列表失败');
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于初始化所有PBS模板
|
|
|
+ *
|
|
|
+ */
|
|
|
+ initPbsModuleList() {
|
|
|
+ const that = this;
|
|
|
+ const pbslist = [];
|
|
|
+ const columns = [{
|
|
|
+ name: 'counter', title: "序号", data: 'counter'
|
|
|
+ }, {
|
|
|
+ name: 'prjName', title: "项目", data: 'prjName'
|
|
|
+ }, {
|
|
|
+ name: 'title', title: '标题', data: 'title'
|
|
|
+ }, {
|
|
|
+ name: 'url', title: '网址', data: 'url'
|
|
|
+ }, {
|
|
|
+ name: 'qrCode', title: '二维码', data: 'qrCode'
|
|
|
+ }, {
|
|
|
+ name: 'scanTimes', title: '浏览次数', data: 'scanTimes'
|
|
|
+ }, {
|
|
|
+ name: 'status', title: '发布状态', data: 'status'
|
|
|
+ }, {
|
|
|
+ name: 'publishPerson', title: '发布人', data: 'publishPerson'
|
|
|
+ }, {
|
|
|
+ name: 'publishDept', title: '发布单位', data: 'publishDept'
|
|
|
+ }, {
|
|
|
+ name: 'createTime', title: '发布时间', data: 'createTime'
|
|
|
+ }, {
|
|
|
+ name: 'operation', title: '操作', data: 'operation'
|
|
|
+ }, {
|
|
|
+ name: "id", title: "id", data: "id", visible: false
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const scrollY = this.resizeTableHeight(80);
|
|
|
+ const dataoptions = {
|
|
|
+ columns: columns,
|
|
|
+ lengthMenu: [
|
|
|
+ 10,
|
|
|
+ 25,
|
|
|
+ 50,
|
|
|
+ 100
|
|
|
+ ],
|
|
|
+ pageLength: 25,
|
|
|
+ pagingType: "simple_numbers",
|
|
|
+ ordering: false,
|
|
|
+ paging: true,
|
|
|
+ info: true,
|
|
|
+ searching: false,
|
|
|
+ scrollCollapse: false,
|
|
|
+ scrollY: "calc(100% - 38px)",
|
|
|
+ language: {
|
|
|
+ "lengthMenu": "每页 _MENU_ 条",
|
|
|
+ "zeroRecords": "未查询到任何记录",
|
|
|
+ "info": "共 _TOTAL_ 条",
|
|
|
+ "infoEmpty": "",
|
|
|
+ "infoFiltered": "",
|
|
|
+ "paginate": {
|
|
|
+ "first": "首页",
|
|
|
+ "last": "尾页",
|
|
|
+ "next": "下一页",
|
|
|
+ "previous": "上一页"
|
|
|
+ },
|
|
|
+ "search": "搜索: ",
|
|
|
+ },
|
|
|
+ dom: 't' +
|
|
|
+ ' <"row paging"' +
|
|
|
+ ' <"col-1 information"ri>' +
|
|
|
+ ' <"col-2 length-changing"l>' +
|
|
|
+ ' <"col-6 pagination"p>' +
|
|
|
+ ' >',
|
|
|
+ serverSide: true,
|
|
|
+ ajax: {
|
|
|
+ headers: that.header,
|
|
|
+ type: "GET",
|
|
|
+ data: function () {
|
|
|
+ const title = that.domObj.find("#" + that.searchTitleID).val().toString().trim();
|
|
|
+ const project = that.domObj.find("#" + that.searchProjSelID).val();
|
|
|
+ const creator = that.domObj.find("#" + that.searchCreatorID).val();
|
|
|
+ const status = that.domObj.find("#" + that.searchNewsStatueID).val();
|
|
|
+ const begintime = that.domObj.find("#" + that.searchDatetimeID).data('begintime');
|
|
|
+ const endtime = that.domObj.find("#" + that.searchDatetimeID).data('endtime');
|
|
|
+ const data = {
|
|
|
+ current: 1,
|
|
|
+ size: that._listTable != undefined ? that._listTable.page.info().length : 25,
|
|
|
+ title: title,
|
|
|
+ publishPerson: creator,
|
|
|
+ prjId: project,
|
|
|
+ status: status,
|
|
|
+ beginTime: begintime,
|
|
|
+ endTime: endtime,
|
|
|
+ "orders[0].asc": false,
|
|
|
+ "orders[0].column": "create_time"
|
|
|
+ }
|
|
|
+ if (that.baseAjaxSend.xssCodeCheck(data)) {
|
|
|
+ that.toast.show('非法输入');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ url: that.apiRoot + that._apiUrls.newsList,
|
|
|
+ dataType: "json",
|
|
|
+ async: false,
|
|
|
+ error: function (e) {
|
|
|
+ that.toast.show("获取发布信息失败");
|
|
|
+ console.error(e);
|
|
|
+ },
|
|
|
+ dataSrc: function (results) {
|
|
|
+ if (results.code == 1) {
|
|
|
+ var value = results;
|
|
|
+ results = {};
|
|
|
+
|
|
|
+ value.recordsFiltered = value.result.total;
|
|
|
+ results.data = [];
|
|
|
+ $.each(value.result.records, function (i: number, item) {
|
|
|
+ const opetions = that.setOpertations(item);
|
|
|
+ const qrcodePreview = that.getQrcodeOperation(item);
|
|
|
+ const hrefUrl = item.publishUrl;
|
|
|
+ const publishUrl = "<a href='" + hrefUrl + "' target='_blank'>" + hrefUrl + "</a>";
|
|
|
+ results.data.push({
|
|
|
+ prjName: item.prjName,
|
|
|
+ id: item.id,
|
|
|
+ title: item.title,
|
|
|
+ url: item.status === 2 ? publishUrl : "",
|
|
|
+ qrCode: qrcodePreview,
|
|
|
+ scanTimes: item.scanTimes,
|
|
|
+ status: item.status === 1 ? "草稿" : item.status === 2 ? "已发布" : "撤销",
|
|
|
+ publishPerson: item.publishPerson,
|
|
|
+ publishDept: item.publishDept,
|
|
|
+ createTime: item.createTime,
|
|
|
+ operation: opetions,
|
|
|
+ counter: i + 1
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return results.data;
|
|
|
+ } else {
|
|
|
+ that.toast.show(results.message);
|
|
|
+ console.error(results.message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ drawCallback: (setting) => {
|
|
|
+ $(setting.nTable).find("tbody tr").off('click').on('click', e => {
|
|
|
+
|
|
|
+ $(e.currentTarget).parents('table').find('tr').removeClass('active');
|
|
|
+ $(e.currentTarget).addClass('active');
|
|
|
+ })
|
|
|
+
|
|
|
+ $(setting.nTable).find("tbody tr").on('click', '.operationBtn', function (e) {
|
|
|
+
|
|
|
+
|
|
|
+ const tb = new $.fn.dataTable.Api(setting);
|
|
|
+ const row = tb.row(e.delegateTarget).data();
|
|
|
+ const operationType = $(e.currentTarget).data('type');
|
|
|
+ that.initOperationsEvent(row, operationType);
|
|
|
+ }.bind(this));
|
|
|
+ },
|
|
|
+ initComplete: (setting) => {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._listTable = this.domObj.find("#" + this._tableID).DataTable(dataoptions);
|
|
|
+ this._listTable.on("preXhr", () => {
|
|
|
+ if (this._listTable) {
|
|
|
+ var pageinfo = this._listTable.page.info();
|
|
|
+ this._listTable.ajax.params().current = pageinfo.page + 1;
|
|
|
+ this._listTable.ajax.params().size = pageinfo.length;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ * 预览
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ preview(id) {
|
|
|
+ const url = this._apiUrls.getByID + id;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { id: id }, url, "GET", (result) => {
|
|
|
+ const newpage = window.open();
|
|
|
+ newpage.document.write(result.result.content);
|
|
|
+ }, err => {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于设置新闻操作配置
|
|
|
+ * @param info 新闻纪录
|
|
|
+ */
|
|
|
+ setOpertations(info: any) {
|
|
|
+ let operations = "";
|
|
|
+ switch (info.status) {
|
|
|
+ case 1:
|
|
|
+ operations = "<button class='btn btn-link operationBtn' data-type='edit'>编辑</button>" +
|
|
|
+ "<button class='btn btn-link operationBtn' data-type='delete'>删除</button>";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ operations = "<button class='btn btn-link operationBtn' data-type='recover'>撤销</button>";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ operations = "<button class='btn btn-link operationBtn' data-type='edit'>编辑</button>" +
|
|
|
+ "<button class='btn btn-link operationBtn' data-type='delete'>删除</button>";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return operations;
|
|
|
+ }
|
|
|
+
|
|
|
+ * 是否可浏览二维码
|
|
|
+ * @param info
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ getQrcodeOperation(info: any) {
|
|
|
+ let operations = "";
|
|
|
+ switch (info.status) {
|
|
|
+ case 2:
|
|
|
+ operations = "<button class='btn btn-link operationBtn' data-type='qrcode'>查看</button>";
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ return operations;
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于表格操作事件触发
|
|
|
+ * @param row 行数据
|
|
|
+ * @param operatType 事件类型
|
|
|
+ */
|
|
|
+ initOperationsEvent(row: any, operatType: string) {
|
|
|
+ switch (operatType) {
|
|
|
+ case "edit":
|
|
|
+ this.editNews(row.id);
|
|
|
+ break;
|
|
|
+ case "delete":
|
|
|
+ this.deleteNews(row.id);
|
|
|
+ break;
|
|
|
+ case "recover":
|
|
|
+ this.revokeNews(row.id);
|
|
|
+ break;
|
|
|
+ case "preview":
|
|
|
+ this.preview(row.id);
|
|
|
+ break;
|
|
|
+ case "qrcode":
|
|
|
+ this.viewQrcode(row.id);
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ * 查看工程信息二维码
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ viewQrcode(id) {
|
|
|
+ const url = this._apiUrls.qrcodeView;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { id: id }, url, "GET", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ const remotePath = result.result.fileName.viewFtpFilePath;
|
|
|
+ const popup = this.popup.setSizeWithoutBtns(500, 500);
|
|
|
+ const src = this.apiRoot + this._apiUrls.viewImg + "?remotePath=" + remotePath;
|
|
|
+ const content = "<div class='qrcode'><img src='" + src + "'></div>";
|
|
|
+ this.popup.show('二维码', content, true);
|
|
|
+ } else {
|
|
|
+ this.toast.show("后台请求失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show("后台请求失败,请联系管理员");
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于根据id删除新闻
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ deleteNews(id: number) {
|
|
|
+ this.popup.setSize(400, 200);
|
|
|
+ const popup = this.popup.show("删除", "<div style='text-align:center;'>确认是否删除工程信息?</div>");
|
|
|
+ popup.submitObj.off('click').on('click', (e) => {
|
|
|
+ const url = this._apiUrls.delNews + id;
|
|
|
+ this.baseAjaxSend.sendAjax(this, { id: id }, url, "DELETE", (result) => {
|
|
|
+ if (result.code === 1) {
|
|
|
+ this.toast.show("删除成功");
|
|
|
+ this.popup.close();
|
|
|
+ this.searchList();
|
|
|
+ } else {
|
|
|
+ this.toast.show('删除失败,请联系管理员');
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ this.toast.show('删除失败,请联系管理员');
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ * 该方法用于调整表格body高度
|
|
|
+ * @param {number} headerAndPage 头部和分页部件高度和
|
|
|
+ * @returns {number} table body Y方向高度
|
|
|
+ */
|
|
|
+ resizeTableHeight(headerAndPage) {
|
|
|
+ const cardBodyH = this.domObj.find('.tbContainer').height();
|
|
|
+ return cardBodyH - headerAndPage;
|
|
|
+ }
|
|
|
+ destroy() {
|
|
|
+ this.afterDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+export = ProjectNewsManagement;
|