search.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. <template>
  2. <div class="advance">
  3. <!--高级查询-->
  4. <div class="content">
  5. <!-- <div class="btns">
  6. <el-button type="primary" size="small" plain @click="addParamsHandler">新增</el-button>
  7. <el-button type="primary" size="small" @click="advancedQueryHandler(false)">查询</el-button>
  8. </div> -->
  9. <el-form ref="paramsForm" class="query-params" :model="paramsForm" :rules="paramsForm.validateRules" :inline="true">
  10. <el-table :data="paramsForm.params" height="248" border stripe>
  11. <el-table-column type="index" label="行号" :index="index => index + 1" align="center" width="60" />
  12. <el-table-column v-for="(col, index) in paramsTableCols" :key="index" :label="col.label" :align="col.align || 'center'">
  13. <template slot-scope="scope">
  14. <el-form-item :prop="'params.' + scope.$index + '.' + col.prop" :rules="paramsForm.validateRules[col.prop]">
  15. <template v-if="col.prop === 'comparisonOperator' || col.inputType[scope.$index] === 'select'">
  16. <el-select v-model="scope.row[col.prop]" placeholder="请选择" @change="
  17. value => {
  18. selectChangeHandler(value, scope.$index, index)
  19. }
  20. ">
  21. <el-option v-for="(option, index) in col.options[scope.$index]" :key="index" :value="option.value" :label="option.label" />
  22. </el-select>
  23. </template>
  24. <template v-else-if="col.inputType === 'select'">
  25. <el-select v-model="scope.row[col.prop]" placeholder="请选择" @change="
  26. value => {
  27. selectChangeHandler(value, scope.$index, index)
  28. }
  29. ">
  30. <el-option v-for="(option, index) in col.options" :key="index" :value="option.value" :label="option.label" :disabled="col.prop === 'paramKey' && option.value === 'flightDate'" />
  31. </el-select>
  32. </template>
  33. <template v-else-if="['varchar', 'text', 'longtext'].includes(col.inputType[scope.$index])">
  34. <el-input v-model="scope.row[col.prop]" placeholder="请输入" :disabled="col.prop === 'paramValue' && paramsForm.disabled[scope.$index]" />
  35. </template>
  36. <template v-else-if="col.inputType[scope.$index] === 'number'">
  37. <el-input v-model="scope.row[col.prop]" placeholder="请输入" :disabled="col.prop === 'paramValue' && paramsForm.disabled[scope.$index]" @keydown.native="inputHold(scope.row[col.prop])" @input="inputLimit(scope.row[col.prop], scope.$index)" @blur="inputFix(scope.row[col.prop], scope.$index)" />
  38. </template>
  39. <template v-else-if="col.inputType[scope.$index] === 'date'">
  40. <el-date-picker v-model="scope.row[col.prop]" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="请选择" :clearable="false" :picker-options="datePickerOptions(scope.$index, index)" @change="
  41. value => {
  42. dateChangeHandler(value, scope.$index, index)
  43. }
  44. " />
  45. </template>
  46. <template v-else-if="col.inputType[scope.$index] === 'datetime'">
  47. <el-date-picker v-model="scope.row[col.prop]" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择" :clearable="false" />
  48. </template>
  49. </el-form-item>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="操作" width="80" align="center">
  53. <template slot-scope="scope">
  54. <el-popconfirm title="是否要删除这一行?" @confirm="deleteParam(scope.$index)">
  55. <span slot="reference" class="clickable-delete">删除</span>
  56. </el-popconfirm>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </el-form>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import Search from '@/components/SearchWithTooltip'
  66. import SimpleTable from '@/components/SimpleTable'
  67. import Dialog from '@/layout/components/Dialog'
  68. import { parseTime } from '@/utils/index'
  69. import { Query } from '@/api/dataIntegration'
  70. import { throttledExportToExcel } from '@/utils/table'
  71. import { mapGetters } from 'vuex'
  72. const comparisonOperatorOptions = [
  73. {
  74. label: '小于等于',
  75. value: '<='
  76. },
  77. {
  78. label: '大于等于',
  79. value: '>='
  80. },
  81. {
  82. label: '小于',
  83. value: '<'
  84. },
  85. {
  86. label: '大于',
  87. value: '>'
  88. },
  89. {
  90. label: '等于',
  91. value: '='
  92. },
  93. {
  94. label: '不等于',
  95. value: '!='
  96. },
  97. {
  98. label: '为空',
  99. value: 'is Null'
  100. },
  101. {
  102. label: '不为空',
  103. value: 'is not Null'
  104. },
  105. {
  106. label: '包含',
  107. value: 'like'
  108. }
  109. ]
  110. export default {
  111. name: 'AdvancedNew',
  112. components: { Search, SimpleTable, Dialog },
  113. props: {
  114. tableColMunt: {
  115. type: Array,
  116. default: () => []
  117. },
  118. dataQuery: {
  119. type: Array,
  120. default: () => []
  121. },
  122. },
  123. data () {
  124. return {
  125. queryString: '',
  126. flightDate: new Array(2).fill(parseTime(new Date(), '{y}-{m}-{d}')),
  127. dateRangePickerOptions: {
  128. onPick: this.dateRangePickHandler,
  129. disabledDate: this.dateRangeDisabled
  130. },
  131. loading: false,
  132. page: 0,
  133. noMore: false,
  134. tableCols: [],
  135. tableData: [],
  136. dialogFlag: false,
  137. paramsForm: {
  138. params: [],
  139. validateRules: {
  140. paramKey: [{ required: true, message: '请选择项', trigger: ['change', ['change', 'blur']] }],
  141. paramValue: [{ required: true, message: '请选择或输入值', trigger: ['change', 'blur'] }]
  142. },
  143. disabled: []
  144. },
  145. checkValue: '',
  146. paramsTableCols: [
  147. {
  148. prop: 'leftBrackets',
  149. label: '左括号',
  150. inputType: 'select',
  151. options: [
  152. {
  153. label: '(',
  154. value: '('
  155. },
  156. {
  157. label: '((',
  158. value: '(('
  159. },
  160. {
  161. label: '(((',
  162. value: '((('
  163. }
  164. ]
  165. },
  166. {
  167. prop: 'paramKey',
  168. label: '项',
  169. inputType: 'select',
  170. options: []
  171. },
  172. {
  173. prop: 'comparisonOperator',
  174. label: '比较符',
  175. inputType: 'select',
  176. options: new Array(2).fill(comparisonOperatorOptions.slice(0, 5).reverse())
  177. },
  178. {
  179. prop: 'paramValue',
  180. label: '值',
  181. inputType: ['date', 'date'],
  182. options: []
  183. },
  184. {
  185. prop: 'rightBrackets',
  186. label: '右括号',
  187. inputType: 'select',
  188. options: [
  189. {
  190. label: ')',
  191. value: ')'
  192. },
  193. {
  194. label: '))',
  195. value: '))'
  196. },
  197. {
  198. label: ')))',
  199. value: ')))'
  200. }
  201. ]
  202. },
  203. {
  204. prop: 'connector',
  205. label: '连接',
  206. inputType: 'select',
  207. options: [
  208. {
  209. label: '并且',
  210. value: 'and'
  211. },
  212. {
  213. label: '或者',
  214. value: 'or'
  215. }
  216. ]
  217. }
  218. ],
  219. columnSet: {}
  220. }
  221. },
  222. computed: {
  223. ...mapGetters(['authMsg']),
  224. },
  225. watch: {
  226. dataQuery: {
  227. handler (arr) {
  228. if (arr && arr.length) {
  229. const datas = []
  230. const types = []
  231. arr.forEach(item => {
  232. if (item.value.includes('-')) {
  233. types.push('date')
  234. }
  235. types.push('text')
  236. const obj = {
  237. leftBrackets: item.left,
  238. paramKey: item.column,
  239. comparisonOperator: item.comparator,
  240. rightBrackets: item.right,
  241. paramValue: item.value,
  242. connector: item['connector']
  243. }
  244. datas.push(obj)
  245. })
  246. this.paramsTableCols[3].inputType = types
  247. setTimeout(() => {
  248. this.paramsForm.params = datas
  249. }, 20);
  250. } else {
  251. this.paramsForm.params = []
  252. }
  253. },
  254. deep: true
  255. },
  256. },
  257. mounted () {
  258. const colDatas = this.authMsg
  259. if (colDatas && colDatas.length) {
  260. const columns = colDatas.filter(item => item.is_search == 1)
  261. this.getColumnSet(columns)
  262. }
  263. },
  264. deactivated () {
  265. this.loading = false
  266. },
  267. beforeDestroy () {
  268. this.loading = false
  269. },
  270. methods: {
  271. queryHandler (query) {
  272. // let queryFlag = false
  273. // const { singleJump } = query
  274. // const queryEntries = Object.entries(query)
  275. // if (queryEntries.length) {
  276. // this.clearForm()
  277. // queryEntries.forEach(([key, value]) => {
  278. // if ((value ?? '') !== '') {
  279. // queryFlag = true
  280. // switch (key) {
  281. // case 'singleJump':
  282. // break
  283. // case 'startDate':
  284. // this.$set(this.flightDate, 0, value)
  285. // break
  286. // case 'endDate':
  287. // this.$set(this.flightDate, 1, value)
  288. // break
  289. // case 'unLoad':
  290. // case 'checkIn':
  291. // case 'active':
  292. // case 'transferIn':
  293. // case 'canceled':
  294. // this.paramsForm.params.push({
  295. // leftBrackets: '',
  296. // paramKey: key,
  297. // comparisonOperator: '=',
  298. // paramValue: value,
  299. // rightBrackets: '',
  300. // connector: 'and'
  301. // })
  302. // break
  303. // default:
  304. // break
  305. // }
  306. // }
  307. // })
  308. // }
  309. // if (queryFlag) {
  310. // this.advancedQueryHandler(singleJump)
  311. // }
  312. },
  313. dateRangePickHandler ({ maxDate, minDate }) {
  314. if (!maxDate) {
  315. this.pickedDate = minDate
  316. } else {
  317. this.pickedDate = null
  318. this.paramsForm.params[0].paramValue = minDate
  319. this.paramsForm.params[1].paramValue = maxDate
  320. }
  321. },
  322. dateRangeDisabled (date) {
  323. return this.pickedDate ? Math.abs(date - this.pickedDate) > 2 * 24 * 60 * 60 * 1000 : false
  324. },
  325. toOldAdvance () {
  326. this.$router.push('/advance')
  327. },
  328. dialogShow () {
  329. this.dialogFlag = true
  330. this.$nextTick(() => {
  331. this.dialogFocus()
  332. })
  333. },
  334. dialogFocus () {
  335. this.$refs['dialog'].focus()
  336. },
  337. dialogHide () {
  338. this.$emit('dialogHide')
  339. },
  340. sendColData () {
  341. this.$emit('getColData', this.queryString)
  342. },
  343. addParamsHandler () {
  344. this.paramsTableCols[3].inputType.push('text')
  345. this.paramsForm.params.push({
  346. leftBrackets: '',
  347. paramKey: '',
  348. comparisonOperator: '',
  349. paramValue: '',
  350. rightBrackets: '',
  351. connector: 'and'
  352. })
  353. },
  354. selectChangeHandler (value, rowIndex, colIndex) {
  355. if (colIndex === 1) {
  356. const datas = this.tableColMunt.filter(item => item.columnName == value)
  357. const { dataType, options } = this.columnSet[value]
  358. // const { dataType, options } = datas[0]
  359. if (dataType === 'date') {
  360. this.paramsTableCols[2].options[rowIndex] = comparisonOperatorOptions.slice(0, 5).reverse()
  361. this.paramsTableCols[3].inputType[rowIndex] = 'date'
  362. } else if (dataType === 'datetime') {
  363. this.paramsTableCols[2].options[rowIndex] = comparisonOperatorOptions.slice(0, 5).reverse()
  364. this.paramsTableCols[3].inputType[rowIndex] = 'datetime'
  365. } else if (options) {
  366. this.paramsTableCols[2].options[rowIndex] = comparisonOperatorOptions.slice(4, 5)
  367. this.paramsTableCols[3].inputType[rowIndex] = 'select'
  368. this.paramsTableCols[3].options[rowIndex] = options
  369. this.paramsForm.params[rowIndex].paramValue = ''
  370. } else if (dataType === 'number') {
  371. this.paramsTableCols[2].options[rowIndex] = comparisonOperatorOptions.slice(0, 5).reverse()
  372. this.paramsTableCols[3].inputType[rowIndex] = 'number'
  373. this.paramsForm.params[rowIndex].paramValue = ''
  374. } else {
  375. this.paramsTableCols[2].options[rowIndex] = comparisonOperatorOptions.slice(4)
  376. this.paramsTableCols[3].inputType[rowIndex] = 'text'
  377. }
  378. this.paramsForm.params[rowIndex].comparisonOperator = this.paramsTableCols[2].options[rowIndex][0].value
  379. } else if (colIndex === 2) {
  380. if (['is Null', 'is not Null'].includes(value)) {
  381. this.paramsForm.params[rowIndex].paramValue = ''
  382. this.paramsForm.disabled[rowIndex] = true
  383. } else {
  384. this.paramsForm.disabled[rowIndex] = false
  385. }
  386. }
  387. },
  388. datePickerOptions (rowIndex, colIndex) {
  389. return rowIndex === 1 && colIndex === 3 ? { disabledDate: this.endDateDisabled } : {}
  390. },
  391. endDateDisabled (endDate) {
  392. const startDate = new Date(this.paramsForm.params[0].paramValue)
  393. endDate = new Date(endDate)
  394. return (
  395. startDate.getTime() >= endDate.getTime() + 24 * 60 * 60 * 1000 ||
  396. startDate.getTime() < endDate.getTime() - 3 * 24 * 60 * 60 * 1000
  397. )
  398. },
  399. dateChangeHandler (dateString, rowIndex, colIndex) {
  400. if (colIndex !== 3) {
  401. return
  402. }
  403. let startDate, endDate
  404. if (rowIndex === 0) {
  405. startDate = new Date(dateString)
  406. endDate = new Date(this.paramsForm.params[1].paramValue)
  407. } else if (rowIndex === 1) {
  408. startDate = new Date(this.paramsForm.params[0].paramValue)
  409. endDate = new Date(dateString)
  410. }
  411. if (startDate.getTime() >= endDate.getTime() + 24 * 60 * 60 * 1000) {
  412. this.$message.warning('开始日期不能大于结束日期')
  413. this.paramsForm.params[1].paramValue = ''
  414. } else if (startDate.getTime() < endDate.getTime() - 3 * 24 * 60 * 60 * 1000) {
  415. this.$message.warning('间隔日期不能超过三天')
  416. this.paramsForm.params[1].paramValue = ''
  417. } else {
  418. this.flightDate = [this.paramsForm.params[0].paramValue, this.paramsForm.params[1].paramValue]
  419. }
  420. },
  421. inputHold (value) {
  422. this.checkValue = value
  423. },
  424. inputLimit (value, rowIndex) {
  425. if (!/^[\-|\+]?((([1-9][0-9]*)|0)(\.[0-9]{0,2})?)?$/.test(value)) {
  426. this.paramsForm.params[rowIndex].paramValue = this.checkValue
  427. }
  428. },
  429. inputFix (value, rowIndex) {
  430. if (value?.at(-1) === '.') {
  431. this.paramsForm.params[rowIndex].paramValue = value.slice(0, -1)
  432. }
  433. },
  434. advancedQueryHandler (singleJump) {
  435. try {
  436. this.$refs['paramsForm'].validate(valid => {
  437. if (!valid) {
  438. throw new Error()
  439. }
  440. })
  441. const queryString = []
  442. this.paramsForm.params.forEach(item => {
  443. const obj = {
  444. left: item['leftBrackets'],
  445. column: item['paramKey'],
  446. comparator: item['comparisonOperator'],
  447. value: item['paramValue'],
  448. right: item['rightBrackets'],
  449. connector: item['connector']
  450. }
  451. queryString.push(obj)
  452. })
  453. this.queryString = queryString
  454. this.sendColData()
  455. this.dialogHide()
  456. } catch (error) {
  457. error.message && this.$message.error(error.message)
  458. }
  459. },
  460. deleteParam (index) {
  461. this.paramsTableCols[3].inputType.splice(index, 1)
  462. this.paramsForm.params.splice(index, 1)
  463. this.paramsForm.disabled.splice(index, 1)
  464. },
  465. clearForm () {
  466. this.paramsTableCols[2].options = new Array(2).fill(comparisonOperatorOptions.slice(0, 5).reverse())
  467. this.paramsTableCols[3].inputType = ['date', 'date']
  468. this.paramsTableCols[3].options = []
  469. this.paramsForm.params.splice(2)
  470. this.paramsForm.disabled = []
  471. },
  472. async getColumnSet (columnSet) {
  473. const reflect = {}
  474. columnSet.forEach(async column => {
  475. if (!this.columnSet[column.columnName]) {
  476. this.columnSet[column.columnName] = column
  477. if ((column.listqueryTemplateID ?? '') !== '' && !this.columnSet[column.columnName].options) {
  478. if (reflect[column.listqueryTemplateID]) {
  479. reflect[column.listqueryTemplateID].push(column.columnName)
  480. } else {
  481. reflect[column.listqueryTemplateID] = [column.columnName]
  482. }
  483. }
  484. this.paramsTableCols[1].options.push({
  485. label: column.columnLabel,
  486. value: column.columnName
  487. })
  488. }
  489. })
  490. const optionsList = await Promise.all(
  491. Object.keys(reflect).map(listqueryTemplateID => this.getSelectData(Number(listqueryTemplateID)))
  492. )
  493. optionsList.forEach(({ id, options }) => {
  494. reflect[id].forEach(columnName => {
  495. this.columnSet[columnName].options = options.map(option => ({
  496. label: option.k,
  497. value: option.v
  498. }))
  499. })
  500. })
  501. },
  502. load () {
  503. if (this.noMore || this.loading) {
  504. return
  505. }
  506. this.queryTableData()
  507. },
  508. resetTable () {
  509. this.page = 0
  510. this.noMore = false
  511. this.tableData = []
  512. },
  513. // 给表头单元格加上 ascending 或 descending 使用 element 自带的排序箭头变色
  514. headerCellClass () {
  515. return function ({ row, column, rowIndex, columnIndex }) {
  516. const classes = []
  517. const rule = this.tableDataSortRules[column.property]
  518. if (rule) {
  519. classes.push(rule)
  520. }
  521. return classes.join(' ')
  522. }
  523. },
  524. rowClass () {
  525. return function ({ row, rowIndex }) {
  526. const classes = []
  527. if (row.deleted === 'DEL') {
  528. classes.push('bgl-deleted')
  529. }
  530. return classes.join(' ')
  531. }
  532. },
  533. cellClass () {
  534. return function ({ row, column, rowIndex, columnIndex }) {
  535. const classes = []
  536. if (
  537. ['flightNO', 'passengerName', 'bagSN', 'U_Device_ID', 'preFlightNO', 'transferFlightNO'].includes(
  538. column.property
  539. ) &&
  540. row[column.property] &&
  541. row[column.property] !== 'FBULK'
  542. ) {
  543. classes.push('cell-click')
  544. if (
  545. this.clickedCells.some(
  546. cell =>
  547. cell.pageName === 'advance' &&
  548. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  549. cell.columnProp === column.property
  550. )
  551. ) {
  552. classes.push('cell-clicked')
  553. }
  554. }
  555. return classes.join(' ')
  556. }
  557. },
  558. cellClickHandler (row, column, cell, event) {
  559. if (
  560. ['flightNO', 'passengerName', 'bagSN', 'U_Device_ID', 'preFlightNO', 'transferFlightNO'].includes(
  561. column.property
  562. ) &&
  563. row[column.property] &&
  564. row[column.property] !== 'FBULK'
  565. ) {
  566. this.$store.dispatch('keepAlive/addClickedCell', {
  567. row,
  568. columnProp: column.property,
  569. pageName: 'advance'
  570. })
  571. switch (column.property) {
  572. case 'flightNO':
  573. this.$router.push({
  574. path: '/advance/flightView',
  575. query: {
  576. flightNO: row.flightNO,
  577. flightDate: row.flightDate
  578. }
  579. })
  580. break
  581. case 'passengerName':
  582. this.$store.dispatch('app/setPassengerQueryParams', {
  583. flightNO: row.flightNO,
  584. flightDate: row.flightDate,
  585. passengerName: row.passengerName
  586. })
  587. this.$store.dispatch('app/togglePassengerDialogFlag', true)
  588. case 'bagSN':
  589. this.$router.push({
  590. path: '/advance/baggageView',
  591. query: {
  592. flightNO: row.flightNO,
  593. flightDate: row.flightDate,
  594. bagSN: row.bagSN
  595. }
  596. })
  597. break
  598. case 'U_Device_ID':
  599. this.$router.push({
  600. path: '/advance/containerView',
  601. query: {
  602. containerID: row.U_Device_ID
  603. }
  604. })
  605. break
  606. case 'transferFlightNO':
  607. this.$router.push({
  608. path: '/advance/flightView',
  609. query: {
  610. flightNO: row.transferFlightNO,
  611. flightDate: row.transferFlightDate
  612. }
  613. })
  614. break
  615. case 'preFlightNO':
  616. this.$router.push({
  617. path: '/advance/flightView',
  618. query: {
  619. flightNO: row.preFlightNO,
  620. flightDate: row.preFlightDate
  621. }
  622. })
  623. break
  624. default:
  625. break
  626. }
  627. }
  628. },
  629. tableFormatter () {
  630. return function (row, column, cellValue) {
  631. switch (column.property) {
  632. case 'departureTime':
  633. return (cellValue ?? '').replace('T', ' ')
  634. case 'deleted':
  635. return cellValue === 'DEL' ? cellValue : ''
  636. case 'activated':
  637. return cellValue === 1 ? '激活' : '未激活'
  638. default:
  639. return cellValue ?? ''
  640. }
  641. }
  642. },
  643. // 清除查询
  644. clearSearchData () {
  645. // this.clearForm()
  646. // this.resetTable()
  647. },
  648. // 统计行数
  649. summaryRow (num) {
  650. return function () {
  651. return ['合计', `共${num}件`]
  652. }
  653. },
  654. getSearchData (val) {
  655. this.clearForm()
  656. if (!val) {
  657. this.$message.error('请先输入完整查询信息')
  658. return
  659. }
  660. const az = /^[a-zA-Z]+$/
  661. const azNum = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]*$/
  662. const top2 = /^([a-zA-Z][0-9])|([0-9][a-zA-Z])|([a-zA-Z]{2})/
  663. const num = /^[0-9]+$/
  664. const bagNo = /^[a-zA-Z]{2}[0-9]{6}$/
  665. if (az.test(val)) {
  666. // 纯字母则为旅客姓名
  667. this.paramsForm.params.push({
  668. leftBrackets: '',
  669. paramKey: 'passengerName',
  670. comparisonOperator: '=',
  671. paramValue: val,
  672. rightBrackets: '',
  673. connector: 'and'
  674. })
  675. } else if (azNum.test(val) && top2.test(val)) {
  676. // 字母加数字且前两位为字母则为航班号
  677. this.paramsForm.params.push({
  678. leftBrackets: '',
  679. paramKey: 'flightNO',
  680. comparisonOperator: '=',
  681. paramValue: val,
  682. rightBrackets: '',
  683. connector: 'and'
  684. })
  685. } else if ((num.test(val) && val.length === 10) || bagNo.test(val)) {
  686. // 纯数字且位数等于10则为行李牌号
  687. this.paramsForm.params.push({
  688. leftBrackets: '',
  689. paramKey: 'bagSN',
  690. comparisonOperator: '=',
  691. paramValue: val,
  692. rightBrackets: '',
  693. connector: 'and'
  694. })
  695. } else {
  696. this.$message.error('请先输入有效查询信息如航班号、旅客姓名首字母、行李牌号')
  697. return
  698. }
  699. this.paramsTableCols[2].options[2] = comparisonOperatorOptions.slice(4)
  700. this.paramsTableCols[3].inputType[2] = 'text'
  701. this.advancedQueryHandler()
  702. },
  703. // 获取下拉数据
  704. async getSelectData (id) {
  705. const result = { id }
  706. try {
  707. const { code, returnData } = await Query({
  708. id,
  709. dataContent: []
  710. })
  711. if (Number(code) === 0) {
  712. result.options = returnData.listValues
  713. } else {
  714. result.options = []
  715. }
  716. } catch (error) {
  717. result.options = []
  718. }
  719. return result
  720. },
  721. async queryTableData (singleJump) {
  722. this.loading = true
  723. try {
  724. const {
  725. code,
  726. returnData: { columnSet, listValues }
  727. } = await Query({
  728. id: DATACONTENT_ID.advancedQueryNew,
  729. needPage: ++this.page,
  730. dataContent: [],
  731. queryConcat: this.queryString || '1 = 2'
  732. })
  733. if (Number(code) === 0) {
  734. if (!listValues.length) {
  735. this.page--
  736. this.noMore = true
  737. } else if (singleJump) {
  738. if (listValues.length === 1) {
  739. this.$router.push({
  740. path: '/advance/baggageView',
  741. query: {
  742. bagSN: listValues[0].bagSN,
  743. flightNO: listValues[0].flightNO,
  744. flightDate: listValues[0].flightDate
  745. }
  746. })
  747. } else {
  748. const onlyFlight = listValues.reduce((pre, curr) => {
  749. if (
  750. pre === null ||
  751. (curr.flightNO &&
  752. curr.flightDate &&
  753. curr.flightNO === pre.flightNO &&
  754. curr.flightDate === pre.flightDate)
  755. ) {
  756. return {
  757. flightNO: curr.flightNO,
  758. flightDate: curr.flightDate
  759. }
  760. } else {
  761. return {}
  762. }
  763. }, null)
  764. if (onlyFlight.flightNO) {
  765. this.$router.push({
  766. path: '/advance/flightView',
  767. query: onlyFlight
  768. })
  769. }
  770. }
  771. }
  772. this.tableCols = columnSet
  773. this.tableData.push(...listValues)
  774. } else {
  775. this.page--
  776. this.$message.error('获取表格数据失败')
  777. }
  778. } catch (error) {
  779. this.$message.error('失败')
  780. }
  781. this.loading = false
  782. },
  783. tableMountedHandler (refName, ref) {
  784. this.$refs[refName] = ref
  785. },
  786. exportHandler (refName, tableName) {
  787. if (!this.tableData.length) {
  788. this.$message.info('无数据')
  789. return
  790. }
  791. const table = this.$refs[refName].$el.cloneNode(true)
  792. const fileName = `${tableName}.xlsx`
  793. throttledExportToExcel(table, tableName, fileName)
  794. }
  795. }
  796. }
  797. </script>
  798. <style lang="scss" scoped>
  799. .advance {
  800. &__head {
  801. line-height: 32px;
  802. margin-top: 8px;
  803. margin-bottom: 16px;
  804. .btnAn:not(:last-child) {
  805. margin-right: 12px;
  806. }
  807. // .setting {
  808. // height: 32px;
  809. // width: 32px;
  810. // cursor: pointer;
  811. // background-size: 100% 100%;
  812. // background: url("@/assets/baggage/ic_setting.png") no-repeat;
  813. // margin-left: 12px;
  814. // position: relative;
  815. // top: 2px;
  816. // }
  817. ::v-deep .interfaceLog_head_time {
  818. .el-input__prefix {
  819. left: 10px;
  820. color: #101116;
  821. }
  822. .el-input--prefix .el-input__inner {
  823. padding-left: 50px;
  824. }
  825. }
  826. }
  827. }
  828. .advance__table {
  829. width: 100%;
  830. ::v-deep .el-table {
  831. .el-table__body-wrapper {
  832. tr.bgl-deleted {
  833. background: #d2d6df;
  834. td {
  835. background: #d2d6df;
  836. font-style: italic;
  837. }
  838. }
  839. }
  840. }
  841. }
  842. .title {
  843. display: flex;
  844. justify-content: space-between;
  845. margin-bottom: 0;
  846. .el-icon-close {
  847. margin-right: 16px;
  848. cursor: pointer;
  849. }
  850. }
  851. .content {
  852. margin: 0 0 20px;
  853. padding: 0 24px;
  854. .btns {
  855. display: flex;
  856. justify-content: flex-end;
  857. padding: 20px 0;
  858. .el-button {
  859. width: 72px;
  860. &:not(:first-child) {
  861. margin-left: 16px;
  862. }
  863. }
  864. }
  865. ::v-deep .query-params {
  866. padding: 0;
  867. .el-table {
  868. width: 100%;
  869. .el-table__header {
  870. .el-table__cell {
  871. padding: 0;
  872. .cell {
  873. height: 40px;
  874. line-height: 40px;
  875. font-family: Helvetica, "Microsoft YaHei";
  876. font-weight: bold;
  877. color: #303133;
  878. }
  879. }
  880. }
  881. .el-table__body {
  882. .el-table__cell {
  883. padding: 0;
  884. .cell {
  885. padding: 0;
  886. .el-form-item {
  887. margin: 0;
  888. height: 40px;
  889. .el-form-item__error {
  890. top: 60%;
  891. left: 14px;
  892. }
  893. .el-input__inner {
  894. background: transparent;
  895. color: #101116;
  896. font-family: Helvetica, "Microsoft YaHei";
  897. &:hover {
  898. background-color: #ffffff;
  899. }
  900. }
  901. &.is-error .el-input__inner::-webkit-input-placeholder {
  902. visibility: hidden;
  903. }
  904. &:not(.is-error) .el-input__inner {
  905. border: none;
  906. }
  907. .el-select {
  908. .el-icon-arrow-up::before {
  909. content: "\e78f";
  910. color: #101116;
  911. }
  912. .el-icon-arrow-down::before {
  913. content: "\e790";
  914. color: #101116;
  915. }
  916. }
  917. }
  918. .clickable-delete {
  919. font-family: Microsoft YaHei;
  920. color: #ed3c3c;
  921. cursor: pointer;
  922. }
  923. }
  924. }
  925. }
  926. }
  927. }
  928. }
  929. </style>