init
This commit is contained in:
114
src/views/EquipmentManager/Analysis/EditForm.vue
Normal file
114
src/views/EquipmentManager/Analysis/EditForm.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<!--
|
||||
* @Date: 2021-01-11 09:24:41
|
||||
* @LastEditors: guo
|
||||
* @LastEditTime: 2021-02-25 16:04:49
|
||||
* @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="设备状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择下拉选择设备状态" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in statusOptions"
|
||||
:key="index"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:disabled="item.disabled"
|
||||
/>
|
||||
</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'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
targetInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
status: undefined,
|
||||
oldStatus: null,
|
||||
id: null
|
||||
},
|
||||
rules: {
|
||||
status: [{
|
||||
required: true,
|
||||
message: '请选择下拉选择设备状态',
|
||||
trigger: 'change'
|
||||
}]
|
||||
},
|
||||
statusOptions: [{
|
||||
'label': 'productive',
|
||||
'value': 0
|
||||
}, {
|
||||
'label': 'standby',
|
||||
'value': 1
|
||||
}, {
|
||||
'label': 'unscheduled downtime',
|
||||
'value': 2
|
||||
}, {
|
||||
'label': 'scheduled downtime',
|
||||
'value': 3
|
||||
}, {
|
||||
'label': 'engineering',
|
||||
'value': 4
|
||||
}, {
|
||||
'label': 'non-scheduled',
|
||||
'value': 5
|
||||
}]
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {},
|
||||
mounted() {},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.formData.id = this.targetInfo.id
|
||||
this.formData.oldStatus = this.targetInfo.status
|
||||
},
|
||||
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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
156
src/views/EquipmentManager/Analysis/index.vue
Normal file
156
src/views/EquipmentManager/Analysis/index.vue
Normal file
@@ -0,0 +1,156 @@
|
||||
<!--
|
||||
* @Date: 2020-12-15 15:36:52
|
||||
* @LastEditors: guo
|
||||
* @LastEditTime: 2021-03-04 10:29:37
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\Analysis\index.vue
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<div class="usermanager-container">
|
||||
<div class="method-btn-area">
|
||||
<el-input v-model="listQuery.keywords" placeholder="设备编码或名称" style="width: 200px;" clearable />
|
||||
<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}" @done="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import dataDict from '@/filters/DataDict'
|
||||
// edit here
|
||||
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: '设备编号',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'name',
|
||||
label: '设备名称',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'status',
|
||||
label: '设备类型',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'color',
|
||||
label: '车间',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'color',
|
||||
label: '工作时间累计',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'color',
|
||||
label: '维修次数',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'color',
|
||||
label: '保养次数',
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'remark',
|
||||
label: '备注',
|
||||
align: 'center'
|
||||
}]
|
||||
import EditForm from './EditForm'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
// edit here
|
||||
import { getStatusSettingList } from '@/api/equipment'
|
||||
|
||||
import Pagination from '@/components/Pagination'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
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,
|
||||
showEditDialog: false,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
keywords: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
// 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
|
||||
break
|
||||
}
|
||||
},
|
||||
async getList() {
|
||||
this.listLoading = true
|
||||
// edit here
|
||||
const res = await getStatusSettingList(this.listQuery)
|
||||
if (res.code === 0) {
|
||||
this.list = res.data.records ? res.data.records.map(item => {
|
||||
return {
|
||||
...item,
|
||||
color: colorTable[item.status]
|
||||
}
|
||||
}) : []
|
||||
this.total = res.data.total
|
||||
this.listLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</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