123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <div>
- <div style="display:flex">
- <!--<slot v-if="slot" name="slot"></slot>-->
- <div style="width: 100%;">
- <el-select style="width: 100%" v-model="selectValue" :size="size" :placeholder="placeholder"
- :filterable="filterable" :clearable="clearable" :remote="remote" :remote-method="remoteMethod"
- :multiple="multiple" :collapse-tags="collapseTags" :disabled="disabled" :allow-create="allowCreate"
- @change="corpChange" @focus="corpFocus" @clear="corpClear">
- <el-option v-for="item in datalist" :key="item[forParameter.key]" :label="item[forParameter.label]"
- :value="item[forParameter.value]"
- :disabled="item[forParameter.disabled] ? item[forParameter.disabled] == disabledStatus : false">
- <span v-if="!joinData" style="float: left">{{ item[forParameter.label] }}</span>
- <span v-if="joinData" style="float: left">
- <span v-if="!special">{{ item[forParameter.label] }} - {{ item[forParameter.short] }}</span>
- <span v-if="special">{{ item[forParameter.short] }} - {{ item[forParameter.label] }}</span>
- </span>
- <span v-if="desc" style="float: right; color: #8492a6; font-size: 13px">{{
- item[forParameter.desc]}}</span>
- </el-option>
- </el-select>
- </div>
- <div v-if="buttonIf" style="display: flex;align-items: center">
- <div class="bottonBox" v-if="tableIf" :class="disabled ? 'disabledBox' : ''" @click="bottonSearchfun">
- <i class="el-icon-search"></i>
- </div>
- <el-tooltip effect="dark" content="获取最新资料" placement="top-start">
- <div class="bottonBox" :class="disabled ? 'disabledBox' : ''" @click="refreshData"><i
- class="el-icon-refresh"></i></div>
- </el-tooltip>
- <el-tooltip v-if="addIf" effect="dark" content="新建数据" placement="top-start">
- <div class="bottonBox" :class="disabled ? 'disabledBox' : ''" @click="addJump"><i
- class="el-icon-plus"></i>
- </div>
- </el-tooltip>
- </div>
- </div>
- <el-dialog :title="title" :visible.sync="corpVisible" width="80%" top="5vh" append-to-body @closed="closed"
- class="el-dialogDeep" :close-on-click-modal="false" v-dialog-drag>
- <div>
- <el-row>
- <el-col :span="24">
- <slot></slot>
- </el-col>
- </el-row>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="corpVisible = false">取 消</el-button>
- <el-button type="primary" @click="confirm">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- // 弹窗关闭
- corpVisible: false,
- }
- },
- props: {
- // 选择框的数据
- datalist: {
- type: Array,
- default: []
- },
- // 选择框数据选择的参数
- forParameter: {
- type: Object,
- default: {
- key: 'value',
- label: 'label',
- value: 'value',
- disabled: false,
- desc: 'desc'
- }
- },
- // 两个按钮是否显示
- buttonIf: {
- type: Boolean,
- default: true,
- },
- // 绑定的值
- selectValue: {
- default: null
- },
- // 是否禁用
- disabled: {
- type: Boolean,
- default: false
- },
- // 是否多选
- multiple: {
- type: Boolean,
- default: false
- },
- // 多选时是否将选中值按文字的形式展示
- collapseTags: {
- type: Boolean,
- default: false
- },
- // 是否可以搜索
- filterable: {
- type: Boolean,
- default: false
- },
- // 是否可以创建条目
- allowCreate: {
- type: Boolean,
- default: false
- },
- // 是否为远程搜索
- remote: {
- type: Boolean,
- default: false
- },
- // 是否可以清空选择项
- clearable: {
- type: Boolean,
- default: false
- },
- // 弹窗的标题
- title: {
- type: String,
- default: '选择数据'
- },
- // 是否禁用
- disabledStatus: {
- type: Number,
- default: 1
- },
- // 未输入的文字提示
- placeholder: {
- type: String,
- default: '请选择'
- },
- // 表格按钮
- tableIf: {
- type: Boolean,
- default: true
- },
- // 添加跳转按钮
- addIf: {
- type: Boolean,
- default: false
- },
- // 尺寸大小
- size: {
- type: String,
- default: 'small'
- },
- desc: {
- type: Boolean,
- default: false
- },
- joinData: {
- type: Boolean,
- default: false
- },
- joinType: {
- type: Number,
- default: 1
- },
- special: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- // // 监听
- // selectValue:{
- // // 执行方法
- // handler(oldValue,newValue) {
- // console.log(oldValue,145)
- // console.log(newValue,146)
- // },
- // deep: true, // 深度监听
- // immediate: true // 第一次改变就执行
- // },
- },
- methods: {
- addJump() {
- if (this.disabled) {
- return
- }
- this.$emit('addJump')
- },
- // 聚焦事件
- corpFocus() {
- this.$emit('corpFocus')
- },
- corpClear() {
- this.$emit('corpClear')
- },
- // 下拉change
- corpChange(value) {
- this.$emit('corpChange', value)
- this.selectValue = value
- },
- /* 远程模糊查询操作用户 */
- remoteMethod(name) {
- if (name == null || name === "") {
- return false;
- }
- this.$emit('remoteMethod', name)
- },
- // 获取最新数据
- refreshData() {
- if (this.disabled) {
- return
- }
- this.$emit('remoteMethod')
- },
- // 弹窗确认事件
- confirm() {
- // this.corpVisible = false
- this.$emit('eldialogConfirm')
- },
- // 打开弹窗
- bottonSearchfun() {
- if (this.disabled) return
- if (!this.disabled) {
- this.corpVisible = true
- this.$emit('bottonSearchfun')
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .bottonBox {
- height: 32px;
- background: #FFF;
- border: 1px solid #DCDFE6;
- font-size: 12px;
- border-radius: 3px;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 10px;
- box-sizing: border-box;
- }
- .disabledBox {
- color: #C0C4CC;
- cursor: not-allowed;
- background-image: none;
- background-color: #FFF;
- border-color: #EBEEF5;
- }
- </style>
|