<template>
    <view>
        <view @click="toBatchEdit" class="bg-color-white px3 wrap-edit p-fixed left0 right0 zIndex border-bottom">
					<view class="f-size-26 text-color-9">请选择修改记录</view>
					<view>去编辑</view>
				</view>
        <view style="height: 80rpx;"></view>
        <my-page
            :loadData="loadData"
            :check-box-show="true"
            :swipe-action="true"
            @rowClick="handleDetail"
            :row-show-params="{ sbUseTypeMap }"
            :page-size="10"
            ref="myPage"
        >
            <template #pageRow="{ recordModel, rowShowParams }">
                <view
                    class="p3 bg-color-white box p-relative d-flex"
                    @longpress="showMask(recordModel.id,$event)">
                    <view class="flex1">
                        <view class="d-flex j-between border-bottom pb-2 a-center">
                            <view class="text-color-b f-size-26">{{
                                rowShowParams.sbUseTypeMap[recordModel.sbModelUseType]
                            }}</view>
                            <view class="f-size-24 state-orange">{{
                                recordModel.updateTime
                            }}</view>
                        </view>
                        <view class="mt-2 d-flex j-between">
                            <view class="text-color-3 f-size-32 f-weight-bold">{{
                                recordModel.sbName || ''
                            }}</view>
                            <view class="text-color-3 f-size-32 f-weight-bold">{{
                                recordModel.zbh || ''
                            }}</view>
                        </view>
                        <view class="mt-2 d-flex j-between">
                            <view class="f-size-26 text-color-6 f-weight-4 mt-2">
                                {{ recordModel.sbNo||'' }}
                            </view>
                            <view class="f-size-26 text-color-6 f-weight-4 mt-2 pr-3">
                                {{ recordModel.fillDate || '' }}
                            </view>
                        </view>
                    </view>
                </view>
            </template>
        </my-page>
    </view>
</template>

<script>

export default {
    data() {
        return {
            sbUseTypeMap: {},
            maskId: 0,
            checked: true,
            checkMap: {}
        };
    },
    onPullDownRefresh() {
        this.$refs.myPage.pagePullDownRefresh();
    },
    onReachBottom() {
        this.$refs.myPage.pageReachBottom();
    },
    onLoad() {
        this.sbUseTypeMap = this.$DictCache.getLabelByValueMapByType(
            this.$DictCache.TYPE.SB_USE_TYPE
        );
        this.$nextTick(() => {
            this.$refs.myPage.initPage();
        });
    },
    onHide() {
        this.maskId = 0
    },
    methods: {
        handleChange(e) { },
        showMask(id, e) {
            this.maskId = id
            // #ifdef H5
            e.preventDefault()
            // #endif
        },
        loadData(parameter) {
            return this.$Http
                .getSbRunFillPage({
                    ...parameter,
                    filter: 1
                })
                .then((res) => {
                    return res.data;
                });
        },
        // 删除
        handleDel(item) {
            const that = this;
            const params = [];
            params.push(item.id);
            uni.showModal({
                title: '提示',
                content: '您确认删除吗?',
                success: (res) => {
                    if (res.confirm) {
                        this.$Http.deleteSbRunFills(params).then((res) => {
                            uni.showToast({ title: '删除成功' });
                            that.$refs.myPage.listData = [];
                            that.$refs.myPage.loadMore = true;
                            that.$refs.myPage.pageNum = 1;
                            that.$refs.myPage.initData();
                        });
                    } else if (res.cancel) {
                    }
                }
            });
        },
        handleClick() {
            uni.navigateTo({
                url: '/pages/running/running-edit'
            });
        },
        toBatchEdit() {
            const checkData = this.$refs.myPage.$data.checkData
            if (!checkData || Object.keys(checkData).length <= 0) {
                uni.showToast({ title: '请选择修改记录', icon: 'none' })
                return
            }
            uni.setStorage({
                key: 'sb-run-list',
                data: Object.keys(checkData),
                success: function () {
                    uni.navigateTo({
                        url: '/pages/running/running-batch-edit'
                    });
                }
            });
        },
        // 跳转详情
        handleDetail(item) {
            // if (this.maskId != 0) return this.maskId = 0
            // uni.navigateTo({
            //     url: '/pages/running/running-detail?id=' + item.id
            // });
        }
    }
};
</script>

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

.box {
  padding-right: 0;
  border-radius: 20rpx;
	/* #ifdef MP-WEIXIN */
	width: 630rpx;
	/* #endif */
}

.p-top8 {
  padding-top: 0rpx;
}
.wrap-edit{
	height: 80rpx;
	line-height: 80rpx;
	display: flex;
	justify-content: space-between;
}
</style>
