index.vue 33 KB

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