<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商家名称" prop="shopName">
        <el-input
          v-model="queryParams.shopName"
          placeholder="请输入商家名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商家电话" prop="shopPhone">
        <el-input
          v-model="queryParams.shopPhone"
          placeholder="请输入商家电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账号" prop="shopAccount">
        <el-input
          v-model="queryParams.shopAccount"
          placeholder="请输入账号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="经营时间开始" prop="shopBusinessBegin">-->
<!--        <el-input-->
<!--          v-model="queryParams.shopBusinessBegin"-->
<!--          placeholder="请输入经营时间开始"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="经营时间结束" prop="shopBusinessEnd">-->
<!--        <el-input-->
<!--          v-model="queryParams.shopBusinessEnd"-->
<!--          placeholder="请输入经营时间结束"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="商家金额" prop="shopMoney">-->
<!--        <el-input-->
<!--          v-model="queryParams.shopMoney"-->
<!--          placeholder="请输入商家金额"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="省份ID" prop="provinceId">-->
<!--        <el-input-->
<!--          v-model="queryParams.provinceId"-->
<!--          placeholder="请输入省份ID"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="省份名称" prop="provinceName">-->
<!--        <el-input-->
<!--          v-model="queryParams.provinceName"-->
<!--          placeholder="请输入省份名称"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="城市ID" prop="cityId">-->
<!--        <el-input-->
<!--          v-model="queryParams.cityId"-->
<!--          placeholder="请输入城市ID"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="城市名称" prop="cityName">-->
<!--        <el-input-->
<!--          v-model="queryParams.cityName"-->
<!--          placeholder="请输入城市名称"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="区域ID" prop="areaId">-->
<!--        <el-input-->
<!--          v-model="queryParams.areaId"-->
<!--          placeholder="请输入区域ID"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="区域名称" prop="areaName">-->
<!--        <el-input-->
<!--          v-model="queryParams.areaName"-->
<!--          placeholder="请输入区域名称"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="地址" prop="address">-->
<!--        <el-input-->
<!--          v-model="queryParams.address"-->
<!--          placeholder="请输入地址"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="经度" prop="longitude">-->
<!--        <el-input-->
<!--          v-model="queryParams.longitude"-->
<!--          placeholder="请输入经度"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="纬度" prop="latitude">-->
<!--        <el-input-->
<!--          v-model="queryParams.latitude"-->
<!--          placeholder="请输入纬度"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="访客数量" prop="visitorCount">-->
<!--        <el-input-->
<!--          v-model="queryParams.visitorCount"-->
<!--          placeholder="请输入访客数量"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="商家状态" prop="shopStatus">
        <el-select v-model="queryParams.shopStatus" placeholder="请选择商家状态" clearable size="small">
          <el-option label="正常" value="0" />
          <el-option label="冻结" value="1" />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="创建时间" prop="createAt">-->
<!--        <el-input-->
<!--          v-model="queryParams.createAt"-->
<!--          placeholder="请输入创建时间"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="更新时间" prop="updateAt">-->
<!--        <el-input-->
<!--          v-model="queryParams.updateAt"-->
<!--          placeholder="请输入更新时间"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </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="['mall:mallShopShop: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="['mall:mallShopShop: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="['mall:mallShopShop:remove']"
        >删除</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          :loading="exportLoading"-->
<!--          @click="handleExport"-->
<!--          v-hasPermi="['mall:mallShopShop:export']"-->
<!--        >导出</el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="mallShopShopList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="商家ID" align="center" prop="shopId" />-->
<!--      <el-table-column label="系统用户ID" align="center" prop="sysUserId" />-->
      <el-table-column label="商家名称" align="center" prop="shopName" />
      <el-table-column label="商家电话" align="center" prop="shopPhone" />
      <el-table-column label="账号" align="center" prop="shopAccount" />
<!--      <el-table-column label="密码" align="center" prop="shopPassword" />-->
<!--      <el-table-column label="商家主图" align="center" prop="shopImage" />-->
<!--      <el-table-column label="商家轮播图" align="center" prop="shopBanner" />-->
<!--      <el-table-column label="营业执照" align="center" prop="shopLicense" />-->
<!--      <el-table-column label="经营许可" align="center" prop="shopPermit" />-->
<!--      <el-table-column label="经营时间开始" align="center" prop="shopBusinessBegin" />-->
<!--      <el-table-column label="经营时间结束" align="center" prop="shopBusinessEnd" />-->
<!--      <el-table-column label="商家金额" align="center" prop="shopMoney" />-->
<!--      <el-table-column label="省份ID" align="center" prop="provinceId" />-->
      <el-table-column label="省份" align="center" prop="provinceName" />
<!--      <el-table-column label="城市ID" align="center" prop="cityId" />-->
      <el-table-column label="城市" align="center" prop="cityName" />
<!--      <el-table-column label="区域ID" align="center" prop="areaId" />-->
      <el-table-column label="区域" align="center" prop="areaName" />
      <el-table-column label="地址" align="center" prop="address" />
<!--      <el-table-column label="经度" align="center" prop="longitude" />-->
<!--      <el-table-column label="纬度" align="center" prop="latitude" />-->
<!--      <el-table-column label="访客数量" align="center" prop="visitorCount" />-->
      <el-table-column label="商家状态" align="center" prop="shopStatus" >
        <template slot-scope="scope">
          <div v-if="scope.row.shopStatus == 0">正常</div>
          <div v-if="scope.row.shopStatus == 1">冻结</div>
        </template>
      </el-table-column>
      <el-table-column label="供应商" align="center" width="80px" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getShopSupplierList(scope.row)">供应商</el-link>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createAt" width="160" />
<!--      <el-table-column label="更新时间" align="center" prop="updateAt" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-key"
            @click="openResetPwd(scope.row.shopId)"
            v-hasPermi="['mall:mallShopShop:edit']"
          >重置密码</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['mall:mallShopShop:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['mall:mallShopShop: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="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<!--        <el-form-item label="系统用户ID" prop="sysUserId">-->
<!--          <el-input v-model="form.sysUserId" placeholder="请输入系统用户ID" />-->
<!--        </el-form-item>-->
        <el-form-item label="商家名称" prop="shopName">
          <el-input v-model="form.shopName" placeholder="请输入商家名称" />
        </el-form-item>
        <el-form-item label="商家电话" prop="shopPhone">
          <el-input v-model="form.shopPhone" placeholder="请输入商家电话" />
        </el-form-item>
        <el-form-item label="账号" prop="shopAccount">
          <el-input v-model="form.shopAccount" placeholder="请输入账号" />
        </el-form-item>
        <el-form-item label="密码" prop="shopPassword" v-if="form.shopId == null">
          <el-input v-model="form.shopPassword" placeholder="请输入密码" :showPassword="true" />
        </el-form-item>
<!--        <el-form-item label="商家主图">-->
<!--          <imageUpload v-model="form.shopImage"/>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="商家轮播图" prop="shopBanner">-->
<!--          <el-input v-model="form.shopBanner" type="textarea" placeholder="请输入内容" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="营业执照" prop="shopLicense">-->
<!--          <el-input v-model="form.shopLicense" type="textarea" placeholder="请输入内容" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="经营许可" prop="shopPermit">-->
<!--          <el-input v-model="form.shopPermit" type="textarea" placeholder="请输入内容" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="经营时间开始" prop="shopBusinessBegin">-->
<!--          <el-input v-model="form.shopBusinessBegin" placeholder="请输入经营时间开始" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="经营时间结束" prop="shopBusinessEnd">-->
<!--          <el-input v-model="form.shopBusinessEnd" placeholder="请输入经营时间结束" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="商家金额" prop="shopMoney">-->
<!--          <el-input v-model="form.shopMoney" placeholder="请输入商家金额" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="省份名称" prop="provinceName">-->
<!--          <el-input v-model="form.provinceName" placeholder="请输入省份名称" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="城市名称" prop="cityName">-->
<!--          <el-input v-model="form.cityName" placeholder="请输入城市名称" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="区域名称" prop="areaName">-->
<!--          <el-input v-model="form.areaName" placeholder="请输入区域名称" />-->
<!--        </el-form-item>-->
        <el-row>
          <el-col :span="parseInt(8)">
            <el-form-item label="省份" prop="provinceId">
              <el-select v-model="form.provinceId" placeholder="请选择省份" clearable filterable @change="getCityList">
                <el-option
                  v-for="item in provinceList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="parseInt(8)">
            <el-form-item label="城市" prop="cityId">
              <el-select v-model="form.cityId" no-data-text="请先选择省份" placeholder="请选择城市" clearable filterable @change="getAreaList">
                <el-option
                  clearable
                  v-for="item in cityList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="parseInt(8)">
            <el-form-item label="区域" prop="areaId">
              <el-select v-model="form.areaId" no-data-text="请先选择城市" placeholder="请选择区域" clearable filterable>
                <el-option
                  clearable
                  v-for="item in areaList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址" />
        </el-form-item>
<!--        <el-form-item label="经度" prop="longitude">-->
<!--          <el-input v-model="form.longitude" placeholder="请输入经度" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="纬度" prop="latitude">-->
<!--          <el-input v-model="form.latitude" placeholder="请输入纬度" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="访客数量" prop="visitorCount">-->
<!--          <el-input v-model="form.visitorCount" placeholder="请输入访客数量" />-->
<!--        </el-form-item>-->
        <el-form-item label="商家状态">
          <el-radio-group v-model="form.shopStatus">
            <el-radio :label="0">正常</el-radio>
            <el-radio :label="1">冻结</el-radio>
          </el-radio-group>
        </el-form-item>
<!--        <el-form-item label="创建时间" prop="createAt">-->
<!--          <el-input v-model="form.createAt" placeholder="请输入创建时间" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="更新时间" prop="updateAt">-->
<!--          <el-input v-model="form.updateAt" placeholder="请输入更新时间" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="删除标记" prop="delFlag">-->
<!--          <el-input v-model="form.delFlag" placeholder="请输入删除标记" />-->
<!--        </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="rePwdOpen" width="500px" append-to-body>
      <el-form ref="rePwdForm" :model="rePwdForm" :rules="rePwdRules" label-width="80px">
        <el-form-item label="新密码" prop="newPassword">
          <el-input type="password" :showPassword="true" v-model="rePwdForm.newPassword" placeholder="请输入新密码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitResetPassword">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--供应商列表-->
    <el-dialog title="供应商列表" :visible.sync="openShopSupplierList" width="1000px" append-to-body>
      <mall-shop-supplier :shopId="shopId" :key="shopId" />
      <div slot="footer" class="dialog-footer">
        <el-button @click="openShopSupplierListCancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listMallShopShop,
  getMallShopShop,
  delMallShopShop,
  addMallShopShop,
  updateMallShopShop,
  exportMallShopShop,
  resetPasswordShop, getRegionByPid
} from "@/api/mall/mallShopShop";
import {resetPassword} from "@/api/mall/mallSalesman";
import MallShopSupplier from "@/views/mall/mallShopSupplier";

export default {
  name: "MallShopShop",
  components: {MallShopSupplier},
  data() {
    return {
      // 供应商列表弹窗开关
      openShopSupplierList: false,
      provinceList:[],
      cityList:[],
      areaList:[],
      rePwdForm:{},
      rePwdOpen:false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商家管理表格数据
      mallShopShopList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sysUserId: null,
        shopName: null,
        shopPhone: null,
        shopAccount: null,
        shopPassword: null,
        shopImage: null,
        shopBanner: null,
        shopLicense: null,
        shopPermit: null,
        shopBusinessBegin: null,
        shopBusinessEnd: null,
        shopMoney: null,
        provinceId: null,
        provinceName: null,
        cityId: null,
        cityName: null,
        areaId: null,
        areaName: null,
        address: null,
        longitude: null,
        latitude: null,
        visitorCount: null,
        shopStatus: null,
        createAt: null,
        updateAt: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        shopName: [
          { required: true, message: "商家名称不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '商家名称长度必须介于 2 和 20 之间', trigger: 'blur' }
        ],
        shopPhone: [
          { required: true, message: "商家手机号不能为空", trigger: "blur" },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ],
        shopAccount: [
          { required: true, message: "商家账号不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '商家账号长度必须介于 5 和 20 之间', trigger: 'blur' }
        ],
        shopPassword: [
          { required: true, message: "密码不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '密码长度必须介于 5 和 20 之间', trigger: 'blur' }
        ],
      },
      // 表单校验
      rePwdRules: {
        newPassword: [
          { required: true, message: "新密码不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '新密码长度必须介于 2 和 20 之间', trigger: 'blur' }
        ]
      },
    };
  },
  created() {
    this.getList();
    // 加载省份列表
    this.getProvinceList();
  },
  methods: {
    openShopSupplierListCancel() {
      this.shopId = null;
      this.openShopSupplierList = false;
    },
    /** 供应商列表弹窗 */
    getShopSupplierList(row) {
      this.shopId = row.shopId;
      this.openShopSupplierList = true;
    },

    /** 获取省份列表 */
    getProvinceList(){
      getRegionByPid(0).then(response =>{
        this.provinceList = response.data
      })
    },
    /** 获取城市列表 */
    getCityList(pid){
      this.cityList = []
      getRegionByPid(pid).then(response =>{
        this.cityList = response.data
      })
    },
    /** 获取区域列表 */
    getAreaList(pid){
      this.areaList = []
      getRegionByPid(pid).then(response =>{
        this.areaList = response.data
      })
    },
    /** 打开重置密码弹框 */
    openResetPwd(shopId){
      this.reset();
      this.rePwdForm.shopId = shopId;
      this.rePwdOpen = true;
    },
    /** 重置密码提交 */
    submitResetPassword(){
      this.$refs["rePwdForm"].validate(valid => {
        if (valid) {
          resetPasswordShop(this.rePwdForm).then(res => {
            this.msgSuccess("修改成功");
            this.rePwdOpen = false;
            this.reset()
          })
        }
      })
    },


    /** 查询商家管理列表 */
    getList() {
      this.loading = true;
      listMallShopShop(this.queryParams).then(response => {
        this.mallShopShopList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.rePwdOpen = false
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        shopId: null,
        sysUserId: null,
        shopName: null,
        shopPhone: null,
        shopAccount: null,
        shopPassword: null,
        shopImage: null,
        shopBanner: null,
        shopLicense: null,
        shopPermit: null,
        shopBusinessBegin: null,
        shopBusinessEnd: null,
        shopMoney: null,
        provinceId: null,
        provinceName: null,
        cityId: null,
        cityName: null,
        areaId: null,
        areaName: null,
        address: null,
        longitude: null,
        latitude: null,
        visitorCount: null,
        shopStatus: 0,
        createAt: null,
        updateAt: null,
        delFlag: null
      };
      this.rePwdForm = {
        shopId: '',
        oldPassword: '',
        newPassword: ''
      };
      this.resetForm("form");
      this.resetForm("rePwdForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.shopId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加商家管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const shopId = row.shopId || this.ids
      getMallShopShop(shopId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改商家管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.shopId != null) {
            updateMallShopShop(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMallShopShop(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const shopIds = row.shopId || this.ids;
      this.$confirm('是否确认删除商家管理编号为"' + shopIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delMallShopShop(shopIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有商家管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportMallShopShop(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
