Commit 1e37bbe2 authored by jingnan's avatar jingnan 👀

工时分配增加添加及删除按钮联调

parent 80143fbf
<template> <template>
<div class="WorkAllocationEditList"> <div class="WorkAllocationEditList">
<dee-tools v-if="enableEdit" slot="header" :tools="tools" mode="normal" :collapse="false" />
<div class="dee-table dee-table-dis-border"> <div class="dee-table dee-table-dis-border">
<el-table <el-table
ref="table" ref="table"
:data="tableData" :data="tableData"
@cell-click="cellClick" @cell-click="cellClick"
@selection-change="handleSelectionChange"
> >
<el-table-column prop="opertor" label="操作者"> <el-table-column
v-if="enableEdit"
type="selection"
width="55"
:selectable="selectable"
/>
<el-table-column prop="dxUserInfoId" label="操作者">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.isMasterOperator">{{ scope.row.extProcessSkillUser.dxUserInfo.name }}(主)</span> <el-select
<span v-else>{{ scope.row.extProcessSkillUser.dxUserInfo.name }}</span> v-if="!scope.row.id"
v-model="scope.row.dxUserInfoId"
size="small"
filterable
remote
:loading="loading"
@change="saveDxUserInfo"
>
<el-option
v-for="i in userData"
:key="i.value"
:disabled="disabledOptions.includes(i.value)"
:label="i.label"
:value="i.value"
/>
</el-select>
<span v-else>
<span v-if="scope.row.isMasterOperator">{{ scope.row.extProcessSkillUser&&scope.row.extProcessSkillUser.dxUserInfo.name }}(主)</span>
<span v-else>{{ scope.row.extProcessSkillUser&&scope.row.extProcessSkillUser.dxUserInfo.name }}</span>
</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="workHour" label="工时分配(min)"> <el-table-column prop="workHour" label="工时分配(min)">
...@@ -65,7 +92,28 @@ export default { ...@@ -65,7 +92,28 @@ export default {
return { return {
loading: false, loading: false,
tableData: [], tableData: [],
tabClickIndex: '' disabledOptions: [],
userData: [],
tabClickIndex: '',
tools: [{
name: '新增',
icon: '/icons/c-add.png',
handler: {
click: () => {
this.handleAdd()
}
}
},
{
name: '删除',
icon: '/icons/c-creatbackups.png',
handler: {
click: () => {
this.handleRemove()
}
}
}],
currentSelection: []
} }
}, },
computed: { computed: {
...@@ -77,6 +125,9 @@ export default { ...@@ -77,6 +125,9 @@ export default {
} else { } else {
return this.basicData.joExecutePlan.state === 'Pending_Review' || this.form.state === 'Pending_Review' return this.basicData.joExecutePlan.state === 'Pending_Review' || this.form.state === 'Pending_Review'
} }
},
enableEdit() {
return this.basicData.joExecutePlan && this.basicData.joExecutePlan.state === 'Pending_Review' || this.$route.query && this.$route.query.taskDefinitionKey === 'Activity_1p9o5b5'
} }
}, },
watch: { watch: {
...@@ -90,11 +141,23 @@ export default { ...@@ -90,11 +141,23 @@ export default {
}) })
} }
} }
},
tableData: {
immediate: true,
deep: true,
handler(val) {
if (val && val.length) {
this.disabledOptions = val.map(item => {
return item.extProcessSkillUserId
}) || []
}
}
} }
}, },
created() { created() {
}, },
mounted() { mounted() {
this.getUserData()
}, },
methods: { methods: {
getTableData() { getTableData() {
...@@ -143,6 +206,7 @@ export default { ...@@ -143,6 +206,7 @@ export default {
} else { } else {
element.workHourOPercent = null element.workHourOPercent = null
} }
element.dxUserInfoId = element.extProcessSkillUser && element.extProcessSkillUser.dxUserInfoId
}) })
const index = res.items.content.findIndex(item => { const index = res.items.content.findIndex(item => {
return item.isMasterOperator return item.isMasterOperator
...@@ -214,6 +278,132 @@ export default { ...@@ -214,6 +278,132 @@ export default {
// 动态控制精度长度 // 动态控制精度长度
n = (r1 >= r2) ? r1 : r2 n = (r1 >= r2) ? r1 : r2
return ((arg1 * m - arg2 * m) / m).toFixed(n) return ((arg1 * m - arg2 * m) / m).toFixed(n)
},
selectable(row, index) {
if (row.isMasterOperator) {
return false
} else {
return true
}
},
getUserData() {
const params = {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'extProcessSkillId',
'operator': 'EQ',
'value': this.basicData.joExecutePlan && this.basicData.joExecutePlan.extProcessSkillId || this.basicData.extProcessSkillId || ''
}
],
'operator': 'AND'
}
],
'items': [],
'operator': 'AND'
},
'openProps': [
{ 'name': 'dxUserInfo'
},
{ 'name': 'dxPost' }
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
this.loading = true
this.userData = []
post(`/ExtProcessSkillUser/search`, params).then(res => {
res.items && res.items.content.map(item => {
this.userData.push(
{
label: `${item.dxUserInfo.name}(${item.dxUserInfo.number})`,
value: item.id
}
)
})
}).catch(err => {
console.log(err)
}).finally(() => {
})
},
handleAdd() {
const flag = this.tableData.find(item => !item.dxUserInfoId)
if (flag) return this.$utils.showMessageWarning('请选择操作者!')
const allPercent = this.$utils.sumArray(this.tableData, 'workHourOPercent')
if (allPercent >= 100) return this.$utils.showMessageWarning('工时总占比不能超过百分之百,请修改后添加!')
this.tableData.push({
tempId: parseInt(Math.random() * 100000000000000, 10),
dxUserInfoId: '',
tempWorkHourId: this.basicData.id,
workHour: 0,
operator: 'ADD',
workHourOPercent: 0
})
},
handleSelectionChange(val) {
this.currentSelection = val
},
handleRemove() {
if (this.currentSelection.length === 0) {
this.$utils.showMessageWarning('请至少选择一条记录!')
} else {
const removedLists = []
this.tableData = this.tableData.filter(x => this.currentSelection.every(y => x.id !== y.id || x.tempId !== y.tempId))
this.currentSelection.map(item => {
if (item.id) {
removedLists.push({
...item,
operator: 'REMOVE'
})
}
})
post(`/ProdTask/recursions`, removedLists).then(res => {
this.$utils.showMessageSuccess('移除成功')
this.$bus.$emit('refreshWorkAllocationList')
}).catch(err => {
console.log(err)
}).finally(() => {
})
}
},
saveDxUserInfo(val, type) {
const prodTask = [{
'subTypeName': 'FitOut',
'operator': 'ADD',
'extProcessSkillUserId': val,
'extProcessSkillUserIdType': 'ExtProcessSkillUser',
'isMasterOperator': false,
'taskState': 'N',
'extProcessSkillId': this.basicData.joExecutePlan && this.basicData.joExecutePlan.extProcessSkillId || this.basicData.extProcessSkillId,
'extProcessSkillIdType': 'ExtProcessSkill'
}]
const params = [
{
'id': this.basicData.joExecutePlanId || this.basicData.id,
'operator': 'MODIFY',
'prodTask': prodTask
}
]
post(`/ProdTask/prodTaskSave?dmirStatus=N`, params).then((res) => {
this.$message({
message: res.message,
type: 'success'
})
this.loading = false
this.getTableData()
this.$bus.$emit('refreshWorkAllocationList')
})
.catch((res) => {
this.loading = false
})
} }
} }
} }
......
...@@ -33,6 +33,7 @@ export default { ...@@ -33,6 +33,7 @@ export default {
WorkHourConfirm: () => import('./workHourConfirm'), // 工时确认 WorkHourConfirm: () => import('./workHourConfirm'), // 工时确认
StationMasteConfirm: () => import('./stationMasteConfirm'), // 站位长确认 StationMasteConfirm: () => import('./stationMasteConfirm'), // 站位长确认
PlannerConfirm: () => import('./plannerConfirm'), // 计划员确认 PlannerConfirm: () => import('./plannerConfirm'), // 计划员确认
WorkHourExamine: () => import('./workHourExamine'), // 工时审核
OutStorageMatchConfirm: () => import('./outStorageMatchConfirm'), // 配套出库确认 OutStorageMatchConfirm: () => import('./outStorageMatchConfirm'), // 配套出库确认
ProPreparateWorkerConfirm: () => import('./proPreparatWorkerConfirm') // 生产准备工确认 ProPreparateWorkerConfirm: () => import('./proPreparatWorkerConfirm') // 生产准备工确认
}, },
......
...@@ -34,6 +34,9 @@ export default { ...@@ -34,6 +34,9 @@ export default {
watch: {}, watch: {},
created() {}, created() {},
mounted() { mounted() {
this.$bus.$on('refreshWorkAllocationList', (data) => {
this.$refs.applyTable && this.$refs.applyTable.$refs.asCom.getData()
})
}, },
// 组件方法 // 组件方法
methods: { methods: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment