This commit is contained in:
shijing 2023-11-20 16:50:23 +08:00
parent df9bdab0a6
commit 0229338a5f
2 changed files with 225 additions and 1 deletions

203
src/views/hrm/team_form.vue Normal file
View File

@ -0,0 +1,203 @@
<template>
<el-drawer
:title="titleMap[mode]"
v-model="visible"
:size="1000"
destroy-on-close
@closed="closeDrawer"
>
<el-container v-loading="loading">
<el-main style="padding: 0 20px 20px 20px">
<el-card style="width: 100%;margin-bottom: 10px;" header="班组信息" shadow="hover">
<el-descriptions>
<el-descriptions-item label="所属车间">{{ itemObj.belong_dept_name }}</el-descriptions-item>
<el-descriptions-item label="班组名称">{{itemObj.name }}</el-descriptions-item>
<el-descriptions-item label="班组组长">{{ itemObj.leader_name }}</el-descriptions-item>
</el-descriptions>
</el-card>
<sc-form-table
v-model="userList"
:addTemplate="addTemplate"
placeholder="暂无数据"
>
<el-table-column prop="belong_dept_name" label="部门" >
<template #default="scope">
<span>{{ scope.row.belong_dept_name }}</span>
</template>
</el-table-column>
<el-table-column prop="type" label="人员">
<template #default="scope">
<el-select
v-model="scope.row.employee"
filterable
placeholder="人员"
>
<el-option
v-for="item in stateOptions"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="open" label="操作" width="80" align="center">
<template #default="scope">
<el-button
text
type="primary"
size="small"
@click="createUserPost(scope.row)"
>保存</el-button
>
</template>
</el-table-column>
</sc-form-table>
</el-main>
<el-footer v-if="mode!=='show'">
<el-button
type="primary"
:loading="isSaveing"
@click="submit"
>
保存
</el-button>
<el-button @click="visible = false">取消</el-button>
</el-footer>
</el-container>
</el-drawer>
</template>
<script>
const defaultForm = {
list:[],
};
export default {
emits: ["success", "closed"],
data() {
return {
belongDept:'',
loading: false,
mode: "add",
titleMap: {
add: '新增',
edit: '编辑',
show: '查看'
},
addTemplate:{
},
stateOptions:[
{label: "待定", id: "pending"},
{label: "正常", id: "normal"},
{label: "迟到", id: "late"},
{label: "早退", id: "early_leave"},
{label: "未到岗", id: "absent"},
{label: "请假", id: "leave"},
],
itemObj:{},
visible: false,
isSaveing: false,
userList:[{name:'',belong_dept_name:''}],
deptOptions: ['6车间','7车间','8车间','10车间'],
shiftOptions:[],
selectionFilters: [],
setFiltersVisible: false,
};
},
mounted() {
this.getShiftOptions();
},
methods: {
getShiftOptions() {
this.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => {
this.deptOptions = res;
});
this.$API.mtm.shift.req({page:0}).then(res=>{
this.shiftOptions = res;
})
},
getEmployee(){
this.$API.hrm.employee.list.req({belong_dept:this.belongDept,page:0}).then(res=>{
this.userList = [];
res.forEach(item=>{
let obj ={};
obj.name = item.name;
obj.employee = item.id;
obj.belong_dept_name = item.belong_dept_name;
obj.state = 'normal';
obj.note = '';
this.userList.push(obj)
})
})
},
//
open(mode) {
this.mode = mode;
this.visible = true;
return this;
},
closeDrawer() {
this.visible = false;
this.$emit('closed');
},
//
submit() {
this.$refs.dialogForm.validate((valid) => {
if (valid) {
this.isSaveing = true;
let arr = [];
this.userList.forEach(item=>{
let obj = {};
obj.employee = item.employee;
obj.shift = this.form.shift;
obj.state = item.state;
obj.work_date = this.form.work_date;
obj.note = item.note;
arr.push(obj)
})
if (this.mode === 'add') {
this.$API.hrm.attendance.create.req(arr)
.then(res => {
this.isSaveing = false;
this.visible = false;
this.$emit("success");
this.$message.success("操作成功");
return res
}).catch(err => {
this.isSaveing = false;
return err
})
} else {
this.$API.hrm.attendance.update.req(this.form.id, this.form)
.then(res => {
this.isSaveing = false;
this.visible = false;
this.$emit("success", this.form, this.mode);
this.$message.success("操作成功");
return res
}).catch(err => {
this.isSaveing = false;
return err
})
}
}
});
},
//
setData(data) {
debugger;
console.log(data);
Object.assign(this.itemObj, data);
},
//
setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
},
};
</script>
<style>
</style>

View File

@ -28,6 +28,8 @@
<el-table-column label="创建时间" prop="create_time" min-width="150"></el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="140">
<template #default="scope">
<el-button link size="small" @click="handleMember(scope.row)" v-auth="'team.update'" type="primary">班组人员</el-button>
<el-divider direction="vertical"></el-divider>
<el-button link size="small" @click="handleEdit(scope.row)" v-auth="'team.update'" type="primary">编辑</el-button>
<el-divider direction="vertical"></el-divider>
<el-popconfirm title="确定删除吗?" @confirm="handleDel(scope.row, scope.$index)">
@ -72,8 +74,16 @@
<el-button v-if="type!=='show'" type="primary" :loading="isSaving" @click="submitHandle()"> </el-button>
</template>
</el-dialog>
<member-dialog
v-if="dialogVisible"
ref="memberDialog"
@success="handleSuccess"
@closed="dialogVisible = false"
>
</member-dialog>
</template>
<script>
import memberDialog from "./team_form.vue";
const defaultForm = {
id:"",
name: "",
@ -83,6 +93,9 @@
};
export default {
name: 'dept',
components: {
memberDialog
},
data() {
return {
apiObj: this.$API.mtm.team.list,
@ -92,6 +105,7 @@
query: {},
isSaving: false,
limitedVisible : false,
dialogVisible:false,
checkStrictly:true,
type: "add",
titleMap: {
@ -184,7 +198,14 @@
//
handleSaveSuccess(){
this.$refs.table.refresh()
}
},
handleMember(row){
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.memberDialog.open('add').setData(row)
})
},
handleSuccess(){},
}
}
</script>