sysinit.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. Ext.define("Ext.grid.column.Combo", {
  2. extend : "Ext.grid.column.Column",
  3. alias : ["widget.combocolumn"],
  4. constructor : function(a) {
  5. this.editor = arguments[0].editor;
  6. this.callParent(arguments);
  7. this.renderer = this.renderer || function(a, b, c, x, y, s, v){
  8. if(!Ext.isEmpty(a)) {
  9. var g = v.ownerCt,h =b.column,f = h.field, k;
  10. if ((k = (h.editor || h.filter)) && k.store) {
  11. var t = null,dd = k.store.data;
  12. t = Ext.Array.filter(dd, function(d, index){
  13. return d.value == a;
  14. });
  15. if (t && t.length > 0) {
  16. return t[0].display;
  17. }
  18. } else if (f) {
  19. if(f.store) {
  20. var t = f.store.findRecord('value', a);
  21. if (t)
  22. return t.get('display');
  23. } else
  24. return f.rawValue;
  25. }
  26. return a;
  27. }
  28. };
  29. }
  30. });
  31. Ext.define('Ext.ux.CellDragDrop', {
  32. extend: 'Ext.AbstractPlugin',
  33. alias: 'plugin.celldragdrop',
  34. uses: ['Ext.view.DragZone'],
  35. /**
  36. * @cfg {Boolean} enforceType
  37. * Set to `true` to only allow drops of the same type.
  38. *
  39. * Defaults to `false`.
  40. */
  41. enforceType: false,
  42. /**
  43. * @cfg {Boolean} applyEmptyText
  44. * If `true`, then use the value of {@link #emptyText} to replace the drag record's value after a node drop.
  45. * Note that, if dropped on a cell of a different type, it will convert the default text according to its own conversion rules.
  46. *
  47. * Defaults to `false`.
  48. */
  49. applyEmptyText: false,
  50. /**
  51. * @cfg {Boolean} emptyText
  52. * If {@link #applyEmptyText} is `true`, then this value as the drag record's value after a node drop.
  53. *
  54. * Defaults to an empty string.
  55. */
  56. emptyText: '',
  57. /**
  58. * @cfg {Boolean} dropBackgroundColor
  59. * The default background color for when a drop is allowed.
  60. *
  61. * Defaults to green.
  62. */
  63. dropBackgroundColor: 'green',
  64. /**
  65. * @cfg {Boolean} noDropBackgroundColor
  66. * The default background color for when a drop is not allowed.
  67. *
  68. * Defaults to red.
  69. */
  70. noDropBackgroundColor: 'red',
  71. //<locale>
  72. /**
  73. * @cfg {String} dragText
  74. * The text to show while dragging.
  75. *
  76. * Two placeholders can be used in the text:
  77. *
  78. * - `{0}` The number of selected items.
  79. * - `{1}` 's' when more than 1 items (only useful for English).
  80. */
  81. dragText: '{0} selected row{1}',
  82. //</locale>
  83. /**
  84. * @cfg {String} ddGroup
  85. * A named drag drop group to which this object belongs. If a group is specified, then both the DragZones and
  86. * DropZone used by this plugin will only interact with other drag drop objects in the same group.
  87. */
  88. ddGroup: "GridDD",
  89. /**
  90. * @cfg {Boolean} enableDrop
  91. * Set to `false` to disallow the View from accepting drop gestures.
  92. */
  93. enableDrop: true,
  94. /**
  95. * @cfg {Boolean} enableDrag
  96. * Set to `false` to disallow dragging items from the View.
  97. */
  98. enableDrag: true,
  99. /**
  100. * @cfg {Object/Boolean} containerScroll
  101. * True to register this container with the Scrollmanager for auto scrolling during drag operations.
  102. * A {@link Ext.dd.ScrollManager} configuration may also be passed.
  103. */
  104. containerScroll: false,
  105. init: function (view) {
  106. var me = this;
  107. view.on('render', me.onViewRender, me, {
  108. single: true
  109. });
  110. },
  111. destroy: function () {
  112. var me = this;
  113. Ext.destroy(me.dragZone, me.dropZone);
  114. },
  115. enable: function () {
  116. var me = this;
  117. if (me.dragZone) {
  118. me.dragZone.unlock();
  119. }
  120. if (me.dropZone) {
  121. me.dropZone.unlock();
  122. }
  123. me.callParent();
  124. },
  125. disable: function () {
  126. var me = this;
  127. if (me.dragZone) {
  128. me.dragZone.lock();
  129. }
  130. if (me.dropZone) {
  131. me.dropZone.lock();
  132. }
  133. me.callParent();
  134. },
  135. onViewRender: function (view) {
  136. var me = this,
  137. scrollEl;
  138. if (me.enableDrag) {
  139. if (me.containerScroll) {
  140. scrollEl = view.getEl();
  141. }
  142. me.dragZone = new Ext.view.DragZone({
  143. view: view,
  144. ddGroup: me.dragGroup || me.ddGroup,
  145. dragText: me.dragText,
  146. containerScroll: me.containerScroll,
  147. scrollEl: scrollEl,
  148. getDragData: function (e) {
  149. var view = this.view,
  150. item = e.getTarget(view.getItemSelector()),
  151. record = view.getRecord(item),
  152. clickedEl = e.getTarget(view.getCellSelector()),
  153. dragEl;
  154. if (item) {
  155. dragEl = document.createElement('div');
  156. dragEl.className = 'x-form-text';
  157. dragEl.appendChild(document.createTextNode(clickedEl.textContent || clickedEl.innerText));
  158. //修改 单元格不能拖动
  159. if (view.getGridColumns()[clickedEl.cellIndex].enableDrag===false) return;
  160. return {
  161. event: new Ext.EventObjectImpl(e),
  162. ddel: dragEl,
  163. item: e.target,
  164. columnName: view.getGridColumns()[clickedEl.cellIndex].dataIndex,
  165. record: record
  166. };
  167. }
  168. },
  169. onInitDrag: function (x, y) {
  170. var self = this,
  171. data = self.dragData,
  172. view = self.view,
  173. selectionModel = view.getSelectionModel(),
  174. record = data.record,
  175. el = data.ddel;
  176. if (!selectionModel.isSelected(record)) {
  177. selectionModel.select(record, true);
  178. }
  179. self.ddel.update(el.textContent || el.innerText);
  180. self.proxy.update(self.ddel.dom);
  181. self.onStartDrag(x, y);
  182. return true;
  183. }
  184. });
  185. }
  186. if (me.enableDrop) {
  187. me.dropZone = new Ext.dd.DropZone(view.el, {
  188. view: view,
  189. ddGroup: me.dropGroup || me.ddGroup,
  190. containerScroll: true,
  191. getTargetFromEvent: function (e) {
  192. var self = this,
  193. v = self.view,
  194. cell = e.getTarget(v.cellSelector),
  195. row, columnIndex;
  196. // Ascertain whether the mousemove is within a grid cell.
  197. if (cell) {
  198. row = v.findItemByChild(cell);
  199. columnIndex = cell.cellIndex;
  200. if (row && Ext.isDefined(columnIndex)) {
  201. //修改 单元格不能拖动
  202. if (self.view.up('grid').columns[columnIndex].enableDrop===false) return;
  203. return {
  204. node: cell,
  205. record: v.getRecord(row),
  206. columnName: self.view.up('grid').columns[columnIndex].dataIndex
  207. };
  208. }
  209. }
  210. },
  211. // On Node enter, see if it is valid for us to drop the field on that type of column.
  212. onNodeEnter: function (target, dd, e, dragData) {
  213. var self = this,
  214. destType = target.record.fields.get(target.columnName).type.type.toUpperCase(),
  215. sourceType = dragData.record.fields.get(dragData.columnName).type.type.toUpperCase();
  216. delete self.dropOK;
  217. // Return if no target node or if over the same cell as the source of the drag.
  218. if (!target || target.node === dragData.item.parentNode) {
  219. return;
  220. }
  221. // Check whether the data type of the column being dropped on accepts the
  222. // dragged field type. If so, set dropOK flag, and highlight the target node.
  223. if (me.enforceType && destType !== sourceType) {
  224. self.dropOK = false;
  225. if (me.noDropCls) {
  226. Ext.fly(target.node).addCls(me.noDropCls);
  227. } else {
  228. Ext.fly(target.node).applyStyles({
  229. backgroundColor: me.noDropBackgroundColor
  230. });
  231. }
  232. return;
  233. }
  234. self.dropOK = true;
  235. if (me.dropCls) {
  236. Ext.fly(target.node).addCls(me.dropCls);
  237. } else {
  238. Ext.fly(target.node).applyStyles({
  239. backgroundColor: me.dropBackgroundColor
  240. });
  241. }
  242. },
  243. // Return the class name to add to the drag proxy. This provides a visual indication
  244. // of drop allowed or not allowed.
  245. onNodeOver: function (target, dd, e, dragData) {
  246. return this.dropOK ? this.dropAllowed : this.dropNotAllowed;
  247. },
  248. // Highlight the target node.
  249. onNodeOut: function (target, dd, e, dragData) {
  250. var cls = this.dropOK ? me.dropCls : me.noDropCls;
  251. if (cls) {
  252. Ext.fly(target.node).removeCls(cls);
  253. } else {
  254. Ext.fly(target.node).applyStyles({
  255. backgroundColor: ''
  256. });
  257. }
  258. },
  259. // Process the drop event if we have previously ascertained that a drop is OK.
  260. onNodeDrop: function (target, dd, e, dragData) {
  261. if (this.dropOK) {
  262. target.record.set(target.columnName, dragData.record.get(dragData.columnName));
  263. /**
  264. * 同时覆盖其它信息
  265. * */
  266. target.record.set('fromname',dragData.record.get('jo_name'));
  267. target.record.set('fromid',dragData.record.get('jo_id'));
  268. if (me.applyEmptyText) {
  269. dragData.record.set(dragData.columnName, me.emptyText);
  270. }
  271. return true;
  272. }
  273. },
  274. onCellDrop: Ext.emptyFn
  275. });
  276. }
  277. }
  278. });
  279. var required = '<span style="color:red;font-weight:bold" data-qtip="必填字段">*</span>';
  280. var columnRequired=function(val){
  281. return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
  282. '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
  283. };
  284. Ext.ns('SYSNIT');
  285. SYSINIT={
  286. GRIDCOLUMNS:{
  287. SALE_CUSTOMERKIND:[{
  288. text:'类型编号',
  289. dataIndex:'ck_code'
  290. },{
  291. text:'类型名称',
  292. dataIndex:'ck_kind'
  293. },{
  294. text:'前缀码',
  295. dataIndex:'ck_excode'
  296. },{
  297. text:'当前数值',
  298. dataIndex:'ck_maxnum'
  299. },{
  300. text:'流水码长度',
  301. dataIndex:'ck_length'
  302. },{
  303. text:'备注信息',
  304. dataIndex:'ck_remark'
  305. },{
  306. text:'ID',
  307. dataIndex:'ck_id',
  308. width:0
  309. }],
  310. SALE_SALEKIND:[{
  311. text:'类型编号',
  312. dataIndex:'sk_code'
  313. },{
  314. text:'类型名称',
  315. dataIndex:'sk_name'
  316. },{
  317. text:'编号前缀',
  318. dataIndex:'sk_excode'
  319. },{
  320. text:'冲销触发类型',
  321. dataIndex:'sk_clashoption'
  322. },{
  323. text:'冲销匹配规则',
  324. dataIndex:'sk_clashfor'
  325. },{
  326. text:'附加冲销条件',
  327. dataIndex:'sk_clashkind'
  328. },{
  329. text:'所属公司',
  330. dataIndex:'sk_cop'
  331. },{
  332. text:'取价原则',
  333. dataIndex:'sk_pricekind'
  334. },{
  335. dataIndex: 'sk_allowzero',
  336. text:'是否允许零单价'
  337. },{
  338. dataIndex:'sk_outtype',
  339. text:'出货类型'
  340. },{
  341. dataIndex:'sk_mrp',
  342. text:'是否参与MRP'
  343. },{
  344. dataIndex:'sk_salecatecode',
  345. text:'销售收入科目编号'
  346. },{
  347. dataIndex:'sk_salecatename',
  348. text:'sk_salecatename'
  349. },{
  350. dataIndex:'sk_costcatecode',
  351. text:'主营成本科目编号'
  352. },{
  353. dataIndex:'sk_costcatename',
  354. text:'主营成本科目名称'
  355. },{
  356. dataIndex:'sk_id',
  357. text:'ID'
  358. }],
  359. SALE_PAYMENTSSALE:[{
  360. dataIndex:'pa_code',
  361. text:'收款方式编号'
  362. },{
  363. dataIndex:'pa_beginby',
  364. text:'计算起始日'
  365. },{
  366. dataIndex:'pa_monthadd',
  367. text:'月增加'
  368. },{
  369. dataIndex:'pa_dayadd',
  370. text:'日增加'
  371. },{
  372. dataIndex:'pa_valid',
  373. text:'是否有效'
  374. },{
  375. text:'收款方式名称',
  376. dataIndex:'pa_name'
  377. },{
  378. text:'折扣率',
  379. dataIndex:'pa_discount'
  380. },{
  381. text:'币别',
  382. dataIndex:'pa_currency'
  383. },{
  384. text:'科目编号',
  385. dataIndex:'pa_catecode'
  386. },{
  387. text:'科目名称',
  388. dataIndex:'pa_catename'
  389. }],
  390. SALE_SALEFORECASTKIND:[{
  391. text:'类型编号',
  392. dataIndex:'sf_code'
  393. },{
  394. text:'类型名称',
  395. dataIndex:'sf_name'
  396. },{
  397. text:'编号字头',
  398. dataIndex:'sf_excode'
  399. },{
  400. text:'冲销类型',
  401. dataIndex:'sf_clashfor'
  402. },{
  403. text:'冲销选项',
  404. dataIndex:'sf_clashoption'
  405. },{
  406. text:'销售收入科目',
  407. dataIndex:'sf_salecatecode'
  408. },{
  409. text:'主营成本科目',
  410. dataIndex:'sf_costcatecode'
  411. },{
  412. text:'是否参与MRP',
  413. dataIndex:'sf_mrp'
  414. },{
  415. text:'ID',
  416. dataIndex:'sf_id'
  417. }],
  418. SALE_BORROWCARGOTYPE:[{
  419. text:'类型编号',
  420. dataIndex:'bt_code'
  421. },{
  422. text:'类型名称',
  423. dataIndex:'bt_name'
  424. },{
  425. text:'默认科目',
  426. dataIndex:'bt_catecode'
  427. },{
  428. text:'科目名称',
  429. dataIndex:'bt_catename'
  430. },{
  431. text:'是否参与MRP',
  432. dataIndex:'bt_ismrp'
  433. },{
  434. text:'ID',
  435. dataIndex:"bt_id'"
  436. }]
  437. }
  438. }
  439. var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';