123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- <title>收费信息修改</title>
- <div class="layui-card layadmin-header">
- <div class="layui-breadcrumb" lay-filter="breadcrumb">
- <a lay-href="">主页</a>
- <a><cite>车辆检测管理</cite></a>
- <a><cite>收费信息修改</cite></a>
- </div>
- </div>
- <div class="layui-fluid">
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md12">
- <div class="layui-card">
- <!--<div class="layui-card-header">开启头部工具栏</div>-->
- <div class="layui-card-body">
- <div class="test-table-reload-btn" style="margin-bottom: 10px;">
- 搜索车牌:
- <div class="layui-inline">
- <input class="layui-input" name="车牌号" id="test-table-demoReload" style="text-transform:uppercase;">
- <!--autocomplete="off"-->
- </div>
- 检测日期:
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="test-laydate-range-date">
- </div>
- <button class="layui-btn" data-type="reload">搜索</button>
- </div>
- <table class="layui-hide" id="test-table-radio" lay-filter="test-table-radio"></table>
- <script type="text/html" id="test-table-radio-toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-event="edit">修改选择</button>
- </div>
- </script>
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
- <script>
- layui.use(['admin', 'table','layer','form','view','laydate'], function(){
- var admin = layui.admin
- ,$ = layui.$
- ,layer = layui.layer
- ,view = layui.view
- ,form = layui.form
- ,laydate = layui.laydate
- ,table = layui.table;
- table.render({
- elem: '#test-table-radio'
- ,url:'/charge/selectCharge'
- ,method:'post'
- // ,where:{"date":new Date()}
- ,toolbar: '#test-table-radio-toolbarDemo'
- ,even: true//隔行背景
- ,title: '收费记录数据表'
- ,cols: [[
- {type: 'radio', fixed: 'left'}
- ,{field:'license', title:'车牌', width:120}
- ,{field:'VIN', title:'车架号', width:120}
- ,{field:'owner', title:'所有人', width:120}
- ,{field:'EP_type', title:'环保类型', width:120}
- ,{field:'car_type', title:'安检类型', width:120}
- ,{field:'customer', title:'挂账客户', width:120}
- ,{field:'contracted_customer', title:'签约客户', width:120}
- ,{field:'EP_receivable', title:'环检应收', width:120}
- ,{field:'Safe_receivable', title:'安检应收', width:120}
- ,{field:'receivable', title:'应收总和', width:120}
- ,{field:'cost', title:'实收总和', width:120}
- ,{field:'telephone', title:'联系电话', width:120}
- ,{field:'date', title:'检测日期', width:120}
- ,{field:'remarks', title:'备注', width:120}
- // ,{fixed: 'right', title:'操作', toolbar: '#test-table-toolbar-barDemo', width:150}
- ]]
- ,page: true
- });
- laydate.render({
- elem: '#test-laydate-range-date'
- });
- var active = {
- reload: function(){
- var demoReload = $('#test-table-demoReload');
- var date = $('#test-laydate-range-date');
- //执行重载
- table.reload('test-table-radio', {
- where: {
- 'license': demoReload.val(),
- 'date': date.val()
- }
- ,page: {
- curr: 1 //重新从第 1 页开始
- }
- });
- }
- };
- $('.test-table-reload-btn .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- //头工具栏事件
- table.on('toolbar(test-table-radio)', function(obj){
- var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
- var data = checkStatus.data; //获取选中行数据
- switch(obj.event){
- case 'edit':
- if (data.length !== 0) {//选中
- admin.popup({
- title: '收费信息修改'
- ,area: ['800px', '680px']
- ,id: 'LAY-popup-charge-update'
- ,success:function (layero, index) {
- $.ajax({
- url:"/customer/getCustomer",
- success:function (res) {
- var data = res;
- $.each(data,function (index,item) {
- if (index===0){
- $('#customerSelect').append('<option value="">'+item.name+'</option>');
- }else {
- $('#customerSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
- }
- });
- form.render('select', 'customerSelect');
- }
- });
- view(this.id).render('detection/layer/popupChargeUpdate',data[0]).done(function(){
- form.val('charge-form-update',{
- 'license':data[0].license,
- 'VIN':data[0].VIN,
- 'owner':data[0].owner,
- // 'EP_type':data[0].EP_type,
- // 'customer':data[0].customer,
- // 'carType':data[0].carType,
- 'Safe_receivable':data[0].Safe_receivable,
- 'EP_receivable':data[0].EP_receivable,
- 'receivable':data[0].receivable,
- 'telephone':data[0].telephone,
- 'ali_pay':data[0].ali_pay,
- 'on_account':data[0].on_account,
- // 'contracted_customer':data[0].contracted_customer,
- 'remarks':data[0].remarks,
- 'cost':data[0].cost,
- });
- // console.log(data[0])
- //以下是popupChargeUpdate的js
- form.verify({
- on_account:function (value) {
- if (value==="") {
- $('#on_account').val(0)//为空自动赋值0
- }else {
- if (isNaN(value)){
- return "请输入数字!"
- }
- }
- },
- ali_pay:function (value) {
- if (value==="") {
- $('#ali_pay').val(0)//为空自动赋值0
- }else {
- if (isNaN(value)){
- return "请输入数字!"
- }
- }
- }
- });
- $('#on_account').focus(function () {
- if($('#customerSelect').val()===""){
- $('#on_account').val(0)//为空自动赋值0
- layer.msg("需要先选择挂账客户!")
- }
- })
- //常用挂账客户
- $.ajax({
- url:"/customer/getCustomer",
- success:function (res) {
- // $('#customerSelect').append('<option value="'+data[0].customer+'">'+data[0].customer+'</option>');
- $.each(res,function (index,item) {
- if (index===0){
- if (item.name === data[0].customer){
- $('#customerSelect').append('<option value="" selected="selected">'+item.name+'</option>');
- } else {
- $('#customerSelect').append('<option value="">'+item.name+'</option>');
- }
- }else {
- if(item.name === data[0].customer){
- $('#customerSelect').append('<option selected="selected" value="'+item.name+'">'+item.name+'</option>');
- }else {
- $('#customerSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
- }
- }
- });
- form.render('select', 'customerSelect');
- }
- });
- //签约客户
- $.ajax({
- url:"/contracted/getContracted",
- success:function (res) {
- // var data = res;
- $.each(res,function (index,item) {
- if (index===0){
- if (item.name === data[0].contracted_customer){
- $('#contractedSelect').append('<option selected="selected" value="">'+item.name+'</option>');
- } else {
- $('#contractedSelect').append('<option value="">'+item.name+'</option>');
- }
- }else {
- if (item.name === data[0].contracted_customer){
- $('#contractedSelect').append('<option selected="selected" value="'+item.name+'">'+item.name+'</option>');
- }else {
- $('#contractedSelect').append('<option value="'+item.name+'">'+item.name+'</option>');
- }
- }
- });
- form.render('select', 'contractedSelect');
- }
- });
- //环检下拉
- $.ajax({
- url:"/chargingStandard/getSelect",
- type:'POST',
- data:{"project":"环检"},
- success:function (res) {
- // var data = res;
- // $('#detectionSelect').append('<option value="'+data[0].EP_type+'">'+data[0].EP_type+'</option>');
- $.each(res,function (index,item) {
- if (item.carType === data[0].EP_type){
- $('#detectionSelect').append('<option selected="selected" value="'+item.carType+'">'+item.carType+'</option>');
- } else {
- $('#detectionSelect').append('<option value="'+item.carType+'">'+item.carType+'</option>');
- }
- });
- form.render('select', 'detectionSelect');
- }
- });
- //安检下拉
- $.ajax({
- url:"/chargingStandard/getSelect",
- type:'POST',
- data:{"project":"安检"},
- success:function (res) {
- // var data = res;
- // $('#carTypeSelect').append('<option value="'+data[0].car_type+'">'+data[0].car_type+'</option>');
- $.each(res,function (index,item) {
- if (item.carType === data[0].car_type){
- $('#carTypeSelect').append('<option selected="selected" value="'+item.carType+'">'+item.carType+'</option>');
- } else {
- $('#carTypeSelect').append('<option value="'+item.carType+'">'+item.carType+'</option>');
- }
- });
- form.render('select', 'carTypeSelect');
- }
- });
- //根据carType(安检)改变,联动默认价格
- form.on('select(carChangeType)',function (data) {
- $.ajax({
- url:"/chargingStandard/getSelect",
- type:'POST',
- data:{"carType":data.value},
- success:function (res) {
- $('#AJYS').val(res[0].cost);
- $('#YSZH').val(parseInt($('#AJYS').val()) + parseInt($('#HJYS').val()));//应收总和
- $('#SSZH').val($('#YSZH').val());
- }
- })
- });
- //根据EP_type(环检)改变,联动默认价格
- form.on('select(detectionChangeType)',function (data) {
- $.ajax({
- url:"/chargingStandard/getSelect",
- type:'POST',
- data:{"carType":data.value},
- success:function (res) {
- $('#HJYS').val(res[0].cost);
- $('#YSZH').val(parseInt($('#AJYS').val()) + parseInt($('#HJYS').val()))//应收总和
- $('#SSZH').val($('#YSZH').val());
- }
- })
- });
- //根据签约客户的选择,自动添加备注内容和手机号
- form.on('select(contractedType)',function (data) {
- $.ajax({
- url:"/contracted/getList",
- type:"POST",
- data:{"name":data.value},
- success:function (res) {
- //给备注栏赋值
- $('#remarks').val(res.data[0].remarks)
- //给手机号码赋值
- $('#telephone').val(res.data[0].phone)
- }
- })
- });
- //监听提交
- form.on('submit(LAY-charge-update-submit)', function(editData){
- var field = editData.field;
- field['id'] = data[0].id;
- admin.req({
- type:"POST",
- url:"/charge/chargeUpdate",
- data:field,
- done:function (res) {
- if (res && res.code === 0){
- layer.msg(res.msg)
- }else {//修改失败
- layer.msg(res.msg)
- }
- layer.close(index);
- layui.table.reload('test-table-radio'); //重载表格
- }
- });
- })
- })
- }
- })
- }else {//未选中
- layer.msg("请选择!");
- }
- // layer.alert(JSON.stringify(data));
- break;
- };
- });
- });
- </script>
|