charge_update.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <title>收费信息修改</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>车辆检测管理</cite></a>
  6. <a><cite>收费信息修改</cite></a>
  7. </div>
  8. </div>
  9. <div class="layui-fluid">
  10. <div class="layui-row layui-col-space15">
  11. <div class="layui-col-md12">
  12. <div class="layui-card">
  13. <!--<div class="layui-card-header">开启头部工具栏</div>-->
  14. <div class="layui-card-body">
  15. <div class="test-table-reload-btn" style="margin-bottom: 10px;">
  16. 搜索车牌:
  17. <div class="layui-inline">
  18. <input class="layui-input" name="车牌号" id="test-table-demoReload" style="text-transform:uppercase;">
  19. <!--autocomplete="off"-->
  20. </div>
  21. 检测日期:
  22. <div class="layui-input-inline">
  23. <input type="text" class="layui-input" id="test-laydate-range-date">
  24. </div>
  25. <button class="layui-btn" data-type="reload">搜索</button>
  26. </div>
  27. <table class="layui-hide" id="test-table-radio" lay-filter="test-table-radio"></table>
  28. <script type="text/html" id="test-table-radio-toolbarDemo">
  29. <div class="layui-btn-container">
  30. <button class="layui-btn layui-btn-sm" lay-event="edit">修改选择</button>
  31. </div>
  32. </script>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </body>
  39. <script>
  40. layui.use(['admin', 'table','layer','form','view','laydate'], function(){
  41. var admin = layui.admin
  42. ,$ = layui.$
  43. ,layer = layui.layer
  44. ,view = layui.view
  45. ,form = layui.form
  46. ,laydate = layui.laydate
  47. ,table = layui.table;
  48. table.render({
  49. elem: '#test-table-radio'
  50. ,url:'/charge/selectCharge'
  51. ,method:'post'
  52. // ,where:{"date":new Date()}
  53. ,toolbar: '#test-table-radio-toolbarDemo'
  54. ,even: true//隔行背景
  55. ,title: '收费记录数据表'
  56. ,cols: [[
  57. {type: 'radio', fixed: 'left'}
  58. ,{field:'license', title:'车牌', width:120}
  59. ,{field:'VIN', title:'车架号', width:120}
  60. ,{field:'owner', title:'所有人', width:120}
  61. ,{field:'EP_type', title:'环保类型', width:120}
  62. ,{field:'car_type', title:'安检类型', width:120}
  63. ,{field:'customer', title:'挂账客户', width:120}
  64. ,{field:'contracted_customer', title:'签约客户', width:120}
  65. ,{field:'EP_receivable', title:'环检应收', width:120}
  66. ,{field:'Safe_receivable', title:'安检应收', width:120}
  67. ,{field:'receivable', title:'应收总和', width:120}
  68. ,{field:'cost', title:'实收总和', width:120}
  69. ,{field:'telephone', title:'联系电话', width:120}
  70. ,{field:'date', title:'检测日期', width:120}
  71. ,{field:'remarks', title:'备注', width:120}
  72. // ,{fixed: 'right', title:'操作', toolbar: '#test-table-toolbar-barDemo', width:150}
  73. ]]
  74. ,page: true
  75. });
  76. laydate.render({
  77. elem: '#test-laydate-range-date'
  78. });
  79. var active = {
  80. reload: function(){
  81. var demoReload = $('#test-table-demoReload');
  82. var date = $('#test-laydate-range-date');
  83. //执行重载
  84. table.reload('test-table-radio', {
  85. where: {
  86. 'license': demoReload.val(),
  87. 'date': date.val()
  88. }
  89. ,page: {
  90. curr: 1 //重新从第 1 页开始
  91. }
  92. });
  93. }
  94. };
  95. $('.test-table-reload-btn .layui-btn').on('click', function(){
  96. var type = $(this).data('type');
  97. active[type] ? active[type].call(this) : '';
  98. });
  99. //头工具栏事件
  100. table.on('toolbar(test-table-radio)', function(obj){
  101. var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
  102. var data = checkStatus.data; //获取选中行数据
  103. switch(obj.event){
  104. case 'edit':
  105. if (data.length !== 0) {//选中
  106. admin.popup({
  107. title: '收费信息修改'
  108. ,area: ['800px', '680px']
  109. ,id: 'LAY-popup-charge-update'
  110. ,success:function (layero, index) {
  111. $.ajax({
  112. url:"/customer/getCustomer",
  113. success:function (res) {
  114. var data = res;
  115. $.each(data,function (index,item) {
  116. if (index===0){
  117. $('#customerSelect').append('<option value="">'+item.name+'</option>');
  118. }else {
  119. $('#customerSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
  120. }
  121. });
  122. form.render('select', 'customerSelect');
  123. }
  124. });
  125. view(this.id).render('detection/layer/popupChargeUpdate',data[0]).done(function(){
  126. form.val('charge-form-update',{
  127. 'license':data[0].license,
  128. 'VIN':data[0].VIN,
  129. 'owner':data[0].owner,
  130. // 'EP_type':data[0].EP_type,
  131. // 'customer':data[0].customer,
  132. // 'carType':data[0].carType,
  133. 'Safe_receivable':data[0].Safe_receivable,
  134. 'EP_receivable':data[0].EP_receivable,
  135. 'receivable':data[0].receivable,
  136. 'telephone':data[0].telephone,
  137. 'ali_pay':data[0].ali_pay,
  138. 'on_account':data[0].on_account,
  139. // 'contracted_customer':data[0].contracted_customer,
  140. 'remarks':data[0].remarks,
  141. 'cost':data[0].cost,
  142. });
  143. // console.log(data[0])
  144. //以下是popupChargeUpdate的js
  145. form.verify({
  146. on_account:function (value) {
  147. if (value==="") {
  148. $('#on_account').val(0)//为空自动赋值0
  149. }else {
  150. if (isNaN(value)){
  151. return "请输入数字!"
  152. }
  153. }
  154. },
  155. ali_pay:function (value) {
  156. if (value==="") {
  157. $('#ali_pay').val(0)//为空自动赋值0
  158. }else {
  159. if (isNaN(value)){
  160. return "请输入数字!"
  161. }
  162. }
  163. }
  164. });
  165. $('#on_account').focus(function () {
  166. if($('#customerSelect').val()===""){
  167. $('#on_account').val(0)//为空自动赋值0
  168. layer.msg("需要先选择挂账客户!")
  169. }
  170. })
  171. //常用挂账客户
  172. $.ajax({
  173. url:"/customer/getCustomer",
  174. success:function (res) {
  175. // $('#customerSelect').append('<option value="'+data[0].customer+'">'+data[0].customer+'</option>');
  176. $.each(res,function (index,item) {
  177. if (index===0){
  178. if (item.name === data[0].customer){
  179. $('#customerSelect').append('<option value="" selected="selected">'+item.name+'</option>');
  180. } else {
  181. $('#customerSelect').append('<option value="">'+item.name+'</option>');
  182. }
  183. }else {
  184. if(item.name === data[0].customer){
  185. $('#customerSelect').append('<option selected="selected" value="'+item.name+'">'+item.name+'</option>');
  186. }else {
  187. $('#customerSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
  188. }
  189. }
  190. });
  191. form.render('select', 'customerSelect');
  192. }
  193. });
  194. //签约客户
  195. $.ajax({
  196. url:"/contracted/getContracted",
  197. success:function (res) {
  198. // var data = res;
  199. $.each(res,function (index,item) {
  200. if (index===0){
  201. if (item.name === data[0].contracted_customer){
  202. $('#contractedSelect').append('<option selected="selected" value="">'+item.name+'</option>');
  203. } else {
  204. $('#contractedSelect').append('<option value="">'+item.name+'</option>');
  205. }
  206. }else {
  207. if (item.name === data[0].contracted_customer){
  208. $('#contractedSelect').append('<option selected="selected" value="'+item.name+'">'+item.name+'</option>');
  209. }else {
  210. $('#contractedSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
  211. }
  212. }
  213. });
  214. form.render('select', 'contractedSelect');
  215. }
  216. });
  217. //环检下拉
  218. $.ajax({
  219. url:"/chargingStandard/getSelect",
  220. type:'POST',
  221. data:{"project":"环检"},
  222. success:function (res) {
  223. // var data = res;
  224. // $('#detectionSelect').append('<option value="'+data[0].EP_type+'">'+data[0].EP_type+'</option>');
  225. $.each(res,function (index,item) {
  226. if (item.carType === data[0].EP_type){
  227. $('#detectionSelect').append('<option selected="selected" value="'+item.carType+'">'+item.carType+'</option>');
  228. } else {
  229. $('#detectionSelect').append('<option value="'+item.carType+'">'+item.carType+'</option>');
  230. }
  231. });
  232. form.render('select', 'detectionSelect');
  233. }
  234. });
  235. //安检下拉
  236. $.ajax({
  237. url:"/chargingStandard/getSelect",
  238. type:'POST',
  239. data:{"project":"安检"},
  240. success:function (res) {
  241. // var data = res;
  242. // $('#carTypeSelect').append('<option value="'+data[0].car_type+'">'+data[0].car_type+'</option>');
  243. $.each(res,function (index,item) {
  244. if (item.carType === data[0].car_type){
  245. $('#carTypeSelect').append('<option selected="selected" value="'+item.carType+'">'+item.carType+'</option>');
  246. } else {
  247. $('#carTypeSelect').append('<option value="'+item.carType+'">'+item.carType+'</option>');
  248. }
  249. });
  250. form.render('select', 'carTypeSelect');
  251. }
  252. });
  253. //根据carType(安检)改变,联动默认价格
  254. form.on('select(carChangeType)',function (data) {
  255. $.ajax({
  256. url:"/chargingStandard/getSelect",
  257. type:'POST',
  258. data:{"carType":data.value},
  259. success:function (res) {
  260. $('#AJYS').val(res[0].cost);
  261. $('#YSZH').val(parseInt($('#AJYS').val()) + parseInt($('#HJYS').val()));//应收总和
  262. $('#SSZH').val($('#YSZH').val());
  263. }
  264. })
  265. });
  266. //根据EP_type(环检)改变,联动默认价格
  267. form.on('select(detectionChangeType)',function (data) {
  268. $.ajax({
  269. url:"/chargingStandard/getSelect",
  270. type:'POST',
  271. data:{"carType":data.value},
  272. success:function (res) {
  273. $('#HJYS').val(res[0].cost);
  274. $('#YSZH').val(parseInt($('#AJYS').val()) + parseInt($('#HJYS').val()))//应收总和
  275. $('#SSZH').val($('#YSZH').val());
  276. }
  277. })
  278. });
  279. //根据签约客户的选择,自动添加备注内容和手机号
  280. form.on('select(contractedType)',function (data) {
  281. $.ajax({
  282. url:"/contracted/getList",
  283. type:"POST",
  284. data:{"name":data.value},
  285. success:function (res) {
  286. //给备注栏赋值
  287. $('#remarks').val(res.data[0].remarks)
  288. //给手机号码赋值
  289. $('#telephone').val(res.data[0].phone)
  290. }
  291. })
  292. });
  293. //监听提交
  294. form.on('submit(LAY-charge-update-submit)', function(editData){
  295. var field = editData.field;
  296. field['id'] = data[0].id;
  297. admin.req({
  298. type:"POST",
  299. url:"/charge/chargeUpdate",
  300. data:field,
  301. done:function (res) {
  302. if (res && res.code === 0){
  303. layer.msg(res.msg)
  304. }else {//修改失败
  305. layer.msg(res.msg)
  306. }
  307. layer.close(index);
  308. layui.table.reload('test-table-radio'); //重载表格
  309. }
  310. });
  311. })
  312. })
  313. }
  314. })
  315. }else {//未选中
  316. layer.msg("请选择!");
  317. }
  318. // layer.alert(JSON.stringify(data));
  319. break;
  320. };
  321. });
  322. });
  323. </script>