lj-win-index-common-list.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <!--
  2. @name 模板组件:单据列表查询通用模板窗口(升级版)
  3. @desc 基于vant-ui, 数据获取请求、下拉刷新、上拉加载更多、高级搜索、扫描等功能
  4. 【必填参数】:
  5. @param {String} [title] - 标题名称
  6. @param {String} [apiName] - 获取单据列表的接口的接口
  7. @param {function} [dataLoadedCallback] - “加载更多”完成时的数据处理回调(函数入参:接口返回的原对象;返回boolean,true继续加载,false没有更多)
  8. @param {function} [dataResetCallback] - “下拉刷新”或高级搜索触发的数据处理回调(入参:接口返回原对象)
  9. 【选填参数】
  10. @param {Boolean} [addable] - 是否显示加号图标, default: false
  11. @param {Boolean} [fixable] - 是否显示维修图标, default: false
  12. @param {Boolean} [tranable] - 是否显示调动图表, default: false
  13. @param {Array} [queryFields] - 同lj-query-list的queryFields,设置后显示筛选按钮,点击弹出高级筛选框
  14. @Object:{
  15. title {String}: "标题",
  16. property {String}: "属性名",
  17. initValue {Number/String}: "默认赋值",
  18. group {String}: "属性分组名称"
  19. }
  20. @param {Array} [queryQuick] - 同lj-query-list的queryFields,tabs栏快捷筛选
  21. @Object:{
  22. title {String}: "标题",
  23. property {String}: "属性名",
  24. initValue {Number/String}: "默认赋值",
  25. group {String}: "属性分组名称"
  26. title {String}: "标题",
  27. property {String}: "属性名称",
  28. type {String}: "类型",
  29. 'radio1': 单选,排版:单行
  30. 'radio2': 单选,排版:一行两个
  31. 'radio3': 单选,排版:一行三个
  32. 'cascader': 层级选择
  33. initValue {Number/String}: "默认赋值",
  34. selectOptions: {
  35. optionsApi {String}: "api接口名称", 动态获取数据
  36. requestbody {Object}: "接口参数",
  37. resultName {String}: "", 返回对象名
  38. options {Array} 选项列表
  39. valueMap {Object} "自定义 options 结构中的字段", default: { text: 'text', value: 'value', children: 'children' },
  40. }
  41. }
  42. @param {Array} [queryHardParms] - 同lj-query-list的hardParms, 默认筛选赋值参数
  43. @param {Boolean} [ifShowSearchbar] - 是否使用搜索栏, default: false
  44. @param {String} [searchText] - 搜索关键字, default: false
  45. @example=> v-on:update:searchText="emitChangeKeyword"
  46. @param {Array} [searchActions] - 搜索栏快捷列表
  47. @Object:{
  48. title {String}: "全部",
  49. property {String}: "属性名",
  50. }
  51. @param {String} [hint] - 继承lj-searchbar-pro: 输入框默认提示信息, default: "请输入关键字搜索"
  52. 【插槽】
  53. @slot [header] - app bar中间,默认为标题
  54. @slot [header_right] - appbar 右侧,通常为图标按钮
  55. @slot [header_sub] - appbar下方子标题,固定在顶部
  56. @slot [body_list] - 中间内容,通常为单据列表
  57. @slot [footer] - 底部,固定
  58. -->
  59. <template>
  60. <lj-win-common :title="title" right-drawer-title="搜索" @fix-body="fixbody" :closeWinHandler="handleCloseWin"
  61. ref="baseWin">
  62. <slot slot="header" name="header"></slot>
  63. <slot name="header_right" slot="header_right"></slot>
  64. <mu-button v-if="addable" icon slot="header_right" @click="handleAddButton">
  65. <i class="iconfont icon-add"></i></mu-button>
  66. <mu-button v-if="fixable" icon slot="header_right" @click="handleFixButton">
  67. <i class="iconfont icon-weixiu"></i></mu-button>
  68. <mu-button v-if="tranable" icon slot="header_right" @click="handleTranButton">
  69. <i class="iconfont icon-cart"></i></mu-button>
  70. <!-- <mu-button v-if="showFilter" icon slot="header_right" @click="openRightDrawer">
  71. <i class="iconfont icon-filter"></i></mu-button> -->
  72. <slot name="header_sub" slot="header_sub" :ifShowSearchbar="ifShowSearchbar" :searchtext="keyword" :search="handleSearchbar">
  73. <lj-searchbar-pro
  74. v-if="ifShowSearchbar"
  75. ref="searchbarPro"
  76. :keyword="keyword"
  77. :apiName="postApiName"
  78. v-on:update:keyword="emitChangeKeyword"
  79. :actions="searchActions"
  80. :hint="hint"
  81. :popoOffset="popoOffset"
  82. scanicon
  83. @search="handleSearchbar"
  84. @cancel="handleSearchbarCancel"
  85. @focusSearch="handleSearchFocus"
  86. @blurSearch="handleSearchBlur"
  87. @scan-click="handleSearchScan"
  88. @click-right-btn="openFilterPopup"
  89. >
  90. <template slot="right" slot-scope="data" v-if="!showQuickFilter && showFilter">
  91. <div class="right-part" @click="data.clickRightBtn" :class="{'filtering': ifBottomFilter}">
  92. <i class="iconfont" :class="ifBottomFilter ? 'icon-filter_dark' : 'icon-filter_light'"></i>
  93. </div>
  94. </template>
  95. </lj-searchbar-pro>
  96. <lj-tabs-quick
  97. v-if="ifTabsQuick"
  98. ref="ljTabsQuick"
  99. :apiName="postApiName"
  100. :query-fields="queryQuick"
  101. @click-right-btn="openFilterPopup"
  102. @confirm="handleFilterConfirm"
  103. >
  104. <template slot="right" slot-scope="data" v-if="showFilter">
  105. <div class="right-part" @click="data.clickRightBtn" :class="{'filtering': ifBottomFilter}">
  106. 筛选
  107. <i class="iconfont" :class="ifBottomFilter ? 'icon-filter_dark' : 'icon-filter_light'"></i>
  108. </div>
  109. </template>
  110. </lj-tabs-quick>
  111. <lj-tabs-filtrate
  112. v-else-if="showQuickFilter"
  113. ref="ljTabsFiltrate"
  114. :apiName="postApiName"
  115. :query-fields="queryQuick"
  116. @click-right-btn="openFilterPopup"
  117. @confirm="handleFilterConfirm"
  118. >
  119. <template slot="right" slot-scope="data" v-if="showFilter">
  120. <div class="right-part" @click="data.clickRightBtn" :class="{'filtering': ifBottomFilter}">
  121. 筛选
  122. <i class="iconfont" :class="ifBottomFilter ? 'icon-filter_dark' : 'icon-filter_light'"></i>
  123. </div>
  124. </template>
  125. </lj-tabs-filtrate>
  126. </slot>
  127. <div class="body" slot="body" ref="bodyref">
  128. <lj-widget-refresh-list
  129. ref="refresh_list"
  130. offset="100"
  131. ifwhite
  132. @onRefresh="refresh"
  133. @onLoad="load"
  134. >
  135. <!-- :style="{'height': bodyHeight, 'overflow': 'auto'}" -->
  136. <template slot="list_body">
  137. <slot name="body_list" ref="bodyListRef"/>
  138. </template>
  139. </lj-widget-refresh-list>
  140. <lj-bottom-filtrate
  141. v-if="showFilter"
  142. ref="ljBottomFiltrate"
  143. :query-fields="queryFields"
  144. :hard-parms="queryHardParms"
  145. :binding-parms="bindingParms"
  146. @confirm="handleFilterConfirm"
  147. @filter="handleFilterBottomFiltering"
  148. >
  149. </lj-bottom-filtrate>
  150. <lj-to-top ref="scrollToTop" :pageindex="currentPageIndex"></lj-to-top>
  151. </div>
  152. <slot slot="footer" name="footer"></slot>
  153. </lj-win-common>
  154. </template>
  155. <script>
  156. import LjWinCommon from 'components/lj-win-common';
  157. // import LjQueryList from "components/lj-query-list";
  158. import LjSearchbarPro from 'components/lj-searchbar-pro';
  159. import LjTabsFiltrate from 'components/filtrate-widget/lj-tabs-filtrate'
  160. import LjTabsQuick from 'components/filtrate-widget/lj-tabs-quick'
  161. import LjBottomFiltrate from 'components/filtrate-widget/lj-bottom-filtrate'
  162. import LjWidgetRefreshList from './lj-widget-refresh-list'
  163. import LjToTop from "./lj-scrolltotop"
  164. export default {
  165. name: "lj-win-index-common-list",
  166. components: {
  167. // LjQueryList,
  168. LjWinCommon,
  169. LjSearchbarPro,
  170. LjTabsFiltrate,
  171. LjTabsQuick,
  172. LjBottomFiltrate,
  173. LjWidgetRefreshList,
  174. LjToTop
  175. },
  176. props: {
  177. // 标题名称
  178. title: {
  179. type: String,
  180. required: true
  181. },
  182. // 是否显示加号图标
  183. addable: {
  184. type: Boolean,
  185. default: false
  186. },
  187. // 是否显示维修图标
  188. fixable: {
  189. type: Boolean,
  190. default: false,
  191. },
  192. // 是否显示调动图表
  193. tranable: {
  194. type: Boolean,
  195. default: false,
  196. },
  197. // 同lj-query-list的queryFields,设置后显示筛选按钮,点击弹出高级筛选框
  198. queryFields: {
  199. type: Array,
  200. default: function () {
  201. return [];
  202. }
  203. },
  204. // 同lj-query-list的hardParms
  205. queryHardParms: {
  206. type: Object,
  207. default: function () {
  208. return {};
  209. }
  210. },
  211. // 同lj-query-list的bindingParms
  212. bindingParms: {
  213. type: Object,
  214. default: function () {
  215. return {};
  216. }
  217. },
  218. // queryParams: {
  219. // type: Array
  220. // },
  221. // 获取单据列表的接口的接口
  222. apiName: {
  223. type: String,
  224. // required: true
  225. },
  226. // “加载更多”完成时的数据处理回调(函数入参:接口返回的原对象;返回boolean,true继续加载,false没有更多)
  227. dataLoadedCallback: {
  228. type: Function
  229. },
  230. // “下拉刷新”或高级搜索触发的数据处理回调(入参:接口返回原对象)
  231. dataResetCallback: {
  232. type: Function,
  233. required: true
  234. },
  235. // 右侧抽屉初始时是否打开
  236. // rightDrawerInitOpen: {
  237. // type: Boolean,
  238. // default: false
  239. // },
  240. searchText:{
  241. type: String,
  242. default: ""
  243. },
  244. // 搜索栏快捷列表
  245. searchActions:{
  246. type: Array,
  247. default: function() {
  248. return []
  249. }
  250. },
  251. // 继承lj-searchbar-pro: 输入框默认提示信息
  252. hint: {
  253. type: String,
  254. default: "请输入关键字搜索"
  255. },
  256. // 同lj-query-list的queryFields,快捷筛选
  257. queryQuick: {
  258. type: Array,
  259. default: function() {
  260. return []
  261. }
  262. },
  263. // 同lj-query-list的queryFields,快捷筛选,是否使用tag样式
  264. ifTabsQuick: {
  265. type: Boolean,
  266. default: false
  267. },
  268. ifShowSearchbar: {
  269. type: Boolean,
  270. default: false
  271. },
  272. // 搜索下拉,出现位置的偏移量[number, number]
  273. popoOffset: {
  274. type: Array,
  275. default: function() {
  276. return [0, 0]
  277. }
  278. },
  279. closeWinHandler: {
  280. type: Function,
  281. },
  282. // 搜索记录,可选,默认用apiName
  283. habitKey: {
  284. type: String,
  285. default: ''
  286. },
  287. // 通用接口xml文件名称,可选;使用通用接口必填
  288. dwname: {
  289. type: String,
  290. default: ''
  291. },
  292. beforePost: {
  293. type: Function,
  294. },
  295. },
  296. data() {
  297. return {
  298. refreshing: false,
  299. currentPageIndex: 1,
  300. currentPageSize: 20,
  301. currentRequestBody: {},
  302. ifBottomFilter: false, // 筛选标签状态
  303. bodyHeight: 'auto',
  304. userFilterName: '', // 用户筛选记录名称
  305. postApiName: ""
  306. }
  307. },
  308. created() {
  309. this.postApiName = this.dwname ? "CommonDynamicSelect" : this.apiName;
  310. let _apiName = this.dwname || this.apiName;
  311. this.userFilterName = this.habitKey || _apiName;
  312. },
  313. mounted() {
  314. this.initSearched();
  315. },
  316. methods: {
  317. handleCloseWin() {
  318. if (this.closeWinHandler){
  319. this.closeWinHandler();
  320. } else {
  321. $lj.closeWin();
  322. }
  323. },
  324. fixbody(obj){
  325. this.bodyHeight = obj.minHeight;
  326. },
  327. /**搜索栏:扫码 */
  328. handleSearchScan(status) {
  329. this.$emit('scan-click', status);
  330. },
  331. /**聚焦搜索条 */
  332. handleSearchFocus() {
  333. this.$refs.ljTabsFiltrate && this.$refs.ljTabsFiltrate.close();
  334. this.$refs.ljTabsQuick && this.$refs.ljTabsQuick.close();
  335. },
  336. /**失去聚焦搜索条 */
  337. handleSearchBlur() {
  338. setTimeout(() => {
  339. this.$refs.baseWin.initStyle();
  340. }, 200);
  341. },
  342. /**取消搜索 */
  343. handleSearchbarCancel(item) {
  344. this.$refs.scrollToTop.totop();
  345. console.log('handleSearchbarCancel item :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(item));
  346. let searchPro = this.fnSetSearchProperty(item);
  347. $lj.setUserFilterParams(this.userFilterName, searchPro);
  348. // this.refresh(item);
  349. this.$refs.refresh_list.onRefresh(searchPro);
  350. this.showFilter && this.$refs.ljBottomFiltrate.initSearched(searchPro);
  351. this.$refs.ljTabsFiltrate && this.$refs.ljTabsFiltrate.close();
  352. this.$refs.ljTabsQuick && this.$refs.ljTabsQuick.close();
  353. // 清空关键字
  354. this.emitChangeKeyword('');
  355. },
  356. /**搜索栏-搜索 */
  357. handleSearchbar(item, ifscan) {
  358. this.$refs.scrollToTop.totop();
  359. console.log(' item :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(item));
  360. // this.refresh(item);
  361. let searchPro = this.fnSetSearchProperty(item);
  362. // 记录用户数据
  363. $lj.setUserFilterParams(this.userFilterName, searchPro);
  364. this.$refs.refresh_list.onRefresh(searchPro);
  365. if (ifscan) {
  366. this._fnSetSearchedForSearchbar(searchPro);
  367. } else {
  368. this.$refs.ljTabsFiltrate && this.$refs.ljTabsFiltrate.close();
  369. this.$refs.ljTabsQuick && this.$refs.ljTabsQuick.close();
  370. }
  371. this.showFilter && this.$refs.ljBottomFiltrate.initSearched(searchPro);
  372. // this.keyword = '';
  373. this.$refs.searchbarPro.clearText();
  374. },
  375. fnSetSearchProperty(item) {
  376. /**
  377. * 情况1:只输入搜索栏
  378. * 情况2:只选择tab菜单
  379. * 情况3:先选择tab,后输入,属性不冲突
  380. * 属性共存
  381. * 目前情况:输入时清空tab
  382. * 情况4:先输入,后选择tab,属性冲突
  383. * 清空输入框
  384. * 情况5:先选择tab,后输入,属性冲突
  385. * 清空tab选择
  386. *
  387. * 先检查【输入】【tab】重复属性
  388. * 后判断是否需要清空操作
  389. *
  390. * 对于冲突属性,如果是tab
  391. */
  392. // 搜索菜单属性数组
  393. let SPropArr = [];
  394. if (this.searchActions && this.searchActions.length > 0) {
  395. for (let i = 0; i < this.searchActions.length; i++) {
  396. SPropArr.push(this.searchActions[i].property);
  397. }
  398. }
  399. let sameProArr = []
  400. if (this.queryQuick && this.queryQuick.length > 0) {
  401. for (let i = 0; i < this.queryQuick.length; i++) {
  402. if (SPropArr.indexOf(this.queryQuick[i].property) > -1) {
  403. // 记录相同属性
  404. sameProArr.push(this.queryQuick[i].property);
  405. }
  406. }
  407. }
  408. console.log('冲突属性 sameProArr :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(sameProArr));
  409. // 搜索栏与tabs栏没有冲突属性
  410. if (!sameProArr.length) {
  411. return item
  412. }
  413. // 检查输入的属性列表
  414. if (this.$refs.ljTabsFiltrate) {
  415. let tabsCurrent = this.$refs.ljTabsFiltrate.currentQueryField;
  416. for (const key in item) {
  417. if (sameProArr.indexOf(key) > -1) {
  418. if (item[key] != '') {
  419. // 通过搜索栏,主动搜索, 出现与tabs栏属性冲突,清除tabs栏选择
  420. this.$refs.ljTabsFiltrate.fnResetTabs(key);
  421. let keywordObjTitle = $lj.getUserFilterTitle(this.userFilterName);
  422. console.log('删除前 keywordObjTitle :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObjTitle));
  423. if (keywordObjTitle.hasOwnProperty(key)) {
  424. // Reflect.deleteProperty(keywordObjTitle, key);
  425. keywordObjTitle[key] = '';
  426. $lj.setUserFilterTitle(this.userFilterName, keywordObjTitle);
  427. console.log('删除后 keywordObjTitle :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObjTitle));
  428. }
  429. } else {
  430. if (this.currentRequestBody[key] && tabsCurrent[key] == this.currentRequestBody[key]) {
  431. // 与tabs栏已有属性共存,读取旧属性
  432. item[key] = this.currentRequestBody[key]
  433. }
  434. }
  435. }
  436. }
  437. }
  438. console.log('赋值后 item :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(item));
  439. return item
  440. },
  441. /**读取搜索记录 */
  442. initSearched() {
  443. console.warn(' this.userFilterName :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.userFilterName));
  444. let keywordObj = $lj.getUserFilterParams(this.userFilterName);
  445. let keywordObjTitle = $lj.getUserFilterTitle(this.userFilterName);
  446. console.log('initSearched keywordObj :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObj));
  447. console.log('initSearched keywordObjTitle :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObjTitle));
  448. this._fnSetSearchedForTabsFiltrate(keywordObj, keywordObjTitle)
  449. this._fnSetSearchedForSearchbar(keywordObj)
  450. // this.refresh(keywordObj);
  451. this.refresh(Object.assign({}, keywordObj, this.currentRequestBody));
  452. this.showFilter && this.$refs.ljBottomFiltrate.initSearched(keywordObj);
  453. },
  454. /**设置ljTabsFiltrate的搜索状态 */
  455. _fnSetSearchedForTabsFiltrate(keywordObj, keywordObjTitle) {
  456. if (JSON.stringify(keywordObj) == '{}') {
  457. // 如果是第一次进来,或没有历史搜索记录,读取默认属性
  458. for (let i = 0; i < this.queryFields.length; i++) {
  459. if (this.queryFields[i].hasOwnProperty("initValue")) {
  460. keywordObj[this.queryFields[i].property] = this.queryFields[i].initValue
  461. }
  462. }
  463. for (let i = 0; i < this.queryQuick.length; i++) {
  464. if (this.queryQuick[i].hasOwnProperty("initValue")) {
  465. keywordObj[this.queryQuick[i].property] = this.queryQuick[i].initValue
  466. }
  467. }
  468. console.log('initSearched 读取默认值 keywordObj :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObj));
  469. }
  470. this.$refs.ljTabsFiltrate && this.$refs.ljTabsFiltrate.initSearched(keywordObj, keywordObjTitle);
  471. this.$refs.ljTabsQuick && this.$refs.ljTabsQuick.initSearched(keywordObj, keywordObjTitle);
  472. },
  473. /**设置SearchbarPro的搜索状态 */
  474. _fnSetSearchedForSearchbar(keywordObj) {
  475. let keywordObj_arr = [];
  476. for (const key in keywordObj) {
  477. keywordObj_arr.push(key);
  478. }
  479. let searchList = JSON.parse(JSON.stringify(this.searchActions));
  480. let keywordList = [];
  481. for (let i = 0; i < searchList.length; i++) {
  482. if (keywordObj_arr.indexOf(searchList[i].property) > -1 && keywordObj[searchList[i].property]) {
  483. searchList[i].value = keywordObj[searchList[i].property];
  484. keywordList.push(searchList[i]);
  485. // break;
  486. }
  487. }
  488. console.log(' _fnSetSearchedForSearchbar :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordList));
  489. this.$refs.searchbarPro && this.$refs.searchbarPro.initSearch(keywordList);
  490. },
  491. /**底部筛选栏-筛选中 -状态 */
  492. handleFilterBottomFiltering() {
  493. this.ifBottomFilter = this._fnCheckIfFilter();
  494. // let keywordObj = $lj.getUserFilterParams(this.apiName);
  495. console.log(' this.currentRequestBody :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.currentRequestBody));
  496. let keywordObj = this.currentRequestBody;
  497. console.log(' handleFilterBottomFiltering keywordObj :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(keywordObj));
  498. // this._fnSetSearchedForSearchbar(keywordObj);
  499. this.showFilter && this.$refs.ljBottomFiltrate.autoSetCurrentQuery(keywordObj);
  500. },
  501. /**检测是否需要标记:筛选中 */
  502. _fnCheckIfFilter() {
  503. console.log(' this.currentRequestBody :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.currentRequestBody));
  504. let ifFilter = false;
  505. for (let i = 0; i < this.queryFields.length; i++) {
  506. let property = this.queryFields[i].property;
  507. if (this.currentRequestBody[property] != this.queryFields[i].initValue) {
  508. console.log(' this.queryFields[i] :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.queryFields[i]));
  509. ifFilter = true;
  510. break;
  511. }
  512. }
  513. return ifFilter;
  514. },
  515. /**重置-底部筛选栏 */
  516. // handleFilterReset(item) {
  517. // this.ifBottomFilter = false;
  518. // let keywordObj = this.$refs.searchbarPro.handleCancel(false);
  519. // let maxObj = Object.assign({}, this.currentRequestBody, keywordObj, item, this.queryHardParms);
  520. // $lj.setUserFilterParams(this.apiName, maxObj);
  521. // // this.refresh(maxObj);
  522. // this.$refs.refresh_list.onRefresh(maxObj);
  523. // },
  524. /**tabs栏-筛选 */
  525. handleFilterConfirm(item, titles) {
  526. this.$refs.scrollToTop.totop();
  527. console.log('handleFilterConfirm item :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(item));
  528. console.log('handleFilterConfirm titles :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(titles));
  529. $lj.setUserFilterParams(this.userFilterName, item);
  530. titles != undefined && $lj.setUserFilterTitle(this.userFilterName, titles);
  531. // this.refresh(item);
  532. this.$refs.refresh_list.onRefresh(item);
  533. console.log(' handleFilterConfirm this.currentRequestBody :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.currentRequestBody));
  534. this._fnSetSearchedForSearchbar(this.currentRequestBody);
  535. },
  536. /**打开底部筛选栏 */
  537. openFilterPopup() {
  538. console.log('this.showFilter && this.$refs.ljBottomFiltrate :>> ', this.showFilter && this.$refs.ljBottomFiltrate);
  539. this.showFilter && this.$refs.ljBottomFiltrate.open();
  540. },
  541. /**回调绑定值 */
  542. emitChangeKeyword(val) {
  543. this.$emit('update:searchText', val)
  544. },
  545. // openRightDrawer() {
  546. // this.$refs.baseWin.openRightDrawer();
  547. // },
  548. // closeRightDrawer() {
  549. // this.$refs.baseWin.closeRightDrawer();
  550. // },
  551. closeWin() {
  552. $lj.closeWin();
  553. },
  554. handleAddButton() {
  555. this.$emit('add-click');
  556. },
  557. handleFixButton() {
  558. this.$emit('fix-click');
  559. },
  560. handleTranButton() {
  561. this.$emit('tran-click');
  562. },
  563. // handleQuerySubmit(queryParams) {
  564. // console.log('handleQuerySubmit queryParams :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(queryParams));
  565. // this.closeRightDrawer();
  566. // this.refresh(queryParams);
  567. // },
  568. refresh(queryParams) {
  569. this.currentPageIndex = 1;
  570. this.currentRequestBody = Object.assign({}, this.currentRequestBody, queryParams, this.queryHardParms);
  571. this.currentRequestBody.pagesize = this.currentPageSize;
  572. this.load((ret) => {
  573. this.dataResetCallback(ret);
  574. });
  575. },
  576. load(callback) {
  577. if (this.dwname) {
  578. let _params = JSON.parse(JSON.stringify(this.currentRequestBody));
  579. _params = $lj.omit(_params, ['dsname', 'dwname', 'itemname', 'queryParams', 'pageindex', 'pagesize', 'token']);
  580. // 删除对象属性(es5)
  581. delete _params.pagesize;
  582. delete _params.pageindex;
  583. console.log("_params ::>>> ", JSON.stringify(_params));
  584. if (this.beforePost) {
  585. _params = this.beforePost(_params);
  586. }
  587. // 只保留指定字段属性(es5)
  588. this.currentRequestBody.queryParams = _params;
  589. this.currentRequestBody = $lj.pick(this.currentRequestBody, ['dsname', 'dwname', 'itemname', 'queryParams', 'pageindex', 'pagesize', 'token']);
  590. this.currentRequestBody.dsname = this.dwname;
  591. this.currentRequestBody.dwname = "JLH_APP";
  592. this.currentRequestBody.itemname = this.userFilterName;
  593. }
  594. console.log("this.currentRequestBody ::>>> ", JSON.stringify(this.currentRequestBody));
  595. // this.currentPageIndex++;
  596. this.currentRequestBody.pageindex = this.currentPageIndex;
  597. this.currentRequestBody.token = $lj.getStorage("token");
  598. let self = this;
  599. $lj.postLJRequest(this.postApiName, this.currentRequestBody, function (ret) {
  600. if (ret) {
  601. /**处理状态 */
  602. let dataArr = [];
  603. for (let prop in ret) {
  604. if (ret[prop] instanceof Array) {
  605. dataArr = ret[prop];
  606. break;
  607. }
  608. }
  609. self.$refs.refresh_list.fnReady();
  610. self.$refs.refresh_list.fnRefreshed();
  611. if (self.currentPageIndex == 1 && !dataArr.length) {
  612. self.$refs.refresh_list.fnLoadedAndEmpty();
  613. return false;
  614. } else if (dataArr.length < self.currentPageSize) {
  615. self.$refs.refresh_list.fnLoaded(1);
  616. } else {
  617. self.currentPageIndex++;
  618. self.$refs.refresh_list.fnLoaded(0);
  619. }
  620. /**回调数据 */
  621. if (callback) {
  622. callback(ret);
  623. } else {
  624. self.dataLoadedCallback(ret);
  625. }
  626. }
  627. }, function (ret) {
  628. self.$refs.refresh_list.fnReady();
  629. self.$refs.refresh_list.fnRefreshed();
  630. self.$refs.refresh_list.fnLoadError();
  631. }, true)
  632. },
  633. // handleQueryFieldClick(event) {
  634. // this.$emit("query-field-click", event);
  635. // },
  636. // handleQueryFieldChange(event){
  637. // this.$emit("query-field-change", event);
  638. // },
  639. // setQueryParam(property, value) {
  640. // this.$refs.queryList.setQueryParam(property, value);
  641. // }
  642. setQueryParam(property, value) {
  643. this.$set(this.currentRequestBody, property, value);
  644. console.log('handleReset!!!! setQueryParamthis.currentQueryField :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.currentQueryField));
  645. },
  646. },
  647. computed: {
  648. showFilter() {
  649. return this.queryFields && this.queryFields.length > 0;
  650. },
  651. showQuickFilter() {
  652. return this.queryQuick.length > 0;
  653. },
  654. hasLoadmoreFunction() {
  655. return this.dataLoadedCallback;
  656. },
  657. keyword: {
  658. get() {
  659. return this.searchText
  660. },
  661. set(val) {
  662. this.$emit('update:searchText', val)
  663. }
  664. },
  665. },
  666. watch: {
  667. bindingParms: {
  668. handler(newVal, oldVal) {
  669. if (newVal) {
  670. for (let prop in newVal) {
  671. this.setQueryParam(prop, newVal[prop]);
  672. }
  673. }
  674. },
  675. deep: true,
  676. immediate: true
  677. }
  678. },
  679. }
  680. </script>
  681. <style lang="less">
  682. .body {
  683. padding-top: 10px;
  684. & > .van-overlay{
  685. z-index: 99!important;
  686. }
  687. & > .van-popover {
  688. width: -moz-calc(~"100% - 20px");
  689. width: -webkit-calc(~"100% - 20px");
  690. width: calc(~"100% - 20px");
  691. left: 10px!important;
  692. right: 10px!important;
  693. .van-popover__action {
  694. width: 100%;
  695. }
  696. }
  697. .van-popover__arrow {
  698. display: none;
  699. }
  700. }
  701. </style>