Ext.namespace('Shipping');
Shipping.MsInfoClientFeedbackEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsInfoClientFeedbackEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsInfoClientFeedbackEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
initUIComponents: function () {
//#region gridList列表 下拉框信息加载
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "modMsInfoClientFeedback"} });
//问答类型
Ext.define('REMARKTYPENAMEModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] });
var dataREMARKTYPENAME = [{ "Name": "问" }, { "Name": "答"}];
this.storeREMARKTYPENAME = Ext.create('Ext.data.Store', { model: 'REMARKTYPENAMEModel', data: dataREMARKTYPENAME });
this.comboxREMARKTYPENAME = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '类型',
forceSelection: true,
store: this.storeREMARKTYPENAME,
id: 'REMARKTYPENAME',
valueField: 'Name',
displayField: 'Name',
allowBlank: false
});
//客户维护方式
this.storeInfoClassACTION = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.MsInfoClassModel',
proxy: { url: '/CommMng/BasicDataRef/GetMsInfoClass' }
});
this.storeInfoClassACTION.load({ params: { condition: "parentID='CI20170122000001' and del_sign=0"} });
this.comboxInfoClassACTION = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '维护方式',
store: this.storeInfoClassACTION,
forceSelection: false, //输入值是否严格为待选列表中存在的值
//matchFieldWidth: false, //下拉款自适应宽度
//allowBlank: false,
name: 'ACTION',
valueField: 'CLASSNAME',
displayField: 'CLASSNAME',
value: ''
});
//#endregion
//#region 信息显示录入面板
this.formHead = Ext.widget('form', {
region: 'north',
frame: true,
fieldDefaults: {
labelAlign: 'right',
flex: 1,
labelWidth: 60,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '反馈编号',
name: 'FEEDBACKID',
readOnly: true
},
{
fieldLabel: '信息状态',
name: 'STATUS',
readOnly: true
},
{
fieldLabel: '客户名称',
name: 'COMPANYID',
readOnly: true
},
{
fieldLabel: '客户项目',
name: 'PROJECT',
readOnly: true
},{
fieldLabel: '开始时间',
name: 'BEGINDATE',
readOnly: true
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{ xtype: 'hiddenfield', height: 10}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '反馈类型',
name: 'FEEDBACKTYPE',
readOnly: true
}, {
fieldLabel: '维护类型',
name: 'STLNAME',
readOnly: true
}, this.comboxInfoClassACTION, {
fieldLabel: '维护费用',
name: 'EXPENSE',
align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '' + lsValue + '';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}, { xtype: 'hiddenfield' }]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{ xtype: 'hiddenfield', height: 10}]
}]
});
//#endregion
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsInfoClientFeedbackInfoEntity',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/SoftMng/MsInfoClientFeedback/GetFeedbackInfoList',
reader: {
id: 'REMARKID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 定义Grid
this.girdcolums = [{
dataIndex: 'REMARKID',
hidden: true,
width: 0
}, {
dataIndex: 'REMARKTYPENAME',
header: '类型',
width: 40,
editor: this.comboxREMARKTYPENAME
}, {
dataIndex: 'REMARK',
header: '问题',
width: 500,
editor: {
xtype: 'textareafield',
selectOnFocus: true,
grow: true,
height: '100%',
anchor: '100%'
}
// ,renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
// //ExtJS3中实现自适应行高
// /*metadata.attr = 'style="white-space:normal;"';
// return value;*/
// //ExtJS4中实现自适应行高
// return '
' + value + '
'
// }
}];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击,2双击
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
region: 'center',
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
enableColumnHide: false, //隐藏表头列
sortableColumns: false, //隐藏表头排序
trackMouseOver: true, //高亮显示鼠标所在的行,默认为true,
disableSelection: false, //是否禁止选择表格行或列,默认为false
//stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
//autoHeight: true,
loadMask: { msg: "数据加载中,请稍等..." },
//selType: 'cellmodel',
plugins: [this.gridListCellEditing],
columns: this.girdcolums,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region gridList函数
this.gridList.on('cellclick', function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
if (cellIndex == 2) {
sName = record.data.REMARK.toString().trim().replace(/
/g, "\r\n");
record.set("REMARK", sName);
}
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
//
//#region 保存
var dataHead = this.formHead.getForm().getValues(false, false, false);
var member = e.record;
sName = member.data.REMARK.toString().trim().replace(/
/g, "\r\n");
member.set("REMARK", sName);
//
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SoftMng/MsInfoClientFeedback/SaveFeedbackInfo',
scope: this,
params: {
dataHead: Ext.JSON.encode(dataHead),
data: Ext.JSON.encode(member.data)
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
member.set("REMARK", jsonresult.Data.REMARK.toString().trim().replace(/\r\n/g, "
"));
e.record.commit();
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
});
//#endregion
}, this);
//#endregion
//#region 页面布局
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: '添加明细',
tooltip: '添加',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick();
},
scope: this
}, {
text: "删除明细",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}]
}); //end 按钮Toolbar
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
border: false,
items: [this.panelBtn, this.formHead]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
//#endregion
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit') {
condition = " FEEDBACKID='" + this.editRecord.get('FEEDBACKID') + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.bodyDel = [];
this.opStatus = opstatus;
if (this.opStatus == 'add') {
var basicForm = this.formHead.getForm();
basicForm.reset();
basicForm.findField('FEEDBACKID').setDisabled(false);
basicForm.findField('FEEDBACKID').setValue("*");
basicForm.findField('FEEDBACKID').setDisabled(true);
}
else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SoftMng/MsInfoClientFeedback/GetData',
params: {
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK });
return;
}
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: condition }, waitMsg: "正在查询数据...", scope: this });
//this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}, // end LoadDate
//#region 新增
onAddClick: function () {
var n = this.storeList.getCount();
var record = Ext.create('MsInfoClientFeedbackInfoEntity', {
REMARKID: '*', //编号
REMARKTYPENAME: '答', //类型
REMARK: '' //问题
});
this.storeList.add(record);
//this.storeList.insert(0, record);
this.gridListCellEditing.startEditByPosition({ row: n, column: 2 }); //n
},
//#endregion
//#region 删除
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (selections[0].data.REMARKTYPENAME.toString() == "问") {
Ext.Msg.show({ title: '提示', msg: '客户的问题不允许删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/SoftMng/MsInfoClientFeedback/DeleteFeedbackInfo',
params: {
data: Ext.JSON.encode(selections[0].data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var condition = " FEEDBACKID='" + this.editRecord.get('FEEDBACKID') + "'";
this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: condition }, waitMsg: "正在查询数据...", scope: this });
Ext.Msg.hide();
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
//#endregion
GetEditStatus: function () {
var canedit = false;
var sMODIFYUSERGID = this.formHead.getForm().findField('sMODIFYUSERGID').getValue();
_this = this;
this.StoreOpRange.load({ params: { optype: "modMsInfoClientFeedback" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', sMODIFYUSERGID);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
}
});