1 this.AddGridColumns = [
2 { text: "产品Id", width: 150, dataIndex: 'MaterialId', sortable: false, hidden: true },
3 { text: "产品名称", flex: 1, dataIndex: "MaterialName", sortable: false },
4 { text: "数量(千克)", width: 150, sortable: false, dataIndex: 'BasicCount', renderer: DateRenderer, editor: { xtype: 'numberfield', minValue: 0} },
5 { text: "数量", width: 150, sortable: false, dataIndex: 'CommodityCount', renderer: DateRenderer, editor: { xtype: 'numberfield', minValue: 0} },
6 { text: "单位", sortable: false, header: '单位数量', dataIndex: 'Unit', width: 100, field: { xtype: 'combobox', typeAhead: true, triggerAction: 'all', editable: false, selectOnTab: true, store: [['微克', '微克'], ['毫克', '毫克'], ['克', '克'], ['千克', '千克'], ['吨', '吨']], lazyRender: true, listClass: 'x-combo-list-small'}}];
7 this.AddGridFields = [{ name: "MaterialId" }, { name: "MaterialName" }, { name: "BasicCount" }, { name: "CommodityCount" }, { name: "Unit"}];
8 this.AddGridStore = Ext.create('Ext.data.Store', {
9 fields: myThis.AddGridFields,
10 autoLoad: true,
11 proxy: {
12 extraParams: {
13 operate: 'LoadData_TempPProductOrder',
14 str: ''
15 },
16 type: 'ajax',
17 url: myThis.url,
18 reader: {
19 type: 'json',
20 root: 'rows'
21 }
22 },
23 fields: myThis.AddGridFields,
24 remoteSort: true
25 });
26 this.AddGrid = Ext.create("Ext.grid.Panel", {
27 autoScorll: true,
28 height: 298,
29 tbar: [{ text: '添加产品', iconCls: 'icon-add',
30 handler: function () {
31 myThis.popupWindowMaterialMessage.show();
32 }
33 }, { text: '删除产品', iconCls: 'icon-delete',
34 handler: function () {
35 var selrows = myThis.AddGrid.getSelectionModel().getSelection();
36 myThis.AddGridStore.remove(selrows);
37 var nodes = myThis.AddGrid.getView().getNodes();
38 var tempArr = [];
39 if (nodes.length != 0) {
40 for (var i = 0; i < nodes.length; i++) {
41 tempArr.push(nodes[i].children[1].children[0].innerHTML);
42 }
43 myThis.PProductOrderIDS_Temp = tempArr.join(',');
44 } else if (nodes.length == 0) {
45 myThis.PProductOrderIDS_Temp = '';
46 }
47 }
48 }],
49 plugins: [
50 Ext.create('Ext.grid.plugin.CellEditing', {
51 clicksToEdit: 2
52 })
53 ],
54 iconCls: 'icon-grid',
55 store: myThis.AddGridStore,
56 selModel: new Ext.selection.CheckboxModel(),
57 columns: myThis.AddGridColumns
58 });
59 myThis.AddGrid.on('edit', function (editor, e) {
60 if (e.value == null || e.value == undefined || e.value == "") {
61 e.record.set("BasicCount", 1);
62 e.record.set("CommodityCount", 1);
63 e.record.commit();
64 myThis.AddGrid.getView().refresh();
65 Ext.Msg.alert('提示', '请输入正确的数量!');
66 }
67 else {
68 ////BasicCount CommodityCount Unit
69 var nodes = myThis.AddGrid.getView().getNodes();
70 for (var i = 0; i < nodes.length; i++) {
71
72 var unitNum =myThis.GetUnitNum(e.record.data.Unit);
73 debugger
74 var CommodityCount = e.record.data.CommodityCount;
75
76 var BasicCount = CommodityCount/ unitNum ;
77 e.record.set("BasicCount", BasicCount);
78 e.record.set("CommodityCount", CommodityCount);
79 e.record.commit();
80 myThis.AddGrid.getView().refresh();
81 }
82 }
83
84 });