<template>
    <fullscreen :fullscreen.sync="fullscreen" class="container">
        <div class="container-box">
            <toolList @iconCli='iconCli' :tooltit='tooltit'></toolList>
            <div class="search">
                <mySearch :searchList="searchList" @searchInfo="searchInfo"></mySearch>
                <el-button type="primary" @click="dialogCheck(3)" size="medium">添加</el-button>
            </div>
            <div class="tabbox">
                <el-table height="calc(100% - 40px)" class="com-table" ref="multipleTable" :data="tableData"
                    tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">
                    <el-table-column prop="demandNo" label="需求收集编号">
                    </el-table-column>
                    <el-table-column prop="secTime" label="科室征集截止时间">
                    </el-table-column>
                    <el-table-column prop="centerTime" label="中心征集截止时间">
                    </el-table-column>
                    <el-table-column prop="deptTime" label="部门征集截止时间">
                    </el-table-column>
                    <el-table-column label="操作" width="180px" align="center">
                        <template slot-scope="scope">
                            <el-button size="mini" type="primary" @click="dialogCheck(0,scope.row)">查看</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(1,scope.row)"
                                v-if="scope.row.sts == 0||scope.row.approvalSts == 1">填写</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(2,scope.row)"
                                v-if="scope.row.sts == 0&&scope.row.opNo == userInfo.loginNo">修改</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(4,scope.row)"
                                v-if="scope.row.sts == 2&&scope.row.approvalSts == 1">审批</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(4,scope.row)"
                                v-if="scope.row.sts == 3&&scope.row.approvalSts == 1">审批</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(4,scope.row)"
                                v-if="scope.row.sts == 4&&scope.row.approvalSts == 1">审批</el-button>
                            <el-button size="mini" type="primary" @click="dialogCheck(5,scope.row)"
                                v-if="scope.row.sts == 1">汇总数据</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next" background
                    :total="total">
                </el-pagination>
            </div>
        </div>

        <el-dialog :title="titname" :visible.sync="dialogStatus" width="50%" :destroy-on-close="true"
            :modal-append-to-body="false" :close-on-click-modal="false" :before-close="closedia">
            <div v-loading="loadinged">
                <el-form :model="infolist" ref="infolist" :rules="rules">
                    <div>
                        <el-form-item prop="demandNo" class="info-line online">
                            <span>需求收集编号</span>
                            <el-input v-model="infolist.demandNo" placeholder="需求收集编号" :disabled="disableStatus">
                            </el-input>
                        </el-form-item>
                        <el-form-item prop="secTime" class="info-line online">
                            <span>科室征集截止时间</span>
                            <el-date-picker v-model="infolist.secTime" type="datetime" placeholder="科室征集截止时间"
                                :disabled="disableStatus">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item prop="centerTime" class="info-line online">
                            <span>中心征集截止时间</span>
                            <el-date-picker v-model="infolist.centerTime" type="datetime" placeholder="中心征集截止时间"
                                :disabled="disableStatus">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item prop="deptTime" class="info-line online">
                            <span>部门征集截止时间</span>
                            <el-date-picker v-model="infolist.deptTime" type="datetime" placeholder="部门征集截止时间"
                                :disabled="disableStatus">
                            </el-date-picker>
                        </el-form-item>
                    </div>
                </el-form>
                <div slot="footer" style="padding-bottom: 20px;text-align: right;">
                    <el-button type="primary" @click="dialogCliadd(2)">确 定</el-button>
                    <el-button @click="dialogCliadd(1)">取 消</el-button>
                </div>
            </div>
        </el-dialog>


        <el-dialog :title="titname" :visible.sync="dialogStatusadd" width="50%" :destroy-on-close="true"
            :modal-append-to-body="false" :close-on-click-modal="false" :before-close="closedia" :fullscreen="true">
            <div v-loading="loadinged">
                <el-form :model="infolist" ref="infolist" :rules="rules"
                    style="height: calc(100vh - 180px);overflow-y: scroll;">
                    <div>
                        <span
                            style="display: block;margin-bottom: 10px;">说明：须在{{timeover}}科室收集截至时间前提交需求，过期将无法提交需求，无需求可不填写</span>
                        <span
                            style="display: block;">注：需求通过方式中除市场决策会和请示汇报通过的需求不用上会外，以下四类需求不用上会，通过方式归为"需求决策会（免上会）"：1）集团需求；2）接口联调需求；3）短信类需求；4）提数类需求
                        </span>
                        <el-button type="primary" @click="downalldata3" v-if="sts == 0" style="margin-top: 20px;">下载模板</el-button>

                        <div style="margin: 20px 0;padding: 0 20px;">
                            <el-table class="com-table" ref="multipleTable" :data="infodatas" tooltip-effect="dark"
                                size="small" border style="width: 100%">
                                <el-table-column prop="demandName" label="需求名称" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.demandName" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="level1No" label="一级编码" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.level1No" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="level2No" label="二级编码" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.level2No" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="level3No" label="三级编码" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.level3No" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="level4No" label="四级编码" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.level4No" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="groupDemand" label="集团需求" width="200px">
                                    <template slot-scope="scope">
                                        <el-select clearable v-model="scope.row.groupDemand" :disabled="disableStatus">
                                            <el-option v-for="items in optone" :key="items.name" :label="items.name"
                                                :value="items.name">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="keyPoint" label="重点需求" width="200px">
                                    <template slot-scope="scope">
                                        <el-select clearable v-model="scope.row.keyPoint" :disabled="disableStatus">
                                            <el-option v-for="items in optone" :key="items.name" :label="items.name"
                                                :value="items.name">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="deptName" label="提出部门" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.deptName" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="secName" label="提出科室" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.secName" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="commitPerson" label="需求提出人" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.commitPerson" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="deptPerson" label="部门需求审核人" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.deptPerson" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="infoPerson" label="信息技术中心需求对接人" width="200px">
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.infoPerson" :disabled="disableStatus"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="demandType" label="类型" width="200px">
                                    <template slot-scope="scope">
                                        <el-select clearable v-model="scope.row.demandType" :disabled="disableStatus">
                                            <el-option v-for="items in opttwo" :key="items.name" :label="items.name"
                                                :value="items.name">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="logoutTime" label="下线时间" width="200px">
                                    <template slot-scope="scope">
                                        <el-select clearable v-model="scope.row.logoutTime" :disabled="disableStatus">
                                            <el-option v-for="items in optthr" :key="items.name" :label="items.name"
                                                :value="items.name">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="passType" label="需求通过方式" width="200px">
                                    <template slot-scope="scope">
                                        <el-select clearable v-model="scope.row.passType" :disabled="disableStatus">
                                            <el-option v-for="items in optfour" :key="items.name" :label="items.name"
                                                :value="items.name">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>

                                <el-table-column label="操作" width="220px" align="center">
                                    <template slot-scope="scope">
                                        <el-button size="mini" type="primary" @click="choline(1,scope)" v-if="sts == 0">
                                            添加</el-button>
                                        <el-button size="mini" type="danger" @click="choline(2,scope)" v-if="sts == 0">
                                            删除</el-button>
                                        <span @click="choline(3,scope)" v-if="sts == 0">
                                            <myUpload style="display:inline-block;position: relative;left: -10px;"
                                                :fileInfo="fileInfot" :fileList="fileInfot.fileList"
                                                @uploadBack='uploadBack'></myUpload>
                                        </span>
                                        <el-button size="mini" type="danger" @click="shenpi(scope.row)"
                                            v-if="sts == 2&&scope.row.sts != 0">拒绝</el-button>
                                        <el-button size="mini" type="primary" v-if="sts == 2&&scope.row.sts != 0" @click="downfile(scope.row)">下载</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>

                    </div>

                    <el-button type="primary" @click="downalldata" style="margin:0 0 20px 20px;" v-if="stsdown!=1">汇总数据下载
                    </el-button>
                    <el-button type="primary" @click="downalldata2" v-if="sts == 5" style="margin:0 0 20px 20px;">导出
                    </el-button>

                    <div style="margin-bottom: 20px;padding: 0 20px;" v-if="sts == 5">
                        <el-table class="com-table" ref="multipleTable" :data="rovaList" tooltip-effect="dark"
                            size="small" border style="width: 100%">
                            <el-table-column prop="stepName" label="流程环节">
                            </el-table-column>
                            <el-table-column prop="dealName" label="处理人">
                            </el-table-column>
                            <el-table-column prop="dealNo" label="处理人工号">
                            </el-table-column>
                            <el-table-column prop="dealTime" label="处理时间">
                            </el-table-column>
                            <!-- <el-table-column prop="remark" label="备注">
                    		</el-table-column> -->
                        </el-table>
                    </div>
                </el-form>

                <div slot="footer" style="margin-top: 20px;text-align: right;">
                    <el-button type="primary" @click="choleader = true" v-if="sts == 0&&appBtnSts==1">提交审批</el-button>
                    <el-button type="primary" @click="dialogCliadds(2)" v-if="sts == 0">确 定</el-button>
                    <el-button type="primary" @click="choseleader(1)" v-if="sts == 2">副总经理审批</el-button>
                    <el-button type="primary" @click="choseleader(2)" v-if="sts == 2||sts == 3">总经理审批</el-button>
                    <el-button type="primary" @click="choseleader(3)" v-if="sts == 4">审批</el-button>
                    <el-button @click="dialogCliadds(1)">取 消</el-button>
                </div>
            </div>
        </el-dialog>

        <el-dialog title="选择审批人" :visible.sync="choleader" width="50%" :destroy-on-close="true"
            :modal-append-to-body="false" :close-on-click-modal="false">
            <div>

                <el-form :model="infolist" ref="infolist" :rules="rules">
                    <el-form-item prop="visiblec" class="info-line online">
                        <span style="width: 100px;">审批人员</span>
                        <deptTreeOnly class="tree" @treeCheck="treeCheckonly" :defaultList="defaultList"
                            :type="depttype" :closeList="closeList"></deptTreeOnly>
                        <div class="tree treeUser">
                            <p>{{treeListonly.leaderAuditName}}
                                <i v-if="treeListonly.leaderAuditName" @click="deletes()" class="el-icon-error"></i>
                            </p>
                        </div>
                    </el-form-item>
                </el-form>

                <div slot="footer" style="text-align: right;padding-bottom: 20px;">
                    <el-button type="primary" @click="dialogCliadds(3)" v-if="!visionchonly">确 定</el-button>
                    <el-button @click="choleader = false">取 消</el-button>
                </div>
            </div>
        </el-dialog>



        <myMessage :messTit='messTit' @closeMessage="closeMessage" :centerDialogVisible="centerDialogVisible"
            v-if="centerDialogVisible"></myMessage>
    </fullscreen>

</template>
<script>
    import mySearch from "../../../components/search.vue";
    import myMessage from "../../../components/myMessage.vue"
    import toolList from '../../../components/toolList'
    import myUpload from '../../../components/upload'
    import uploadDown from '../../../components/uploadDown.vue'
    import deptTreeOnly from "../../../components/deptTreeOnly.vue"

    export default {
        components: {
            mySearch,
            myMessage,
            toolList,
            myUpload,
            uploadDown,
            deptTreeOnly
        },
        data() {
            const demandNo = (rule, value, callback) => {
                if (!this.infolist.demandNo) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            const secTime = (rule, value, callback) => {
                if (!this.infolist.secTime) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            const centerTime = (rule, value, callback) => {
                if (!this.infolist.centerTime) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            const deptTime = (rule, value, callback) => {
                if (!this.infolist.deptTime) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            return {
                rules: {
                    demandNo: [{
                        required: true,
                        trigger: 'blur',
                        validator: demandNo
                    }],
                    secTime: [{
                        required: true,
                        trigger: 'change',
                        validator: secTime
                    }],
                    centerTime: [{
                        required: true,
                        trigger: 'change',
                        validator: centerTime
                    }],
                    deptTime: [{
                        required: true,
                        trigger: 'change',
                        validator: deptTime
                    }],
                },
                searchList: [{
                    type: 'input',
                    tit: '需求收集编号',
                    value: '',
                    width: '98%'
                }],
                tooltit: '市场开发需求征集',
                fullscreen: false,
                total: 0,
                pageSize: 1,
                tableData: [{}],
                dialogStatus: false,
                disableStatus: false,
                titname: '',
                infolist: {
                    secTime: '',
                    centerTime: '',
                    deptTime: ''
                },
                userInfo: {},
                params: {},
                centerDialogVisible: false,
                messTit: '',
                delid: '',
                loading: false,
                loadinged: false,
                docType: [],
                contentType: [],
                infodata: [{}],
                infodatas: [{}],
                dialogStatusadd: false,
                choid: '',
                optone: [{
                        name: '是'
                    },
                    {
                        name: '否'
                    }
                ],
                opttwo: [{
                        name: '需求开发'
                    },
                    {
                        name: '功能需求'
                    }
                ],
                optthr: [{
                        name: '长期'
                    },
                    {
                        name: '短期'
                    }
                ],
                optfour: [{
                        name: '市场决策会'
                    },
                    {
                        name: '请示汇报'
                    },
                    {
                        name: '需求决策会'
                    },
                    {
                        name: '需求决策会（免上会）'
                    }
                ],
                fileInfot: {
                    type: 'btn',
                    typename: '导入',
                    btntype: 'primary',
                    limit: 1,
                    url: '/market/cmkAttachInfo/upload',
                    fileList: [],
                    size: "mini",
                    typexz: 'ppt',
                    uploadType: 'workDemand'
                },
                choleader: false,
                treeListonly: {},
                defaultList: [],
                closeList: false,
                visionchonly: false,
                depttype: 0,
                sts: 0,
                leader: 0,
                timeover: '',
                rovaList: [],
                appBtnSts:'',
                stsdown:'',
            }
        },
        methods: {
            downfile(v){
                this.$http({
                    url: '/market/compatt/downfile',
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    responseType: "blob",
                    data: {"id": v.attList[0].fileId, "fileName": v.attList[0].fileName},
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: 'application/vnd.ms-excel'
                        });
                        window.navigator.msSaveOrOpenBlob(blob, v.attList[0].fileName);
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = v.attList[0].fileName;
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            downalldata() {
                let param = new FormData();
                param.append("demandId", this.choid);
                param.append("sts", 1);
                this.$http({
                    url: '/market/cWorkDemand/downLoadFile',
                    method: "post",
                    responseType: 'blob',
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: param,
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: response.data.type
                        });
                        window.navigator.msSaveOrOpenBlob(blob, '汇总数据.pptx');
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = '汇总数据.pptx';
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            downalldata2() {
                let param = {
                    demandId: this.choid,
                    sts: 2
                };

                this.$http({
                    url: '/market/cWorkDemand/excelExport',
                    method: "post",
                    responseType: 'blob',
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: param,
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: response.data.type
                        });
                        window.navigator.msSaveOrOpenBlob(blob, '汇总数据.xlsx');
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = '汇总数据.xlsx';
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            downalldata3() {
                this.$http({
                    url: '/market/cWorkDemand/downLoadTemp',
                    method: "post",
                    responseType: 'blob',
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {},
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: response.data.type
                        });
                        window.navigator.msSaveOrOpenBlob(blob, '模板.pptx');
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = '模板.pptx';
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            choseleader(v) {
                this.leader = v;
                if (v == 3) {
                    this.dialogCliadds(3);
                } else {
                    this.choleader = true;
                }
            },
            shenpi(v) {
                let params = {
                    id: v.id,
                    sts: '0',
                    stsDesc: '不通过'
                }
                this.$http({
                    url: "/market/cWorkDemand/approvalDemandDetail",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: params,
                }).then((res) => {
                    this.$http({
                        url: "/market/cWorkDemand/queryDemandDetailList2",
                        method: "post",
                        headers: {
                            "Content-Type": "application/json",
                        },
                        data: {
                            id: this.choid,
                            sts:"2"
                        },
                    }).then((res) => {
                        this.infodatas = res.data;
                    });
                });
            },
            deletes() {
                this.treeListonly = {};
                this.closeList = !this.closeList;
            },
            treeCheckonly(v) {
                this.treeListonly = v;
            },
            uploadBack(v) {
                this.infodatas[this.loadnum].attList = [{
                    id: v.data.body.id,
                    fileCode: v.data.body.fileCode,
                    fileName: v.data.body.fileName,
                    type: v.data.body.type,
                }];
            },
            choline(v, n) {
                if (v == 1) {
                    this.infodatas.push({})
                } else if (v == 2) {
                    if (this.infodatas.length != 1) {
                        this.infodatas.splice(n.$index, 1)
                    }
                } else {
                    this.loadnum = n.$index
                }
            },
            //搜索数据
            searchInfo(v) {
                this.params = {};
                v[0] ? this.params.docName = v[0] : '';
                this.getList(this.params, this.pageSize);
            },
            closedia() {
                this.infolist = {
                    secTime: '',
                    centerTime: '',
                    deptTime: ''
                };
                this.infodata = [{}];
                this.dialogStatus = false;
                this.dialogStatusadd = false;
            },
            //获取列表
            getList(v, n) {
                this.pageSize = n;
                let _this = this;
                this.loading = true;
                this.$http({
                    url: "/market/cWorkDemand/queryPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + n + '","pageSize":"10"}'
                    },
                    data: v,
                }).then((res) => {
                    this.tableData = res.data.data;
                    this.total = res.data.totalRecord;
                    this.loading = false;
                });
            },
            // 分页
            currchange(v) {
                this.pageSize = v;
                this.getList(this.params, this.pageSize);
            },
            setabList(n, p) {
                let params = {
                    children: "",
                    name: n,
                    rountPath: p,
                    target: "_self",
                };
                for (let i = 0; i < this.$store.state.tabList.length; i++) {
                    if (this.$store.state.tabList[i].name === params.name) {
                        this.$store.state.tabList[i] = params;
                    }
                }
                let set = new Set([...this.$store.state.tabList, params]);
                set.add(params);
                this.$store.commit("setDefaultActive", params.rountPath);
                this.$store.commit("setTabList", Array.from(set));
            },
            //申请
            dialogCheck(v, n) {
                console.log(n);
                if(n != undefined){
                    this.appBtnSts=n.appBtnSts;
                }
                this.stsdown=v;
                let url = '/market/cWorkDemand/queryDemandDetailList';
                let params = {}
                if (v != 3) {
                    params = {
                        id: n.id
                    }
                }
                if (v === 1) {
                    this.titname = '查看';
                    this.dialogStatusadd = true;
                    this.disableStatus = false;
                    this.sts = 0;
                } else if (v === 2) {
                    this.titname = '修改';
                    this.dialogStatus = true;
                    this.disableStatus = false;
                    this.infolist = Object.assign({}, n);
                    this.infolist.secTime = this.infolist.secUtcTime;
                    this.infolist.centerTime = this.infolist.centerUtcTime;
                    this.infolist.deptTime = this.infolist.deptUtcTime;
                    return
                } else if (v === 3) {
                    this.titname = '添加';
                    this.dialogStatus = true;
                    this.disableStatus = false;
                    return
                } else if (v === 4) {
                    this.titname = '审批';
                    this.dialogStatusadd = true;
                    this.disableStatus = true;
                    this.sts = n.sts;
                    url = '/market/cWorkDemand/queryDemandDetailList2'
                    params = {
                        id: n.id,
                        sts: n.sts
                    }
                } else if (v === 0) {
                    this.titname = '查看';
                    this.dialogStatusadd = true;
                    this.disableStatus = true;
                    this.sts = 6;
                } else if (v === 5) {
                    this.titname = '汇总';
                    this.dialogStatusadd = true;
                    this.disableStatus = true;
                    this.sts = 5;
                    url = '/market/cWorkDemand/queryDemandDetailList2'
                    params = {
                        id: n.id,
                        sts: n.sts
                    }
                    this.$http({
                        url: '/market/cWorkDemandTrace/queryList',
                        method: "post",
                        headers: {
                            "Content-Type": "application/json",
                        },
                        data: {
                            demandId: n.id
                        },
                    }).then((res) => {
                        this.rovaList = res.data
                    });
                }
                this.timeover = n.secTime;
                this.$http({
                    url: '/market/cWorkDemand/queryDemandDetailList2',
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: params,
                }).then((res) => {
                    this.choid = n.id;
                    this.infodatas = res.data;
                    if (this.infodatas.length == 0) {
                        this.infodatas.push({})
                    }
                });
            },
            //添加
            dialogCliadd(v) {
                if (v == 1 || this.titname == '查看') {
                    this.infolist = {
                        secTime: '',
                        centerTime: '',
                        deptTime: ''
                    };
                    this.infodata = [{}];
                    this.dialogStatus = false;
                    return
                }
                let _this = this;
                let info = this.infolist;
                info.opTime = _this.$formatDate(new Date(), "YYYY-MM-DD");
                info.opNo = this.userInfo.loginNo;
                info.opName = this.userInfo.loginName;
                info.secUtcTime = info.secTime;
                info.centerUtcTime = info.centerTime;
                info.deptUtcTime = info.deptTime;
                info.secTime = info.secTime ? _this.$formatDate(info.secTime, "YYYY-MM-DD HH:mm") : '';
                info.centerTime = info.centerTime ? _this.$formatDate(info.centerTime, "YYYY-MM-DD HH:mm") : '';
                info.deptTime = info.deptTime ? _this.$formatDate(info.deptTime, "YYYY-MM-DD HH:mm") : '';

                if (this.titname == '修改') {
                    this.submitInfo("/market/cWorkDemand/update", info);
                } else {
                    this.submitInfo("/market/cWorkDemand/add", info);
                }
            },
            //添加
            dialogCliadds(v) {
                let _this = this;
                let info = {};
                if (v == 1) {
                    this.dialogStatusadd = false;
                    return
                } else if (v == 3) {
                    if (this.leader == 1) {
                        info.centerLeaderNo = this.treeListonly.leaderAuditNo;
                        info.centerLeaderName = this.treeListonly.leaderAuditName;
                        info.sts = 3;
                        info.stsDesc = '副总经理待审批';
                    } else if (this.leader == 2) {
                        info.deptLeaderNo = this.treeListonly.leaderAuditNo;
                        info.deptLeaderName = this.treeListonly.leaderAuditName;
                        info.sts = 4;
                        info.stsDesc = '总经理待审批';
                    } else if (this.leader == 3) {
                        info.sts = 1;
                        info.stsDesc = '审批完成';
                    } else {
                        info.secLeaderNo = this.treeListonly.leaderAuditNo;
                        info.secLeaderName = this.treeListonly.leaderAuditName;
                        info.sts = 2;
                        info.stsDesc = '科室待审批';
                    }
                    info.demandDetailList = this.infodatas;
                    info.id = this.choid;
                    this.submitInfo("/market/cWorkDemand/approvalDemand", info);
                    return
                }
                for (let i = 0; i < this.infodatas.length; i++) {
                    let n = 0;
                    for (let item in this.infodatas[i]) {
                        if (item == 'demandName' || item == 'level1No' || item == 'level2No' || item == 'level3No' ||
                            item == 'level4No' || item == 'groupDemand' || item == 'keyPoint' || item == 'deptName' ||
                            item == 'secName' || item == 'commitPerson' || item == 'deptPerson' || item ==
                            'demandType' || item == 'logoutTime' || item == 'passType') {
                            if (this.infodatas[i][item] == null) {
                                n++
                            }
                        }
                    }
                    if (14 > n && n > 0) {
                        this.$message({
                            message: '请填写完整的需求项！',
                            type: 'error'
                        });
                        return
                    }
                }
                console.log(info)
                info.demandDetailList = this.infodatas;
                info.id = this.choid;
                this.submitInfo("/market/cWorkDemand/saveDemandDetail", info);
            },

            submitInfo(u, v) {
                let _this = this;
                this.$refs.infolist.validate(valid => {
                    if (valid) {
                        this.$http({
                            url: u,
                            method: "post",
                            headers: {
                                "Content-Type": "application/json",
                            },
                            data: v,
                        }).then((res) => {
                            if (res.data.result === 1) {
                                _this.$message({
                                    message: res.data.desc,
                                    type: 'error'
                                });
                            } else {
                                _this.$message({
                                    message: '成功',
                                    type: 'success'
                                });
                                _this.closedia();
                                _this.infolist = {
                                    secTime: '',
                                    centerTime: '',
                                    deptTime: ''
                                };
                                _this.infodata = [{}];
                                _this.dialogStatusadd = false;
                                _this.choleader = false;
                                _this.getList(this.params, this.pageSize);
                            }

                        });
                    }
                })
            },
            closeMessage(v) {
                this.centerDialogVisible = false;
                let _this = this;
                if (v === 1) {
                    _this.$http({
                        url: "/market/cNewlyDoc/del",
                        method: "post",
                        headers: {
                            "Content-Type": "application/json",
                        },
                        data: {
                            id: this.delid
                        },
                    }).then((res) => {
                        if (res.data.result === 1) {
                            _this.$message({
                                message: res.data.desc,
                                type: 'error'
                            });
                        } else {
                            _this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            _this.getList(this.params, this.pageSize);
                        }
                    });
                }
            },
            //删除
            delLine(v) {
                this.centerDialogVisible = true;
                this.messTit = '即将删除此条数据, 是否删除?';
                this.delid = v.id;
            },
            //功能栏
            iconCli(v) {
                if (v === 1) {
                    this.getList(this.params, this.pageSize);
                }
                if (v === 2) {
                    this.fullscreen = !this.fullscreen
                }
            },
            getUser() {
                this.userInfo = JSON.parse(window.sessionStorage.userInfo);
                this.$http({
                    url: "/market/cfgDataDict/queryList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        dictCode: 'docType'
                    },
                }).then((res) => {
                    this.docType = res.data;
                });
                this.$http({
                    url: "/market/cfgDataDict/queryList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        dictCode: 'contentType'
                    },
                }).then((res) => {
                    this.contentType = res.data;
                });
            },
        },
        mounted() {
            this.getList({}, 1);
            this.getUser();
        },
        created() {

        }
    }
</script>
<style scoped lang="scss">
    .onetab {
        margin-bottom: 20px;
        padding: 0 20px;
    }

    .titbox {
        div {
            float: right;

            i {
                font-size: 22px;
                margin-left: 20px;
                cursor: pointer;
            }
        }
    }

    .tabbox {
        margin-top: 15px;
    }

    .pageBox {
        text-align: right;
        margin-top: 10px;
    }

    .info-line {
        width: 100%;
        display: block;
        padding-left: 20px;

        div {
            width: 50%;
            display: inline-block;
        }

        span {
            width: 140px;
            display: inline-block;
            text-align: left;

            i {
                color: red;
                display: inline-block;
                padding-right: 5px;
            }
        }

        .el-select,
        .el-input {
            width: calc(100% - 160px);
        }
    }

    .online {
        width: 100%;

        .el-select {
            width: calc(100% - 160px);
        }

        span {
            vertical-align: top;
        }

        .el-textarea {
            width: calc(100% - 160px);
        }

        .tree {
            width: calc(50% - 60px);
            display: inline-block;
            margin-right: 20px;
            height: 300px;
            overflow-y: scroll;

            .el-icon-error {
                float: right;
                font-size: 20px;
                margin-top: 9px;
                cursor: pointer;
            }
        }

        .treeUser {
            margin: 0;
            border: 1px solid #ddd;

            p {
                background: #f4f4f4;
                padding: 0 20px;
                margin-bottom: 5px;
            }
        }

        .treeUserb {
            width: calc(100% - 100px);
            border: 1px solid #ddd;
            background: #f4f4f4;
            border-radius: 3px;
            height: auto;
            overflow: hidden;

            p {
                display: inline-block;
                padding: 0 20px;
                margin-bottom: 5px;
            }
        }
    }

    .adv-type {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        // border: 1px solid #ddd;
        border-radius: 5px;
        padding: 20px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);

        div {
            width: 33%;
            text-align: center;
            height: 80px;
            overflow: hidden;
            min-width: 100px;
            cursor: pointer;
            padding-top: 10px;
            margin: 10px 0;
        }

        div:hover {
            background: #CFE8FC;
            border-radius: 5px;
        }

        span {
            width: 100%;
            display: inline-block;
            height: 40px;

            // line-height: 40px;
            i {
                color: #0074D9;
                font-size: 36px;
            }
        }
    }
</style>
