<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('载体下发列表')" />
</head>
<body class="gray-bg">
<div class="container-div" id="app">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <input type="hidden" name="status" th:value="3"/>
                        <li>
                            <label>载体名称:</label>
                            <input type="text" name="carrierName"/>
                        </li>
                        <li>
                            <label>密级:</label>
                            <select name="carrierSecret" th:with="type=${@dict.getType('sys_file_miji')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>载体类型:</label>
                            <select name="carrierLevel" th:with="type=${@dict.getType('sys_provide_level')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>所属市州:</label>
                            <select id="City" name="areaCity" v-model="City">
                                <option value="">请选择</option>
                                <option v-for="option in CityList" :value="option.id" :key="option.id">
                                    {{ option.name }}
                                </option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:useCarrier:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:useCarrier:remove')}]];
    var detailFlag = [[${@permission.hasPermi('system:useCarrier:detail')}]];
    var carrierLevelDatas = [[${@dict.getType('sys_provide_level')}]];
    var fileSecretDatas = [[${@dict.getType('sys_file_miji')}]];
    var carrierExtentDatas = [[${@dict.getType('sys_file_jinjichengdu')}]];
    var prefix = ctx + "system/useCarrier";
    let datas = []
    $.ajax({
        url: ctx + "system/area/getAllList",
        type: 'GET',
        data:{parentId:''} ,
        success:((res)=>{
            datas = res.data
        }) ,
    });
    $(function() {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/edit/{id}",
            modalName: "国家秘密载体使用",
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'areaCity',
                    title: '所属市州',
                    formatter: function(value, row, index) {
                        return getCity(datas, value)
                    }
                },
                {
                    field: 'carrierName',
                    title: '载体名称'
                },
                {
                    field: 'carrierLevel',
                    title: '载体类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(carrierLevelDatas, value);
                    }
                },
                {
                    field: 'carrierExtent',
                    title: '紧急程度',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(carrierExtentDatas, value);
                    }
                },
                {
                    field: 'carrierSecret',
                    title: '密级',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(fileSecretDatas, value);
                    }
                },
                {
                    field: 'carrierTerm',
                    title: '保密期限'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>使用</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    var app = new Vue({
        el: '#app',
        data: {
            CityList: [],
            City:'',
            params:{
                parentId:'',
            }
        },
        mounted(){
            // 初始化地市列表
            this.getCityList();
        },
        methods:{
            getCityList(){
                $.ajax({
                    url: ctx + "system/area/getSysAreaList",
                    type: 'GET',
                    data:this.params ,
                    success:((res)=>{
                        this.CityList = res.data.filter(obj => obj.id === '36625');
                    }) ,
                });
            },
        }
    })
</script>
</body>
</html>