You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dc3-web/src/views/config/Config.vue

236 lines
8.7 KiB

<template>
<el-col :span="24">
<base-card>
<avue-crud :option="listOption"
:data="listData"
:page="page"
:table-loading="loading"
ref="crud"
v-model="listForm"
@on-load="list"
@row-save="listAdd"
@row-del="listDelete"
@row-update="listUpdate"
@search-reset="searchReset"
@search-change="searchChange"
@refresh-change="refreshChange"
@size-change="sizeChange"
@current-change="currentChange"
>
</avue-crud>
</base-card>
</el-col>
</template>
<script>
import {deviceApi, pointApi, pointInfoApi, profileInfoApi} from '@/api/device'
import {successMessage} from "@/util/util";
export default {
data() {
return {
query: {},
listForm: {},
listData: [],
listOption: {
tip: false,
index: true,
stripe: true,
border: true,
viewBtn: true,
height: 664,
align: 'center',
column: [
{
label: '属性',
prop: 'profileInfoId',
span: 12,
search: true,
searchSpan: 8,
type: 'tree',
dicData: [],
defaultExpandAll: true,
rules: [
{
required: true,
message: '请选择属性',
trigger: 'click'
}
]
}, {
label: '内容',
prop: 'value',
span: 12
}, {
label: '所属设备',
prop: 'deviceId',
span: 12,
search: true,
searchSpan: 8,
type: 'tree',
dicData: [],
defaultExpandAll: true,
rules: [
{
required: true,
message: '请选择所属设备',
trigger: 'click'
}
]
}, {
label: '所属位号',
prop: 'pointId',
span: 12,
search: true,
searchSpan: 8,
type: 'tree',
dicData: [],
defaultExpandAll: true,
rules: [
{
required: true,
message: '请选择所属位号',
trigger: 'click'
}
]
}, {
label: '备注',
prop: 'description',
width: 200,
span: 24,
type: 'textarea',
overHidden: true,
rules: [
{
max: 380,
message: '最多输入380个字符',
trigger: 'blur'
}
]
}, {
label: '修改日期',
prop: 'updateTime',
width: 155,
span: 12,
disabled: true,
type: 'date',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss'
}, {
label: '创建日期',
prop: 'createTime',
width: 155,
span: 12,
disabled: true,
type: 'date',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss'
}
]
},
loading: true,
page: {
total: 0,
pageSize: 20,
currentPage: 1
}
}
},
created() {
this.device();
this.point();
this.profileInfo();
},
methods:
{
list(page) {
this.loading = true;
pointInfoApi.list(Object.assign({
page: {
current: page.currentPage,
size: page.pageSize
}
}, this.query)).then(res => {
const data = res.data;
this.page.total = data.total;
this.listData = data.records;
}).finally(() => {
this.loading = false;
});
},
device() {
deviceApi.dictionary().then(res => {
this.listOption.column[this.$refs.crud.findColumnIndex('deviceId')].dicData = res.data;
}).catch((e) => {
console.log(e);
});
},
point() {
pointApi.dictionary().then(res => {
this.listOption.column[this.$refs.crud.findColumnIndex('pointId')].dicData = res.data;
}).catch((e) => {
console.log(e);
});
},
profileInfo() {
profileInfoApi.dictionary().then(res => {
this.listOption.column[this.$refs.crud.findColumnIndex('profileInfoId')].dicData = res.data;
}).catch((e) => {
console.log(e);
});
},
listAdd(row, done, loading) {
pointInfoApi.add(row).then(() => {
loading();
this.list(this.page);
successMessage();
}).finally(() => {
done();
});
},
listDelete(row) {
this.$confirm('是否删除该条数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return pointInfoApi.delete(row.id);
}).then(() => {
this.list(this.page);
successMessage();
});
},
listUpdate(row, index, done, loading) {
pointInfoApi.update(row).then(() => {
loading();
this.list(this.page);
successMessage();
}).finally(() => {
done();
});
},
refreshChange() {
this.list(this.page);
},
currentChange(page) {
this.page.currentPage = page;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
searchChange(params, done) {
this.query = params;
this.list(this.page);
done();
},
searchReset() {
this.query = {};
this.list(this.page);
}
}
}
</script>
<style lang="scss">
</style>