index.vue 31 KB

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