Commit 1f7cddab authored by “lixuyan”'s avatar “lixuyan”

执行派工重派

parent b4e2dac2
<template>
<div class="ReassignWorkers">
<dee-up-table
table-height="auto"
selection-row
:data="filtetData"
:columns="columns"
@selection-change="handleSelectionChange"
>
<dee-tools slot="header" :tools="tools" mode="normal" />
</dee-up-table>
</div>
</template>
<script>
export default {
name: 'ReassignWorkers',
componentName: '重新派工',
props: {
form: {
type: Object,
default: () => {}
},
basicData: {
type: Object,
default: () => {}
}
},
data() {
const that = this
return {
tools: [{
name: '新增',
icon: '/icons/c-add.png',
handler: {
click: () => {
this.handleAdd(false)
}
}
},
{
name: '删除',
icon: '/icons/c-creatbackups.png',
handler: {
click: () => {
this.handleDetele()
}
}
}],
isMasterList: [{
label: '是',
value: true
}, {
label: '否',
value: false
}],
opertorList: [],
selectedRow: [],
tableData: [],
columns: [
{ title: '操作', key: 'operate', align: 'center', hideTip: true, component: {
show: true,
name: 'EditTableRow',
props: {
btns: [
{
operation: '保存',
handleClick: (row, index) => {
this.save(row, index)
},
icon: '/icons/b-save.png',
showFun: (row) => {
return row.isEdit
}
},
{
operation: '编辑',
handleClick: (row, index) => {
this.$set(this.tableData[index], 'isEdit', true)
},
icon: '/icons/c-edit.png',
showFun: (row) => {
return !row.isEdit
}
}
]
}
}, width: 100 },
{
title: '操作人', key: 'extProcessSkillUserId', align: 'center', component: {
render: function(h, data, column, index) {
if (!data.show) {
return (<span>{data.extProcessSkillUser.dxUserInfo.name}</span>)
} else {
return (
<el-select v-model={data.extProcessSkillUser} size='small' valueKey='id'
on-change={() => {}}>
{
that.opertorList.map(x => <el-option disabled={x.disabled} label={x.dxUserInfo.name} value={x}/>)
}
</el-select>)
}
}
}
},
{
title: '是否是主操作手', key: 'isMasterOperator', align: 'center', component: {
render: function(h, data, column, index) {
if (!data.isEdit) {
if (data.isMasterOperator) {
return (<span></span>)
} else {
return (<span></span>)
}
} else {
return (<el-select v-model={data.isMasterOperator} size='small'
on-change={(val) => {
that.changeMasterOperator(index, val)
}}>
{
that.isMasterList.map(x => <el-option label={x.label} value={x.value}/>)
}
</el-select>)
}
}
}
}
]
}
},
computed: {
filtetData() {
return this.tableData.filter(el => (el.operator !== 'REMOVE')) || []
}
},
watch: {
'basicData.prodTask': {
handler: function(val, oval) {
if (!val) return
if (val.length) this.tableData = [...this.basicData.prodTask]
this.getOpertorList()
},
deep: true,
immediate: true
}
},
created() {
},
mounted() {
},
methods: {
getOpertorList() {
const params = {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [{
'items': [{
'fieldName': 'extProcessSkillId',
'operator': 'EQ',
'value': this.basicData.extProcessSkillId
}],
'operator': 'AND'
}],
'items': [],
'operator': 'AND'
},
'openProps': [{
'name': 'extProcessSkill'
}],
'sortItem': [{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}],
'toValidateKeys': ''
}
this.$api.searchApi('ExtProcessSkillUser', params).then(res => {
if (res.items.content.length) {
const arr = []
this.basicData.prodTask.forEach(element => {
arr.push(element.extProcessSkillUserId)
})
res.items.content.forEach(item => {
if (arr.includes(item.id)) {
item.disabled = true
} else {
item.disabled = false
}
})
this.opertorList = res.items.content
}
})
},
handleSelectionChange(val) {
this.selectedRow = val
},
handleDetele() {
if (this.selectedRow.length) {
this.$utils.showConfirm(
'你是否确定删除选中的数据吗?',
'提示',
'warning',
'确定',
'取消',
() => {
this.selectedRow.forEach(item => {
if (item.onlyID) {
this.tableData = this.tableData.filter(el => (el.onlyID !== item.onlyID)) || []
} else {
this.tableData.forEach(ele => {
if (ele.id === item.id) {
ele.operator = 'REMOVE'
}
})
}
})
this.form.prodTask = [...this.tableData]
}
)
} else {
this.$utils.showMessageError('请先选择需要删除的数据')
}
},
save(row, index) {
row.extProcessSkillUserId = row.extProcessSkillUser.id
if (!row.extProcessSkillUserId) return this.$utils.showMessageError('请选择操作者')
this.tableData[index] = row
this.$set(this.tableData[index], 'isEdit', false)
this.$set(this.tableData[index], 'show', false)
this.form.prodTask = [...this.tableData]
},
changeMasterOperator(index, val) {
this.tableData.forEach(item => {
item.isMasterOperator = false
})
this.tableData[index].isMasterOperator = true
this.form.prodTask = [...this.tableData]
},
handleAdd() {
const newObj = {
isEdit: true,
show: true,
extProcessSkillUser: {},
extProcessSkillUserId: '',
extProcessSkillUserIdType: 'ExtProcessSkillUser',
extProcessSkillId: this.basicData.extProcessSkillId,
extProcessSkillIdType: 'ExtProcessSkill',
joExecutePlanId: this.basicData.id,
joExecutePlanIdType: 'JoExecutePlan',
isMasterOperator: false,
operator: 'ADD',
onlyID: new Date().getTime().toString(),
subTypeName: 'FitOut',
taskState: 'N',
isConfirm: 'N'
}
const newObjCopy = this.$utils.deepClone(newObj)
this.tableData.push(newObjCopy)
}
}
}
</script>
<style lang="scss">
</style>
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