New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| | | <el-form-item label="部署名称" prop="deploymentName"> |
| | | <el-input |
| | | v-model="queryParams.deploymentName" |
| | | placeholder="请输入部署名称" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="版本" prop="edition"> |
| | | <el-select v-model="queryParams.edition" placeholder="请选择版本"> |
| | | <el-option |
| | | v-for="dict in dict.type.DICT110" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="安装位置" prop="buildingId"> |
| | | <building v-model="queryParams.buildingId" :schoolId="schoolId"></building> |
| | | </el-form-item> |
| | | <el-form-item label="所属单位" prop="organizationId"> |
| | | <organization v-model="queryParams.organizationId" :schoolId="schoolId"></organization> |
| | | </el-form-item> |
| | | <el-form-item label="施工批次" prop="constructionBatchId"> |
| | | <construction-batch v-model="queryParams.constructionBatchId" :schoolId="schoolId"></construction-batch> |
| | | </el-form-item> |
| | | <el-form-item label="监控对象" prop="monitorObject"> |
| | | <el-input |
| | | v-model="queryParams.monitorObject" |
| | | placeholder="请输入监控对象" |
| | | clearable |
| | | size="small" |
| | | @keyup.enter.native="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="通道" prop="passageway"> |
| | | <el-select v-model="queryParams.passageway" placeholder="请选择通道" clearable size="small"> |
| | | <el-option |
| | | v-for="dict in dict.type.DICT111" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="外设" prop="peripheralUnit"> |
| | | <peripheralUnit v-model="queryParams.peripheralUnit"></peripheralUnit> |
| | | </el-form-item> |
| | | <el-form-item label="外设数量"> |
| | | <el-input v-model="sum" disabled/> |
| | | </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-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="el-icon-plus" |
| | | size="mini" |
| | | @click="handleAdd" |
| | | v-hasPermi="['oa:iot:add']" |
| | | >新增 |
| | | </el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="el-icon-edit" |
| | | size="mini" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['oa:iot:edit']" |
| | | >修改 |
| | | </el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="el-icon-delete" |
| | | size="mini" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['oa:iot:remove']" |
| | | >删除 |
| | | </el-button> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="iotList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center"/> |
| | | <el-table-column label="序号" align="center" width="50"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ scope.$index + (queryParams.pageNum - 1) * queryParams.pageSize + 1 }} </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="部署名称" align="center" prop="deploymentName"/> |
| | | <el-table-column label="版本" align="center" prop="edition"> |
| | | <template slot-scope="scope"> |
| | | <dict-tag :options="dict.type.DICT110" :value="scope.row.edition"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="LAN" align="center" prop="lan"/> |
| | | <el-table-column label="IP" align="center" prop="ip"/> |
| | | <el-table-column label="通道1" align="center" prop="passagewayOne_dictText"/> |
| | | <el-table-column label="通道2" align="center" prop="passagewayTwo_dictText"/> |
| | | <el-table-column label="通道3" align="center" prop="passagewayThree_dictText"/> |
| | | <el-table-column label="通道4" align="center" prop="passagewayFour_dictText"/> |
| | | <el-table-column label="安装位置" align="center" prop="buildingId_dictText"/> |
| | | <el-table-column label="所属单位" align="center" prop="organizationId_dictText"/> |
| | | <el-table-column label="施工批次" align="center" prop="constructionBatchId_dictText"/> |
| | | <!-- <el-table-column label="序列号" align="center" prop="serialNumber"/>--> |
| | | <!-- <el-table-column label="型号" align="center" prop="model"/>--> |
| | | <el-table-column label="生产厂商" align="center" prop="manufacturerId_dictText"/> |
| | | <el-table-column label="监控对象" align="center" prop="monitorObject"/> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-view" |
| | | @click="handleInfo(scope.row)" |
| | | v-hasPermi="['oa:iot:edit']" |
| | | >查看 |
| | | </el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | icon="el-icon-edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['oa:iot:edit']" |
| | | >修改 |
| | | </el-button> |
| | | <el-button |
| | | size="mini" |
| | | type="text" |
| | | class="del-btn" |
| | | icon="el-icon-delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['oa:iot:remove']" |
| | | >删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | :page.sync="queryParams.pageNum" |
| | | :limit.sync="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改IoT设备对话框 --> |
| | | <el-dialog :title="title" :visible.sync="open" width="700px" :append-to-body="true" :close-on-click-modal="false"> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="80px" :disabled="disabled"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部署名称" prop="deploymentName"> |
| | | <el-input v-model="form.deploymentName" maxlength="64" show-word-limit placeholder="请输入部署名称"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="版本" prop="edition"> |
| | | <el-select v-model="form.edition" placeholder="请选择版本"> |
| | | <el-option |
| | | v-for="dict in dict.type.DICT110" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="LAN" prop="lan"> |
| | | <el-input v-model="form.lan" placeholder="请输入LAN"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="IP" prop="ip"> |
| | | <el-input v-model="form.ip" placeholder="请输入IP"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="通道1" prop="passagewayOne"> |
| | | <peripheralUnit v-if="open" v-model="form.passagewayOne"></peripheralUnit> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="通道2" prop="passagewayTwo"> |
| | | <peripheralUnit v-if="open" v-model="form.passagewayTwo"></peripheralUnit> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="通道3" prop="passagewayThree"> |
| | | <peripheralUnit v-if="open" v-model="form.passagewayThree"></peripheralUnit> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="通道4" prop="passagewayFour"> |
| | | <peripheralUnit v-if="open" v-model="form.passagewayFour"></peripheralUnit> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="安装位置" prop="buildingId"> |
| | | <building v-if="open" v-model="form.buildingId" :schoolId="schoolId"></building> |
| | | </el-form-item> |
| | | <el-form-item label="所属单位" prop="organizationId"> |
| | | <organization v-if="open" v-model="form.organizationId" :schoolId="schoolId"></organization> |
| | | </el-form-item> |
| | | <el-form-item label="施工批次" prop="constructionBatchId"> |
| | | <constructionBatch v-if="open" v-model="form.constructionBatchId" :schoolId="schoolId"></constructionBatch> |
| | | </el-form-item> |
| | | <el-form-item label="序列号" prop="serialNumber"> |
| | | <el-input v-model="form.serialNumber" maxlength="64" show-word-limit placeholder="请输入序列号"/> |
| | | </el-form-item> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="型号" prop="model"> |
| | | <el-input v-model="form.model" maxlength="64" show-word-limit placeholder="请输入型号"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="生产厂商" prop="manufacturerId"> |
| | | <manufacturer v-if="open" v-model="form.manufacturerId"></manufacturer> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="监控对象" prop="monitorObject"> |
| | | <el-input v-model="form.monitorObject" type="textarea" maxlength="512" show-word-limit :rows="8" placeholder="请输入内容"/> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button :loading="buttonLoading" type="primary" @click="submitForm" :disabled="disabled">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import {listIot, getIot, delIot, addIot, updateIot, numberList} from "@/api/oa/iot"; |
| | | import building from "../../components/building"; |
| | | import organization from "../../components/organization"; |
| | | import constructionBatch from "../../components/constructionBatch"; |
| | | import manufacturer from "../../components/manufacturer"; |
| | | import peripheralUnit from '../../components/peripheralUnit' |
| | | |
| | | export default { |
| | | name: "Iot", |
| | | dicts: ['DICT111', 'DICT110'], |
| | | props: { |
| | | schoolId: { |
| | | type: Number, |
| | | default: undefined |
| | | } |
| | | }, |
| | | components: { |
| | | building, |
| | | organization, |
| | | constructionBatch, |
| | | manufacturer, |
| | | peripheralUnit |
| | | }, |
| | | data() { |
| | | return { |
| | | // 按钮loading |
| | | buttonLoading: false, |
| | | // 遮罩层 |
| | | loading: true, |
| | | // 选中数组 |
| | | ids: [], |
| | | // 非单个禁用 |
| | | single: true, |
| | | // 非多个禁用 |
| | | multiple: true, |
| | | // 显示搜索条件 |
| | | showSearch: true, |
| | | // 总条数 |
| | | total: 0, |
| | | // IoT设备表格数据 |
| | | iotList: [], |
| | | // 弹出层标题 |
| | | title: "", |
| | | // 是否显示弹出层 |
| | | open: false, |
| | | // 查询参数 |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | deploymentName: undefined, |
| | | edition: undefined, |
| | | buildingId: undefined, |
| | | organizationId: undefined, |
| | | constructionBatchId: undefined, |
| | | monitorObject: undefined, |
| | | passageway: undefined, |
| | | peripheralUnit: undefined, |
| | | }, |
| | | // 表单参数 |
| | | form: {}, |
| | | // 表单校验 |
| | | rules: { |
| | | id: [ |
| | | {required: true, message: "不能为空", trigger: "blur"} |
| | | ], |
| | | deploymentName: [ |
| | | {required: true, message: "部署名称不能为空", trigger: "blur"} |
| | | ], |
| | | edition: [ |
| | | {required: true, message: "版本不能为空", trigger: "blur"} |
| | | ], |
| | | lan: [ |
| | | {required: true, message: "LAN不能为空", trigger: "blur"}, |
| | | { |
| | | pattern: /^[A-F0-9]{2}(-[A-F0-9]{2}){5}$|^[A-F0-9]{2}(:[A-F0-9]{2}){5}$|^[A-F0-9]{12}$|^[A-F0-9]{4}(\.[A-F0-9]{4}){2}$/, |
| | | message: "请输入正确的LAN", |
| | | trigger: "blur" |
| | | } |
| | | ], |
| | | ip: [ |
| | | {required: true, message: "IP不能为空", trigger: "blur"}, |
| | | { |
| | | pattern: /^(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])$/, |
| | | message: "请输入正确的ip地址", |
| | | trigger: "blur" |
| | | } |
| | | ], |
| | | buildingId: [ |
| | | {required: true, message: "安装位置不能为空", trigger: "blur"} |
| | | ], |
| | | organizationId: [ |
| | | {required: true, message: "所属单位不能为空", trigger: "blur"} |
| | | ], |
| | | constructionBatchId: [ |
| | | {required: true, message: "施工批次不能为空", trigger: "blur"} |
| | | ], |
| | | }, |
| | | disabled: false, |
| | | sum: undefined |
| | | }; |
| | | }, |
| | | computed: { |
| | | getPassageway() { |
| | | return this.queryParams.passageway |
| | | }, |
| | | getPeripheralUnit() { |
| | | return this.queryParams.peripheralUnit |
| | | } |
| | | }, |
| | | watch: { |
| | | 'schoolId': function () { |
| | | this.getList() |
| | | }, |
| | | getPassageway: function (v) { |
| | | if (v && this.queryParams.peripheralUnit) { |
| | | this.getNum(); |
| | | } |
| | | }, |
| | | getPeripheralUnit: function (v) { |
| | | if (v && this.queryParams.passageway) { |
| | | this.getNum(); |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.getList(); |
| | | }, |
| | | methods: { |
| | | /** 查询IoT设备列表 */ |
| | | getList() { |
| | | this.loading = true; |
| | | listIot(Object.assign({}, this.queryParams, {schoolId: this.schoolId})).then(response => { |
| | | this.iotList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | | }); |
| | | if (this.queryParams.peripheralUnit && this.queryParams.passageway) { |
| | | this.getNum(); |
| | | } |
| | | }, |
| | | // 取消按钮 |
| | | cancel() { |
| | | this.open = false; |
| | | this.reset(); |
| | | }, |
| | | // 表单重置 |
| | | reset() { |
| | | this.form = { |
| | | id: undefined, |
| | | deploymentName: undefined, |
| | | edition: undefined, |
| | | lan: undefined, |
| | | ip: undefined, |
| | | buildingId: undefined, |
| | | organizationId: undefined, |
| | | constructionBatchId: undefined, |
| | | serialNumber: undefined, |
| | | model: undefined, |
| | | manufacturerId: undefined, |
| | | monitorObject: undefined, |
| | | passagewayOne: undefined, |
| | | passagewayTwo: undefined, |
| | | passagewayThree: undefined, |
| | | passagewayFour: undefined, |
| | | createBy: undefined, |
| | | createTime: undefined, |
| | | updateBy: undefined, |
| | | updateTime: undefined, |
| | | delFlag: undefined |
| | | }; |
| | | this.resetForm("form"); |
| | | }, |
| | | /** 搜索按钮操作 */ |
| | | handleQuery() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** 重置按钮操作 */ |
| | | resetQuery() { |
| | | this.resetForm("queryForm"); |
| | | this.handleQuery(); |
| | | }, |
| | | // 多选框选中数据 |
| | | handleSelectionChange(selection) { |
| | | this.ids = selection.map(item => item.id) |
| | | this.single = selection.length !== 1 |
| | | this.multiple = !selection.length |
| | | }, |
| | | /** 新增按钮操作 */ |
| | | handleAdd() { |
| | | this.reset(); |
| | | this.disabled = false; |
| | | this.open = true; |
| | | this.title = "添加IoT设备"; |
| | | }, |
| | | /** 修改按钮操作 */ |
| | | handleUpdate(row) { |
| | | this.loading = true; |
| | | this.disabled = false; |
| | | this.reset(); |
| | | const id = row.id || this.ids |
| | | getIot(id).then(response => { |
| | | this.loading = false; |
| | | this.form = response.data; |
| | | this.open = true; |
| | | this.title = "修改IoT设备"; |
| | | }); |
| | | }, |
| | | handleInfo(row) { |
| | | this.loading = true; |
| | | this.disabled = true; |
| | | this.reset(); |
| | | getIot(row.id).then(response => { |
| | | this.loading = false; |
| | | this.form = response.data; |
| | | this.open = true; |
| | | this.title = "IoT设备详情"; |
| | | }); |
| | | }, |
| | | /** 提交按钮 */ |
| | | submitForm() { |
| | | this.$refs["form"].validate(valid => { |
| | | if (valid) { |
| | | this.buttonLoading = true; |
| | | this.form.schoolId = this.schoolId; |
| | | if (this.form.id != null) { |
| | | updateIot(this.form).then(response => { |
| | | this.$modal.msgSuccess("修改成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } else { |
| | | addIot(this.form).then(response => { |
| | | this.$modal.msgSuccess("新增成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | /** 删除按钮操作 */ |
| | | handleDelete(row) { |
| | | const ids = row.id || this.ids; |
| | | this.$modal.confirm('是否确认删除IoT设备编号为"' + ids + '"的数据项?').then(() => { |
| | | this.loading = true; |
| | | return delIot(ids); |
| | | }).then(() => { |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.$modal.msgSuccess("删除成功"); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** 导出按钮操作 */ |
| | | handleExport() { |
| | | this.download('oa/iot/export', { |
| | | ...this.queryParams |
| | | }, `iot_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | // 获取外设数量 |
| | | getNum() { |
| | | numberList(Object.assign({}, this.queryParams, {schoolId: this.schoolId})).then(res => { |
| | | this.sum = res.data; |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | | </script> |