<template>
    <view class="mx3" style="padding-bottom: 100rpx">
        <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
        <view
            class="p3 bg-color-white"
            style="margin-top: -50rpx; border-radius: 20rpx"
        >
            <u-form :model="form" ref="uForm" :label-width="180">
                <u-form-item label="计划名称">
                    <u-input disabled v-model="form.planName" />
                </u-form-item>
                <u-form-item label="盘点仓库">
                    <u-input disabled v-model="form.storeName" />
                </u-form-item>
                <u-form-item label="盘点备件">
                    <u-input disabled v-model="form.spareName" />
                </u-form-item>
                <u-form-item label="任务开始时间">
                    <u-input disabled v-model="form.startTime" />
                </u-form-item>
                <u-form-item label="待盘数量">
                    <u-input disabled v-model="form.checkNum" />
                </u-form-item>

                <u-form-item label="盘点数量">
                    <u-input v-model="form.realNum" />
                </u-form-item>
                <u-form-item label="备注">
                    <u-input
                        placeholder="请填写说明"
                        type="textarea"
                        :height="50"
                        v-model="form.remark"
                    />
                </u-form-item>
            </u-form>

            <view class="p-fixed d-flex j-around a-center footer">
                <view class="main-color-bg text-color-white common" @tap="submit"
                >提交</view
                >
            </view>
        </view>
    </view>
</template>

<script>
import DictCache from "@/utils/dict.js";
export default {
    data() {
        return {
            action: this.$BaseTool.UserUtil.getUploadUrl(),
            // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
            header: {
                Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
            },
            fileList: [],
            imagesList: [],
            form: {
                planId: "",
                sbId: "",
                partId: "",
                standardId: "",
                checkUserId: "",
                planNo: "",
                name: "",
                planName: "",
                checkUserName: "",
                sbName: "",
                partName: "",
                startTime: "",
                endTime: "",
                actualStartTime: "",
                actualEndTime: "",
                status: "",
                createdUserName: "",
                createdTime: "",
                remark: "",
                feedback: "",
            },
            test: null,
            detailId: "",
        };
    },
    onLoad(options) {
        this.detailId = options.detailId;
        this.initData();
        this.statusMap = this.$DictCache.getLabelByValueMapByType(
            this.$DictCache.TYPE.STORE_CHECK_JOB_STATUS
        );
    },
    methods: {
        // 提交
        submit() {
            this.form.fileList = this.imagesList;
            this.$Http.finishStoreCheckJob(this.form).then((res) => {
                uni.showToast({
                    title: res.message,
                });
            });
        },
        initData() {
            this.$Http
                .fetchStoreCheckJob({
                    id: this.detailId,
                })
                .then((res) => {
                    this.form = res.data;
                });
        },
        // 删除成功
        uploadRemove(index, lists, name) {
            this.fileList = lists;

            this.imagesList.splice(index, 1)
            console.log(this.imagesList);
        },
        // 上传成功
        uploadSuccess(data, index, lists, name) {
            this.fileList = lists;
            this.imagesList.push(data.data)
            console.log(this.imagesList);
        }
    },
};
</script>

<style lang="less">
page {
    background-color: #f4f4f4;
}

.footer {
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    z-index: 10000;
    border-top: 1rpx solid #f4f4f4;
    height: 100rpx;

    .common {
        padding: 15rpx 200rpx;
        border-radius: 30rpx;
        background-color: #0082ff;
        color: #fff;
    }
}
</style>
