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/template/Template.vue

246 lines
9.2 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 {driverApi, profileApi} from '@/api/manager'
import {successMessage} from "@/util/util";
export default {
data() {
return {
query: {},
listForm: {},
listData: [],
listOption: {
tip: false,
index: true,
stripe: true,
border: true,
viewBtn: true,
selection: true,
height: 664,
align: 'center',
column: [
{
label: '模板',
prop: 'name',
width: 230,
span: 24,
search: true,
searchSpan: 12,
rules: [
{
required: true,
message: '请输入 模板名称',
trigger: 'blur'
}, {
min: 2,
max: 32,
message: '请输入 2~32 位字长的模板名称',
trigger: 'blur'
}, {
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+$/,
message: '请输入 正确格式的模板名称,例:\'profile01\' 或 \'模板01\''
}
]
}, {
label: '公/私有',
prop: 'share',
width: 100,
search: true,
searchSpan: 6,
type: 'select',
searchFilterable: true,
value: true,
dicData: [
{
label: '公有',
value: true
}, {
label: '私有',
value: false
}
],
rules: [{
required: true,
message: '请选择模板共享类型',
trigger: 'click'
}]
}, {
label: '驱动',
prop: 'driverId',
width: 220,
search: true,
searchSpan: 6,
type: 'select',
filterable: true,
searchFilterable: true,
dicData: [],
props: {
label: 'name',
value: 'id'
},
rules: [{
required: true,
message: '请选择使用驱动',
trigger: 'click'
}]
}, {
label: '配置属性',
prop: 'config',
width: 360,
span: 24,
type: 'textarea',
rules: [
{
required: true,
message: '请输入 配置属性',
trigger: 'blur'
}
]
}, {
label: '描述',
prop: 'description',
width: 220,
span: 24,
type: 'textarea',
rules: [
{
max: 380,
message: '最多输入380个字符',
trigger: 'blur'
}
]
}, {
label: '创建日期',
prop: 'createTime',
width: 180,
span: 12,
disabled: true,
type: 'date',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss'
}, {
label: '修改日期',
prop: 'updateTime',
width: 180,
span: 12,
disabled: true,
type: 'date',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'yyyy-MM-dd HH:mm:ss'
}
]
},
selectionList: [],
loading: true,
page: {
total: 0,
pageSize: 20,
currentPage: 1
}
}
},
created() {
this.driver();
},
methods:
{
list(page) {
this.loading = true;
profileApi.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;
});
},
driver() {
driverApi.dictionary().then(res => {
this.listOption.column[this.$refs.crud.findColumnIndex('driverId')].dicData = res.data;
}).catch((e) => {
console.log(e);
});
},
listAdd(row, done, loading) {
profileApi.add(row).then(() => {
loading();
this.list(this.page);
successMessage();
}).finally(() => {
done();
});
},
listDelete(row) {
this.$confirm('是否删除该条模板?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return profileApi.delete(row.id);
}).then(() => {
this.list(this.page);
successMessage();
});
},
listUpdate(row, index, done, loading) {
profileApi.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>