repair_price_set.php 6.15 KB
<?php

use yii\helpers\Url;
use app\ht\widgets\LinkPager;

$this->title = '设置价格';
$this->params['breadcrumbs'][] = '设备管理';
$this->params['breadcrumbs'][] = ['label' => '维修方案设置', 'url' => ['/device/fault/repair-plan-set?type=1&modelDeviceFaultId='.$gets['modelDeviceFaultId']]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="panel panel-default">
    <div class="panel-heading bg-success">
        <?=$gets['info']; ?>&nbsp;>&nbsp;<?=$fault['name'] ?>&nbsp;>&nbsp;<?=$plan['name']?>
    </div>
    <div class="panel-heading">

        <div class="clearfix"></div>
    </div>

    <div  class="panel-body">
        <table class="table table-striped table-bordered"  id="brand-table">
            <thead>
            <tr>
                <th>型号</th>
                <th>维修价格</th>
            </tr>
            </thead>
            <tbody>
                <tr>
                    <td><?=$gets['model'] ?></td>
                    <td class="text-center align-middle hqy-row-select">
                        配件价格:<input type="number" style="width:80px;" value="<?=$plan['parts_price']?>" id="txt_parts_price"  class="txt_parts_price" man_hour_fee="<?=$man_hour_fee ?>" />&nbsp;,
                        工时费:<label id="lbl_labor_price" style="color:red;"><?=$man_hour_fee * $plan['repair_hours']*$plan['difficulty_degree']?>&nbsp;元</label>
                        (<?=$man_hour_fee?>元/小时*标准工时:<input type="number" style="width:80px;" value="<?=$plan['repair_hours']?>" id="txt_repair_hours"  class="txt_repair_hours" man_hour_fee="<?=$man_hour_fee ?>" />小时*
                        难度系数:<input type="number" style="width:80px;" value="<?=$plan['difficulty_degree']?>" id="txt_difficulty_degree"  class="txt_difficulty_degree" man_hour_fee="<?=$man_hour_fee ?>"/>)
                        &nbsp;
                        保修等级:<select id="warranty_level">
                            <?php foreach($warrantyLevel as $k=>$v){ ?> <option value="<?=$k?>" <?php if ($plan['warranty_level'] == $k) { echo 'selected="selected"'; }?>  ><?=$v['desc']?> </option><?php }?>
                        </select>
                        <br/>

                        维修价格:<label id="last_price" style="color:red;"><?=$plan['price'] ?>&nbsp;元</label>
                        <input type="hidden" id="modelsRepairPlanPricesId" value="<?=$plan['id'] ?>"/>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

    <div class="panel-footer text-center">
        <button type="button" class="btn btn-primary" id="save">提&nbsp;&nbsp;&nbsp;&nbsp;交</button>&nbsp;&nbsp;&nbsp;&nbsp;
    </div>

    <div class="panel-footer">
        <div class="hqy-panel-pager">

            <div class="clearfix"></div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        $(".txt_parts_price").bind("change",function () {
            var man_hour_fee = $(this).attr("man_hour_fee");
            reckon(man_hour_fee);
        });

        $(".txt_repair_hours").bind("change",function () {
            var man_hour_fee = $(this).attr("man_hour_fee");
            reckon(man_hour_fee);
        });

        $(".txt_difficulty_degree").bind("change",function () {
            var man_hour_fee = $(this).attr("man_hour_fee");
            reckon(man_hour_fee);
        });

        function reckon(man_hour_fee) {
            var parts_price = parseFloat($("#txt_parts_price").val());
            var repair_hours = parseFloat($("#txt_repair_hours").val());
            var difficulty_degree = parseFloat($("#txt_difficulty_degree").val());

            $("#last_price").html((parts_price + man_hour_fee * repair_hours * difficulty_degree)+" 元");
            $("#lbl_labor_price").html((man_hour_fee * repair_hours * difficulty_degree)+" 元");
        }

        $("#save").bind("click",function () {
            var id = $("#modelsRepairPlanPricesId").val();
            var parts_price = parseFloat($("#txt_parts_price").val());
            var repair_hours = parseFloat($("#txt_repair_hours").val());
            var difficulty_degree = parseFloat($("#txt_difficulty_degree").val());
            var warranty_level = $("#warranty_level").val()
            if (confirm("确认提交报价数据吗?")){
                $.ajax({
                    type: "post",
                    url: "update-models-repair-plan-price",
                    dataType:"json",
                    data: $.csrf({"modelsRepairPlanPricesId":id,"parts_price":parts_price,"repair_hours":repair_hours,"difficulty_degree":difficulty_degree ,"warranty_level":warranty_level}),
                    success:function(msg){
                        alert(msg['msg']);
                        if (msg['status'] == 1){
                            location.reload();
                        }else{
                            //提示确认失败
                        }
                    },
                    error:function(msg){
                        //提示确认失败
                    }
                });
            }
        });
        
        //执行删除维修方案报价
        $(".btn_fault_models_replan_").bind("click",function(){
            var model_price_id = $(this).attr("model_price_id");
            //var model_id = $(this).attr("model_id");
            if (model_price_id == null || model_price_id == ""){
                alert("删除失败,请刷新后再试");
                return false;
            }
            var thiz = $(this);
            if (confirm("你确定要删除此维修方案吗?")){
                $.ajax({
                    type: "post",
                    url: "fault-repair-plan-del",
                    dataType:"json",
                    data: $.csrf({"ids":model_price_id}),
                    success:function(msg){
                        alert(msg['msg']);
                        if (msg['status'] == 1){
                            thiz.parents('tr').remove();
                        }else{
                        }
                    },
                    error:function(msg){
                    }
                });
            }
        });
    });
</script>