searchquery.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div>
  3. <div style="display:flex">
  4. <!--<slot v-if="slot" name="slot"></slot>-->
  5. <div style="width: 100%;">
  6. <el-select style="width: 100%" v-model="selectValue" size="small" :placeholder="placeholder"
  7. :filterable="filterable" :clearable="clearable"
  8. :remote="remote" :remote-method="remoteMethod"
  9. :multiple="multiple" :collapse-tags="collapseTags"
  10. :disabled="disabled" :allow-create="allowCreate"
  11. @change="corpChange"
  12. @focus="corpFocus">
  13. <el-option
  14. v-for="item in datalist"
  15. :key="item[forParameter.key]"
  16. :label="item[forParameter.label]"
  17. :value="item[forParameter.value]"
  18. :disabled="item[forParameter.disabled] ? item[forParameter.disabled] == disabledStatus : false"
  19. >
  20. </el-option>
  21. </el-select>
  22. </div>
  23. <div v-if="buttonIf" style="display: flex;align-items: center">
  24. <el-button :disabled="disabled" icon="el-icon-search" size="mini" @click="corpVisible = true"></el-button>
  25. <el-tooltip effect="dark" content="获取最新资料" placement="top-start">
  26. <el-button :disabled="disabled" icon="el-icon-refresh" size="mini" @click="refreshData"
  27. style="margin-left:0px;"></el-button>
  28. </el-tooltip>
  29. </div>
  30. </div>
  31. <el-dialog :title="title" :visible.sync="corpVisible" width="80%" top="5vh" append-to-body @closed="closed"
  32. class="el-dialogDeep" :close-on-click-modal="false" v-dialog-drag>
  33. <div>
  34. <el-row>
  35. <!--<el-col :span="4">-->
  36. <!-- <el-scrollbar>-->
  37. <!-- <basic-container>-->
  38. <!-- <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" :style="treeStyle" />-->
  39. <!-- </basic-container>-->
  40. <!-- </el-scrollbar>-->
  41. <!--</el-col>-->
  42. <el-col :span="24">
  43. <slot></slot>
  44. </el-col>
  45. </el-row>
  46. </div>
  47. <span slot="footer" class="dialog-footer">
  48. <el-button @click="corpVisible = false">取 消</el-button>
  49. <el-button type="primary" @click="confirm">确 定</el-button>
  50. </span>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. data(){
  57. return {
  58. // 弹窗关闭
  59. corpVisible:false,
  60. }
  61. },
  62. props:{
  63. // 选择框的数据
  64. datalist:{
  65. type:Array,
  66. default:[]
  67. },
  68. // 选择框数据选择的参数
  69. forParameter:{
  70. type:Object,
  71. default:{
  72. key:'value',
  73. label:'label',
  74. value:'value',
  75. disabled: false,
  76. }
  77. },
  78. // 两个按钮是否显示
  79. buttonIf:{
  80. type:Boolean,
  81. default:true,
  82. },
  83. // 绑定的值
  84. selectValue:{
  85. default:null
  86. },
  87. // 是否禁用
  88. disabled:{
  89. type:Boolean,
  90. default:false
  91. },
  92. // 是否多选
  93. multiple:{
  94. type:Boolean,
  95. default:false
  96. },
  97. // 多选时是否将选中值按文字的形式展示
  98. collapseTags:{
  99. type:Boolean,
  100. default:false
  101. },
  102. // 是否可以搜索
  103. filterable:{
  104. type:Boolean,
  105. default:false
  106. },
  107. // 是否可以创建条目
  108. allowCreate:{
  109. type:Boolean,
  110. default:false
  111. },
  112. // 是否为远程搜索
  113. remote:{
  114. type:Boolean,
  115. default:false
  116. },
  117. // 是否可以清空选择项
  118. clearable:{
  119. type:Boolean,
  120. default:false
  121. },
  122. // 弹窗的标题
  123. title:{
  124. type:String,
  125. default:'选择数据'
  126. },
  127. // 是否禁用
  128. disabledStatus:{
  129. type:Number,
  130. default: 1
  131. },
  132. // 未输入的文字提示
  133. placeholder:{
  134. type:String,
  135. default:'请选择'
  136. },
  137. },
  138. methods:{
  139. // 聚焦事件
  140. corpFocus(){
  141. this.$emit('corpFocus')
  142. },
  143. // 下拉change
  144. corpChange(value) {
  145. this.$emit('corpChange',value)
  146. },
  147. /* 远程模糊查询操作用户 */
  148. remoteMethod(name) {
  149. if (name == null || name === "") {
  150. return false;
  151. }
  152. this.$emit('remoteMethod',name)
  153. },
  154. // 获取最新数据
  155. refreshData(){
  156. this.$emit('remoteMethod')
  157. },
  158. // 弹窗确认事件
  159. confirm(){
  160. this.corpVisible = false
  161. // this.$emit('')
  162. },
  163. }
  164. }
  165. </script>
  166. <style scoped>
  167. </style>