ludc
2024-07-04 328b0158c3d97f87efc7da22a1e3f5a7c258b127
Source/plt-web/plt-web-ui/src/components/PLT-basic-component/transfer.vue
@@ -1,59 +1,59 @@
<template>
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      :destroy-on-close="true"
      :title="title"
      :visible.sync="visible"
      append-to-body="true"
      class="avue-dialog"
      style="text-align: center"
      width="40%"
      @close="dialogClose">
      <el-transfer
        v-model="rightRoleData"
        v-loading="loading"
        :data="data"
        :filter-method="filterMethod"
        :render-content="renderFunc"
        :titles="['现有角色', '拥有角色']"
        filter-placeholder="角色名称搜索"
        filterable
        style="text-align: left; display: inline-block;">
      </el-transfer>
      <span slot="footer" class="dialog-footer">
    <el-button @click="visible = false">取 消</el-button>
    <el-button type="primary" @click="sendHandler">确 定</el-button>
  </span>
    </el-dialog>
  <el-dialog
    v-dialogDrag
    :close-on-click-modal="false"
    :destroy-on-close="true"
    :title="title"
    :visible.sync="visible"
    append-to-body="true"
    class="avue-dialog"
    style="text-align: center"
    width="50%"
    @close="dialogClose">
    <el-transfer
      v-model="rightRoleData"
      v-loading="loading"
      :data="data"
      :filter-method="filterMethod"
      :render-content="renderFunc"
      :titles="transferTitle"
      filter-placeholder="关键词搜索"
      filterable
      style="text-align: left; display: inline-block;">
    </el-transfer>
    <div slot="footer" class="dialog-footer">
      <div class="valueInfo" v-if="bottomValue">已设置的值为:[{{bottomValue}}]</div>
      <el-button @click="visible = false" size="small">取 消</el-button>
      <el-button type="primary" @click="sendHandler" size="small">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "transfer",
  props: ['title', 'leftRoleData', 'rightRoleData'],
  props: ['title', 'leftRoleData', 'rightRoleData', 'transferTitle' , 'bottomValue'],
  data() {
    return {
      visible: false, // 通过 this.$refs.transfer.visible = true; 开启子组件对话框
      data: [],
      value: [],
      loading: false,
      filterMethod(query, item) {
        return item.label.indexOf(query) > -1;
      },
      renderFunc(h, option) {
        return <span><i class="el-icon-s-custom"></i> { option.label }</span>;
        return <span><i class="el-icon-s-custom"></i> {option.label}</span>;
      }
    }
  },
  watch: {
    //渲染穿梭框
    leftRoleData: {
      handler(newval, oldval) {
      handler(newval) {
        if (newval) {
          // 清空data数组
          this.data = [];
          newval.forEach((city, index) => {
          newval.forEach((city) => {
            this.data.push({
              label: city.name,
              key: city.oid,
@@ -82,11 +82,20 @@
</script>
<style lang="scss" scoped>
/deep/ .el-transfer-panel{ /* 左右两个穿梭框的高度和宽度 */
  height: 450px;
/deep/ .el-transfer-panel {
  height: 450px; /* 左右两个穿梭框的高度和宽度 */
  width: 300px;
}
/deep/ .el-transfer-panel__list.is-filterable {
  height: 323px; /* 穿梭框列表高度 */
}
.valueInfo{
  float: left;
  border: 1px solid #E9E7E7;
  display: inline-block;
  vertical-align: middle;
  padding: 6px 12px;
  line-height: 1;
}
</style>