<!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-notify-edit" th:object="${tdNotify}">
            <input name="notifyId" th:field="*{notifyId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属地市：</label>
                <div class="col-sm-8">
                    <select id="City" name="framework" 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="area" 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">通知人员：</label>
                <div class="col-sm-8">
                    <input name="notifyUser" readonly th:field="*{notifyUser}" 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="notifyDepart" readonly th:field="*{notifyDepart}" 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="notifyTime" th:value="${#dates.format(tdNotify.notifyTime, '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">
                    <textarea name="notifyContent" required class="form-control">[[*{notifyContent}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">被通知人：</label>
                <div class="col-sm-8">
                    <input name="notifyBeuser" required th:field="*{notifyBeuser}" 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="radio-box" th:each="dict : ${@dict.getType('sys_notice_state')}">
                        <input type="radio" th:id="${dict.dictCode}" name="notifyState" th:value="${dict.dictValue}" th:field="*{notifyState}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </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/notify";
        $("#form-notify-edit").validate({
            focusCleanup: true
        });
        var app = new Vue({
            el: '#app',
            data: {
                CityList: [],
                AreaList:[],
                City:[[${tdNotify.framework}]],
                Area:[[${tdNotify.area}]],
                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-notify-edit').serialize());
            }
        }

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