index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  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 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" clearable 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.setTableCols();
  326. this.getQuery(id);
  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.getQueryListAuth(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. if (item.needGroup) {
  516. this.tableGroups.push(item.columnName);
  517. }
  518. });
  519. const dats = this.setTableFilters(this.tableData, this.tableDataFilters)
  520. this.tableDataFilters = _.cloneDeep(dats)
  521. // this.selectTableRows(this.tableData, "DeployID");
  522. this.tableGroup(this.tableData)
  523. // this.getSelectDataAll(reqUts)
  524. },
  525. setTableFilters (tableData, filters) {
  526. const tempSets = {}
  527. Object.keys(filters).forEach(key => {
  528. tempSets[key] = new Set()
  529. })
  530. tableData.forEach(item => {
  531. Object.keys(tempSets).forEach(key => {
  532. ; (item[key] ?? '') !== '' && tempSets[key].add(String(item[key]))
  533. })
  534. })
  535. Object.keys(tempSets).forEach(key => {
  536. filters[key] = _.orderBy(
  537. [...tempSets[key]].map(value => ({
  538. text: value,
  539. value,
  540. })),
  541. o => o.value
  542. )
  543. })
  544. return filters
  545. },
  546. //获取所有获取弹框-下拉数据-请求状态
  547. getSelectDataAll (reqUts) {
  548. Promise.all(reqUts)
  549. .then((res) => {
  550. this.proAll = true;
  551. })
  552. .catch((err) => {
  553. this.proAll = false;
  554. });
  555. },
  556. //获取弹框-下拉数据
  557. async getSelectData (id, name) {
  558. // name ? [name] : name === null ? [null]: [],
  559. const { code, returnData } = await Query({
  560. id,
  561. dataContent: name ? [name] : name === null ? [null] : [],
  562. });
  563. if (code == 0) {
  564. return returnData.listValues;
  565. } else {
  566. return [];
  567. }
  568. },
  569. //重组table-显示名称
  570. setTable () {
  571. this.tableArrs.forEach((item) => {
  572. this.tableOptions[item].forEach((p) => {
  573. this.tableDataCopy.forEach((msg) => {
  574. if (msg[item] == p.v) {
  575. msg[item] = p.k;
  576. }
  577. });
  578. this.tableDataFilters[item].forEach((cap) => {
  579. if (cap.value == p.v) {
  580. cap.text = p.k;
  581. cap.value = p.k;
  582. }
  583. });
  584. });
  585. });
  586. this.tableData = this.tableDataCopy;
  587. },
  588. //分组
  589. tableGroup (tableData) {
  590. const spanArr = [];
  591. let pos = 0;
  592. let ifYj = this.tableGroups[0];
  593. for (let i = 0; i < tableData.length; i++) {
  594. if (i === 0) {
  595. spanArr.push(1);
  596. } else {
  597. if (tableData[i][ifYj] === tableData[i - 1][ifYj]) {
  598. spanArr[pos] += 1;
  599. spanArr.push(0);
  600. } else {
  601. spanArr.push(1);
  602. pos = i;
  603. }
  604. }
  605. }
  606. this.spanArr = spanArr;
  607. this.pos = pos;
  608. },
  609. popoverShowHandler (prop) {
  610. this.colShowFilter = prop;
  611. },
  612. popoverHideHandler () {
  613. this.colShowFilter = "";
  614. },
  615. formatter (row, column, cellValue, index) {
  616. const sameColumn = this.tableCols.find(
  617. col => col.columnName === column.property
  618. )
  619. if (sameColumn && this.fromDataType(sameColumn.dataType) === 'datetime') {
  620. return (cellValue ?? '').replace('T', ' ')
  621. }
  622. return cellValue
  623. },
  624. //分组
  625. tableSpanMethod ({ row, column, rowIndex, columnIndex }) {
  626. if (this.tableGroups.includes(column["property"])) {
  627. const _row = this.spanArr[rowIndex];
  628. const _col = _row > 0 ? 1 : 0;
  629. return {
  630. rowspan: _row,
  631. colspan: _col,
  632. };
  633. }
  634. },
  635. //合计
  636. getSummaries (param) {
  637. const { columns, data } = param;
  638. const sums = [];
  639. columns.forEach((column, index) => {
  640. this.tableColsCopy.forEach((p) => {
  641. if (column.property == p.columnName && p.needCount) {
  642. const values = data.map((item) => Number(item[column.property]));
  643. if (!values.every((value) => isNaN(value))) {
  644. sums[index] = values.reduce((prev, curr) => {
  645. const value = Number(curr);
  646. if (!isNaN(value)) {
  647. return prev + curr;
  648. } else {
  649. return prev;
  650. }
  651. }, 0);
  652. sums[index] += "";
  653. }
  654. }
  655. });
  656. });
  657. return sums;
  658. },
  659. //弹框-确定
  660. handleOk () {
  661. this.submitClickHandler();
  662. },
  663. //滚动
  664. tableLoad () { },
  665. //表格-新增
  666. handleAdd () {
  667. this.flag = true;
  668. this.tableType = "add";
  669. this.tableTitle = "新增算法配置";
  670. for (const key in this.form) {
  671. if (Object.hasOwnProperty.call(this.form, key)) {
  672. this.form[key] = null
  673. }
  674. }
  675. },
  676. async getDataSourceId (id) {
  677. const { code, returnData } = await this.getQueryList(id, this.dataContent);
  678. if (code == 0) {
  679. this.dataSourceArrs = returnData
  680. }
  681. },
  682. //表格-编辑
  683. handleEdit (row) {
  684. this.flag = true;
  685. this.tableType = "edit";
  686. this.tableTitle = "编辑算法配置";
  687. this.form = JSON.parse(JSON.stringify(row));
  688. this.form.isActiveTable = row.isActiveTable == '1' ? true : false
  689. },
  690. successData () {
  691. this.$message.success("操作成功");
  692. this.resetTable();
  693. this.getQuery(this.queryId);
  694. this.flag = false;
  695. this.rmFlag = false;
  696. this.tableObj = {};
  697. this.form = {};
  698. },
  699. // 新增/编辑-确认
  700. submitClickHandler () {
  701. this.$refs["ruleForm"].validate(async (valid) => {
  702. if (valid) {
  703. this.form = Object.assign(this.form, this.dataContent)
  704. if (this.tableType == "add") {
  705. const { code } = await this.getChangeList(this.dataId, this.form, 1)
  706. if (code == 0) {
  707. this.successData()
  708. }
  709. } else {
  710. const { code } = await this.getChangeList(this.dataId, this.form, 2, 'library_id')
  711. if (code == 0) {
  712. this.successData()
  713. }
  714. }
  715. } else {
  716. return false;
  717. }
  718. });
  719. },
  720. //表格-删除
  721. handleRemove (row) {
  722. this.rmFlag = true;
  723. // this.rmTitle = row.className || row.username || row.serviceName || row.queryTemplateName;
  724. this.rmTitle = row[this.rowTitle];
  725. this.tableObj = row;
  726. },
  727. //表格-删除-确认
  728. async tableRemove () {
  729. const { code } = await this.getChangeList(this.dataId, this.tableObj, 3)
  730. if (code == 0) {
  731. this.successData()
  732. }
  733. },
  734. // 表格-选中行
  735. selectHandler (selection, row) {
  736. this.$emit("selection-change", selection, row);
  737. },
  738. // 表格-查询模板预览
  739. handlePreview (row) {
  740. this.$emit("preview", row);
  741. },
  742. },
  743. };
  744. </script>
  745. <style lang="scss" scoped>
  746. .data-table {
  747. width: 100%;
  748. // background-color: #fff;
  749. padding: 20px;
  750. .data-table-content {
  751. height: 100%;
  752. .nodata {
  753. margin-top: 25px;
  754. }
  755. }
  756. .bcButton {
  757. background: #2f3480;
  758. border-radius: 4px;
  759. border-color: #2f3480;
  760. color: #ffffff;
  761. }
  762. .bcButton.is-disabled {
  763. color: #8cc5ff;
  764. background-color: #2f3480;
  765. border-color: #d9ecff;
  766. }
  767. .bcTitle {
  768. font-size: 20px;
  769. font-family: Microsoft YaHei;
  770. font-weight: bold;
  771. color: #303133;
  772. }
  773. ::v-deep .table {
  774. width: 100%;
  775. margin-top: 25px;
  776. .cell {
  777. padding: 0;
  778. text-align: center;
  779. font-size: 14px;
  780. font-family: Helvetica, "Microsoft YaHei";
  781. letter-spacing: 0;
  782. }
  783. .hd-td {
  784. display: flex;
  785. justify-content: center;
  786. }
  787. .cell-click {
  788. cursor: pointer;
  789. color: #2f3480;
  790. &.cell-clicked {
  791. color: purple;
  792. }
  793. }
  794. .el-table__header-wrapper {
  795. .cell {
  796. font-weight: bold;
  797. color: #101116;
  798. .el-tooltip {
  799. white-space: nowrap;
  800. text-overflow: ellipsis;
  801. overflow: hidden;
  802. line-height: 34px;
  803. }
  804. > .el-checkbox {
  805. display: none;
  806. }
  807. }
  808. .has-gutter {
  809. tr {
  810. .bgl-huang {
  811. background: #fcf0b1;
  812. }
  813. }
  814. }
  815. }
  816. .el-table__body-wrapper {
  817. tr.bgl-hui {
  818. background: #d2d6df;
  819. td {
  820. background: #d2d6df;
  821. }
  822. &.redBorder {
  823. position: relative;
  824. &::after {
  825. content: "";
  826. position: absolute;
  827. left: 0;
  828. bottom: 0;
  829. width: 100%;
  830. height: 2px;
  831. background: #e83f82;
  832. }
  833. }
  834. }
  835. }
  836. .rmScs {
  837. width: 48px;
  838. height: 24px;
  839. border-color: #b2cbde;
  840. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  841. border-radius: 4px;
  842. display: flex;
  843. align-items: center;
  844. justify-content: center;
  845. float: left;
  846. span {
  847. color: #2f3480;
  848. }
  849. }
  850. .rmScser {
  851. width: 60px;
  852. height: 24px;
  853. border-color: #9ebbf7;
  854. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  855. border-radius: 4px;
  856. display: flex;
  857. align-items: center;
  858. justify-content: center;
  859. float: left;
  860. span {
  861. color: #2f3480;
  862. }
  863. }
  864. .rmSc {
  865. width: 48px;
  866. height: 24px;
  867. background: #eb2f3b;
  868. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  869. border-radius: 4px;
  870. display: flex;
  871. align-items: center;
  872. justify-content: center;
  873. span {
  874. color: #ffffff;
  875. }
  876. }
  877. .hrefBtn {
  878. width: 48px;
  879. height: 24px;
  880. background: #6f81bc;
  881. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  882. border-radius: 4px;
  883. display: flex;
  884. align-items: center;
  885. justify-content: center;
  886. span {
  887. color: #ffffff;
  888. }
  889. }
  890. .tableStatus {
  891. font-size: 14px;
  892. .icon {
  893. width: 14px;
  894. height: 14px;
  895. background: #2f3480;
  896. border-radius: 2px;
  897. display: inline-block;
  898. vertical-align: middle;
  899. position: relative;
  900. top: -2px;
  901. }
  902. .status0 {
  903. position: relative;
  904. top: 5px;
  905. }
  906. .status1 {
  907. position: relative;
  908. top: 5px;
  909. .icon {
  910. background-color: #afb4bf;
  911. }
  912. }
  913. .status2 {
  914. position: relative;
  915. top: 5px;
  916. .icon {
  917. background-color: #eb2f3b;
  918. }
  919. }
  920. }
  921. .el-table__fixed-right {
  922. thead {
  923. div {
  924. color: #101116;
  925. }
  926. }
  927. }
  928. .hd-td {
  929. .hd-tr {
  930. display: flex;
  931. justify-content: center;
  932. flex-direction: row;
  933. padding: 0 8px;
  934. }
  935. }
  936. }
  937. .data-table-btn {
  938. margin-top: 13px;
  939. line-height: 32px;
  940. margin-bottom: 20px;
  941. }
  942. }
  943. .filter-arrow {
  944. cursor: pointer;
  945. transition: 0.3s transform;
  946. &.arrow-active {
  947. transform: rotate(-180deg);
  948. }
  949. &.arrow-blue {
  950. color: #2f3480;
  951. font-weight: bold;
  952. }
  953. }
  954. .el-select-dropdown__item.hover {
  955. background: #d2d6df;
  956. }
  957. .data-table-dialog {
  958. ::v-deep .dialog-content {
  959. .title {
  960. background-color: #2f3480;
  961. }
  962. .bcButton {
  963. background-color: #2f3480;
  964. }
  965. .contents {
  966. padding: 24px;
  967. .el-form {
  968. padding-right: 0;
  969. }
  970. .el-select {
  971. width: 100%;
  972. }
  973. .r40 {
  974. margin-right: 60px;
  975. }
  976. }
  977. .datetimes {
  978. width: 100%;
  979. }
  980. .el-form-item__content {
  981. line-height: 41px;
  982. }
  983. }
  984. }
  985. </style>