searchquery.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="size" :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. <div class="bottonBox" v-if="tableIf" :class="disabled?'disabledBox':''" @click="disabled?'':corpVisible = true"><i class="el-icon-search"></i></div>
  25. <el-tooltip effect="dark" content="获取最新资料" placement="top-start">
  26. <div class="bottonBox" :class="disabled?'disabledBox':''" @click="refreshData"><i class="el-icon-refresh"></i></div>
  27. </el-tooltip>
  28. <el-tooltip v-if="addIf" effect="dark" content="新建数据" placement="top-start">
  29. <div class="bottonBox" :class="disabled?'disabledBox':''" @click="addJump"><i class="el-icon-plus"></i></div>
  30. </el-tooltip>
  31. </div>
  32. </div>
  33. <el-dialog :title="title" :visible.sync="corpVisible" width="80%" top="5vh" append-to-body @closed="closed"
  34. class="el-dialogDeep" :close-on-click-modal="false" v-dialog-drag>
  35. <div>
  36. <el-row>
  37. <!--<el-col :span="4">-->
  38. <!-- <el-scrollbar>-->
  39. <!-- <basic-container>-->
  40. <!-- <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" :style="treeStyle" />-->
  41. <!-- </basic-container>-->
  42. <!-- </el-scrollbar>-->
  43. <!--</el-col>-->
  44. <el-col :span="24">
  45. <slot></slot>
  46. </el-col>
  47. </el-row>
  48. </div>
  49. <span slot="footer" class="dialog-footer">
  50. <el-button @click="corpVisible = false">取 消</el-button>
  51. <el-button type="primary" @click="confirm">确 定</el-button>
  52. </span>
  53. </el-dialog>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. data(){
  59. return {
  60. // 弹窗关闭
  61. corpVisible:false,
  62. }
  63. },
  64. props:{
  65. // 选择框的数据
  66. datalist:{
  67. type:Array,
  68. default:[]
  69. },
  70. // 选择框数据选择的参数
  71. forParameter:{
  72. type:Object,
  73. default:{
  74. key:'value',
  75. label:'label',
  76. value:'value',
  77. disabled: false,
  78. }
  79. },
  80. // 两个按钮是否显示
  81. buttonIf:{
  82. type:Boolean,
  83. default:true,
  84. },
  85. // 绑定的值
  86. selectValue:{
  87. default:null
  88. },
  89. // 是否禁用
  90. disabled:{
  91. type:Boolean,
  92. default:false
  93. },
  94. // 是否多选
  95. multiple:{
  96. type:Boolean,
  97. default:false
  98. },
  99. // 多选时是否将选中值按文字的形式展示
  100. collapseTags:{
  101. type:Boolean,
  102. default:false
  103. },
  104. // 是否可以搜索
  105. filterable:{
  106. type:Boolean,
  107. default:false
  108. },
  109. // 是否可以创建条目
  110. allowCreate:{
  111. type:Boolean,
  112. default:false
  113. },
  114. // 是否为远程搜索
  115. remote:{
  116. type:Boolean,
  117. default:false
  118. },
  119. // 是否可以清空选择项
  120. clearable:{
  121. type:Boolean,
  122. default:false
  123. },
  124. // 弹窗的标题
  125. title:{
  126. type:String,
  127. default:'选择数据'
  128. },
  129. // 是否禁用
  130. disabledStatus:{
  131. type:Number,
  132. default: 1
  133. },
  134. // 未输入的文字提示
  135. placeholder:{
  136. type:String,
  137. default:'请选择'
  138. },
  139. // 表格按钮
  140. tableIf:{
  141. type:Boolean,
  142. default:true
  143. },
  144. // 添加跳转按钮
  145. addIf:{
  146. type:Boolean,
  147. default:false
  148. },
  149. // 尺寸大小
  150. size:{
  151. type:String,
  152. default:'small'
  153. },
  154. },
  155. watch:{
  156. // // 监听
  157. // selectValue:{
  158. // // 执行方法
  159. // handler(oldValue,newValue) {
  160. // console.log(oldValue,145)
  161. // console.log(newValue,146)
  162. // },
  163. // deep: true, // 深度监听
  164. // immediate: true // 第一次改变就执行
  165. // },
  166. },
  167. methods:{
  168. addJump(){
  169. if (this.disabled) {
  170. return
  171. }
  172. this.$emit('addJump')
  173. },
  174. // 聚焦事件
  175. corpFocus(){
  176. this.$emit('corpFocus')
  177. },
  178. // 下拉change
  179. corpChange(value) {
  180. this.$emit('corpChange',value)
  181. },
  182. /* 远程模糊查询操作用户 */
  183. remoteMethod(name) {
  184. if (name == null || name === "") {
  185. return false;
  186. }
  187. this.$emit('remoteMethod',name)
  188. },
  189. // 获取最新数据
  190. refreshData(){
  191. if (this.disabled) {
  192. return
  193. }
  194. this.$emit('remoteMethod')
  195. },
  196. // 弹窗确认事件
  197. confirm(){
  198. this.corpVisible = false
  199. // this.$emit('')
  200. },
  201. }
  202. }
  203. </script>
  204. <style lang="scss" scoped>
  205. .bottonBox {
  206. height: 32px;
  207. background: #FFF;
  208. border: 1px solid #DCDFE6;
  209. font-size: 12px;
  210. border-radius: 3px;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. padding: 0 10px;
  215. box-sizing: border-box;
  216. }
  217. .disabledBox {
  218. color: #C0C4CC;
  219. cursor: not-allowed;
  220. background-image: none;
  221. background-color: #FFF;
  222. border-color: #EBEEF5;
  223. }
  224. </style>