index.vue 31 KB

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