<div id="app_index">
    <fieldset>
        <legend>查询应用</legend>
        <label>应用名称：<input type="text" name="appName" v-model="appNameValue" /></label>
        <input class="btn btn-primary" type="button" value="查询" id="search" v-on:click="search" />
        <a class="btn btn-info" fajax-updata="#newdlg" asp-controller="app" asp-action="AddNew">新增</a>
    </fieldset>
    <table class="table" v-if="rows.length > 0">
        <thead>
            <tr>
                <td>应用编号</td>
                <td>应用名称</td>
                <td>说明</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="(r,i) in rows">
                <td>{{r.Id}}</td>
                <td>{{r.Name}}</td>
                <td>{{r.Description}}</td>
                <td><input type="button" value="删除" v-on:click="remove(r.Id,i)" /></td>
            </tr>
        </tbody>
    </table>
    <div id="newdlg"></div>
</div>
<script type="text/javascript">
    mydata.app_index = new Vue({
        el: '#app_index',
        data: {
            userTicket: myJs.getTicket(),
            appNameValue: "全部",
            rows: [],
        },
        methods: {
            search() {
                if (this.appNameValue == "全部" || this.appNameValue == "") {
                    var url = myJs.url.app.GetAppList;
                    myJs.get(url, { adminTicket: this.userTicket }, function (d) {
                        mydata.app_index.rows = d;
                    }, function (s, i, m) {
                        myJs.msg(m);
                    });
                } else {
                    var url = myJs.url.app.GetApps;
                    myJs.post(url, { adminTicket: this.userTicket, appName: this.appNameValue, }, function (d) {
                        mydata.app_index.rows = new Array(d);
                    }, function (s, i, m) {
                        myJs.msg(m);
                    });
                }
            },
            remove(id, i) {
                var url = myJs.url.app.RemoveApp;
                myJs.post(url, { id: id }, function (d) {
                    mydata.app_index.rows.splice(i, 1);
                });
            },
        },
    });
</script>