index.vue 28 KB

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