<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改资产登记')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content" id="app">
        <form class="form-horizontal m" id="form-property-edit" th:object="${tdPropertyManager}">
            <input name="useId" th:field="*{useId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">资产编号：</label>
                <div class="col-sm-8">
                    <input disabled name="useId" required th:field="*{useId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属地市：</label>
                <div class="col-sm-8">
                    <select id="City" name="part" required @change="getAreaList()" v-model="City" class="form-control m-b">
                        <option value="">---请选择---</option>
                        <option v-for="option in CityList" :value="option.id" :key="option.id">
                            {{ option.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属区县：</label>
                <div class="col-sm-8">
                    <select id="Area" name="areaId" required v-model="Area" class="form-control m-b">
                        <option value="">---请选择---</option>
                        <option v-for="option in AreaList" :value="option.id" :key="option.id">
                            {{ option.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">使用部门：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" required type="text" name="useDepart" onclick="selectDeptTree()" id="treeName" th:field="*{useDepart}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">使用人员：</label>
                <div class="col-sm-8">
                    <input name="userName" required th:field="*{userName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">使用日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="useDate" required th:value="${#dates.format(tdPropertyManager.useDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">单位名称：</label>
                <div class="col-sm-8">
                    <input name="frameworkId" required th:field="*{frameworkId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登记部门：</label>
                <div class="col-sm-8">
                    <input name="recoverDepart" readonly th:field="*{recoverDepart}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登记人员：</label>
                <div class="col-sm-8">
                    <input name="recoverName" readonly th:field="*{recoverName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登记日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="recoverDate" disabled th:value="${#dates.format(tdPropertyManager.recoverDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">资产数量：</label>
                <div class="col-sm-8">
                    <input name="propertyNum" required digits="true" th:field="*{propertyNum}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/property";
        $("#form-property-edit").validate({
            focusCleanup: true
        });
        var app = new Vue({
            el: '#app',
            data: {
                CityList: [],
                AreaList:[],
                City:[[${tdPropertyManager.part}]],
                Area:[[${tdPropertyManager.areaId}]],
                params:{
                    parentId:'',
                }
            },
            mounted(){
                // 初始化地市列表
                this.getCityList();
                if (this.City){
                    this.getAreaList()
                }
            },
            methods:{
                getCityList(){
                    $.ajax({
                        url: ctx + "system/area/getSysAreaList",
                        type: 'GET',
                        data:this.params ,
                        success:((res)=>{
                            this.CityList = res.data
                        }) ,
                    });
                },
                getAreaList(){
                    this.params.parentId = this.City
                    $.ajax({
                        url: ctx + "system/area/getSysAreaList",
                        type: 'GET',
                        data:this.params,
                        success:((res)=>{
                            this.AreaList = res.data
                        }) ,
                    });
                }
            }
        })
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-property-edit').serialize());
            }
        }
        /* 选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
        $("input[name='useDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='recoverDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>
