<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 size="medium" type="primary" @click="dialogCheck(3)">添加</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="woTitle" label="产品名称">
                    </el-table-column>
                    <el-table-column prop="createTime" label="提出时间">
                    </el-table-column>
                    <el-table-column prop="taskName" label="流程进展">
                    </el-table-column>
                    <el-table-column prop="stsDesc" label="批复状态">
                    </el-table-column>
                    <el-table-column prop="opName" label="起草人">
                    </el-table-column>
                    <el-table-column label="操作" width="120px" align="center">
                        <template slot-scope="scope">
                            <el-button size="mini" type="primary" @click="dialogCheck(1,scope.row)">查看</el-button>
                            <el-button size="mini" type="danger" v-if="scope.row.sts != 1"
                                @click="dialogCheck(2,scope.row)">处理</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" :fullscreen="true">
            <div v-loading="loadinged">
                <el-form :model="infolist" ref="infolist" :rules="rules"
                    style="height: calc(100vh - 180px);overflow-y: scroll;">

                    <div class="info-line online">
                        <el-form-item prop="woTitle">
                            <span>产品名称{{visionsts}}</span>
                            <el-input v-model="infolist.woTitle" placeholder="产品名称" :disabled="disableStatus||visionsts != '1'"></el-input>
                        </el-form-item>
                        <el-form-item prop="extField5">
                            <span>负责部门</span>
                            <el-input v-model="infolist.extField5" placeholder="负责部门" :disabled="disableStatus||visionsts != '1'"></el-input>
                        </el-form-item>
                    </div>
                    <el-form-item class="info-line online">
                        <span style="width: 80px;margin-right: 20px;line-height: 20px;margin-top: 10px;">产品前景及市场格局</span>
                        <el-input v-model="infolist.qjjgj" placeholder="产品前景及市场格局" type="textarea" :rows="4" :disabled="disableStatus||visionsts != '1'"></el-input>
                    </el-form-item>
                    <el-form-item class="info-line online">
                        <span style="width: 90px;margin-right: 10px;line-height: 20px;margin-top: 10px;">公司资源及产品收益分析</span>
                        <el-input v-model="infolist.zyjcp" placeholder="公司资源及产品收益分析" type="textarea" :rows="4" :disabled="disableStatus||visionsts != '1'"></el-input>
                    </el-form-item>
                    <el-form-item class="info-line online">
                        <span>效益分析</span>
                        <el-select clearable v-model="infolist.xyfx" placeholder="效益分析" :disabled="disableStatus||visionsts != '1'">
                            <el-option v-for="item in xyfxopt" :key="item.name" :label="item.name" :value="item.name">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item class="info-line online" v-if="visionlevel*1>1">
                        <span>竞品对标</span>
                        <el-input v-model="infolist.jpdb" placeholder="竞品对标" type="textarea" :rows="4" :disabled="disableStatus||vision != '产品规划'"></el-input>
                    </el-form-item>
                    <el-form-item class="info-line online" v-if="visionlevel*1>1">
                        <span>目标用户分析</span>
                        <el-input v-model="infolist.mbyh" placeholder="目标用户分析" type="textarea" :rows="4" :disabled="disableStatus||vision != '产品规划'"></el-input>
                    </el-form-item>
                    <el-form-item class="info-line online" v-if="visionlevel*1>1">
                        <span>产品发展目标</span>
                        <el-input v-model="infolist.cpfzmu" placeholder="产品发展目标" type="textarea" :rows="4" :disabled="disableStatus||vision != '产品规划'"></el-input>
                    </el-form-item>
                    <el-form-item class="info-line online" v-if="visionlevel*1>1">
                        <span>产品发展举措</span>
                        <el-input v-model="infolist.cpfzjc" placeholder="产品发展举措" type="textarea" :rows="4" :disabled="disableStatus||vision != '产品规划'"></el-input>
                    </el-form-item>

                    <el-form-item class="info-line online" v-if="visionlevel*1>6">
                        <span>通过产品开发</span>
                        <el-select clearable v-model="infolist.tgcpkf" placeholder="是否通过产品开发" :disabled="disableStatus||vision != '产品开发'">
                            <el-option v-for="item in ifopt" :key="item.name" :label="item.name" :value="item.name">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item class="info-line online" v-if="visionlevel*1>6">
                        <span>完成测试</span>
                        <el-select clearable v-model="infolist.wccc" placeholder="是否完成测试" :disabled="disableStatus||vision != '产品开发'">
                            <el-option v-for="item in ifopt" :key="item.name" :label="item.name" :value="item.name">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <div style="margin: 20px 0;padding: 0 20px;" v-if="visionlevel*1>8">
                        <el-table class="com-table" ref="multipleTable" :data="infodatas" tooltip-effect="dark"
                            size="small" border style="width: 100%">

                            <el-table-column label="时间">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.time" :disabled="disableStatus||vision != '运营推广'"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="用户规模">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.yhgm" :disabled="disableStatus||vision != '运营推广'"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="收入规模">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.srgm" :disabled="disableStatus||vision != '运营推广'"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" width="120px" align="center" v-if="vision == '运营推广'">
                                <template slot-scope="scope">
                                    <el-button size="mini" type="primary" @click="choline(1,scope)">添加</el-button>
                                    <el-button size="mini" type="danger" @click="choline(2,scope)">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>


                    <div v-if="titname == '查看'" style="padding:0 20px 20px 20px;">
                        <uploadDown :datalist="datalist" :dialogStatus="uploadstatus"></uploadDown>
                    </div>
                    <myUpload v-if="titname != '查看'" @uploadBack="uploadBack" :fileInfo="fileInfo"
                        :fileList="fileInfo.fileList">
                    </myUpload>

                    <el-form-item class="info-line online" v-if="titname == '审批'" style="margin-top: 20px;">
                    	<span>审批说明</span>
                    	<el-input v-model="remark" placeholder="审批说明" type="textarea" :rows="3"
                    		:disabled="titname == '查看'">
                    	</el-input>
                    </el-form-item>

                    <div style="padding: 20px;" v-if="titname != '添加'">
                    	<el-table class="com-table" :data="rovaList" tooltip-effect="dark"
                    		size="small" border style="width: 100%">
                    		<el-table-column prop="taskId" label="编号">
                    		</el-table-column>
                    		<el-table-column prop="taskName" label="环节">
                    		</el-table-column>
                    		<el-table-column prop="assigneeName" label="处理人">
                    		</el-table-column>
                    		<el-table-column prop="assigneeNo" label="处理人工号">
                    		</el-table-column>
                    		<el-table-column prop="opTime" label="处理时间">
                    		</el-table-column>
                    		<el-table-column prop="remark" label="备注">
                    		</el-table-column>
                    	</el-table>
                    </div>

                </el-form>


                <div slot="footer" class="dialog-footer myfooter">
                    <el-button type="primary" v-if="titname == '添加'" @click="dialogCliadd">确 定</el-button>
                    <el-button type="primary" v-if="vision == '科室主任审批'&&titname == '审批'" @click="dialogCli(2)">通 过</el-button>
                    <el-button v-if="vision == '科室主任审批'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button type="primary" v-if="vision == '产品规划'&&titname == '审批'" @click="dialogCli(2)">确 定</el-button>
                    <el-button type="primary" v-if="vision == '产品设计'&&titname == '审批'" @click="checkexa = true">确 定</el-button>
                    <el-button type="primary" v-if="vision == '科室主任-审批'&&titname == '审批'" @click="checkexa = true">通 过</el-button>
                    <el-button v-if="vision == '科室主任-审批'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button type="primary" v-if="vision == '中心主任审批'&&titname == '审批'" @click="dialogCli(2)">通 过</el-button>
                    <el-button v-if="vision == '中心主任审批'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button type="primary" v-if="vision == '产品-设计'&&titname == '审批'" @click="dialogCli(2)">确 定</el-button>
                    <el-button type="primary" v-if="vision == '产品开发'&&titname == '审批'" @click="dialogCli(2)">确 定</el-button>

                    <el-button type="primary" v-if="vision == '测试上线'&&titname == '审批'" @click="dialogCli(2)">通 过</el-button>
                    <el-button v-if="vision == '测试上线'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>

                    <el-button type="primary" v-if="vision == '运营推广'&&titname == '审批'" @click="baocun">保 存</el-button>
                    <el-button type="primary" v-if="vision == '运营推广'&&titname == '审批'" @click="checkexa = true">退 订</el-button>

                    <el-button type="primary" v-if="vision == '科室主任审批(退订)'&&titname == '审批'" @click="checkexa = true">通 过</el-button>
                    <el-button v-if="vision == '科室主任审批(退订)'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button type="primary" v-if="vision == '中心主任审批(退订)'&&titname == '审批'" @click="checkexa = true">通 过</el-button>
                    <el-button v-if="vision == '中心主任审批(退订)'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button type="primary" v-if="vision == '信息技术中心(退订)'&&titname == '审批'" @click="dialogCli(2)">通 过</el-button>
                    <el-button v-if="vision == '信息技术中心(退订)'&&titname == '审批'" @click="dialogCli(1)">打 回</el-button>
                    <el-button @click="dialogCli(3)">取 消</el-button>
                </div>
            </div>
        </el-dialog>


        <el-dialog
        title="选择审批人"
        :visible.sync="checkexa"
        width="100%"
        style="height: 100%"
        :fullscreen="true"
        :destroy-on-close="true"
        :modal-append-to-body="false"
        :close-on-click-modal="false"
      >
        <div style="height: 100%">
          <el-form :model="infolist" ref="infolist"  :rules="rules" style="height: 100%">
            <el-form-item prop="visiblec" style="height: 100%" >
             
              <deptTreeOnly
                @treeCheck="treeCheckonly"
                :defaultList="defaultList"
                :type="depttype"
                :closeList="closeList"
              ></deptTreeOnly>
              <div style="text-align: center; margin-top: 30px">
                <el-button type="primary" @click="checkProcessUser()"
                  >确 定</el-button
                >
                <el-button @click="checkexa = false">取 消</el-button>
                <!-- <el-button v-if="titname == '添加'" type="primary" @click="dialogCliadd">确 定</el-button>
                    <el-button v-if="titname != '添加'" type="primary" @click="dialogCli(2)">确 定</el-button>
                    <el-button @click="checkexa = false">取 消</el-button> -->
              </div>
              
            </el-form-item>
          </el-form>
        </div>
      </el-dialog>
        <!-- <el-dialog title="选择审批人" :visible.sync="checkexa" 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>审批人员</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 v-if="titname == '添加'" type="primary" @click="dialogCliadd">确 定</el-button>
                    <el-button v-if="titname != '添加'" type="primary" @click="dialogCli(2)">确 定</el-button>
                    <el-button @click="checkexa = 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"
    import deptTreeOnly from "../../../components/newTree.vue";

    export default {
        components: {
            mySearch,
            myMessage,
            toolList,
            myUpload,
            uploadDown,
            deptTreeOnly
        },
        data() {
            const woTitle = (rule, value, callback) => {
                if (!this.infolist.woTitle) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            const extField5 = (rule, value, callback) => {
                if (!this.infolist.extField5) {
                    callback(new Error('不能为空'))
                } else {
                    callback()
                }
            }
            return {
                rules: {
                    woTitle: [{
                        required: true,
                        trigger: 'blur',
                        validator: woTitle
                    }],
                    extField5: [{
                        required: true,
                        trigger: 'blur',
                        validator: extField5
                    }],
                },
                tooltit: '产品品质端到端',
                fullscreen: false,
                total: 0,
                pageSize: 1,
                tableData: [{}],
                dialogStatus: false,
                disableStatus: false,
                titname: '',
                infolist: {},
                userInfo: {},
                params: {},
                centerDialogVisible: false,
                messTit: '',
                delid: '',
                loading: false,
                loadinged: false,
                fileInfo: {
                    limit: 5,
                    url: '/bpm/api/upload',
                    fileList: []
                },
                rovaList: [],
                vision: '',
                datalist: {
                    url: '/bpm/api/download',
                    type: 1
                },
                uploadstatus: false,
                mydisable: 1,
                opname: '',
                opno: '',
                attList: [],
                options: [],
                // terminal: '745181114903359488',
                terminal: '745488750718808064',
                remark: '',
                visionsts: '1',
                visionchonly: false,
                infodatas: [{}],
                busiTime: [],
                demandTypeopt: [],
                carryChannelopt: [],
                checkexa: false,
                treeListonly: [],
                defaultList: [],
                closeList: false,
                depttype: 0,
                fileInfotd: {
                    type: 'btn',
                    typename: '导入',
                    btntype: 'success',
                    limit: 1,
                    url: '/market/cStoreOutWo/importDataEva',
                    fileList: []
                },
                xyfxopt: [
                    {
                        name:'正效益',
                    },
                    {
                        name:'负效益',
                    }
                ],
                ifopt: [
                    {
                        name:'是',
                    },
                    {
                        name:'否',
                    }
                ],
                chosts: 0,
                searchList: [{
                    type: 'input',
                    tit: '标题',
                    value: '',
                    width: '32%'
                }, {
                    type: 'input',
                    tit: '流程',
                    value: '',
                    width: '32%'
                }, {
                    type: 'input',
                    tit: '发起人',
                    value: '',
                    width: '32%'
                }],
                visionlevel:1
            }
        },
        methods: {
             checkProcessUser() {
                let _this = this;
                if (_this.treeListonly.length > 1) {
                    _this.$message({
                    message: "只能选择一个人",
                    type: "error",
                    });
                } else {
                    _this.dialogCliadd();
                }
                },
            //搜索数据
            searchInfo(v) {
                this.params = {};
                v[0] ? this.params.woTitle = v[0] : '';
                v[1] ? this.params.extField4 = v[1] : '';
                v[2] ? this.params.extField5 = v[2] : '';
                this.getList(this.params, this.pageSize);
            },
            chospjd(v) {
                this.chosts = v;
                this.checkexa = true;
            },
            deletes() {
                this.treeListonly = {};
                this.closeList = !this.closeList;
            },
            treeCheckonly(v) {
                this.treeListonly = v;
                console.log(v);
                this.treeListonly.leaderAuditName = v[0].label;
                this.treeListonly.leaderAuditNo = v[0].key;
                // var val = {...v};
                // console.log(val);
                

                //  let newArr=v.map(function (currentValue, index, ar) {
                //     console.log(currentValue);//遍历打印1,2,3
                //     // console.log(index);//遍历打印0,1,2
                //     console.log(ar);//遍历打印三次[1, 2, 3]
                //     // console.log(currentValue.key);
                   
                // //    this.treeListonly.leaderAuditName = currentValue.label;
                // },)
                // this.treeListonly.leaderAuditNo = newArr.currentValue.key;
                // console.log(this.currentValue.key);


            },
            choline(v, n) {
                if (v == 1) {
                    this.infodatas.push({})
                } else {
                    this.infodatas.splice(n.$index, 1)
                }
            },
            closedia() {
                this.infolist = {};
                this.attList = [];
                this.fileInfo.fileList = [];
                this.dialogStatus = false;
                this.checkexa = false;
            },
            //获取列表
            getList(v, n) {
                this.pageSize = n;
                let _this = this;
                this.loading = true;
                v.procName = "产品品质端到端2";
                this.$http({
                    url: "/bpm/api/queryToDoAndFinishTaskList",
                    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);
            },
            //申请
            dialogCheck(v, n) {
                let infolist = Object.assign({}, n);
                this.vision = '';
                this.visionsts = '';
                this.infodatas = [{}];
                if (v === 1) {
                    this.titname = '查看';
                    this.dialogStatus = true;
                    this.disableStatus = true;
                } else if (v === 2) {
                    this.titname = '审批';
                    this.dialogStatus = true;
                    this.disableStatus = false;
                } else if (v === 3) {
                    this.visionsts = '1';
                    this.visionlevel = 1;
                    this.titname = '添加';
                    this.dialogStatus = true;
                    this.disableStatus = false;
                    return
                }
                this.$http({
                    url: '/bpm/api/taskInit',
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {
                        woNo: n.woNo
                    },
                }).then((res) => {
                    this.terminal = infolist.procId;
                    this.opname = res.data.opName;
                    this.opno = res.data.opNo;
                    if (JSON.parse(res.data.params.terminalRes).length == 0) {
                        this.infolist = {};
                    } else {
                        this.infolist = JSON.parse(res.data.params.terminalRes);
                    }
                    res.data.params.fillList ? this.infodatas = JSON.parse(res.data.params.fillList) : '';
                    if (this.infodatas.length == 0) {
                        this.infodatas = [{}];
                    }
                    this.infolist.procId = infolist.procId;
                    this.infolist.procVersion = infolist.procVersion;
                    this.remark = infolist.remark;
                    this.infolist.stepId = infolist.stepId;
                    this.infolist.taskId = infolist.taskId;
                    this.infolist.taskName = infolist.taskName;
                    this.infolist.opName = infolist.opName;
                    this.infolist.opNo = infolist.opNo;
                    this.infolist.opTime = infolist.opTime;
                    this.infolist.woNo = infolist.woNo;
                    this.infolist.extField4 = infolist.taskName;
                    this.infolist.extField5 = infolist.opName;
                    this.visionlevel = 1;
                    if (res.data.taskList[res.data.taskList.length - 1].taskName == '科室主任审批') {
                        this.vision = '科室主任审批';
                        this.visionsts = '2';
                        this.visionchonly = false;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '产品规划') {
                        this.vision = '产品规划';
                        this.visionsts = '2';
                        this.visionchonly = false;
                        this.visionlevel = 2;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '产品设计') {
                        this.vision = '产品设计';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 3;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '科室主任-审批') {
                        this.vision = '科室主任-审批';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 4;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '中心主任审批') {
                        this.vision = '中心主任审批';
                        this.visionsts = '2';
                        this.visionchonly = false;
                        this.visionlevel = 5;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '产品-设计') {
                        this.vision = '产品-设计';
                        this.visionsts = '2';
                        this.visionchonly = false;
                        this.visionlevel = 6;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '产品开发') {
                        this.vision = '产品开发';
                        this.visionsts = '2';
                        this.visionchonly = false;
                        this.visionlevel = 7;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '测试上线') {
                        this.vision = '测试上线';
                        this.visionsts = '2';
                        this.visionchonly = false;
                        this.visionlevel = 8;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '运营推广') {
                        this.vision = '运营推广';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 9;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '科室主任审批(退订)') {
                        this.vision = '科室主任审批(退订)';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 9;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '中心主任审批(退订)') {
                        this.vision = '中心主任审批(退订)';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 9;
                    }else if (res.data.taskList[res.data.taskList.length - 1].taskName == '信息技术中心(退订)') {
                        this.vision = '信息技术中心(退订)';
                        this.visionsts = '2';
                        this.visionchonly = true;
                        this.visionlevel = 9;
                    }
                    this.datalist.attList = JSON.parse(res.data.params.attList);
                    this.attList = [];
                    this.fileInfo.fileList = [];
                    this.datalist.attList.forEach(item => {
                        item.id = item.attchFileId;
                        this.fileInfo.fileList.push({
                            name: item.fileName,
                            url: '',
                            id: item.id,
                            attchFileId: item.attchFileId,
                            fileName: item.fileName
                        });
                        this.attList.push({
                            name: item.fileName,
                            url: '',
                            id: item.id,
                            attchFileId: item.attchFileId,
                            fileName: item.fileName
                        });
                    })
                    this.rovaList = res.data.taskList;
                    this.uploadstatus = !this.uploadstatus;
                });
            },
            //审批
            dialogCli(v) {
                this.dialogStatus = false;
                if (v === 3) {
                    this.infolist = {};
                    this.attList = [];
                    this.fileInfo.fileList = [];
                    this.checkexa = false;
                    return
                }
                let _this = this;
                if (v === 1) {
                    let params = {
                        dealType: '1',
                        dealTypeDesc: '打回',
                        procId: this.infolist.procId,
                        procVersion: this.infolist.procVersion,
                        remark: this.remark,
                        stepId: this.infolist.stepId,
                        taskId: this.infolist.taskId,
                        taskName: this.infolist.taskName,
                        opName: this.infolist.opName,
                        opNo: this.opno,
                        opTime: this.infolist.opTime,
                        params: {
                            procExeCondiVal: '不同意',
                            terminalRes: JSON.stringify(this.infolist),
                            assigneeNo: this.opno,
                            assigneeName: this.opname,
                        },
                        woNo: this.infolist.woNo,
                    }
                    this.submitInfo("/bpm/api/submitTask", params);
                } else if (v === 2) {
                    console.log(222222)
                    let param = {
                        dealType: '0',
                        dealTypeDesc: '提交',
                        procId: this.infolist.procId,
                        procVersion: this.infolist.procVersion,
                        remark: this.remark,
                        stepId: this.infolist.stepId,
                        taskId: this.infolist.taskId,
                        taskName: this.infolist.taskName,
                        opName: this.infolist.opName,
                        opNo: this.opno,
                        opTime: this.infolist.opTime,
                        params: {
                            woType: this.infolist.woType,
                            terminalRes: JSON.stringify(this.infolist),
                        },
                        woNo: this.infolist.woNo,
                    }
                    param.params.fillList = JSON.stringify(this.infodatas);
                    if (this.visionchonly) {
                        param.params.assigneeNo = this.treeListonly.leaderAuditNo;
                        param.params.assigneeName = this.treeListonly.leaderAuditName;
                    }else{
                        param.params.assigneeNo = this.opno;
                        param.params.assigneeName = this.infolist.opName;
                    }
                    let attList = [];
                    for (let i = 0; i < this.attList.length; i++) {
                        attList.push({
                            id: this.attList[i].id,
                            fileCode: this.attList[i].fileCode,
                            fileName: this.attList[i].fileName,
                            opName: this.attList[i].opName,
                            opNo: this.attList[i].opNo,
                            opTime: this.attList[i].opTime,
                            woNo: this.infolist.woNo,
                            attchFileId: this.attList[i].attchFileId,
                        });
                    }
                    param.params.attList = JSON.stringify(attList)
                    this.submitInfo("/bpm/api/submitTask", param);
                }
                this.checkexa = false;
            },
            baocun(){
                let param = {
                    dealType: '0',
                    dealTypeDesc: '提交',
                    procId: this.infolist.procId,
                    procVersion: this.infolist.procVersion,
                    remark: this.remark,
                    stepId: this.infolist.stepId,
                    taskId: this.infolist.taskId,
                    taskName: this.infolist.taskName,
                    opName: this.infolist.opName,
                    opNo: this.opno,
                    opTime: this.infolist.opTime,
                    params: {
                        woType: this.infolist.woType,
                        terminalRes: JSON.stringify(this.infolist),
                    },
                    woNo: this.infolist.woNo,
                }
                param.params.fillList = JSON.stringify(this.infodatas);
                if (this.visionchonly) {
                    param.params.assigneeNo = this.treeListonly.leaderAuditNo;
                    param.params.assigneeName = this.treeListonly.leaderAuditName;
                }else{
                    param.params.assigneeNo = this.opno;
                    param.params.assigneeName = this.infolist.opName;
                }
                let attList = [];
                for (let i = 0; i < this.attList.length; i++) {
                    attList.push({
                        id: this.attList[i].id,
                        fileCode: this.attList[i].fileCode,
                        fileName: this.attList[i].fileName,
                        opName: this.attList[i].opName,
                        opNo: this.attList[i].opNo,
                        opTime: this.attList[i].opTime,
                        woNo: this.infolist.woNo,
                        attchFileId: this.attList[i].attchFileId,
                    });
                }
                param.params.attList = JSON.stringify(attList)
                this.submitInfo("/bpm/api/updateTaskParams", param);
            },
            //添加
            dialogCliadd(v) {
                console.log(11111)
                let _this = this;
                let info = {};
                info.params = {};
                info.opTime = _this.$formatDate(new Date(), "YYYY-MM-DD");
                info.opNo = this.userInfo.loginNo;
                info.opName = this.userInfo.loginName;
                info.woTitle = this.infolist.woTitle;
                info.extField4 = this.infolist.taskName;
                info.extField5 = this.infolist.opName;

                info.params.terminalRes = this.infolist;

                if(this.infolist.xyfx == '正效益'){
                    info.procId = '745485230322020352';
                    info.params.assigneeNo = this.userInfo.loginNo;
                    info.params.assigneeName = this.userInfo.loginName;
                }else{
                    info.procId = '745488750718808064';
                    if(this.treeListonly.leaderAuditNo){
                        info.params.assigneeNo = this.treeListonly.leaderAuditNo;
                        info.params.assigneeName = this.treeListonly.leaderAuditName;
                    }else{
                        this.checkexa = true;
                        return
                    }
                }
                console.log(123);
                for (let i = 0; i < this.options.length; i++) {
                    if (this.terminal == this.options[i].procId) {
                        info.procName = this.options[i].procName;
                        info.procVersion = this.options[i].procVersion;
                    }
                }
                info.params.terminalRes = JSON.stringify(info.params.terminalRes);
                let fillList = [];
                let attList = [];
                for (let i = 0; i < this.attList.length; i++) {
                    attList.push({
                        id: this.attList[i].id,
                        fileCode: this.attList[i].fileCode,
                        fileName: this.attList[i].fileName,
                        opName: this.attList[i].opName,
                        opNo: this.attList[i].opNo,
                        opTime: this.attList[i].opTime,
                        woNo: this.infolist.woNo,
                        attchFileId: this.attList[i].attchFileId,
                    });
                }
                info.params.fillList = JSON.stringify(fillList);
                info.params.attList = JSON.stringify(attList);
                this.submitInfo("/bpm/api/startProc", 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 = {};
                                _this.attList = [];
                                _this.fileInfo.fileList = [];
                                _this.getList(this.params, this.pageSize);
                            }

                        });
                    }
                })
            },
            //流程
            getTermianl() {
                this.$http({
                    url: "/bpm/api/queryBpmProcList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + 1 + '","pageSize":"100"}'
                    },
                    data: {},
                }).then((res) => {
                    this.options = res.data.data;
                    console.log(res.data.data);
                });
            },
            closeMessage(v) {
                this.centerDialogVisible = false;
                let _this = this;
                if (v === 1) {
                    _this.$http({
                        url: "/bpm/api/deleteBpmPrePlugin",
                        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;
            },
            //文件返回值
            uploadBack(v) {
                this.attList = v;
                // for (let i = 0; i < v.length; i++) {
                //     this.attList.push(v[i])
                // }
            },
            uploadBackin(v) {
                let x = [];
                for (let i = 1; i < v.data.body.length; i++) {
                    x.push({
                        factoryName: v.data.body[i].factoryName,
                        workLoad: v.data.body[i].workLoad
                    })
                }
                this.infodatas = x;
            },
            //功能栏
            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: "/sysmgr/csysdept/queryRegionDeptList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {},
                }).then((res) => {
                    this.regionopt = res.data[0].children;
                });
            },
        },
        mounted() {
            this.getList({}, 1);
            this.getUser();
            this.getTermianl();
        },
        created() {

        }
    }
</script>
<style scoped lang="scss">
    ::v-deep .el-dialog .flex-box{
        height: 400px;
    }
    .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: 100px;
            display: inline-block;
            text-align: left;

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

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

    .online {
        width: 100%;

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

        span {
            vertical-align: top;
        }

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

        .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>
