selectApplication.vue 4.11 KB
<template>
  <div>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="70%" :before-close="!dialogVisible">
      <span>
        <glsx-combi-form ref="showSearch" :formObj="searchForm" :formData="searchFormData">
          <span slot="footer" class="footer-btns">
            <el-button :size="size" type="primary" @click="handleSearch">搜索</el-button>
          </span>
        </glsx-combi-form>
        <el-row :gutter="20">
          <el-col :span="16">
            <GLTable ref="merchantTable" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :tableData="tableData" @selectionTable="selectionTable"></GLTable>
          </el-col>
          <el-col :span="8">
            <div>
              <div>
                <h4>已选列表</h4>
                <el-card class="box-card">
                  <!-- 展示内容 -->
                  <div>
                    <el-tag v-for="(tag, idx) in innerTags" :key="idx" type="info" closable :disable-transitions="false" @close="remove(tag)">
                      {{ tag.applicationName }}-{{ tag.applicationType }}
                    </el-tag>
                  </div>
                </el-card>
              </div>
            </div>
          </el-col>
        </el-row>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
  name: 'SelectApplication',
  data() {
    return {
      url,
      dialogVisible: false,
      mutiSelectArr: {},
      searchForm: {
        merchantName: ''
      },
      innerTags: [],
      searchFormData: [
        {
          label: '关键字:',
          name: 'merchantName',
          type: 'input',
          maxlength: 20,
          placeholder: '请输入应用名称进行搜索',
          isClear: true
        },
        {
          label: '应用类型:',
          name: 'merchantName',
          type: 'select',
          maxlength: 20,
          placeholder: '全部',
          isClear: true
        }
      ],
      tableParams: {
        listName: 'list',
        tableOption: false,
        // 行数据的key
        mutiSelectUniqueKey: 'id',
        // 多选ref的名称
        mutiSelectName: 'list',
        tableColumns: [
          {
            label: '应用名称',
            prop: 'applicationName',
            line: 2
          },
          {
            label: '应用类型',
            prop: 'applicationType',
            line: 2
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      tableData: [
        {
          id: 111,
          applicationName: '有点东西',
          applicationType: '小程序'
        },
        {
          id: 222,
          applicationName: '有点东西',
          applicationType: '小程序'
        },
        {
          id: 333,
          applicationName: '有点东西',
          applicationType: '小程序'
        },
        {
          id: 444,
          applicationName: '有点东西',
          applicationType: '小程序'
        },
        {
          id: 555,
          applicationName: '有点东西',
          applicationType: '小程序'
        }
      ]
    }
  },
  methods: {
    init() {
      this.dialogVisible = true
      this.mutiSelectArr = {}
    },
    handleSearch() {
      this.$refs.merchantTable.refreshTable()
    },
    // 多选
    selectionTable(val) {
      console.log(val)
      this.innerTags = val
    },
    // 提交选择业务应用
    handleConfirm() {
      // if (!this.mutiSelectArr.length) {
      //   this.$message({
      //     message: '请最少选择一条业务应用!',
      //     type: 'warning'
      //   })
      // }
      this.$emit('selectApplication', this.mutiSelectArr)
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
h4 {
  margin-top: 0;
  color: red;
}
.box-card {
  height: 120px;
  border: 1px solid rgb(61, 60, 60);
}
</style>