<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商家名称" prop="storeName">
        <el-input v-model="queryParams.storeName" placeholder="请输入商家名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="商家性质" prop="storeNature">
        <el-select v-model="queryParams.storeNature" placeholder="请选择商家性质">
          <el-option v-for="item in selectInfo" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="联系方式" prop="telno">
        <el-input v-model="queryParams.telno" placeholder="请输入联系方式" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态">
          <el-option v-for="item in storeStatus" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:manage:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:manage:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:manage:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:manage:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-upload2" size="mini" @click="handleUpload"
          v-hasPermi="['system:manage:add']">导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="manageList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="50" />
      <el-table-column label="机构名称" align="center" prop="storeName" />
      <el-table-column label="机构性质" align="center" prop="storeNature" />
      <el-table-column label="社会统一信用代码" align="center" prop="creditCode" />
      <el-table-column label="是否自营" align="center" prop="isOne" />
      <el-table-column label="负责人" align="center" prop="leader" />
      <el-table-column label="联系电话" align="center" prop="leaderTel" />
      <el-table-column label="服务区域" align="center" prop="serviceRegion" />
      <el-table-column label="发布范围" align="center" prop="service" width="150" />
      <el-table-column label="创建部门" align="center" prop="createDepartment" />
      <el-table-column label="状态" align="center" prop="status" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleSee(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:manage:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:manage:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改服务商管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px" :inline="true">
        <el-row>
          <el-col :span="12">
            <el-form-item label="*商家名称" prop="storeName">
              <el-input v-model="form.storeName" placeholder="请输入商家名称" style="width: 350px;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*商家性质" prop="storeNature">
              <el-select v-model="form.storeNature" placeholder="请选择商家性质" style="width: 350px;">
                <el-option v-for="item in selectInfo" :key="item.dictValue" :label="item.dictLabel"
                  :value="item.dictValue">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*登录账号" prop="username">
              <el-input v-model="form.username" placeholder="请输入登录账号" style="width: 350px;"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*登录密码" prop="password">
              <el-input v-model="form.password" placeholder="请输入登录密码" style="width: 350px;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*负责人" prop="leader">
              <el-input v-model="form.leader" placeholder="请输入负责人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*联系方式" prop="leaderTel">
              <el-input v-model="form.leaderTel" placeholder="请输入联系方式" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*服务状态" prop="serviceStatus">
              <el-radio-group v-model="form.serviceStatus">
                <el-radio :label="1">正常</el-radio>
                <el-radio :label="0">停止</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*经营时间" prop="date">
              <el-date-picker v-model="form.date" type="daterange" range-separator="至" start-placeholder="开始日期"
                end-placeholder="结束日期" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*周末服务" prop="weekendStatus">
              <el-radio-group v-model="form.weekendStatus">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*假日服务" prop="holidayStatus">
              <el-radio-group v-model="form.holidayStatus">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="固定电话" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入固定电话" style="width: 350px;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属区域" prop="isRegin">
              <el-input v-model="form.isRegin" placeholder="请输入所属区域" style="width: 350px;">
                <el-button slot="append" icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="服务区域" prop="serviceRegion">
              <el-input v-model="form.serviceRegion" placeholder="请输入服务区域" style="width: 350px;">
                <el-button slot="append" icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入地址" style="width: 350px;">
                <el-button slot="append" icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="发布范围" prop="releaseScope">
              <el-checkbox-group v-model="checked" @change="checkeInfo">
                <el-checkbox v-for="item in scopeRelease" :key="item.dictValue" :label="item.dictValue">{{item.dictLabel}}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="社会统一信用代码" prop="creditCode">
              <el-input v-model="form.creditCode" placeholder="请输入" style="width: 350px;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="结算周期" prop="settleTime">
              <el-radio-group v-model="form.settleTime">
                <el-radio v-for="i in settleTime" :key="i.dictValue" :label="i.dictValue">{{ i.dictLabel }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商家在线" prop="storeOnline">
              <el-radio-group v-model="form.storeOnline">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否自营" prop="isOne">
              <el-radio-group v-model="form.isOne">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="营业执照" prop="businessurl">
              <imageUpload :limit="1" url="/system/manage/businessUpload" name="file"></imageUpload>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商家图片" prop="storeurl">
              <imageUpload :limit="1" url="/system/manage/storeUpload" name="file"></imageUpload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="合同附件" prop="contracturl">
              <fileUpload :limit="1" url="/system/manage/contractUpload" name="file"></fileUpload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="机构介绍" prop="introduction">
          <el-input type="textarea" style="width: 900px;" v-model="form.introduction"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="查看服务商" :visible.sync="openToSee" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px" :inline="true" disabled>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*商家名称" prop="storeName">
              <el-input v-model="form.storeName" style="width: 350px;" class="rt-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*商家性质" prop="storeNature">
              <el-input v-model="form.storeNature" style="width: 350px;" class="rt-input" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*登录账号" prop="username">
              <el-input v-model="form.username" style="width: 350px;" class="rt-input"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*负责人" prop="leader">
              <el-input v-model="form.leader" class="rt-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*联系方式" prop="leaderTel">
              <el-input v-model="form.leaderTel" class="rt-input" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*服务状态" prop="serviceStatus">
              <div>{{ form.serviceStatus == 1 ? '正常' : form.serviceStatus == 0 ? '停止' : '' }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*经营时间" prop="date">
              <div>{{ form.begintime ? form.begintime.slice(0, 10) + ' 至 ' + form.endtime.slice(0, 10) : '' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="*周末服务" prop="weekendStatus">
              <div>{{ form.weekendStatus == 1 ? '是' : form.weekendStatus == 0 ? '否':'' }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="*假日服务" prop="holidayStatus">
              <div>{{ form.holidayStatus == 1 ? '是' : form.holidayStatus == 0 ? '否':'' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="固定电话" prop="phone">
              <el-input v-model="form.phone" style="width: 350px;" class="rt-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属区域" prop="isRegin">
              <el-input v-model="form.isRegin" style="width: 350px;" class="rt-input">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="服务区域" prop="serviceRegion">
              <el-input v-model="form.serviceRegion" style="width: 350px;" class="rt-input">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地址" prop="address">
              <el-input v-model="form.address" style="width: 350px;" class="rt-input">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="发布范围" prop="releaseScope">
              <div>{{ scope }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="社会统一信用代码" prop="creditCode">
              <el-input v-model="form.creditCode" style="width: 350px;" class="rt-input"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="结算周期" prop="settleTime">
              <div>{{ settle }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商家在线" prop="storeOnline">
              <div>{{ form.storeOnline == 1 ? '是' : form.storeOnline == 0?'否':'' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否自营" prop="isOne">
              <div>{{ form.isOne == 1 ? '是' : form.isOne == 0?'否': '' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="营业执照" prop="businessurl">
              <el-image style="width: 150px; height: 200px" :src="form.businessurl"
                :preview-src-list="[form.businessurl]">
              </el-image>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商家图片" prop="storeurl">
              <el-image style="width: 150px; height: 150px" :src="form.storeurl" :preview-src-list="[form.storeurl]">
              </el-image>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合同附件" prop="contracturl">
              <el-link type="primary" :href="form.contracturl" :underline="false">合同附件</el-link>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="机构介绍" prop="introduction">
          <el-input type="textarea" v-model="form.introduction" style="width: 900px;" class="rt-input"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog :visible.sync="openToUpload" width="630px" append-to-body>
      <el-upload class="upload-demo" drag :action="uploadFileUrl" multiple style="text-align: center;"
        :before-upload="handleBeforeUpload" :headers="headers" :on-success="handleUploadSuccess" ref="fileUpload">
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip" style="font-size: 15px;line-height: 15px;">仅允许导入xls、xlsx格式文件
          <el-button type="text" @click="downloadTemplate">下载模板</el-button>
        </div>
      </el-upload>
    </el-dialog>
    <div id="map">
    </div>
  </div>
</template>

<script>
import { listManage, getManage, delManage, addManage, updateManage } from "@/api/system/manage";
import imageUpload from '@/components/ImageUpload'
import fileUpload from '@/components/FileUpload'
import AMapLoader from '@amap/amap-jsapi-loader';
import { getToken } from "@/utils/auth";
export default {
  name: "Manage",
  components: { imageUpload, fileUpload },
  data() {
    return {
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/system/manage/importData",
      fileType: ["xlsx", "xls"],
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 服务商管理表格数据
      manageList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      openToSee: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        storeName: null,
        storeNature: null,
        username: null,
        password: null,
        leader: null,
        leaderTel: null,
        serviceStatus: null,
        begintime: null,
        endtime: null,
        weekendStatus: null,
        holidayStatus: null,
        phone: null,
        isRegion: null,
        serviceRegion: null,
        address: null,
        settleTime: null,
        storeOnline: null,
        isOne: null,
        businessurl: null,
        storeurl: null,
        contracturl: null,
        creditCode: null,
        releaseScope: null,
        createDepartment: null,
        status: null,
        createTime: null,
        date: null,
        introduction: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      selectInfo: [],
      storeStatus: [
        {
          value: '0',
          label: '未审核'
        },
        {
          value: '1',
          label: '审核通过'
        },
        {
          value: '2',
          label: '不通过'
        },
      ],
      date: [],
      checked: [],
      center: [117.66275, 39.03068],
      map: null,
      openToUpload: false,
      scopeRelease: [],
      settleTime: [],
      settle: '',
      scope: null,
    };
  },
  created() {
    this.getList();
    this.getDicts('sys_business_nature').then(res => {
      this.selectInfo = res.data
    })
    this.getDicts('sys_release_scope').then(res => {
      this.scopeRelease = res.data
    })
    this.getDicts('sys_settle_time').then(res => {
      this.settleTime = res.data
    })
  },
  mounted() {
    this.createMap()
  },
  watch: {
    'form.date': {
      handler(val) {
        if (val) {
          this.form.begintime = val[0]
          this.form.endtime = val[1]
        }
      }
    },
    'form.settleTime': {
      handler(val) {
        if (val) {
          this.settle = this.settleTime[val].dictLabel
        }
      }
    },
    'form.releaseScope': {
      handler(val) {
        if (val) {
          let arr = JSON.parse(val)
          this.scope = []
          arr.map(item => {
            this.scope.push(this.scopeRelease[item].dictLabel)
          })
          this.scope = this.scope.join('、')
        }
      }
    }
  },
  methods: {
    handleUploadSuccess(res, file) {
      if (res.code != 200) {
        this.$modal.msgError(`上传模板不正确，请重新上传`);
        this.$modal.closeLoading()
        this.$refs.fileUpload.handleRemove(file);
      } else {
        this.modal.msgSuccess("导入成功");
        this.openToUpload = false
        this.resetQuery()
      }
    },
    handleBeforeUpload(file) {
      // 校检文件类型
      if (this.fileType) {
        const fileName = file.name.split('.');
        const fileExt = fileName[fileName.length - 1];
        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
        if (!isTypeOk) {
          this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
          return false;
        }
      }
      this.$modal.loading("正在上传文件，请稍候...");
      return true;
    },
    createMap() {
      let that = this
      window._AMapSecurityConfig = {
        securityJsCode: '6aaa52f268bd774edcc494a7055cf167',
      }
      AMapLoader.load({
        key: "533a73da5000e2db8d89b8fda02f33bf",       // 申请好的Web端开发者Key，首次调用 load 时必填
        version: "2.0",                 // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
      }).then((AMap) => {
        this.map = new AMap.Map('map', {
          zoom: 11,
          resizeEnable: true
        });
        this.map.plugin([
          'AMap.ToolBar',
          'AMap.Scale',
          'AMap.Geolocation',
        ], function () {
          that.map.addControl(new AMap.ToolBar({
            position: 'LT',
            locate: false
          }));
          that.map.addControl(new AMap.Scale());
          //   var getlocation = new AMap.Geolocation({
          //     needAddress: true,
          //     extensions: 'all',
          //     enableHighAccuracy: true,//是否使用高精度定位，默认:true
          //     timeout: 10000,          //超过10秒后停止定位，默认：5s
          //     position: 'RB',    //定位按钮的停靠位置
          //     offset: [10, 20], //定位按钮与设置的停靠位置的偏移量，默认：[10, 20]
          //     zoomToAccuracy: true,   //定位成功后是否自动调整地图视野到定位点
          //   })
          //   that.map.addControl(getlocation);
          //   document.querySelector('.amap-geolocation').onclick = function () {
          //   getlocation.getCurrentPosition(function (status, result) {
          //     console.log(result);
          //   });
          // }
        });
        let marker = new AMap.Marker()
        this.map.on('click', (e) => {
          let lnglat = [e.lnglat.lng, e.lnglat.lat]
          this.map.add(marker)
          marker.setPosition(lnglat)
        })
      })
    },
    checkeInfo(e) {
      this.form.releaseScope = JSON.stringify(e)
    },
    /** 查询服务商管理列表 */
    getList() {
      this.loading = true;
      listManage(this.queryParams).then(response => {
        this.manageList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.manageList.map(item => {
          if (item.releaseScope) {
            let arr = JSON.parse(item.releaseScope)
            item.service = []
            arr.map(i => {
              item.service.push(this.scopeRelease[i])
            })
          }
          // item.service = item.releaseScope ? JSON.parse(item.releaseScope).join('、') : ''
          // console.log(item.service);
        })
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        storeName: null,
        storeNature: null,
        username: null,
        password: null,
        leader: null,
        leaderTel: null,
        serviceStatus: null,
        begintime: null,
        endtime: null,
        weekendStatus: null,
        holidayStatus: null,
        phone: null,
        isRegion: null,
        serviceRegion: null,
        address: null,
        settleTime: null,
        storeOnline: null,
        isOne: null,
        businessurl: null,
        storeurl: null,
        contracturl: null,
        creditCode: null,
        releaseScope: null,
        createDepartment: null,
        status: null,
        createTime: null,
        introduction: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true;
      this.title = "添加服务商管理";
    },
    /** 修改按钮操作 */
    handleSee(row) {
      // this.reset();
      const id = row.id || this.ids
      getManage(id).then(response => {
        this.form = response.data;
        this.openToSee = true;
        // this.title = "修改服务商管理";
        this.selectInfo.map(item => {
          if (item.dictValue == this.form.storeNature) {
            this.form.storeNature = item.dictLabel
          }
        })
        if (this.form.releaseScope) {
            let releaseRound = JSON.parse(this.form.releaseScope)
            console.log(this.form.releaseRound);
            let releaseArr = []
            releaseRound.map(i => {
              releaseArr.push(this.scopeRelease[i].dictLabel)
            })
            this.form.releaseScope = releaseArr
          }
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getManage(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改服务商管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateManage(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addManage(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除服务商管理编号为"' + ids + '"的数据项？').then(function () {
        return delManage(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/manage/export', {
        ...this.queryParams
      }, `manage_${new Date().getTime()}.xlsx`)
    },
    handleUpload() {
      this.openToUpload = true
    },
    downloadTemplate() {
      this.download('system/manage/importTemplate', {
      }, `user_template_${new Date().getTime()}.xlsx`)
    }
  },
};
</script>
<style scoped>
.textline {
  height: 50px;
  line-height: 50px;
}

.rt-input /deep/ .el-input__inner {
  color: #000 !important;
  /* cursor: pointer; */
}

#map {
  width: 500px;
  height: 500px;
}
</style>