FormPanelController.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. Ext.define('saas.view.sale.sale.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.sale-sale-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. //放大镜赋值关系 以及 tpl模板
  8. 'dbfindtrigger[name=sa_custname]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. dataUrl:'/api/document/customer/dbfind',
  12. addXtype: 'document-customer-formpanel',
  13. addTitle: '客户资料',
  14. defaultCondition:"cu_statuscode='OPEN'",
  15. dbfinds:[
  16. {
  17. from:'id',to:'sa_custid'
  18. },{
  19. from:'cu_code',to:'sa_custcode'
  20. },{
  21. from:'cu_name',to:'sa_custname'
  22. },{
  23. from:'ca_address',to:'sa_toplace'
  24. }],
  25. dbtpls:[{
  26. field:'cu_code',width:100
  27. },{
  28. field:'cu_name',width:100
  29. }],
  30. dbSearchFields:[{
  31. emptyText:'输入客户编号或客户名称',
  32. xtype : "textfield",
  33. name : "search",
  34. getCondition: function(v) {
  35. return "(upper(cu_code) like '%"+v.toUpperCase()+"%' or upper(cu_name) like '%"+v.toUpperCase()+"%')";
  36. },
  37. allowBlank : true,
  38. columnWidth : 0.25
  39. }],
  40. dbColumns:[
  41. {
  42. conditionCode:'id',
  43. "text": "客户ID",
  44. "flex": 0,
  45. "dataIndex": "id",
  46. "width": 0,
  47. "xtype": "",
  48. "items": null
  49. },{
  50. conditionCode:'cu_code',
  51. "text": "客户编号",
  52. "flex": 1,
  53. "dataIndex": "cu_code",
  54. "width": 100,
  55. "xtype": "",
  56. "items": null
  57. }, {
  58. conditionCode:'cu_name',
  59. "text": "客户名称",
  60. "flex": 1,
  61. "dataIndex": "cu_name",
  62. "xtype": "",
  63. "items": null
  64. }, {
  65. conditionCode:'cu_type',
  66. "text": "客户类型",
  67. "flex": 1,
  68. "dataIndex": "cu_type",
  69. "width": 200,
  70. "xtype": "",
  71. "items": null
  72. }, {
  73. "text": "业务员编号",
  74. "flex": 1,
  75. "dataIndex": "cu_sellercode",
  76. "width": 100
  77. }, {
  78. "text": "业务员",
  79. "flex": 1,
  80. "dataIndex": "cu_sellername",
  81. "width": 100
  82. }, {
  83. "text": "税率",
  84. "flex": 1,
  85. "dataIndex": "cu_taxrate",
  86. "width": 100
  87. }, {
  88. "text": "承付天数",
  89. "flex": 1,
  90. "dataIndex": "cu_promisedays",
  91. "width": 100
  92. }, {
  93. "text": "额度",
  94. "flex": 1,
  95. "dataIndex": "cu_credit",
  96. "width": 100
  97. }, {
  98. "text": "客户地址",
  99. "flex": 1,
  100. "dataIndex": "ca_address",
  101. "width": 250
  102. }]
  103. }) ;
  104. }
  105. },
  106. //放大镜赋值关系 以及 tpl模板
  107. 'multidbfindtrigger[name=sd_prodcode]':{
  108. beforerender:function(f){
  109. Ext.apply(f,{
  110. dataUrl:'/api/document/product/list',
  111. addXtype: 'document-product-formpanel',
  112. addTitle: '物料资料',
  113. dbfinds:[
  114. {
  115. from:'pr_code',to:'sd_prodcode'
  116. }, {
  117. from:'pr_detail',to:'pr_detail'
  118. }, {
  119. from:'pr_spec',to:'pr_spec'
  120. }, {
  121. from:'id',to:'sd_prodid'
  122. }],
  123. dbtpls:[{
  124. field:'pr_code',width:100
  125. },{
  126. field:'pr_detail',width:100
  127. }],
  128. defaultCondition: "pr_statuscode='OPEN'",
  129. dbSearchFields:[{
  130. emptyText:'输入物料编号、名称或规格',
  131. xtype : "textfield",
  132. name : "search",
  133. width: 200,
  134. getCondition: function(v) {
  135. return "(upper(pr_spec) like '%" + v.toUpperCase()+"%' or upper(pr_code) like '%"+v.toUpperCase()+"%' or upper(pr_detail) like '%"+v.toUpperCase()+"%')";
  136. },
  137. allowBlank : true,
  138. columnWidth : 0.25
  139. }],
  140. dbColumns:[{
  141. "text": "物料ID",
  142. "hidden": true,
  143. "dataIndex": "id",
  144. }, {
  145. "text": "物料编号",
  146. "dataIndex": "pr_code",
  147. "width": 200,
  148. }, {
  149. "text": "物料名称",
  150. "width": 200,
  151. "dataIndex": "pr_detail",
  152. }, {
  153. "text": "规格",
  154. "dataIndex": "pr_spec",
  155. "width": 100,
  156. }, {
  157. "text": "单位",
  158. "dataIndex": "pr_unit",
  159. "width": 100,
  160. },{
  161. "text": "仓库id",
  162. "dataIndex": "pr_whid",
  163. "hidden": true,
  164. },{
  165. "text": "仓库编号",
  166. "dataIndex": "pr_whcode",
  167. "hidden": true,
  168. },{
  169. "text": "仓库",
  170. "dataIndex": "pr_whname",
  171. "width": 200,
  172. },{
  173. "text": "总库存数",
  174. "dataIndex": "po_onhand",
  175. "width": 100,
  176. },{
  177. "text": "类型",
  178. "dataIndex": "pr_kind",
  179. "width": 100,
  180. },{
  181. "text": "型号",
  182. "dataIndex": "pr_orispeccode",
  183. "width": 100,
  184. },{
  185. "text": "品牌",
  186. "dataIndex": "pr_brand",
  187. "width": 100,
  188. },{
  189. "text": "供应商",
  190. "dataIndex": "pr_vendname",
  191. "width": 100,
  192. },{
  193. "text": "最小包装",
  194. "dataIndex": "pr_zxbzs",
  195. "width": 100,
  196. },{
  197. "text": "L/T",
  198. "dataIndex": "pr_leadtime",
  199. "width": 100,
  200. }]
  201. }) ;
  202. }
  203. }
  204. });
  205. },
  206. delete: function(){
  207. var me = this;
  208. var form = this.getView();
  209. warnMsg('确定删除该单据吗?', function(btn){
  210. if(btn == 'yes'){
  211. var viewModel = me.getViewModel();
  212. var id = viewModel.get(form._idField);
  213. var code = viewModel.get(form._codeField);
  214. if(id&&id.value!=0){
  215. me.BaseUtil.request({
  216. url: form._deleteUrl+id,
  217. method: 'POST',
  218. })
  219. .then(function(localJson) {
  220. if(localJson.success){
  221. var mainTab = Ext.getCmp('main-tab-panel');
  222. mainTab.getActiveTab().close();
  223. //解析参数
  224. showToast('删除成功');
  225. }
  226. })
  227. .catch(function(res) {
  228. console.error(res);
  229. showToast('删除失败: ' + res.message);
  230. });
  231. }
  232. }
  233. });
  234. },
  235. turnOut: function() {
  236. var me = this,
  237. form = me.getView(),
  238. id = form.getForm().findField(form._idField);
  239. form.BaseUtil.request({
  240. url: form._turnOutUrl+id.value,
  241. method: 'POST',
  242. })
  243. .then(function(localJson) {
  244. if(localJson.success){
  245. var intValue = localJson.data.id,
  246. codeValue= localJson.data.code,
  247. name = localJson.data.name;
  248. openTab('sale-saleout-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  249. initId: intValue
  250. });
  251. showToast('转单成功');
  252. form.FormUtil.loadData(form);
  253. }
  254. })
  255. .catch(function(res) {
  256. console.error(res);
  257. showToast('转单失败: ' + res.message);
  258. });
  259. }
  260. });