loadSuggestbox.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. $(function() {
  2. //仓库
  3. $('#warehouseId').combogrid({
  4. url:WEBROOT+"/loadData.action?entity=warehouse",
  5. idField:'warehouseId',
  6. textField:'warehouseName',
  7. delay: 500,
  8. showHeader:false,
  9. mode: 'remote',
  10. columns:[[
  11. {field:'warehouseName',title:'仓库名称',width:155}
  12. ]],
  13. onBeforeLoad:function(param){
  14. //此设置使控件不会自动加载数据 这里不能使用this
  15. if (!$('#warehouseId').combogrid('getText'))
  16. {
  17. return false;
  18. }
  19. else
  20. {
  21. return true;
  22. }
  23. },onShowPanel:function(){
  24. //在第一次触发下拉框事件是加载数据
  25. if (!$(this).combogrid('getText'))
  26. {
  27. $(this).combogrid({onBeforeLoad:function(param){
  28. return true;
  29. }});
  30. }
  31. }
  32. });
  33. // 货主
  34. $('#customerId').combogrid({
  35. url : WEBROOT + "/loadData.action?entity=customer",
  36. idField : 'customerId',
  37. textField : 'customerName',
  38. delay : 500,
  39. mode : 'remote',
  40. showHeader : false,
  41. striped : true,
  42. columns : [[{field : 'customerName', width : '155'}]],
  43. onBeforeLoad : function(param) {
  44. // 此设置使控件不会自动加载数据 这里不能使用this
  45. if (!$("#customerId").combogrid('getText')) {
  46. return false;
  47. } else {
  48. return true;
  49. }
  50. },
  51. onShowPanel : function() {
  52. // 在第一次触发下拉框事件是加载数据
  53. if (!$(this).combogrid('getText')) {
  54. $(this).combogrid({
  55. onBeforeLoad : function(param) {
  56. return true;
  57. }
  58. });
  59. }
  60. }
  61. });
  62. // 某货主的客户
  63. $("#receiverId").combogrid({
  64. url:WEBROOT + "/loadData.action?entity=transceiver&isConsignee=1",
  65. mode: 'remote',
  66. idField : 'transceiverId',
  67. textField : 'transceiverName',
  68. delay: 500,
  69. showHeader : false,
  70. striped : true,
  71. columns:[[
  72. {field:'transceiverName',width:155}
  73. ]],
  74. onBeforeLoad:function(param){
  75. param.customerId = $("#customerId").combogrid('getValue');
  76. //此设置使控件不会自动加载数据
  77. if (!$('#receiverId').combogrid('getText'))
  78. {
  79. return false;
  80. }
  81. else
  82. {
  83. return true;
  84. }
  85. },
  86. onShowPanel:function(){
  87. //在第一次触发下拉框事件是加载数据
  88. if (!$(this).combogrid('getText'))
  89. {
  90. $(this).combogrid({onBeforeLoad:function(param){
  91. param.customerId = $("#customerId").combogrid('getValue');
  92. return true;
  93. }});
  94. }
  95. }
  96. });
  97. // 客户的地址
  98. $("#toTransceiverAddressId").combogrid({
  99. url:WEBROOT + "/loadData.action?entity=transceiverAddress",
  100. mode: 'remote',
  101. idField : 'id',
  102. textField : 'addressCode',
  103. delay: 500,
  104. showHeader : false,
  105. striped : true,
  106. columns:[[
  107. {field:'addressCode',width:155}
  108. ]],
  109. onBeforeLoad:function(param){
  110. param.transceiverId = $("#receiverId").combogrid('getValue');
  111. //此设置使控件不会自动加载数据
  112. if (!$('#toTransceiverAddressId').combogrid('getText'))
  113. {
  114. return false;
  115. }
  116. else
  117. {
  118. return true;
  119. }
  120. },
  121. onShowPanel:function(){
  122. //在第一次触发下拉框事件是加载数据
  123. if (!$(this).combogrid('getText'))
  124. {
  125. $(this).combogrid({onBeforeLoad:function(param){
  126. param.transceiverId = $("#receiverId").combogrid('getValue');
  127. return true;
  128. }});
  129. }
  130. },onSelectAfter:function(index,record)
  131. {
  132. getTransceiverAddressInfo(record.id);
  133. }
  134. });
  135. //产品
  136. $("#itemId").combogrid({
  137. url:WEBROOT + "/loadData.action?entity=item",
  138. mode: 'remote',
  139. idField : 'itemId',
  140. textField : 'itemName',
  141. delay: 500,
  142. showHeader : false,
  143. striped : true,
  144. columns:[[
  145. {field:'itemName',width:155}
  146. ]],
  147. onBeforeLoad:function(param){
  148. param.customerId = $("#customerId").combogrid('getValue');
  149. //此设置使控件不会自动加载数据
  150. if (!$('#itemId').combogrid('getText'))
  151. {
  152. return false;
  153. }
  154. else
  155. {
  156. return true;
  157. }
  158. },
  159. onShowPanel:function(){
  160. //在第一次触发下拉框事件是加载数据
  161. if (!$(this).combogrid('getText'))
  162. {
  163. $(this).combogrid({onBeforeLoad:function(param){
  164. param.customerId = $("#customerId").combogrid('getValue');
  165. return true;
  166. }});
  167. }
  168. },onSelectAfter:function(index,record)
  169. {
  170. }
  171. });
  172. //货主关系人
  173. $("#relationedCustomerId").combogrid({
  174. url:WEBROOT + "/loadData.action?entity=customerRelation",
  175. mode: 'remote',
  176. idField : 'relationedCustomerId',
  177. textField : 'relationedCustomerName',
  178. delay: 500,
  179. showHeader : false,
  180. striped : true,
  181. columns:[[
  182. {field:'relationedCustomerName',width:155}
  183. ]],
  184. onBeforeLoad:function(param){
  185. param.customerId = $("#customerId").combogrid('getValue');
  186. //此设置使控件不会自动加载数据
  187. if (!$('#relationedCustomerId').combogrid('getText'))
  188. {
  189. return false;
  190. }
  191. else
  192. {
  193. return true;
  194. }
  195. },
  196. onShowPanel:function(){
  197. //在第一次触发下拉框事件是加载数据
  198. if (!$(this).combogrid('getText'))
  199. {
  200. $(this).combogrid({onBeforeLoad:function(param){
  201. param.customerId = $("#customerId").combogrid('getValue');
  202. return true;
  203. }});
  204. }
  205. },onSelectAfter:function(index,record)
  206. {
  207. }
  208. });
  209. if( $("#carrierId") ){
  210. //承运商
  211. $("#carrierId").combogrid({
  212. url:WEBROOT + "/loadData.action?entity=vender&isCarrier=1",
  213. mode: 'remote',
  214. idField : 'venderId',
  215. textField : 'venderName',
  216. delay: 500,
  217. showHeader : false,
  218. striped : true,
  219. columns:[[
  220. {field:'venderName',width:155}
  221. ]],
  222. onBeforeLoad:function(param){
  223. //此设置使控件不会自动加载数据
  224. if (!$('#carrierId').combogrid('getText'))
  225. {
  226. return false;
  227. }
  228. else
  229. {
  230. return true;
  231. }
  232. },
  233. onShowPanel:function(){
  234. //在第一次触发下拉框事件是加载数据
  235. if (!$(this).combogrid('getText'))
  236. {
  237. $(this).combogrid({onBeforeLoad:function(param){
  238. return true;
  239. }});
  240. }
  241. },onSelectAfter:function(index,record)
  242. {
  243. }
  244. });
  245. }
  246. var $deliveryOutboundForm = $("#deliveryOutboundForm");
  247. var $receiverContactor = $deliveryOutboundForm.find("input[name='receiverContactor']");
  248. var $receiverStreet = $deliveryOutboundForm.find("input[name='receiverStreet']");
  249. var $receiverContactorPhone = $deliveryOutboundForm.find("input[name='receiverContactorPhone']");
  250. var $receiverContactorMobile = $deliveryOutboundForm.find("input[name='receiverContactorMobile']");
  251. var $toTransceiverAddressIdCombobox = $deliveryOutboundForm.find("input[name='toTransceiverAddressId']");
  252. var $countryCombobox = $deliveryOutboundForm.find("select[comboname='receiverCountry']");
  253. var $provinceCombobox = $deliveryOutboundForm.find("select[comboname='receiverProvince']");
  254. var $cityCombobox = $deliveryOutboundForm.find("select[comboname='receiverCity']");
  255. function initProvince(provinceVal, cityVal) {
  256. if($deliveryOutboundForm.find("input[name='receiverCountry']").val() != "") {
  257. ajaxRequest(WEBROOT + "/findGlobalLocation.action", {
  258. country : $deliveryOutboundForm.find("input[name='receiverCountry']").val()
  259. }, function(data) {
  260. $provinceCombobox.combobox("clear");
  261. $cityCombobox.combobox("clear");
  262. var datas = [];
  263. for (var i = 0, j = data.length; i < j; i++) {
  264. var ele = {};
  265. ele.value = data[i];
  266. ele.text = data[i];
  267. datas.push(ele);
  268. }
  269. $provinceCombobox.combobox("loadData", datas);
  270. if(provinceVal) {
  271. $provinceCombobox.combobox("setValue", provinceVal);
  272. initCity(cityVal);
  273. }
  274. });
  275. } else {
  276. $provinceCombobox.combobox({data:[]});
  277. $cityCombobox.combobox({data:[]});
  278. }
  279. }
  280. function initCity(cityVal) {
  281. if($deliveryOutboundForm.find("input[name='receiverCountry']").val() != "" && $deliveryOutboundForm.find("input[name='receiverProvince']").val() != "") {
  282. ajaxRequest(WEBROOT + "/findGlobalLocation.action", {
  283. country : $deliveryOutboundForm.find("input[name='receiverCountry']").val(),
  284. province : $deliveryOutboundForm.find("input[name='receiverProvince']").val()
  285. }, function(data) {
  286. $cityCombobox.combobox("clear");
  287. var datas = [];
  288. for (var i = 0, j = data.length; i < j; i++) {
  289. var ele = {};
  290. ele.value = data[i];
  291. ele.text = data[i];
  292. datas.push(ele);
  293. }
  294. $cityCombobox.combobox("loadData", datas);
  295. if(cityVal) {
  296. $cityCombobox.combobox("setValue", cityVal);
  297. }
  298. });
  299. }
  300. };
  301. $countryCombobox.combobox({//国家修改事件
  302. onSelect:function(){
  303. contentChange($.DeliveryOutboundEdit.changeList, $countryCombobox);
  304. initProvince();
  305. }
  306. });
  307. $provinceCombobox.combobox({//省修改事件
  308. onSelect:function(){
  309. contentChange($.DeliveryOutboundEdit.changeList, $provinceCombobox);
  310. initCity();
  311. }
  312. });
  313. function initTransceiverAddress(transceiverId, defaultAddressId) {
  314. ajaxRequest(WEBROOT + "/TransceiverAddress/getTransceiverAddressesInfo.action", {
  315. transceiverId : transceiverId
  316. }, function(resp) {
  317. $toTransceiverAddressIdCombobox.combobox("clear");
  318. var datas = [];
  319. for (var i = 0, j = resp.length; i < j; i++) {
  320. var ele = {};
  321. ele.id = resp[i].id;
  322. ele.addressCode = resp[i].addressCode;
  323. datas.push(ele);
  324. }
  325. $toTransceiverAddressIdCombobox.combobox("loadData", datas);
  326. if(defaultAddressId) {
  327. $toTransceiverAddressIdCombobox.combobox("setValue", defaultAddressId);
  328. getTransceiverAddressInfo(defaultAddressId);
  329. }
  330. });
  331. }
  332. function getTransceiverAddressInfo(id) {
  333. ajaxRequest(WEBROOT + "/TransceiverAddress/getTransceiverAddressInfo.action", {
  334. id : id
  335. }, function(data) {
  336. if(data) {
  337. $receiverContactor.val(data.accountContactor);
  338. $provinceCombobox.combobox("setValue", data.province);
  339. initCity(data.city);
  340. $receiverStreet.val(data.street);
  341. $receiverContactorPhone.val(data.phone);
  342. $receiverContactorMobile.val(data.personalPhone);
  343. }
  344. });
  345. }
  346. initProvince();
  347. });