2 changed files with 1047 additions and 488 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,520 @@
|
||||
<template> |
||||
<basic-container> |
||||
<div class="avue-crud"> |
||||
<div v-h5uShow="!search"> |
||||
<!-- 查询模块 --> |
||||
<el-form :inline="true" :model="query" class="header_search"> |
||||
<el-form-item label="编码类型:"> |
||||
<el-select type="text" v-model="query.codeType" placeholder="请选择编码类型"> |
||||
<el-option |
||||
v-for="item in codeType" |
||||
:key="item.dictKey" |
||||
:label="item.dictValue" |
||||
:value="item.dictKey" |
||||
> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="展示类型:" style="margin-left: 5px"> |
||||
<el-select type="text" v-model="query.showType" placeholder="请选择展示类型"> |
||||
<el-option |
||||
v-for="item in showType" |
||||
:key="item.dictKey" |
||||
:label="item.dictValue" |
||||
:value="item.dictKey" |
||||
> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<!-- 查询按钮 --> |
||||
<el-form-item> |
||||
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button> |
||||
<el-button icon="el-icon-delete" @click="searchReset">清 空</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
<el-row> |
||||
<div class="avue-crud__header"> |
||||
<!-- 头部左侧按钮模块 --> |
||||
<div class="avue-crud__left"> |
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新 增</el-button> |
||||
<el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain |
||||
>删 除</el-button |
||||
> |
||||
</div> |
||||
<!-- 头部右侧按钮模块 --> |
||||
<div class="avue-crud__right"> |
||||
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button> |
||||
<el-button icon="el-icon-search" @click="searchHide" circle></el-button> |
||||
</div> |
||||
</div> |
||||
</el-row> |
||||
<el-row> |
||||
<!-- 列表模块 --> |
||||
<tablecmt |
||||
class="tableNode" |
||||
:columnList="columnList" |
||||
:tableData="data" |
||||
:loading="loading" |
||||
@inputTxt="inputsc" |
||||
@timeCheck="timesc" |
||||
@btnCheck="btnsc" |
||||
@selectCheck="selectsc" |
||||
@selection="selectionChange" |
||||
> |
||||
<template #default="slotProps"> |
||||
<el-text |
||||
type="primary" |
||||
text |
||||
icon="el-icon-view" |
||||
@click="handleView(slotProps.scope.row)" |
||||
>查看</el-text |
||||
> |
||||
<el-text |
||||
type="primary" |
||||
text |
||||
icon="el-icon-edit" |
||||
@click="handleEdit(slotProps.scope.row)" |
||||
>编辑</el-text |
||||
> |
||||
<el-text type="primary" text icon="el-icon-delete" @click="rowDel(slotProps.scope.row)" |
||||
>删除</el-text |
||||
> |
||||
</template> |
||||
</tablecmt> |
||||
</el-row> |
||||
<el-row> |
||||
<div class="avue-crud__pagination flex-c-sb" style="width: 100%"> |
||||
<div style="font-size: 14px">勾选数量: {{ selectionList.length }}</div> |
||||
<!-- 分页模块 --> |
||||
<el-pagination |
||||
align="right" |
||||
background |
||||
@size-change="sititlezeChange" |
||||
@current-change="currentChange" |
||||
:current-page="page.currentPage" |
||||
:page-sizes="[30, 50, 80, 120]" |
||||
:page-size="page.pageSize" |
||||
layout="total, sizes, prev, pager, next, jumper" |
||||
:total="page.total" |
||||
> |
||||
</el-pagination> |
||||
</div> |
||||
</el-row> |
||||
<!-- 表单模块 --> |
||||
<el-dialog |
||||
:title="title" |
||||
v-model="box" |
||||
width="20%" |
||||
:before-close="beforeClose" |
||||
append-to-body |
||||
> |
||||
<el-form :disabled="view" ref="form" :model="form" label-width="80px" :rules="rules"> |
||||
<!-- 表单字段 --> |
||||
<el-form-item label="编码类型:" prop="codeType" label-width="100px"> |
||||
<el-select v-model="form.codeType" clearable placeholder="请选择编码类型"> |
||||
<el-option |
||||
v-for="item in codeType" |
||||
:key="item.dictKey" |
||||
:label="item.dictValue" |
||||
:value="item.dictKey" |
||||
> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="展示类型:" prop="showType" label-width="100px"> |
||||
<el-select v-model="form.showType" clearable placeholder="请选择展示类型"> |
||||
<el-option |
||||
v-for="item in showType" |
||||
:key="item.dictKey" |
||||
:label="item.dictValue" |
||||
:value="item.dictKey" |
||||
> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item label="租户编码:" prop="code" label-width="100px"> |
||||
<el-input v-model="form.code" placeholder="请输入编码" style="width: 83%" /> |
||||
</el-form-item> |
||||
</el-form> |
||||
<!-- 表单按钮 --> |
||||
<template #footer> |
||||
<span v-if="!view" class="dialog-footer"> |
||||
<el-button |
||||
type="primary" |
||||
icon="el-icon-circle-check" |
||||
:loading="buttonLoadingList.handleSubmitBtn" |
||||
@click="handleSubmit" |
||||
>提 交</el-button |
||||
> |
||||
<el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button> |
||||
</span> |
||||
</template> |
||||
</el-dialog> |
||||
</div> |
||||
</basic-container> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getList, getDetail, add, update, remove } from '@/api/basic/basicTenantCode'; |
||||
import option from '@/option/basic/basicTenantCode'; |
||||
import { mapGetters } from 'vuex'; |
||||
import { getDictionaryBiz } from '@/api/system/dict'; |
||||
import { setNodeHeight, debounce, handleClearTableQuery } from '@/utils/util'; |
||||
|
||||
export default { |
||||
data() { |
||||
return { |
||||
columnList: [ |
||||
{ |
||||
prop: '', |
||||
label: '复选框', |
||||
type: 0, |
||||
values: '', |
||||
width: 60, |
||||
checkarr: [], |
||||
fixed: true, |
||||
}, |
||||
{ |
||||
prop: '', |
||||
label: '序号', |
||||
type: 12, |
||||
values: '', |
||||
width: 60, |
||||
checkarr: [], |
||||
fixed: true, |
||||
}, |
||||
{ |
||||
prop: 'codeType', |
||||
label: '编码类型', |
||||
type: 2, |
||||
values: '', |
||||
width: '300', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
// head: true, |
||||
}, |
||||
{ |
||||
prop: 'showType', |
||||
label: '展示类型', |
||||
type: 2, |
||||
values: '', |
||||
width: '150', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
// head: true, |
||||
}, |
||||
{ |
||||
prop: 'code', |
||||
label: '编码', |
||||
type: 2, |
||||
values: '', |
||||
width: '300', |
||||
checkarr: [], |
||||
fixed: false, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
prop: '', |
||||
label: '操作', |
||||
type: 6, |
||||
values: '', |
||||
width: '300', |
||||
checkarr: [], |
||||
fixed: 'right', |
||||
sortable: false, |
||||
}, |
||||
], |
||||
height: 0, |
||||
// 弹框标题 |
||||
title: '', |
||||
// 是否展示弹框 |
||||
box: false, |
||||
// 是否显示查询 |
||||
search: true, |
||||
// 加载中 |
||||
loading: true, |
||||
// 是否为查看模式 |
||||
view: false, |
||||
// 查询信息 |
||||
query: { |
||||
codeType: '', |
||||
showType: '', |
||||
}, |
||||
// 分页信息 |
||||
page: { |
||||
currentPage: 1, |
||||
pageSize: 30, |
||||
total: 40, |
||||
}, |
||||
// 表单数据 |
||||
form: {}, |
||||
// 选择行 |
||||
selectionList: [], |
||||
// 表单配置 |
||||
option: option, |
||||
// 表单列表 |
||||
data: [], |
||||
codeType: [], |
||||
showType: [], |
||||
rules: { |
||||
codeType: [ |
||||
{ |
||||
required: true, |
||||
trigger: 'change', |
||||
message: '请选择编码类型', |
||||
}, |
||||
], |
||||
showType: [ |
||||
{ |
||||
required: true, |
||||
trigger: 'change', |
||||
message: '请选择展示类型', |
||||
}, |
||||
], |
||||
}, |
||||
buttonLoadingList: { |
||||
handleSubmitBtn: false, |
||||
}, |
||||
onLoad: debounce(function (page, params = {}) { |
||||
this.loading = true; |
||||
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { |
||||
const data = res.data.data; |
||||
console.log(data); |
||||
//编码类型数据回显 |
||||
this.codeType.forEach(item => { |
||||
data.records.forEach(code => { |
||||
if (item.dictKey === code.codeType) { |
||||
code.codeType = item.dictValue; |
||||
} |
||||
}); |
||||
}); |
||||
//展示类型数据回显 |
||||
this.showType.forEach(item => { |
||||
data.records.forEach(code => { |
||||
if (item.dictKey === code.showType) { |
||||
code.showType = item.dictValue; |
||||
} |
||||
}); |
||||
}); |
||||
this.page.total = data.total; |
||||
this.data = data.records; |
||||
this.loading = false; |
||||
this.selectionClear(); |
||||
}); |
||||
}, 500), |
||||
}; |
||||
}, |
||||
created() { |
||||
//创建获取字典信息 |
||||
this.getDictionaryBizInfo(); |
||||
}, |
||||
|
||||
mounted() { |
||||
//页面布局初始化 |
||||
this.init(); |
||||
//加载页面数据 |
||||
this.onLoad(this.page); |
||||
}, |
||||
computed: { |
||||
...mapGetters(['permission']), |
||||
ids() { |
||||
let ids = []; |
||||
this.selectionList.forEach(ele => { |
||||
ids.push(ele.id); |
||||
}); |
||||
return ids.join(','); |
||||
}, |
||||
}, |
||||
methods: { |
||||
/** |
||||
* 弹窗的勾选回调,用于更改头部数组 |
||||
* 固定搭配,只需要更换 columnList |
||||
*/ |
||||
setnewcolum(newarr, headarr, type) { |
||||
// console.log(newarr,'+++++++++++') |
||||
if (type == 1) { |
||||
this.columnList = newarr; |
||||
this.$functions.setStorage(window.location.pathname + 'checkList', headarr); |
||||
} else if (type == 2) { |
||||
this.columnList = newarr; |
||||
this.$functions.setStorage(window.location.pathname + 'flexList', headarr); |
||||
} else if (type == 3) { |
||||
this.columnList = newarr; |
||||
this.$functions.setStorage(window.location.pathname + 'sortlist', headarr); |
||||
} |
||||
}, |
||||
//获取字典数据 |
||||
getDictionaryBizInfo() { |
||||
getDictionaryBiz('basic_tenant_code').then(res => { |
||||
this.codeType = res.data.data; |
||||
}); |
||||
getDictionaryBiz('basic_tenant_code_show').then(res => { |
||||
this.showType = res.data.data; |
||||
}); |
||||
}, |
||||
init() { |
||||
this.height = this.setPx(document.body.clientHeight - 340); |
||||
}, |
||||
searchHide() { |
||||
this.search = !this.search; |
||||
|
||||
const _tableNode = document.querySelector('.tableNode'); |
||||
setNodeHeight(_tableNode, '', true); |
||||
}, |
||||
searchChange() { |
||||
this.onLoad(this.page); |
||||
}, |
||||
searchReset() { |
||||
this.query = {}; |
||||
this.page.currentPage = 1; |
||||
handleClearTableQuery(this.columnList); |
||||
this.onLoad(this.page); |
||||
}, |
||||
handleSubmit() { |
||||
//表单校验添加租户编码 |
||||
this.$refs.form.validate(valid => { |
||||
this.buttonLoadingList.handleSubmitBtn = true; |
||||
if (valid) { |
||||
if (!this.form.id) { |
||||
add(this.form).then(() => { |
||||
this.box = false; |
||||
this.onLoad(this.page); |
||||
this.$message({ |
||||
type: 'success', |
||||
message: '操作成功!', |
||||
}); |
||||
}); |
||||
} else { |
||||
update(this.form).then(() => { |
||||
this.box = false; |
||||
this.onLoad(this.page); |
||||
this.$message({ |
||||
type: 'success', |
||||
message: '操作成功!', |
||||
}); |
||||
}); |
||||
} |
||||
this.buttonLoadingList.handleSubmitBtn = false; |
||||
} else { |
||||
console.log('error submit!!'); |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
inputsc(index, row) { |
||||
this.query[row.prop] = index; |
||||
if (index === '') delete this.query[row.prop]; |
||||
this.onLoad(this.page); |
||||
}, |
||||
async handleAdd() { |
||||
this.title = '新增'; |
||||
this.form = {}; |
||||
this.box = true; |
||||
await this.$nextTick(); |
||||
this.$refs['form'].resetFields(); |
||||
}, |
||||
handleEdit(row) { |
||||
this.title = '编辑'; |
||||
this.box = true; |
||||
this.$refs['form'].resetFields(); |
||||
getDetail(row.id).then(res => { |
||||
res.data.data.codeType = parseInt(res.data.data.codeType); |
||||
res.data.data.showType = parseInt(res.data.data.showType); |
||||
this.form = res.data.data; |
||||
}); |
||||
}, |
||||
handleView(row) { |
||||
this.title = '查看'; |
||||
this.view = true; |
||||
this.box = true; |
||||
getDetail(row.id).then(res => { |
||||
res.data.data.codeType = parseInt(res.data.data.codeType); |
||||
res.data.data.showType = parseInt(res.data.data.showType); |
||||
this.form = res.data.data; |
||||
}); |
||||
}, |
||||
handleDelete() { |
||||
if (this.selectionList.length === 0) { |
||||
this.$message.warning('请选择至少一条数据'); |
||||
return; |
||||
} |
||||
this.$confirm('确定将选择数据删除?', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
}) |
||||
.then(() => { |
||||
return remove(this.ids); |
||||
}) |
||||
.then(() => { |
||||
this.selectionClear(); |
||||
this.onLoad(this.page); |
||||
this.$message({ |
||||
type: 'success', |
||||
message: '操作成功!', |
||||
}); |
||||
}); |
||||
}, |
||||
rowDel(row) { |
||||
this.$confirm('确定将选择数据删除?', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
}) |
||||
.then(() => { |
||||
return remove(row.id); |
||||
}) |
||||
.then(() => { |
||||
this.onLoad(this.page); |
||||
this.$message({ |
||||
type: 'success', |
||||
message: '操作成功!', |
||||
}); |
||||
}); |
||||
}, |
||||
beforeClose(done) { |
||||
done(); |
||||
this.form = {}; |
||||
this.view = false; |
||||
}, |
||||
selectionChange(list) { |
||||
this.selectionList = list; |
||||
}, |
||||
selectionClear() { |
||||
this.selectionList = []; |
||||
// this.$refs.table.clearSelection(); |
||||
}, |
||||
currentChange(currentPage) { |
||||
this.page.currentPage = currentPage; |
||||
this.onLoad(this.page); |
||||
}, |
||||
sizeChange(pageSize) { |
||||
this.page.pageSize = pageSize; |
||||
this.onLoad(this.page); |
||||
}, |
||||
}, |
||||
}; |
||||
</script> |
||||
|
||||
<style scoped lang="scss"> |
||||
.fr-fo { |
||||
width: 100%; |
||||
display: flex; |
||||
justify-content: space-between; |
||||
|
||||
.fr-fm { |
||||
.el-form-item { |
||||
margin-right: 30px; |
||||
} |
||||
} |
||||
.el-form-item { |
||||
margin-right: 0; |
||||
} |
||||
} |
||||
:deep(.el-form-item__label) { |
||||
padding-right: 8px; |
||||
} |
||||
</style> |
Loading…
Reference in new issue