| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656 |
- Ext.define('saas.view.purchase.quotationList.DataList', {
- extend: 'Ext.grid.Panel',
- xtype: 'purchase-quotationList-datalist',
- controller: 'purchase-quotationList-datalist',
- viewModel: 'purchase-quotationList-datalist',
- autoScroll: true,
- style:'border:1px solid #fff',
- cls:'x-quotation-main',
- layout:'fit',
-
- dataUrl:'/api/purchase/purchase/inquiry/list',
- quotationListUrl:'/api/commons/number/delete/',
- plugins: [{
- ptype: 'menuclipboard'
- },{
- ptype: 'rowwidget',
- setupRowData: function(record, rowIndex, rowValues) {
- var me = this.rowExpander;
- me.rowBodyFeature = this;
- rowValues.rowBodyCls = me.recordsExpanded[record.internalId] ? '' : me.rowBodyHiddenCls;
- if(record.get('qutations')==null){
- this.rowExpander.expanderColumn.setWidth(0)
- }else{
- this.rowExpander.expanderColumn.setWidth(40)
- }
- },
- widget: {
- frame:true,
- cls:'x-quotation-detail',
- xtype: 'grid',
- plugins: [{
- ptype: 'menuclipboard'
- }],
- bind: {
- store: '{record.qutations}'
- },
- columns: [{
- text: '供应商名称',
- dataIndex: 'vendName',
- width: 175
- }, {
- text: '联系电话',
- dataIndex: 'tel',
- width: 265
- }, {
- text: '替代型号',
- dataIndex: 'replaceOrispeccode',
- width: 100,
- }, {
- width: 120,
- text: '交期',
- dataIndex: 'leadTime'
- }, {
- width: 120,
- text: '税率',
- dataIndex: 'taxRate'
- }, {
- width: 120,
- text: '梯度/价格',
- dataIndex: 'replies',
- renderer:function(val, meta, record,x,y,store, view){
- if(val==null||val==''){
- return '<div style="text-align: center;color:#34baf6;">暂无</div>';
- }
- var id = record.id;
- var renderName=this.columns[y].dataIndex;
- var grid = view.ownerCt;
- var columnId;
- Ext.Array.each(grid.columns, function(c, index){
- if(c.dataIndex=='replies'){
- columnId = c.id
- }
- });
- if(!view.tip || view.tip.createFrom != renderName) {
- view.tip = Ext.create('Ext.tip.ToolTip', {
- target: view.el,
- delegate: '.x-grid-cell-'+columnId,
- trackMouse: true,
- createFrom:renderName,
- renderTo: Ext.getBody(),
- maxWidth :830,
- layout:'anchor',
- listeners: {
- beforeshow: function updateTipBody(tip) {
- var dg = Ext.getCmp('grid-'+id);
- var rowindex = tip.triggerElement.parentNode.rowIndex;
- var rec = Ext.getCmp(grid.id).getStore().getAt(rowindex);
- dg.store.loadData(rec.get('replies'));
- dg.show();
- }
- },
- items : [Ext.create('Ext.grid.Panel', {
- id: 'grid-'+id,
- frame:true,
- anchor: '100% 100%',
- width:205,
- store:[],
- columns: [{
- text: '分段数量',
- dataIndex: 'lapQty',
- width: 110,
- renderer:function(v,m,rec){
- return '≥' +v
- }
- }, {
- text: '分段价格',
- dataIndex: 'price',
- width: 90
- }]
- })]
- });
- }
- return '<div style="text-align: center;color:#34baf6;">查看报价信息</div>';
- }
- }, {
- width: 200,
- text: '操作',
- dataIndex: 'agreed',
- renderer:function(val, meta, record,x,y,store, view){
- var id = record.get('id');
- window.sendMessage = function(id,status,refusereason){
- var params = {
- id:id,
- status:status,
- refusereason:refusereason
- };
- Ext.Ajax.request({
- url : '/api/purchase/purchase/inquiry/deal',
- timeout: 8000,
- headers:{
- 'Access-Control-Allow-Origin': '*',
- 'Authorization': saas.util.State.get('session').token,
- "Content-Type": 'application/json;charset=UTF-8'
- },
- method: 'POST',
- params:JSON.stringify(params),
- success: function(response, o){
- var res = Ext.decode(response.responseText);
- if(res.success){
- Ext.getCmp('main-tab-panel').getActiveTab().items.items[0].store.loadPage(1);
- saas.util.BaseUtil.showSuccessToast('操作成功');
- }else{
- saas.util.BaseUtil.showErrorToast('操作失败:'+res.message);
- }
- },
- failure: function (response, opts) {
- saas.util.BaseUtil.showErrorToast('操作失败,请重试');
- }
- });
- };
- window.checkPrice = function(status,id){
- if(status=='0'){
- var panel = view.ownerCt.ownerCmp.ownerCt;
- var win = Ext.create('Ext.window.Window', {
- renderTo: panel.getEl(),
- cls:'x-window-dbfind',
- height: 100,
- width: 450,
- modal:true,
- title: '提示',
- bodyPadding: 10,
- constrain: true,
- closable: true,
- layout: {
- type: 'vbox',
- align: 'center'
- },
- items:[{
- xtype:'panel',
- layout:'hbox',
- items:[{
- margin:'0 10 0 0',
- labelWidth:60,
- xtype : "textfield",
- name : "refusereason",
- fieldLabel : "拒绝信息"
- },{
- margin:'0 0 0 5',
- xtype:'button',
- text:'确认',
- handler:function(b){
- var refusereason = b.ownerCt.down('[name=refusereason]').value;
- window.sendMessage(id,status,refusereason);
- b.ownerCt.ownerCt.close();
- }
- }]
- }]
- });
- win.show();
- }else if(status=='1'){
- window.sendMessage(id,status,'');
- }
- }
- window.showRefuse = function(msg){
- var panel = view.ownerCt.ownerCmp.ownerCt;
- var win = Ext.create('Ext.window.Window', {
- renderTo: panel.getEl(),
- cls:'x-window-dbfind',
- height: 100,
- width: 450,
- modal:true,
- title: '查看',
- bodyPadding: 10,
- constrain: true,
- closable: true,
- layout: {
- type: 'vbox',
- align: 'center'
- },
- items:[{
- xtype:'panel',
- layout:'hbox',
- items:[{
- margin:'0 10 0 0',
- labelWidth:60,
- xtype : "displayfield",
- name : "refusereason",
- fieldLabel : "拒绝信息",
- value:msg
- }]
- }]
- });
- win.show();
- }
- if((!val||val=='')&&val!=0){
- //未采纳状态
- return '<div style="width:100%;vertical-align: middle; text-align: center;">'+
- "<input type='button' value='采纳' name='agree' style='border: 1px solid;color:#34baf6;cursor:pointer;background:#fff;' onClick='window.checkPrice(1,"+id+")'>"+
- "<input type='button' value='拒绝' name='disagree' style='margin:0 0 0 20px;border: 1px solid;color:#ff0000;cursor:pointer;background:#fff;' onClick='window.checkPrice(0,"+id+")'>"+
- '</div>';
- }else if(val==1||val=='1'){
- return '<div style="color:#34baf6;width:100%;vertical-align: middle; text-align: center;">已采纳</div>'
- }else if(val==0||val=='0'){
- var refusereason = record.get('refusereason');
- if(!refusereason||refusereason==''){
- return '<div style="color:#ff6c00;width:100%;vertical-align: middle; text-align: center;">已拒绝</div>'
- }else{
- return '<div style="width:100%;vertical-align: middle; text-align: center;">'+
- "<input type='button' value='查看拒绝理由' name='showRefuse' style='border: 1px solid;color:#ff6c00;cursor:pointer;background:#fff;' onClick='window.showRefuse("+refusereason+")'></input>"+
- '</div>';
- }
- }
- }
- }]
- }
- }],
- tbar: [{
- bodyStyle:'padding:0px 10px 0 0',
- xtype:'panel',
- layout:'column',
- height:75,
- width:'100%',
- rbar:{style:'padding:0',items:[{
- xtype:'button',
- cls:'x-formpanel-btn-blue',
- text:'查询',
- listeners: {
- click:function(b){
- var grid = b.ownerCt.ownerCt.ownerCt.ownerCt;
- grid.condition = grid.getConditions();
- grid.store.loadPage(1);
- }
- }
- },{
- style:'text-align: center;',
- xtype:'displayfield',
- value:'<a href=\"javascript:saas.util.BaseUtil.openTab(\'purchase-sendQuotation-datalist\',\'发起询价\',\'maintab-query-sendQuotation\')\">立即询价</a>'
- }]},
- items:[{
- columnWidth:0.33,
- name: 'search',
- xtype: 'textfield',
- emptyText : '请输入供应商名称/物料编号/品牌/名称/型号',
- enableKeyEvents: true,
- getCondition: function (value) {
- return value;
- },
- listeners: {
- keydown: {
- fn: function(th, e, eOpts) {
- if(e.keyCode == 13) {
- var grid = th.up('grid');
- grid.condition = grid.getConditions();
- grid.store.loadPage(1);
- }
- }
- }
- }
- },{
- columnWidth:0.33,
- xtype: 'combobox',
- name: 'quoted',
- fieldLabel: '报价状态',
- allowBlank: true,
- value:1,
- editable: false,
- queryMode: 'local',
- displayField: 'pi_status',
- valueField: 'pi_statuscode',
- store: Ext.create('Ext.data.ArrayStore', {
- fields: ['pi_statuscode', 'pi_status'],
- data: [
- [1, "已报价"],
- [0, "未报价"]
- ]
- }),
- getCondition: function (value) {
- return null
- }
- },{
- columnWidth:0.33,
- xtype: 'combobox',
- name: 'overdue',
- fieldLabel: '截止状态',
- allowBlank: true,
- value:0,
- editable: false,
- queryMode: 'local',
- displayField: 'pi_status',
- valueField: 'pi_statuscode',
- store: Ext.create('Ext.data.ArrayStore', {
- fields: ['pi_statuscode', 'pi_status'],
- data: [
- [1, "已截止"],
- [0, "未截止"]
- ]
- }),
- getCondition: function (value) {
- return null
- }
- },{
- margin:'10px 0 0 0',
- columnWidth:0.5,
- xtype: 'condatefield',
- name: '_date',
- fieldLabel: '日期',
- operation: 'between'
- }]
- }],
- columns : [{
- text : 'id',
- width : 0,
- dataIndex : 'id',
- xtype : 'numbercolumn',
- hidden:true
- },{
- text : '物料编号',
- width : 200.0,
- dataIndex : 'prodCode',
- xtype : '',
- },
- {
- text : '品牌',
- dataIndex : 'prodBrand',
- width : 110.0,
- xtype : '',
- },
- {
- text : '名称',
- dataIndex : 'prodName',
- width : 150.0
- },{
- text : '型号',
- dataIndex : 'prodOrispeccode',
- width : 110.0
- },{
- text : '规格',
- dataIndex : 'prodSpec',
- width : 110.0
- },{
- text : '单位',
- dataIndex : 'prodUnit',
- width : 110.0
- },{
- text : '发起时间',
- dataIndex : 'startDate',
- width : 160.0
- },{
- text : '截止日期',
- dataIndex : 'endDate',
- width : 160.0
- },{
- text : '报价状态',
- dataIndex : 'qutations',
- width : 110.0,
- renderer:function(val, meta, record,x,y,store, view){
- if(!val||val==0||val.length==0){
- return '否'
- }else{
- return '是'
- }
- }
- }, {
- dataIndex: '',
- flex: 1
- }],
- dbSearchFields: [],
- condition:'',
- initComponent: function() {
- var me = this;
- if(me.columns){
- var fields = me.columns.map(column => column.dataIndex);
- me.store = Ext.create('Ext.data.Store',{
- fields:fields,
- autoLoad: true,
- pageSize: 15,
- proxy: {
- timeout:8000,
- type: 'ajax',
- headers:{
- 'Access-Control-Allow-Origin': '*',
- "Content-Type": 'application/json;charset=UTF-8'
- },
- url: me.dataUrl,
- actionMethods: {
- read: 'GET'
- },
- reader: {
- type: 'json',
- rootProperty: 'data.content',
- totalProperty: 'data.totalElements',
- }
- },
- listeners: {
- beforeload: function (store, op) {
- var date = Ext.ComponentQuery.query('[name=_date]')[0];
- var from = date.value.from || '';
- if(!Ext.isDate(from)){
- from = new Date(from);
- from = from.getTime()
- }else{
- from = date.value.from.getTime()
- }
- var to = date.value.to || '';
- if(!Ext.isDate(to)){
- to = new Date(to);
- to = to.getTime()
- }else{
- to = date.value.to.getTime()
- }
- var search = Ext.ComponentQuery.query('[name=search]')[0].value;
- var quoted = Ext.ComponentQuery.query('[name=quoted]')[0].value;
- var overdue = Ext.ComponentQuery.query('[name=overdue]')[0].value;
- Ext.apply(store.proxy.extraParams, {
- keyword :search,//search==''?' ':search,
- pageNumber: op._page,
- pageSize: store.pageSize,
- quoted:quoted,
- fromDate:from,
- endDate:to,
- overdue:overdue
- });
- }
- }
- });
- Ext.apply(me, {
- dockedItems:[{
- xtype: 'pagingtoolbar',
- dock: 'bottom',
- displayInfo: true,
- store: me.store
- }]
- });
- }
- me.callParent(arguments);
- },
- listeners:{
- boxready: function(grid, width, height, eOpts) {
- var store = grid.getStore(),
- gridBodyBox = grid.body.dom.getBoundingClientRect(),
- gridBodyBoxHeight = gridBodyBox.height;
- var pageSize = Math.floor(gridBodyBoxHeight / 33);
- store.setPageSize(pageSize);
- grid.ownerCt.el.dom.style.left = '8px';
- grid.el.dom.style.padding = '0px'
- },
- itemClick: function(view,record,a,index,c) {
- }
- },
- getGridSelected:function(type){
- var isErrorSelect = false;
- var checkField = this.statusCodeField;
- var me = this,
- items = me.selModel.getSelection(),
- data = new Array() ;
- Ext.each(items, function(item, index){
- if(!Ext.isEmpty(item.data[me.idField])){
- var o = new Object();
- if(me.idField){
- o['id'] = item.data[me.idField];
- }
- if(me.codeField){
- o['code'] = item.data[me.codeField];
- }
- if(type&&type==item.data[checkField]){
- isErrorSelect = true
- }
- data.push(o);
- }
- });
- if(isErrorSelect){
- return false;
- }
- return data;
- },
- /**
- * 获得过滤条件
- */
- getConditions: function() {
- var me = this,
- tbar = me.getDockedItems()[0],
- items = Ext.Array.filter(tbar.items.items, function(item) {
- return !!item.name;
- }),
- conditions = [];
- for(var i = 0; i < items.length; i++) {
- var item = items[i];
- var field = item.name,
- func = item.getCondition,
- value = item.value,
- condition;
- if(value&&value!=''){
- if(typeof func == 'function') {
- condition = {
- type: 'condition',
- value: func(value)
- }
- }else {
- var type = item.fieldType || me.getDefaultFieldType(item),
- operation = item.operation || me.getDefaultFieldOperation(item),
- conditionValue = me.getConditionValue(item, value);
-
- if(!conditionValue) {
- continue;
- }
- condition = {
- type: type,
- field: field,
- operation: operation,
- value: conditionValue
- }
- }
- conditions.push(condition);
- }
- }
- return conditions;
- },
- /**
- * 只要arr1和arr2中存在相同项即返回真
- */
- isContainsAny: function (arr1, arr2) {
- for (var i = 0; i < arr2.length; i++) {
- var a2 = arr2[i];
- if (!!arr1.find(function (a1) {
- return a1 == a2
- })) {
- return true;
- }
- }
- return false;
- },
- getDefaultFieldType: function (field) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- type;
- if (me.isContainsAny(xtypes, ['numberfield'])) {
- type = 'number';
- } else if (me.isContainsAny(xtypes, ['datefield', 'condatefield', 'conmonthfield'])) {
- type = 'date';
- } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
- type = 'enum';
- } else if (me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
- type = 'enum';
- } else {
- type = 'string';
- }
- return type;
- },
- getDefaultFieldOperation: function (field) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- operation;
- if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
- operation = '=';
- } else if (me.isContainsAny(xtypes, ['condatefield', 'conmonthfield'])) {
- operation = 'between';
- } else if (me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
- operation = 'in';
- } else {
- operation = 'like';
- }
- return operation;
- },
- /**
- * 处理部分字段值
- */
- getConditionValue: function (field, value) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- conditionValue;
- if (me.isContainsAny(xtypes, ['datefield'])) {
- conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
- } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
- var from = value.from,
- to = value.to;
- conditionValue = from + ',' + to;
- } else if (me.isContainsAny(xtypes, ['condatefield'])) {
- var from = value.from,
- to = value.to;
- conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
- } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
- conditionValue = value;
- } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
- conditionValue = '\'' + value + '\'';
- } else if (me.isContainsAny(xtypes, ['multicombo'])) {
- conditionValue = value.map ? value.map(function (v) {
- return '\'' + v.value + '\'';
- }).join(',') : '';
- } else {
- conditionValue = value;
- }
- return conditionValue;
- }
- })
|