index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. <template>
  2. <div class="data-table" :style="{ marginTop: marginTop }">
  3. <div
  4. :style="dataTableContentStyle"
  5. v-loading="loading"
  6. element-loading-text="拼命加载中"
  7. element-loading-spinner="el-icon-loading"
  8. element-loading-background="rgba(0, 0, 0, 0.8)"
  9. class="data-table-content"
  10. >
  11. <div :class="isStatus ? 'flex' : 'flex-end'" class="data-table-btn">
  12. <div v-if="isStatus" class="vStatus">
  13. <slot name="header" />
  14. </div>
  15. <el-button
  16. v-if="isBtn"
  17. size="small"
  18. @click="handleAdd"
  19. plain
  20. type="primary"
  21. >新增</el-button
  22. >
  23. </div>
  24. <template v-if="tableData.length">
  25. <div>
  26. <el-table
  27. v-el-table-infinite-scroll="load"
  28. :data="filteredTableData"
  29. :summary-method="getSummaries"
  30. :span-method="tableSpanMethod"
  31. :tree-props="treeProps"
  32. :row-key="rowKeyTree"
  33. stripe
  34. :show-summary="showSummary"
  35. border
  36. ref="table"
  37. :height="tableHeight ? tableHeight : minHeight - 8 + 'vh'"
  38. class="table infinite-list"
  39. style="width: 100%; overflow: auto"
  40. @select="selectHandler"
  41. >
  42. <el-table-column
  43. v-if="selectionEnable"
  44. type="selection"
  45. width="35"
  46. />
  47. <el-table-column v-if="isStatus" width="55">
  48. <template slot-scope="scope">
  49. <div class="tableStatus">
  50. <div
  51. v-if="filteredTableData[scope.$index].runState == '运行'"
  52. class="status0"
  53. >
  54. <span class="icon"></span>
  55. </div>
  56. <div
  57. v-else-if="
  58. filteredTableData[scope.$index].runState == '停止'
  59. "
  60. class="status1"
  61. >
  62. <span class="icon"></span>
  63. </div>
  64. <div v-else class="status2"><span class="icon"></span></div>
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column
  69. v-for="(item, index) in tableColsCopy"
  70. :sortable="item.needSort ? true : false"
  71. :key="index"
  72. :prop="item.columnName"
  73. :label="item.columnLabel"
  74. :show-overflow-tooltip="showOverflowTooltip"
  75. >
  76. <template #header>
  77. <span class="colTips">
  78. <el-tooltip :content="item.columnDescribe" placement="top">
  79. <span>{{ item.columnLabel }}</span>
  80. </el-tooltip>
  81. </span>
  82. <span v-if="item.needFilters">
  83. <el-popover
  84. placement="bottom"
  85. trigger="click"
  86. @show="popoverShowHandler(item.columnName)"
  87. @hide="popoverHideHandler"
  88. >
  89. <i
  90. slot="reference"
  91. :class="[
  92. 'filter-arrow',
  93. 'el-icon-arrow-down',
  94. arrowClass(item.columnName),
  95. ]"
  96. />
  97. <el-form>
  98. <el-form-item :label="item.columnLabel">
  99. <el-select
  100. v-model="filterValues[item.columnName]"
  101. size="small"
  102. placeholder="筛选"
  103. default-first-option
  104. filterable
  105. clearable
  106. >
  107. <el-option
  108. v-for="(option, optionIndex) in tableDataFilters[
  109. item.columnName
  110. ]"
  111. :key="option.value + optionIndex"
  112. :value="option.value"
  113. :label="option.text"
  114. />
  115. </el-select>
  116. </el-form-item>
  117. </el-form>
  118. </el-popover>
  119. </span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column fixed="right" label="操作" :width="fixedWidth">
  123. <template slot-scope="scope">
  124. <div class="hd-td">
  125. <div class="hd-tr">
  126. <template v-if="isStatus">
  127. <el-button
  128. type="text"
  129. @click="handleLook(scope.row)"
  130. size="small"
  131. class="rmScs"
  132. >查看</el-button
  133. >
  134. <el-button
  135. type="text"
  136. v-if="scope.row.runState == '停止'"
  137. @click="chanheState(scope.row)"
  138. size="small"
  139. class="rmScs"
  140. >启动</el-button
  141. >
  142. <el-button
  143. type="text"
  144. v-if="scope.row.runState == '运行'"
  145. @click="chanheState(scope.row)"
  146. size="small"
  147. class="rmScs"
  148. >停止</el-button
  149. >
  150. </template>
  151. <!-- <el-button class="hrefBtn" type="text" @click="handleHerf(scope.row)" size="small">跳转</el-button> -->
  152. <el-button
  153. type="text"
  154. @click="handleEdit(scope.row)"
  155. size="small"
  156. class="rmScs"
  157. >编辑</el-button
  158. >
  159. <el-button
  160. class="rmSc"
  161. type="text"
  162. @click="handleRemove(scope.row)"
  163. size="small"
  164. >删除</el-button
  165. >
  166. <el-button
  167. class="rmScs"
  168. v-if="withColumnSet"
  169. type="text"
  170. size="small"
  171. @click="handleColumnSet(scope.row)"
  172. >列设置</el-button
  173. >
  174. <el-button
  175. class="rmScs"
  176. v-if="withItemSet"
  177. type="text"
  178. size="small"
  179. @click="handleItemSet(scope.row)"
  180. >数据项</el-button
  181. >
  182. <el-button
  183. class="rmScser"
  184. v-if="withlodSet"
  185. type="text"
  186. size="small"
  187. @click="handlelodSet(scope.row)"
  188. >航站设置</el-button
  189. >
  190. <el-button
  191. class="rmScser"
  192. v-if="withnodeSet"
  193. type="text"
  194. size="small"
  195. @click="handlenodeSet(scope.row)"
  196. >位置设置</el-button
  197. >
  198. </div>
  199. </div>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. <!-- <p v-if="noMore" style="text-align: center">没有更多了</p> -->
  204. </div>
  205. </template>
  206. <template v-else>
  207. <NoData image-width="auto" image-height="100%" />
  208. </template>
  209. </div>
  210. <div class="data-table-dialog">
  211. <!--新增/编辑-->
  212. <Dialog :width="width" :flag="flag">
  213. <div class="dialog-content">
  214. <div class="title">{{ tableTitle }}</div>
  215. <div class="content">
  216. <el-form
  217. ref="ruleForm"
  218. :model="tableForm"
  219. :label-width="labelWidth"
  220. >
  221. <el-row :gutter="20">
  222. <el-col
  223. v-for="(item, index) in tableColsCopy"
  224. :key="index"
  225. :span="rows"
  226. >
  227. <el-form-item :label="item.columnLabel">
  228. <template
  229. v-if="
  230. item.listqueryTemplateID ||
  231. item.listqueryTemplateID == 0
  232. "
  233. >
  234. <el-select
  235. size="small"
  236. clearable
  237. style="width: 100%"
  238. v-model="tableForm[item.columnName]"
  239. @change="changeSelect(item.columnName)"
  240. placeholder="请选择"
  241. >
  242. <el-option
  243. v-for="item in tableOptions[item.columnName]"
  244. :key="item.v"
  245. :label="item.k"
  246. :value="item.v"
  247. >
  248. </el-option>
  249. </el-select>
  250. </template>
  251. <!-- <template v-else-if="item.dataType == 'longtext'">
  252. <el-input
  253. size="small"
  254. :rows="1"
  255. type="textarea"
  256. v-model="tableForm[item.columnName]"
  257. ></el-input>
  258. </template> -->
  259. <template v-else>
  260. <el-input
  261. size="small"
  262. v-model="tableForm[item.columnName]"
  263. @change="inputChangeHandler(item.columnName)"
  264. ></el-input>
  265. </template>
  266. </el-form-item>
  267. </el-col>
  268. </el-row>
  269. </el-form>
  270. </div>
  271. <div class="foot right t30">
  272. <el-button
  273. size="medium"
  274. @click="handleOk"
  275. class="r24"
  276. type="primary"
  277. >确定</el-button
  278. >
  279. <el-button @click="flag = false" size="medium">取消</el-button>
  280. </div>
  281. </div>
  282. </Dialog>
  283. <Dialog :flag="rmFlag">
  284. <div class="airportInfoDialog">
  285. <div class="title del-title">删除</div>
  286. <div class="content del-content">
  287. <span class="el-icon-error error r10"></span>您是否确认删除<span
  288. class="error l10"
  289. >{{ rmTitle }}</span
  290. >
  291. </div>
  292. <div class="foot right Delfoot t30">
  293. <el-button
  294. size="medium"
  295. class="r24"
  296. @click="tableRemove"
  297. type="danger"
  298. >删除</el-button
  299. >
  300. <el-button size="medium" @click="rmFlag = false">取消</el-button>
  301. </div>
  302. </div>
  303. </Dialog>
  304. </div>
  305. </div>
  306. </template>
  307. <script>
  308. import { setTableFilters } from "@/utils/table";
  309. import Dialog from "@/layout/components/Dialog/index.vue";
  310. import NoData from "@/components/nodata";
  311. import { translateDataToTreeAllTreeMsg } from "@/utils/validate";
  312. import {
  313. Query,
  314. GeneralDataReception,
  315. Start,
  316. Stop,
  317. } from "@/api/dataIntegration";
  318. export default {
  319. name: "DataTable",
  320. props: {
  321. isDialog: {
  322. type: Boolean,
  323. default: true,
  324. },
  325. //接口ID
  326. dataId: {
  327. type: [String, Number],
  328. default: "",
  329. },
  330. editId: {
  331. type: [String, Number],
  332. default: "",
  333. },
  334. dataContent: {
  335. type: Object,
  336. default: () => ({}),
  337. },
  338. //是否显示状态
  339. isStatus: {
  340. type: Boolean,
  341. default: false,
  342. },
  343. //弹框宽度
  344. width: {
  345. type: String,
  346. default: "560px",
  347. },
  348. //弹框表单-行数
  349. rows: {
  350. type: Number,
  351. default: 3,
  352. },
  353. //弹框-表单文字宽度
  354. labelWidth: {
  355. type: String,
  356. default: "80px",
  357. },
  358. //表格高度
  359. tableHeight: {
  360. type: [String, Number],
  361. default: 0,
  362. },
  363. minHeight: {
  364. type: Number,
  365. default: 65,
  366. },
  367. //是否显示树形表格
  368. isTree: {
  369. type: Boolean,
  370. default: false,
  371. },
  372. //树形props
  373. treeProps: {
  374. type: Object,
  375. default: function () {
  376. return { children: "children", hasChildren: "hasChildren" };
  377. },
  378. },
  379. //树形标识id
  380. rowKeyTree: {
  381. type: String,
  382. default: "companyID",
  383. },
  384. //是否显示新增按钮
  385. isBtn: {
  386. type: Boolean,
  387. default: true,
  388. },
  389. // 是否显示合计行
  390. showSummary: {
  391. type: Boolean,
  392. default: false,
  393. },
  394. marginTop: {
  395. type: String,
  396. default: "0px",
  397. },
  398. // 是否可选中行
  399. selectionEnable: {
  400. type: Boolean,
  401. default: false,
  402. },
  403. // 懒加载
  404. withLazyLoad: {
  405. type: Boolean,
  406. default: false,
  407. },
  408. // 不换行,溢出隐藏
  409. showOverflowTooltip: {
  410. type: Boolean,
  411. default: false,
  412. },
  413. // 表格-操作-列设置按钮显示
  414. withColumnSet: {
  415. type: Boolean,
  416. default: false,
  417. },
  418. // 表格-操作-项设置按钮显示
  419. withItemSet: {
  420. type: Boolean,
  421. default: false,
  422. },
  423. // 表格-操作-项设置按钮显示
  424. withlodSet: {
  425. type: Boolean,
  426. default: false,
  427. },
  428. // 表格-操作-节点按钮显示
  429. withnodeSet: {
  430. type: Boolean,
  431. default: false,
  432. },
  433. //操作列宽度
  434. fixedWidth: {
  435. type: String,
  436. default: "180px",
  437. },
  438. },
  439. components: { Dialog, NoData },
  440. data() {
  441. return {
  442. loading: false,
  443. flag: false,
  444. serviceId: null,
  445. rmFlag: false,
  446. rowTitle: "",
  447. page: 0,
  448. noMore: false,
  449. tableCols: [], //表头数据
  450. tableData: [], //表格数据
  451. tableColsCopy: [], //表头数据缓存
  452. tableDataFilters: {}, //表头-下拉数据
  453. filterValues: {}, //表头-下拉-选中数据
  454. tableDataCopy: [], //缓存table数据
  455. tableGroups: [], //表格分组数据
  456. colShowFilter: "", //表头-下拉-箭头
  457. spanArr: [], //表格分组数据缓存
  458. pos: 0, //表格分组计数
  459. tableTitle: "新增", //弹框标题
  460. tableType: "add", //弹框类型=新增/编辑
  461. tableForm: {}, //弹框表单
  462. rmTitle: "", //弹框-删除-标题
  463. tableObj: {}, //增/删/改数据缓存
  464. tableOptions: {}, //弹框-下来数据缓存
  465. tableArrs: [], //重组table-表头下拉
  466. proAll: false, //重组时-所有请求是否都完成
  467. };
  468. },
  469. computed: {
  470. dataTableContentStyle() {
  471. const style = {};
  472. if (this.minHeight) {
  473. style["min-height"] = this.minHeight;
  474. }
  475. if (this.tableHeight) {
  476. style["height"] = this.tableHeight;
  477. }
  478. return style;
  479. },
  480. //设置表头-下拉-箭头样式
  481. arrowClass() {
  482. return function (prop) {
  483. let classString = "";
  484. if (this.colShowFilter === prop) {
  485. return "arrow-active";
  486. }
  487. if (
  488. Object.entries(this.tableDataFilters).find(
  489. ([key, arr]) => this.filterValues[prop]
  490. )
  491. ) {
  492. classString += "arrow-blue";
  493. }
  494. return classString;
  495. };
  496. },
  497. //设置表头-下拉-选中数据
  498. filteredTableData() {
  499. if (this.isTree) {
  500. this.tableData = translateDataToTreeAllTreeMsg(
  501. this.tableData,
  502. "parentID",
  503. "companyID"
  504. );
  505. }
  506. return this.tableData.filter((item) => {
  507. let flag = true;
  508. Object.entries(this.filterValues).forEach(([key, value]) => {
  509. if (value !== "" && item[key] !== value) {
  510. flag = false;
  511. }
  512. });
  513. return flag;
  514. });
  515. },
  516. },
  517. watch: {
  518. dataContent: {
  519. handler(val) {
  520. if (val) {
  521. if (val.companyID) {
  522. this.resetTable();
  523. this.getQuery();
  524. }
  525. }
  526. },
  527. deep: true,
  528. },
  529. //监听机场变更的id 不可删除
  530. // dataId: {
  531. // if(val) {
  532. // console.log(val);
  533. // if (val.companyID) {
  534. // this.resetTable();
  535. // this.getQuery();
  536. // }
  537. // },
  538. // },
  539. },
  540. mounted() {
  541. this.getQuery();
  542. },
  543. updated() {
  544. this.$refs["table"]?.doLayout();
  545. },
  546. methods: {
  547. load() {
  548. // console.log("分页");
  549. if (!this.isTree) {
  550. if (this.noMore || this.loading) {
  551. return;
  552. }
  553. this.getQuery();
  554. }
  555. },
  556. resetTable() {
  557. this.page = 0;
  558. this.noMore = false;
  559. this.tableData = [];
  560. },
  561. changeSelect(data) {
  562. if (this.tableForm[data] === "") {
  563. this.tableForm[data] = null;
  564. }
  565. this.tableForm[this.tableOptions[data][0].setvalue] =
  566. this.tableForm[data];
  567. },
  568. inputChangeHandler(data) {
  569. if (this.tableForm[data] === "") {
  570. this.tableForm[data] = null;
  571. }
  572. },
  573. //获取表格数据
  574. async getQuery() {
  575. try {
  576. this.loading = true;
  577. const { code, returnData } = await Query({
  578. id: this.dataId,
  579. needPage: ++this.page,
  580. dataContent: [this.dataContent.companyID],
  581. });
  582. if (code == 0) {
  583. if (returnData.listValues.length === 0) {
  584. this.page--;
  585. this.noMore = true;
  586. this.loading = false;
  587. }
  588. const titleColumn = returnData.columnSet.find(
  589. (item) => item.needShow === 1
  590. );
  591. if (titleColumn) {
  592. this.rowTitle = titleColumn.columnName;
  593. }
  594. this.tableData.push(...returnData.listValues);
  595. this.tableCols = returnData.columnSet;
  596. this.serviceId = returnData.submitID;
  597. setTimeout(() => {
  598. this.initTableData();
  599. this.loading = false;
  600. }, 100);
  601. } else {
  602. this.page--;
  603. this.loading = false;
  604. this.$message.error("获取表格数据失败");
  605. }
  606. } catch (error) {
  607. this.page--;
  608. this.loading = false;
  609. console.log(error);
  610. }
  611. },
  612. //表格-增/删/改
  613. async generalDataReception(data) {
  614. try {
  615. data = {
  616. ...data,
  617. ...this.dataContent,
  618. };
  619. const { code, message } = await GeneralDataReception({
  620. serviceId: this.serviceId,
  621. dataContent: JSON.stringify(data),
  622. });
  623. if (code == 0) {
  624. this.$message.success("操作成功");
  625. this.resetTable();
  626. this.getQuery();
  627. this.flag = false;
  628. this.rmFlag = false;
  629. this.tableObj = {};
  630. this.tableForm = {};
  631. } else {
  632. this.$message.error("操作失败");
  633. this.flag = false;
  634. this.rmFlag = false;
  635. this.tableObj = {};
  636. this.tableForm = {};
  637. }
  638. } catch (error) {
  639. console.log(error);
  640. this.flag = false;
  641. this.rmFlag = false;
  642. this.tableObj = {};
  643. this.tableForm = {};
  644. }
  645. },
  646. // 表格勾选
  647. toggleRowSelection(row, isSelected) {
  648. this.$refs["table"].toggleRowSelection(row, isSelected);
  649. },
  650. // 表格初始勾选
  651. selectTableRows(tableData, selectFlagName) {
  652. tableData.forEach((row) => {
  653. this.$refs["table"].toggleRowSelection(row, !!row[selectFlagName]);
  654. });
  655. },
  656. //初始化表格
  657. initTableData() {
  658. this.tableColsCopy = this.tableCols.filter((item) => item.needShow);
  659. // console.log(this.tableColsCopy);
  660. // debugger;
  661. this.tableDataCopy = _.cloneDeep(this.tableData);
  662. const datas = _.cloneDeep(this.tableColsCopy);
  663. // const reqUts = [];
  664. datas.forEach(async (item) => {
  665. this.tableDataFilters[item.columnName] = [];
  666. if (item.needGroup) {
  667. this.tableGroups.push(item.columnName);
  668. }
  669. if (item.listqueryTemplateID || item.listqueryTemplateID == 0) {
  670. this.tableArrs.push(item.columnName);
  671. // const reqUt = this.getSelectData(item.listqueryTemplateID)
  672. // reqUts.push(reqUt)
  673. if (!this.tableOptions[item.columnName]) {
  674. this.tableOptions[item.columnName] = await this.getSelectData(
  675. item.listqueryTemplateID
  676. );
  677. }
  678. // console.log(this.tableOptions[item.columnName])
  679. }
  680. // this.filterValues[item.columnName] = ''
  681. });
  682. setTableFilters(this.tableData, this.tableDataFilters);
  683. this.tableGroup(this.tableData);
  684. this.selectTableRows(this.tableData, "DeployID");
  685. // this.getSelectDataAll(reqUts)
  686. },
  687. //获取所有获取弹框-下拉数据-请求状态
  688. getSelectDataAll(reqUts) {
  689. Promise.all(reqUts)
  690. .then((res) => {
  691. this.proAll = true;
  692. })
  693. .catch((err) => {
  694. this.proAll = false;
  695. });
  696. },
  697. //获取弹框-下拉数据
  698. async getSelectData(id) {
  699. const { code, returnData } = await Query({
  700. id,
  701. dataContent: [],
  702. });
  703. if (code == 0) {
  704. return returnData.listValues;
  705. } else {
  706. return [];
  707. }
  708. },
  709. //重组table-显示名称
  710. setTable() {
  711. this.tableArrs.forEach((item) => {
  712. this.tableOptions[item].forEach((p) => {
  713. this.tableDataCopy.forEach((msg) => {
  714. if (msg[item] == p.v) {
  715. msg[item] = p.k;
  716. }
  717. });
  718. this.tableDataFilters[item].forEach((cap) => {
  719. if (cap.value == p.v) {
  720. cap.text = p.k;
  721. cap.value = p.k;
  722. }
  723. });
  724. });
  725. });
  726. this.tableData = this.tableDataCopy;
  727. },
  728. //分组
  729. tableGroup(tableData) {
  730. const spanArr = [];
  731. let pos = 0;
  732. let ifYj = this.tableGroups[0];
  733. for (let i = 0; i < tableData.length; i++) {
  734. if (i === 0) {
  735. spanArr.push(1);
  736. } else {
  737. if (tableData[i][ifYj] === tableData[i - 1][ifYj]) {
  738. spanArr[pos] += 1;
  739. spanArr.push(0);
  740. } else {
  741. spanArr.push(1);
  742. pos = i;
  743. }
  744. }
  745. }
  746. this.spanArr = spanArr;
  747. this.pos = pos;
  748. },
  749. popoverShowHandler(prop) {
  750. this.colShowFilter = prop;
  751. },
  752. popoverHideHandler() {
  753. this.colShowFilter = "";
  754. },
  755. //分组
  756. tableSpanMethod({ row, column, rowIndex, columnIndex }) {
  757. if (this.tableGroups.includes(column["property"])) {
  758. const _row = this.spanArr[rowIndex];
  759. const _col = _row > 0 ? 1 : 0;
  760. return {
  761. rowspan: _row,
  762. colspan: _col,
  763. };
  764. }
  765. },
  766. //合计
  767. getSummaries(param) {
  768. const { columns, data } = param;
  769. const sums = [];
  770. columns.forEach((column, index) => {
  771. this.tableColsCopy.forEach((p) => {
  772. if (column.property == p.columnName && p.needCount) {
  773. const values = data.map((item) => Number(item[column.property]));
  774. if (!values.every((value) => isNaN(value))) {
  775. sums[index] = values.reduce((prev, curr) => {
  776. const value = Number(curr);
  777. if (!isNaN(value)) {
  778. return prev + curr;
  779. } else {
  780. return prev;
  781. }
  782. }, 0);
  783. sums[index] += "";
  784. }
  785. }
  786. });
  787. });
  788. return sums;
  789. },
  790. //弹框-确定
  791. handleOk() {
  792. this.submitClickHandler();
  793. },
  794. //滚动
  795. tableLoad() {
  796. console.log("d");
  797. },
  798. //表格-新增
  799. handleAdd() {
  800. // this.flag = true;
  801. // this.tableType = "add";
  802. // this.tableTitle = "新增";
  803. // this.tableForm = {};
  804. if (this.isDialog) {
  805. this.flag = true;
  806. this.tableType = "add";
  807. this.tableTitle = "新增";
  808. this.tableForm = {};
  809. this.tableForm = {
  810. companyID: this.dataContent.companyID,
  811. companyName: this.dataContent.companyName,
  812. fullName: "",
  813. };
  814. // console.log(this.tableForm.companyName);
  815. // this.tableForm.companyID = this.dataContent.companyID;
  816. } else {
  817. this.$emit("handleAdd");
  818. }
  819. // console.log(this.tableOptions);
  820. },
  821. //表格-编辑
  822. async handleEdit(row) {
  823. if (this.isDialog) {
  824. if (this.editId) {
  825. let data = await this.queryOriginRow(
  826. this.editId,
  827. row.queryTemplateColumnSetID
  828. );
  829. this.tableForm = JSON.parse(JSON.stringify(data));
  830. // this.tableForm =this.tableForm;
  831. // Object.entries(tableForm).forEach(([key, value]) => {
  832. // this.tableForm[key] = value
  833. // })
  834. } else {
  835. this.tableForm = JSON.parse(JSON.stringify(row));
  836. console.log(this.tableForm);
  837. }
  838. this.flag = true;
  839. this.tableType = "edit";
  840. this.tableTitle = "编辑";
  841. } else {
  842. this.$emit("handleEdit", row);
  843. }
  844. },
  845. async queryOriginRow(editId, queryTemplateColumnSetID) {
  846. try {
  847. const { code, returnData } = await Query({
  848. id: editId,
  849. dataContent: [queryTemplateColumnSetID],
  850. });
  851. if (Number(code) === 0) {
  852. return returnData.listValues[0];
  853. } else {
  854. this.$message.error("失败");
  855. }
  856. } catch (error) {
  857. console.log(error);
  858. }
  859. },
  860. //表格-跳转
  861. handleHerf(row) {
  862. alert("跳转");
  863. },
  864. // 新增/编辑-确认
  865. submitClickHandler() {
  866. this.$refs["ruleForm"].validate((valid) => {
  867. if (valid) {
  868. this.dataContent.companyID = this.tableForm.companyID;
  869. this.dataContent.companyName = this.tableForm.companyName;
  870. if (this.tableType == "add") {
  871. this.tableForm.event = 1;
  872. } else {
  873. this.tableForm.event = 2;
  874. }
  875. this.generalDataReception(this.tableForm);
  876. } else {
  877. return false;
  878. }
  879. });
  880. },
  881. //表格-删除
  882. handleRemove(row) {
  883. this.rmFlag = true;
  884. // this.rmTitle = row.className || row.username || row.serviceName || row.queryTemplateName;
  885. this.rmTitle = row[this.rowTitle];
  886. this.tableObj = row;
  887. },
  888. //表格-删除-确认
  889. tableRemove() {
  890. this.tableObj.event = 3;
  891. this.generalDataReception(this.tableObj);
  892. },
  893. // 表格-跳转列设置页
  894. handleColumnSet(row) {
  895. this.$router.push({
  896. path: "/systemSettings/queryTemplateChild",
  897. query: {
  898. queryTemplateID: row.queryTemplateID,
  899. },
  900. });
  901. },
  902. // 表格-跳转数据项设置页
  903. handleItemSet(row) {
  904. this.$router.push({
  905. path: "/systemSettings/datastructureChild",
  906. query: {
  907. dataStructureID: row.dataStructureID,
  908. },
  909. });
  910. },
  911. // 表格-跳转航站设置页
  912. handlelodSet(row) {
  913. this.$router.push({
  914. path: "/BasicsData/airportInfoChild",
  915. query: {
  916. IATACode: row.IATACode,
  917. },
  918. });
  919. },
  920. // 表格-节点置页
  921. handlenodeSet(row) {
  922. this.$router.push({
  923. path: "/BasicsData/deployNodeChild",
  924. query: {
  925. nodeCode: row.nodeCode,
  926. },
  927. });
  928. },
  929. // 表格-查看
  930. handleLook(row) {
  931. this.$router.push({
  932. name: "serviceTopology",
  933. params: {
  934. serviceID: row.serviceID,
  935. serviceName: row.serviceName,
  936. },
  937. });
  938. },
  939. // 表格-启动/停止
  940. async chanheState(row) {
  941. const runState = row.runState == "运行" ? 0 : 1;
  942. const serviceID = row.serviceID;
  943. this.changeBtn(runState, serviceID);
  944. },
  945. // 表格-选中行
  946. selectHandler(selection, row) {
  947. this.$emit("selection-change", selection, row);
  948. },
  949. async changeBtn(state, id) {
  950. let res = null;
  951. // const { code, message } = await GeneralDataReception({
  952. // serviceId: 61,
  953. // dataContent: JSON.stringify(obj)
  954. // })
  955. if (state) {
  956. res = await Start({
  957. serviceId: id,
  958. });
  959. } else {
  960. res = await Stop({
  961. serviceId: id,
  962. });
  963. }
  964. if (res.code == 0) {
  965. this.$message.success(res.message);
  966. this.resetTable();
  967. this.getQuery();
  968. } else {
  969. this.$message.error(res.message);
  970. }
  971. },
  972. },
  973. };
  974. </script>
  975. <style lang="scss" scoped>
  976. .data-table {
  977. width: 100%;
  978. // background-color: #fff;
  979. // padding: 20px;
  980. .data-table-content {
  981. height: 100%;
  982. }
  983. ::v-deep .table {
  984. width: 100%;
  985. .cell {
  986. padding: 0;
  987. text-align: center;
  988. font-size: 14px;
  989. font-family: Helvetica, "Microsoft YaHei";
  990. letter-spacing: 0;
  991. }
  992. .cell-click {
  993. cursor: pointer;
  994. color: #2d7cff;
  995. &.cell-clicked {
  996. color: purple;
  997. }
  998. }
  999. .el-table__header-wrapper {
  1000. .cell {
  1001. font-weight: bold;
  1002. color: #101116;
  1003. > .el-checkbox {
  1004. display: none;
  1005. }
  1006. }
  1007. .has-gutter {
  1008. tr {
  1009. .bgl-huang {
  1010. background: #fcf0b1;
  1011. }
  1012. }
  1013. }
  1014. }
  1015. .el-table__body-wrapper {
  1016. tr.bgl-hui {
  1017. background: #d2d6df;
  1018. td {
  1019. background: #d2d6df;
  1020. }
  1021. &.redBorder {
  1022. position: relative;
  1023. &::after {
  1024. content: "";
  1025. position: absolute;
  1026. left: 0;
  1027. bottom: 0;
  1028. width: 100%;
  1029. height: 2px;
  1030. background: #e83f82;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. .rmScs {
  1036. width: 48px;
  1037. height: 24px;
  1038. border-color: #9ebbf7;
  1039. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  1040. border-radius: 4px;
  1041. display: flex;
  1042. align-items: center;
  1043. justify-content: center;
  1044. float: left;
  1045. span {
  1046. color: #2d67e3;
  1047. }
  1048. }
  1049. .rmScser {
  1050. width: 60px;
  1051. height: 24px;
  1052. border-color: #9ebbf7;
  1053. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  1054. border-radius: 4px;
  1055. display: flex;
  1056. align-items: center;
  1057. justify-content: center;
  1058. float: left;
  1059. span {
  1060. color: #2d67e3;
  1061. }
  1062. }
  1063. .rmSc {
  1064. width: 48px;
  1065. height: 24px;
  1066. background: #eb2f3b;
  1067. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  1068. border-radius: 4px;
  1069. display: flex;
  1070. align-items: center;
  1071. justify-content: center;
  1072. span {
  1073. color: #ffffff;
  1074. }
  1075. }
  1076. .hrefBtn {
  1077. width: 48px;
  1078. height: 24px;
  1079. background: #6f81bc;
  1080. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  1081. border-radius: 4px;
  1082. display: flex;
  1083. align-items: center;
  1084. justify-content: center;
  1085. span {
  1086. color: #ffffff;
  1087. }
  1088. }
  1089. .tableStatus {
  1090. font-size: 14px;
  1091. .icon {
  1092. width: 14px;
  1093. height: 14px;
  1094. background: #2d67e3;
  1095. border-radius: 2px;
  1096. display: inline-block;
  1097. vertical-align: middle;
  1098. position: relative;
  1099. top: -2px;
  1100. }
  1101. .status0 {
  1102. position: relative;
  1103. top: 5px;
  1104. }
  1105. .status1 {
  1106. position: relative;
  1107. top: 5px;
  1108. .icon {
  1109. background-color: #afb4bf;
  1110. }
  1111. }
  1112. .status2 {
  1113. position: relative;
  1114. top: 5px;
  1115. .icon {
  1116. background-color: #eb2f3b;
  1117. }
  1118. }
  1119. }
  1120. .el-table__fixed-right {
  1121. thead {
  1122. div {
  1123. color: #101116;
  1124. }
  1125. }
  1126. }
  1127. .hd-td {
  1128. .hd-tr {
  1129. display: flex;
  1130. justify-content: center;
  1131. flex-direction: row;
  1132. padding: 0 8px;
  1133. }
  1134. }
  1135. }
  1136. .data-table-btn {
  1137. line-height: 32px;
  1138. margin-bottom: 20px;
  1139. }
  1140. }
  1141. .filter-arrow {
  1142. cursor: pointer;
  1143. transition: 0.3s transform;
  1144. &.arrow-active {
  1145. transform: rotate(-180deg);
  1146. }
  1147. &.arrow-blue {
  1148. color: #2d7cff;
  1149. font-weight: bold;
  1150. }
  1151. }
  1152. .el-select-dropdown__item.hover {
  1153. background: #d2d6df;
  1154. }
  1155. </style>