<template> 
 | 
    <GlobalWindow 
 | 
        :title="title" 
 | 
        width="30%" 
 | 
        :visible.sync="visible" 
 | 
        :confirm-working="isWorking" 
 | 
        @confirm="confirm" 
 | 
    > 
 | 
        <el-form class="demo-form-inline"> 
 | 
            <el-form-item label="派遣单位" required> 
 | 
                <el-select v-model="dw" @change="selectChange" placeholder="请选择"> 
 | 
                    <el-option 
 | 
                        v-for="item in dispatching" 
 | 
                        :key="item.id" 
 | 
                        :label="item.name" 
 | 
                        :value="item.id"> 
 | 
                    </el-option> 
 | 
                </el-select> 
 | 
            </el-form-item> 
 | 
            <el-form-item label="所属工种" required> 
 | 
                <el-select v-model="gz" placeholder="请选择"> 
 | 
                    <el-option 
 | 
                        v-for="item in options" 
 | 
                        :key="item.id" 
 | 
                        :label="item.name" 
 | 
                        :value="item.id"> 
 | 
                    </el-option> 
 | 
                </el-select> 
 | 
            </el-form-item> 
 | 
        </el-form> 
 | 
    </GlobalWindow> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
    import BaseOpera from '@/components/base/BaseOpera' 
 | 
    import GlobalWindow from '@/components/common/GlobalWindow' 
 | 
    import { findListByDTO } from '@/api/business/dispatchUnit' 
 | 
    import { findListByDTO as worktype } from '@/api/business/worktype' 
 | 
    export default { 
 | 
        name: 'confirmJobType', 
 | 
        extends: BaseOpera, 
 | 
        components: { GlobalWindow }, 
 | 
        data () { 
 | 
            return { 
 | 
                form: { 
 | 
                    solutionId: '' 
 | 
                }, 
 | 
                data: [], 
 | 
                dw: [], 
 | 
                gz: [], 
 | 
                dispatching: [], 
 | 
                options: [] 
 | 
            } 
 | 
        }, 
 | 
        methods: { 
 | 
            open (title, arr) { 
 | 
                this.title = title 
 | 
                this.dw = '' 
 | 
                this.gz = '' 
 | 
                this.form.solutionId = arr.solutionId 
 | 
                this.data = arr.seleData 
 | 
                this.visible = true 
 | 
                this.options=[] 
 | 
                this.getFindListByDTO() 
 | 
            }, 
 | 
            getFindListByDTO () { 
 | 
                findListByDTO({ 
 | 
                    solutionId: this.form.solutionId, 
 | 
                    // dataType: 0 
 | 
                }).then(res => { 
 | 
                    this.dispatching = res 
 | 
                }) 
 | 
            }, 
 | 
            selectChange(id) { 
 | 
                this.gz = '' 
 | 
                let duSolutionId = '' 
 | 
                this.dispatching.forEach(item => { 
 | 
                    if (item.id === id) { 
 | 
                        duSolutionId = item.duSolutionId 
 | 
                    } 
 | 
                }) 
 | 
                worktype({ id: duSolutionId, queryType: 1 }) 
 | 
                    .then(res => { 
 | 
                        this.options = res 
 | 
                    }) 
 | 
            }, 
 | 
            confirm() { 
 | 
              if(!this.dw || !this.gz){ 
 | 
                this.$message.error("请先选择派遣单位和工种!") 
 | 
                return; 
 | 
              } 
 | 
                let obj = { 
 | 
                    workTypeName: '', 
 | 
                    worktypeId: '', 
 | 
                    duName: '', 
 | 
                    duId: '' 
 | 
                } 
 | 
                this.dispatching.forEach(item => { 
 | 
                    if (item.id === this.dw) { 
 | 
                        obj.duName = item.name 
 | 
                        obj.duId = item.id 
 | 
                    } 
 | 
                }) 
 | 
                this.options.forEach(item => { 
 | 
                    if (item.id === this.gz) { 
 | 
                        obj.workTypeName = item.name 
 | 
                        obj.worktypeId = item.id 
 | 
                    } 
 | 
                }) 
 | 
                this.$emit('result', obj) 
 | 
                this.visible = false 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
</script> 
 | 
  
 | 
<style lang="scss" scoped> 
 | 
  
 | 
</style> 
 |