<#-- 此宏包含《网络请求》《vue通用设置》《实用小工具》，为引用方便集成到一个宏里 -->
<script>
    // 网络请求
    {
        function Ajax(module, target, method) {
            this.mModule = module;
            this.mTarget = target;
            this.mMethod = method;

            this.method = function (method) {
                this.mMethod = method;
                return this;
            };
            this.post = function (data, callback) {
                switch (this.mMethod) {
                    case "upload":
                    case "imports":
                        nav.tipShow("上传中...");
                        nav.barShow();
                        var fd = new FormData();
                        fd.append("file", data);
                        $.ajax({
                            url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
                            method: "post",
                            data: fd,
                            responseType: "blob",
                            success: function (response) {
                                nav.tipClose();
                                nav.barFinish();
                                if ("application/json" === response.data.type) {
                                    var reader = new FileReader();
                                    reader.addEventListener("loadend", function () {
                                        var rsp = JSON.parse(reader.result);
                                        if (rsp.errors.length > 0) {
                                            nav.barError();
                                            nav.e(rsp.errors[0].message)
                                        } else {
                                            nav.barFinish();
                                        }
                                    });
                                    reader.readAsText(response.data, "utf-8");
                                    callback({errors: []});
                                } else {
                                    // 获取响应header中文件信息
                                    var dis = response.headers['content-disposition'];
                                    // 正则匹配文件名
                                    var fileName = dis.match(/filename="(.*\..*)"/)[1];
                                    // 模拟下载
                                    $.blobtoDown(decodeURIComponent(fileName), new Blob([response.data]));
                                    callback({errors: []});
                                }
                            },
                            error: function (error, xhr) {
                                nav.tipClose();
                                nav.barError();
                                callback({errors: [{message: error.statusText}]})
                            },
                            progress: function (progressEvent) {
                                var complete = (progressEvent.loaded / progressEvent.total * 100 | 0) + '%';
                                nav.tipShow("上传中(" + complete + ")");
                                if (complete === '100%') {
                                    nav.tipShow("处理中，请稍等..")
                                }
                            }
                        });
                        break;
                    case "exports":
                    case "template":
                        nav.tipShow("请稍等...");
                        nav.barShow();
                        $.ajax({
                            url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
                            method: "POST",
                            data: JSON.stringify(data),
                            responseType: "blob",
                            success: function (response) {
                                nav.tipClose();
                                nav.barFinish();
                                var dis = response.headers['content-disposition'];
                                // 正则匹配文件名
                                var fileName = dis.match(/filename="(.*\..*)"/)[1];
                                // 模拟下载
                                $.blobtoDown(decodeURIComponent(fileName), new Blob([response.data], {type: 'application/vnd.ms-excel'}));
                                callback({errors: []})
                            },
                            error: function (error) {
                                nav.tipClose();
                                nav.barError();
                                callback({errors: [{message: error.statusText}]})
                            }
                        });
                        break;
                    default:
                        nav.barShow();
                        $.ajax({
                            url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
                            method: "POST",
                            data: JSON.stringify(data),
                            success: function (response) {
                                nav.barFinish();
                                callback(response.data)
                            },
                            error: function (error) {
                                nav.barError();
                                callback({errors: [{message: error.statusText}]})
                            }
                        });
                }
            };
            this.create = function (data, callback) {
                this.mMethod = "create";
                this.post(data, callback);
            };
            this.delete = function (data, callback) {
                this.mMethod = "delete";
                this.post(data, callback);
            };
            this.update = function (data, callback) {
                this.mMethod = "update";
                this.post(data, callback);
            };
            this.find = function (data, callback) {
                this.mMethod = "find";
                this.post(data, callback);
            };
            this.get = function (data, callback) {
                this.mMethod = "get";
                this.post(data, callback);
            };
            this.load = function (data, callback) {
                this.mMethod = "load";
                this.post(data, callback);
            };
            this.template = function (data, callback) {
                this.mMethod = "template";
                this.post(data, callback);
            };
            this.imports = function (data, callback) {
                this.mMethod = "imports";
                this.post(data, callback);
            };
            this.exports = function (data, callback) {
                this.mMethod = "exports";
                this.post(data, callback);
            };
            this.upload = function (data, callback) {
                this.mMethod = "upload";
                this.post(data, callback);
            };
        }
    }
    // vue通用设置
    {
        // 关闭生产提示
        Vue.config.productionTip = false;
        // 字典缓存对象
        Vue.prototype.$dictCache = {};
        // 全局提交标记
        Vue.prototype.$isSubmit = false;
        // 树组件
        Vue.component('el-input-tree', {
            data: function () {
                return {
                    items: []
                }
            },
            props: {
                value: {
                    type: String | Object,
                    default: ''
                },
                props: {
                    type: Object,
                    default: {
                        key: "id",
                        label: "label",
                        value: "value",
                        children: "children"
                    }
                },
                data: {
                    type: Array,
                    default: []
                },
                valueFor: {
                    type: String,
                    default: 'value',
                    validator: function (value) {
                        var r = (['label', 'value', 'item'].indexOf(value) !== -1);
                        if (!r) {
                            console.error("value-for的值只能是['label','value','item']中的一个.")
                        }
                        return r;
                    }
                },
                clearable: {
                    type: Boolean,
                    default: true
                },
                limit: {
                    type: Number,
                    default: 0
                },
                size: {
                    type: String,
                    default: 'mini'
                },
                multiple: {
                    type: Boolean,
                    default: false
                },
                placeholder: {
                    type: String,
                    default: ''
                },
                change: {
                    type: Function,
                    default: function (item) {

                    }
                }
            },
            computed: {
                labels: function () {
                    var labels = [];
                    for (var i = 0; i < this.items.length; i++) {
                        labels.push(this.items[i][this.props.label])
                    }
                    return labels;
                },
                values: function () {
                    var values = [];
                    for (var i = 0; i < this.items.length; i++) {
                        values.push(this.items[i][this.props.value])
                    }
                    return values;
                }
            },
            watch: {
                value: function (val, old) {// 数据发生变化时需要重新初始化
                    // 排除input事件触发的value变化事件，防止循环
                    if (val !== this.values.join(",")) {
                        this.init();
                    }
                },
                data: function (val, old) {// 数据集发生变化时需要重新初始化
                    this.init();
                }
            },
            methods: {
                input: function () {
                    // 触发input事件
                    switch (this.valueFor) {
                        case "label":
                            this.$emit('input', this.labels.join(","));
                            break;
                        case "value":
                            this.$emit('input', this.values.join(","));
                            break;
                        case "item":
                            this.$emit('input', this.items);
                            break;
                    }
                    // 触发change事件
                    this.$emit('change', this.items);
                },
                init: function () {
                    this.items = [];
                    if (this.value) {
                        var values = this.value.split(",");
                        this.data.forTree(function (item) {
                            for (var i = 0; i < values.length; i++) {
                                if (item.value === values[i]) {
                                    this.items.push(item);
                                }
                            }
                        }.bind(this));
                    }
                    this.$refs.tree.setCheckedNodes(this.items);
                },
                onCheck: function (item, state) {
                    var index = this.items.indexOf(item);
                    if (index === -1) {
                        this.items.push(item);
                    } else {
                        this.items.splice(index, 1);
                    }
                    // 当单选时，需要移除前一个条目
                    while (!this.multiple && this.items.length > 1) {
                        this.items.splice(0, 1);
                        this.$refs.tree.setCheckedNodes(this.items);
                    }
                    this.input();
                },
                onClear: function () {
                    this.items = [];
                    this.$refs.tree.setCheckedNodes([]);
                    this.input();
                },
                onRemoveTag: function (tag) {
                    var index = this.labels.indexOf(tag);
                    if (index > -1) {
                        this.items.splice(index, 1);
                        this.$refs.tree.setCheckedNodes(this.items);
                        this.input();
                    }
                }
            },
            mounted: function () {
                this.init();
            },
            template: '' +
            '<el-select :value="labels" :size="size" :clearable="clearable" :multiple="multiple" collapse-tags @clear="onClear" @remove-tag="onRemoveTag">' +
            '    <el-option style="background: #ffffff;padding: 0!important;min-height:200px;display: initial;">' +
            '        <el-tree' +
            '                ref="tree"' +
            '                style="width: 100%;min-height: 245px"' +
            '                :indent="8"' +
            '                :data="data"' +
            '                :node-key="props.key"' +
            '                :check-strictly="true"' +
            '                :props="props"' +
            '                :show-checkbox="true"' +
            '                @check="onCheck"/>' +
            '    </el-option>' +
            '</el-select>'
        });
        // 字典组件
        Vue.component('el-input-dict', {
            data: function () {
                return {
                    item: {},
                    options: []
                }
            },
            props: {
                value: {
                    type: String | Object,
                    default: ''
                },
                valueFor: {
                    type: String,
                    default: 'value',
                    validator: function (value) {
                        var r = (['value', 'label', 'item'].indexOf(value) !== -1);
                        if (!r) {
                            console.error("value-for的值只能是['value','label','item']中的一个.")
                        }
                        return r;
                    }
                },
                dictName: {
                    type: String,
                    default: ''
                },
                size: {
                    type: String,
                    default: 'mini'
                },
                placeholder: {
                    type: String,
                    default: ''
                },
                change: {
                    type: Function,
                    default: function (item) {

                    }
                }
            },
            watch: {
                value: function (val, old) {
                    this.init();
                }
            },
            methods: {
                input: function (item) {
                    this.item = item;
                    switch (this.valueFor) {
                        case "value":
                            this.$emit('input', item.value);
                            break;
                        case "label":
                            this.$emit('input', item.label);
                            break;
                        case "item":
                            this.$emit('input', item);
                            break;
                    }
                },
                init: function () {
                    if (this.dictName) {
                        var dictCache = Vue.prototype.$dictCache[this.dictName];
                        if (typeof(dictCache) === "undefined") {// 未缓存字典数据
                            new Ajax("wframe", "dict", "load").post({
                                dictName: this.dictName
                            }, function (response) {
                                if (response.errors.length > 0) {
                                    console.error(response.errors[0].message)
                                } else {
                                    Vue.prototype.$dictCache[this.dictName].loading = false;
                                    Vue.prototype.$dictCache[this.dictName].data = response.result;
                                }
                            }.bind(this));
                            Vue.prototype.$dictCache[this.dictName] = {
                                dictName: this.dictName,
                                loading: true,
                                data: []
                            };
                            this.init();
                        } else if (dictCache.loading) {// 请求数据中,休眠100毫秒再次尝试初始化
                            setTimeout(function () {
                                this.init()
                            }.bind(this), 100);
                        } else {
                            this.options = dictCache.data;
                            this.item = {};
                            this.options.forTree(function (item) {
                                if (item.value === this.value) {
                                    this.item = item;
                                }
                            }.bind(this));
                        }
                    }
                }
            },
            mounted: function () {
                this.init();
            },
            template: '' +
            '<el-select :value="item.label" @input="input" filterable clearable placeholder="请选择" :size="size" :placeholder="placeholder" @change="change">' +
            ' <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item">' +
            '  <span style="float: left">{{ item.label }}</span>' +
            '  <span style="float: right; color: #8492a6; font-size: 12px">{{ item.value }}</span>' +
            ' </el-option>' +
            '</el-select>'
        });
        // 字典树组件
        Vue.component('el-input-dict-tree', {
            data: function () {
                return {
                    data: []
                }
            },
            props: {
                value: {
                    type: String | Object,
                    default: ''
                },
                props: {
                    type: Object,
                    default: {
                        key: "id",
                        label: "label",
                        value: "value",
                        children: "children"
                    }
                },
                size: {
                    type: String,
                    default: 'mini'
                },
                clearable: {
                    type: Boolean,
                    default: true
                },
                filterable: {
                    type: Boolean,
                    default: true
                },
                multiple: {
                    type: Boolean,
                    default: false
                },
                placeholder: {
                    type: String,
                    default: ''
                },
                valueFor: {
                    type: String,
                    default: 'value',
                    validator: function (value) {
                        var r = (['value', 'label', 'item'].indexOf(value) !== -1);
                        if (!r) {
                            console.error("value-for的值只能是['value','label','item']中的一个.")
                        }
                        return r;
                    }
                },
                dictName: {
                    type: String,
                    default: ''
                },
                change: {
                    type: Function,
                    default: function (item) {

                    }
                }
            },
            watch: {
                value: function (val, old) {
                    this.init();
                }
            },
            methods: {
                input: function (value) {
                    this.$emit('input', value);
                },
                change: function (items) {
                    this.$emit('change', items);
                },
                init: function () {
                    if (this.dictName) {
                        var dictCache = Vue.prototype.$dictCache[this.dictName];
                        if (typeof(dictCache) === "undefined") {// 未缓存字典数据
                            new Ajax("wframe", "dict", "load").post({
                                dictName: this.dictName
                            }, function (response) {
                                if (response.errors.length > 0) {
                                    console.error(response.errors[0].message)
                                } else {
                                    Vue.prototype.$dictCache[this.dictName].loading = false;
                                    Vue.prototype.$dictCache[this.dictName].data = response.result;
                                }
                            }.bind(this));
                            Vue.prototype.$dictCache[this.dictName] = {
                                dictName: this.dictName,
                                loading: true,
                                data: []
                            };
                            this.init();
                        } else if (dictCache.loading) {// 请求数据中,休眠100毫秒再次尝试初始化
                            setTimeout(function () {
                                this.init()
                            }.bind(this), 100);
                        } else {
                            this.data = dictCache.data;
                        }
                    }
                }
            },
            mounted: function () {
                this.init();
            },
            template: '' +
            '<el-input-tree  ' +
            ' @input="input" ' +
            ' @change="change" ' +
            ' :value="value" ' +
            ' :data="data" ' +
            ' :clearable="clearable" ' +
            ' :size="size" ' +
            ' :multiple="multiple" ' +
            ' :props="props" ' +
            ' :filterable="filterable" ' +
            ' :valueFor="valueFor" ' +
            ' :placeholder="placeholder">' +
            '</el-input-tree>'
        });
        // 字典视图组件
        Vue.component('el-view-dict', {
            data: function () {
                return {
                    item: {}
                }
            },
            props: {
                value: {
                    type: String,
                    default: ''
                },
                dictName: {
                    type: String,
                    default: ''
                },
            },
            watch: {
                value: function (val, old) {
                    this.init();
                }
            },
            methods: {
                init: function () {
                    if (this.dictName) {
                        var dictCache = Vue.prototype.$dictCache[this.dictName];
                        if (typeof(dictCache) === "undefined") {
                            new Ajax("wframe", "dict", "load").post({
                                dictName: this.dictName
                            }, function (response) {
                                if (response.errors.length > 0) {
                                    console.error(response.errors[0].message)
                                } else {
                                    Vue.prototype.$dictCache[this.dictName].loading = false;
                                    Vue.prototype.$dictCache[this.dictName].data = response.result;
                                }
                            }.bind(this));
                            Vue.prototype.$dictCache[this.dictName] = {
                                dictName: this.dictName,
                                loading: true,
                                data: []
                            };
                            this.init();
                        } else if (dictCache.loading) {// 请求数据中,休眠100毫秒再次尝试初始化
                            setTimeout(function () {
                                this.init()
                            }.bind(this), 100);
                        } else {
                            this.options = dictCache.data;
                            this.options.forTree(function (item) {
                                if (item.value === this.value) {
                                    this.item = item;
                                }
                            }.bind(this));
                        }
                    }
                }
            },
            mounted: function () {
                this.init();
            },
            template: '' +
            '<span>{{item.label}}</span>'
        });
        // 用户组件
        Vue.component('el-input-user', {
            data: function () {
                return {
                    showValue: "",
                    item: {},
                    options: []
                }
            },
            props: {
                value: {
                    type: String | Object,
                    default: ''
                },
                valueFor: {
                    type: String,
                    default: 'id'
                },
                multipleLimit: {
                    type: Number,
                    default: 1
                },
                dictName: {
                    type: String,
                    default: ''
                },
                size: {
                    type: String,
                    default: 'mini'
                },
                placeholder: {
                    type: String,
                    default: ''
                },
                change: {
                    type: Function,
                    default: function (item) {

                    }
                }
            },
            watch: {},
            methods: {
                input: function (item) {
                    if (item.length > 0) {
                        if (this.multipleLimit === 1) {
                            this.$emit('input', item[0][this.valueFor]);
                        } else {
                            var values = []
                            for (var i = 0; i < item.length; i++) {
                                values.push(item[i][this.valueFor])
                            }
                            this.$emit('input', values);
                        }
                    }
                },
                onSearch: function (keyword) {
                    new Ajax("wadmin", "user", "find").post({
                        pageSize: 99
                    }, function (response) {
                        if (response.errors.length > 0) {
                            console.error(response.errors[0].message)
                        } else {
                            this.options = [];
                            if ("超级管理员".indexOf(keyword)) {
                                this.options.push({
                                    id: 0,
                                    userAlias: "超级管理员"
                                })
                            }
                            for (var i = 0; i < response.result.length; i++) {
                                this.options.push(response.result[i])
                            }
                        }
                    }.bind(this));
                },
                visibleChange: function (visible) {
                    if (visible) this.onSearch();
                }
            },
            template: '' +
            '<el-select :multiple="true" v-model="showValue" :multiple-limit="multipleLimit" @input="input" :value-key="valueFor" filterable clearable placeholder="请选择" :size="size" :placeholder="placeholder" @change="change" remote :remote-method="onSearch" @visible-change="visibleChange">' +
            ' <el-option v-for="item in options" :key="item.id" :label="item.userAlias" :value="item">' +
            '  <span style="float: left">{{ item.userAlias }}</span>' +
            '  <span style="float: right; color: #8492a6; font-size: 12px">{{ item.userName }}</span>' +
            ' </el-option>' +
            '</el-select>'
        });
        // 机构选择
        Vue.component('el-input-dept', {
            data: function () {
                return {
                    data: [],
                    props: {
                        key: "id",
                        label: "deptName",
                        value: "deptCode",
                        children: "children"
                    }
                }
            },
            props: {
                value: {
                    type: String,
                    default: ''
                },
                size: {
                    type: String,
                    default: 'mini'
                },
                clearable: {
                    type: Boolean,
                    default: true
                },
                filterable: {
                    type: Boolean,
                    default: true
                },
                multiple: {
                    type: Boolean,
                    default: false
                },
                placeholder: {
                    type: String,
                    default: ''
                },
                valueFor: {
                    type: String,
                    default: 'value',
                    validator: function (value) {
                        var r = (['value', 'label', 'item'].indexOf(value) !== -1);
                        if (!r) {
                            console.error("value-for的值只能是['value','label','item']中的一个.")
                        }
                        return r;
                    }
                }
            },
            methods: {
                input: function (value) {
                    this.$emit('input', value);
                },
                change: function (items) {
                    this.$emit('change', items);
                }
            },
            mounted: function () {
                var param = {tree: true};
                new Ajax("wadmin", "dept", "find").post(param, function (response) {
                    if (response.errors.length > 0) {
                        console.error(response.errors[0].message)
                    } else {
                        this.data = response.result;
                    }
                }.bind(this))
            },
            template: '' +
            '<el-input-tree  ' +
            ' @input="input" ' +
            ' @change="change" ' +
            ' :value="value" ' +
            ' :data="data" ' +
            ' :clearable="clearable" ' +
            ' :size="size" ' +
            ' :multiple="multiple" ' +
            ' :props="props" ' +
            ' :filterable="filterable" ' +
            ' :valueFor="valueFor" ' +
            ' :placeholder="placeholder">' +
            '</el-input-tree>'
        });
        // 表数据操作,动态操作项
        Vue.component('wb-table-ops', {
            data: function () {
                return {}
            },
            props: {
                size: {
                    type: String,
                    default: 'mini'
                },
                type: {
                    type: String,
                    default: 'primary'
                },
                splitButton: {
                    type: Boolean,
                    default: true
                },
                arg: {
                    type: Object | String | Number,
                    default: {}
                }
            },
            methods: {
                onCommand: function (index) {
                    if (this.$slots.menu[index].data.on.click) {
                        this.$slots.menu[index].data.on.click(this.arg);
                    }
                }
            },
            template: '' +
            '<el-dropdown ' +
            '  v-if="$slots.menu.length > 0"' +
            ' :size="size" ' +
            ' :type="type" ' +
            ' :split-button="splitButton" ' +
            ' @click="onCommand(0)" ' +
            ' @command="onCommand"><i :class="$slots.menu[0].data.attrs.icon"></i>{{$slots.menu[0].children[0].text}}' +
            '  <el-dropdown-menu slot="dropdown" style="white-space: nowrap">' +
            '    <el-dropdown-item v-for="(item,index) in $slots.menu" :key="index" v-if="index != 0" :command="index" :icon="item.data.attrs.icon">' +
            '      {{item.children[0].text}}' +
            '    </el-dropdown-item>' +
            '  </el-dropdown-menu>' +
            '</el-dropdown>'
        });
        // Vue复用组件
        var mixinBase = {
            data: {
                context: '${context?default("")}',
                //等待标记
                loading: false
            }
        }
        var mixinForMgr = {
            data: {
                //列表查询存放集合
                result: [],
                //列表选择集合
                select: []
            },
            methods: {
                onSearch: function () {
                    this.vm.pageNumber = 1;
                    this.onFind();
                },
                onReset: function (form) {
                    this.$refs[form].resetFields();
                    nav.s('重置成功');
                },
                onPageChange: function (pageNumber) {
                    this.vm.pageNumber = pageNumber;
                    this.onFind();
                },
                onPageSizeChange: function (pageSize) {
                    this.vm.pageSize = pageSize;
                    this.onFind();
                },
                onSelectionChange: function (select) {
                    this.select = select;
                },
                onTemplate: function () {
                    new Ajax(this.module, this.target).method("template").post({}, function (response) {
                        if (response.errors.length > 0) {
                            nav.e(response.errors[0].message);
                        }
                    })
                },
                onImport: function (item) {
                    $.selectFile(function (files) {
                        new Ajax(this.module, this.target).method("imports").post(files[0], function (response) {
                            if (response.errors.length > 0) {
                                nav.e(response.errors[0].message);
                            }
                        });
                    }.bind(this))
                },
                onExport: function () {
                    var req = JSON.parse(JSON.stringify(this.vm));
                    req.pageSize = 0;
                    new Ajax(this.module, this.target).method("exports").post(req, function (response) {
                        if (response.errors.length > 0) {
                            nav.e(response.errors[0].message);
                        }
                    });
                },
                onSave: function () {
                    this.$refs['form'].validate(function (valid) {
                        if (valid) {
                            if (this.form.id) {
                                new Ajax(this.module, this.target).update(this.form, function (response) {
                                    if (response.errors.length > 0) {
                                        nav.e(response.errors[0].message);
                                    } else {
                                        nav.s("保存成功.");
                                        this.onFind();
                                        this.$refs['form'].resetFields();
                                        this.form.formShow = false;
                                    }
                                }.bind(this))
                            } else {
                                new Ajax(this.module, this.target).create(this.form, function (response) {
                                    if (response.errors.length > 0) {
                                        nav.e(response.errors[0].message);
                                    } else {
                                        nav.s("保存成功.");
                                        this.onFind();
                                        this.$refs['form'].resetFields();
                                        this.form.formShow = false;
                                    }
                                }.bind(this))
                            }
                        } else {
                            return false;
                        }
                    }.bind(this));
                },
                onFind: function () {
                    new Ajax(this.module, this.target).find(this.vm, function (response) {
                        if (response.errors.length > 0) {
                            nav.e(response.errors[0].message);
                        } else {
                            this.result = response.result;
                            this.vm.totalCount = Number(response.totalCount);
                        }
                    }.bind(this))
                },
                onDelete: function (item) {
                    this.$confirm('将删除该项, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(function () {
                        new Ajax(this.module, this.target).delete({id: item.id}, function (response) {
                            if (response.errors.length > 0) {
                                nav.e(response.errors[0].message);
                            } else {
                                nav.s("删除成功");
                                this.onFind();
                            }
                        }.bind(this))
                    }.bind(this)).catch(function (action) {

                    });
                },
                onBitchDelete: function () {
                    if (this.select.length === 0) {
                        nav.w("至少选中一项");
                    } else {
                        this.$confirm('将删除已选择的项, 是否继续?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(function () {
                            nav.tipShow("删除中...");
                            this.select.forAsync(function (item, next) {
                                new Ajax(this.module, this.target).delete({id: item.id}, function (response) {
                                    if (response.errors.length > 0) {
                                        nav.e(response.errors[0].message);
                                    } else {
                                        this.result.remove(item)
                                    }
                                    next();
                                }.bind(this))
                            }.bind(this), function () {
                                nav.tipClose();
                                nav.i("批量删除结束.");
                                this.onFind();
                            }.bind(this))
                        }.bind(this)).catch(function (action) {

                        });
                    }
                }
            },
            created: function () {
            },
            mounted: function () {
            },
            filters: {},
            watch: {}
        };
    }
    // 实用小工具
    {
        window.nav = new Vue({
            data: {
                loadingTip: '',
                loadingBar: '',
                context: '${context?default("")}'
            },
            methods: {
                tipShow: function (msg) {
                    var message = "<i class='el-icon-loading'></i> 正在加载 ...";
                    if (msg) {
                        message = "<i class='el-icon-loading'></i> " + msg
                    }
                    if (!this.loadingTip) {
                        this.loadingTip = this.$message({
                            type: '',
                            duration: 0,
                            dangerouslyUseHTMLString: true,
                            message: message
                        });
                    } else {
                        this.loadingTip.message = message;
                    }
                },
                tipClose: function () {
                    if (this.loadingTip) {
                        this.loadingTip.close();
                        this.loadingTip = '';
                    }
                },
                barShow: function () {
                    if (window.index) {
                        window.index.barStart();
                    } else if (window.parent.index) {
                        window.parent.index.barStart();
                    }
                },
                barFinish: function () {
                    if (window.index) {
                        window.index.barFinish();
                    } else if (window.parent.index) {
                        window.parent.index.barFinish();
                    }
                },
                barError: function () {
                    if (window.index) {
                        window.index.barError();
                    } else if (window.parent.index) {
                        window.parent.index.barError();
                    }
                },
                i: function (message, callback) {
                    this.$message({
                        type: "info",
                        showClose: true,
                        message: message,
                        duration: 1500,
                        onClose: callback
                    });
                },
                e: function (message, callback) {
                    this.$message({
                        type: "error",
                        showClose: true,
                        message: message,
                        duration: 1500,
                        onClose: callback
                    });
                },
                w: function (message, callback) {
                    this.$message({
                        type: "warning",
                        showClose: true,
                        message: message,
                        duration: 1500,
                        onClose: callback
                    });
                },
                s: function (message, callback) {
                    this.$message({
                        type: "success",
                        showClose: true,
                        message: message,
                        duration: 1500,
                        onClose: callback
                    });
                },
                boxYes: function (title, message, callback) {
                    this.$alert(message, title, {
                        confirmButtonText: '确定'
                    }).then(function () {
                        callback ? callback(true) : '';
                    }).catch(function () {
                        callback ? callback(false) : '';
                    });
                },
                boxYesNo: function (title, message, callback) {
                    this.$confirm(message, title, {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消'
                    }).then(function () {
                        callback ? callback(true) : '';
                    }).catch(function () {
                        callback ? callback(false) : '';
                    });
                },
                boxInput: function (title, message, callback) {
                    this.$prompt(message, title, {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消'
                    }).then(function (value) {
                        callback ? callback(value.value) : '';
                    }).catch(function () {

                    });
                },
                boxHtml: function (title, html) {
                    this.$alert(html, title, {
                        dangerouslyUseHTMLString: true
                    });
                },
                // 回到首页
                toHome: function () {
                    location.href = this.context + "/"
                },
                // 打开一个新Tab
                tabOpen: function (tab) {
                    if (window.index) {
                        window.index.addTab(tab)
                    } else if (window.parent.index) {
                        window.parent.index.addTab(tab)
                    }
                },
                // 关闭Tab
                tabClose: function (tabName) {
                    if (window.index) {
                        window.index.removeTab(tabName)
                    } else if (window.parent.index) {
                        window.parent.index.removeTab(tabName)
                    }
                },
                // 关闭当前Tab
                tabCloseCur: function () {
                    if (window.index) {
                        window.index.removeTab(window.index.activeTabName)
                    } else if (window.parent.index) {
                        window.parent.index.removeTab(window.parent.index.activeTabName)
                    }
                },
                // 全屏
                screenFull: function () {
                    if (window.isFull)return;
                    window.isFull = true;
                    var docElm = document.documentElement;
                    // 如果首次全屏是程序发起而不是用户发起，则会出现fullscreen error
                    if (docElm.requestFullscreen) {//W3C
                        docElm.requestFullscreen();
                    } else if (docElm.mozRequestFullScreen) {//FireFox
                        docElm.mozRequestFullScreen();
                    } else if (docElm.webkitRequestFullScreen) {//Chrome等
                        docElm.webkitRequestFullScreen();
                    } else if (elem.msRequestFullscreen) {//IE11
                        elem.msRequestFullscreen();
                    } else if (typeof window.ActiveXObject !== "undefined") {
                        //for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏
                        var wscript = new ActiveXObject("WScript.Shell");
                        if (wscript !== null) {
                            wscript.SendKeys("{F11}");
                        }
                    }
                },
                // 取消全屏
                screenNotFull: function () {
                    if (!window.isFull)return;
                    window.isFull = false;
                    if (document.exitFullscreen) {//W3C
                        document.exitFullscreen();
                    } else if (document.mozCancelFullScreen) {//FireFox
                        document.mozCancelFullScreen();
                    } else if (document.webkitCancelFullScreen) {//Chrome等
                        document.webkitCancelFullScreen();
                    } else if (document.msExitFullscreen) {//IE11
                        document.msExitFullscreen();
                    } else if (typeof window.ActiveXObject !== "undefined") {
                        //for IE，这里和fullScreen相同，模拟按下F11键退出全屏
                        var wscript = new ActiveXObject("WScript.Shell");
                        if (wscript !== null) {
                            wscript.SendKeys("{F11}");
                        }
                    }
                },
                // 添加Cookie,expiretime可选
                setCookie: function (name, value, expiretime) {
                    if (typeof expiretime === 'undefined') {
                        document.cookie = name + "=" + encodeURIComponent(value) + ";path=/";
                    } else {
                        var exdate = new Date();
                        exdate.setDate(exdate.getTime() + expiretime);
                        document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + exdate.toGMTString() + ";path=/";
                    }
                },
                // 获取Cookie
                getCookie: function (name) {
                    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
                    if (arr = document.cookie.match(reg)) {
                        return decodeURIComponent(arr[2]);
                    } else {
                        return "";
                    }
                },
                // 删除Cookie
                clearCookie: function (name) {
                    this.setCookie(name, "", -1);
                }
            }
        });
    }
</script>