<template>
    <view>
        <cu-custom bgColor="bg-gradual-blueness" :isBack="true">
            <block slot="backText">返回</block>
            <block slot="content">隐患整改</block>
        </cu-custom>
        <scroll-view scroll-y>
            <view class="de-card-list de-list">
                <view class="de-item">
                  <text class="text-semi">{{pd.HIDDENDESCR}}</text>
                </view>
                <!-- 		<view class="de-title">
                            <text class="text-semi">隐患信息</text>
                        </view> -->
                <view class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患来源</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text v-if="pd.SOURCE=='1'" class="text-semi">隐患快报</text>
                        <text v-if="pd.SOURCE=='2'" class="text-semi">清单排查</text>
                        <text v-if="pd.SOURCE=='3'" class="text-semi">清单排查</text>
                    </view>
                </view>
                <view class="de-item" v-if="pd.SOURCE==2">
                    <view class="de-sub-title">
                        <text class="text-grey">风险点(单元)</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.RISK_UNIT}}</text>
                    </view>
                </view>
                <view class="de-item" v-if="pd.SOURCE==2">
                    <view class="de-sub-title">
                        <text class="text-grey">辨识部位</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.IDENTIFICATION}}</text>
                    </view>
                </view>
                <view class="de-item" v-if="pd.SOURCE==2">
                    <view class="de-sub-title">
                        <text class="text-grey">存在风险</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.RISK_DESCR}}</text>
                    </view>
                </view>
                <view class="de-item">
                    <view style="width: 200px" class="de-sub-title">
                        <text class="text-grey" >隐患上报位置(经纬度)</text>
                    </view>
                    <view class="uni-flex-item text-right" v-if="pd.LONGITUDE">
                        <text class="text-semi">
                            {{ pd.LONGITUDE && pd.LONGITUDE.length>6?pd.LONGITUDE.substr(0,6):pd.LONGITUDE}},{{pd.LATITUDE && pd.LATITUDE.length>6?pd.LATITUDE.substr(0,6):pd.LATITUDE}}
                        </text>
                    </view>
                </view>
                <view class="de-item" v-if="pd.SOURCE==2">
                    <view class="de-sub-title">
                        <text class="text-grey">风险分级</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.LEVEL}}</text>
                    </view>
                </view>
                <view class="de-item" v-if="pd.SOURCE==2">
                    <view class="de-sub-title">
                        <text class="text-grey">检查内容</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.CHECK_CONTENT}}</text>
                    </view>
                </view>
                <!-- 				<view class="de-item-sp">
                                    <view class="de-sub-title">
                                        <text class="text-grey">隐患描述</text>
                                    </view>
                                    <view class="de-sub-content">
                                        <text class="text-semi">{{pd.HIDDENDESCR}}</text>
                                    </view>
                                </view> -->
                <view class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患部位</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.hregionName}}</text>
                    </view>
                </view>
                <view class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患类型</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.HIDDENTYPENAME}}</text>
                    </view>
                </view>
                <!--<view class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患类型2</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.HIDDENTYPENAME2}}</text>
                    </view>
                </view>-->
                <view class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">整改类型</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text v-if="pd.RECTIFICATIONTYPE=='1'" class="text-semi">立即整改</text>
                        <text v-else-if="pd.RECTIFICATIONTYPE=='2'" class="text-semi">限期整改</text>
                    </view>
                </view>
                <view v-if="pd.RECTIFICATIONTYPE=='2'" class="de-item">
                    <view class="de-sub-title">
                        <text class="text-grey">整改期限</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.RECTIFICATIONDEADLINE}}</text>
                    </view>
                </view>
                <view class="de-item-sp">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患照片</text>
                    </view>
                    <view class="de-sub-content">
                        <scroll-view scroll-x class="bg-white nav" scroll-with-animation>
                            <view class="cu-item" v-for="(item,index) in files" v-bind:key="index">
                                <view class="imgs">
                                    <image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage" mode=""></image>
                                </view>
                            </view>
                        </scroll-view>
                    </view>
                </view>
                <view class="de-item-sp" v-if="hiddenVideo.length>0">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患视频</text>
                    </view>
                    <view class="de-sub-content" style="background-color: #000;width: 120upx;">
                        <image src="/static/icon-apps/video.png" mode="aspectFill" @click="playVideo"
                               :data-src="baseImgPath + hiddenVideo[0].FILEPATH" style="width: 120upx;height: 120upx;"></image>
                    </view>
                </view>
            </view>
            <view class="cu-form-group margin-top">
                <view class="title text-hui">是否正常整改</view>
                <radio-group class="selected">
                    <view class="group mr20">
                        <radio class='radio'  value="1" :checked="IS_NORMAL=='1'" @click="radioNormal('1')"></radio>
                        <text>是</text>
                    </view>
                    <view class="group">
                        <radio class='radio'  value="0" :checked="IS_NORMAL=='2'" @click="radioNormal('2')"></radio>
                        <text>否</text>
                    </view>
                </radio-group>
            </view>
            <view class="cu-form-textarea margin-top" v-if="IS_NORMAL=='2'">
                <view class="cu-form-title text-grey">无法整改原因</view>
                <textarea maxlength="-1" v-model="pd.disposalPlan" placeholder="请输入无法整改原因"></textarea>
            </view>
            <!--            <view class="cu-form-group margin-top" v-if="IS_NORMAL=='2'">-->
            <!--                <view class="title">整改部门</view>-->
            <!--				<view class="picker-tree-box">-->
            <!--					<view class="picker-tree" @tap="showZgTree">{{pd.RECTIFICATIONDEPTNAME?pd.RECTIFICATIONDEPTNAME:'请选择'}}</view>-->
            <!--				</view>-->
            <!--                <tki-tree ref="tkiTree"-->
            <!--                          :selectParent=true-->
            <!--                          :range="treeNode"-->
            <!--                          rangeKey="name"-->
            <!--                          @confirm="zgtreeConfirm"></tki-tree>-->
            <!--            </view>-->
            <!--            <view class="cu-form-group margin-top" v-if="IS_NORMAL=='2'">-->
            <!--                <view class="title">整改责任人</view>-->
            <!--                <picker @change="PickerZgr" :value="uindex" :range="rectificationUserList" range-key="NAME">-->
            <!--                    <view class="picker">-->
            <!--                        {{pd.RECTIFICATIONORNAME?pd.RECTIFICATIONORNAME:'请选择'}}-->
            <!--                    </view>-->
            <!--                </picker>-->
            <!--            </view>-->

            <view class="de-card-list de-list" v-if="IS_NORMAL=='1'">
                <view class="de-title">
                    <text class="text-semi">隐患整改</text>
                </view>
                <view class="cu-form-textarea" style="border: none;">
                    <view class="cu-form-title text-grey">隐患整改</view>
                    <textarea maxlength="-1" @input="textareaAInput" placeholder="请对隐患整改详细描述(必填项)"></textarea>
                </view>
                <view class="cu-form-group bb">
                    <view class="title">整改日期</view>
                    <picker mode="date" :value="RECTIFICATIONTIME" start="2015-09-01" :end="date" @change="changeDate">
                        <view class="picker">
                            {{RECTIFICATIONTIME==''?'请选择':RECTIFICATIONTIME}}
                        </view>
                    </picker>
                </view>

                <view class="cu-form-textarea">
                    <view class="cu-form-title">投入资金(元):</view>
                    <textarea v-model="INVEST_FUNDS" placeholder="请填写投入资金" type="number"></textarea>
                </view>
                <view class="cu-bar bg-white">
                    <view class="action">
                        整改后照片
                    </view>
                    <view class="action">
                        {{imgList.length}}/4
                    </view>
                </view>
                <view class="cu-form-group">
                    <view class="grid col-4 grid-square flex-sub">
                        <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
                            <image :src="imgList[index]" mode="aspectFill"></image>
                            <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
                                <text class='cuIcon-close'></text>
                            </view>
                        </view>
                        <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
                            <text class='cuIcon-cameraadd'></text>
                        </view>
                    </view>
                </view>
                <view class="add_pard_box">
                    <view class="add_pard_btns">
                        <view class="add_pard_b">
                            <button class="cu-btn round bg-blue" @click="addOther">添加</button>
                        </view>
                    </view>
                    <view class="add_pard_item" v-for="(item,index) of other">
                        <view class="add_pard_del" v-if="index>0" @click="removeOther(index)">
                            <text class="cuIcon-roundclosefill text-red f40"></text>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">验收部门</view>
                            <view class="picker-tree-box">
                                <view class="picker-tree" @tap="showYsTree(index)">{{other[index].DEPARTMENT_NAME?other[index].DEPARTMENT_NAME:'请选择'}}</view>
                            </view>
                            <tki-tree :ref="'tkiTree'+index"
                                      :selectParent=true
                                      :range="treeNode"
                                      rangeKey="name"
                                      @confirm="ystreeConfirm($event,index)"></tki-tree>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">验收人</view>
                            <picker @change="PickerYsr($event,index)" :value="other[index].index" @click="haveUser(otherUserList[index])" :disabled="otherUserList[index] ==null || otherUserList[index].length==0" :range="otherUserList[index]" range-key="NAME">
                                <view class="picker">
                                    {{other[index].USER_NAME?other[index].USER_NAME:'请选择'}}
                                </view>
                            </picker>
                        </view>
                    </view>
                </view>

                <view class="cu-form-group">
                    <view class="title text-hui">是否有整改方案</view>
                    <radio-group class="selected">
                        <view class="group mr20">
                            <radio class='radio'  value="1" :checked="HAVESCHEME==='1'" @click="radio('1')"></radio>
                            <text>是</text>
                        </view>
                        <view class="group">
                            <radio class='radio'  value="0" :checked="HAVESCHEME==='0'" @click="radio('0')"></radio>
                            <text>否</text>
                        </view>
                    </radio-group>
                </view>
                <view class="de-item" v-if="HAVESCHEME=='1'">
                    <view class="de-sub-title">
                        <text class="text-grey">排查日期</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.CREATTIME}}</text>
                    </view>
                </view>
                <view class="de-item" v-if="HAVESCHEME=='1'">
                    <view class="de-sub-title">
                        <text class="text-grey">隐患清单</text>
                    </view>
                    <view class="uni-flex-item text-right">
                        <text class="text-semi">{{pd.LIST_NAME}}</text>
                    </view>
                </view>

                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">治理标准</view>
                    <textarea maxlength="-1" v-model="pd.GOVERNSTANDARDS" placeholder="请输入治理标准"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">治理方法</view>
                    <textarea maxlength="-1" v-model="pd.GOVERNMETHOD" placeholder="请输入治理方法"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">经费落实</view>
                    <textarea maxlength="-1" v-model="pd.EXPENDITURE" placeholder="请输入经费落实"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">负责人员</view>
                    <textarea maxlength="-1" v-model="pd.PRINCIPAL" placeholder="请输入负责人员"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">工时安排</view>
                    <textarea maxlength="-1" v-model="pd.PROGRAMMING" placeholder="请输入工时安排"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">时限要求</view>
                    <textarea maxlength="-1" v-model="pd.TIMELIMITFOR" placeholder="请输入时限要求"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">工作要求</view>
                    <textarea maxlength="-1" v-model="pd.JOBREQUIREMENT" placeholder="请输入工作要求"></textarea>
                </view>
                <view class="cu-form-textarea" v-if="HAVESCHEME=='1'">
                    <view class="cu-form-title text-grey">其他事项</view>
                    <textarea maxlength="-1" v-model="pd.OTHERBUSINESS" placeholder="请输入其他事项"></textarea>
                </view>
                <view class="cu-bar bg-white" v-if="HAVESCHEME=='1'">
                    <view class="action">
                        方案照片
                    </view>
                    <view class="action">
                        {{imgList_fa.length}}/4
                    </view>
                </view>
                <view class="cu-form-group" v-if="HAVESCHEME=='1'">
                    <view class="grid col-4 grid-square flex-sub">
                        <view class="bg-img" v-for="(item,index) in imgList_fa" :key="index" @tap="ViewImage_fa" :data-url="imgList_fa[index]">
                            <image :src="imgList_fa[index]" mode="aspectFill"></image>
                            <view class="cu-tag bg-red" @tap.stop="DelImg_fa" :data-index="index">
                                <text class='cuIcon-close'></text>
                            </view>
                        </view>
                        <view class="solids" @tap="ChooseImage_fa" v-if="imgList_fa.length<4">
                            <text class='cuIcon-cameraadd'></text>
                        </view>
                    </view>
                </view>
                <!--				<view class="cu-form-textarea">-->
                <!--					<l-file ref="lFile" @up-success="onSuccess"></l-file>-->
                <!--					<view class="cu-form-title text-grey">隐患描述1</view>-->
                <!--					<button @tap="onUpload">上传</button>-->
                <!--				</view>-->
            </view>

            <view class="padding flex flex-direction bf">
                <button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goSubmit)">提 交</button>
            </view>
            <view class="cu-tabbar-height"></view>
        </scroll-view>
        <view :class="['cu-modal',{'show':modalShow}]" v-if="modalShow">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">播放视频</view>
                    <view class="action" @tap="modalShow = false">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <video :src="videoSrc" :autoplay="true"></video>
                <view class="cu-bar bg-white justify-end">
                    <view class="action">
                        <button class="cu-btn line-green text-green" @click="modalShow = false">关闭</button>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import {
        basePath,corpinfoId,loginSession,loginUser,baseImgPath
    } from '@/common/tool.js';
    import lFile from '@/components/l-file/l-file.vue'
    import tkiTree from "@/components/select-tree/select-tree.vue"
    export default {
        components: {
            tkiTree,lFile
        },
        data() {
            return {
                noClick: true,
                date: '',
                RECTIFICATIONTIME: '',
                imgList: [],
                imgList_fa: [],
                id: '',
                pd: [],
                files: [],
                RECTIFYDESCR: '',
                INVEST_FUNDS: '',
                basePath:basePath,
                baseImgPath:baseImgPath,
                HAVESCHEME:'0',
                HIDDENSCHEME_ID:'',
                treeNode:[],//部门下拉数据
                uindex: -1,
                IS_NORMAL:1,
                rectificationUserList:[],
                other:[{"DEPARTMENT_ID":'',"USER_ID":'',"DEPARTMENT_NAME":'',"USER_NAME":'',index:-1}],//其他验收人员
                otherUserList:[],
                modalShow: false,
                hiddenVideo:[],
                videoSrc: ''
            }
        },
        onLoad(e) {
            this.id = e.id;
            // let now = new Date();
            // this.date = formatDate(now, 'yyyy-MM-dd');

            this.getData();
            this.getDept();
            loginSession();
        },
        // filters: {
        // 	formatDate(time) {
        // 		time = time * 1
        // 		let date = new Date(time)
        // 		return formatDate(date, 'yyyy-MM-dd hh:mm')
        // 	}
        // },
        methods: {
            getData() {
                var _this = this;
                uni.showLoading({
                    title: '请稍候'
                })
                uni.request({
                    url: basePath + '/app/hidden/goEdit',
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        HIDDEN_ID: _this.id,
                    },
                    success: (res) => {
                        if ("success" == res.data.result) {
                            uni.hideLoading();
                            _this.pd = res.data.pd; //参数map
                            _this.files = res.data.hImgs;
                            _this.hiddenVideo = res.data.hiddenVideo
                        } else if ("exception" == data.result) {
                            uni.showToast({
                                title: '错误',
                                duration: 2000
                            });
                        }
                    }
                });
            },
            //图片上传
            ChooseImage() {
                var _this = this;
                uni.chooseImage({
                    count: 4, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
                    sourceType: ['camera', 'album'], //从相册选择
                    success: (res) => {
                        if (this.imgList.length != 0) {
                            this.imgList = this.imgList.concat(res.tempFilePaths)
                        } else {
                            this.imgList = res.tempFilePaths
                        }
                    }
                });
            },
            ViewImage(e) {
                uni.previewImage({
                    urls: this.imgList,
                    current: e.currentTarget.dataset.url
                });
            },
            DelImg(e) {
                uni.showModal({
                    title: '温馨提示',
                    content: '确定要删除这张图片吗?',
                    cancelColor: "#000000",
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            this.imgList.splice(e.currentTarget.dataset.index, 1)
                        }
                    }
                })
            },
            //图片上传
            ChooseImage_fa() {
                var _this = this;
                uni.chooseImage({
                    count: 4, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
                    sourceType: ['camera', 'album'], //从相册选择
                    success: (res) => {
                        if (this.imgList_fa.length != 0) {
                            this.imgList_fa = this.imgList_fa.concat(res.tempFilePaths)
                        } else {
                            this.imgList_fa = res.tempFilePaths
                        }
                    }
                });
            },
            ViewImage_fa(e) {
                uni.previewImage({
                    urls: this.imgList_fa,
                    current: e.currentTarget.dataset.url
                });
            },
            DelImg_fa(e) {
                uni.showModal({
                    title: '温馨提示',
                    content: '确定要删除这张图片吗?',
                    cancelColor: "#000000",
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            this.imgList_fa.splice(e.currentTarget.dataset.index, 1)
                        }
                    }
                })
            },
            textareaAInput(e) {
                this.RECTIFYDESCR = e.detail.value
            },
            goSubmit() {
                var _this = this;
                if(_this.IS_NORMAL==1) {
                    if (!_this.RECTIFYDESCR) {
                        uni.showToast({
                            icon: 'none',
                            title: '请填整改描述',
                            duration: 1500
                        });
                        return;
                    }
                    if (!_this.RECTIFICATIONTIME) {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择整改时间',
                            duration: 1500
                        });
                        return;
                    }
                    if (_this.imgList.length <= 0) {
                        uni.showToast({
                            icon: 'none',
                            title: '请上传整改后照片',
                            duration: 1500
                        });
                        return;
                    }

                    if (this.HAVESCHEME == 1) {
                        if (this.pd.GOVERNSTANDARDS == '' || this.pd.GOVERNSTANDARDS == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入治理标准要求',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.GOVERNMETHOD == '' || this.pd.GOVERNMETHOD == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入治理方法',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.EXPENDITURE == '' || this.pd.EXPENDITURE == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入经费和物资的落实',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.PRINCIPAL == '' || this.pd.PRINCIPAL == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入负责治理人员',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.PROGRAMMING == '' || this.pd.PROGRAMMING == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入工时安排',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.TIMELIMITFOR == '' || this.pd.TIMELIMITFOR == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入时限要求',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.JOBREQUIREMENT == '' || this.pd.JOBREQUIREMENT == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入工作要求',
                                duration: 1500
                            });
                            return;
                        }
                        if (this.pd.OTHERBUSINESS == '' || this.pd.OTHERBUSINESS == undefined) {
                            uni.showToast({
                                icon: 'none',
                                title: '请输入其他事项',
                                duration: 1500
                            });
                            return;
                        }
                        if (_this.imgList_fa.length <= 0) {
                            uni.showToast({
                                icon: 'none',
                                title: '请上传方案照片',
                                duration: 1500
                            });
                            return;
                        }
                    }
                    if (!_this.other[0].USER_ID) {
                        uni.showToast({
                            icon: 'none',
                            title: '请添加验收人',
                            duration: 1500
                        });
                        return;
                    }
                    new Promise((resolve, reject) => {
                        _this.submit().then(() => {
                            resolve();
                        })
                    }).then(() => {
                        var fileList = [];
                        for (var i = 0; i < _this.imgList.length; i++) {
                            var file = {};
                            file.type = 4;
                            file.filePath = _this.imgList[i];
                            file.FOREIGN_KEY = _this.id;
                            fileList.push(file);
                        }
                        if (_this.HAVESCHEME == 1) {
                            for (var i = 0; i < _this.imgList_fa.length; i++) {
                                var file = {};
                                file.type = 8;
                                file.filePath = _this.imgList_fa[i];
                                file.FOREIGN_KEY = _this.HIDDENSCHEME_ID;
                                fileList.push(file);
                            }
                        }
                        var m = 0;
                        _this.uploadImg(fileList, m).then(() => {
                            resolve();
                        })
                    }).then(() => {
                        uni.showToast({
                            icon: 'none',
                            title: '提交成功',
                            duration: 1500
                        });
                        setTimeout(function () {
                            var pages = getCurrentPages();	// 获取当前页面栈
                            var prePage = pages[pages.length - 2];	// 上一个页面
                            prePage.$vm.initflag = true;    // A 页面 init方法 为true
                            uni.navigateBack({});
                            uni.hideLoading();
                        }, 1500);
                    })
                }else if (_this.IS_NORMAL==2) {
                    if (!_this.pd.disposalPlan) {
                        uni.showToast({
                            icon: 'none',
                            title: '请输入无法整改原因',
                            duration: 1500
                        });
                        return;
                    }

                    uni.request({
                        url: basePath + "//app/hiddenexamine/special", //提交接口
                        method: 'POST',
                        dataType: 'json',
                        header:{
                            'Content-type':'application/x-www-form-urlencoded'
                        },
                        data: {
                            disposalPlan:_this.pd.disposalPlan,
                            HIDDEN_ID: _this.id,
                        },
                        success: (res) => {
                            uni.hideLoading();
                            if ("success" == res.data.result) {
                                uni.showToast({
                                    icon: 'none',
                                    title: '提交成功',
                                    duration: 1500
                                });
                                setTimeout(function(){
                                    var pages = getCurrentPages();	// 获取当前页面栈
                                    var prePage = pages[pages.length - 2];	// 上一个页面
                                    prePage.$vm.initflag = true;    // A 页面 init方法 为true
                                    uni.navigateBack({});
                                    uni.hideLoading();
                                },1500);
                            }else{
                                uni.showToast({
                                    title: '错误',
                                    duration: 2000
                                });
                            }
                        }
                    });
                }
            },
            uploadImg(tempFilePaths,i) {
                return new Promise((resolve, reject) => {
                    var _this = this;
                    if(tempFilePaths.length==0){
                        resolve();
                    }
                    uni.showLoading({
                        title: '上传中'
                    })
                    uni.uploadFile({
                        url: basePath + '/app/imgfiles/add',
                        filePath: tempFilePaths[i].filePath,
                        name: 'FFILE',

                        formData: {
                            'FOREIGN_KEY': tempFilePaths[i].FOREIGN_KEY,
                            'TYPE': tempFilePaths[i].type
                        },
                        success: (res) => {
                            i++;
                            if (tempFilePaths.length > i) {
                                _this.uploadImg(tempFilePaths, i);
                            } else {
                                uni.hideLoading();
                                resolve();
                            }
                        },
                        fail: (err) => {
                            uni.hideLoading();
                            uni.showModal({
                                content: err.errMsg,
                                showCancel: false
                            });
                        }
                    })
                })
            },

            uploadImg_fa(tempFilePaths,i) {
                var _this = this;
                uni.showLoading({
                    title: '上传中'
                })
                uni.uploadFile({
                    url: basePath + '/app/imgfiles/add',
                    filePath: tempFilePaths[i],
                    name: 'FFILE',

                    formData: {
                        'FOREIGN_KEY': _this.HIDDENSCHEME_ID,
                        'TYPE': '8'
                    },
                    success: (res) => {
                        i++;
                        if (tempFilePaths.length > i) {
                            _this.uploadImg(tempFilePaths, i);
                        } else {
                            if(_this.HAVESCHEME == '1'){
                                _this.onUpload()
                            } else {
                                uni.showToast({
                                    icon: 'none',
                                    title: '提交成功',
                                    duration: 1500
                                });
                                setTimeout(function(){
                                    var pages = getCurrentPages();	// 获取当前页面栈
                                    var prePage = pages[pages.length - 2];	// 上一个页面
                                    prePage.$vm.initflag = true;    // A 页面 init方法 为true
                                    uni.navigateBack({});
                                    uni.hideLoading();
                                },1500);
                            }


                        }
                    },
                    fail: (err) => {
                        uni.hideLoading();
                        console.log('uploadImage fail', err);
                        uni.showModal({
                            content: err.errMsg,
                            showCancel: false
                        });
                    }
                })
            },
            submit() {
                return new Promise((resolve, reject) => {
                    var _this = this;
                    uni.request({
                        url: basePath + "/app/hidden/rectify", //提交接口
                        method: 'POST',
                        dataType: 'json',
                        header:{
                            'Content-type':'application/x-www-form-urlencoded'
                        },
                        data: {
                            RECTIFICATIONTIME: _this.RECTIFICATIONTIME,
                            RECTIFYDESCR: _this.RECTIFYDESCR,
                            HAVESCHEME:_this.HAVESCHEME,
                            // RECTIFICATIONDEPT:_this.pd.RECTIFICATIONDEPT,
                            // RECTIFICATIONOR:_this.pd.RECTIFICATIONOR,
                            USER_ID:loginUser.USER_ID,
                            CORPINFO_ID:corpinfoId,
                            HIDDEN_ID: _this.id,
                            INVEST_FUNDS: _this.INVEST_FUNDS,
                            SCREENINGDATE:_this.pd.CREATTIME?_this.pd.CREATTIME:'',
                            LISTNAME:_this.pd.LIST_NAME?_this.pd.LIST_NAME:'',
                            GOVERNSTANDARDS:_this.pd.GOVERNSTANDARDS?_this.pd.GOVERNSTANDARDS:'',
                            GOVERNMETHOD:_this.pd.GOVERNMETHOD?_this.pd.GOVERNMETHOD:'',
                            EXPENDITURE:_this.pd.EXPENDITURE?_this.pd.EXPENDITURE:'',
                            PRINCIPAL:_this.pd.PRINCIPAL?_this.pd.PRINCIPAL:'',
                            PROGRAMMING:_this.pd.PROGRAMMING?_this.pd.PROGRAMMING:'',
                            TIMELIMITFOR:_this.pd.TIMELIMITFOR?_this.pd.TIMELIMITFOR:'',
                            JOBREQUIREMENT:_this.pd.JOBREQUIREMENT?_this.pd.JOBREQUIREMENT:'',
                            OTHERBUSINESS:_this.pd.OTHERBUSINESS?_this.pd.OTHERBUSINESS:'',
                            OTHER:JSON.stringify(_this.other)
                        },
                        success: (res) => {
                            uni.hideLoading();
                            if ("success" == res.data.result) {
                                _this.HIDDENSCHEME_ID = res.data.HIDDENSCHEME_ID
                                resolve();
                            }else{
                                uni.showToast({
                                    title: '错误',
                                    duration: 2000
                                });
                                reject();
                            }

                        }
                    });
                })
            },
            haveUser(e){
                if(e == null || e.length == 0){
                    uni.showToast({
                        icon:"none",
                        title: '请先选择有人员的部门',
                        duration: 2000
                    });
                }
                console.info(1)
            },
            onUpload() {
                return new Promise((resolve, reject) => {
                    this.$refs.lFile.upload({
                        // #ifdef APP-PLUS
                        // nvue页面使用时请查阅nvue获取当前webview的api,当前示例为vue窗口
                        currentWebview: this.$mp.page.$getAppWebview(),
                        // #endif
                        //非真实地址,记得更换,调试时ios有跨域,需要后端开启跨域并且接口地址不要使用http://localhost/
                        url: basePath + "/app/hidden/rectify1?HIDDENSCHEME_ID="+this.HIDDENSCHEME_ID,
                        //默认file,上传文件的key
                        name: 'file',
                        // header:{
                        // 	'Content-type':'application/x-www-form-urlencoded'
                        // },
                        //...其他参数
                    });
                    resolve();
                })
            },
            onSuccess(res) {
                return new Promise((resolve, reject) => {
                    resolve();
                })


            },
            getDept() {
                var _this = this;
                uni.request({
                    url: basePath + '/app/sys/listTree',//部门下拉接口
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type':'application/x-www-form-urlencoded'
                    },
                    data: {
                        CORPINFO_ID : corpinfoId,
                    },
                    success: (res) => {
                        if("success" == res.data.result){
                            _this.treeNode=eval(res.data.zTreeNodes);
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                });
            },
            // 确定回调事件
            zgtreeConfirm(e) {
                this.pd.RECTIFICATIONDEPT=e[0].id;
                this.pd.RECTIFICATIONDEPTNAME=e[0].name;
                this.uindex=-1;
                this.pd.RECTIFICATIONOR='';
                this.pd.RECTIFICATIONORNAME='';
                this.$forceUpdate();//强制刷新
                this.getUserList(this.pd.RECTIFICATIONDEPT);
            },
            // 显示树形选择器
            showZgTree() {
                this.$refs.tkiTree._show();
            },

            // 确定回调事件
            ystreeConfirm(e,index) {
                this.other[index].DEPARTMENT_ID=e[0].id;
                this.other[index].DEPARTMENT_NAME=e[0].name;
                this.other[index].USER_ID='';
                this.other[index].USER_NAME='';
                this.other[index].index=-1;
                this.getUserList(this.other[index].DEPARTMENT_ID,index);
                this.$forceUpdate();//强制刷新
            },
            // 显示树形选择器
            showYsTree(index) {
                let ref = 'tkiTree'+index;
                this.$refs['tkiTree'+index][0]._show();
            },
            //根据主键ID获取数据
            addOther: function(){
                var _this=this;
                let o = {"DEPARTMENT_ID":'',"USER_ID":'',"DEPARTMENT_NAME":'',"USER_NAME":'',index:-1};
                _this.other.push(o);
                let index=_this.other.length-1;
                _this.otherUserList[index]=[];
            },
            removeOther: function(index){
                this.other.splice(index,1);
                this.otherUserList.splice(index,1);
            },
            //获取人员列表
            getUserList(DEPARTMENT_ID,i){
                //发送 post 请求
                var _this = this;
                uni.request({
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type':'application/x-www-form-urlencoded'
                    },
                    url: basePath+'/app/sys/listUser',
                    data: {
                        DEPARTMENT_ID:DEPARTMENT_ID, NOMAIN:'1',
                        LOGINUSERID:loginUser.USER_ID,
                        NOSELF:'1',
                        tm:new Date().getTime()
                    },
                    success: function(res){
                        if("success" == res.data.result){
                            if(i>-1){
                                _this.otherUserList[i]=[];
                                _this.otherUserList[i]=res.data.userList;
                                _this.$forceUpdate();//强制刷新
                            }else{
                                _this.rectificationUserList=res.data.userList;
                            }
                        }else{
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                })
            },
            PickerZgr(e) {
                this.uindex = e.detail.value;
                this.pd.RECTIFICATIONOR=this.rectificationUserList[this.uindex].USER_ID;
                this.pd.RECTIFICATIONORNAME=this.rectificationUserList[this.uindex].NAME;
                this.$forceUpdate();//强制刷新
            },
            PickerYsr(e,index) {
                this.other[index].index = e.detail.value;
                this.other[index].USER_ID=this.otherUserList[index][e.detail.value]?this.otherUserList[index][e.detail.value].USER_ID:'';
                this.other[index].USER_NAME=this.otherUserList[index][e.detail.value]?this.otherUserList[index][e.detail.value].NAME:'';
                this.$forceUpdate();//强制刷新
            },
            radio(e){
                this.HAVESCHEME = e
            },
            radioNormal(e){
                this.IS_NORMAL = e
            },
            changeDate(e) {
                this.RECTIFICATIONTIME = e.detail.value
            },
            ViewShowImage(e) {
                let files = [];
                for (var i = 0; i < this.files.length; i++) {
                    files.push(baseImgPath+this.files[i].FILEPATH)
                }
                uni.previewImage({
                    urls: files,
                    current: e.currentTarget.dataset.index
                });
            },
            playVideo(e) {
                this.videoSrc = e.currentTarget.dataset.src
                this.modalShow = true
            }
        }
    }
</script>

<style>
    .bb {
        border-top: 1upx solid #f1f1f1;
        border-bottom: 1upx solid #f1f1f1;
    }

    .cu-bar .action:first-child {
        font-size: 26upx
    }

    .cu-form-title {
        padding: 20upx 0;
    }

    .cu-form-textarea {
        background-color: #ffffff;
        padding: 1upx 30upx 20upx;
        min-height: 100upx;
        border-bottom: 1px solid #f1f1f1;
    }

    .cu-form-textarea textarea {
        height: 4.6em;
        width: 100%;
        line-height: 1.2em;
        flex: 1;
        font-size: 28upx;
        padding: 0;
    }

    .cu-form-group {
        padding: 0upx 25upx;
    }

    .cu-form-group picker .picker {
        line-height: 76upx;
    }

    .cu-form-group .title {
        font-size: 28upx;
        /* line-height: 76upx; */
        color: #888;
    }

    .cu-form-group uni-picker::after {
        top: -11upx;
    }

    .selected {
        display: flex;
        align-items: center;
    }

    .selected .radio {
        transform: scale(0.5);
        margin-right: 10upx;
    }

    .bf .cu-btn {
        border-radius: 0;
        width: 100%;
        height: 84upx;
        font-weight: bold;
    }

    .group {
        display: flex;
        align-items: center;
    }
</style>