<template>
    <fieldset>
        <legend>
            <el-tag type="info">按需操作</el-tag>
        </legend>
        <div class="op-header">
            <div class="left-panel">
                <el-button type="primary" icon="el-icon-plus" @click="table_add()">新增打印机</el-button>
                <el-button type="warning" icon="el-icon-refresh" @click="table_refresh()">查询状态</el-button>
            </div>
        </div>
    </fieldset>
    <formMain ref="formMain" @success="handleSuccess"></formMain>
</template>

<script>
import formMain from './form';
export default {
    components: {
        formMain
    },
    props: {
        type: { type: String, default: "1" },
        dataSelect: { type: Array, default: () => [] },
        searchKey: { type: Object, default: () => {} },
        dataSelectFull: { type: Array, default: () => [] }
    },
    data(){
        return {

        }
    },
    methods: {
        async table_refresh(){
            var loading = this.$loading();
            var resp = await this.$API.print.refresh.post({});
            loading.close();
            if (resp.code == 0) {
                return this.$message.error(resp.msg);
            }
            this.$message.success(resp.msg);
        },
        table_add(){
            this.$nextTick(() => {
                this.$refs.formMain.open()
            })
        },
        handleSuccess(){
            this.$emit("success");
        },
    }
}
</script>