index.vue 30 KB

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