loadSuggestbox.js 11 KB

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