init
This commit is contained in:
129
src/views/EquipmentManager/StatusSetting/EditForm.vue
Normal file
129
src/views/EquipmentManager/StatusSetting/EditForm.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<!--
|
||||
* @Date: 2021-01-11 09:24:41
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2021-05-11 10:54:22
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\StatusSetting\EditForm.vue
|
||||
* @Description: 子页面
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-bind="$attrs" title="修改设备状态" v-on="$listeners" @open="onOpen" @close="onClose">
|
||||
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="120px">
|
||||
<el-form-item :label="$t('module.equipmentManager.statusSetting.devicestatus')" prop="status">
|
||||
<el-select v-model="formData.status" :placeholder="$t('module.equipmentManager.statusSetting.placeholderdevicestatus')" clearable :style="{width: '80%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in statusOptions"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-tooltip placement="top" style="float:right;margin-right:100px">
|
||||
<div slot="content"><img src="../../../assets/img/status.png" alt=""></div>
|
||||
<el-button type="text" icon="el-icon-question" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.statusSetting.controlStatus')" prop="controlStatus">
|
||||
<el-select v-model="formData.controlStatus" :placeholder="$t('module.equipmentManager.statusSetting.placeholdercontrolStatus')" clearable :style="{width: '80%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in controlStatusOptions"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { editStatusSetting } from '@/api/equipment/index'
|
||||
import { statusList } from '@/api/dict'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
targetInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
status: null,
|
||||
oldStatus: null,
|
||||
id: null,
|
||||
controlStatus: null
|
||||
},
|
||||
rules: {
|
||||
status: [{
|
||||
required: true,
|
||||
message: i18n.t('module.equipmentManager.statusSetting.placeholderdevicestatus'),
|
||||
trigger: 'change'
|
||||
}],
|
||||
controlStatus: [{
|
||||
required: true,
|
||||
message: i18n.t('module.equipmentManager.statusSetting.placeholdercontrolStatus'),
|
||||
trigger: 'change'
|
||||
}]
|
||||
},
|
||||
statusOptions: [],
|
||||
controlStatusOptions: [
|
||||
{ name: this.$t('module.equipmentManager.statusSetting.controlStatusLocal'), value: 0 },
|
||||
{ name: this.$t('module.equipmentManager.statusSetting.controlStatusOnline'), value: 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {},
|
||||
mounted() {
|
||||
this.getDict()
|
||||
},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.formData.id = this.targetInfo.id
|
||||
this.formData.status = String(this.targetInfo.status)
|
||||
this.formData.oldStatus = String(this.targetInfo.status)
|
||||
this.formData.controlStatus = this.targetInfo.controlStatus
|
||||
},
|
||||
onClose() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
this.$refs['elForm'].validate(async valid => {
|
||||
if (!valid) return
|
||||
const result = await editStatusSetting({
|
||||
...this.formData,
|
||||
id: this.targetInfo?.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改状态成功!'
|
||||
})
|
||||
this.$emit('done')
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getDict() {
|
||||
const result = await statusList()
|
||||
this.statusOptions = result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
193
src/views/EquipmentManager/StatusSetting/index.vue
Normal file
193
src/views/EquipmentManager/StatusSetting/index.vue
Normal file
@@ -0,0 +1,193 @@
|
||||
<!--
|
||||
* @Date: 2020-12-15 15:36:52
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2021-05-11 11:29:33
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\StatusSetting\index.vue
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<div class="usermanager-container">
|
||||
<div class="method-btn-area">
|
||||
<el-input v-model="listQuery.equipmentName" :placeholder="$t('module.equipmentManager.statusSetting.searchPlaceholder')" style="width: 200px;" clearable />
|
||||
<el-select v-model="listQuery.status" :placeholder="$t('module.equipmentManager.statusSetting.searchPlaceholder2')" clearable style="width: 200px;">
|
||||
<el-option
|
||||
v-for="item in dict.statusList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button type="primary" @click="getList">{{ 'btn.search' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
<base-table :table-config="tableProps" :table-data="list" :is-loading="listLoading" :page="listQuery.current" :limit="listQuery.size">
|
||||
<method-btn slot="handleBtn" :method-list="tableBtn" @clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size" @pagination="getList" />
|
||||
<edit-form :visible.sync="showEditDialog" :target-info="{id: curEditId, status: curStatus, controlStatus: curControlStatus }" @done="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import dataDict from '@/filters/DataDict'
|
||||
import ColorSqua from '@/components/BaseTable/subcomponents/ColorSqua'
|
||||
import equipment from '@/filters/equipment'
|
||||
// edit here
|
||||
// const statusTableFilter = value => {
|
||||
// const table = {
|
||||
// '0': 'productive',
|
||||
// '1': 'standby',
|
||||
// '2': 'unscheduled downtime',
|
||||
// '3': 'scheduled downtime',
|
||||
// '4': 'engineering',
|
||||
// '5': 'non-scheduled'
|
||||
// }
|
||||
// return table[value] ? table[value] : value
|
||||
// }
|
||||
|
||||
// const colorTable = {
|
||||
// '0': 'rgb(155,187,89)',
|
||||
// '1': 'rgb(255,255,0)',
|
||||
// '2': 'rgb(192,80,77)',
|
||||
// '3': 'rgb(247,150,70)',
|
||||
// '4': 'rgb(79,129,189)',
|
||||
// '5': 'rgb(0,0,0)'
|
||||
// }
|
||||
const tableBtn = [{
|
||||
type: 'edit',
|
||||
btnName: 'btn.edit'
|
||||
}]
|
||||
const tableProps = [{
|
||||
prop: 'code',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.code'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'name',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.name'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'controlStatus',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.controlStatus'),
|
||||
align: 'center',
|
||||
filter: equipment('controlStatus')
|
||||
}, {
|
||||
prop: 'communication',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.communication'),
|
||||
align: 'center',
|
||||
filter: equipment('communication')
|
||||
}, {
|
||||
prop: 'equipmentStatusName',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.status'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'equipmentStatusColor',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.color'),
|
||||
align: 'center',
|
||||
subcomponent: ColorSqua
|
||||
// filter: dataDict('enableState')
|
||||
}, {
|
||||
prop: 'description',
|
||||
label: i18n.t('module.equipmentManager.statusSetting.description'),
|
||||
align: 'center'
|
||||
}]
|
||||
import EditForm from './EditForm'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
// edit here
|
||||
import { getStatusSettingList } from '@/api/equipment'
|
||||
import { statusList } from '@/api/dict'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
name: 'OrgManager',
|
||||
components: {
|
||||
Pagination,
|
||||
BaseTable,
|
||||
MethodBtn,
|
||||
EditForm
|
||||
},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
tableBtn,
|
||||
tableProps,
|
||||
list: [],
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
showDialog: false,
|
||||
curEditId: null,
|
||||
curStatus: null,
|
||||
curControlStatus: null,
|
||||
showEditDialog: false,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
equipmentName: ''
|
||||
},
|
||||
dict: {
|
||||
statusList: []
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getDict()
|
||||
// this.listLoading = false
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
handleClick(raw) {
|
||||
console.log(raw)
|
||||
switch (raw.type) {
|
||||
case 'edit':
|
||||
this.showEditDialog = true
|
||||
this.curEditId = raw.data.id
|
||||
this.curStatus = raw.data.status
|
||||
this.curControlStatus = raw.data.controlStatus
|
||||
break
|
||||
}
|
||||
},
|
||||
async getList() {
|
||||
this.listLoading = true
|
||||
// edit here
|
||||
if (this.listQuery.status === '') {
|
||||
delete this.listQuery.status
|
||||
}
|
||||
const res = await getStatusSettingList(this.listQuery)
|
||||
if (res.code === 0) {
|
||||
this.list = res.data.records
|
||||
// this.list = res.data.records ? res.data.records.map(item => {
|
||||
// return {
|
||||
// ...item,
|
||||
// color: colorTable[item.status]
|
||||
// }
|
||||
// }) : []
|
||||
this.total = res.data.total
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
async getDict() {
|
||||
const result = await statusList()
|
||||
this.dict.statusList = result
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.usermanager-container {
|
||||
padding: 20px;
|
||||
.method-btn-area {
|
||||
padding: 15px 30px;
|
||||
margin: 10px 0 20px 0;
|
||||
border: 1px solid #dfe6ec;
|
||||
}
|
||||
}
|
||||
.edit-input {
|
||||
padding-right: 100px;
|
||||
}
|
||||
.cancel-btn {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 10px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user