<template>
    <basic-container>
        <el-drawer
        title=""
        append-to-body
        :visible.sync="drawer"
        size="88%"
        class="examineDialog"
        :wrapperClosable="false"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        >
            <div class="companyTitle">
                <div class="title">
                    <h2>{{companyInfo.companyName}}</h2>
                    <p><span>所属市场：{{companyInfo.stationName}}</span><span>邀请码：{{row.inviteCode}}</span></p>
                </div>
                <div class="btn">
                    <el-button type="primary" size="small" @click="stopHandelClick(companyId)" v-show="entranceFlag == 'suss'">终止合作</el-button>
                    <el-button type="primary" size="small" @click="recoveryHandelClick()" v-show="entranceFlag == 'stop'">恢复合作</el-button>
                </div>
            </div>
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="企业信息" name="companyInfo">
                    <el-form ref="formCompanyInfo" :model="companyInfo" label-width="150px" class="companyInfo" :rules="rules">
                        <el-form-item label="社会信用代码:" prop="companyTid">
                            <el-input v-model="companyInfo.companyTid" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="公司名称:" prop="companyName">
                            <el-input v-model="companyInfo.companyName" :disabled="companyDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="法人:" prop="masterName">
                            <el-input v-model="companyInfo.masterName" :disabled="companyDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="身份证号:" prop="masterIdentity">
                            <el-input v-model="companyInfo.masterIdentity" :disabled="companyDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="法人电话:">
                            <el-input v-model="companyInfo.masterPhone" :disabled="companyDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="注册电话:" prop="telphone">
                            <el-input v-model="companyInfo.telphone" :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="行业:" prop="tradeId">
                            <!-- <el-input v-model="companyInfo.tradeId" :disabled="true"></el-input> -->
                            <el-select v-model="companyInfo.tradeId" placeholder="请选择" :disabled="companyDisabled">
                                <el-option
                                    v-for="(item,index) in tradeDic"
                                    :key="index"
                                    :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="所在地区:" prop="cityId">
                            <jl-city-cascader
                            :disabled="companyDisabled"
                            v-model="companyInfo.cityId"
                            ></jl-city-cascader>
                        </el-form-item>
                        <el-form-item label="详细地址:" prop="companyAddress">
                            <el-input v-model="companyInfo.companyAddress" :disabled="companyDisabled"></el-input>
                        </el-form-item>
                        <el-form-item v-show="btnShowFlag">
                            <el-button size="small" @click="cancelHandelClick('companyDisabled','formCompanyInfo')">取消</el-button>
                            <el-button type="primary" size="small" @click="saveHandelClick('companyDisabled','formCompanyInfo')">保存</el-button>
                        </el-form-item>
                    </el-form>
                    <i class="el-icon-edit" @click="editHandelClick('companyDisabled')">修改</i>
                </el-tab-pane>
                <el-tab-pane label="服务设置" name="serviceInfo">
                    <div class="serviceSetBox" v-for="(item,index) in configData" :key="index">
                    <div v-if="item.type == 5" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>合同<span v-if="item.value == 0">未签</span><span v-else-if="item.value == 1">已签</span></h3>
                            <p>合同是平台与企业签订的合作合同，详细记录了合作细节，是平台与企业合作关系的重要依据。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text" @click="configSubmit(item)">
                                <span v-if="item.value == 0">已签</span>
                                <span v-else-if="item.value == 1">未签</span>
                            </el-button>
                        </div>
                    </div>
                    <div v-else-if="item.type == 4" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>保证金<span v-if="item.value == 1">未缴</span><span v-if="item.value == 0">已缴</span><span v-if="item.value == 2">免缴</span></h3>
                            <p>保证金是保证平台权益和企业权益的重要担保，企业不缴纳保证金不可以发布任务。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text" v-if="item.value != 2" @click="configPay(item, 'free')">免缴</el-button>
                            <el-button type="text" v-if="item.value != 0" @click="configPay(item, 'yes')">已缴</el-button>
                            <el-button type="text" v-if="item.value != 1" @click="configPay(item, 'no')">未缴</el-button>
                        </div>
                    </div>
                    <div v-else-if="item.type == 1" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>商保<span v-if="item.value == 0">停用</span><span v-if="item.value == 1">启用</span></h3>
                            <p>是保障员工安全的重要手段，减少了企业的用工风险。为企业开通商保后，企业不为员工投保则不可以录用相应员工。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text"  @click="configSubmit(item)">
                                <span v-if="item.value == 1">停用</span><span v-if="item.value == 0">启用</span>
                            </el-button>
                        </div>
                    </div>
                    <div v-else-if="item.type == 6" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>电子合同<span v-if="item.value == 0">关闭</span><span v-if="item.value == 1">启用</span></h3>
                            <p>电子合同是企业与员工签订的合作协议，详细记录了用工要求与责任，是企业与员工合作关系的重要依据。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text" v-if="item.value == 1" @click="configSubmit(item)">关闭</el-button>
                            <el-button type="text" v-if="item.value == 0"  @click="configOpenElec(item)">启用</el-button>
                        </div>
                    </div>
                    <div v-else-if="item.type == 2" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>先开票<span v-if="item.value == 0">停用</span><span v-if="item.value == 1">启用</span></h3>
                            <p>打开先开票服务，企业可不支付订单就可以申请开发票，请谨慎设置。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text"  @click="configSubmit(item)">
                                <span v-if="item.value == 1">停用</span><span v-if="item.value == 0">启用</span>
                            </el-button>
                        </div>
                    </div>
                    <div v-else-if="item.type == 3" class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>银联代发<span v-if="item.value == 0">停用</span><span v-if="item.value == 1">启用</span></h3>
                            <p>银联代发是线上发放工资的一种方式。设置为打开状态，企业工资可以使用线上待发渠道发放。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text"  @click="configSubmit(item)">
                                <span v-if="item.value == 1">停用</span><span v-if="item.value == 0">启用</span>
                            </el-button>
                        </div>
                    </div>
                    <div v-else class="showFlag">
                        <div class="serviceSetTitle" >
                            <h3>合同{{item}}<span>未签</span><span>已签</span></h3>
                            <p>合同是平台与企业签订的合作合同，详细记录了合作细节，是平台与企业合作关系的重要依据。</p>
                        </div>
                        <div class="serviceSetBtn">
                            <el-button type="text">
                                <span >已签</span>
                                <span>未签</span>
                            </el-button>
                        </div>
                    </div>
                </div>
                </el-tab-pane>
                <el-tab-pane label="服务费信息" name="serviceChargeInfo">
                    <div class="serviceChargeInfo">
                        <p class="tips">服务费：是企业享受二项服务（发工资和投商保）的费用，启用之后需新的订单才会生效。</p>
                        <div class="company-config-title-tool">
                            <el-button type="text" icon="el-icon-circle-plus-outline" @click="serviceVisible = true">添加新服务</el-button>
                        </div>
                        <el-table :data="serviceData" border>
                            <div slot="empty">请在右上角添加新服务</div>
                            <el-table-column label="产品">
                                <template>服务费</template>
                            </el-table-column>
                            <el-table-column label="服务费" prop="serveCost">
                                <template v-slot="{ row }">{{ moneyFormat(row.serveCost) }}元</template>
                            </el-table-column>
                            <el-table-column label="状态" prop="isEnabled">
                                <template v-slot="{ row }">
                                <span v-if="row.isEnabled === 0">停用</span>
                                <span v-else-if="row.isEnabled === 1">启用</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作">
                                <template v-slot="{ row }">
                                <el-button size="small" type="text" :disabled="row.isEnabled === 1" @click="serverEnable(row)">启用
                                </el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="附件" name="enclosure">
                    <avue-form
                        :option="option"
                        v-model="companyInfo"
                        ref="formEnclosure"
                        @submit="formSubmit"
                        :upload-after="uploadAfter"
                        :upload-error="uploadError"
                        :upload-before="beforeAvatarUpload"
                        @on-load="onLoad"
                    >
                        <template slot="motoleyUrl">
                            <el-upload
                                    class="companyList-upload"
                                    list-type="picture-card"
                                    :auto-upload="true"
                                    :file-list="imgList"
                                    :limit="4"
                                    :action="mutiPutFile"
                                    :on-preview="handlePictureCardPreview"
                                    :on-exceed="handleImgLimit"
                                    :on-success="handleImgSuccess"
                                    :on-remove="handleImgRemove"
                                    :before-remove="beforeRemove"
                                    :before-upload="beforeAvatarUpload"
                                >
                                    <i slot="default" class="el-icon-plus avue-upload__icon"></i>
                            </el-upload>
                        </template>
                    </avue-form>
                    <p style="text-align:center">
                        <el-button size="small" @click="cancelHandelClick('','formEnclosure')">取消</el-button>
                        <el-button type="primary" size="small" @click="saveHandelClick('enclosure','formEnclosure')">保存</el-button>
                        <i class="el-icon-download" @click="downloadAllClick('enclosure')">下载全部</i>
                    </p>


                </el-tab-pane>
                <el-tab-pane label="签发电子签章" name="contractOn">
                   <avue-form
                        :option="optionContractOn"
                        v-model="companyInfo"
                        ref="formContractOn"
                        @submit="formSubmit"
                        :upload-after="uploadAfter"
                        :upload-error="uploadError"
                        :upload-before="beforeAvatarUpload"
                        @on-load="onLoad"
                    >
                    </avue-form>
                    <p style="text-align:center">
                        <el-button size="small" @click="cancelHandelClick('','formContractOn')">取消</el-button>
                        <el-button type="primary" size="small" @click="saveHandelClick('contractOn','formContractOn')">保存</el-button>
                        <i class="el-icon-download" @click="downloadAllClick('contractOn')">下载全部</i>
                    </p>

                </el-tab-pane>
                <el-tab-pane label="操作记录" name="operationRecord">
                    <company-config-record :data="record"></company-config-record>
                </el-tab-pane>
            </el-tabs>
            <el-dialog :visible.sync="serviceVisible" append-to-body @closed="serviceClosed">
            <avue-form ref="serviceForm" v-model="serviceForm" :option="serviceOption" @reset-change="emptytChange"
                @submit="serviceSubmit">
                <template v-slot:id>
                <span>服务费</span>
                </template>
            </avue-form>
        </el-dialog>
        </el-drawer>
    </basic-container>
</template>
<script>
import {getStation } from "@/api/manage/station";
import {getDetail,downloadList,update,setConfig,addService,getNoProcessing,stop,whetherSignService,serviceEnable} from "@/api/manage/company";
import { getTradeDic } from "@/api/manage/trade";
import { moneyFormat, toCent} from "@/util/money";
import { getConfigListNew } from "@/api/manage/companyRecord";
import companyConfigRecord from "../companyConfigRecordNew";
import Axios from "axios";
import lodash from "lodash";
import { putFile } from "@/api/resource/oss";

import {
    getConfigNew,
  } from "@/api/manage/company";
const accept = [
  "image/png",
  "image/jpeg",
  "image/svg+xml",
  "image/gif",
  "image/x-photoshop",
];
function getPath(path) {
  const arr = path.split(",");
  return arr[arr.length - 1];
}
export default {
    components: { companyConfigRecord },
    data() {
      return {
        rules: {
            companyTid: [
                { required: true, message: '请输入社会信用代码', trigger: 'blur' },
            ],
            companyName: [
                { required: true, message: '请输入公司名称', trigger: 'blur' },
            ],
            masterName: [
                { required: true, message: '请输入法人姓名', trigger: 'blur' },
            ],
            masterIdentity: [
                { required: true, message: '请输入身份证号', trigger: 'blur' },
            ],
            telphone: [
                { required: true, message: '请输入注册电话', trigger: 'blur' },
            ],
            tradeId: [
                { required: true, message: '请选择行业', trigger: 'blur' },
            ],
            cityId: [
                { required: true, message: '请选择所在地区', trigger: 'blur' },
            ],
            companyAddress: [
                { required: true, message: '请输入信息地址', trigger: 'blur' },
            ],
        },
        noProcessingStatus:9,//终止合作
        entranceFlag:'',
        btnShowFlag:false,
        serviceVisible: false,
        downloadUrls:'',
        serviceForm: {},
        serviceOption: {
          menuPosition: "right",
          labelWidth: 120,
          column: [
            {
              type: "select",
              label: "产品",
              prop: "id",
              formslot: true,
              span: 24,
            },
            {
              type: "number",
              label: "服务费金额",
              prop: "serveCost",
              precision: 2,
              rules: [{ required: true, message: "请输入服务费金额" }],
              span: 24,
            },
            {
              type: "select",
              label: "计量单位",
              prop: "serveUnit",
              dataType: "number",
              dicData: [{ value: 0, label: "元/人·次" }],
              rules: [{ required: true, message: "请选择计量单位" }],
              span: 24,
            },
          ],
        },
        activeName: 'companyInfo',
        formEnclosure:{},
        row:{},
        drawer:false,
        companyDisabled:true,
        companyInfo:{},
        tradeDic:[],
        configData:[],
        companyId: null,
        tenantId: null,
        serviceData: [],
        record:[],
        mutiPutFile: putFile(),
        imgList:[],
        option: {
            labelWidth: 200,
            menuBtn:false,
            column: [
            {
                type: "upload",
                label: "法人身份证（人像）",
                span:12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                canvasOption: {},
                headers: [],
                data: [],
                accept,
                size: "small",
                prop: "identityUrl4Id",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传法人身份证（人像）",
                    },
                ],
            },
            {
                type: "upload",
                label: "法人身份证（国徽）",
                span: 12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                canvasOption: {},
                headers: [],
                data: [],
                accept,
                size: "small",
                prop: "identityUrl5Id",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传法人身份证（国徽）",
                    },
                ],
                // tip:'上传图片大小限制2M以内',
            },
            {
                type: "upload",
                label: "营业执照",
                span: 12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                accept,
                canvasOption: {},
                headers: [],
                data: [],
                size: "small",
                prop: "authUrlId",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传营业执照照片",
                    },
                ],
                    // tip:'上传图片大小限制2M以内',
            },

            {
                type: "upload",
                label: "授权委托书",
                span: 12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                canvasOption: {},
                headers: [],
                data: [],
                accept,
                size: "small",
                prop: "letterOfAttorneyUrl",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传授权委托书",
                    },
                ],
                // tip:'上传图片大小限制2M以内',
            },
            {
                label: "招聘简章",
                formslot:true,
                span:24,
                prop:'motoleyUrl',
                rules: [
                  {
                    required: true,
                    message: "请上传招聘简章",
                  },
                ],
                viewDisplay: false,
            },
            ]
        },
        optionContractOn: {
            labelWidth: 200,
            menuBtn:false,
            column: [
            {
                type: "upload",
                label: "电子签章申请表",
                span: 12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                accept,
                canvasOption: {},
                headers: [],
                data: [],
                size: "small",
                prop: "signSrcUrl",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传电子签章申请表",
                    },
                ],
                // tip:'上传图片大小限制2M以内',
            },
            {
                type: "upload",
                label: "电子签章章模",
                span: 12,
                showFileList: false,
                listType: "picture-img",
                multiple: false,
                propsHttp: {
                    res: "data",
                    url: "link",
                },
                canvasOption: {},
                headers: [],
                data: [],
                accept,
                size: "small",
                prop: "templateUrl",
                action: putFile(),
                viewDisplay: false,
                rules: [
                    {
                    required: true,
                    message: "请上传电子签章章模",
                    },
                ],
                // tip:'上传图片大小限制2M以内',
            },
            ]
        }
      };
    },
    methods:{
        rowStop(id) {
        let h = this.$createElement;
        this.$confirm(
            h("p", { style: "color: #F56C6C" }, "一旦终止合作企业将无法操作系统"),
            "您确定要终止与此公司的合作吗？",
            {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
            center: true,
            }
        )
            .then(() => {
            this.loading = true;
            stop(id)
                .then((resp) => {
                this.$message({
                    type: "success",
                    message: resp.data.msg,
                });
                this.onLoad(this.page, this.query);
                })
                .catch(() => {
                this.loading = false;
                });
            })
            .catch(() => {});
        },
        moneyFormat,
        //下载全部
        downloadAllClick(name){
            this.downloadUrls = '';
            if(name == 'enclosure'){
                this.downloadUrls += this.companyInfo.identityUrl4Id + ',';
                this.downloadUrls += this.companyInfo.identityUrl5Id + ',';
                this.downloadUrls += this.companyInfo.authUrlId + ',';
                this.downloadUrls += this.companyInfo.letterOfAttorneyUrl + ',';
                this.downloadUrls += this.companyInfo.motoleyUrl;
            }else{
                this.downloadUrls += this.companyInfo.signSrcUrl + ',';
                this.downloadUrls += this.companyInfo.templateUrl;
            }
            window.open(downloadList(this.downloadUrls));
        },
        serverEnable(row) {
            this.loading = true;
            serviceEnable(row.id, this.companyId)
            .then(() => {
                this.$message({ type: "success", message: "操作成功！" });
                this.getConfig();
            })
            .catch(() => {
                this.getConfig();
            });
        },
        recoveryHandelClick() {
            let h = this.$createElement;
            this.$confirm(
                h("p", { style: "color: #F56C6C" }, "一旦恢复合作企业所有账号均可使用"),
                "您确定要恢复与此公司的合作吗？",
                {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
                center: true,
                }
            )
                .then(() => {
                 getNoProcessing(this.companyId,'',0).then((res)=>{ //0代表回复合作
                  if (res.data.code==200) {
                    this.$message.success(res.data.msg);
                    this.drawer = false;
                    this.$emit('refresh')
                  }else{
                    this.$message.error(res.data.msg)
                  }
                })
                })
                .catch(() => {});
            },
        serviceSubmit(form, done) {
            form.serveCost = toCent(form.serveCost);
            form.companyId = this.companyId;
            form.tenantId = this.tenantId;
            addService(form)
            .then(() => {
                this.$message({ type: "success", message: "操作成功！" });
                this.getConfig();
                this.serviceVisible = false;
                done();
            })
            .catch(() => {
                done();
            });
        },
        /*开启电子合同服务*/
        configOpenElec(row) {
            whetherSignService(this.companyId).then((res) => {
            if (res.data.data) {
                const data = lodash.cloneDeep(row);
                data.value = 1;
                setConfig(data)
                .then(() => {
                    this.$message({ type: "success", message: "操作成功！" });
                    this.getConfig();
                })
                .catch(() => {
                    this.getConfig();
                });
            }
            else {
                this.$message.error('企业未开通【电子签章】，不能开启【电子合同】')
            }

            }).catch((error) => {
            this.$message.error(error)
            })
        },
        //合同
        configSubmit(row) {
            const data = lodash.cloneDeep(row);
            data.value = data.value ? 0 : 1;
            if(row.type == 2 && row.value == 0){
                this.$confirm('开启<font color="#409EFF"> 先开票 </font>服务，则会在企业付款之前开发票，确定开启？', '提示', {
                    confirmButtonText: '开启',
                    cancelButtonText: '取消',
                    dangerouslyUseHTMLString:true,
                    }).then(() => {
                    setConfig(data)
                        .then((res) => {
                            this.$message({ type: "success", message: res.data.msg });
                            this.getConfig();
                        })
                        .catch(() => {
                            this.getConfig();
                        });
                    }).catch(() => {
                    // this.$message({
                    //     type: 'info',
                    //     message: '已取消删除'
                    // });
                    });
            }else{
                if(row.type == 3 && row.value == 1){
                    this.$confirm('停用<font color="#409EFF"> 银联代发 </font>服务，企业发工资则不可以使用线上代发功能，确定停用吗？', '提示', {
                        confirmButtonText: '停用',
                        cancelButtonText: '取消',
                        dangerouslyUseHTMLString:true,
                        }).then(() => {
                        setConfig(data)
                            .then((res) => {
                                this.$message({ type: "success", message: res.data.msg });
                                this.getConfig();
                            })
                            .catch(() => {
                                this.getConfig();
                            });
                        }).catch(() => {
                        // this.$message({
                        //     type: 'info',
                        //     message: '已取消删除'
                        // });
                        });
                }else{
                    setConfig(data)
                    .then((res) => {
                        this.$message({ type: "success", message: res.data.msg });
                        this.getConfig();
                    })
                    .catch(() => {
                        this.getConfig();
                    });
                }

            }

        },
        /*免缴保证金*/
        configPay(row, type) {
            const data = lodash.cloneDeep(row);
            if (type == "free") {//免缴--2
            data.value = 2;
            } else if (type == "yes") {//已缴 --0
            data.value = 0;
            } else if (type == "no") {//未缴--1
            data.value = 1;
            }

            setConfig(data)
            .then(() => {
                this.$message({ type: "success", message: "操作成功！" });
                this.getConfig();
            })
            .catch(() => {
                this.getConfig();
            });
        },
        //修改
        editHandelClick(flag){
            this[flag] = false;
            this.btnShowFlag = true;
        },
        //保存
        saveHandelClick(flag,formName){
            if(formName){
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.saveUpdate(flag);
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                })
            }else{
                this.saveUpdate(flag);
            }


        },
        saveUpdate(flag){
            this.companyInfo.authUrlId = getPath(this.companyInfo.authUrlId);
            this.companyInfo.identityUrl4Id = getPath(this.companyInfo.identityUrl4Id);
            this.companyInfo.identityUrl5Id = getPath(this.companyInfo.identityUrl5Id);
            this.companyInfo.remarks = '修改';
            update(this.companyInfo).then(
                () => {
                this.openDialog(this.row);
                this.$message({
                    type: "success",
                    message: "操作成功!",
                });
                },
                (error) => {
                window.console.log(error);
                }
            );
            this[flag] = true;
            this.btnShowFlag = false;
        },
        //取消
        cancelHandelClick(flag,formName){
            formName ? this.$refs[formName].clearValidate() : '';
            this.openDialog(this.row,this.entranceFlag);
            this[flag] = true;
            this.btnShowFlag = false;

        },
        //终止合作
        stopHandelClick(){
            this.$confirm('您确定要终止与此公司合作吗？</br><span style="color:#ff0000">一旦终止合作企业将无法操作系统</span>', '终止合作', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                dangerouslyUseHTMLString:true
            }).then(() => {
                getNoProcessing(this.companyId,'',this.noProcessingStatus).then((res)=>{
                  if (res.data.code==200) {
                    this.$message.success(res.data.msg);
                    this.drawer = false;
                    this.$emit('refresh')
                  }else{
                    this.$message.error(res.data.msg)
                  }
                })
            }).catch(() => {

            });
        },
        /*多张图片上传*/

        handleImgLimit(){
            this.$message.warning('当前最多上传4张图片');
        },
        handleImgSuccess(res){
            if(res.code==200){
                this.imgList.push({url:res.data.link});

            var str="";
            for(var i=0;i<this.imgList.length;i++){
                str+=this.imgList[i]['url']+",";
            }
            if(str.length>0){
                str=str.substr(0,str.length-1);
            }
            this.companyInfo.motoleyUrl=str;
            }
            else{
                this.$message.error('上传失败');
            }

        },
        handleImgRemove(file){
            let index=0;
            for(let i in this.imgList){
                if(this.imgList[i]['uid']==file.uid){
                index=i;
                break;
                }
            }
            this.imgList.splice(index,1);
            var str="";
            for(var i=0;i<this.imgList.length;i++){
                str+=this.imgList[i]['url']+",";
            }
            if(str.length>0){
                str=str.substr(0,str.length-1);
            }
            this.companyInfo.motoleyUrl=str;
        },
        //获取企业服务配置
        getConfig() {
            this.loading = true;
            Axios.all([
                getConfigListNew(this.companyId,0),
                getConfigNew(this.companyId),
            ]).then(
            Axios.spread((record, config) => {
                this.record = record.data.data;
                this.configData = config.data.data.config;
                this.serviceData = config.data.data.fee;
                this.loading = false;
            })
            );
            },
        /*打开drawer*/
        openDialog (row,flag) {
            this.entranceFlag = flag;
            this.row = row;
            this.companyDisabled = true;
            this.companyId = row.id;
            this.tenantId = row.tenantId;
            this.drawer = true;
            this.imgList = [];
            getTradeDic(true).then((res) => {
                this.tradeDic = res.data.data;
            });
            getDetail(row.id).then((res) => {
                this.loading = false;
                this.companyInfo = res.data.data;
                // if(this.form.tradeId==1){
                //     this.form.tradeId='';
                //     this.tradeId = this.form.tradeId;
                // }
                if(this.companyInfo.motoleyUrl!=""){
                    var strList=this.companyInfo.motoleyUrl.split(',');
                for(var i in strList){
                    this.imgList.push({url:strList[i]})
                }
                }
                getStation().then((res)=>{
                    let getStationList = res.data.data;
                    getStationList.forEach((ele) => {
                        if(row.stationId == ele.stationId){
                            this.companyInfo.stationName = ele.stationName;
                        }
                    });
                })
            });
            this.getConfig();


        },
        handleClick(tab, event) {
            console.log(tab, event);
        }
    }
}
</script>
<style lang="scss">
    .examineDialog .companyTitle{
        border-bottom: 2px solid #e7e7e7;
        margin-bottom: 30px;
        display: flex;
    }
    .examineDialog .el-drawer__header{
        padding: 0;
        margin: 0;
    }
    .examineDialog .companyTitle p span{
        margin-right: 20px;
    }
    .examineDialog .companyTitle h2{
        margin: 0;
        padding: 0;
    }
    .examineDialog .companyTitle .title{
        width: 85%;
    }
    .examineDialog .companyTitle .btn{
        margin-top: 40px;
    }
    .examineDialog .el-form-item{
        float: left;
        width: 35%;
    }
    .examineDialog .el-cascader,.examineDialog .el-select{
        width: 100%;
    }
  .examineDialog .serviceSetBox{
        display: flex;
        height: 80px;
        width: 96%;
        padding: 0 2%;
        background-color: #F5F7FA;
        border-radius: 10px;
        margin-bottom: 10px;
    }
       .examineDialog .serviceSetBox .showFlag{
           width: 100%;
           display: flex;
       }
       .serviceSetTitle{
        width:97%;
    }
    .examineDialog .serviceSetTitle h3{
        font-weight: 400;
        font-size: 16px;
        padding:0;
        margin: 0;
        margin-top: 10px;
    }
    .examineDialog .serviceSetTitle p{
        padding: 0;
        margin: 0;
        margin-top: 10px;
        font-size: 14px;
    }
    .examineDialog .serviceSetTitle h3 span{
        display: inline-block;
        margin-left: 20px;
        padding: 2px 10px;
        border: 1px solid #5379f7;
        border-radius: 5px;
        font-size: 12px;
        color:#5379f7;
    }
    .examineDialog .serviceSetBtn{
        line-height: 80px;
        display: flex;
    }
    .examineDialog .serviceInfo li{
        display: flex;
        height: 50px;
        background-color: #F5F7FA;
        border-radius: 10px;
        margin-top: 20px;
        line-height: 50px;
    }
    .examineDialog .serviceInfo li div{
        width: 60%;
        margin-left: 20px;
    }
    .examineDialog .serviceInfo li span{
        color: #409EFF;
    }
    .examineDialog .serviceChargeInfo .tips{
        line-height: 30px;
        color: #ff0000;
        padding: 0;
        margin: 0;
    }
    .examineDialog .el-upload--picture-card{
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px!important;
        text-align: center;
        background-color: #ffffff;
    }
    .examineDialog .el-upload-list--picture-card .el-upload-list__item{
        width: 178px;
        height: 178px;
        line-height: 178px!important;
    }
    .examineDialog .el-input__inner{
        height: 32px;
    }
    .examineDialog .el-tabs__header{
        margin: 0 0 35px;
    }
    .examineDialog .el-drawer__close-btn{
        margin: 20px 20px 0 0;
    }
    .examineDialog .el-icon-edit{
        color: #1989fa;
        cursor: pointer;
        position: relative;
        right: -120px;
        top: 0;
    }
</style>

