You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/TruckMng/Viewsjs/MsWlTruck/CertView.js

160 lines
5.9 KiB
JavaScript

2 years ago
Ext.namespace('DsTruck');
var FilePath = '';
DsTruck.CertView = function (config) {
Ext.applyIf(this, config);
FilePath = config.filePath;
this.initUIComponents();
DsTruck.CertView.superclass.constructor.call(this);
};
Ext.regModel('CertType', {
fields: [{ name: 'value' }, { name: 'text'}]
})
var storeType = new Ext.data.Store({
model: 'CertType',
data: [
{ 'value': '0', 'text': '请选择' },
{ 'value': '1', 'text': '行车证' },
{ 'value': '2', 'text': '营运证' },
{ 'value': '3', 'text': '驾驶证' },
{ 'value': '4', 'text': '资格证' },
{ 'value': '5', 'text': '车辆照片' },
2 years ago
{ 'value': '6', 'text': '驾驶员身份证'}]
});
var cmbType = Ext.create('Ext.form.ComboBox', {
fieldLabel: '证件类型',
queryMode: 'local',
name: 'Cert_Type',
id: 'CertType',
triggerAction: 'all',
valueField: 'value',
displayField: 'text',
store: storeType,
listeners: {
afterRender: function (combo) {
var firstValue = storeType.data.items[0].data.value;
combo.setValue(firstValue); //同时下拉框会将与name为firstValue值对应的 text显示
}
}
});
var btnPrint = Ext.create("Ext.Button", {
text: "打印证件",
region: "north",
allowDepress: true, //是否允许按钮被按下的状态
enableToggle: true, //是否允许按钮在弹起和按下两种状态中切换
height: 30,
width: 80,
handler: function () {
Ext.MessageBox.confirm('提示', '确定打印此证件?', function (btn) {
if (btn == 'yes') {
var newstr = document.getElementsByName('certimg')[0].src;
printWindow = window.open(newstr);
printWindow.print();
return false;
} else {
}
});
},
id: "bt1"
});
Ext.extend(DsTruck.CertView, Ext.Window, {
ImgPath: null,
TruckNo: null,
initUIComponents: function () {
Ext.apply(this, {
height: 600,
modal: true,
width: 800,
layout: "border", //设置为手风琴布局
closable: true,
closeAction: 'hide',
draggable: true,
resizable: false,
items: [btnPrint
,
{
xtype: 'container',
//layout: 'hbox',
defaultType: 'textfield',
items: [
{
xtype: 'component', //或者xtype: 'component',renderTo: Ext.getBody(),
name: "CertImg",
//region: "center",
autoEl: {
top: 30,
tag: 'img', //指定为img标签
src: FilePath, //指定url路径
name: 'certimg',
style: 'max-width: 100%; max-height: 100%;'
}
}
]
2 years ago
}
//,{
// xtype: 'fieldcontainer',
// //fieldLabel: '图片',
// combineErrors: true,
// anchor: '100%',
// items: [
// //{
// //xtype: 'image',
// //src: FilePath, // 替换为你的图片路径
// //autoSize: true // 防止图片自动伸展
// //}
// {
// xtype: 'image',
// src: FilePath, // 替换为你的图片路径
// //autoSize: 'height',
// // 'width' 或者 'height', 'portrait', 'landscape'
// listeners: {
// afterrender: function (img) {
// _picWidth =(img.getWidth());
// _picHeight = (img.getHeight());
// rate = 1;
// rateWidth = 1;
// rateHeight = 1;
// if (_picHeight > this.height) {
// //img.setHeight(this.height)
// rateHeight = this.height / _picHeight;
// }
// if (_picWidth > this.width) {
// //img.setWidth(this.width);
// rateWidth = this.width / _picWidth;
// }
// rate = rateWidth;
// if (rateHeight < rate) rate = rateHeight;
// img.setHeight(_picHeight * rate);
// img.setWidth(_picWidth * rate);
// // 在图片加载后调整大小
// //img.setSize(img.getWidth(), img.getHeight());
// },
// resize: function (img, width, height, adjusted) {
// // 当容器大小变化时调整图片大小
// //if (adjusted) {
// // img.setSize(width, height);
// //}
// },
// scope: this
// }
// }
// ]
//}
],
2 years ago
xtype: "window"
});
}
});