QueryConditionComplex.vue 14 KB

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