SelectExtSearchDialog.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <Dialog ref="dialog" v-model="dialogVisible">
  3. <template #header>
  4. <div class="row items-center">
  5. <div style="font-size: 110%">
  6. Расширенный поиск
  7. </div>
  8. </div>
  9. </template>
  10. <div ref="box" class="column q-mt-xs overflow-auto" style="max-width: 700px; padding: 0px 10px 10px 10px;">
  11. <div class="row">
  12. <div v-for="f in recStruct" :key="f.field" class="row">
  13. <div class="q-mx-xs" />
  14. <q-input
  15. v-model="search[f.field]" :maxlength="5000"
  16. class="q-mt-xs" style="width: 150px;" :label="`${f.field} (${f.type == 'N' ? 'число' : 'строка'})`"
  17. :bg-color="bgColor[f.field] || 'white'"
  18. stack-label outlined dense clearable
  19. >
  20. <q-tooltip v-if="search[f.field]" :delay="500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
  21. {{ search[f.field] }}
  22. </q-tooltip>
  23. </q-input>
  24. </div>
  25. </div>
  26. <div class="row q-mt-xs q-ml-sm" style="color: red" v-html="error" />
  27. </div>
  28. <template #footer>
  29. <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps :disabled="error !== ''" @click="apply">
  30. Применить
  31. </q-btn>
  32. <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">
  33. Закрыть
  34. </q-btn>
  35. </template>
  36. </Dialog>
  37. </template>
  38. <script>
  39. //-----------------------------------------------------------------------------
  40. import vueComponent from '../../vueComponent.js';
  41. import Dialog from '../../share/Dialog.vue';
  42. const componentOptions = {
  43. components: {
  44. Dialog
  45. },
  46. watch: {
  47. modelValue(newValue) {
  48. this.dialogVisible = newValue;
  49. },
  50. dialogVisible(newValue) {
  51. this.$emit('update:modelValue', newValue);
  52. },
  53. extSearch(newValue) {
  54. this.search = newValue;
  55. },
  56. search: {
  57. handler() {
  58. this.validate();
  59. },
  60. deep: true,
  61. },
  62. }
  63. };
  64. class SelectExtSearchDialog {
  65. _options = componentOptions;
  66. _props = {
  67. modelValue: Boolean,
  68. extSearch: Object,
  69. };
  70. dialogVisible = false;
  71. search = {};
  72. bgColor = {};
  73. error = '';
  74. created() {
  75. this.commit = this.$store.commit;
  76. }
  77. mounted() {
  78. }
  79. get config() {
  80. return this.$store.state.config;
  81. }
  82. get recStruct() {
  83. if (this.config.dbConfig && this.config.dbConfig.inpxInfo.recStruct)
  84. return this.config.dbConfig.inpxInfo.recStruct;
  85. else
  86. return [];
  87. }
  88. validate() {
  89. const validNumValue = (n) => {
  90. return false;
  91. };
  92. let error = [];
  93. const s = this.search;
  94. for (const f of this.recStruct) {
  95. if (f.type == 'N' && s[f.field] && !validNumValue(s[f.field])) {
  96. error.push(`Недопустимое значение поля ${f.field}`);
  97. this.bgColor[f.field] = 'red-2';
  98. } else {
  99. this.bgColor[f.field] = '';//default
  100. }
  101. }
  102. this.error = error.join('<br>');
  103. }
  104. okClick() {
  105. this.dialogVisible = false;
  106. }
  107. apply() {
  108. this.validate();
  109. this.dialogVisible = false;
  110. }
  111. }
  112. export default vueComponent(SelectExtSearchDialog);
  113. //-----------------------------------------------------------------------------
  114. </script>
  115. <style scoped>
  116. </style>