query.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. v-if="queryData.length"
  6. ref="queryForm"
  7. :model="queryParams"
  8. size="small"
  9. label-position="left"
  10. >
  11. <SearchBar :show-span="12" :collapse-span="6" :show-more="false">
  12. <template #header>
  13. <template>
  14. <el-col :span="24">
  15. <el-button type="text" style="font-weight: bold">{{
  16. title
  17. }}</el-button></el-col
  18. >
  19. <template v-for="(data, idx) in queryList">
  20. <el-col :key="idx" :span="9">
  21. <el-select
  22. v-model="queryList[idx].key"
  23. style="width: 35%"
  24. size="mini"
  25. filterable
  26. placeholder="请选择"
  27. @change="queryKeyChange($event, idx, 'query')"
  28. >
  29. <el-option
  30. v-for="(item, i) in searchData"
  31. :key="i"
  32. :label="item.columnComment"
  33. :value="item.columnName"
  34. />
  35. </el-select>
  36. <DictSelect
  37. v-if="data.dataType != 'ym_date_query_type'"
  38. v-model="queryList[idx].operate"
  39. style="width: 28%"
  40. size="mini"
  41. placeholder="请选择"
  42. :dict-type="data.dataType ? data.dataType.toUpperCase() : ''"
  43. />
  44. <el-form-item
  45. style="display: inline-block"
  46. :style="
  47. data.dataType == 'ym_date_query_type'
  48. ? 'width: 63%;'
  49. : 'width: 35%;'
  50. "
  51. >
  52. <!-- 文本域 -->
  53. <el-input
  54. v-if="data.htmlType == 'textarea'"
  55. v-model="queryList[idx].value"
  56. type="textarea"
  57. :placeholder="'请输入'"
  58. clearable
  59. size="mini"
  60. @keyup.enter.native="handleQuery"
  61. />
  62. <!-- 日期选择 -->
  63. <el-date-picker
  64. v-else-if="
  65. data.htmlType == 'datetime' ||
  66. data.htmlType == 'datetimerange' ||
  67. data.htmlType == 'daterange'
  68. "
  69. v-model="queryList[idx].value"
  70. value-format="yyyy-MM-dd HH:mm:ss"
  71. type="datetimerange"
  72. :default-time="['00:00:00', '23:59:59']"
  73. placeholder="选择日期"
  74. start-placeholder="开始时间"
  75. end-placeholder="结束时间"
  76. />
  77. <!-- 字典下拉 -->
  78. <DictSelect
  79. v-else-if="data.htmlType == 'select' && data.dictType"
  80. v-model="queryList[idx].value"
  81. placeholder="请选择"
  82. :dict-type="data.dictType.toUpperCase()"
  83. />
  84. <!-- 字典单选 -->
  85. <el-radio-group
  86. v-else-if="data.htmlType == 'radio' && data.dictType"
  87. v-model="queryList[idx].value"
  88. >
  89. <el-radio
  90. v-for="dict in getDictDatas(
  91. DICT_TYPE[data.dictType.toUpperCase()]
  92. )"
  93. :key="dict.value"
  94. :label="parseInt(dict.value)"
  95. >{{ dict.label }}</el-radio
  96. >
  97. </el-radio-group>
  98. <!-- 输入框 -->
  99. <el-input
  100. v-else
  101. v-model="queryList[idx].value"
  102. :placeholder="'请输入'"
  103. clearable
  104. size="mini"
  105. />
  106. </el-form-item>
  107. </el-col>
  108. </template>
  109. <el-col :span="6">
  110. <el-button
  111. type="primary"
  112. icon="el-icon-search"
  113. size="mini"
  114. @click="handleQuery"
  115. >搜索</el-button
  116. >
  117. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  118. >重置</el-button
  119. >
  120. <el-popover
  121. v-if="true"
  122. v-model="visible"
  123. placement="bottom"
  124. width="500"
  125. >
  126. <div>
  127. <template v-for="(data, idx) in querySetList">
  128. <el-col :key="idx" :span="24">
  129. <el-select
  130. v-model="querySetList[idx].key"
  131. style="width: 30%"
  132. size="mini"
  133. placeholder="请选择"
  134. filterable
  135. @change="queryKeyChange($event, idx, 'querySet')"
  136. >
  137. <el-option
  138. v-for="(item, i) in searchData"
  139. :key="i"
  140. :label="item.columnComment"
  141. :value="item.columnName"
  142. />
  143. </el-select>
  144. <DictSelect
  145. v-if="data.dataType != 'ym_date_query_type'"
  146. v-model="querySetList[idx].operate"
  147. style="width: 25%"
  148. size="mini"
  149. placeholder="请选择"
  150. :dict-type="
  151. data.dataType ? data.dataType.toUpperCase() : ''
  152. "
  153. />
  154. <el-form-item
  155. style="display: inline-block"
  156. :style="
  157. data.dataType == 'ym_date_query_type'
  158. ? 'width: 55%;'
  159. : 'width: 30%;'
  160. "
  161. >
  162. <!-- 文本域 -->
  163. <el-input
  164. v-if="data.htmlType == 'textarea'"
  165. v-model="querySetList[idx].value"
  166. type="textarea"
  167. :placeholder="'请输入'"
  168. clearable
  169. size="mini"
  170. />
  171. <!-- 日期选择 -->
  172. <el-date-picker
  173. v-else-if="
  174. data.htmlType == 'datetime' ||
  175. data.htmlType == 'datetimerange' ||
  176. data.htmlType == 'daterange'
  177. "
  178. v-model="querySetList[idx].value"
  179. style="width: 100%"
  180. value-format="yyyy-MM-dd HH:mm:ss"
  181. type="datetimerange"
  182. :default-time="['00:00:00', '23:59:59']"
  183. placeholder="选择日期"
  184. start-placeholder="开始时间"
  185. end-placeholder="结束时间"
  186. />
  187. <!-- 字典下拉 -->
  188. <DictSelect
  189. v-else-if="data.htmlType == 'select' && data.dictType"
  190. v-model="querySetList[idx].value"
  191. placeholder="请选择"
  192. :dict-type="data.dictType.toUpperCase()"
  193. />
  194. <!-- 字典单选 -->
  195. <el-radio-group
  196. v-else-if="data.htmlType == 'radio' && data.dictType"
  197. v-model="querySetList[idx].value"
  198. >
  199. <el-radio
  200. v-for="dict in getDictDatas(
  201. DICT_TYPE[data.dictType.toUpperCase()]
  202. )"
  203. :key="dict.value"
  204. :label="parseInt(dict.value)"
  205. >{{ dict.label }}</el-radio
  206. >
  207. </el-radio-group>
  208. <!-- 输入框 -->
  209. <el-input
  210. v-else
  211. v-model="querySetList[idx].value"
  212. :placeholder="'请输入'"
  213. clearable
  214. size="mini"
  215. />
  216. </el-form-item>
  217. <i
  218. v-if="idx != 0"
  219. class="el-icon-remove-outline"
  220. @click="delQueryItem(idx)"
  221. />
  222. </el-col>
  223. </template>
  224. <el-col :span="24">
  225. <el-select
  226. v-model="querySettingKey"
  227. style="width: 30%"
  228. filterable
  229. size="mini"
  230. placeholder="请选择"
  231. @change="querySettingKeyChange"
  232. >
  233. <el-option
  234. v-for="(item, i) in searchData"
  235. :key="i"
  236. :label="item.columnComment"
  237. :value="item.columnName"
  238. />
  239. </el-select>
  240. </el-col>
  241. </div>
  242. <div style="text-align: right; margin: 0">
  243. <el-button size="mini" type="text" @click="visible = false"
  244. >取消</el-button
  245. >
  246. <el-button type="primary" size="mini" @click="queryDataSetOk"
  247. >确定</el-button
  248. >
  249. </div>
  250. <el-button slot="reference" size="mini"
  251. ><i class="el-icon-setting"
  252. /></el-button> </el-popover
  253. ></el-col>
  254. </template>
  255. </template>
  256. <template #buttons />
  257. </SearchBar>
  258. </el-form>
  259. <!-- 操作工具栏 -->
  260. <el-row :gutter="10" class="mb8">
  261. <el-col :span="1.5">
  262. <el-button
  263. type="warning"
  264. plain
  265. icon="el-icon-download"
  266. size="mini"
  267. @click="Export"
  268. >导出</el-button
  269. >
  270. </el-col>
  271. <el-col :span="1.5">
  272. <el-button
  273. type="primary"
  274. plain
  275. icon="el-icon-download"
  276. size="mini"
  277. :loading="exportLoading"
  278. @click="ExportAll"
  279. >导出全部</el-button
  280. >
  281. </el-col>
  282. <el-col :span="1.5">
  283. <el-dropdown
  284. v-show="dropdownList && dropdownList.length > 0"
  285. @command="batchCommand"
  286. >
  287. <el-button type="primary" size="mini">
  288. 扩展业务功能<i class="el-icon-arrow-down" />
  289. </el-button>
  290. <el-dropdown-menu>
  291. <el-dropdown-item
  292. v-for="(item, i) in dropdownList"
  293. :key="i"
  294. :command="item.value"
  295. >{{ item.text }}</el-dropdown-item
  296. >
  297. </el-dropdown-menu>
  298. </el-dropdown>
  299. </el-col>
  300. </el-row>
  301. <el-row :gutter="10" class="mb8">
  302. <right-toolbar
  303. ref="rightToolbar"
  304. :show-search.sync="showSearch"
  305. :columns="columnsList"
  306. @queryTable="getList"
  307. >
  308. <el-button
  309. type="primary"
  310. size="small"
  311. :loading="saveLoading"
  312. @click="saveColumnsList"
  313. >保存</el-button
  314. >
  315. </right-toolbar>
  316. </el-row>
  317. <el-table
  318. id="table_excel"
  319. ref="table"
  320. v-loading="loading"
  321. :data="list"
  322. :stripe="true"
  323. :show-overflow-tooltip="true"
  324. :summary-method="getSummaries"
  325. show-summary
  326. border
  327. @header-dragend="handleResize"
  328. >
  329. <el-table-column type="selection" width="50" fixed="left" />
  330. <el-table-column type="index" width="50" align="center" />
  331. <template v-for="(item, i) in queryData">
  332. <el-table-column
  333. v-if="item.ifHide === false"
  334. :key="i"
  335. :label="item.columnComment"
  336. align="center"
  337. :prop="item.columnComment"
  338. :show-overflow-tooltip="true"
  339. :width="item.javaField || ''"
  340. :sortable="item.ifSort"
  341. >
  342. <template #default="{ row }">
  343. <div
  344. :class="{ active: item.example }"
  345. @click="
  346. pathChange(item.example, row[item.columnComment], item, row)
  347. "
  348. >
  349. <dict-tag
  350. v-if="isDict(item.columnComment)"
  351. :type="isDict(item.columnComment)"
  352. :value="row[item.columnComment]"
  353. />
  354. <span v-else-if="isDateTime(item.columnComment)">{{
  355. parseData(row[item.columnComment])
  356. }}</span>
  357. <span v-else>{{ row[item.columnComment] }}</span>
  358. </div>
  359. </template>
  360. </el-table-column></template
  361. >
  362. </el-table>
  363. <!-- 分页组件 -->
  364. <pagination
  365. v-show="total > 0"
  366. :total="total"
  367. :page.sync="pageNo"
  368. :limit.sync="pageSize"
  369. @pagination="handleSearch"
  370. />
  371. </div>
  372. </template>
  373. <script>
  374. import * as QueryManageApi from "@/api/mes/queryManage";
  375. export default {
  376. name: "MocsQueryForm",
  377. components: {
  378. SearchBar: () => import("@/components/SearchBar"),
  379. },
  380. data() {
  381. return {
  382. // 显示搜索条件
  383. showSearch: true,
  384. // 显隐列参数
  385. columnsList: [],
  386. // 保存加载层
  387. saveLoading: false,
  388. exportLoading: false,
  389. title: "",
  390. visible: false,
  391. // 所有的查询/产看条件
  392. queryData: [],
  393. // 所有的查询条件
  394. searchData: [],
  395. // 已添加的查询条件
  396. queryList: [],
  397. // 设置查询条件弹框中的数据
  398. querySetList: [],
  399. // 设置查询条件弹框中添加查询条件的值
  400. querySettingKey: "",
  401. // 遮罩层
  402. loading: true,
  403. // 总条数
  404. total: 0,
  405. // 物料及产品列表列表
  406. list: [],
  407. // 查询参数
  408. pageNo: 1,
  409. pageSize: 20,
  410. sql: "",
  411. queryParams: {},
  412. headerWidthChange: false,
  413. dropdownList: [],
  414. dataSourceConfigId: null,
  415. };
  416. },
  417. watch: {
  418. $route: function (to, from) {
  419. // 获取显隐列列表
  420. this.id = this.$route.query?.id;
  421. this.getQueryData();
  422. QueryManageApi.queryManageExecutecomplexdropdownlist().then((res) => {
  423. this.dropdownList = res;
  424. });
  425. },
  426. visible(nVal) {
  427. if (nVal) {
  428. this.querySetList = JSON.parse(JSON.stringify([...this.queryList]));
  429. }
  430. },
  431. },
  432. created() {
  433. // 获取显隐列列表
  434. this.id = this.$route.query?.id;
  435. this.getQueryData();
  436. // 昱懋的,应该用不上
  437. /* QueryManageApi.queryManageExecutecomplexdropdownlist().then((res) => {
  438. this.dropdownList = res;
  439. });*/
  440. },
  441. beforeDestroy() {
  442. if (this.headerWidthChange) {
  443. this.headerWidthChange = false;
  444. const widthList = [];
  445. const headers = this.$refs.table.$el.querySelectorAll(
  446. ".el-table__header-wrapper tr th"
  447. );
  448. const queryData = this.queryData.filter((item) => {
  449. return !item.ifHide;
  450. });
  451. // console.log(queryData);
  452. headers.forEach((header, i) => {
  453. const width = header.offsetWidth;
  454. if (i !== 0 && headers.length - 1 !== i) {
  455. widthList.push({ id: queryData[i - 1].id, javaField: width });
  456. }
  457. });
  458. // console.log(widthList);
  459. QueryManageApi.updateWidth(widthList);
  460. }
  461. },
  462. methods: {
  463. // 小数点问题处理
  464. getHandleNumber(val) {
  465. return Math.round(parseFloat(val) * 100000000) / 100000000;
  466. },
  467. // 数量合计
  468. getSummaries(param) {
  469. const { columns, data } = param;
  470. const sums = [];
  471. columns.forEach((column, index) => {
  472. if (index === 0) {
  473. sums[index] = "总计";
  474. return;
  475. }
  476. const values = this.list.map((item) => Number(item[column.property]));
  477. // console.log(column,values);
  478. if (this.isNumber(column.property)) {
  479. sums[index] = values.reduce((acc, cur) => {
  480. const value = Number(cur);
  481. if (!isNaN(value)) {
  482. return this.getHandleNumber(acc + cur);
  483. } else {
  484. return acc;
  485. }
  486. }, 0);
  487. sums[index];
  488. }
  489. });
  490. return sums;
  491. },
  492. saveColumnsList(e) {
  493. this.saveLoading = true;
  494. const list = this.columnsList.map((item) => {
  495. const { id, visible } = item;
  496. return { id, ifHide: !visible };
  497. });
  498. QueryManageApi.updateWidth(list)
  499. .then(() => {
  500. this.$refs.rightToolbar.open = false;
  501. this.getQueryData();
  502. })
  503. .finally(() => {
  504. this.saveLoading = false;
  505. });
  506. },
  507. async getQueryList() {
  508. try {
  509. this.loading = true;
  510. // const res = await SaleOrderApi.getSaleOrderPage(this.queryParams);
  511. // this.list = res.data.list;
  512. // this.total = res.data.total;
  513. } finally {
  514. this.loading = false;
  515. }
  516. },
  517. handleResize() {
  518. this.headerWidthChange = true;
  519. },
  520. pathChange(path, val, item, row) {
  521. // console.log(path);
  522. if (path) {
  523. console.log(val, item, row);
  524. let url = `${path}`;
  525. if (item) {
  526. url =
  527. url +
  528. "&columnComment=" +
  529. item.columnComment +
  530. "&value=" +
  531. row[item.columnComment];
  532. }
  533. this.$router.push({ path: url });
  534. }
  535. },
  536. // 批量操作
  537. async batchCommand(url) {
  538. const list = this.$refs.table.selection;
  539. if (list.length === 0) {
  540. return this.$message.warning(`请选择需要批量操作的订单!`);
  541. }
  542. try {
  543. await this.$modal.confirm(`您正在进行批量操作,请确认是否继续?`);
  544. const baseUrl = url.replace("/admin-api", ""); // 去掉 /admin-api
  545. await QueryManageApi.batchApi(baseUrl, list);
  546. this.$message.success(`批量操作成功`);
  547. } catch {
  548. } finally {
  549. this.handleQuery();
  550. }
  551. },
  552. Export() {
  553. this.$confirm("确定要导出文件到Excel?", "导出提示", {
  554. confirmButtonText: "确定",
  555. cancelButtonText: "取消",
  556. type: "info",
  557. }).then(() => {
  558. setTimeout(() => {
  559. var xlsxParam = { raw: true }; // 导出的内容只做解析,不进行格式转换
  560. const tables = document.getElementById("table_excel"); // 这里是绑定元素,输入你要导出的table表格的id
  561. const table_book = this.$XLSX.utils.table_to_book(tables, xlsxParam);
  562. const table_write = this.$XLSX.write(table_book, {
  563. bookType: "xlsx",
  564. bookSST: true,
  565. type: "array",
  566. });
  567. try {
  568. this.$FileSaver.saveAs(
  569. new Blob([table_write], { type: "application/octet-stream" }),
  570. `${this.title}.xlsx` // 这里是文件名
  571. );
  572. } catch (e) {
  573. if (typeof console !== "undefined") {
  574. // console.log(e, table_write);
  575. }
  576. }
  577. return table_write;
  578. }, 1000);
  579. });
  580. },
  581. async ExportAll() {
  582. await this.$modal.confirm("是否确认导出所有查询数据项?");
  583. try {
  584. const list = [];
  585. const paramList = this.queryList.forEach((item) => {
  586. let { key, operate, value } = item;
  587. value = (value || "").toString();
  588. if (item.dataType === "ym_date_query_type") {
  589. operate = "between";
  590. }
  591. list.push({ key, operate, value });
  592. });
  593. // return
  594. this.exportLoading = true;
  595. const res = await QueryManageApi.exportExcel({
  596. id: this.id,
  597. paramList: list,
  598. });
  599. this.$download.excel(res, this.title);
  600. } catch {
  601. } finally {
  602. this.exportLoading = false;
  603. }
  604. },
  605. // 确定修改查询条件
  606. queryDataSetOk() {
  607. this.queryList = JSON.parse(JSON.stringify([...this.querySetList]));
  608. this.visible = false;
  609. },
  610. // 查询条件下拉修改
  611. queryKeyChange(e, i, type) {
  612. const { dataType, htmlType, dictType } = this.searchData.find(
  613. (item) => item.columnName === e
  614. );
  615. if (type === "query") {
  616. this.queryList[i].dataType = dataType;
  617. this.queryList[i].htmlType = htmlType;
  618. this.queryList[i].dictType = dictType;
  619. this.queryList[i].operate =
  620. dataType == "ym_string_query_type" ? "like" : "";
  621. }
  622. if (type === "querySet") {
  623. this.querySetList[i].dataType = dataType;
  624. this.querySetList[i].htmlType = htmlType;
  625. this.querySetList[i].dictType = dictType;
  626. this.querySetList[i].operate =
  627. dataType == "ym_string_query_type" ? "like" : "";
  628. }
  629. // console.log(dataType, htmlType, dictType);
  630. },
  631. // 判断table中的数据是否为字典数据
  632. isDict: function (key) {
  633. let isDict = false;
  634. this.queryData.some((item) => {
  635. if (item.columnComment == key) {
  636. if (item.dictType) {
  637. isDict = item.dictType;
  638. }
  639. return true;
  640. }
  641. return false;
  642. });
  643. return isDict;
  644. },
  645. // 判断table中的数据字段类型是否为数值 ym_int_query_type
  646. isNumber: function (key) {
  647. let isNum = false;
  648. this.queryData.some((item) => {
  649. if (item.columnComment == key) {
  650. if (item.dataType === "ym_int_query_type") {
  651. isNum = true;
  652. }
  653. return true;
  654. }
  655. return false;
  656. });
  657. return isNum;
  658. },
  659. // 判断table中的数据是否为时间
  660. isDateTime: function (key) {
  661. let isDateTime = false;
  662. this.queryData.some((item) => {
  663. if (item.columnComment == key) {
  664. if (item.javaType === "LocalDateTime") {
  665. isDateTime = true;
  666. }
  667. return true;
  668. }
  669. return false;
  670. });
  671. return isDateTime;
  672. },
  673. parseData(val) {
  674. if (!val) {
  675. return "";
  676. }
  677. var date = new Date(val); // 时间戳转换成Date对象
  678. return date.toISOString().slice(0, 10); // 格式化为YYYY-MM-DD
  679. },
  680. // 设置查询条件 删除
  681. delQueryItem(i) {
  682. this.querySetList.splice(i, 1);
  683. },
  684. // 设置查询条件修改查询条件下拉 添加
  685. querySettingKeyChange(e) {
  686. if (this.querySetList.length === this.searchData.length) {
  687. return;
  688. }
  689. const { dataType, htmlType, dictType } = this.searchData.find(
  690. (item) => item.columnName === e
  691. );
  692. this.querySettingKey = "";
  693. this.querySetList.push({
  694. dataType,
  695. htmlType,
  696. dictType,
  697. key: e,
  698. });
  699. },
  700. /** 获取查询列表 */
  701. async getQueryData() {
  702. this.loading = true;
  703. // 执行查询
  704. const res = await QueryManageApi.getQueryManageColumnListByMasterId(
  705. this.id
  706. );
  707. // console.log(res.data,'==========');
  708. this.queryData = res.data;
  709. this.columnsList = res.data.map((item, i) => {
  710. const { columnComment, id, ifHide } = item;
  711. return { key: i, label: columnComment, id, visible: !ifHide };
  712. });
  713. this.searchData = res.data.filter((item) => {
  714. return item.listOperationResult && item.ifHide === false;
  715. });
  716. // console.log(this.searchData);
  717. this.queryList = [];
  718. for (let i = 0; i < 2; i++) {
  719. if (!this.searchData[i]) {
  720. break;
  721. }
  722. const { dataType, htmlType, dictType, columnName } = this.searchData[i];
  723. this.queryList.push({
  724. dataType,
  725. htmlType,
  726. dictType,
  727. key: columnName,
  728. operate: dataType == "ym_string_query_type" ? "like" : "",
  729. });
  730. }
  731. if (this.$route.query?.columnComment) {
  732. let key = "";
  733. this.searchData.filter((v) => {
  734. if (v.columnComment === this.$route.query?.columnComment) {
  735. key = v.columnName;
  736. }
  737. });
  738. if (key) {
  739. this.queryList.push({
  740. key: key,
  741. operate: "=",
  742. value: this.$route.query?.value,
  743. });
  744. }
  745. }
  746. const res1 = await QueryManageApi.getQueryManage(this.id);
  747. this.title = res1.data.name;
  748. this.sql = res1.data.sqlStatement;
  749. this.dataSourceConfigId = res1.data?.dataSourceConfigId;
  750. this.getList();
  751. this.loading = false;
  752. },
  753. getList() {
  754. this.loading = true;
  755. const paramList = this.queryList.map((item) => {
  756. let { key, operate, value } = item;
  757. value = (value || "").toString();
  758. if (item.dataType === "ym_date_query_type") {
  759. operate = "between";
  760. }
  761. return { key, operate, value };
  762. });
  763. QueryManageApi.loadTableData({
  764. // sql: this.sql,
  765. id: this.id,
  766. pageNo: this.pageNo,
  767. pageSize: this.pageSize,
  768. paramList,
  769. dataSourceConfigId: this.dataSourceConfigId,
  770. })
  771. .then((res) => {
  772. this.list = res.data.list;
  773. this.total = res.data.total;
  774. })
  775. .finally(() => {
  776. this.loading = false;
  777. });
  778. },
  779. handleSearch() {
  780. this.list = [];
  781. this.getList();
  782. },
  783. /** 搜索按钮操作 */
  784. handleQuery() {
  785. this.pageNo = 1;
  786. this.getList();
  787. },
  788. /** 重置按钮操作 */
  789. resetQuery() {
  790. this.queryList.forEach((item, i) => {
  791. // this.queryList[i].value = null;
  792. this.$set(this.queryList[i], "value", null);
  793. });
  794. this.handleQuery();
  795. },
  796. },
  797. };
  798. </script>
  799. <style lang="scss" scoped>
  800. .mb8 {
  801. margin-bottom: 0;
  802. }
  803. .app-container {
  804. margin: 8px;
  805. padding: 0;
  806. // height: calc(100vh - 100px);
  807. padding-bottom: 20px;
  808. }
  809. ::v-deep .el-form-item {
  810. margin-bottom: 0px !important;
  811. }
  812. ::v-deep .el-tabs__item {
  813. height: 30px !important;
  814. line-height: 30px !important;
  815. padding: 0 15px !important;
  816. }
  817. ::v-deep .el-tabs--border-card > .el-tabs__content {
  818. padding: 2px !important;
  819. }
  820. ::v-deep .pagination-container {
  821. margin: 0;
  822. padding: 0;
  823. }
  824. .active {
  825. color: #1890ff !important;
  826. }
  827. .active:hover {
  828. cursor: pointer;
  829. }
  830. </style>