table.vue 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. <template>
  2. <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
  3. element-loading-background="rgba(0, 0, 0, 0.8)" class="newQueryTable">
  4. <template v-if="istableChild">
  5. <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries"
  6. :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass"
  7. :row-class-name="rowClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" stripe border
  8. @cell-click="cellClick">
  9. <el-table-column v-for="col in tableColsCopy" :key="col.columnName" :prop="col.columnName"
  10. :label="col.groupName" align="center">
  11. <el-table-column v-for="childCol in col.children" :key="childCol.columnName"
  12. :width="childCol.nameLength ? Number(childCol.nameLength) : ''" :prop="childCol.columnName"
  13. :label="childCol.columnLabel" :formatter="formatter">
  14. <template #header>
  15. <el-tooltip :content="childCol.columnDescribe || childCol.columnLabel" placement="top">
  16. <TableHeaderCell :label="childCol.columnLabel" :filter-options="tableDataFilters[childCol.columnName]"
  17. :filter-values.sync="filterValues[childCol.columnName]" :sortable="childCol.needSort"
  18. :sort-rule.sync="tableDataSortRules[childCol.columnName]" />
  19. </el-tooltip>
  20. </template>
  21. <template slot-scope="scope">
  22. <template v-if="childCol.columnName == 'check_in_LT'">
  23. <div v-if="scope.row.check_in_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'check_in_L')">
  24. <span class="cell">{{ scope.row.check_in_L }}L</span>
  25. </div>
  26. <div v-else>0L</div>
  27. <div v-if="scope.row.check_in_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'check_in_T')">
  28. <span class="cell">{{ scope.row.check_in_T }}T</span>
  29. </div>
  30. <div v-else>0T</div>
  31. </template>
  32. <template v-else-if="childCol.columnName == 'security_LT'">
  33. <div v-if="scope.row.security_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'security_L')">
  34. <span class="cell">{{ scope.row.security_L }}L</span>
  35. </div>
  36. <div v-else>0L</div>
  37. <div v-if="scope.row.security_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'security_T')">
  38. <span class="cell">{{ scope.row.security_T }}T</span>
  39. </div>
  40. <div v-else>0T</div>
  41. </template>
  42. <template v-else-if="childCol.columnName == 'sort_LT'">
  43. <div v-if="scope.row.sort_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'sort_L')"><span
  44. class="cell">{{ scope.row.sort_L }}L</span></div>
  45. <div v-else>0L</div>
  46. <div v-if="scope.row.sort_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'sort_T')"><span
  47. class="cell">{{ scope.row.sort_T }}T</span></div>
  48. <div v-else>0T</div>
  49. </template>
  50. <template v-else-if="childCol.columnName == 'load_LT'">
  51. <div v-if="scope.row.load_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'load_L')"><span
  52. class="cell">{{ scope.row.load_L }}L</span></div>
  53. <div v-else>0L</div>
  54. <div v-if="scope.row.load_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'load_T')"><span
  55. class="cell">{{ scope.row.load_T }}T</span></div>
  56. <div v-else>0T</div>
  57. </template>
  58. <template v-else-if="childCol.columnName == 'onaiecraft_LT'">
  59. <div v-if="scope.row.onaiecraft_L > 0" class="is-click-btn"
  60. @click="cellClick2(scope.row, 'onaiecraft_L')">
  61. <span class="cell">{{ scope.row.onaiecraft_L }}L</span>
  62. </div>
  63. <div v-else>0L</div>
  64. <div v-if="scope.row.onaiecraft_T > 0" class="is-click-btn"
  65. @click="cellClick2(scope.row, 'onaiecraft_T')">
  66. <span class="cell">{{ scope.row.onaiecraft_T }}T</span>
  67. </div>
  68. <div v-else>0T</div>
  69. </template>
  70. <template v-else-if="childCol.columnName == 'unload_XT'">
  71. <div v-if="scope.row.unload_X > 0" class="is-click-btn" @click="cellClick2(scope.row, 'unload_X')"><span
  72. class="cell">{{ scope.row.unload_X }}X</span></div>
  73. <div v-else>0L</div>
  74. <div v-if="scope.row.unload_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'unload_T')"><span
  75. class="cell">{{ scope.row.unload_T }}T</span></div>
  76. <div v-else>0T</div>
  77. </template>
  78. <template v-else-if="childCol.columnName == 'arrive_XT'">
  79. <div v-if="scope.row.arrive_X > 0" class="is-click-btn" @click="cellClick2(scope.row, 'arrive_X')"><span
  80. class="cell">{{ scope.row.arrive_X }}X</span></div>
  81. <div v-else>0L</div>
  82. <div v-if="scope.row.arrive_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'arrive_T')"><span
  83. class="cell">{{ scope.row.arrive_T }}T</span></div>
  84. <div v-else>0T</div>
  85. </template>
  86. <template v-else-if="childCol.columnName == 'B_security_check_number_LT'">
  87. <div v-if="scope.row.B_security_check_number_L > 0" class="is-click-btn"
  88. @click="cellClick2(scope.row, 'B_security_check_number_L')"><span class="cell">{{
  89. scope.row.B_security_check_number_L }}L</span></div>
  90. <div v-else>0L</div>
  91. <div v-if="scope.row.B_security_check_number_T > 0" class="is-click-btn"
  92. @click="cellClick2(scope.row, 'B_security_check_number_T')"><span class="cell">{{
  93. scope.row.B_security_check_number_T }}T</span></div>
  94. <div v-else>0T</div>
  95. </template>
  96. <template v-else>
  97. {{ scope.row[childCol.columnName] }}
  98. </template>
  99. </template>
  100. </el-table-column>
  101. </el-table-column>
  102. </el-table>
  103. </template>
  104. <template v-else>
  105. <el-table ref="table" v-el-table-infinite-scroll="load" :data="dealedTableData" :summary-method="getSummaries"
  106. :span-method="tableSpanMethod" :show-summary="showSummary" :header-cell-class-name="headerCellClass"
  107. :row-class-name="rowClass" :cell-class-name="cellClass" height="100%" class="table infinite-list" border stripe
  108. @cell-click="cellClick">
  109. <el-table-column v-for="(item, index) in tableColsCopy" :key="item.columnName"
  110. :width="item.nameLength ? Number(item.nameLength) : ''" :prop="item.columnName" :label="item.columnLabel"
  111. :show-overflow-tooltip="showOverflowTooltip" :formatter="formatter">
  112. <template #header>
  113. <el-tooltip :content="item.columnDescribe || item.columnLabel" placement="top">
  114. <TableHeaderCell :label="item.columnLabel" :filter-options="tableDataFilters[item.columnName]"
  115. :filter-values.sync="filterValues[item.columnName]" :sortable="item.needSort"
  116. :sort-rule.sync="tableDataSortRules[item.columnName]" />
  117. </el-tooltip>
  118. </template>
  119. <!-- <template slot-scope="scope" v-if="item.columnName == 'check_in_LT'">
  120. <p>{{ scope.row.check_in_L}}L</p>
  121. <p>{{ scope.row.check_in_T}}T</p>
  122. </template> -->
  123. <template slot-scope="scope">
  124. <template v-if="item.columnName == 'check_in_LT'">
  125. <div v-if="scope.row.check_in_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'check_in_L')">
  126. <span class="cell">{{ scope.row.check_in_L }}L</span>
  127. </div>
  128. <div v-else>0L</div>
  129. <div v-if="scope.row.check_in_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'check_in_T')">
  130. <span class="cell">{{ scope.row.check_in_T }}T</span>
  131. </div>
  132. <div v-else>0T</div>
  133. </template>
  134. <template v-else-if="item.columnName == 'security_LT'">
  135. <div v-if="scope.row.security_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'security_L')">
  136. <span class="cell">{{ scope.row.security_L }}L</span>
  137. </div>
  138. <div v-else>0L</div>
  139. <div v-if="scope.row.security_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'security_T')">
  140. <span class="cell">{{ scope.row.security_T }}T</span>
  141. </div>
  142. <div v-else>0T</div>
  143. </template>
  144. <template v-else-if="item.columnName == 'sort_LT'">
  145. <div v-if="scope.row.sort_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'sort_L')"><span
  146. class="cell">{{ scope.row.sort_L }}L</span></div>
  147. <div v-else>0L</div>
  148. <div v-if="scope.row.sort_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'sort_T')"><span
  149. class="cell">{{ scope.row.sort_T }}T</span></div>
  150. <div v-else>0T</div>
  151. </template>
  152. <template v-else-if="item.columnName == 'load_LT'">
  153. <div v-if="scope.row.load_L > 0" class="is-click-btn" @click="cellClick2(scope.row, 'load_L')"><span
  154. class="cell">{{ scope.row.load_L }}L</span></div>
  155. <div v-else>0L</div>
  156. <div v-if="scope.row.load_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'load_T')"><span
  157. class="cell">{{ scope.row.load_T }}T</span></div>
  158. <div v-else>0T</div>
  159. </template>
  160. <template v-else-if="item.columnName == 'onaiecraft_LT'">
  161. <div v-if="scope.row.onaiecraft_L > 0" class="is-click-btn"
  162. @click="cellClick2(scope.row, 'onaiecraft_L')">
  163. <span class="cell">{{ scope.row.onaiecraft_L }}L</span>
  164. </div>
  165. <div v-else>0L</div>
  166. <div v-if="scope.row.onaiecraft_T > 0" class="is-click-btn"
  167. @click="cellClick2(scope.row, 'onaiecraft_T')">
  168. <span class="cell">{{ scope.row.onaiecraft_T }}T</span>
  169. </div>
  170. <div v-else>0T</div>
  171. </template>
  172. <template v-else-if="item.columnName == 'unload_XT'">
  173. <div v-if="scope.row.unload_X > 0" class="is-click-btn" @click="cellClick2(scope.row, 'unload_X')"><span
  174. class="cell">{{ scope.row.unload_X }}X</span></div>
  175. <div v-else>0L</div>
  176. <div v-if="scope.row.unload_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'unload_T')"><span
  177. class="cell">{{ scope.row.unload_T }}T</span></div>
  178. <div v-else>0T</div>
  179. </template>
  180. <template v-else-if="item.columnName == 'arrive_XT'">
  181. <div v-if="scope.row.arrive_X > 0" class="is-click-btn" @click="cellClick2(scope.row, 'arrive_X')"><span
  182. class="cell">{{ scope.row.arrive_X }}X</span></div>
  183. <div v-else>0L</div>
  184. <div v-if="scope.row.arrive_T > 0" class="is-click-btn" @click="cellClick2(scope.row, 'arrive_T')"><span
  185. class="cell">{{ scope.row.arrive_T }}T</span></div>
  186. <div v-else>0T</div>
  187. </template>
  188. <template v-else-if="item.columnName == 'B_security_check_number_LT'">
  189. <div v-if="scope.row.B_security_check_number_L > 0" class="is-click-btn"
  190. @click="cellClick2(scope.row, 'B_security_check_number_L')"><span class="cell">{{
  191. scope.row.B_security_check_number_L }}L</span></div>
  192. <div v-else>0L</div>
  193. <div v-if="scope.row.B_security_check_number_T > 0" class="is-click-btn"
  194. @click="cellClick2(scope.row, 'B_security_check_number_T')"><span class="cell">{{
  195. scope.row.B_security_check_number_T }}T</span></div>
  196. <div v-else>0T</div>
  197. </template>
  198. <template v-else>
  199. {{ scope.row[item.columnName] }}
  200. </template>
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. </template>
  205. <template v-if="istableDown">
  206. <div :style="downStyle" class="down-btns">
  207. <img class="btn-square btn-shadow" src="@/assets/baggage/ic_export.png" title="下载" @click="exportHandler">
  208. </div>
  209. </template>
  210. <template v-if="istableCol">
  211. <div :style="btnStyle" class="btns">
  212. <img class="btn-square btn-shadow" src="@/assets/baggage/ic_setting.png" title="列设置" @click="show">
  213. </div>
  214. <Dialog :flag="dialogFlag" width="600px" class="dialog-check-group">
  215. <div class="dialog-wrapper">
  216. <div class="title">列设置</div>
  217. <div style="height: 600px" class="content">
  218. <el-scrollbar style="height: 100%">
  219. <el-tree ref="columnSetTree" :data="tableCols" :class="colsCheckClass" show-checkbox node-key="index"
  220. :default-expand-all="true" :props="{
  221. label: 'columnLabel',
  222. children: 'children',
  223. }" :default-checked-keys="checkedKeysTemp" @check="handleCheck" />
  224. </el-scrollbar>
  225. </div>
  226. <div class="foot right t30">
  227. <el-button size="medium" class="r24" type="primary" @click="onCheck('baggageTableData')">确定</el-button>
  228. <el-button size="medium" @click="hide">取消</el-button>
  229. </div>
  230. </div>
  231. </Dialog>
  232. </template>
  233. <Dialog :flag="reamkeFlag" width="600px" class="dialog-check-group">
  234. <div class="dialog-wrapper">
  235. <div class="title">备注</div>
  236. <div style="height: 250px" class="content">
  237. <el-form ref="form" :model="form" label-width="70px">
  238. <el-form-item label="输入备注">
  239. <el-input v-model="form.desc" type="textarea" clearable rows="10" />
  240. </el-form-item>
  241. </el-form>
  242. </div>
  243. <div class="foot right t30">
  244. <el-button size="medium" class="r24" type="primary" @click="onReamkeCheck">确定</el-button>
  245. <el-button size="medium" @click="reamkeFlag = false">取消</el-button>
  246. </div>
  247. </div>
  248. </Dialog>
  249. <Dialog :flag="storyFlag" width="600px" class="dialog-check-group">
  250. <div class="dialog-wrapper">
  251. <div class="title">备注</div>
  252. <div style="padding:0 20px 20px 20px;" class="table">
  253. <el-table height="250" :data="storyTable" border style="width: 100%">
  254. <el-table-column prop="luggageDescribe" label="行李服务记录" />
  255. <el-table-column prop="createtime" label="行李服务时间" />
  256. </el-table>
  257. </div>
  258. <div class="content">
  259. <el-form ref="form" :model="form" label-width="70px">
  260. <el-form-item label="输入备注">
  261. <el-input v-model="form.desc" type="textarea" clearable />
  262. </el-form-item>
  263. </el-form>
  264. </div>
  265. <div class="foot right t30">
  266. <el-button size="medium" class="r24" type="primary" @click="onStoryCheck">确定</el-button>
  267. <el-button size="medium" @click="storyFlag = false">取消</el-button>
  268. </div>
  269. </div>
  270. </Dialog>
  271. </div>
  272. </template>
  273. <script>
  274. import pf from '@/layout/mixin/publicFunc'
  275. import { getToken } from '@/utils/auth'
  276. import { getAuthData, formatOrder } from '@/utils/validate'
  277. import { parseTime } from '@/utils'
  278. import { exportToExcel } from '@/utils/table'
  279. import { Query, newData, modifyData } from '@/api/webApi'
  280. import tableColsMixin from '../mix/tableCols'
  281. import Dialog from '@/layout/components/Dialog/index.vue'
  282. import TableHeaderCell from '@/components/TableHeaderCell/index.vue'
  283. export default {
  284. name: 'NewQueryTable',
  285. components: { Dialog, TableHeaderCell },
  286. mixins: [pf, tableColsMixin],
  287. props: {
  288. // 不换行,溢出隐藏
  289. showOverflowTooltip: {
  290. type: Boolean,
  291. default: true,
  292. },
  293. tableTag: {
  294. type: Object,
  295. default: () => ({}),
  296. },
  297. tableName: {
  298. type: String,
  299. default: '',
  300. },
  301. istableCol: {
  302. type: Boolean,
  303. default: false,
  304. },
  305. istableDown: {
  306. type: Boolean,
  307. default: false,
  308. },
  309. downName: {
  310. type: String,
  311. default: '',
  312. },
  313. istableChild: {
  314. type: Boolean,
  315. default: false,
  316. },
  317. btnStyle: {
  318. type: Object,
  319. default: () => { },
  320. },
  321. downStyle: {
  322. type: Object,
  323. default: () => { },
  324. },
  325. pageSize: {
  326. type: Number,
  327. default: 20,
  328. },
  329. shouldReset: {
  330. type: Boolean,
  331. default: true
  332. },
  333. fastFilter: {
  334. type: Function,
  335. default: () => () => true
  336. },
  337. },
  338. data() {
  339. return {
  340. allColReturnData: [],
  341. page: 0,
  342. queryId: '',
  343. noMore: false,
  344. loading: false,
  345. tableCols: [], // 表头数据
  346. tableData: [], // 表格数据
  347. tableColsCopy: [], // 表头数据缓存
  348. tableDataFilters: {}, // 表头-下拉数据
  349. filterValues: {}, // 表头-下拉-选中数据
  350. tableDataCopy: [], // 缓存table数据
  351. tableGroups: [], // 表格分组数据
  352. colShowFilter: '', // 表头-下拉-箭头
  353. spanArr: [], // 表格分组数据缓存
  354. pos: 0, // 表格分组计数
  355. dataContent: [],
  356. authBtns: [],
  357. authBtnCol: [],
  358. authBtnColName: [],
  359. tableArrs: [], // 重组table-表头下拉
  360. tableOptions: {}, // 弹框-下来数据缓存
  361. showSummary: false, // 是否显示统计
  362. tableDataSortRules: {},
  363. tableCath: [],
  364. leaveCount: 0,
  365. arriveCount: 0,
  366. checkPath: ['/newDeparture', '/newTransfer/in', '/newTransfer/out', '/newArrival'],
  367. hasSetTableScroll: false,
  368. reamkeFlag: false,
  369. storyFlag: false,
  370. storyTable: [],
  371. reamkeMap: {},
  372. form: {
  373. desc: ''
  374. },
  375. rushCount: 0,
  376. initSetTableScroll: true // 是否 只滚动一次(红线)
  377. }
  378. },
  379. computed: {
  380. // 设置表头-下拉-选中数据
  381. fastFilteredTableData() {
  382. return this.tableData.filter(this.fastFilter)
  383. },
  384. dealedTableData() {
  385. const filtered = this.fastFilteredTableData.filter(item => {
  386. let flag = true
  387. Object.entries(this.filterValues).forEach(([key, arr]) => {
  388. if (arr.length && !arr.includes(String(item[key]))) {
  389. flag = false
  390. }
  391. })
  392. return flag
  393. })
  394. const sortRules = Object.entries(this.tableDataSortRules).reduce(
  395. (pre, [key, value]) => {
  396. if (value) {
  397. pre[0].push(key)
  398. value = value === 'ascending' ? 'asc' : 'desc'
  399. pre[1].push(value)
  400. }
  401. return pre
  402. },
  403. [[], []]
  404. )
  405. return this._.orderBy(filtered, sortRules[0], sortRules[1])
  406. },
  407. tableHeight() {
  408. return 100
  409. },
  410. fromDataType() {
  411. return function (type) {
  412. if (type) {
  413. return type.replace(/\([^\)]*\)/g, '')
  414. }
  415. }
  416. },
  417. },
  418. watch: {
  419. tableTag: {
  420. async handler(val) {
  421. this.dataContent = _.cloneDeep(val)
  422. delete this.dataContent.shouldReset
  423. this.restTable()
  424. if (val.shouldReset) {
  425. this.$emit('update:shouldReset', true)
  426. await this.$nextTick()
  427. this.hasSetTableScroll = false
  428. }
  429. this.load()
  430. },
  431. deep: true,
  432. }
  433. },
  434. created() {
  435. if (this.AauthTable && this.AauthTable.length) {
  436. const t = this.AauthTable.filter(item => item.auth_name == this.tableName)
  437. const obj = t[0]
  438. this.AqueryParams = obj
  439. this.AqueryId = obj.queryTemplateID
  440. this.AauthId = obj.auth_id
  441. }
  442. this.getColumnData()
  443. },
  444. mounted() {
  445. this.setCellClick()
  446. },
  447. updated() {
  448. this.$refs['table']?.doLayout()
  449. },
  450. methods: {
  451. // 获取表头数据
  452. async getColumnData() {
  453. try {
  454. const { code, returnData } = await this.getQueryList(
  455. SERVICE_ID.sysUserAuthId,
  456. [
  457. {
  458. user_id: getToken('userid'),
  459. auth_id: this.AauthId,
  460. },
  461. ]
  462. )
  463. if (code == 0) {
  464. if (returnData && returnData.length) {
  465. if (!this.istableCol) {
  466. sessionStorage.setItem('tableColumns', JSON.stringify(returnData))
  467. this.$store.dispatch('auth/changeAuthMsg', returnData)
  468. }
  469. this.allColReturnData = returnData
  470. this.setTableColsXT()
  471. }
  472. } else {
  473. this.$message.error('获取表头数据失败')
  474. }
  475. } catch (error) {
  476. console.log(error)
  477. }
  478. },
  479. setTableColsXT(val = sessionStorage.getItem('Totalvalue') == 'true') {
  480. const returnData = _.cloneDeep(this.allColReturnData)
  481. if (val == true) {
  482. returnData.map(item => {
  483. if (item.columnName == 'check_in_baggage_number' || item.columnName == 'screened_number' || item.columnName == 'sorted_number' || item.columnName == 'loaded_number' || item.columnName == 'onaiecraft_number' || item.columnName == 'unloading_number' || item.columnName == 'arrive_number' || item.columnName == 'B_security_check_number') {
  484. item.needShow = 1
  485. }
  486. if (item.columnName == 'check_in_LT' || item.columnName == 'security_LT' || item.columnName == 'sort_LT' || item.columnName == 'load_LT' || item.columnName == 'onaiecraft_LT' || item.columnName == 'unload_XT' || item.columnName == 'arrive_XT' || item.columnName == 'B_security_check_number_LT') {
  487. item.needShow = 0
  488. }
  489. })
  490. } else {
  491. returnData.map(item => {
  492. if (item.columnName == 'check_in_baggage_number' || item.columnName == 'screened_number' || item.columnName == 'sorted_number' || item.columnName == 'loaded_number' || item.columnName == 'onaiecraft_number' || item.columnName == 'unloading_number' || item.columnName == 'arrive_number' || item.columnName == 'B_security_check_number') {
  493. item.needShow = 0
  494. }
  495. if (item.columnName == 'check_in_LT' || item.columnName == 'security_LT' || item.columnName == 'sort_LT' || item.columnName == 'load_LT' || item.columnName == 'onaiecraft_LT' || item.columnName == 'unload_XT' || item.columnName == 'arrive_XT' || item.columnName == 'B_security_check_number_LT') {
  496. item.needShow = 1
  497. }
  498. })
  499. }
  500. this.setTableColsUTC(returnData)
  501. },
  502. setTableColsUTC(returnData) {
  503. const val = sessionStorage.getItem('UTCvalue') === 'true'
  504. if (val == true) {
  505. returnData.map(item => {
  506. if (item.columnName == 'checkInDateUTC' || item.columnName == 'security_check_timeUTC' || item.columnName == 'B_security_check_timeUTC' || item.columnName == 'sorting_timeUTC' || item.columnName == 'loading_timeUTC' || item.columnName == 'installation_timeUTC' || item.columnName == 'unloadtimeUTC' || item.columnName == 'arrivedtimeUTC') {
  507. item.needShow = 1
  508. }
  509. if (item.columnName == 'checkInDate' || item.columnName == 'security_check_time' || item.columnName == 'B_security_check_time' || item.columnName == 'sorting_time' || item.columnName == 'loading_time' || item.columnName == 'installation_time' || item.columnName == 'unloadtime' || item.columnName == 'arrivedtime') {
  510. item.needShow = 0
  511. }
  512. })
  513. } else {
  514. returnData.map(item => {
  515. if (item.columnName == 'checkInDateUTC' || item.columnName == 'security_check_timeUTC' || item.columnName == 'B_security_check_timeUTC' || item.columnName == 'sorting_timeUTC' || item.columnName == 'loading_timeUTC' || item.columnName == 'installation_timeUTC' || item.columnName == 'unloadtimeUTC' || item.columnName == 'arrivedtimeUTC') {
  516. item.needShow = 0
  517. }
  518. if (item.columnName == 'checkInDate' || item.columnName == 'security_check_time' || item.columnName == 'B_security_check_time' || item.columnName == 'sorting_time' || item.columnName == 'loading_time' || item.columnName == 'installation_time' || item.columnName == 'unloadtime' || item.columnName == 'arrivedtime') {
  519. item.needShow = 1
  520. }
  521. })
  522. }
  523. this.setTableCols(returnData)
  524. },
  525. setTableCols(returnData) {
  526. this.tableColsCopy = []
  527. const msgDatas = returnData.filter(item => item.needShow)
  528. const msgCounts = msgDatas.filter(item => item.needCount)
  529. if (msgCounts.length) {
  530. this.showSummary = true
  531. }
  532. const msgDatasShows = formatOrder(msgDatas)
  533. this.tableCath = msgDatasShows
  534. if (this.istableChild) {
  535. const datas = _.cloneDeep(msgDatasShows)
  536. const cache = {}
  537. const indices = []
  538. const others = []
  539. datas.forEach(item => {
  540. if (!cache[item.groupName] && item.groupName) {
  541. cache[item.groupName] = item.groupName
  542. indices.push(item)
  543. } else {
  544. const newItem = _.cloneDeep(item)
  545. others.push(newItem)
  546. }
  547. })
  548. indices.map((item, index) => {
  549. item.tabIndex = index
  550. })
  551. others.forEach(item => {
  552. indices.forEach(p => {
  553. if (item.groupName == p.groupName && item.groupName) {
  554. item.tabIndex = p.tabIndex
  555. }
  556. })
  557. })
  558. indices.forEach(item => {
  559. item.children = [
  560. _.cloneDeep(item),
  561. ...this.formatCaps(item.tabIndex, others),
  562. ]
  563. })
  564. this.tableCols = _.cloneDeep(indices)
  565. } else {
  566. this.tableCols = _.cloneDeep(msgDatasShows)
  567. }
  568. this.tableColsCopy = _.cloneDeep(this.tableCols)
  569. this.initTableCols()
  570. this.tableCath.forEach(({ columnName, needFilters, needSort }) => {
  571. if (needFilters) {
  572. this.$set(this.tableDataFilters, columnName, [])
  573. this.$set(this.filterValues, columnName, [])
  574. }
  575. if (needSort) {
  576. this.$set(this.tableDataSortRules, columnName, '')
  577. }
  578. })
  579. },
  580. formatCaps(order, arr) {
  581. const datas = []
  582. for (let i = 0; i < arr.length; i++) {
  583. const element = arr[i]
  584. if (element['tabIndex'] == order) {
  585. datas.push(element)
  586. }
  587. }
  588. return datas
  589. },
  590. // 获取表格数据
  591. async getQueryRow(id, dataContent = this.dataContent, page, pageSize) {
  592. try {
  593. const params = {} || dataContent
  594. if (dataContent.filter && dataContent.filter?.length) {
  595. params['fd1'] = dataContent.filter[0].value
  596. params['fd2'] = dataContent.filter[1].value
  597. params['airport'] = dataContent.filter[2].value
  598. } else {
  599. params['fd1'] = dataContent.departure_flights_date1
  600. params['fd2'] = dataContent.departure_flights_date2
  601. params['airport'] = dataContent.current_airport
  602. }
  603. const { code, returnData } = await this.getQueryListAuth(
  604. id,
  605. params,
  606. page,
  607. pageSize
  608. )
  609. if (code == 0) {
  610. return returnData
  611. } else {
  612. return []
  613. }
  614. } catch (error) {
  615. console.log(error)
  616. }
  617. },
  618. // 获取表格数据
  619. async getQuery(id, dataContent = this.dataContent, page, pageSize) {
  620. try {
  621. if (this.shouldReset) {
  622. this.loading = true
  623. }
  624. this.$emit('update:shouldReset', false)
  625. await this.$nextTick()
  626. const { code, returnData } = await this.getQueryListAuth(
  627. id,
  628. dataContent,
  629. page,
  630. pageSize
  631. )
  632. if (code == 0) {
  633. let tableData = []
  634. if (pageSize && returnData.length < pageSize) {
  635. this.noMore = true
  636. if (returnData.length === 0) {
  637. this.page--
  638. this.loading = false
  639. }
  640. }
  641. if (id == SERVICE_ID.bagDetailId) {
  642. const rushDataCatch = sessionStorage.getItem('rushDataCatch') || {}
  643. if (rushDataCatch && rushDataCatch.length) {
  644. const rushData = JSON.parse(rushDataCatch)
  645. const { OriginalBagTag_TagSequence } = rushData
  646. returnData.forEach(item => {
  647. const luggageNum_Nine = item.luggageNum + ''
  648. if (luggageNum_Nine.substring(1) == OriginalBagTag_TagSequence) {
  649. item.rushFlag = true
  650. }
  651. })
  652. }
  653. }
  654. if (this.shouldReset) {
  655. tableData = [...this.tableData, ...returnData]
  656. this.tableData.push(...returnData)
  657. } else {
  658. tableData = [...returnData]
  659. this.noMore = true
  660. }
  661. this.$emit('tableLoad', [...tableData])
  662. this.initTableData(tableData)
  663. await this.$nextTick()
  664. this.setTableScroll()
  665. this.loading = false
  666. } else {
  667. throw new Error('获取表格数据失败')
  668. }
  669. } catch (error) {
  670. this.page--
  671. this.loading = false
  672. this.$message.error(error.message)
  673. }
  674. },
  675. restTable() {
  676. this.loading = false
  677. this.page = 0
  678. this.noMore = false
  679. if (this.shouldReset) {
  680. this.tableData = []
  681. }
  682. },
  683. load() {
  684. if (this.tableTag && Object.keys(this.tableTag).length) {
  685. if (this.noMore || this.loading) {
  686. return
  687. }
  688. if (this.AqueryParams && this.AqueryParams.queryparams) {
  689. const newData = _.cloneDeep(this.tableTag)
  690. delete newData.shouldReset
  691. const paramsType = typeof this.AqueryParams.queryparams
  692. if (paramsType == 'string') {
  693. const dataObj = {}
  694. const paramsData = this.AqueryParams.queryparams.split(',')
  695. if (paramsData && paramsData.length) {
  696. for (const key in newData) {
  697. paramsData.map(item => {
  698. if (key === item) {
  699. dataObj[item] = newData[key]
  700. } else {
  701. if (item.includes('=')) {
  702. const newItem = item.split('=')
  703. if (key === newItem[0]) {
  704. dataObj[newItem[1]] = newData[key]
  705. }
  706. }
  707. }
  708. })
  709. }
  710. this.dataContent = dataObj
  711. }
  712. }
  713. }
  714. this.getQuery(
  715. this.AqueryId,
  716. this.dataContent,
  717. ++this.page,
  718. this.pageSize
  719. )
  720. }
  721. },
  722. setCellClick() {
  723. let table = null
  724. const { auth_id } = this.$route.meta
  725. const { arrs } = getAuthData(auth_id)
  726. if (this.tableName) {
  727. table = this.AauthTable.filter(item => item.auth_name == this.tableName)
  728. } else {
  729. table = arrs.filter(item => item.auth_type == 4)
  730. }
  731. if (table && table.length) {
  732. const obj = table[0]
  733. const { arrs } = getAuthData(obj.auth_id)
  734. this.authBtnCol = arrs.filter(item => Number(item.service_type) == 6)
  735. if (this.authBtnCol.length) {
  736. this.authBtnCol.forEach(item => {
  737. this.authBtnColName.push(item.relation_data)
  738. })
  739. }
  740. }
  741. },
  742. // 初始化表格
  743. async initTableData(tableData) {
  744. tableData = tableData || this.tableData
  745. tableData.forEach(async row => {
  746. if (row.needGroup) {
  747. this.tableGroups.push(row.columnName)
  748. }
  749. })
  750. const now = new Date()
  751. if (this.$route.path == '/newDeparture') {
  752. this.leaveCount = 0
  753. const tableMap = new Map()
  754. const nTableData = [...tableData]
  755. const nTableDataRow = await this.getQueryRow(SERVICE_ID.departureDanggerId, this.dataContent, 1, 999)
  756. if (nTableDataRow?.length) {
  757. nTableDataRow.map(({ carrierFlights, carrierFlightsDate, craftType_num, depstandCd_num, landAirport, outAirport }) => {
  758. tableMap.set(carrierFlights + carrierFlightsDate + landAirport + outAirport, `${craftType_num}` + '-' + `${depstandCd_num}`)
  759. })
  760. }
  761. const cData = nTableData.filter(row => Number(row['NO_BSM_number']) + Number(row['check_in_baggage_number']) > 0)
  762. if (tableMap.size) {
  763. cData.map(item => {
  764. const { carrierFlights, carrierFlightsDate, landAirport, outAirport } = item
  765. const itemKey = carrierFlights + carrierFlightsDate + landAirport + outAirport
  766. if (tableMap.has(itemKey)) {
  767. const [craftType_num, depstandCd_num] = tableMap.get(itemKey)?.split('-')
  768. item.craftType_num = Number(craftType_num)
  769. item.depstandCd_num = Number(depstandCd_num)
  770. }
  771. })
  772. }
  773. cData.forEach(row => {
  774. if (row.abnormalState === 'CAN') {
  775. row.canceled = 'Y'
  776. } else if (row.normalState === 'DEP' || row.actualTakeOffTime) {
  777. row.hasTakenOff = 'Y'
  778. this.leaveCount++
  779. }
  780. const isUTC = sessionStorage.getItem('UTCvalue') ? sessionStorage.getItem('UTCvalue') : false
  781. if (isUTC == 'false') {
  782. row.scheduleTakeOffTime = ''
  783. if (row.actualTakeOffTimeLocalOut != null && row.actualTakeOffTimeLocalOut != '') {
  784. row.scheduleTakeOffTime = row.actualTakeOffTimeLocalOut
  785. } else {
  786. if (row.estimateTakeOffTimeLocalOut != null && row.estimateTakeOffTimeLocalOut != '') {
  787. row.scheduleTakeOffTime = row.estimateTakeOffTimeLocalOut
  788. } else {
  789. row.scheduleTakeOffTime = row.scheduleTakeOffTimeLocalOut
  790. }
  791. }
  792. } else {
  793. row.scheduleTakeOffTime = ''
  794. if (row.actualTakeOffTimeUTC != null && row.actualTakeOffTimeUTC != '') {
  795. row.scheduleTakeOffTime = row.actualTakeOffTimeUTC
  796. } else {
  797. if (row.estimateTakeOffTimeUTC != null && row.estimateTakeOffTimeUTC != '') {
  798. row.scheduleTakeOffTime = row.estimateTakeOffTimeUTC
  799. } else {
  800. row.scheduleTakeOffTime = row.scheduleTakeOffTimeUTC
  801. }
  802. }
  803. }
  804. })
  805. this.tableData = []
  806. this.tableData = _.orderBy(cData, ['canceled', 'hasTakenOff', 'scheduleTakeOffTime'], ['desc', 'asc', 'asc'])
  807. // 添加宏任务,让页面首次进入的时候,滚动到红线速度加快
  808. setTimeout(() => {
  809. if(this.initSetTableScroll === true) {
  810. this.$nextTick()
  811. this.hasSetTableScroll = false
  812. this.setTableScroll()
  813. this.initSetTableScroll = false
  814. }
  815. },10)
  816. }
  817. if (this.$route.path == '/newArrival') {
  818. this.arriveCount = 0
  819. const nTableData = [...tableData]
  820. const tableMap = new Map()
  821. const nTableDataRow = await this.getQueryRow(SERVICE_ID.arrivalDanggerId, this.dataContent, 1, 999)
  822. if (nTableDataRow?.length) {
  823. nTableDataRow.map(({ carrierFlights, carrierFlightsDate, craftType_num, arrstandCd_num, landAirport, outAirport }) => {
  824. tableMap.set(carrierFlights + carrierFlightsDate + landAirport + outAirport, `${craftType_num}` + '-' + `${arrstandCd_num}`)
  825. })
  826. }
  827. const cData = nTableData.filter(row => Number(row['NO_BSM_number']) + Number(row['check_in_baggage_number']) > 0)
  828. if (tableMap.size) {
  829. cData.map(item => {
  830. const { carrierFlights, carrierFlightsDate, landAirport, outAirport } = item
  831. const itemKey = carrierFlights + carrierFlightsDate + landAirport + outAirport
  832. if (tableMap.has(itemKey)) {
  833. const [craftType_num, arrstandCd_num] = tableMap.get(itemKey)?.split('-')
  834. item.craftType_num = Number(craftType_num)
  835. item.arrstandCd_num = Number(arrstandCd_num)
  836. }
  837. })
  838. }
  839. cData.forEach(row => {
  840. if (row.abnormalState === 'CAN') {
  841. row.canceled = 'Y'
  842. } else if (row.normalState === 'ARR' || row.actualLandInTime) {
  843. row.hasLanded = 'Y'
  844. this.arriveCount++
  845. }
  846. const isUTC = sessionStorage.getItem('UTCvalue') ? sessionStorage.getItem('UTCvalue') : false
  847. if (isUTC == 'false') {
  848. row.actualLandInTime = ''
  849. if (row.actualLandinTimeLocalIn != null && row.actualLandinTimeLocalIn != '') {
  850. row.actualLandInTime = row.actualLandinTimeLocalIn
  851. } else {
  852. if (row.estimateLandinTimeLocalIn != null && row.estimateLandinTimeLocalIn != '') {
  853. row.actualLandInTime = row.estimateLandinTimeLocalIn
  854. } else {
  855. row.actualLandInTime = row.scheduleLandInTimeLocalIn
  856. }
  857. }
  858. } else {
  859. row.actualLandInTime = ''
  860. if (row.actualLandInTimeUTC != null && row.actualLandInTimeUTC != '') {
  861. row.actualLandInTime = row.actualLandInTimeUTC
  862. } else {
  863. if (row.estimatelandInTimeUTC != null && row.estimatelandInTimeUTC != '') {
  864. row.actualLandInTime = row.estimatelandInTimeUTC
  865. } else {
  866. row.actualLandInTime = row.scheduleLandinTimeUTC
  867. }
  868. }
  869. }
  870. })
  871. this.tableData = []
  872. this.tableData = _.orderBy(cData, ['canceled', 'hasLanded', 'actualLandInTime'], ['desc', 'asc', 'asc'])
  873. }
  874. if (this.$route.path.startsWith('/newTransfer')) {
  875. this.leaveCount = 0
  876. const nTableData = [...tableData]
  877. const [tableMap1, tableMap2] = [new Map(), new Map()]
  878. const nTableDataRow1 = await this.getQueryRow(SERVICE_ID.departureAviLtDanggerId, this.dataContent, 1, 999) // 离港数据
  879. const nTableDataRow2 = await this.getQueryRow(SERVICE_ID.departureAviDanggerId, this.dataContent, 1, 999) // 进港数据
  880. if (nTableDataRow1?.length) {
  881. nTableDataRow1.map(({ carrierFlights, carrierFlightsDate, craftType_num, depstandCd_num, outAirport }) => {
  882. tableMap1.set(carrierFlights + carrierFlightsDate + outAirport, `${craftType_num}` + '-' + `${depstandCd_num}`)
  883. })
  884. }
  885. if (nTableDataRow2?.length) {
  886. nTableDataRow2.map(({ carrierFlights, carrierFlightsDate, craftType_num, arrstandCd_num, landAirport }) => {
  887. tableMap2.set(carrierFlights + carrierFlightsDate + landAirport, `${craftType_num}` + '-' + `${arrstandCd_num}`)
  888. })
  889. }
  890. if (tableMap1.size) {
  891. nTableData.map(item => {
  892. const { departure_flights_number, departure_flights_date, current_airport } = item
  893. const itemKey = departure_flights_number + departure_flights_date + current_airport
  894. if (tableMap1.has(itemKey)) {
  895. const [craftType_num, depstandCd_num] = tableMap1.get(itemKey)?.split('-')
  896. item.craftType_num = Number(craftType_num)
  897. item.depstandCd_num = Number(depstandCd_num)
  898. }
  899. })
  900. }
  901. if (tableMap2.size) {
  902. nTableData.map(item => {
  903. const { Inbound_flight_number, Inbound_flight_date, current_airport } = item
  904. const itemKey = Inbound_flight_number + Inbound_flight_date + current_airport
  905. if (tableMap2.has(itemKey)) {
  906. const [craftType_num, arrstandCd_num] = tableMap2.get(itemKey)?.split('-')
  907. item.craftType_num = Number(craftType_num)
  908. item.arrstandCd_num = Number(arrstandCd_num)
  909. }
  910. })
  911. }
  912. nTableData.forEach(row => {
  913. if (row.departure_flights_leave_date && new Date(row.departure_flights_leave_date) < now) {
  914. row.hasTakenOff = 'Y'
  915. this.leaveCount++
  916. }
  917. })
  918. this.tableData = _.orderBy(nTableData, ['departure_flights_leave_date', 'normalState'], ['asc', 'desc'])
  919. }
  920. if (this.$route.path == '/newBagDetails') {
  921. const nTableData = [...tableData]
  922. this.tableData = _.orderBy(nTableData, ['readTime'], ['asc', 'desc'])
  923. }
  924. const filters = this.setTableFilters(this.tableData, this.tableDataFilters)
  925. this.tableDataFilters = _.cloneDeep(filters)
  926. this.tableGroup(this.tableData)
  927. },
  928. setTableFilters(tableData, filters) {
  929. const tempSets = {}
  930. Object.keys(filters).forEach(key => {
  931. tempSets[key] = new Set()
  932. })
  933. tableData.forEach(item => {
  934. Object.keys(tempSets).forEach(key => {
  935. (item[key] ?? '') !== '' && tempSets[key].add(String(item[key]))
  936. })
  937. })
  938. Object.keys(tempSets).forEach(key => {
  939. filters[key] = _.orderBy(
  940. [...tempSets[key]].map(value => ({
  941. text: value,
  942. value,
  943. })),
  944. o => o.value
  945. )
  946. })
  947. return filters
  948. },
  949. // 分组
  950. tableGroup(tableData) {
  951. const spanArr = []
  952. let pos = 0
  953. const ifYj = this.tableGroups[0]
  954. for (let i = 0; i < tableData.length; i++) {
  955. if (i === 0) {
  956. spanArr.push(1)
  957. } else {
  958. if (tableData[i][ifYj] === tableData[i - 1][ifYj]) {
  959. spanArr[pos] += 1
  960. spanArr.push(0)
  961. } else {
  962. spanArr.push(1)
  963. pos = i
  964. }
  965. }
  966. }
  967. this.spanArr = spanArr
  968. this.pos = pos
  969. },
  970. setTableScroll () {
  971. const count = Math.max(this.leaveCount, this.arriveCount)
  972. if (this.hasSetTableScroll || count === 0) {
  973. return
  974. }
  975. const table = this.$refs['table'].$el
  976. const scrollParent = table.querySelector('.el-table__body-wrapper')
  977. if (scrollParent.scrollHeight <= scrollParent.offsetHeight) {
  978. return
  979. }
  980. const lastRow = table.querySelectorAll('.el-table__body tr')[count - 1]
  981. setTimeout(() => {
  982. const scrollMid = lastRow.offsetTop + lastRow.offsetHeight - scrollParent.offsetHeight / 2
  983. const scrollMax = scrollParent.scrollHeight - scrollParent.offsetHeight
  984. if (scrollMid > 0) {
  985. const scrollHeight = Math.min(scrollMid, scrollMax)
  986. scrollParent.scrollTo(0, scrollHeight)
  987. }
  988. }, 10)
  989. this.hasSetTableScroll = true
  990. },
  991. popoverShowHandler(prop) {
  992. this.colShowFilter = prop
  993. },
  994. popoverHideHandler() {
  995. this.colShowFilter = ''
  996. },
  997. // 获取弹框-下拉数据
  998. async getSelectData(id) {
  999. // name ? [name] : name === null ? [null]: [],
  1000. const { code, returnData } = await this.getQueryList(id, {})
  1001. if (code == 0) {
  1002. return returnData
  1003. } else {
  1004. return []
  1005. }
  1006. },
  1007. // 设置表头-下拉-箭头样式
  1008. arrowClass() {
  1009. return function (prop) {
  1010. const classes = []
  1011. if (this.colShowFilter === prop) {
  1012. classes.push('arrow-active')
  1013. }
  1014. if (
  1015. Object.entries(this.tableDataFilters).find(
  1016. ([key, arr]) => this.filterValues[prop]
  1017. )
  1018. ) {
  1019. classes.push('arrow-blue')
  1020. }
  1021. return classes.join(' ')
  1022. }
  1023. },
  1024. // 合计
  1025. getSummaries(param) {
  1026. const { columns, data } = param
  1027. const sums = []
  1028. columns.forEach((column, index) => {
  1029. if (index === 0) {
  1030. sums[index] = '合计:' + data.length
  1031. return
  1032. }
  1033. this.tableCath.forEach(p => {
  1034. if (column.property == p.columnName && p.needCount) {
  1035. const values = data.map(item => Number(item[column.property]))
  1036. if (!values.every(value => isNaN(value))) {
  1037. sums[index] = values.reduce((prev, curr) => {
  1038. const value = Number(curr)
  1039. if (!isNaN(value)) {
  1040. return prev + curr
  1041. } else {
  1042. return prev
  1043. }
  1044. }, 0)
  1045. sums[index] += ''
  1046. }
  1047. }
  1048. })
  1049. })
  1050. return sums
  1051. },
  1052. // 分组
  1053. tableSpanMethod({ row, column, rowIndex, columnIndex }) {
  1054. if (this.tableGroups.includes(column['property'])) {
  1055. const _row = this.spanArr[rowIndex]
  1056. const _col = _row > 0 ? 1 : 0
  1057. return {
  1058. rowspan: _row,
  1059. colspan: _col,
  1060. }
  1061. }
  1062. },
  1063. // 给表头单元格加上 ascending 或 descending 使用 element 自带的排序箭头变色
  1064. headerCellClass({ row, column, rowIndex, columnIndex }) {
  1065. const classes = []
  1066. const rule = this.tableDataSortRules[column.property]
  1067. if (rule) {
  1068. classes.push(rule)
  1069. }
  1070. return classes.join(' ')
  1071. },
  1072. // 表格-设置单元格样式---
  1073. cellClass({ row, column, rowIndex, columnIndex }) {
  1074. const classes = []
  1075. if (this.authBtnColName.includes(column.property) && Number(row[column.property]) !== 0) {
  1076. classes.push('is-click-btn')
  1077. }
  1078. if (this.$route.path == '/newDeparture') {
  1079. if (column.property === 'NO_check_number' && row['NO_check_number'] != 0) {
  1080. classes.push('cell-toUnload')
  1081. }
  1082. if (column.property === 'scon_number' && row['scon_number'] && row['scon_number'] != 0) {
  1083. classes.push('cell-toUnload')
  1084. }
  1085. if (column.property === 'depstandCd' && row['depstandCd_num'] > 2) {
  1086. classes.push('cell-toBule-red')
  1087. }
  1088. if (column.property === 'depstandCd' && row['depstandCd_num'] == 2) {
  1089. classes.push('cell-toBule')
  1090. }
  1091. if (column.property === 'craftNo' && row['craftType_num'] > 2) {
  1092. classes.push('cell-toBule-red')
  1093. }
  1094. if (column.property === 'craftNo' && row['craftType_num'] == 2) {
  1095. classes.push('cell-toBule')
  1096. }
  1097. }
  1098. if (this.$route.path == '/newArrival') {
  1099. if (column.property === 'arrstandCd' && row['arrstandCd_num'] > 2) {
  1100. classes.push('cell-toBule-red')
  1101. }
  1102. if (column.property === 'arrstandCd' && row['arrstandCd_num'] == 2) {
  1103. classes.push('cell-toBule')
  1104. }
  1105. if (column.property === 'craftNo' && row['craftType_num'] > 2) {
  1106. classes.push('cell-toBule-red')
  1107. }
  1108. if (column.property === 'craftNo' && row['craftType_num'] == 2) {
  1109. classes.push('cell-toBule')
  1110. }
  1111. }
  1112. if (this.$route.path.startsWith('/newTransfer')) {
  1113. if (column.property === 'Inbound_flight_stand' && row['arrstandCd_num'] > 2) {
  1114. classes.push('cell-toBule-red')
  1115. }
  1116. if (column.property === 'Inbound_flight_stand' && row['arrstandCd_num'] == 2) {
  1117. classes.push('cell-toBule')
  1118. }
  1119. if (column.property === 'departure_flights_leave_stand' && row['depstandCd_num'] > 2) {
  1120. classes.push('cell-toBule-red')
  1121. }
  1122. if (column.property === 'departure_flights_leave_stand' && row['depstandCd_num'] == 2) {
  1123. classes.push('cell-toBule')
  1124. }
  1125. if (column.property === 'craftNo' && row['craftType_num'] > 2) {
  1126. classes.push('cell-toBule-red')
  1127. }
  1128. if (column.property === 'craftNo' && row['craftType_num'] == 2) {
  1129. classes.push('cell-toBule')
  1130. }
  1131. }
  1132. if (this.$route.path.startsWith('/newBagDetails')) {
  1133. if (column.property === 'luggageNum' && row['rushFlag']) {
  1134. classes.push('txtToRed')
  1135. }
  1136. }
  1137. return classes.join(' ')
  1138. },
  1139. // 表格-设置行样式
  1140. rowClass({ row, rowIndex }) {
  1141. const classes = []
  1142. if (this.checkPath.includes(this.$route.path)) {
  1143. const { abnormalState } = row
  1144. if (abnormalState) {
  1145. if (abnormalState == 'DLY') {
  1146. classes.push('bgl-delayed')
  1147. }
  1148. if (abnormalState == 'CAN') {
  1149. classes.push('bgl-canceled')
  1150. }
  1151. }
  1152. if (row.hasTakenOff === 'Y' || row.hasLanded === 'Y') {
  1153. classes.push('bgl-hui')
  1154. }
  1155. if (rowIndex === this.leaveCount - 1 || rowIndex === this.arriveCount - 1) {
  1156. classes.push('redBorder')
  1157. }
  1158. }
  1159. return classes
  1160. },
  1161. // 表格-单元格点击
  1162. cellClick(row, column) {
  1163. const dataBtns = this.authBtnCol
  1164. if (dataBtns && dataBtns.length) {
  1165. const clickBtn = dataBtns.filter(item => item.relation_data === column.property)[0]
  1166. if (clickBtn) {
  1167. const { open_method, route_info, pass_parameters, relation_data } = clickBtn
  1168. if (Number(open_method) === 2 && Number(row[relation_data]) !== 0) {
  1169. if (pass_parameters) {
  1170. const query = pass_parameters.split(',')
  1171. const obj = {}
  1172. query.forEach(key => {
  1173. obj[key] = row[key]
  1174. })
  1175. if (['Inbound_flight_number'].includes(relation_data)) {
  1176. obj.outAirport = obj.inbound_flights_departure_airport
  1177. obj.landAirport = obj.current_airport
  1178. delete obj.current_airport
  1179. delete obj.inbound_flights_departure_airport
  1180. }
  1181. if (['departure_flights_number', 'departure_flights_transferred_bags_number', 'Inbound_baggage_number'].includes(relation_data)) {
  1182. obj.outAirport = obj.current_airport
  1183. obj.landAirport = obj.departure_flights_destination_airport
  1184. delete obj.current_airport
  1185. delete obj.departure_flights_destination_airport
  1186. }
  1187. this.$router.push({
  1188. path: route_info,
  1189. query: obj,
  1190. })
  1191. }
  1192. }
  1193. } else {
  1194. this.headerClick(row, column)
  1195. }
  1196. } else {
  1197. this.headerClick(row, column)
  1198. }
  1199. },
  1200. cellClick2(row, property) {
  1201. const obj = {
  1202. 'carrierFlights': row.carrierFlights,
  1203. 'carrierFlightsDate': row.carrierFlightsDate,
  1204. 'outAirport': row.outAirport,
  1205. 'landAirport': row.landAirport,
  1206. }
  1207. obj[property] = row[property]
  1208. this.$router.push({
  1209. path: '/newFlightView',
  1210. query: obj,
  1211. })
  1212. },
  1213. // 表格-备注-单元格点击
  1214. headerClick(row, column) {
  1215. const { property } = column
  1216. const path = this.$route.path
  1217. const newPath = !!((path.endsWith('/in') || path.endsWith('/out') || path.endsWith('/newQueryAdvance') || path.endsWith('/newBagDetails')))
  1218. if (newPath && property == 'luggage_describe') {
  1219. this.storyFlag = true
  1220. this.reamkeMap = row
  1221. this.queryStoryCheck(row)
  1222. }
  1223. if (newPath && property == 'remarks') {
  1224. if (property == 'remarks') {
  1225. this.form.desc = row.remarks || ''
  1226. } else if (property == 'luggage_describe') {
  1227. this.form.desc = row.luggage_describe || ''
  1228. }
  1229. this.reamkeFlag = true
  1230. this.reamkeMap = row
  1231. }
  1232. },
  1233. async queryStoryCheck(row) {
  1234. this.storyTable = []
  1235. const { ID, luggage_describe } = row
  1236. const params = {
  1237. serviceId: SERVICE_ID.advancedStoryId,
  1238. dataContent: {
  1239. luggageID: ID,
  1240. },
  1241. event: '0'
  1242. }
  1243. const { code, returnData } = await Query(params)
  1244. if (code == 0 && returnData?.length) {
  1245. const ndatas = [...returnData]
  1246. ndatas.forEach(item => item.createtime = parseTime(item.createtime.replace('T', ' '), '{y}-{m}-{d} {h}:{i}:{s}'))
  1247. this.storyTable = ndatas
  1248. }
  1249. },
  1250. async onStoryCheck() {
  1251. const { ID, luggage_describe } = this.reamkeMap
  1252. const params = {
  1253. serviceId: SERVICE_ID.advancedStoryId,
  1254. dataContent: {
  1255. luggageID: ID,
  1256. luggageDescribe: this.form.desc,
  1257. user_id: getToken('userid')
  1258. },
  1259. event: '1'
  1260. }
  1261. const parmasts = {
  1262. 'serviceId': SERVICE_ID.advancedRemakesId,
  1263. 'page': 1,
  1264. 'pageSize': 10,
  1265. 'dataContent': {
  1266. 'ID': ID,
  1267. 'luggage_describe': '...'
  1268. },
  1269. 'event': '2'
  1270. }
  1271. await modifyData(parmasts)
  1272. const { code } = await newData(params)
  1273. if (code == 0) {
  1274. const item = {
  1275. luggageDescribe: this.form.desc,
  1276. createtime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
  1277. }
  1278. this.storyTable.push(item)
  1279. this.$message.success('操作成功')
  1280. this.form.desc = ''
  1281. this.restTable()
  1282. this.load()
  1283. } else this.$message.success('操作失败')
  1284. },
  1285. // 表格-备注-单元格点击-弹框确定
  1286. onReamkeCheck() {
  1287. const path = this.$route.path
  1288. const name = path.endsWith('/in') || path.endsWith('/out') ? 'remarks' : path.endsWith('/newQueryAdvance') ? 'luggage_describe' : 'bag'
  1289. this.sendReamkesHttp(name)
  1290. },
  1291. // 发送备注请求
  1292. async sendReamkesHttp(key) {
  1293. const parmas = {
  1294. 'serviceId': key == 'remarks' ? SERVICE_ID.transferReamkesId : key == 'luggage_describe' ? SERVICE_ID.advancedRemakesId : SERVICE_ID.baggageRemakes,
  1295. 'page': 1,
  1296. 'pageSize': 10,
  1297. 'dataContent': {
  1298. 'ID': this.reamkeMap.ID,
  1299. },
  1300. 'event': '2'
  1301. }
  1302. key == 'remarks' ? parmas.dataContent.remarks = this.form.desc : parmas.dataContent.luggage_describe = this.form.desc
  1303. const { code } = await modifyData(parmas)
  1304. if (code == 0) this.$message.success('操作成功')
  1305. this.restTable()
  1306. this.load()
  1307. this.reamkeFlag = false
  1308. },
  1309. // 导出
  1310. exportHandler() {
  1311. const table = this.$refs['table'].$el.cloneNode(true)
  1312. const fileName = `${this.downName || this.AqueryParams.auth_name}.xlsx`
  1313. exportToExcel(table, `${this.downName || this.AqueryParams.auth_name}`, fileName)
  1314. },
  1315. formatter(row, column, cellValue, index) {
  1316. let sameColumn = null
  1317. this.tableCols.some(col => {
  1318. if (col.columnName === column.property) {
  1319. sameColumn = col
  1320. return true
  1321. } else if (col.children) {
  1322. col.children.some(childCol => {
  1323. if (childCol.columnName === column.property) {
  1324. sameColumn = childCol
  1325. return true
  1326. }
  1327. })
  1328. }
  1329. })
  1330. if (sameColumn && this.fromDataType(sameColumn.dataType) === 'datetime') {
  1331. return (cellValue ?? '').replace('T', '\n')
  1332. }
  1333. return cellValue
  1334. },
  1335. },
  1336. }
  1337. </script>
  1338. <style lang="scss" scoped>
  1339. .newQueryTable {
  1340. height: 100%;
  1341. position: relative;
  1342. ::v-deep .table {
  1343. p {
  1344. padding: 0;
  1345. }
  1346. .is-click-btn {
  1347. .cell {
  1348. color: #409eff;
  1349. cursor: pointer;
  1350. position: relative;
  1351. }
  1352. }
  1353. .txtToRed {
  1354. .cell {
  1355. color: #ff0000;
  1356. }
  1357. }
  1358. .cell {
  1359. color: #000;
  1360. text-align: center;
  1361. white-space: pre-line;
  1362. padding: 0;
  1363. .el-tooltip {
  1364. white-space: nowrap;
  1365. text-overflow: ellipsis;
  1366. overflow: hidden;
  1367. line-height: 34px;
  1368. }
  1369. }
  1370. tr.bgl-hui td {
  1371. background: #d2d6df;
  1372. }
  1373. tr.bgl-delayed td {
  1374. background: #fcf0b1;
  1375. }
  1376. tr.bgl-canceled td {
  1377. background: #f7babe;
  1378. }
  1379. .redBorder {
  1380. position: relative;
  1381. &::after {
  1382. content: "";
  1383. position: absolute;
  1384. left: 0;
  1385. bottom: 0;
  1386. width: 100%;
  1387. height: 2px;
  1388. background: #e83f82;
  1389. }
  1390. }
  1391. td.cell-toUnload {
  1392. background: lightcoral !important;
  1393. position: relative;
  1394. &::after {
  1395. content: "";
  1396. display: block;
  1397. width: 100%;
  1398. height: 100%;
  1399. position: absolute;
  1400. top: 0;
  1401. left: 0;
  1402. border: 2px dashed red;
  1403. }
  1404. }
  1405. td.cell-toBule {
  1406. background: rgba(45, 124, 255, 0.5) !important;
  1407. position: relative;
  1408. &::after {
  1409. content: "";
  1410. display: block;
  1411. width: 100%;
  1412. height: 100%;
  1413. position: absolute;
  1414. top: 0;
  1415. left: 0;
  1416. border: 2px dashed #2d7cff;
  1417. }
  1418. }
  1419. td.cell-toBule-red {
  1420. background: rgba(45, 124, 255, 0.5) !important;
  1421. position: relative;
  1422. .cell {
  1423. color: red;
  1424. }
  1425. &::after {
  1426. content: "";
  1427. display: block;
  1428. width: 100%;
  1429. height: 100%;
  1430. position: absolute;
  1431. top: 0;
  1432. left: 0;
  1433. border: 2px dashed #2d7cff;
  1434. }
  1435. }
  1436. }
  1437. .btns {
  1438. position: absolute;
  1439. top: -50px;
  1440. right: 32px;
  1441. z-index: 10;
  1442. }
  1443. .down-btns {
  1444. position: absolute;
  1445. top: -50px;
  1446. right: 72px;
  1447. z-index: 10;
  1448. }
  1449. }
  1450. </style>