MrShi
2024-11-13 b496da6315314d9bd048ac2214d8bc95d2f1df02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<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 v-if="type !== 2">
                <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: ''
                },
                type: null,
                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.type = arr.type
                this.visible = true
                this.options=[]
                if (arr.type === 2) {
                  worktype({ id: arr.solutionId, queryType: 0 })
                    .then(res => {
                      this.options = res
                    })
                } else {
                  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.type === 2) {
                if(!this.gz){
                  this.$message.error("请先选择工种!")
                  return;
                }
              } else {
                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>