buy_invoice_load.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <ul>
  2. {foreach name="inv_list" item="val" key="k" }
  3. <li class="inv_item {if $k=='0'}dsc-selected-item{/if}">
  4. <input content="{$val.content}" id="inv_{$val.invoice_id}" ds_type="inv" type="radio" name="inv" value="{$val.invoice_id}" {if $k=='0'}checked{/if}/>
  5. <label for="inv_{$val.invoice_id}">&nbsp;&nbsp;{$val.content}</label>
  6. &emsp;&emsp;&emsp;<a href="javascript:void(0);" onclick="delInv({$val.invoice_id});" class="del">[{$Think.lang.ds_delete}]</a>
  7. </li>
  8. {/foreach}
  9. <li class="inv_item">
  10. {if count($inv_list) < 10}
  11. <input value="0" ds_type="inv" id="add_inv" type="radio" name="inv">
  12. <label for="add_inv">&nbsp;&nbsp;{$Think.lang.new_invoice_information}</label>
  13. {else/}
  14. {$Think.lang.remove_unusual_invoice_additions}
  15. {/if}
  16. </li>
  17. <div id="add_inv_box" style="display:none">
  18. <form method="POST" id="inv_form" action="{:url('Buy/add_addr')}">
  19. <div class="dsc-form-default">
  20. <dl>
  21. <dt>{$Think.lang.invoice_type}:</dt>
  22. <dd>
  23. <label><input type="radio" checked name="invoice_type" value="1">{$Think.lang.commercial_invoice}</label>
  24. &emsp;&emsp;
  25. <label><input type="radio" name="invoice_type" value="2">{$Think.lang.vat_invoice}</label>
  26. </dd>
  27. </dl>
  28. </div>
  29. <div id="invoice_panel" class="dsc-form-default">
  30. <dl>
  31. <dt>{$Think.lang.invoice_title}:</dt>
  32. <dd>
  33. <!-- <select name="invoice_title_select">
  34. <option value="person">{$Think.lang.individual}</option>
  35. <option value="company">{$Think.lang.unit}</option>
  36. </select>-->
  37. <input class="text w200" name="invoice_title" id="invoice_title" value="">
  38. </dd>
  39. </dl>
  40. <dl id="invoice_code_dl">
  41. <dt>{$Think.lang.taxpayer_identification_number}</dt>
  42. <dd>
  43. <input type="text" class="text w200" maxlength="50" name="invoice_code" id="invoice_code" value="">
  44. </dd>
  45. </dl>
  46. <dl>
  47. <dt>{$Think.lang.invoice_content}:</dt>
  48. <dd>
  49. <!-- <select id="invoice_content" name="invoice_content">
  50. <option selected value="{$Think.lang.details}">{$Think.lang.details}</option>
  51. <option value="{$Think.lang.wine}">{$Think.lang.wine}</option>
  52. <option value="{$Think.lang.food}">{$Think.lang.food}</option>
  53. <option value="{$Think.lang.drink}">{$Think.lang.drink}</option>
  54. <option value="{$Think.lang.toys}">{$Think.lang.toys}</option>
  55. <option value="{$Think.lang.daily_necessities}">{$Think.lang.daily_necessities}</option>
  56. <option value="{$Think.lang.decoration_materials}">{$Think.lang.decoration_materials}</option>
  57. <option value="{$Think.lang.cosmetics}">{$Think.lang.cosmetics}</option>
  58. <option value="{$Think.lang.office_supplies}">{$Think.lang.office_supplies}</option>
  59. <option value="{$Think.lang.student_supplies}">{$Think.lang.student_supplies}</option>
  60. <option value="{$Think.lang.household_goods}">{$Think.lang.household_goods}</option>
  61. <option value="{$Think.lang.accessories}">{$Think.lang.accessories}</option>
  62. <option value="{$Think.lang.clothing}">{$Think.lang.clothing}</option>
  63. <option value="{$Think.lang.luggage}">{$Think.lang.luggage}</option>
  64. <option value="{$Think.lang.boutique}">{$Think.lang.boutique}</option>
  65. <option value="{$Think.lang.home_appliances}">{$Think.lang.home_appliances}</option>
  66. <option value="{$Think.lang.labor_protection_products}">{$Think.lang.labor_protection_products}</option>
  67. <option value="{$Think.lang.consumables}">{$Think.lang.consumables}</option>
  68. <option value="{$Think.lang.computer_accessories}">{$Think.lang.computer_accessories}</option>
  69. </select>-->
  70. <input type="text" class="text w200" maxlength="50" name="invoice_content" id="invoice_content" value="">
  71. </dd>
  72. </dl>
  73. </div>
  74. <div id="vat_invoice_panel" class="dsc-form-default" style="display:none">
  75. <dl>
  76. <dt><i class="required">*</i>{$Think.lang.company_name}:</dt>
  77. <dd>
  78. <input type="text" class="text w200" maxlength="50" name="invoice_company" value="">
  79. </dd>
  80. </dl>
  81. <dl>
  82. <dt><i class="required">*</i>{$Think.lang.taxpayer_identification_number}:</dt>
  83. <dd>
  84. <input type="text" class="text w200" maxlength="50" name="invoice_company_code" value="">
  85. </dd>
  86. </dl>
  87. <dl>
  88. <dt><i class="required">*</i>{$Think.lang.registered_address}:</dt>
  89. <dd>
  90. <input type="text" class="text w200" maxlength="50" name="invoice_reg_addr" value="">
  91. </dd>
  92. </dl>
  93. <dl>
  94. <dt><i class="required">*</i>{$Think.lang.registered_phone}:</dt>
  95. <dd>
  96. <input type="text" class="text w200" maxlength="50" name="invoice_reg_phone" value="">
  97. </dd>
  98. </dl>
  99. <dl>
  100. <dt><i class="required">*</i>{$Think.lang.bank_account}:</dt>
  101. <dd>
  102. <input type="text" class="text w200" maxlength="50" name="invoice_reg_bname" value="">
  103. </dd>
  104. </dl>
  105. <dl>
  106. <dt><i class="required">*</i>{$Think.lang.bank_accounts}:</dt>
  107. <dd>
  108. <input type="text" class="text w200" maxlength="50" name="invoice_reg_baccount" value="">
  109. </dd>
  110. </dl>
  111. <!-- <dl>
  112. <dt></dt>
  113. <dd>{$Think.lang.open_information}</dd>
  114. </dl>
  115. <dl>
  116. <dt><i class="required">*</i>{$Think.lang.invoice_content}:</dt>
  117. <dd>{$Think.lang.details}</dd>
  118. </dl>
  119. <dl>
  120. <dt><i class="required">*</i>{$Think.lang.name_of_bearer}:</dt>
  121. <dd>
  122. <input type="text" class="text w200" maxlength="50" name="invoice_rec_name" value="">
  123. </dd>
  124. </dl>
  125. <dl>
  126. <dt><i class="required">*</i>{$Think.lang.ticket_collector_number}:</dt>
  127. <dd>
  128. <input type="text" class="text w200" maxlength="50" name="invoice_rec_mobphone" value="">
  129. </dd>
  130. </dl>
  131. <dl>
  132. <dt><i class="required">*</i>{$Think.lang.drawee_province}:</dt>
  133. <dd id="region">
  134. <select>
  135. </select>
  136. <input type="hidden" value="" name="city_id" id="city_id">
  137. <input type="hidden" name="area_id" id="area_id" class="area_ids"/>
  138. <input type="hidden" name="area_info" id="area_info" class="area_names"/>
  139. </dd>
  140. </dl>
  141. <dl>
  142. <dt><i class="required">*</i>{$Think.lang.ticket_delivery_address}:</dt>
  143. <dd>
  144. <input type="text" class="text w200" maxlength="50" name="invoice_goto_addr" value="">
  145. </dd>
  146. </dl>-->
  147. </div>
  148. </form>
  149. </div>
  150. </ul>
  151. <div class="hr16"> <a id="hide_invoice_list" class="dsc-btn dsc-btn-red" href="javascript:void(0);">{$Think.lang.cart_step1_invoice_submit}</a> <a id="cancel_invoice" class="dsc-btn ml10" href="javascript:void(0);">{$Think.lang.no_invoice_required}</a></div>
  152. <script>
  153. var postResult = false;
  154. function delInv(id) {
  155. var url = HOMESITEURL+'/Buy/load_inv/id/'+id+'.html';
  156. $('#invoice_list').load(url);
  157. }
  158. $(function() {
  159. $.ajaxSetup({async: false});
  160. //不需要发票
  161. $('#cancel_invoice').on('click', function() {
  162. $('#invoice_id').val('');
  163. hideInvList('{$Think.lang.no_invoice_required}');
  164. });
  165. //使用新的发票信息
  166. $('input[ds_type="inv"]').on('click', function() {
  167. regionInit("region");
  168. if ($(this).val() == '0') {
  169. $('.inv_item').removeClass('dsc-selected-item');
  170. $('#add_inv_box').show();
  171. } else {
  172. $('.inv_item').removeClass('dsc-selected-item');
  173. $(this).parent().addClass('dsc-selected-item');
  174. $('#add_inv_box').hide();
  175. }
  176. });
  177. //保存发票信息
  178. $('#hide_invoice_list').on('click', function() {
  179. var content = '';
  180. if ($('input[name="inv"]:checked').size() == 0) {
  181. $('#cancel_invoice').click();
  182. return false;
  183. }
  184. if ($('input[name="inv"]:checked').val() != '0') {
  185. //如果选择已保存过的发票信息
  186. content = $('input[name="inv"]:checked').attr('content');
  187. $('#invoice_id').val($('input[name="inv"]:checked').val());
  188. hideInvList(content);
  189. return false;
  190. }
  191. //如果是新增发票信息
  192. if ($('input[name="invoice_type"]:checked').val() == 1) {
  193. //如果选择普通发票
  194. if ($('select[name="invoice_title_select"]').val() == 'person') {
  195. content = '{$Think.lang.ordinary_invoice_individual}' + $('select[name="invoice_content"]').val();
  196. } else if ($.trim($('#invoice_title').val()) == '' || $.trim($('#invoice_title').val()) == '{$Think.lang.company_name}') {
  197. layer.alert('{$Think.lang.fill_in_company_name}');
  198. return false;
  199. } else {
  200. content = '{$Think.lang.commercial_invoice} ' + $.trim($('#invoice_title').val()) + ' ' + $('#invoice_code').val() + ' ' + $('#invoice_content').val();
  201. }
  202. } else {
  203. content = '{$Think.lang.vat_invoice} ' + $.trim($('input[name="invoice_company"]').val()) + ' ' + $.trim($('input[name="invoice_company_code"]').val()) + ' ' + $.trim($('input[name="invoice_reg_addr"]').val());
  204. //验证增值税发票表单
  205. if (!$('#inv_form').valid()) {
  206. return false;
  207. }
  208. }
  209. var datas = $('#inv_form').serialize();
  210. $.post("{:url('Buy/add_inv')}", datas, function(data) {
  211. if (data.state == 'success') {
  212. $('#invoice_id').val(data.id);
  213. postResult = true;
  214. } else {
  215. layer.alert(data.msg);
  216. postResult = false;
  217. }
  218. }, 'json');
  219. if (postResult) {
  220. hideInvList(content);
  221. }
  222. });
  223. $('input[name="invoice_type"]').on('click', function() {
  224. if ($(this).val() == 1) {
  225. $('#invoice_panel').show();
  226. $('#vat_invoice_panel').hide();
  227. } else {
  228. $('#invoice_panel').hide();
  229. $('#vat_invoice_panel').show();
  230. }
  231. });
  232. $('select[name="invoice_title_select"]').on('change', function() {
  233. if ($(this).val() == 'company') {
  234. $('#invoice_title').show();
  235. $('#invoice_code_dl').show();
  236. } else {
  237. $('#invoice_title').hide();
  238. $('#invoice_code_dl').hide();
  239. }
  240. });
  241. $('#inv_form').validate({
  242. rules: {
  243. invoice_company: {
  244. required: true
  245. },
  246. invoice_company_code: {
  247. required: true
  248. },
  249. invoice_reg_addr: {
  250. required: true
  251. },
  252. invoice_reg_phone: {
  253. required: true
  254. },
  255. invoice_reg_bname: {
  256. required: true
  257. },
  258. invoice_reg_baccount: {
  259. required: true
  260. },
  261. invoice_rec_name: {
  262. required: true
  263. },
  264. invoice_rec_mobphone: {
  265. required: true
  266. },
  267. area_id: {
  268. required: true,
  269. min: 1,
  270. checkarea: true
  271. },
  272. invoice_goto_addr: {
  273. required: true
  274. }
  275. },
  276. messages: {
  277. invoice_company: {
  278. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.unit_name_cannot_empty}'
  279. },
  280. invoice_company_code: {
  281. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.taxpayer_identification_number_cannot_empty}'
  282. },
  283. invoice_reg_addr: {
  284. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.registered_address_cannot_empty}'
  285. },
  286. invoice_reg_phone: {
  287. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.registered_phone_cannot_empty}'
  288. },
  289. invoice_reg_bname: {
  290. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.opening_bank_cannot_empty}'
  291. },
  292. invoice_reg_baccount: {
  293. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.bank_accounts_cannot_empty}'
  294. },
  295. invoice_rec_name: {
  296. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.ticket_collector_name_empty}'
  297. },
  298. invoice_rec_mobphone: {
  299. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.ticket_collector_phone_empty}'
  300. },
  301. area_id: {
  302. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.please_select_region}',
  303. min: '<i class="iconfont">&#xe64c;</i>{$Think.lang.please_select_region}',
  304. checkarea: '<i class="iconfont">&#xe64c;</i>{$Think.lang.please_select_region}'
  305. },
  306. invoice_goto_addr: {
  307. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.ticket_delivery_address_empty}'
  308. }
  309. }
  310. });
  311. });
  312. </script>