QueryConditionComplex.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <!-- 复杂查询过滤 -->
  2. <template>
  3. <div>
  4. <div>
  5. <div class="form-inline">
  6. <div
  7. v-for="(item,index) in filterFields"
  8. v-show="item.isShow"
  9. :key="index"
  10. class="form-group m-form-group"
  11. >
  12. <label
  13. v-tooltip.right="Language.getHelpTrl($i18n.locale, item)"
  14. :for="item.id"
  15. class="m-form-group-label"
  16. >
  17. {{ Language.getNameTrl($i18n.locale, item) }}
  18. </label>
  19. <div
  20. v-if="item.index == 1"
  21. class="form-inline-div"
  22. @keyup.enter="complexSearch()"
  23. >
  24. <input
  25. v-if="item.displayType =='TextEditor'"
  26. :id="item.id"
  27. v-model="item.value.value1"
  28. autocomplete="off"
  29. type="text"
  30. :placeholder="$t('lang.QueryConditionComplex.pleaseInputTheContent')"
  31. class="form-control form-control-complex form-input"
  32. />
  33. <input
  34. v-if="item.displayType =='NumberEditor'"
  35. :id="item.id"
  36. v-model="item.value.value1"
  37. autocomplete="off"
  38. type="number"
  39. class="form-control form-control-complex form-input"
  40. :placeholder="$t('lang.QueryConditionComplex.pleaseEnterANumber')"
  41. onmousewheel="return false;"
  42. @mousewheel="mouseWheelEvent"
  43. />
  44. <select
  45. v-if="item.displayType =='CheckBoxEditor'"
  46. v-model="item.value.value1"
  47. class="form-control form-control-complex form-input form-select"
  48. >
  49. <option value="">{{ $t('lang.QueryConditionComplex.all') }}</option>
  50. <option value="true">{{ $t('lang.QueryConditionComplex.true') }}</option>
  51. <option value="false">{{ $t('lang.QueryConditionComplex.false') }}</option>
  52. </select>
  53. <DateTime
  54. v-if="item.displayType =='DateTimeBoxEditor'"
  55. v-model="item.value.value1"
  56. class="m-form-input"
  57. @update:model-value="dateValueChange($event, item, 'value1')"
  58. />
  59. <!-- 年份选择器-->
  60. <YearPicker
  61. v-if="item.displayType =='YearEditor'"
  62. v-model="item.value.value1"
  63. class="m-form-input"
  64. @selected="textChanged(item, 'value1', $event)"
  65. />
  66. <!-- 年月选择器 -->
  67. <VueMonthlyPicker
  68. v-if="item.displayType =='YearMonthEditor'"
  69. id="month-picker"
  70. v-model="item.value.value1"
  71. date-format="YYYY-MM"
  72. class="form-inline-div m-form-input"
  73. @selected="refresh"
  74. />
  75. <!-- 日期选择器 -->
  76. <DateWidget
  77. v-if="item.displayType =='DateBoxEditor'"
  78. v-model="item.value.value1"
  79. class="m-form-input"
  80. @on-value-change="dateValueChange($event, item, 'value1')"
  81. />
  82. <EnumSelectWidgetInfo
  83. v-if="item.displayType =='ListBoxEnumEditor'"
  84. :field="item"
  85. :field-value="item.fieldValue"
  86. @value-changed="tabValueChanged($event, item, 'value1')"
  87. />
  88. <SearchWidget
  89. v-if="item.displayType =='SearchBoxEditor'"
  90. :where-clause-source="{'infoFilterField': {'infoWindowNo': infoWindowNo, 'fieldName' : item.fieldName}}"
  91. :info-window-no="item.infoWindowNo"
  92. :title-name="item.name"
  93. :field-value="item.fieldValue"
  94. :display-name="item.listFieldNames"
  95. class="m-form-input"
  96. @value-changed="tabValueChanged($event, item)"
  97. />
  98. <!-- 多选搜索框 number类型-->
  99. <MultiSearchWidget
  100. v-if="item.displayType =='MultiSearchBoxEditor'"
  101. :where-clause-source="{'infoFilterField': {'infoWindowNo': infoWindowNo, 'fieldName' : item.fieldName}}"
  102. :info-window-no="item.infoWindowNo"
  103. :title-name="item.name"
  104. :field-value="item.fieldValue"
  105. :display-name="item.listFieldNames"
  106. class="m-form-input"
  107. @value-changed="multiSearchValueChange($event, item)"
  108. />
  109. </div>
  110. <div
  111. v-if="item.index == 2"
  112. class="form-inline-div"
  113. >
  114. <input
  115. v-if="item.displayType =='TextEditor'"
  116. :id="item.id"
  117. v-model="item.value.value2"
  118. autocomplete="off"
  119. type="text"
  120. :placeholder="$t('lang.QueryConditionComplex.pleaseInputTheContent')"
  121. class="form-control form-control-complex form-input"
  122. @keyup.enter="complexSearch()"
  123. />
  124. <input
  125. v-if="item.displayType =='NumberEditor'"
  126. :id="item.id"
  127. v-model="item.value.value2"
  128. autocomplete="off"
  129. type="number"
  130. class="form-control form-control-complex form-input"
  131. :placeholder="$t('lang.QueryConditionComplex.pleaseEnterANumber')"
  132. @keyup.enter="complexSearch()"
  133. />
  134. <select
  135. v-if="item.displayType =='CheckBoxEditor'"
  136. v-model="item.value.value2"
  137. class="form-control form-control-complex form-input form-select"
  138. >
  139. <option value="">{{ $t('lang.QueryConditionComplex.all') }}</option>
  140. <option value="true">{{ $t('lang.QueryConditionComplex.true') }}</option>
  141. <option value="false">{{ $t('lang.QueryConditionComplex.false') }}</option>
  142. </select>
  143. <!-- <input autocomplete="off" v-if="item.displayType =='CheckBoxEditor'"
  144. type="checkbox" class="form-control form-control-complex form-input"
  145. :id="item.id" v-model="item.value.value2"
  146. @keyup.enter="complexSearch()"> -->
  147. <!-- <input autocomplete="off" v-if="item.displayType =='DateTimeBoxEditor'"
  148. type="date"
  149. placeholder="yyyy-MM-dd"
  150. class="form-control form-control-complex form-input"
  151. :id="item.id"
  152. v-model="item.value.value2"
  153. @keyup.enter="complexSearch()"> -->
  154. <DateTime
  155. v-if="item.displayType =='DateTimeBoxEditor'"
  156. v-model="item.value.value2"
  157. class="m-form-input"
  158. @update:model-value="dateValueChange($event, item, 'value2')"
  159. />
  160. <!-- 年份选择器-->
  161. <YearPicker
  162. v-if="item.displayType =='YearEditor'"
  163. v-model="item.value.value2"
  164. class="m-form-input"
  165. @selected="textChanged(item, 'value2', $event)"
  166. />
  167. <!-- 年月选择器 -->
  168. <vue-monthly-picker
  169. v-if="item.displayType =='YearMonthEditor'"
  170. id="month-picker"
  171. v-model="item.value.value2"
  172. date-format="YYYY-MM"
  173. class="form-inline-div m-form-input"
  174. @selected="refresh"
  175. />
  176. <!-- 日期选择器 -->
  177. <DateWidget
  178. v-if="item.displayType =='DateBoxEditor'"
  179. v-model="item.value.value2"
  180. class="m-form-input"
  181. @on-value-change="dateValueChange($event, item, 'value2')"
  182. />
  183. <EnumSelectWidgetInfo
  184. v-if="item.displayType =='ListBoxEnumEditor'"
  185. :field="item"
  186. :field-value="item.fieldValue"
  187. class="m-form-input"
  188. @value-changed="tabValueChanged($event, item)"
  189. />
  190. <!--单选number类型-->
  191. <SearchWidget
  192. v-if="item.displayType =='SearchBoxEditor'"
  193. :where-clause-source="{'infoFilterField': {'infoWindowNo': infoWindowNo, 'fieldName' : item.fieldName}}"
  194. :info-window-no="item.infoWindowNo"
  195. :title-name="item.name"
  196. :field-value="item.fieldValue"
  197. :display-name="item.listFieldNames"
  198. class="m-form-input"
  199. @value-changed="tabValueChanged($event, item)"
  200. />
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. <div>
  206. <div>
  207. <div>
  208. <button
  209. id="filter"
  210. type="button"
  211. class="btn btn-default m-btn"
  212. @click="complexSearch()"
  213. >
  214. {{ $t('lang.QueryConditionComplex.filter') }}
  215. </button>
  216. <template v-if="!isSearchWidget">
  217. <button
  218. type="button"
  219. class="btn btn-default m-btn"
  220. @click="executeExport()"
  221. >
  222. {{ $t('lang.QueryConditionComplex.export') }}
  223. </button>
  224. <template v-for="infoButton in infoButtons" :key="infoButton.name">
  225. <button
  226. v-tooltip.right="Language.getHelpTrl($i18n.locale, infoButton)"
  227. class="btn btn-default btn-process m-btn"
  228. @click="executeProcess(infoButton)"
  229. >
  230. {{ Language.getNameTrl($i18n.locale, infoButton) }}
  231. </button>
  232. </template>
  233. </template>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. </template>
  239. <script>
  240. import { defineAsyncComponent } from 'vue';
  241. import EnumSelectWidgetInfo from './EnumSelectWidgetInfo.vue';
  242. import DateTime from '../../datetime/src/DateTime.vue';
  243. import YearPicker from '../../year-picker/src/YearPicker.vue';
  244. import DateWidget from '../../date/src/Date.vue';
  245. import VueMonthlyPicker from '../../vue-monthly-picker/src/VueMonthlyPicker.vue';
  246. import Language from '../../common/Language.js';
  247. export default {
  248. components: {
  249. EnumSelectWidgetInfo,
  250. DateTime,
  251. SearchWidget : defineAsyncComponent(() =>
  252. import('./SearchWidget.vue'),
  253. ),
  254. MultiSearchWidget : defineAsyncComponent(() =>
  255. import('./MultiSearchWidget.vue'),
  256. ),
  257. DateWidget,
  258. VueMonthlyPicker,
  259. YearPicker,
  260. },
  261. props: {
  262. 'infoWindowNo':{
  263. type: String,
  264. default: null,
  265. },
  266. 'filterFields': {
  267. type: Array,
  268. default: null,
  269. },
  270. 'infoButtons': {
  271. type: Array,
  272. default: null,
  273. },
  274. 'isSearchWidget':{
  275. type: Boolean,
  276. default: null,
  277. },
  278. 'showButton':{
  279. type: Boolean,
  280. default: null,
  281. },
  282. },
  283. emits: ['complexSearch', 'executeExport', 'executeProcess'],
  284. data: function () {
  285. this.Language = Language;
  286. return {
  287. simpleConditionValue: '',
  288. selectedText: [],
  289. };
  290. },
  291. methods: {
  292. /**
  293. * 日期时间选择框值改变事件
  294. */
  295. dateValueChange: function (value, item, fieldName) {
  296. item.value[fieldName] = value;
  297. },
  298. /**
  299. * 年月选择器时间改变
  300. */
  301. refresh: function () {
  302. },
  303. /**
  304. * 年份选择器的值改变
  305. * @param {Object} item
  306. * @param {Object} key
  307. * @param {Object} val
  308. */
  309. textChanged: function (item, key, val) {
  310. var value = val + ' ';
  311. item.value[key] = value.replace(/(^\s*)|(\s*$)/g, '');
  312. },
  313. /**
  314. * 搜索框值发生改变
  315. * @param {Object} newFieldValue 改变后的值
  316. * @param {Object} item 当前field
  317. * @return {void}
  318. */
  319. tabValueChanged: function (newFieldValue, item) {
  320. item.fieldValue = newFieldValue;
  321. if (item.index == 1) {
  322. if (item.displayType == 'ListBoxEnumEditor') {
  323. item.value.value1 = newFieldValue.displayValue[0];
  324. } else {
  325. item.value.value1 = newFieldValue.id;
  326. }
  327. } else if (item.index == 2) {
  328. item.value.value2 = newFieldValue.id;
  329. }
  330. item.value.infoFilterFieldId = item.id;
  331. },
  332. // 多选搜索框值发生改变事件
  333. multiSearchValueChange: function (newFieldValue, item) {
  334. var _self = this;
  335. item.fieldValue = newFieldValue;
  336. var ids = newFieldValue.ids;
  337. var texts = newFieldValue.displayValue;
  338. if (item.index == 1) {
  339. item.value.value1 = ids.join(',');
  340. } else if (item.index == 2) {
  341. item.value.value2 = ids.join(',');
  342. }
  343. item.value.infoFilterFieldId = item.id;
  344. },
  345. /**
  346. * 回车键查询
  347. * @return {void}
  348. */
  349. complexSearch: function () {
  350. this.$emit('complexSearch');
  351. },
  352. /**
  353. * 执行导出
  354. * @return {void}
  355. */
  356. executeExport: function () {
  357. this.$emit('executeExport');
  358. },
  359. /**
  360. * 获取查询条件供外部调用
  361. * @return {Object} 查询条件
  362. */
  363. getQueryCondition: function () {
  364. var _self = this;
  365. var values = [];
  366. _self.filterFields.forEach(function (item) {
  367. if (item.index == 1) {
  368. item.value.fieldName = item.fieldName;
  369. values.push(item.value);
  370. }
  371. });
  372. return values;
  373. },
  374. /**
  375. * 执行流程
  376. *
  377. */
  378. executeProcess: function (infoButton) {
  379. this.$emit('executeProcess', infoButton);
  380. },
  381. /**
  382. * 禁止滚轮滚动影响数字
  383. */
  384. mouseWheelEvent: function (event) {
  385. if (event || Window.event) {
  386. event.preventDefault();
  387. }
  388. },
  389. },
  390. };
  391. </script>
  392. <style scoped>
  393. .form-input {
  394. border-radius: 4px !important;
  395. }
  396. .form-inline-div {
  397. display: inline-block;
  398. }
  399. .m-select {
  400. display: inline-block !important;
  401. }
  402. .m-form-group {
  403. margin-left: 5px !important;
  404. margin-right: 5px !important;
  405. margin-bottom: 5px !important;
  406. }
  407. .m-form-group-label{
  408. white-space: nowrap;
  409. text-overflow: ellipsis;
  410. }
  411. @media (max-width: 768px) {
  412. .m-form-group-label {
  413. text-align: left;
  414. padding-right: 10px;
  415. }
  416. }
  417. @media (min-width: 768px) {
  418. .m-form-group-label {
  419. width: 100px;
  420. text-align: center;
  421. padding-right: 10px;
  422. }
  423. .input-switches {
  424. width: 100%;
  425. }
  426. }
  427. .btn-process {
  428. margin-right: 5px;
  429. }
  430. .m-row {
  431. margin-bottom: 5px;
  432. text-align: left;
  433. }
  434. .form-control-complex {
  435. float: none !important;
  436. width: auto !important;
  437. }
  438. .input-simple {
  439. width: 100% !important;
  440. }
  441. .input-switches {
  442. width: 200px;
  443. }
  444. .form-select {
  445. width: 200px !important;
  446. }
  447. .m-form-input {
  448. border-radius: 4px !important;
  449. width: 200px !important;
  450. }
  451. .form-control-complex {
  452. width: 200px !important;
  453. }
  454. .m-btn {
  455. float: left;
  456. margin-right: 5px;
  457. }
  458. </style>