yudao-dev/src/views/group/base/groupTeam/index.vue

226 lines
5.2 KiB
Vue
Raw Normal View History

2023-07-27 15:16:13 +08:00
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
2023-08-02 09:17:46 +08:00
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick"
/>
2023-07-27 15:16:13 +08:00
<!-- 列表 -->
2023-08-02 09:17:46 +08:00
<base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH"
@emitFun="handleTableEvents"
>
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="80"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
<pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
<!-- 新增 -->
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="centervisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
>
<group-team-add ref="groupList" @successSubmit="successSubmit" />
</base-dialog>
2023-07-27 15:16:13 +08:00
</div>
</template>
<script>
2023-08-02 09:17:46 +08:00
import { getGroupTeamPage, deleteGroupTeam, updateGroupTeam } from "@/api/base/groupTeam";
import { parseTime } from '@/utils/ruoyi'
import GroupTeamAdd from './components/groupTeamAdd.vue'
import StatusBtn from './components/statusBtn.vue'
const tableProps = [
{
prop: 'createTime',
label: '创建时间',
filter: parseTime,
minWidth: 150
},
{
prop: 'name',
label: '班组名称'
},
{
prop: 'code',
label: '班组编码',
minWidth: 220
},
{
prop: 'num',
label: '班组人数'
},
{
prop: 'leaderName',
label: '班组组长'
},
{
prop: 'enabled',
label: '班组状态',
subcomponent: StatusBtn
}
]
2023-07-27 15:16:13 +08:00
export default {
name: "GroupTeam",
2023-08-02 09:17:46 +08:00
components: { GroupTeamAdd },
2023-07-27 15:16:13 +08:00
data() {
return {
2023-08-02 09:17:46 +08:00
formConfig: [
{
type: 'input',
2023-08-14 16:19:12 +08:00
label: '班次名称',
placeholder: '班次名称',
2023-08-02 09:17:46 +08:00
param: 'name'
},
{
type: 'input',
2023-08-14 16:19:12 +08:00
label: '班次编码',
placeholder: '班次编码',
2023-08-02 09:17:46 +08:00
param: 'code'
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary'
},
{
type: 'separate'
},
{
type: this.$auth.hasPermi('base:group-team:create') ? 'button' : '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true
}
],
tableProps,
2023-08-03 11:18:03 +08:00
tableBtn: [
this.$auth.hasPermi('base:group-team:update')
? {
type: 'edit',
btnName: '编辑'
}
: undefined,
this.$auth.hasPermi('base:group-team:delete')
? {
type: 'delete',
btnName: '删除'
}
: undefined
].filter((v) => v),
tableH: this.tableHeight(260),
2023-07-27 15:16:13 +08:00
// 总条数
total: 0,
2023-08-02 09:17:46 +08:00
// 班次基础信息列表
2023-07-27 15:16:13 +08:00
list: [],
// 弹出层标题
2023-08-02 09:17:46 +08:00
addOrEditTitle: "",
2023-07-27 15:16:13 +08:00
// 是否显示弹出层
2023-08-02 09:17:46 +08:00
centervisible: false,
2023-07-27 15:16:13 +08:00
// 查询参数
queryParams: {
pageNo: 1,
2023-08-02 09:17:46 +08:00
pageSize: 20,
2023-07-27 15:16:13 +08:00
name: null,
2023-08-02 09:17:46 +08:00
code: null
2023-07-27 15:16:13 +08:00
}
};
},
created() {
2023-08-02 09:17:46 +08:00
window.addEventListener('resize', () => {
2023-08-03 11:18:03 +08:00
this.tableH = this.tableHeight(260)
2023-08-02 09:17:46 +08:00
})
2023-07-27 15:16:13 +08:00
this.getList();
},
methods: {
2023-08-02 09:17:46 +08:00
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.queryParams.pageNo = 1;
this.queryParams.name = val.name
this.queryParams.code = val.code
this.getList()
break
default:
this.addOrEditTitle = '新增'
this.centervisible = true
this.$nextTick(() => {
this.$refs.groupList.init()
})
}
},
2023-07-27 15:16:13 +08:00
/** 查询列表 */
getList() {
getGroupTeamPage(this.queryParams).then(response => {
this.list = response.data.list;
this.total = response.data.total;
});
},
2023-08-02 09:17:46 +08:00
handleClick(val) {
switch (val.type) {
case 'edit':
this.addOrEditTitle = '编辑'
this.$nextTick(() => {
this.$refs.groupList.init(val.data.id)
})
this.centervisible = true
break
default:
this.handleDelete(val.data)
}
2023-07-27 15:16:13 +08:00
},
2023-08-02 09:17:46 +08:00
// 班组状态
handleTableEvents(data) {
updateGroupTeam({ ...data }).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess("操作成功");
}
})
2023-07-27 15:16:13 +08:00
},
2023-08-02 09:17:46 +08:00
handleCancel() {
this.$refs.groupList.formClear()
this.centervisible = false
this.addOrEditTitle = ''
2023-07-27 15:16:13 +08:00
},
2023-08-02 09:17:46 +08:00
handleConfirm() {
this.$refs.groupList.submitForm()
2023-07-27 15:16:13 +08:00
},
2023-08-02 09:17:46 +08:00
successSubmit() {
this.handleCancel()
this.getList()
2023-07-27 15:16:13 +08:00
},
/** 删除按钮操作 */
handleDelete(row) {
2023-08-02 09:17:46 +08:00
this.$modal.confirm('是否确认删除班组名称为"' + row.name + '"的数据项?').then(function() {
return deleteGroupTeam(row.id);
2023-07-27 15:16:13 +08:00
}).then(() => {
2023-08-02 09:17:46 +08:00
this.queryParams.pageNo = 1;
2023-07-27 15:16:13 +08:00
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>