<template>
    <div class="users">
        <el-form :inline="true" :model="formData" :rules="rules" ref="form" class="option">
            <el-form-item label="检查人员:" prop="userAccount">
                <el-select v-model="formData.userAccount" filterable clearable multiple placeholder="选择检查人员">
                    <el-option v-for="item in orgUsers" :key="item.userId" :value="item.userId" :label="item.userName" />
                </el-select>
            </el-form-item>
            <el-form-item label="检查时间:" prop="checkDate">
                <el-date-picker
                    v-model="formData.checkDate"
                    type="date"
                    placeholder="选择日期">
                </el-date-picker>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>

import { getUserByOrg } from '@/api/base'

export default {
    name: 'AssignUser',
    data () {
        return {
            loading: false,
            formData: {
                userAccount: [],
                checkDate: undefined
            },
            orgUsers:[],
            rules: {
                userAccount: [
                    {required: true, message: '请选择检查人员', trigger: 'change'}
                ],
                checkDate: [
                    {required: true, message: '请选择检查时间', trigger: 'change'}
                ]
            }

        }
    },
    props:['jobId','orgId','executor_ids'],
    mounted () {
        this.formData.userAccount = this.executor_ids.split(",")
        this.getOrgUsers()
    },
    methods: {
        getOrgUsers() {
            if (this.orgId) {
                getUserByOrg(1, 10000, this.orgId).then(res => {
                    if (res && res.status === 200 && res.data) {
                        this.orgUsers = res.data
                    }
                })
            }
            else {
                this.$message.warning('请先选择执法机构')
            }
        }
    }
}
</script>