index.vue 30 KB

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