组件.搜索

12003

普通搜索

  1. <jh-toast />
  2. <v-app>
  3. <v-row class="mt-3 ml-3">
  4. <v-col cols="12" xs="12" sm="6" md="4" xl="3" class="pa-0 pr-0 pr-sm-2">
  5. <v-select v-model="serverSearchInput.level" color="success" prefix="年级:" class="jh-v-input bg-white" :items="constantObj.level" dense filled single-line hide-details></v-select>
  6. </v-col>
  7. <v-col cols="12" xs="12" sm="6" md="4" xl="3" class="pa-0 pr-0 pr-md-2 pt-2 pt-sm-0">
  8. <v-select v-model="serverSearchInput.gender" color="success" prefix="性别:" class="jh-v-input bg-white" :items="constantObj.gender" dense filled single-line hide-details></v-select>
  9. </v-col>
  10. <div class="jh-backend-search-btn">
  11. <v-btn class="elevation-0 float-right mt-2 mt-md-0" color="success" small @click="() => { window.vtoast.success(`年级:${serverSearchInput.level} 性别:${serverSearchInput.gender}`) }">
  12. 查询
  13. </v-btn>
  14. </div>
  15. </v-row>
  16. </v-app>
  17. <script type="module">
  18. new Vue({
  19. el: '#app',
  20. template: '#app-template',
  21. vuetify: new Vuetify(),
  22. data: () => ({
  23. constantObj: {
  24. level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
  25. gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
  26. },
  27. serverSearchInput: {
  28. level: null,
  29. gender: null
  30. },
  31. }),
  32. })
  33. </script>

场景搜索

  1. <jh-toast />
  2. <jh-mask />
  3. <jh-confirm-dialog />
  4. <v-app>
  5. <div class="jh-page-second-bar px-8">
  6. <v-row class="align-center" dense>
  7. <v-col cols="12" xs="12" sm="4" md="4" xl="3">
  8. <div class="py-4 text-body-1 font-weight-bold d-flex align-center">场景搜索</div>
  9. </v-col>
  10. <!-- 搜索条件表单 >>>>>>>> -->
  11. <v-col cols="12" xs="12" sm="8" md="8" xl="9">
  12. <v-row class="jh-backend-form-container justify-end ma-0 py-3">
  13. <v-btn-toggle :value="0" mandatory dense color="success" @change="doUiAction('useScene', sceneList[$event])" >
  14. <v-btn small v-for="scene, index in sceneList" :key="index"> {{scene.name}} </v-btn>
  15. </v-btn-toggle>
  16. <div class="jh-backend-search-btn">
  17. <v-btn class="elevation-0 float-right mt-2 mt-md-0" color="success" small
  18. @click="doUiAction('getTableData')">
  19. 查询
  20. </v-btn>
  21. </div>
  22. </v-row>
  23. </v-col>
  24. <!-- <<<<<<<< 搜索条件表单 -->
  25. </v-row>
  26. </div>
  27. </v-app>
  28. <script type="module">
  29. new Vue({
  30. el: '#app',
  31. template: '#app-template',
  32. vuetify: new Vuetify(),
  33. data: () => ({
  34. sceneList: [
  35. {"form": {}, "name": "全部", "id": "scene-fixed-all"},
  36. {"form": {"level": "01", "gender": "male"}, "name": "一年级的男生", "id": "scene-fixed-1"},
  37. {"form": {"level": "02", "gender": "female"}, "name": "二年级的女生", "id": "scene-fixed-2"},
  38. ],
  39. currentSceneId: 'scene-fixed-all',
  40. serverSearchInput: {
  41. level: null,
  42. gender: null
  43. },
  44. }),
  45. methods: {
  46. async doUiAction(uiActionId, uiActionData) {
  47. try {
  48. switch (uiActionId) {
  49. case 'useScene':
  50. await this.useScene(uiActionData);
  51. break;
  52. case 'getTableData':
  53. await this.getTableData();
  54. break;
  55. default:
  56. console.error("[doUiAction] uiActionId not find", { uiActionId });
  57. break;
  58. }
  59. } catch (error) {
  60. throw error;
  61. } finally {
  62. window.jhMask && window.jhMask.hide();
  63. }
  64. },
  65. async getTableData() {
  66. window.vtoast.show({ message: `${JSON.stringify(this.serverSearchInput)}`, icon: 'mdi-help-circle' })
  67. },
  68. // ---------- 场景 uiAction >>>>>>>>>> --------
  69. useScene(funObj) {
  70. this.currentSceneId = funObj.id;
  71. this.serverSearchInput = _.cloneDeep(funObj.form);
  72. },
  73. // ---------- <<<<<<<<<<< 场景 uiAction --------
  74. }
  75. })
  76. </script>

定制场景搜索

  1. <jh-toast />
  2. <jh-mask />
  3. <jh-confirm-dialog />
  4. <v-app>
  5. <div class="jh-page-second-bar px-8">
  6. <v-row class="align-center" dense>
  7. <v-col cols="12" xs="12" sm="4" md="4" xl="3">
  8. <div class="py-4 text-body-1 font-weight-bold d-flex align-center">场景搜索</div>
  9. </v-col>
  10. <!-- 搜索条件表单 >>>>>>>> -->
  11. <v-col cols="12" xs="12" sm="8" md="8" xl="9">
  12. <v-row class="jh-backend-form-container justify-end ma-0 py-3">
  13. <jh-scene
  14. :initFormData="serverSearchInput" :sceneListKey="localSceneListKey"
  15. :currentSceneId="currentSceneId" @useScene="doUiAction('useScene', $event)">
  16. <template v-slot:form="{form}">
  17. <v-select class="jh-v-input mb-2" dense single-line filled clearable prefix="年级:" v-model="form.level" :items="constantObj.level"></v-select>
  18. <v-select class="jh-v-input" dense single-line filled clearable prefix="性别:" v-model="form.gender" :items="constantObj.gender"></v-select>
  19. </template>
  20. </jh-scene>
  21. <div class="jh-backend-search-btn">
  22. <v-btn class="elevation-0 float-right mt-2 mt-md-0" color="success" small
  23. @click="doUiAction('getTableData')">
  24. 查询
  25. </v-btn>
  26. </div>
  27. </v-row>
  28. </v-col>
  29. <!-- <<<<<<<< 搜索条件表单 -->
  30. </v-row>
  31. </div>
  32. </v-app>
  33. {% include 'component/jianghuJs/jhSceneV4.html' %}
  34. <script type="module">
  35. new Vue({
  36. el: '#app',
  37. template: '#app-template',
  38. vuetify: new Vuetify(),
  39. data: () => ({
  40. constantObj: {
  41. gender: [{"value": "male", "text": "男"}, {"value": "female", "text": "女"}],
  42. level: [{"value": "01", "text": "一年级"}, {"value": "02", "text": "二年级"}, {"value": "03", "text": "三年级"}],
  43. },
  44. currentSceneId: 'scene-fixed-all',
  45. localSceneListKey: `${window.appInfo.appId}_${window.appInfo.pageId}_${window.userInfo.userId}`,
  46. serverSearchInput: {
  47. level: null,
  48. gender: null
  49. },
  50. }),
  51. async created() {
  52. this.doUiAction("setDefaultSceneData");
  53. },
  54. methods: {
  55. async doUiAction(uiActionId, uiActionData) {
  56. try {
  57. switch (uiActionId) {
  58. case 'setDefaultSceneData':
  59. await this.setDefaultSceneData();
  60. break;
  61. case 'useScene':
  62. await this.useScene(uiActionData);
  63. break;
  64. case 'getTableData':
  65. await this.getTableData();
  66. break;
  67. default:
  68. console.error("[doUiAction] uiActionId not find", { uiActionId });
  69. break;
  70. }
  71. } catch (error) {
  72. throw error;
  73. } finally {
  74. window.jhMask && window.jhMask.hide();
  75. }
  76. },
  77. async getTableData() {
  78. window.vtoast.show({ message: `${JSON.stringify(this.serverSearchInput)}`, icon: 'mdi-help-circle' })
  79. },
  80. // ---------- 场景 uiAction >>>>>>>>>> --------
  81. setDefaultSceneData() {
  82. let localSceneList = localStorage.getItem(this.localSceneListKey);
  83. if (localSceneList == null) localSceneList = '[]';
  84. localSceneList = JSON.parse(localSceneList);
  85. localSceneList = _.filter(localSceneList, function (sceneItem) {
  86. return !sceneItem.system;
  87. });
  88. localSceneList = [
  89. {"form": {}, "name": "全部", "default": true, "id": "scene-custom-all", 'system': true},
  90. {"form": {"level": "02", "gender": "male"}, "name": "二年级的男生", "default": null, "id": "scene-custom-1", 'system': true},
  91. {"form": {"level": "02", "gender": "female"}, "name": "二年级的女生", "default": null, "id": "scene-custom-2", 'system': true},
  92. ...localSceneList
  93. ];
  94. this.currentSceneId = 'scene-custom-all';
  95. localStorage.setItem(this.localSceneListKey, JSON.stringify(localSceneList))
  96. },
  97. useScene(funObj) {
  98. this.currentSceneId = funObj.id;
  99. this.serverSearchInput = _.cloneDeep(funObj.form);
  100. },
  101. // ---------- <<<<<<<<<<< 场景 uiAction --------
  102. }
  103. })
  104. </script>