fix bugs
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import request from '@/axios';
|
||||
|
||||
export const getList = (current, size, params) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/list',
|
||||
method: 'get',
|
||||
params: {
|
||||
...params,
|
||||
current,
|
||||
size,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const getDetail = (id) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/detail',
|
||||
method: 'get',
|
||||
params: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const getTree = (tenantId) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/tree',
|
||||
method: 'get',
|
||||
params: {
|
||||
tenantId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const remove = (ids) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/remove',
|
||||
method: 'post',
|
||||
params: {
|
||||
ids,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const add = (row) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/submit',
|
||||
method: 'post',
|
||||
data: row
|
||||
})
|
||||
}
|
||||
|
||||
export const update = (row) => {
|
||||
return request({
|
||||
url: '/${serviceName!}/${modelCode!}/submit',
|
||||
method: 'post',
|
||||
data: row
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<basic-container>
|
||||
<avue-crud :option="option"
|
||||
v-model:search="search"
|
||||
v-model:page="page"
|
||||
v-model="form"
|
||||
:table-loading="loading"
|
||||
:data="data"
|
||||
:permission="permissionList"
|
||||
:before-open="beforeOpen"
|
||||
ref="crud"
|
||||
@row-update="rowUpdate"
|
||||
@row-save="rowSave"
|
||||
@row-del="rowDel"
|
||||
@search-change="searchChange"
|
||||
@search-reset="searchReset"
|
||||
@selection-change="selectionChange"
|
||||
@current-change="currentChange"
|
||||
@size-change="sizeChange"
|
||||
@refresh-change="refreshChange"
|
||||
@on-load="onLoad">
|
||||
<template \#menu-left>
|
||||
<el-button type="danger"
|
||||
icon="el-icon-delete"
|
||||
plain
|
||||
v-if="permission.${modelCode!}_delete"
|
||||
@click="handleDelete">删 除
|
||||
</el-button>
|
||||
<el-button type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
@click="handleExport">导 出
|
||||
</el-button>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</basic-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getList, getDetail, getTree, add, update, remove} from "@/api/${serviceCode!}/${modelCode!}";
|
||||
import option from "@/option/${serviceCode!}/${modelCode!}";
|
||||
import {mapGetters} from "vuex";
|
||||
import {exportBlob} from "@/api/common";
|
||||
import {getToken} from '@/utils/auth';
|
||||
import {downloadXls} from "@/utils/util";
|
||||
import {dateNow} from "@/utils/date";
|
||||
import NProgress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
query: {},
|
||||
search: {},
|
||||
loading: true,
|
||||
page: {
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
},
|
||||
selectionList: [],
|
||||
option: option,
|
||||
data: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.validData(this.permission.${modelCode!}_add, false),
|
||||
viewBtn: this.validData(this.permission.${modelCode!}_view, false),
|
||||
delBtn: this.validData(this.permission.${modelCode!}_delete, false),
|
||||
editBtn: this.validData(this.permission.${modelCode!}_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
let ids = [];
|
||||
this.selectionList.forEach(ele => {
|
||||
ids.push(ele.id);
|
||||
});
|
||||
return ids.join(",");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
rowSave(row, done, loading) {
|
||||
add(row).then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
done();
|
||||
}, error => {
|
||||
loading();
|
||||
window.console.log(error);
|
||||
});
|
||||
},
|
||||
rowUpdate(row, index, done, loading) {
|
||||
update(row).then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
done();
|
||||
}, error => {
|
||||
loading();
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
rowDel(row) {
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
handleDelete() {
|
||||
if (this.selectionList.length === 0) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(this.ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.$refs.crud.toggleSelection();
|
||||
});
|
||||
},
|
||||
handleExport() {
|
||||
let downloadUrl = `/${serviceName!}/${modelCode!}/export-${modelCode!}?\${this.website.tokenHeader}=\${getToken()}`;
|
||||
const {
|
||||
#for(x in prototypes) {
|
||||
#if(x.isQuery==1){
|
||||
${x.propertyName!},
|
||||
#}
|
||||
#}
|
||||
} = this.query;
|
||||
let values = {
|
||||
#for(x in prototypes) {
|
||||
#if(x.isQuery==1){
|
||||
${x.propertyName!}_${x.queryType!}: ${x.propertyName!},
|
||||
#}
|
||||
#}
|
||||
};
|
||||
this.$confirm("是否导出数据?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
NProgress.start();
|
||||
exportBlob(downloadUrl, values).then(res => {
|
||||
downloadXls(res.data, `${codeName!}\${dateNow()}.xlsx`);
|
||||
NProgress.done();
|
||||
})
|
||||
});
|
||||
},
|
||||
beforeOpen(done, type) {
|
||||
if (["edit", "view"].includes(type)) {
|
||||
getDetail(this.form.id).then(res => {
|
||||
this.form = res.data.data;
|
||||
});
|
||||
}
|
||||
done();
|
||||
},
|
||||
searchReset() {
|
||||
this.query = {};
|
||||
this.onLoad(this.page);
|
||||
},
|
||||
searchChange(params, done) {
|
||||
this.query = params;
|
||||
this.page.currentPage = 1;
|
||||
this.onLoad(this.page, params);
|
||||
done();
|
||||
},
|
||||
selectionChange(list) {
|
||||
this.selectionList = list;
|
||||
},
|
||||
selectionClear() {
|
||||
this.selectionList = [];
|
||||
this.$refs.crud.toggleSelection();
|
||||
},
|
||||
currentChange(currentPage){
|
||||
this.page.currentPage = currentPage;
|
||||
},
|
||||
sizeChange(pageSize){
|
||||
this.page.pageSize = pageSize;
|
||||
},
|
||||
refreshChange() {
|
||||
this.onLoad(this.page, this.query);
|
||||
},
|
||||
onLoad(page, params = {}) {
|
||||
this.loading = true;
|
||||
|
||||
const {
|
||||
#for(x in prototypes) {
|
||||
#if(x.isQuery==1){
|
||||
${x.propertyName!},
|
||||
#}
|
||||
#}
|
||||
} = this.query;
|
||||
|
||||
let values = {
|
||||
#for(x in prototypes) {
|
||||
#if(x.isQuery==1){
|
||||
${x.propertyName!}_${x.queryType!}: ${x.propertyName!},
|
||||
#}
|
||||
#}
|
||||
};
|
||||
|
||||
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||
this.data = res.data.data;
|
||||
this.loading = false;
|
||||
getTree().then(res => {
|
||||
const column = this.findObject(this.option.column, "${treePidHump!}");
|
||||
column.dicData = res.data.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -0,0 +1,74 @@
|
||||
export default {
|
||||
height:'auto',
|
||||
calcHeight: 30,
|
||||
tip: false,
|
||||
searchShow: true,
|
||||
searchMenuSpan: 6,
|
||||
border: true,
|
||||
index: true,
|
||||
viewBtn: true,
|
||||
selection: true,
|
||||
dialogClickModal: false,
|
||||
column: [
|
||||
#for(x in prototypes) {
|
||||
{
|
||||
label: "${x.jdbcComment!}",
|
||||
prop: "${x.propertyName!}",
|
||||
#if(x.propertyName==treePidHump){
|
||||
type: "tree",
|
||||
dicData: [],
|
||||
props: {
|
||||
label: "title",
|
||||
},
|
||||
value: 0,
|
||||
#}else if(strutil.contain(x.componentType,"editor")){
|
||||
component: 'avue-ueditor',
|
||||
options: {
|
||||
action: '/blade-resource/oss/endpoint/put-file',
|
||||
props: {
|
||||
res: "data",
|
||||
url: "link",
|
||||
}
|
||||
},
|
||||
hide: true,
|
||||
minRows: 6,
|
||||
#}else{
|
||||
type: "${x.componentType!}",
|
||||
#}
|
||||
#if(strutil.contain(x.componentType,"date")||strutil.contain(x.componentType,"time")){
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
#}
|
||||
#if(isNotEmpty(x.dictCode)&&x.propertyName!=treePidHump){
|
||||
dicUrl: "/blade-system/dict/dictionary?code=${x.dictCode!}",
|
||||
dataType: "number",
|
||||
props: {
|
||||
label: "dictValue",
|
||||
value: "dictKey"
|
||||
},
|
||||
#}
|
||||
#if(x.isForm==0){
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
viewDisplay: false,
|
||||
#}
|
||||
#if(x.isRow==1){
|
||||
span: 24,
|
||||
#}
|
||||
#if(x.isList==0){
|
||||
hide: true,
|
||||
#}
|
||||
#if(x.isQuery==1){
|
||||
search: true,
|
||||
#}
|
||||
#if(x.isRequired==1){
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入${x.jdbcComment!}",
|
||||
trigger: "blur"
|
||||
}],
|
||||
#}
|
||||
},
|
||||
#}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user