fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
  <el-dialog class="filterDialog" :title="title" :visible.sync="dialogShow" :show-close="true"
             :close-on-click-modal="false" :modal-append-to-body="false" v-if="dialogShow"
             :append-to-body="appendToBody" :width="dialogWidth">
    <list-condition-template ref="table" :form="form" :formLabel="formLabel" v-loading="loading"
                             element-loading-custom-class="customLoading" :tableData="tableData"
                             :total="total" :multipleSelected="multipleSelected"
                             @page-info-change="handlePageInfoChange" @selected="handleSelected"
                             :emptyText="emptyText" :isShowPage="isShowPage"
                             :limiteSelectedNum="limiteSelectedNum">
      <template slot="otherElement" slot-scope="scope">
         <slot name="condition" :data="scope.data"></slot>
      </template>
      <template slot="columns">
        <slot name="columns"></slot>
      </template>
    </list-condition-template>
    <div slot="footer" class="dialog-footer">
      <el-button size="mini" type="primary" v-if="multipleSelected" @click="closeDialog">确定
      </el-button>
      <el-button size="mini" @click="dialogShow = false">关闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  props: {
    /**
         * 对话框显示状态
         */
    show: {
      type: Boolean,
      default: false
    },
    /**
         * 数据行
         */
    tableData: {
      type: Array,
      default: function () {
        return []
      }
    },
    /**
         * 数据总数
         */
    total: {
      type: Number,
      default: 0
    },
    title: {
      type: String,
      default: '添加品牌'
    },
    /**
         * 是否嵌套弹出框
         */
    appendToBody: {
      type: Boolean,
      default: false
    },
    /**
         * 表格遮罩
         */
    loading: {
      type: Boolean,
      default: false
    },
    /**
         * 查询条件
         */
    form: {
      type: Object,
      default: function () {
        return {}
      }
    },
    /**
         *标签数据
         */
    formLabel: {
      type: Array,
      default: function () {
        return []
      }
    },
    /**
     * 是否多选
     */
    multipleSelected: {
      type: Boolean,
      default: false
    },
    /**
     * 表格空数据时显示文字
     */
    emptyText: {
      type: String,
      default: '暂无数据'
    },
    isShowPage: {
      type: Boolean,
      default: true
    },
    /**
     * 限制勾选个数
     */
    limiteSelectedNum: {
      type: Number,
      default: null
    },
    /**
   * 弹出框默认宽度
   */
    dialogWidth: {
      type: String,
      default: '50%'
    }
  },
  data () {
    return {
      dialogShow: false
    }
  },
  watch: {
    /**
         * 监控外部显示变量变化
         * 传递到dialog组件
         */
    show: function (newShow, oldShow) {
      this.dialogShow = newShow
      if (this.dialogShow) {
        this.$emit('page-info-change', { pageNum: 1, pageSize: 10 })
      }
    },
    /**
         * 监控内部显示属性变化
         * 传递到外部调用变量
         */
    dialogShow: function (newDialogShow, oldDialogShow) {
      this.$emit('update:show', newDialogShow)
    }
  },
  methods: {
    /**
     * 重置条件
     */
    reloadCurrent () {
      this.$refs.table.reloadCurrent()
    },
    /**
     * 主动关闭对话框
     */
    closeDialog () {
      this.$emit('update:show', false)
      this.onClose()
    },
    /**
     * 触发关闭事件
     */
    onClose () {
      this.$emit('close')
    },
    /**
     * 行选中事件处理
     * @param {*} rows 行数据
     */
    handleSelected (rows) {
      this.$emit('selected', rows)
    },
 
    /**
         * 当分页信息变动的时候
         */
    handlePageInfoChange (pageInfo) {
      this.onPageInfoChage(pageInfo)
    },
    /**
         * 触发分页信息变化事件
         */
    onPageInfoChage (pageInfo) {
      this.$emit('page-info-change', pageInfo)
    },
    /**
         * 重置条件并触发条件变化事件
         */
    changeCondition () {
      this.$refs.table.changeCondition()
    }
  }
}
</script>
<style lang="scss">
.filterDialog {
  .commonForm,
  .main-b-style {
    padding: 0;
  }
}
</style>