index.vue 9.04 KB
<template>
  <div class="scrm-main">
    <div class="form-header" v-if="$globalState.session.accountLevel == 1 && $globalState.session.merchantModel == 1">
      <el-button type="primary" @click="handleContact" size="small" icon="el-icon-link"
        >门店账户关联企微</el-button
      >
    </div>
    <div class="follow-form">
      <el-form :inline="true" :model="searchForm" class="follow-form-item" label-width="80px">
        <el-row>
          <el-form-item size="small" label="关联企微">
            <el-select v-model="searchForm.isRelevance" placeholder="请选择">
              <el-option v-for="item in optionsContact" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="merchant-row" size="small">
            <el-input
              size="small"
              v-model="searchForm.merchantLoginAccount"
              placeholder="请输入"
              v-if="searchForm.accountOrPhone == 1"
            >
              <el-select
                size="small"
                v-model="searchForm.accountOrPhone"
                 @change="searchForm.merchantLoginAccount = '';searchForm.merchantLegalPersonPhone = ''"
                slot="prepend"
                placeholder="请选择"
              >
                <el-option label="登录账户名" :value="1"></el-option>
                <el-option label="手机号" :value="2"></el-option>
              </el-select>
            </el-input>
            <el-input
              size="small"
              v-model="searchForm.merchantLegalPersonPhone"
              placeholder="请输入"
              v-if="searchForm.accountOrPhone == 2"
            >
              <el-select
                size="small"
                v-model="searchForm.accountOrPhone"
                slot="prepend"
                @change="searchForm.merchantLoginAccount = '';searchForm.merchantLegalPersonPhone = ''"
                placeholder="请选择"
              >
                <el-option label="登录账户名" :value="1"></el-option>
                <el-option label="手机号" :value="2"></el-option>
              </el-select>
            </el-input>
          </el-form-item>
          <el-form-item size="small" label="账户状态">
            <el-select size="small" v-model="searchForm.status" placeholder="请选择">
              <el-option v-for="item in merchantStatus" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item size="small" label="账户等级">
            <el-select size="small" v-model="searchForm.merchantAccountLevel" placeholder="请选择">
              <el-option v-for="item in accountLevel" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="merchant-wx" size="small">
            <el-input size="small" v-model="searchForm.merchantName" placeholder="请输入商户名称/关联的企业微信名"></el-input>
          </el-form-item>
          <el-form-item size="small" style="float: right">
            <el-button type="primary" @click="handleSearch">查询</el-button>
          </el-form-item>
        </el-row>
      </el-form>
      <GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="handleSearch">
        <div slot="accountTypeNames" slot-scope="scope">
          <div class="accountType-row" v-for="(item, index) in scope.scope.accountTypeNames.split(',')" :key="index">
            {{ item }}
          </div>
        </div>
        <template slot="auth-button" slot-scope="scope" :data="scope.scope">
          <el-button type="text" @click="handleLook(scope.scope)">查看</el-button>
          <el-button type="text" @click="handleEdit(scope.scope)" v-if="$globalState.session.merchantId != scope.scope.merchantNo">修改</el-button>
          <el-button type="text" @click="handleAdd(scope.scope)" v-if="scope.scope.status == 2 && scope.scope.merchantAccountLevel != 4">创建子商户/门店</el-button>
        </template>
      </GLTable>
    </div>
  </div>
</template>

<script>
const optionsContact = [
  {
    value: '',
    label: '全部'
  },
  {
    value: '1',
    label: '已关联'
  },
  {
    value: '2',
    label: '未关联'
  }
]
export default {
  name: 'index',
  data() {
    return {
      drawer: false,
      direction: 'rtl',
      searchForm: {
        accountOrPhone: 1,
        merchantLegalPersonPhone: '',
        merchantLoginAccount: ''
      },
      optionsContact,
      accountLevel: [],
      accountType: [],
      merchantStatus: [],
      scope: {
        scope: ''
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 表格参数
      tableParams: {
        tableOption: {
          width: '150px'
        },
        mutiSelectName: 'merchant',
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        tableColumns: [
          {
            label: '商户名',
            prop: 'merchantName'
          },
          {
            label: "关联的企业微信",
            prop: "entmicroName",
            formatter: (cellValue) => {
              return cellValue.entmicroName ? cellValue.entmicroName : "-";
            },
          },
          {
            label: '账户类型',
            prop: 'accountTypeNames',
            addHtml: 'accountTypeNames'
          },
          {
            label: '登录账户',
            prop: 'merchantLoginAccount'
          },
          {
            label: '账户等级',
            prop: 'accountLevelName',
            width: '80px'
          },
          {
            label: "上级商户",
            prop: "parentMerchant",
            formatter: (cellValue) => {
              return cellValue.parentMerchant ? cellValue.parentMerchant : "-";
            },
          },
          {
            label: '账户状态',
            prop: 'statusName',
            width: '80px'
          },
          {
            label: "联系人",
            prop: "merchantLegalPerson",
            formatter: (cellValue) => {
              return cellValue.merchantLegalPerson ? cellValue.merchantLegalPerson : "-";
            },
          },
          {
            label: '手机号',
            prop: 'merchantLegalPersonPhone',
            width: '120px'
          },
          {
            label: "更新时间",
            prop: "updatedTime",
          },
        ],
      },
      layout: 'sizes, prev, pager, next, jumper, ->, total',
      tableData: [],
      tableTotal: 0
    }
  },
  methods: {
    handleContact() {
      this.$router.push('/baseInfo/relevance/')
    },
    handleLook(scope) {
      this.$router.push('/account/detailAccount/' + scope.id)
    },
    handleEdit(scope) {
      this.$router.push('/account/editAccount/' + scope.id)
    },
    handleAdd(scope) {
      this.$router.push('/account/addAccount/' + scope.id)
    },
    findAllDictData(dictType) {
      var params = {
        dictType
      }
      this.$apis.store.findAllDictData(params).then(res => {
        if (res) {
          if (dictType == "account_level") {
            this.accountLevel = [{ dictValue: "", dictLabel: "全部" }].concat(res);
          }
          if (dictType == 'account_type') {
            this.accountType = res
          }
          if (dictType == "merchant_status") {
            this.merchantStatus = [{ dictValue: "", dictLabel: "全部" }].concat(res);
          }
        }
      })
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        // 调接口前,操作
        resolve()
      })
    },
    handleSearch() {
      var params = {
        ...JSON.parse(JSON.stringify(this.searchForm)),
        pageSize: this.$refs.table.page.pageSize,
        pageNum: this.$refs.table.page.pageNum
      }
      this.$apis.store.findMerchantByPage(params).then(res => {
        this.tableData = res.data
        this.tableTotal = res.count
        if (res.data && res.data.length == []) {
          this.$refs.table.setTableHeightFun()
        }
      })
    }
  },

  mounted() {
    this.handleSearch()
    this.findAllDictData('account_level')
    this.findAllDictData('account_type')
    this.findAllDictData('merchant_status')
  }
}
</script>

<style scoped lang="scss">
.follow-form {
  margin-top: 20px;
  background: #ffffff;
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  padding: 20px;
}
.accountType-row {
  text-align: left;
  position: relative;
  padding-left: 15px;
  &::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #5850ff;
    border-radius: 8px;
    left: 0px;
    top: 7px;
  }
}
.merchant-row {
  margin-left: 20px;
  /deep/ {
    .el-form-item__content {
      line-height: 1;
    }
    .el-select {
      .el-input {
        width: 110px;
      }
    }
  }
}
.merchant-wx {
  margin-left: 20px;
  /deep/ {
    .el-input__inner {
      width: 310px;
    }
  }
}
</style>