lookImpowerSearch.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <!--
  2. =========================示例说明=========================
  3. <advanced-search :searchData="searchData"></advanced-search>
  4. import advancedSearch from "@/components/ZDcomponents/advancedSearch.vue"
  5. components: {
  6. addPage,
  7. advancedSearch
  8. },
  9. =========================必要参数=========================
  10. searchData:{
  11. buttonList:[//按钮数组没有则为空
  12. {
  13. name:"新增",//按钮名称 只有再状态 1 时需要
  14. type:"1", //按钮类型 1.按钮 2.导入 3.导出
  15. parameter:"add",//按钮字符用于返回方法时的判断
  16. hasPermi:['laboratory:gradeManage:add'] // 权限字段 如果没有则传空字符 hasPermi:"",
  17. },
  18. {
  19. name:"导入",//按钮名称 只有再状态 1 时需要
  20. type:"2", //按钮类型 1.按钮 2.导入 3.导出
  21. parameter:"import",//按钮字符用于返回方法时的判断
  22. hasPermi:['laboratory:gradeManage:import'] // 权限字段 如果没有则传空字符 hasPermi:"",
  23. },
  24. {
  25. name:"导出",//按钮名称 只有再状态 1 时需要
  26. type:"3", //按钮类型 1.按钮 2.导入 3.导出
  27. parameter:"export",//按钮字符用于返回方法时的判断
  28. hasPermi:['laboratory:gradeManage:export'] // 权限字段 如果没有则传空字符 hasPermi:"",
  29. }
  30. ],
  31. searchList:[//搜索数组
  32. {
  33. name:"名称",//描述名称
  34. key:"name",//键名 用于返回数据
  35. value:"",//内容 用于组件内绑定数据
  36. placeholder:"请输入名称",//输入提示
  37. level:"1",//1.普通搜索 2.高级搜索 普通搜索默认会在高级搜索时显示
  38. type:"1",//类型 1.input 2.select 3.TimePicker
  39. universal:'10',//通用参数 input时为最大长度 //TimePicker时可不传
  40. universal:[ //通用参数 select时为列表数据 //TimePicker时可不传
  41. {label:"全部",value:""},{label:"开启",value:"1"},{label:"关闭",value:"0"},
  42. ],
  43. labelWidth:'100px',//label-width宽度 可传可不传 不传时为默认宽度
  44. width:'200',//el-form-item 长度 可传可不传 不传时input/select默认180长度 TimePicker默认240长度
  45. }
  46. ]
  47. }
  48. =========================必要方法=========================
  49. //父组件必要此方法用于接收参数
  50. searchClick(type,data){
  51. if(type == 1){ //type 1.查询
  52. this.queryParams = JSON.parse(JSON.stringify(data));
  53. this.queryParams.pageNum = 1;
  54. this.queryParams.pageSize = 20;
  55. this.getList();
  56. }else if(type == 2){ //type 1.重置
  57. this.queryParams = {
  58. pageNum : 1,
  59. pageSize:20,
  60. };
  61. this.getList();
  62. }else if(type == 'add'){ //type 其他 自定义按钮
  63. this.clickPageType(2);
  64. }else if(type == 'import'){ //如果按钮类型是2或者3 这里data也会返回数据
  65. console.log('data',data)
  66. }else if(type == 'export'){ //如果按钮类型是2或者3 这里data也会返回数据
  67. console.log('data',data)
  68. }
  69. },
  70. -->
  71. <template>
  72. <div class="advancedSearchMaxBigBox">
  73. <el-form ref="queryForm" :inline="true" v-if="!searchState">
  74. <el-form-item :label="item.name" :label-width="item.labelWidth?item.labelWidth:'px'" prop="searchValue" v-for="item in searchData.searchList" v-if="item.level == 1">
  75. <el-input v-if="item.type == 1" v-model="item.value" :maxlength="item.universal" :placeholder="item.placeholder" clearable
  76. :style="item.width?'width:'+item.width+'px;':'width: 180px;'"/>
  77. <el-select v-if="item.type == 2" v-model="item.value" :placeholder="item.placeholder" clearable
  78. :style="item.width?'width:'+item.width+'px;':'width: 180px;'">
  79. <el-option :key="minItem.value" :label="minItem.label" :value="minItem.value" v-for="minItem in item.universal"></el-option>
  80. </el-select>
  81. <el-date-picker v-if="item.type == 3" v-model="item.value" :clearable="false" value-format="yyyy-MM-dd"
  82. :style="item.width?'width:'+item.width+'px;':'width: 240px;'"
  83. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
  84. </el-date-picker>
  85. </el-form-item>
  86. <el-form-item>
  87. <p class="inquire-button-one" @click="buttonClick(1)">查询</p>
  88. <p class="reset-button-one" @click="buttonClick(2)">重置</p>
  89. </el-form-item>
  90. <el-form-item>
  91. <p class="advanced-button" @click="stateSwitch">高级搜索</p>
  92. </el-form-item>
  93. <el-form-item style="float: right" v-for="item in searchData.buttonList" >
  94. <p v-if="item.type == 1" class="inquire-button-one" v-hasPermi="item.hasPermi" style="width:120px;" @click="buttonClick(item.parameter)">{{item.name}}</p>
  95. <div style="float: right;" v-if="item.type == 2">
  96. <el-dropdown @command="commandButton" v-hasPermi="item.hasPermi">
  97. <div class="form-dropdown-box">
  98. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  99. <p>导入</p>
  100. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  101. </div>
  102. <el-dropdown-menu slot="dropdown">
  103. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{item:item,command:1}">下载模板</el-dropdown-item>
  104. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{item:item,command:2}">导入数据</el-dropdown-item>
  105. </el-dropdown-menu>
  106. </el-dropdown>
  107. </div>
  108. <div style="float: right; " v-if="item.type == 3">
  109. <el-dropdown @command="commandButton" v-hasPermi="item.hasPermi">
  110. <div class="form-dropdown-box">
  111. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  112. <p>导出</p>
  113. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  114. </div>
  115. <el-dropdown-menu slot="dropdown">
  116. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{item:item,command:1}">导出全部数据</el-dropdown-item>
  117. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{item:item,command:2}">导出选中数据</el-dropdown-item>
  118. </el-dropdown-menu>
  119. </el-dropdown>
  120. </div>
  121. </el-form-item>
  122. </el-form>
  123. <el-form ref="queryForm" :inline="true" v-if="searchState">
  124. <el-form-item :label="item.name" :label-width="item.labelWidth?item.labelWidth:'px'" prop="searchValue" v-for="item in searchData.searchList" >
  125. <el-input v-if="item.type == 1" v-model="item.value" :maxlength="item.universal" :placeholder="item.placeholder" clearable
  126. :style="item.width?'width:'+item.width+'px;':'width: 180px;'"/>
  127. <el-select v-if="item.type == 2" v-model="item.value" :placeholder="item.placeholder" clearable
  128. :style="item.width?'width:'+item.width+'px;':'width: 180px;'">
  129. <el-option :key="minItem.value" :label="minItem.label" :value="minItem.value" v-for="minItem in item.universal"></el-option>
  130. </el-select>
  131. <el-date-picker v-if="item.type == 3" v-model="item.value" :clearable="false" value-format="yyyy-MM-dd"
  132. :style="item.width?'width:'+item.width+'px;':'width: 240px;'"
  133. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
  134. </el-date-picker>
  135. </el-form-item>
  136. </el-form>
  137. <div class="advanced-max-big-box" v-if="searchState">
  138. <div class="left-advanced-box"></div>
  139. <div class="center-advanced-box">
  140. <p class="inquire-button-one" @click="buttonClick(1)">查询</p>
  141. <p class="reset-button-one" @click="buttonClick(2)">重置</p>
  142. </div>
  143. <div class="right-advanced-box">
  144. <span class="ordinary-button" @click="stateSwitch">普通搜索</span>
  145. </div>
  146. <div v-for="item in searchData.buttonList">
  147. <p v-if="item.type == 1" class="inquire-button-one"
  148. v-hasPermi="item.hasPermi" style="width:120px;float: right;" @click="buttonClick(item.parameter)">{{item.name}}</p>
  149. <div style="float: right;" v-if="item.type == 2">
  150. <el-dropdown @command="commandButton" v-hasPermi="item.hasPermi">
  151. <div class="form-dropdown-box">
  152. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  153. <p>导入</p>
  154. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  155. </div>
  156. <el-dropdown-menu slot="dropdown">
  157. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{item:item,command:1}">下载模板</el-dropdown-item>
  158. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{item:item,command:2}">导入数据</el-dropdown-item>
  159. </el-dropdown-menu>
  160. </el-dropdown>
  161. </div>
  162. <div style="float: right; " v-if="item.type == 3">
  163. <el-dropdown @command="commandButton" v-hasPermi="item.hasPermi">
  164. <div class="form-dropdown-box">
  165. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  166. <p>导出</p>
  167. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  168. </div>
  169. <el-dropdown-menu slot="dropdown">
  170. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{item:item,command:1}">导出全部数据</el-dropdown-item>
  171. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{item:item,command:2}">导出选中数据</el-dropdown-item>
  172. </el-dropdown-menu>
  173. </el-dropdown>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </template>
  179. <script>
  180. export default {
  181. name: "advancedSearch",
  182. props:{
  183. searchData:{}
  184. },
  185. data() {
  186. return {
  187. searchState:false,
  188. }
  189. },
  190. created() {
  191. },
  192. mounted(){
  193. },
  194. methods: {
  195. //普通/高级状态切换
  196. stateSwitch(){
  197. this.searchState = !this.searchState;
  198. },
  199. //导出/导入按钮
  200. commandButton(data){
  201. this.$parent.searchClick(data.item.parameter,data.command);
  202. },
  203. //按钮方法
  204. buttonClick(type){
  205. let self = this;
  206. if(type == '1'){
  207. //查找
  208. let obj = {};
  209. for(let i=0;i<self.searchData.searchList.length;i++){
  210. if(self.searchState){
  211. //高级搜索
  212. obj[self.searchData.searchList[i].key] = self.searchData.searchList[i].value;
  213. }else{
  214. //普通搜索
  215. if(self.searchData.searchList[i].level == '1'){
  216. obj[self.searchData.searchList[i].key] = self.searchData.searchList[i].value;
  217. }
  218. }
  219. }
  220. self.$parent.searchClick(type,obj);
  221. }else if(type == '2'){
  222. //返回
  223. for(let i=0;i<self.searchData.searchList.length;i++){
  224. self.searchData.searchList[i].value = '';
  225. }
  226. self.$parent.searchClick(type);
  227. }else{
  228. self.$parent.searchClick(type);
  229. }
  230. },
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .advancedSearchMaxBigBox{
  236. margin:0 20px;
  237. .advanced-button{
  238. margin:0 20px;
  239. cursor: pointer;
  240. line-height:40px;
  241. font-weight:500;
  242. font-size:14px;
  243. color:#0183FA;
  244. }
  245. .advanced-max-big-box{
  246. display: flex;
  247. padding-bottom:20px;
  248. padding-right:10px;
  249. font-size:14px;
  250. .left-advanced-box{
  251. flex:1;
  252. }
  253. .center-advanced-box{
  254. }
  255. .right-advanced-box{
  256. flex:1;
  257. .ordinary-button{
  258. margin:0 20px;
  259. cursor: pointer;
  260. line-height:40px;
  261. font-weight:500;
  262. font-size:14px;
  263. color:#0183FA;
  264. }
  265. }
  266. }
  267. .form-dropdown-box{
  268. display: flex;
  269. margin:0;
  270. padding:0 10px;
  271. cursor: pointer;
  272. height:40px;
  273. img:nth-child(1){
  274. width:16px;
  275. height:16px;
  276. margin-top:12px;
  277. }
  278. p{
  279. width:47px;
  280. text-align: center;
  281. font-size:14px;
  282. margin:0;
  283. line-height:40px;
  284. }
  285. img:nth-child(3){
  286. width:10px;
  287. height:6px;
  288. margin-top:17px;
  289. }
  290. }
  291. }
  292. </style>
  293. <style lang="scss">
  294. .advancedSearchMaxBigBox{
  295. .el-range-editor--medium.el-input__inner{
  296. height:40px;
  297. }
  298. }
  299. </style>