From c89113ec9b5032b5553334ec6c9ac3700ba6c398 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 23 六月 2022 16:35:29 +0800
Subject: [PATCH] 1.设备管理、设备类型(查询、新增、删除)功能开发 2.设备管理、设备组(查询、新增、删除)功能开发
---
src/views/sbgl/sbqd.vue | 323 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 290 insertions(+), 33 deletions(-)
diff --git a/src/views/sbgl/sbqd.vue b/src/views/sbgl/sbqd.vue
index 5fe46db..717a8a9 100644
--- a/src/views/sbgl/sbqd.vue
+++ b/src/views/sbgl/sbqd.vue
@@ -9,15 +9,15 @@
inline
style="display: flex;justify-content: space-between"
>
- <div class="elForm" style="width:100%">
+ <div class="elForm">
<el-form-item label="璁惧缂栫爜" style=" display: flex;">
- <el-input v-model="form.DeviceCode" placeholder="璇疯緭鍏�" style="width: calc(100%-30px)" />
+ <el-input v-model="form.DeviceCode" placeholder="璇疯緭鍏�" style="width: 200px" />
</el-form-item>
<el-form-item label="璁惧鍚嶇О" style=" display: flex;">
- <el-input v-model="form.DeviceName" placeholder="璇疯緭鍏�" style="width: calc(100%-30px)" />
+ <el-input v-model="form.DeviceName" placeholder="璇疯緭鍏�" style="width: 200px" />
</el-form-item>
<el-form-item label="浣跨敤鐘舵��" style=" display: flex;">
- <el-select v-model="form.Status" filterable style="width: calc(100%-30px)" placeholder="璇烽�夋嫨">
+ <el-select v-model="form.Status" filterable style="width: 200px" placeholder="璇烽�夋嫨">
<el-option
v-for="item in StatusArr"
:key="item.value"
@@ -27,7 +27,7 @@
</el-select>
</el-form-item>
<el-form-item label="鎵�灞炶溅闂�" style=" display: flex;">
- <el-select v-model="form.WorkShop" filterable style="width: calc(100%-30px)" placeholder="璇烽�夋嫨">
+ <el-select v-model="form.WorkShop" filterable style="width: 200px" placeholder="璇烽�夋嫨">
<el-option
v-for="item in WorkShopArr"
:key="item.code"
@@ -37,7 +37,7 @@
</el-select>
</el-form-item>
<el-form-item filterable label="璁惧绫诲瀷" style="display: flex;">
- <el-select v-model="form.DeviceType" style="width: calc(100%-30px)" placeholder="璇烽�夋嫨" @change="deviceTypeChange">
+ <el-select v-model="form.DeviceType" style="width: 200px" placeholder="璇烽�夋嫨" @change="deviceTypeChange">
<el-option
v-for="item in DeviceTypeArr"
:key="item.code"
@@ -47,7 +47,12 @@
</el-select>
</el-form-item>
<el-form-item label="璁惧缁�" style=" display: flex;">
- <el-select v-model="form.DeviceGroup" :disabled="form.DeviceType===''" style="width: calc(100%-30px)" placeholder="璇烽�夋嫨">
+ <el-select
+ v-model="form.DeviceGroup"
+ :disabled="form.DeviceType===''"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+ >
<el-option
v-for="item in DeviceGroupArr"
:key="item.code"
@@ -74,6 +79,7 @@
<el-table
:data="tableData"
border
+ stripe
highlight-current-row
:style="{width: 100+'%',height:tableHeight+'px'}"
:header-cell-style="this.$headerCellStyle"
@@ -246,7 +252,7 @@
<!--璁惧绫诲瀷-->
<el-dialog
- title="瑙掕壊绫诲瀷"
+ title="璁惧绫诲瀷"
:visible.sync="DeviceTypeDialogVisible"
width="50%"
top="15vh"
@@ -310,12 +316,6 @@
<el-button v-if="row.isVisible===1" type="text" @click="DeviceTypeCancel(row)">鍙栨秷</el-button>
</div>
</template>
- <!-- <template v-for="item in RoleTypeCodeArr" slot-scope="{row}">-->
- <!-- <div :key="item.roletype_code" class="operationClass">-->
- <!-- <el-button v-if="item.isVisible" type="text" @click="formSettingSave(row)">淇濆瓨</el-button>-->
- <!-- <el-button v-if="item.isVisible" type="text" @click="formSettingCancel(row)">鍙栨秷</el-button>-->
- <!-- </div>-->
- <!-- </template>-->
</el-table-column>
</el-table>
<!--鍒嗛〉-->
@@ -338,16 +338,127 @@
</el-dialog>
<!--璁惧缁�-->
+ <el-dialog
+ title="璁惧缁�"
+ :visible.sync="DeviceGroupDialogVisible"
+ width="70%"
+ top="15vh"
+ class="DeviceTypeDialogVisible"
+ @close="handleCloseDeviceGroup"
+ >
+ <div style="margin-bottom: 20px;display: flex">
+ <el-button type="primary" icon="el-icon-circle-plus-outline" @click="addDeviceGroup">鏂板</el-button>
+ </div>
+ <el-table
+ :data="DeviceGroupArray"
+ border
+ highlight-current-row
+ :style="{width: 100+'%',height:tableHeight-300+'px'}"
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ @sort-change="sortChangeOfDeviceGroup"
+ >
+ <el-table-column
+ width="50"
+ label="搴忓彿"
+ prop="RowNum"
+ />
+ <el-table-column
+ prop="code"
+ label="鍒嗙粍缂栫爜"
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <el-input v-if="row.isVisible===1" v-model="row.code" placeholder="璇疯緭鍏�" />
+ <div v-else> {{ row.code }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="name"
+ label="鍒嗙粍鍚嶇О"
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <el-input v-if="row.isVisible===1" v-model="row.name" placeholder="璇疯緭鍏�" />
+ <div v-else> {{ row.name }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="eqptype_name"
+ label="鎵�灞炶澶囩被鍨�"
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <!-- <el-input v-if="row.isVisible===1" v-model="row.eqptype_code" placeholder="璇疯緭鍏�" />-->
+ <el-select v-if="row.isVisible===1" v-model="row.eqptype_code" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in DeviceTypeArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ <div v-else> {{ row.eqptype_name }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="remark"
+ label="鍒嗙粍鎻忚堪"
+ show-overflow-tooltip
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <el-input v-if="row.isVisible===1" v-model="row.remark" placeholder="璇疯緭鍏�" />
+ <div v-else> {{ row.remark }}</div>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔">
+ <template slot-scope="{row}">
+ <div class="operationClass">
+ <el-button v-if="row.isVisible===0" type="text" @click="DeviceGroupDel(row)">鍒犻櫎</el-button>
+ <el-button v-if="row.isVisible===1" type="text" @click="DeviceGroupSave(row)">淇濆瓨</el-button>
+ <el-button v-if="row.isVisible===1" type="text" @click="DeviceGroupCancel(row)">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!--鍒嗛〉-->
+ <pagination
+ v-show="DeviceGroupTotal>0"
+ :total="DeviceGroupTotal"
+ :page.sync="formDeviceGroup.page"
+ :limit.sync="formDeviceGroup.rows"
+ align="right"
+ layout="prev, pager, next,sizes"
+ popper-class="select_bottom"
+ @pagination="getDeviceGroupSearchDialog"
+ />
+ <span slot="footer" class="dialog-footer">
+ <div class="footerButton">
+ <el-button @click="DeviceGroupDialogVisibleCancel">杩斿洖</el-button>
+ <!-- <el-button type="primary" @click="settingDialogVisibleConfirm">纭� 瀹�</el-button>-->
+ </div>
+ </span>
+ </el-dialog>
<!--瀵煎叆-->
+
</div>
</template>
<script>
import Pagination from '@/components/Pagination'
-import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
+import {
+ AddUpdateOrganization,
+ DeleteOrganization,
+ OrganizationSearch,
+ PrentOrganization,
+ RoleTypeDelete
+} from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import {
+ AddUpdateDeviceGroup,
+ AddUpdateDeviceType, DeleteDeviceType,
DeviceGroupSearch,
DeviceMangerSearch,
DeviceTypeSearch,
@@ -430,17 +541,21 @@
DeviceTypeDialogVisible: false,
DeviceTypeArray: [], // 璁惧绫诲瀷瀵硅瘽妗嗗唴鐨勬暟缁�
formDeviceType: {
- // code: '',
- // name: '',
- // group: '',
- // description: '',
- rows: 1,
- row: 10,
+ page: 1,
+ rows: 10,
prop: 'code',
order: 'desc'
},
- DeviceTypeTotal: 0
-
+ DeviceTypeTotal: 0,
+ DeviceGroupDialogVisible: false,
+ DeviceGroupArray: [], // 璁惧缁勫璇濇鍐呯殑鏁扮粍
+ formDeviceGroup: {
+ page: 1,
+ rows: 10,
+ prop: 'code',
+ order: 'desc'
+ },
+ DeviceGroupTotal: 0
}
},
created() {
@@ -463,7 +578,7 @@
this.total = res.count
},
// 鑾峰彇鎵�灞炶溅闂翠笅鎷�
- async getWorkShopSelect() {
+ async getWorkShopSelect() {
const { data: res } = await WorkShopSelect()
this.WorkShopArr = res
},
@@ -473,7 +588,7 @@
this.DeviceTypeArr = res
},
// 璁惧绫诲瀷鏀瑰彉鏃�
- async deviceTypeChange(val) {
+ async deviceTypeChange(val) {
this.form.DeviceType = val
const { data: res } = await DeviceTypeSelectGroup({ eqptypecode: val })
this.DeviceGroupArr = res
@@ -603,7 +718,12 @@
},
// 澶勭悊瀵硅瘽妗嗗叧闂�
handleCloseDeviceType() {
- // this.DeviceTypeDialogVisible = false
+ this.DeviceTypeArray.forEach((item, index) => {
+ if (item.isVisible === 1) {
+ this.DeviceTypeArray.splice(index, 1)
+ }
+ })
+ this.getDeviceTypeSelect()
},
// 璁惧绫诲瀷琛ㄥ崟鐐瑰嚮鎺掑簭
sortChangeOfDeviceType({ column, prop, order }) {
@@ -620,19 +740,55 @@
},
// 鏂板鎸夐挳
addDeviceType() {
- this.DeviceTypeArray.unshift({ code: '', name: '', group: '', description: '', isVisible: 1 })
+ this.DeviceTypeArray.unshift({ code: '', name: '', group: '', remark: '', isVisible: 1 })
},
// 鍒犻櫎
DeviceTypeDel(row) {
-
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ DeleteDeviceType({ devicetypecode: row.code }).then(res => {
+ if (res.code === '200') {
+ this.$message.success('鍒犻櫎鎴愬姛!')
+ this.getDeviceTypeSearchDialog()
+ }
+ })
+ }).catch(() => {
+ this.$message.info('宸插彇娑堝垹闄�')
+ })
},
// 淇濆瓨
- DeviceTypeSave(row) {
-
+ async DeviceTypeSave(row) {
+ if (row.code.trim().length < 1) {
+ return this.$message.info('绫诲瀷缂栫爜涓嶈兘涓虹┖锛�')
+ }
+ if (row.name.trim().length < 1) {
+ return this.$message.info('绫诲瀷鍚嶇О涓嶈兘涓虹┖锛�')
+ }
+ if (row.remark.trim().length < 1) {
+ return this.$message.info('绫诲瀷鎻忚堪涓嶈兘涓虹┖锛�')
+ }
+ const data = {
+ 'code': row.code,
+ 'name': row.name,
+ 'group': '',
+ 'description': row.remark
+ }
+ const res = await AddUpdateDeviceType([data])
+ if (res.code === '200') {
+ this.$message.success('娣诲姞鎴愬姛锛�')
+ await this.getDeviceTypeSearchDialog()
+ }
},
// 鍙栨秷
DeviceTypeCancel(row) {
-
+ this.DeviceTypeArray.forEach((item, index) => {
+ if (item.isVisible === 1 && item.code === row.code) {
+ this.DeviceTypeArray.splice(index, 1)
+ }
+ })
},
// 杩斿洖鎸夐挳
DeviceTypeDialogVisibleCancel() {
@@ -642,7 +798,101 @@
/* 璁惧缁勬ā鍧�*/
// 鐐瑰嚮璁惧缁勬寜閽�
deviceGroupButton() {
-
+ this.DeviceGroupDialogVisible = true
+ this.getDeviceGroupSearchDialog()
+ },
+ // 璁惧缁勫璇濇鍏抽棴浜嬩欢
+ handleCloseDeviceGroup() {
+ this.DeviceGroupDialogVisible = false
+ this.DeviceGroupArray.forEach((item, index) => {
+ if (item.isVisible === 1) {
+ this.DeviceGroupArray.splice(index, 1)
+ }
+ })
+ if (this.form.DeviceType !== '') {
+ this.deviceTypeChange(this.form.DeviceType)
+ }
+ },
+ // 鏂板
+ addDeviceGroup() {
+ this.DeviceGroupArray.unshift({ code: '', name: '', eqptype_code: '', eqptype_name: '', remark: '', isVisible: 1 })
+ },
+ // 鎺掑簭
+ sortChangeOfDeviceGroup({ column, prop, order }) {
+ if (order === 'descending') {
+ order = 'desc'
+ } else if (order === 'ascending') {
+ order = 'asc'
+ } else {
+ order = 'desc'
+ }
+ this.formDeviceGroup.order = order
+ this.formDeviceGroup.prop = prop
+ this.getDeviceGroupSearchDialog()
+ },
+ // 鑾峰彇璁惧缁勫垪琛�
+ async getDeviceGroupSearchDialog() {
+ const res = await DeviceGroupSearch(this.formDeviceGroup)
+ this.DeviceGroupArray = res.data
+ this.DeviceGroupTotal = res.count
+ this.DeviceGroupArray.forEach(item => {
+ item.isVisible = 0
+ })
+ },
+ // 杩斿洖鎸夐挳
+ DeviceGroupDialogVisibleCancel() {
+ this.DeviceGroupDialogVisible = false
+ },
+ // 鍒犻櫎鎸夐挳
+ DeviceGroupDel(row) {
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ DeleteDeviceGroup({ devicegroupcode: row.code }).then(res => {
+ if (res.code === '200') {
+ this.$message.success('鍒犻櫎鎴愬姛!')
+ this.getDeviceGroupSearchDialog()
+ }
+ })
+ }).catch(() => {
+ this.$message.info('宸插彇娑堝垹闄�')
+ })
+ },
+ // 淇濆瓨鎸夐挳
+ async DeviceGroupSave(row) {
+ if (row.code.trim().length < 1) {
+ return this.$message.info('鍒嗙粍缂栫爜涓嶈兘涓虹┖锛�')
+ }
+ if (row.name.trim().length < 1) {
+ return this.$message.info('鍒嗙粍鍚嶇О涓嶈兘涓虹┖锛�')
+ }
+ if (row.eqptype_code.trim().length < 1) {
+ return this.$message.info('鎵�灞炶澶囩被鍨嬩笉鑳戒负绌猴紒')
+ }
+ if (row.remark.trim().length < 1) {
+ return this.$message.info('鍒嗙粍鎻忚堪涓嶈兘涓虹┖锛�')
+ }
+ const data = {
+ 'code': row.code,
+ 'name': row.name,
+ 'group': row.eqptype_code,
+ 'description': row.remark
+ }
+ const res = await AddUpdateDeviceGroup([data])
+ if (res.code === '200') {
+ this.$message.success('娣诲姞鎴愬姛锛�')
+ await this.getDeviceGroupSearchDialog()
+ }
+ },
+ // 鍙栨秷鎸夐挳
+ DeviceGroupCancel(row) {
+ this.DeviceGroupArray.forEach((item, index) => {
+ if (item.isVisible === 1 && item.code === row.code) {
+ this.DeviceGroupArray.splice(index, 1)
+ }
+ })
}
}
}
@@ -701,6 +951,12 @@
::v-deep .el-dialog__body {
padding: 20px 20px !important;
}
+
+ ::v-deep .el-select .el-input .el-select__caret {
+ display: flex;
+ align-items: center;
+ }
+
}
::v-deep .el-radio__input.is-checked .el-radio__inner {
@@ -780,10 +1036,11 @@
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
margin: 10px 30px 0px 0;
}
+
.elForm {
display: flex;
justify-content: flex-start;
- width: 85%;
+ width: 100%;
flex-wrap: wrap;
}
</style>
--
Gitblit v1.9.3