searchquery.vue 7.0 KB

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