Browse Source

表格修改

fix_bug_pro20231227
zhangsiyu 2 years ago
parent
commit
5ba28b273c
  1. 403
      src/views/basicdata/team/basicdataTeamGroup.vue

403
src/views/basicdata/team/basicdataTeamGroup.vue

@ -1,12 +1,12 @@
<template> <template>
<basic-container> <basic-container>
<div class="avue-crud"> <div class="avue-crud">
<el-row v-if="!search" style="padding:6px 18px"> <el-row v-if="!search" style="padding: 6px 18px">
<!-- 查询模块 --> <!-- 查询模块 -->
<el-form :inline="true" :model="query"> <el-form :inline="true" :model="query">
<!-- <el-form-item label="仓库名称:">--> <!-- <el-form-item label="仓库名称:">-->
<!-- <el-input v-model="query.warehouseName" placeholder="请输入仓库名称"></el-input>--> <!-- <el-input v-model="query.warehouseName" placeholder="请输入仓库名称"></el-input>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="班组名称:"> <el-form-item label="班组名称:">
<el-input v-model="query.groupName" placeholder="请输入班组名称"></el-input> <el-input v-model="query.groupName" placeholder="请输入班组名称"></el-input>
</el-form-item> </el-form-item>
@ -22,7 +22,9 @@
<!-- 头部左侧按钮模块 --> <!-- 头部左侧按钮模块 -->
<div class="avue-crud__left"> <div class="avue-crud__left">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd"> </el-button> <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> <el-button type="danger" icon="el-icon-delete" @click="handleDelete" plain
> </el-button
>
</div> </div>
<!-- 头部右侧按钮模块 --> <!-- 头部右侧按钮模块 -->
<div class="avue-crud__right"> <div class="avue-crud__right">
@ -44,69 +46,100 @@
@selection="selectionChange" @selection="selectionChange"
> >
<template #default="slotProps"> <template #default="slotProps">
<el-text type="primary" text icon="el-icon-view" @click="handleView(slotProps.scope.row)">查看</el-text> <el-text
<el-text type="primary" text icon="el-icon-view" @click="handleList(slotProps.scope.row)">人员列表</el-text> type="primary"
<el-text type="primary" text icon="el-icon-edit" @click="handleEdit(slotProps.scope.row)">编辑</el-text> text
<el-text type="primary" text icon="el-icon-delete" @click="rowDel(slotProps.scope.row)">删除</el-text> icon="el-icon-view"
@click="handleView(slotProps.scope.row)"
>查看</el-text
>
<el-text
type="primary"
text
icon="el-icon-view"
@click="handleList(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> </template>
</tablecmt> </tablecmt>
</el-row> </el-row>
<el-row> <el-row>
<div class="avue-crud__pagination" style="width:100%"> <div class="avue-crud__pagination" style="width: 100%">
<!-- 分页模块 --> <!-- 分页模块 -->
<el-pagination align="right" <el-pagination
background align="right"
@size-change="sizeChange" background
@current-change="currentChange" @size-change="sizeChange"
:current-page="page.currentPage" @current-change="currentChange"
:page-sizes="[30, 50,80, 120]" :current-page="page.currentPage"
:page-size="page.pageSize" :page-sizes="[30, 50, 80, 120]"
layout="total, sizes, prev, pager, next, jumper" :page-size="page.pageSize"
:total="page.total"> layout="total, sizes, prev, pager, next, jumper"
:total="page.total"
>
</el-pagination> </el-pagination>
</div> </div>
</el-row> </el-row>
<!-- 表单模块 --> <!-- 表单模块 -->
<el-dialog :title="title" <el-dialog
v-model="box" :title="title"
width="40%" v-model="box"
:before-close="beforeClose" width="40%"
append-to-body> :before-close="beforeClose"
append-to-body
>
<el-form :disabled="view" ref="form" :model="form" :rules="rules" label-width="80px"> <el-form :disabled="view" ref="form" :model="form" :rules="rules" label-width="80px">
<!-- 表单字段 --> <!-- 表单字段 -->
<!-- <el-form-item label="归属部门" prop="department">--> <!-- <el-form-item label="归属部门" prop="department">-->
<!-- <el-select v-model="form.department" clearable placeholder="请选择归属部门" @change="clickDept($event)">--> <!-- <el-select v-model="form.department" clearable placeholder="请选择归属部门" @change="clickDept($event)">-->
<!-- <el-option--> <!-- <el-option-->
<!-- v-for="item in departmentData"--> <!-- v-for="item in departmentData"-->
<!-- :key="item.id"--> <!-- :key="item.id"-->
<!-- :label="item.deptName"--> <!-- :label="item.deptName"-->
<!-- :value="item.id">--> <!-- :value="item.id">-->
<!-- </el-option>--> <!-- </el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="组名" prop="groupName"> <el-form-item label="组名" prop="groupName">
<el-input v-model="form.groupName" placeholder="请输入组名"/> <el-input v-model="form.groupName" placeholder="请输入组名" />
</el-form-item> </el-form-item>
<!-- <el-form-item label="仓库" prop="belongTo">--> <!-- <el-form-item label="仓库" prop="belongTo">-->
<!--&lt;!&ndash; <el-input v-model="form.belongTo" placeholder="请输入仓库"/>&ndash;&gt;--> <!--&lt;!&ndash; <el-input v-model="form.belongTo" placeholder="请输入仓库"/>&ndash;&gt;-->
<!-- <el-select v-model="form.belongTo" clearable placeholder="请选择仓库" style="width: 80%" @change="clickWarehouse($event)">--> <!-- <el-select v-model="form.belongTo" clearable placeholder="请选择仓库" style="width: 80%" @change="clickWarehouse($event)">-->
<!-- <el-option--> <!-- <el-option-->
<!-- v-for="item in warehouseList"--> <!-- v-for="item in warehouseList"-->
<!-- :key="item.id"--> <!-- :key="item.id"-->
<!-- :label="item.name"--> <!-- :label="item.name"-->
<!-- :value="item.id">--> <!-- :value="item.id">-->
<!-- </el-option>--> <!-- </el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="班组类型" prop="groupTypes"> <el-form-item label="班组类型" prop="groupTypes">
<!-- <el-input v-model="form.groupType" placeholder="请输入班组类型"/>--> <!-- <el-input v-model="form.groupType" placeholder="请输入班组类型"/>-->
<el-select v-model="form.groupTypes" multiple clearable placeholder="请选择班组类型" style="width: 80%"> <el-select
v-model="form.groupTypes"
multiple
clearable
placeholder="请选择班组类型"
style="width: 80%"
>
<el-option <el-option
v-for="item in teamType" v-for="item in teamType"
:key="item.dictKey" :key="item.dictKey"
:label="item.dictValue" :label="item.dictValue"
:value="item.dictKey"> :value="item.dictKey"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -114,7 +147,9 @@
<!-- 表单按钮 --> <!-- 表单按钮 -->
<template #footer> <template #footer>
<span v-if="!view" class="dialog-footer"> <span v-if="!view" class="dialog-footer">
<el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')"> </el-button> <el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')"
> </el-button
>
<el-button icon="el-icon-circle-close" @click="box = false"> </el-button> <el-button icon="el-icon-circle-close" @click="box = false"> </el-button>
</span> </span>
</template> </template>
@ -124,17 +159,17 @@
</template> </template>
<script> <script>
import { getList, getDetail, add, update, remove } from "@/api/basicdata/basicdataTeamGroup"; import { getList, getDetail, add, update, remove } from '@/api/basicdata/basicdataTeamGroup';
import option from "@/option/basicdata/basicdataTeamGroup"; import option from '@/option/basicdata/basicdataTeamGroup';
import { mapGetters } from "vuex"; import { mapGetters } from 'vuex';
import { getDictionaryBiz } from '@/api/system/dict'; import { getDictionaryBiz } from '@/api/system/dict';
import { getListUser } from '@/api/distribution/distributionStockup'; import { getListUser } from '@/api/distribution/distributionStockup';
import { getDept,getLazyList } from '@/api/system/dept'; import { getDept, getLazyList } from '@/api/system/dept';
import { getDeptWarehouse } from '@/api/basicdata/basicdataWarehouse'; import { getDeptWarehouse } from '@/api/basicdata/basicdataWarehouse';
import { getUserDetail } from '@/api/system/user'; import { getUserDetail } from '@/api/system/user';
export default { export default {
data () { data() {
return { return {
columnList: [ columnList: [
{ {
@ -217,7 +252,7 @@ export default {
page: { page: {
currentPage: 1, currentPage: 1,
pageSize: 30, pageSize: 30,
total: 40 total: 40,
}, },
// //
form: {}, form: {},
@ -232,34 +267,26 @@ export default {
// //
data: [], data: [],
rules: { rules: {
groupName: [ groupName: [{ required: true, message: '请输入班组名称', trigger: 'blur' }],
{ required: true, message: '请输入班组名称', trigger: 'blur' }, groupTypes: [{ required: true, message: '请选择班组类型', trigger: 'change' }],
], department: [{ required: true, message: '请选择班组', trigger: 'change' }],
groupTypes: [ belongTo: [{ required: true, message: '请选择仓库', trigger: 'change' }],
{ required: true, message: '请选择班组类型', trigger: 'change' } },
], };
department: [
{ required: true, message: '请选择班组', trigger: 'change' }
],
belongTo: [
{ required: true, message: '请选择仓库', trigger: 'change' }
],
}
}
}, },
mounted () { mounted() {
this.init(); this.init();
this.onLoad(this.page); this.onLoad(this.page);
}, },
computed: { computed: {
...mapGetters(["permission"]), ...mapGetters(['permission']),
ids () { ids() {
let ids = []; let ids = [];
this.selectionList.forEach(ele => { this.selectionList.forEach(ele => {
ids.push(ele.id); ids.push(ele.id);
}); });
return ids.join(","); return ids.join(',');
} },
}, },
methods: { methods: {
showdrawer(value) { showdrawer(value) {
@ -290,49 +317,48 @@ export default {
console.log(index, row); console.log(index, row);
}, },
selectsc(index, row) { selectsc(index, row) {
this.query[row.prop] =index this.query[row.prop] = index;
if (!index){ if (!index) {
delete this.query[row.prop] delete this.query[row.prop];
} }
this.onLoad(this.page); this.onLoad(this.page);
}, },
timesc(index, row) { timesc(index, row) {
if (!!index){ if (!!index) {
index = dayjs(index).format('YYYY-MM-DD'); index = dayjs(index).format('YYYY-MM-DD');
} }
this.query[row.prop] = index this.query[row.prop] = index;
if (!index){ if (!index) {
delete this.query[row.prop] delete this.query[row.prop];
} }
this.onLoad(this.page); this.onLoad(this.page);
}, },
inputsc(index, row) { inputsc(index, row) {
this.query[row.prop] =index this.query[row.prop] = index;
if (!index){ if (!index) {
delete this.query[row.prop] delete this.query[row.prop];
} }
this.onLoad(this.page); this.onLoad(this.page);
}, },
// //
clickWarehouse(row){ clickWarehouse(row) {
// console.log("",row); // console.log("",row);
let a = this.warehouseList.find(i => i.id == row); let a = this.warehouseList.find(i => i.id == row);
if(!!a){ if (!!a) {
this.form.warehouseName = a.name; this.form.warehouseName = a.name;
this.form.belongTo = a.id; this.form.belongTo = a.id;
} }
}, },
// //
clickDept(row){ clickDept(row) {
// console.log("",row); // console.log("",row);
let a = this.departmentData.find(i => i.id == row); let a = this.departmentData.find(i => i.id == row);
if(!!a){ if (!!a) {
this.form.departmentName = a.deptName; this.form.departmentName = a.deptName;
this.form.department = a.id; this.form.department = a.id;
} }
}, },
init () { init() {
this.height = this.setPx(document.body.clientHeight - 340); this.height = this.setPx(document.body.clientHeight - 340);
getDictionaryBiz('team_type').then(res => { getDictionaryBiz('team_type').then(res => {
this.teamType = res.data.data; this.teamType = res.data.data;
@ -343,19 +369,19 @@ export default {
// }); // });
}); });
}, },
searchHide () { searchHide() {
this.search = !this.search; this.search = !this.search;
}, },
searchChange () { searchChange() {
this.onLoad(this.page); this.onLoad(this.page);
}, },
searchReset () { searchReset() {
this.query = {}; this.query = {};
this.page.currentPage = 1; this.page.currentPage = 1;
this.onLoad(this.page); this.onLoad(this.page);
}, },
handleSubmit (formName) { handleSubmit(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate(valid => {
if (valid) { if (valid) {
if (!this.form.id) { if (!this.form.id) {
this.form.groupType = this.form.groupTypes.join(','); this.form.groupType = this.form.groupTypes.join(',');
@ -364,8 +390,8 @@ export default {
this.box = false; this.box = false;
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: '操作成功!',
}); });
}); });
} else { } else {
@ -374,109 +400,105 @@ export default {
this.box = false; this.box = false;
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: '操作成功!',
}); });
}) });
} }
}else { } else {
console.log('error submit!!'); console.log('error submit!!');
return false; return false;
} }
}); });
}, },
handleAdd () { handleAdd() {
this.title = '新增' this.title = '新增';
this.form = {} this.form = {};
this.box = true; this.box = true;
// //
this.getWarehouseList(); this.getWarehouseList();
}, },
async getWarehouseList(){ async getWarehouseList() {
let userDept = await getListUser(); let userDept = await getListUser();
console.log("<><><>",userDept.data.data); console.log('<><><>', userDept.data.data);
let sole = await getUserDetail(userDept.data.data.userId); let sole = await getUserDetail(userDept.data.data.userId);
console.log(",....t=用户信息s",sole); console.log(',....t=用户信息s', sole);
if(sole.data.data.roleName == '管理员'){ if (sole.data.data.roleName == '管理员') {
// let dept = await getDept(); // let dept = await getDept();
let parentId = 0; let parentId = 0;
let lis = await getLazyList(parentId); let lis = await getLazyList(parentId);
console.log("全部部门",lis); console.log('全部部门', lis);
this.departmentData = lis.data.data; this.departmentData = lis.data.data;
// //
let deptW = await getDeptWarehouse({tenantId: userDept.data.data.tenantId}); let deptW = await getDeptWarehouse({ tenantId: userDept.data.data.tenantId });
console.log("仓库数据",deptW.data.data); console.log('仓库数据', deptW.data.data);
this.warehouseList = deptW.data.data; this.warehouseList = deptW.data.data;
}else{ } else {
// //
let dept = await getDept(userDept.data.data.deptId); let dept = await getDept(userDept.data.data.deptId);
console.log("<><><>",dept.data.data); console.log('<><><>', dept.data.data);
// let a = { // let a = {
// id:dept.data.data.id, // id:dept.data.data.id,
// deptName: dept.data.data.deptName // deptName: dept.data.data.deptName
// } // }
/* this.departmentData = []; /* this.departmentData = [];
this.form.department = a.id; this.form.department = a.id;
this.form.departmentName = a.deptName; this.form.departmentName = a.deptName;
this.departmentData.push(a);*/ this.departmentData.push(a);*/
const da = dept.data.data; const da = dept.data.data;
if(!!da.parentId && da.parentId != '0'){ if (!!da.parentId && da.parentId != '0') {
// //
let deptW = await getDeptWarehouse({department: da.id}); let deptW = await getDeptWarehouse({ department: da.id });
this.warehouseList = deptW.data.data; this.warehouseList = deptW.data.data;
console.log("123123123123",deptW); console.log('123123123123', deptW);
} }
} }
}, },
// //
handleList(row){ handleList(row) {
console.log('班组信息', row);
console.log("班组信息",row);
this.$router.push({ this.$router.push({
path: '/basicdata/team/basicdataTeamStaff', path: '/basicdata/team/basicdataTeamStaff',
query: { query: {
id: row.id, id: row.id,
name: '班组人员 - ' + row.groupName, name: '班组人员 - ' + row.groupName,
type: '2' type: '2',
} },
}); });
}, },
async handleEdit (row) { async handleEdit(row) {
// //
await this.getWarehouseList(); await this.getWarehouseList();
this.title = '编辑' this.title = '编辑';
this.box = true this.box = true;
getDetail(row.id).then(res => { getDetail(row.id).then(res => {
console.log("编码》》》",res.data.data.groupType); console.log('编码》》》', res.data.data.groupType);
this.form = res.data.data; this.form = res.data.data;
this.form.groupTypes = this.form.groupType.split(","); this.form.groupTypes = this.form.groupType.split(',');
console.log("<><><>",this.form); console.log('<><><>', this.form);
}); });
}, },
handleView (row) { handleView(row) {
this.title = '查看' this.title = '查看';
this.view = true; this.view = true;
this.box = true; this.box = true;
// //
this.getWarehouseList(); this.getWarehouseList();
getDetail(row.id).then(res => { getDetail(row.id).then(res => {
this.form = res.data.data; this.form = res.data.data;
this.form.groupTypes = this.form.groupType.split(","); this.form.groupTypes = this.form.groupType.split(',');
}); });
}, },
handleDelete () { handleDelete() {
if (this.selectionList.length === 0) { if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据"); this.$message.warning('请选择至少一条数据');
return; return;
} }
this.$confirm("确定将选择数据删除?", { this.$confirm('确定将选择数据删除?', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning',
}) })
.then(() => { .then(() => {
return remove(this.ids); return remove(this.ids);
@ -485,16 +507,16 @@ export default {
this.selectionClear(); this.selectionClear();
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: '操作成功!',
}); });
}); });
}, },
rowDel (row) { rowDel(row) {
this.$confirm("确定将选择数据删除?", { this.$confirm('确定将选择数据删除?', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning',
}) })
.then(() => { .then(() => {
return remove(row.id); return remove(row.id);
@ -502,32 +524,32 @@ export default {
.then(() => { .then(() => {
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: '操作成功!',
}); });
}); });
}, },
beforeClose (done) { beforeClose(done) {
done() done();
this.form = {}; this.form = {};
this.view = false; this.view = false;
}, },
selectionChange (list) { selectionChange(list) {
this.selectionList = list; this.selectionList = list;
}, },
selectionClear () { selectionClear() {
this.selectionList = []; this.selectionList = [];
// this.$refs.table.clearSelection(); // this.$refs.table.clearSelection();
}, },
currentChange (currentPage) { currentChange(currentPage) {
this.page.currentPage = currentPage; this.page.currentPage = currentPage;
this.onLoad(this.page); this.onLoad(this.page);
}, },
sizeChange (pageSize) { sizeChange(pageSize) {
this.page.pageSize = pageSize; this.page.pageSize = pageSize;
this.onLoad(this.page); this.onLoad(this.page);
}, },
onLoad (page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data; const data = res.data.data;
@ -550,17 +572,20 @@ export default {
this.data.forEach(e => { this.data.forEach(e => {
let a = e.groupType.split(','); let a = e.groupType.split(',');
let f = a.map((i, index) => { let f = a
let s = this.teamType.find(l => l.dictKey === i); .map((i, index) => {
return s ? s.dictValue : ''; let s = this.teamType.find(l => l.dictKey === i);
}).filter(Boolean).join(' | '); return s ? s.dictValue : '';
})
.filter(Boolean)
.join(' | ');
e.groupTypeName = f; e.groupTypeName = f;
}); });
this.loading = false; this.loading = false;
this.selectionClear(); this.selectionClear();
}); });
} },
} },
}; };
</script> </script>

Loading…
Cancel
Save