suerprisePlus
2024-05-30 d4c810f9803aa13d806724a5f4f71fe85abac38e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
    <div style="margin-top:-50px;">
        <el-divider></el-divider>
        <el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
            <el-form-item label="名称" prop="templateName">
                <el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="类别" prop="type">
                <el-select v-model="queryParams.type" placeholder="请选择模型类别" clearable size="small">
                    <el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label"
                        :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
 
        <el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange"
            ref="selectTemplateTable" size="small">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="名称" align="center" prop="templateName" />
            <el-table-column label="标识符" align="center" prop="identifier" />
            <el-table-column label="物模型类别" align="center" prop="type">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_things_type" :value="scope.row.type" />
                </template>
            </el-table-column>
            <el-table-column label="图表展示" align="center" prop="isChart" width="75">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isChart" />
                </template>
            </el-table-column>
            <el-table-column label="实时监测" align="center" prop="isMonitor" width="75">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
                </template>
            </el-table-column>
            <el-table-column label="只读" align="center" prop="isReadonly" width="75">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isReadonly" />
                </template>
            </el-table-column>
            <el-table-column label="历史存储" align="center" prop="isHistory" width="75">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isHistory" />
                </template>
            </el-table-column>
            <el-table-column label="数据类型" align="center" prop="datatype">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
                </template>
            </el-table-column>
        </el-table>
 
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
    </div>
</template>
 
<script>
import {
    listTemplate,
} from "@/api/iot/template";
export default {
    name: "product-select-template",
    dicts: ["iot_things_type", "iot_data_type", "iot_yes_no"],
    data() {
        return {
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 总条数
            total: 0,
            // 通用物模型表格数据
            templateList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                templateName: null,
                type: null,
            },
        };
    },
    created() {
        this.getList();
        this.ids = [];
    },
    methods: {
        /** 查询通用物模型列表 */
        getList() {
            this.loading = true;
            listTemplate(this.queryParams).then((response) => {
                this.templateList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("product-select-template");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.templateId);
            this.single = selection.length !== 1;
            this.multiple = !selection.length;
            // Id数组传递到父组件
            this.$emit('idsToParentEvent', this.ids);
        },
    },
};
</script>