<form id="theFrm">
    <?php if (isset($info)): ?>
        <input type="hidden" name="id" value="<?= $info->id ?>">
    <?php endif; ?>
    <input type="hidden" name="fix_id" value="<?= $fix_id > 0 ? $fix_id : (isset($info) ? $info->fix_id : '') ?>">
    <input type="hidden" name="list_type" value="<?= $type > 0 ? $type : (isset($info) ? $info->big_type_id : '') ?>">
    <input type="hidden" name="big_type_id" value="<?= $type > 0 ? $type : (isset($info) ? $info->big_type_id : '') ?>">
    <table width="500" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tbody>
        <tr>
            <td colspan="4">
                <select name="small_type_id">
                    <option value="1" <?= isset($info) ? (1 == $info->small_type_id ? 'selected' : '') : '' ?>>更换清单
                    </option>
                    <option value="2" <?= isset($info) ? (2 == $info->small_type_id ? 'selected' : '') : '' ?>>维修清单
                    </option>
                    <option value="3" <?= isset($info) ? (3 == $info->small_type_id ? 'selected' : '') : '' ?>>辅料清单
                    </option>
                    <option value="4" <?= isset($info) ? (4 == $info->small_type_id ? 'selected' : '') : '' ?>>待定清单
                    </option>
                    <option value="5" <?= isset($info) ? (5 == $info->small_type_id ? 'selected' : '') : '' ?>>汽车保养
                    </option>
                    <option value="6" <?= isset($info) ? (6 == $info->small_type_id ? 'selected' : '') : '' ?>>美容装饰
                    </option>
                </select>
            </td>
        </tr>
        <tr class="tdbg2">
            <td align="right" class="bg_tr">项目名称：</td>
            <td class="td_bg">
                <div align="left">
                    <input id="name" name="name" type="text" value="<?= isset($info) ? $info->name : '' ?>"/>
                </div>
            </td>
            <td class="bg_tr">数量</td>
            <td class="td_bg"><input name="count" type="text" value="<?= isset($info) ? $info->count : '' ?>"></td>
        </tr>
        <tr class="tdbg2">
            <td class="bg_tr">保险定价</td>
            <td class="td_bg"><input name="insurance_price" type="text"
                                     value="<?= isset($info) ? $info->insurance_price : '' ?>"></td>
            <td class="bg_tr">自费单价</td>
            <td class="td_bg"><input name="price" type="text" value="<?= isset($info) ? $info->price : '' ?>"></td>
        </tr>
        <tr class="tdbg2">
            <td class="bg_tr">类型</td>
            <td class="td_bg">
                <select name="type" onchange="typeChange($(this).val())" id="type">
                    <option value="">--请选择--</option>
                    <option value="68" <?= isset($info) ? (68 == $info->type ? 'selected' : '') : '' ?>>机修</option>
                    <option value="69" <?= isset($info) ? (69 == $info->type ? 'selected' : '') : '' ?>>美容</option>
                    <option value="70" <?= isset($info) ? (70 == $info->type ? 'selected' : '') : '' ?>>喷漆</option>
                </select>
            </td>
            <td class="bg_tr">维修人</td>
            <td class="td_bg">
                <select name="fix_user" id="fix-user">
                    <option value="">--请选择--</option>
                    <?php if (isset($info) && isset($user)): ?>
                        <?php foreach ($user as $u): ?>
                            <option value="<?= $u->id ?>" <?= $u->id == $info->fix_user ? 'selected' : '' ?>><?= $u->name ?></option>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </select>
            </td>
        </tr>
        <tr class="tdbg2">
            <td class="bg_tr">结算方式</td>
            <td class="td_bg">
                <select name="pay_type">
                    <?php if (isset($info)): ?>
                        <option value="1" <?= 1 == $info->pay_type ? 'selected' : '' ?>>保险理赔</option>
                        <option value="2" <?= 2 == $info->pay_type ? 'selected' : '' ?>>自费维修</option>
                    <?php else: ?>
                        <option value="1" <?= 1 == $type ? 'selected' : '' ?>>保险理赔</option>
                        <option value="2" <?= 2 == $type ? 'selected' : '' ?>>自费维修</option>
                    <?php endif; ?>
                </select>
            </td>
        </tr>
        <tr class="tdbg2">
            <td class="bg_tr">备注</td>
            <td class="td_bg" colspan="3"><textarea name="fix_remark" id="" cols="40"
                                                    rows="2"><?= isset($info) ? $info->fix_remark : '' ?></textarea>
            </td>
        </tr>
        <tr class="tdbg2">
            <td height="22" colspan="4" align="center" class="td_bg">
                <input type=button class="ACT_btn" value=" <?= isset($info) ? '保存' : '提交' ?> "
                       onclick="detailedListAdd()"/>
            </td>
        </tr>
        </tbody>
    </table>
</form>
<script type="text/javascript" language="javascript" src="/js/artDialog/artDialog.js?skin=default"></script>
<script type="text/javascript" language="javascript" src="/js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script>
    //清单添加
    function detailedListAdd() {
        var param = $('#theFrm').serialize();
        $.get('/fix-car/fix-item-save', param, function (msg) {
            alert(msg.msg);
            if (msg.success) {
                originReload()
            }
        });
    }

    //类型联动
    function typeChange(gid) {
        var options = '<option class="top" value="">--请选择--</option>';
        if (gid > 0) {
            $.get('/fix-car/ajax-fix-user', {gid: gid}, function (msg) {
                if (msg.success) {
                    for (var i = 0; i < msg.content.length; i++) {
                        options += '<option class="top" value="' + msg.content[i].id + '">' + msg.content[i].name + '</option>';
                    }
                    var $options = $(options);
                    $('#fix-user').html($options);
                    return false;
                }
            }, 'json');
        }
        $('#fix-user').html(options);
    }

    //art.dialog 重载来源页面
    function originReload() {
        var win = art.dialog.open.origin;
        win.location.reload();
    }
</script>