| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- /**
- * 产品库
- */
- Ext.define('saas.view.sale.b2b.Product', {
- extend: 'saas.view.core.base.BasePanel',
- xtype: 'sale-b2b-product',
- viewName: 'sale-b2b-Product',
- // dataUrl: 'http://10.1.80.23:8560/api/document/product/prodStorage/list',
- dataUrl: '/api/document/product/prodStorage/list',
- initComponent: function() {
- var me = this;
- Ext.apply(this, {
- searchField: [{
- xtype: 'textfield',
- name: 'keyword',
- columnWidth: 0.2,
- emptyText:'物料编号/名称/型号/品牌',
- getCondition: function(value) {
- return ' (prodCode like\'%' + value + '%\' or prodBrand like \'%'+value+'%\' or prodName like \'%'+value+'%\' or prodOriSpeccode like \'%'+value+'%\') ';
- }
- }, {
- xtype: 'combobox',
- name: 'b2bStatus',
- fieldLabel: '上传状态',
- queryMode: 'local',
- displayField: 'name',
- valueField: 'value',
- emptyText :'全部',
- value: 0,
- editable:true,
- labelWidth: 80,
- columnWidth: 0.2,
- store: Ext.create('Ext.data.ArrayStore', {
- fields: ['name', 'value'],
- data: [
- ["全部", "all"],
- ["待上传", "待上传"],
- ["已上传", "已上传"]
- ]
- }),
- getCondition: function(v) {
- if(v == 'all') {
- return '1=1'
- }else {
- return 'ifnull(b2bStatus,\'待上传\')=' + '\'' + v + '\'';
- }
- }
- }, {
- xtype: 'checkbox',
- name: 'status',
- fieldLabel: '我的产品库',
- columnWidth: 0.2,
- getCondition: function(v) {
- if(v) {
- return 'status=' + Number(v);
- }else {
- return '1=1';
- }
- }
- }],
- toolButtons: [{
- xtype: 'button',
- text: '上传公司产品',
- handler: function() {
- me.onUpload();
- }
- }],
-
- gridConfig: {
- dataUrl: me.dataUrl,
- actionColumn: [],
- selModel: {
- type: 'cellmodel'
- },
- hiddenTools: true,
- data: [{
- }],
- columns : [{
- text: '物料编号',
- dataIndex: 'prodCode',
- width: 150
- }, {
- text: '品牌',
- dataIndex: 'prodBrand',
- width: 100
- }, {
- text: '名称',
- dataIndex: 'prodName',
- width: 150
- }, {
- text: '型号',
- dataIndex: 'prodOrispeccode',
- width: 200
- }, {
- text: '规格',
- dataIndex: 'prodSpec',
- width: 200
- }, {
- text: '单位',
- width: 65.0,
- dataIndex: 'prodUnit'
- }, {
- text: '上传状态',
- dataIndex: 'b2bStatus',
- renderer: function(v, m, r) {
- return v || '待上传';
- }
- }, {
- text: '我的产品',
- dataIndex: 'status',
- xtype: 'actioncolumn',
- align : 'center',
- items: [{
- iconCls:'',
- getClass: function(v, meta, rec) {
- if(rec.get('status')){
- return 'x-grid-checkcolumn-checked-btn';
- }else{
- return 'x-grid-checkcolumn-btn';
- }
- },
- handler: function(view, rowIndex, colIndex) {
- var rec = view.getStore().getAt(rowIndex);
- // 禁用/启用
- var grid = this.ownerCt.ownerCt;
- var params = {
- prodId: rec.get('prodId'),
- prodCode: rec.get('prodCode'),
- operate: new Number(!rec.get('status'))
- };
- grid.setLoading(true);
- saas.util.BaseUtil.request({
- // url: 'http://10.1.80.23:8560/api/document/product/prodStorage/saler',
- url: '/api/document/product/prodStorage/saler',
- params: JSON.stringify(params),
- method: 'POST',
- })
- .then(function(localJson) {
- grid.setLoading(false);
- if(localJson.success){
- saas.util.BaseUtil.showSuccessToast('操作成功');
- grid.store.load();
- }
- })
- .catch(function(e) {
- grid.setLoading(false);
- saas.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
- });
- }
- }]
- }]
- },
- });
- this.callParent(arguments);
- },
- onUpload: function() {
- var me = this;
- me.setLoading(true);
- saas.util.BaseUtil.request({
- url: '/api/document/product/b2b/upload',
- method: 'POST',
- }).then(function(res) {
- me.setLoading(false);
- saas.util.BaseUtil.showSuccessToast('上传成功');
- me.refresh();
- }).catch(function(e) {
- me.setLoading(false);
- saas.util.BaseUtil.showErrorToast('上传失败: ' + e.message);
- });
- },
- });
|