|
@@ -0,0 +1,217 @@
|
|
|
+import BaseWidget = require('core/BaseWidget.class');
|
|
|
+import AjaxSend = require("common/AjaxSend.class")
|
|
|
+export = MaintenanceTypeManage;
|
|
|
+
|
|
|
+class MaintenanceTypeManage extends BaseWidget {
|
|
|
+ baseClass = "widget-MaintenanceTypeManage";
|
|
|
+ toast = null;
|
|
|
+ popup = null;
|
|
|
+ dataTable = null;
|
|
|
+ ajaxSend = null;
|
|
|
+ searchInfo = null;
|
|
|
+
|
|
|
+ startup() {
|
|
|
+ this.configure();
|
|
|
+ this.initHtml();
|
|
|
+ this.initEvent();
|
|
|
+ }
|
|
|
+ initHtml() {
|
|
|
+ var html = _.template(this.template.split('$$')[0] + "</div>")();
|
|
|
+ this.setHtml(html);
|
|
|
+ this.ready();
|
|
|
+ this.getInfoList()
|
|
|
+ }
|
|
|
+
|
|
|
+ configure() {
|
|
|
+ this.toast = this.AppX.runtimeConfig.toast;
|
|
|
+ this.popup = this.AppX.runtimeConfig.popup;
|
|
|
+ this.ajaxSend=new AjaxSend();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ initEvent() {
|
|
|
+ this.domObj.find('.btn_search').on("click", function () {
|
|
|
+ this.getInfoList()
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
+ this.domObj.find('.btn_add').on("click", function () {
|
|
|
+
|
|
|
+ this.popup.setSize(600, 450);
|
|
|
+ var Obj = this.popup.show("新增", this.template.split('$$')[1]);
|
|
|
+
|
|
|
+ (<any>$('#MaintenanceTypeManage_addpopup')).bootstrapValidator();
|
|
|
+ Obj.submitObj.off("click").on("click", function () {
|
|
|
+ var name = Obj.conObj.find(".name");
|
|
|
+ var type = Obj.conObj.find('.type option:selected');
|
|
|
+ var note = Obj.conObj.find(".note");
|
|
|
+ if (name.val() == '') {
|
|
|
+ name.addClass('has-error');
|
|
|
+ name.attr("placeholder", "不能为空!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (type.val() == '') {
|
|
|
+ type.addClass('has-error');
|
|
|
+ type.attr("placeholder", "不能为空!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var data = {
|
|
|
+ "name": name.val(),
|
|
|
+ "type": type.val(),
|
|
|
+ "note": note.val()
|
|
|
+ };
|
|
|
+ this.ajaxSend.sendAjax(this, data, this.config.addHiddenDangerDevice, this.ajaxSend.type.post, this.addHiddenDangerDeviceCallback.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
+ this.domObj.find('.btn_edit').on("click", function () {
|
|
|
+ let dataInfo = this.dataTable.aExtentData.currentTableData;
|
|
|
+ if (!dataInfo) {
|
|
|
+ this.toast.show("请选择要修改的数据!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.popup.setSize(600, 450);
|
|
|
+ var Obj = this.popup.show("修改", this.template.split('$$')[2]);
|
|
|
+
|
|
|
+ Obj.conObj.find('.name').val(dataInfo.name);
|
|
|
+ Obj.conObj.find('.type').val(dataInfo.type);
|
|
|
+ Obj.conObj.find('.note').val(dataInfo.note);
|
|
|
+
|
|
|
+ (<any>$('#MaintenanceTypeManage_updatepopup')).bootstrapValidator();
|
|
|
+ Obj.submitObj.off("click").on("click", function () {
|
|
|
+ var name = Obj.conObj.find(".name");
|
|
|
+ var type = Obj.conObj.find('.type');
|
|
|
+ var note = Obj.conObj.find('.note');
|
|
|
+ if (name.val() == '') {
|
|
|
+ name.addClass('has-error');
|
|
|
+ name.attr("placeholder", "不能为空!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (type.val() == '') {
|
|
|
+ type.addClass('has-error');
|
|
|
+ type.attr("placeholder", "不能为空!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var data = {
|
|
|
+ "id": dataInfo.id,
|
|
|
+ "name": name.val(),
|
|
|
+ "type": type.val(),
|
|
|
+ "note": note.val()
|
|
|
+ };
|
|
|
+ this.ajaxSend.sendAjax(this, data, this.config.updateHiddenDangerDevice, this.ajaxSend.type.put, this.updateHiddenDangerDeviceCallback.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
+ this.domObj.find('.btn_delete').on("click", function () {
|
|
|
+ let dataInfo = this.dataTable.aExtentData.currentTableData;
|
|
|
+ if (!dataInfo) {
|
|
|
+ this.toast.show("请选择要删除的数据!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.popup.setSize(300, 200);
|
|
|
+ var Obj = this.popup.show("删除", this.template.split('$$')[4]);
|
|
|
+ Obj.submitObj.off("click").on("click", function () {
|
|
|
+ var data = {};
|
|
|
+ var url = this.config.deleteHiddenDangerDevice + dataInfo.id;
|
|
|
+ this.ajaxSend.sendAjax(this, data, url, this.ajaxSend.type.delete, this.deleteHiddenDangerDeviceCallback.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+ }.bind(this));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 双击查看
|
|
|
+ * */
|
|
|
+ lookInfo() {
|
|
|
+ let dataInfo = this.dataTable.aExtentData.currentTableData;
|
|
|
+ if (!dataInfo) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dataInfo.id == "") {
|
|
|
+ this.toast.show("请选择一位用户");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.popup.setSize(600, 450);
|
|
|
+ var Obj = this.popup.show("查看", this.template.split('$$')[3], true);
|
|
|
+
|
|
|
+ Obj.conObj.find('.name').val(dataInfo.name);
|
|
|
+ Obj.conObj.find('.note').val(dataInfo.note);
|
|
|
+ Obj.conObj.find('.type').val(dataInfo.typeName);
|
|
|
+ Obj.submitObj.off("click").on("click", function () {
|
|
|
+ this.popup.close();
|
|
|
+ }.bind(this));
|
|
|
+ }
|
|
|
+
|
|
|
+ addHiddenDangerDeviceCallback(results) {
|
|
|
+ if (!this.ajaxSend.checkResults(this, results)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.popup.close();
|
|
|
+ this.getInfoList();
|
|
|
+ this.toast.show("新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ updateHiddenDangerDeviceCallback(results) {
|
|
|
+ if (!this.ajaxSend.checkResults(this, results)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.popup.close();
|
|
|
+ this.getInfoList();
|
|
|
+ this.toast.show("修改成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteHiddenDangerDeviceCallback(results) {
|
|
|
+ if (!this.ajaxSend.checkResults(this, results)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.popup.close();
|
|
|
+ this.getInfoList();
|
|
|
+ this.toast.show("删除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取查询条件
|
|
|
+ * */
|
|
|
+ getSearchInfo() {
|
|
|
+ this.searchInfo = {
|
|
|
+ name: this.domObj.find(".search_condition").val()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 渲染出列表
|
|
|
+ * */
|
|
|
+ getInfoList() {
|
|
|
+ this.loadWait.show("正在查询数据,请耐心等待...", this.domObj);
|
|
|
+ let that = this;
|
|
|
+ this.getSearchInfo();
|
|
|
+ if (that.dataTable) {
|
|
|
+ that.dataTable.ajax.reload();
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ let option = {
|
|
|
+ that: this,
|
|
|
+ dataTable: that.dataTable,
|
|
|
+ elementId: "hiddendangerdeviceinfotable",
|
|
|
+ url: this.config.getHiddenDangerDeviceList,
|
|
|
+ isCheck: false,
|
|
|
+ searchInfo: that.searchInfo,
|
|
|
+ displayTitle: ["巡检类型名称", "类型", "备注"],
|
|
|
+ displayField: ["name", "typeName", "note"],
|
|
|
+ beforeTrClickEvent: undefined,
|
|
|
+ afterTrClickEvent: function () {
|
|
|
+ this.domObj.off('dblclick', '#hiddendangerdeviceinfotable tr').on('dblclick', "#hiddendangerdeviceinfotable tr", e => {
|
|
|
+ this.lookInfo();
|
|
|
+ })
|
|
|
+ }.bind(this),
|
|
|
+ errmassage: "设备类型查询失败",
|
|
|
+ nullmessage: undefined,
|
|
|
+ exportTitle: "设置类型"
|
|
|
+ }
|
|
|
+ that.dataTable = this.ajaxSend.DataTables_check(option);
|
|
|
+ }
|
|
|
+
|
|
|
+ destroy() {
|
|
|
+ this.domObj.remove();
|
|
|
+ this.afterDestroy();
|
|
|
+ }
|
|
|
+}
|