<div class="modal fade" id="createdModal">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title text-center text-uppercase">
                    <span v-show="isUpdate">卸货任务修改</span>
                    <span v-show="!isUpdate">卸货任务添加</span>
                </h5>
                <button type="button" class="close" data-dismiss="modal"
                        @click="addTask={},isUpdate=false,taskError={}">
                    <span>&times;</span>
                </button>
            </div>

            <div class="modal-body">
                <form class="form">
                    <div class="form-group row">
                        <label for="addTask-owner-id" class="col-sm-3 col-form-label text-right text-primary">货主 *</label>
                        <div class="col-sm-5">
                            <select id="addTask-owner-id" class="form-control"
                                    v-model="addTask.owner_id" :class="taskError.owner_id? 'is-invalid' :''" @focus="taskError.owner_id = null">
                                <option v-for="(owner,index) in ownerFilter" :value="owner.name" :key="owner+index">@{{
                                    owner.value }}
                                </option>
                            </select>
                            <div class="invalid-feedback">
                                @{{ taskError['owner_id'] ? taskError['owner_id'][0] : '' }}
                            </div>
                        </div>
                        <div class="col-3 ">
                            <input class="form-control" id="owner-name-filter" placeholder="输入货主进行刷选" @input="filterOwner($event)">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-created-at" class="col-sm-3 col-form-label text-right text-primary">预约日期 *</label>
                        <div class="col-sm-9 form-inline">
                            <input type="datetime-local" id="addTask-created-at" class="form-control col-9"
                                   v-model="addTask.income_at" @focus="taskError.income_at= null">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-type" class="col-sm-3 col-form-label text-right text-primary text-primary">作业名称 *</label>
                        <div class="col-sm-9 form-inline">
                            <select id="addTask-type" class="form-control col-4" v-model="addTask.type"
                                    :class="taskError.type? 'is-invalid' :''"
                                    @focus="taskError.type= null">
                                <option v-for="(type,index) in taskTypes" :value="type.name" :key="type+index">@{{
                                    type.value }}
                                </option>
                            </select>
                            <div class="invalid-feedback">
                                @{{ taskError['type'] ? taskError['type'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-type" class="col-sm-3 col-form-label text-right text-primary">仓库 *</label>
                        <div class="col-sm-9 form-inline">
                            <select id="addTask-type" class="form-control col-4" v-model="addTask.warehouse_id"
                                    :class="taskError.warehouse_id? 'is-invalid' :''"
                                    @focus="taskError.warehouse_id = null">
                                <option v-for="(type,index) in warehouses" :value="type.id" :key="type+index">@{{ type.name }}
                                </option>
                            </select>
                            <div class="invalid-feedback">
                                @{{ taskError['warehouse_id'] ? taskError['warehouse_id'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-numbers" class="col-sm-3 col-form-label text-right text-primary">入库单 *</label>
                        <div class="col-sm-9 form-inline">
                            <input type="text" id="addTask-numbers" class="form-control col-9"
                                   v-model="addTask.numbers" :class="taskError.numbers? 'is-invalid' :''"
                                   @focus="taskError.numbers = null">
                            <div class="invalid-feedback">
                                @{{ taskError['numbers'] ? taskError['numbers'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-amount" class="col-sm-3 col-form-label text-right text-primary">数量 *</label>
                        <div class="col-sm-9 form-inline">
                            <input type="number" id="addTask-amount" class="form-control col-9"
                                   v-model="addTask.income_amount" :class="taskError.income_amount? 'is-invalid' :''"
                                   @focus="taskError.income_amount = null">
                            <div class="invalid-feedback">
                                @{{ taskError['income_amount'] ? taskError['income_amount'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-amount" class="col-sm-3 col-form-label text-right text-primary">单位 *</label>
                        <div class="col-sm-9 form-inline">
                            <select id="addTask-type" class="form-control col-4" v-model="addTask.income_unit"
                                    :class="taskError.income_unit? 'is-invalid' :''"
                                    @focus="taskError.income_unit = null">
                                <option v-for="(unit,index) in units" :value="unit.name" :key="unit+index">@{{
                                    unit.value }}
                                </option>
                            </select>
                            <div class="invalid-feedback">
                                @{{ taskError['income_unit'] ? taskError['income_unit'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="addTask-income-unit-price" class="col-sm-3 col-form-label text-right text-primary">单价 *</label>
                        <div class="col-sm-9 form-inline">
                            <input type="number" id="addTask-income-unit-price" class="form-control col-9"
                                   v-model="addTask.income_unit_price" :class="taskError.income_unit_price? 'is-invalid' :''"
                                   @focus="taskError.income_unit_price = null">
                            <div class="invalid-feedback">
                                @{{ taskError['income_unit_price'] ? taskError['income_unit_price'][0] : '' }}
                            </div>
                        </div>
                    </div>

                    <div class="form-group row" v-show="isUpdate">
                        <label for="addTask-income-total-cost" class="col-sm-3 col-form-label text-right text-primary">总价 *</label>
                        <div class="col-sm-9 form-inline">
                            <input type="number" id="addTask-income-total-cost" class="form-control col-9"
                                   v-model="addTask.income_total_cost">
                        </div>
                    </div>


                    <div class="form-group row">
                        <label for="addTask-amount" class="col-sm-3 col-form-label text-right">备注</label>
                        <div class="col-sm-9 form-inline">
                            <textarea class="form-control col-9" v-model="addTask.income_remark"></textarea>
                        </div>
                    </div>
                </form>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal"
                        @click="addTask={},isUpdate=false,taskError={}">关闭
                </button>
                <button type="button" class="btn btn-primary" v-show="isUpdate"
                        @click="updateCurrentTask(addTask,selectIndex)">提交
                </button>
                <button type="button" class="btn btn-primary" v-show="!isUpdate" @click="createTask">创建</button>
            </div>
        </div>
    </div>

</div>
