index.vue 4.06 KB
<template>
  <div class="system-container vehicle">
    <div class="container">
      <search-form
        class="searchTop border-shadow"
        :formModel="searchForm"
        :formList="shopFormList"
      >
        <slot name="form-slot">
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="shopTableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
          >重置</el-button>
        </slot>
      </search-form>
      <h3>
        <el-button
          v-for="item in authList"
          :key="item.id"
          :type="item.type"
          :size="btn_size"
          @click="btnClick(item.pType)"
        >{{item.name}}</el-button>
      </h3>
      <basic-table
        ref="roleTable"
        :tableParams="shopTableParams"
        :getListApi="getListApi"
        :searchForm="searchForm"
        :hasNum="false"
      >
        <span
          slot="status"
          slot-scope="scope"
        >
          <span
            class="dot"
            :class="scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[1] : ''"
          ></span>
          <span class="statusText">{{ scope.scope.enableStatus ? USERSTATUS[scope.scope.enableStatus].split(',')[0] : '--'}}</span>
        </span>
        <span
          slot="table-button"
          slot-scope="scope"
        >
          <el-button
            v-for="(j, idx) in shopTableParams.tableOption.btnList"
            :key="idx"
            :type="j.type"
            size="mini"
            plain
            @click="btnClick(j.pType, scope.scope)"
          >{{j.name}}</el-button>
        </span>
      </basic-table>
    </div>
  </div>
</template>

<script>
import { getList } from 'services/specialshop'
export default {
  data() {
    return {
      searchForm: {},
      shopFormList: [
        {
          label: '关键字:',
          type: 'input',
          inputType: 'text',
          prop: 'term',
          placeholder: '特约店编码|特约店名称',
        }
      ],
      shopTableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        mutiSelectName: 'specialShop',
        listName: 'list',
        tableColumns: [
          {
            label: '特约店编码',
            prop: 'shopCode'
          }, {
            label: '特约店名称',
            prop: 'shopName'
          }, {
            label: '店级别',
            prop: 'shopLevel'
          }, {
            label: '所属大区',
            prop: 'area'
          }, {
            label: '所属省',
            prop: 'province'
          }, {
            label: '所属市',
            prop: 'city'
          }, {
            label: '详细地址',
            prop: 'address'
          }, {
            label: '店围栏名',
            prop: 'fenceName'
          }
        ],
        tableOption: {
          width: 300,
          btnList: [
            {
              type: 'danger',
              name: '删除',
              pType: 'delete'
            },
            {
              type: 'primary',
              name: '编辑',
              pType: 'edit'
            },
            {
              type: 'primary',
              name: '查看',
              pType: 'edit'
            }
          ]
        }
      },
      getListApi: getList,
      authList: [
        {
          id: 1,
          name: '新增特约店',
          type: 'primary',
          pType: 'create'
        },
        {
          id: 2,
          name: '批量删除',
          type: 'default',
          pType: 'delete'
        },
        {
          id: 3,
          name: '批量导出',
          type: 'default',
          pType: 'export'
        }
      ]
    }
  },
  methods: {
    btnClick(pType, scope) {
      console.log(pType)
      switch (pType) {
        case 'create':
          this.$router.push({ name: 'addShop' })
          break
      }
    }
  },
}
</script>

<style>
.vehicle .el-form .el-input__inner {
  width: 300px;
}
</style>