From addcc1a144ff8b548a01571f637fafb19132190a Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期一, 25 三月 2024 15:41:04 +0800
Subject: [PATCH] 工单阈值
---
src/views/system/threshold/index.vue | 352 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/api/platform/threshold.js | 44 ++++++
2 files changed, 396 insertions(+), 0 deletions(-)
diff --git a/src/api/platform/threshold.js b/src/api/platform/threshold.js
new file mode 100644
index 0000000..f11bf24
--- /dev/null
+++ b/src/api/platform/threshold.js
@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 鏌ヨ杩愮淮闃堝�煎垪琛�
+export function listThreshold(query) {
+ return request({
+ url: '/ycl/threshold/list',
+ method: 'get',
+ params: query
+ })
+}
+
+// 鏌ヨ杩愮淮闃堝�艰缁�
+export function getThreshold(id) {
+ return request({
+ url: '/ycl/threshold/' + id,
+ method: 'get'
+ })
+}
+
+// 鏂板杩愮淮闃堝��
+export function addThreshold(data) {
+ return request({
+ url: '/ycl/threshold',
+ method: 'post',
+ data: data
+ })
+}
+
+// 淇敼杩愮淮闃堝��
+export function updateThreshold(data) {
+ return request({
+ url: '/ycl/threshold',
+ method: 'put',
+ data: data
+ })
+}
+
+// 鍒犻櫎杩愮淮闃堝��
+export function delThreshold(id) {
+ return request({
+ url: '/ycl/threshold/' + id,
+ method: 'delete'
+ })
+}
diff --git a/src/views/system/threshold/index.vue b/src/views/system/threshold/index.vue
new file mode 100644
index 0000000..9144c2b
--- /dev/null
+++ b/src/views/system/threshold/index.vue
@@ -0,0 +1,352 @@
+<template>
+ <div class="app-container">
+ <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="['ycl:threshold: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="['ycl:threshold: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="['ycl:threshold:remove']"
+ >鍒犻櫎
+ </el-button>
+ </el-col>
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+ </el-row>
+
+ <el-table v-loading="loading" :data="thresholdList" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55" align="center"/>
+ <el-table-column label="璁惧绫诲瀷" align="center" prop="monitorType">
+ <template slot-scope="scope">
+ <span v-show="scope.row['monitorType'] === '1'">浜鸿劯</span>
+ <span v-show="scope.row['monitorType'] === '2'">杞﹁締</span>
+ <span v-show="scope.row['monitorType'] === '3'">瑙嗛</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="瓒呮椂澶╂暟" align="center" prop="timeout"/>
+ <el-table-column label="鎸囨爣" align="center" prop="indicator">
+ <template slot-scope="scope">
+ <div v-for="item in JSON.parse(scope.row.indicator)" :key="item">
+ {{ item.label }}锛歿{ item.value }}
+ </div>
+ </template>
+ </el-table-column>
+ <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-edit"
+ @click="handleUpdate(scope.row)"
+ v-hasPermi="['ycl:threshold:edit']"
+ >淇敼
+ </el-button>
+ <el-button
+ size="mini"
+ type="text"
+ icon="el-icon-delete"
+ @click="handleDelete(scope.row)"
+ v-hasPermi="['ycl:threshold: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"
+ />
+
+ <!-- 娣诲姞鎴栦慨鏀硅繍缁撮槇鍊煎璇濇 -->
+ <el-dialog :title="title" :visible.sync="open" width="400px" append-to-body>
+ <el-form ref="form" :model="form" :rules="rules" label-width="150px">
+ <el-form-item label="璁惧绫诲瀷" prop="monitorType">
+ <el-select v-model="form.monitorType" placeholder="璇烽�夋嫨璁惧绫诲瀷" @change="handleModeNameChange">
+ <el-option label="浜鸿劯" value="1"/>
+ <el-option label="杞﹁締" value="2"/>
+ <el-option label="瑙嗛" value="3"/>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="瓒呮椂澶╂暟" prop="timeout" label-width="150px">
+ <el-input type="number" min="0" max="1000" v-model="form.timeout" placeholder="璇疯緭鍏ヨ秴鏃跺ぉ鏁�"/>
+ </el-form-item>
+ <el-form-item :label="indicator.label" prop="indexOneValue" v-for="indicator in indicators" label-width="150px">
+ <el-input class="el-input-width" v-model="indicator.value" :placeholder="'璇疯緭鍏�' + indicator.label"/>
+ </el-form-item>
+ </el-form>
+ <div slot="footer" class="dialog-footer">
+ <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
+ <el-button @click="cancel">鍙� 娑�</el-button>
+ </div>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+import { listThreshold, getThreshold, delThreshold, addThreshold, updateThreshold } from '@/api/platform/threshold'
+
+export default {
+ name: 'Threshold',
+ data() {
+ return {
+ indicators: [],
+ // 閬僵灞�
+ loading: true,
+ // 閫変腑鏁扮粍
+ ids: [],
+ // 闈炲崟涓鐢�
+ single: true,
+ // 闈炲涓鐢�
+ multiple: true,
+ // 鏄剧ず鎼滅储鏉′欢
+ showSearch: true,
+ // 鎬绘潯鏁�
+ total: 0,
+ // 杩愮淮闃堝�艰〃鏍兼暟鎹�
+ thresholdList: [],
+ // 寮瑰嚭灞傛爣棰�
+ title: '',
+ // 鏄惁鏄剧ず寮瑰嚭灞�
+ open: false,
+ // 鏌ヨ鍙傛暟
+ queryParams: {
+ pageNum: 1,
+ pageSize: 10,
+ monitorType: null
+ },
+ // 琛ㄥ崟鍙傛暟
+ form: {},
+ // 琛ㄥ崟鏍¢獙
+ rules: {
+ monitorType: [
+ { required: true, message: '璁惧绫诲瀷锛�1浜鸿劯 2杞﹁締 3瑙嗛涓嶈兘涓虹┖', trigger: 'change' }
+ ],
+ timeout: [
+ { required: true, message: '瓒呮椂澶╂暟涓嶈兘涓虹┖', trigger: 'blur' }
+ ]
+ }
+ }
+ },
+ created() {
+ this.getList()
+ },
+ methods: {
+ /** 鏌ヨ杩愮淮闃堝�煎垪琛� */
+ getList() {
+ this.loading = true
+ listThreshold(this.queryParams).then(response => {
+ this.thresholdList = response.rows
+ this.total = response.total
+ this.loading = false
+ })
+ },
+ // 鍙栨秷鎸夐挳
+ cancel() {
+ this.open = false
+ this.reset()
+ },
+ // 琛ㄥ崟閲嶇疆
+ reset() {
+ this.form = {
+ id: null,
+ monitorType: null,
+ timeout: null,
+ indicator: null,
+ createTime: null,
+ updateTime: null,
+ deleted: null
+ }
+ 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.open = true
+ this.title = '娣诲姞杩愮淮闃堝��'
+ this.handleModeNameChange()
+ },
+ /** 淇敼鎸夐挳鎿嶄綔 */
+ handleUpdate(row) {
+ this.reset()
+ const id = row.id || this.ids
+ getThreshold(id).then(response => {
+ this.form = response.data
+ this.indicators = JSON.parse(this.form.indicator)
+ this.open = true
+ this.title = '淇敼杩愮淮闃堝��'
+ })
+ },
+ /** 鎻愪氦鎸夐挳 */
+ submitForm() {
+ this.$refs['form'].validate(valid => {
+ if (valid) {
+ // 灏唅ndicators杞负json璧嬪�煎埌form
+ this.form.indicator = JSON.stringify(this.indicators)
+ if (this.form.id != null) {
+ updateThreshold(this.form).then(response => {
+ this.$modal.msgSuccess('淇敼鎴愬姛')
+ this.open = false
+ this.getList()
+ })
+ } else {
+ addThreshold(this.form).then(response => {
+ this.$modal.msgSuccess('鏂板鎴愬姛')
+ this.open = false
+ this.getList()
+ })
+ }
+ }
+ })
+ },
+ /** 鍒犻櫎鎸夐挳鎿嶄綔 */
+ handleDelete(row) {
+ const ids = row.id || this.ids
+ this.$modal.confirm('鏄惁纭鍒犻櫎杩愮淮闃堝�肩紪鍙蜂负"' + ids + '"鐨勬暟鎹」锛�').then(function() {
+ return delThreshold(ids)
+ }).then(() => {
+ this.getList()
+ this.$modal.msgSuccess('鍒犻櫎鎴愬姛')
+ }).catch(() => {
+ })
+ },
+ /** 鍒囨崲涓嶅悓鎸囨爣 */
+ handleModeNameChange() {
+ if (this.form.monitorType === '1' || this.form.monitorType === null) {
+ this.indicators = [
+ {
+ label: '鎶撴媿閲�',
+ value: null
+ },
+ {
+ label: '鍙婃椂鐜�',
+ value: null
+ },
+ {
+ label: '寤惰繜閲�',
+ value: null
+ },
+ {
+ label: '鎶芥閲�',
+ value: null
+ },
+ {
+ label: '璁惧娲昏穬鐜�',
+ value: null
+ },
+ {
+ label: '鎶撴媿鍙婃椂鐜�',
+ value: null
+ },
+ {
+ label: '鏃堕挓鍑嗙‘鐜�',
+ value: null
+ },
+ {
+ label: '鏃堕挓涓嶅噯纭巼',
+ value: null
+ }
+ ]
+ } else if (this.form.monitorType === '2') {
+ this.indicators = [
+ {
+ label: '杩囪溅鏁版嵁閲�',
+ value: null
+ },
+ {
+ label: '杩囪溅缂哄け鐜�',
+ value: null
+ },
+ {
+ label: '鏈夋晥杩囪溅鏁版嵁閲�',
+ value: null
+ },
+ {
+ label: '鎶芥閲�',
+ value: null
+ },
+ {
+ label: '璁惧娲昏穬鐜�',
+ value: null
+ },
+ {
+ label: '鎶撴媿鍙婃椂鐜�',
+ value: null
+ },
+ {
+ label: '鏃堕挓鍑嗙‘鐜�',
+ value: null
+ },
+ {
+ label: '鏃堕挓涓嶅噯纭巼',
+ value: null
+ }
+ ]
+ } else if (this.form.monitorType === '3') {
+ this.indicators = [
+ {
+ label: '閲囬泦璁惧鎬绘暟',
+ value: null
+ },
+ {
+ label: '鐩戞祴姝e父璁惧鏁�',
+ value: null
+ },
+ {
+ label: '缂栫爜寮傚父璁惧鏁�',
+ value: null
+ },
+ {
+ label: '缁忕含搴﹀紓甯歌澶囨暟',
+ value: null
+ }
+ ]
+ }
+ }
+ }
+}
+</script>
--
Gitblit v1.8.0