FormPanelController.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 "CONCAT(cu_code, cu_name) like '%" + v + "%'";
  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. dbColumns:[
  129. {
  130. "text": "物料ID",
  131. "flex": 0,
  132. "dataIndex": "id",
  133. "width": 0,
  134. "xtype": "",
  135. "items": null
  136. },{
  137. "text": "物料编号",
  138. "flex": 1,
  139. "dataIndex": "pr_code",
  140. "width": 100,
  141. "xtype": "",
  142. "items": null
  143. }, {
  144. "text": "物料名称",
  145. "flex": 1,
  146. "dataIndex": "pr_detail",
  147. "xtype": "",
  148. "items": null
  149. }, {
  150. "text": "规格",
  151. "flex": 1,
  152. "dataIndex": "pr_spec",
  153. "width": 200,
  154. "xtype": "",
  155. "items": null
  156. }, {
  157. "text": "单位",
  158. "flex": 1,
  159. "dataIndex": "pr_unit",
  160. "width": 200,
  161. "xtype": "",
  162. "items": null
  163. }, {
  164. "text": "品牌",
  165. "flex": 1,
  166. "dataIndex": "pr_brand",
  167. "width": 200,
  168. "xtype": "",
  169. "items": null
  170. }, {
  171. "text": "供应商ID",
  172. "flex": 0,
  173. "dataIndex": "pr_vendid",
  174. "width": 0,
  175. "xtype": "",
  176. "items": null
  177. }, {
  178. "text": "供应商编号",
  179. "flex": 1,
  180. "dataIndex": "pr_vendcode",
  181. "width": 200,
  182. "xtype": "",
  183. "items": null
  184. }, {
  185. "text": "供应商名称",
  186. "flex": 1,
  187. "dataIndex": "pr_vendname",
  188. "width": 200,
  189. "xtype": "",
  190. "items": null
  191. }, {
  192. "text": "最小包装量",
  193. "flex": 1,
  194. "dataIndex": "pr_zxbzs",
  195. "width": 200,
  196. "xtype": "",
  197. "items": null
  198. }]
  199. }) ;
  200. }
  201. }
  202. });
  203. },
  204. delete: function(){
  205. var me = this;
  206. var form = this.getView();
  207. warnMsg('确定删除该单据吗?', function(btn){
  208. if(btn == 'yes'){
  209. var viewModel = me.getViewModel();
  210. var id = viewModel.get(form._idField);
  211. var code = viewModel.get(form._codeField);
  212. if(id&&id.value!=0){
  213. me.BaseUtil.request({
  214. url: form._deleteUrl+id,
  215. method: 'POST',
  216. })
  217. .then(function(localJson) {
  218. if(localJson.success){
  219. var mainTab = Ext.getCmp('main-tab-panel');
  220. mainTab.getActiveTab().close();
  221. //解析参数
  222. showToast('删除成功');
  223. }
  224. })
  225. .catch(function(res) {
  226. console.error(res);
  227. showToast('删除失败: ' + res.message);
  228. });
  229. }
  230. }
  231. });
  232. },
  233. turnOut: function() {
  234. var me = this,
  235. form = me.getView(),
  236. id = form.getForm().findField(form._idField);
  237. form.BaseUtil.request({
  238. url: form._turnOutUrl+id.value,
  239. method: 'POST',
  240. })
  241. .then(function(localJson) {
  242. if(localJson.success){
  243. var intValue = localJson.data.id,
  244. codeValue= localJson.data.code,
  245. name = localJson.data.name;
  246. openTab('sale-saleout-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  247. initId: intValue
  248. });
  249. showToast('转单成功');
  250. form.FormUtil.loadData(form);
  251. }
  252. })
  253. .catch(function(res) {
  254. console.error(res);
  255. showToast('转单失败: ' + res.message);
  256. });
  257. }
  258. });