index.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <template>
  2. <div class="global-variable" v-loading="loading">
  3. <div class="condition">
  4. <el-form
  5. ref="ruleForm"
  6. :inline="true"
  7. :model="formInline"
  8. class="demo-form-inline"
  9. >
  10. <el-form-item label="批次名称:" prop="batchName">
  11. <el-input
  12. v-model="formInline.batchName"
  13. placeholder="请输入批次名称"
  14. size="small"
  15. ></el-input>
  16. </el-form-item>
  17. <el-form-item label="状态:" prop="transferState">
  18. <el-select
  19. v-model="formInline.transferState"
  20. placeholder="请选择状态"
  21. size="small "
  22. >
  23. <el-option
  24. v-for="item in stateDataList"
  25. :key="item.value"
  26. :label="item.lable"
  27. :value="item.value"
  28. ></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" @click="onSubmit" size="small"
  33. >查询</el-button
  34. >
  35. <el-button @click="reset('ruleForm')" size="small">重置</el-button>
  36. </el-form-item>
  37. </el-form>
  38. </div>
  39. <div class="list-page">
  40. <div class="newly">
  41. <el-button type="primary" @click="addData" size="small">新增</el-button>
  42. </div>
  43. <el-table
  44. class="center-align-table"
  45. :data="tableData"
  46. border
  47. :cell-style="rowStyle"
  48. stripe
  49. style="width: 100%"
  50. >
  51. <!-- Table Columns -->
  52. <el-table-column
  53. fixed
  54. prop="batchName"
  55. align="center"
  56. label="批次名称"
  57. min-width="200"
  58. >
  59. </el-table-column>
  60. <el-table-column
  61. prop="fieldName"
  62. align="center"
  63. label="风场名称"
  64. min-width="200"
  65. >
  66. </el-table-column>
  67. <el-table-column
  68. prop="engineCount"
  69. align="center"
  70. label="机组数量"
  71. min-width="100"
  72. >
  73. </el-table-column>
  74. <el-table-column
  75. prop="transferTypeName"
  76. align="center"
  77. label="类型"
  78. min-width="200"
  79. >
  80. </el-table-column>
  81. <el-table-column
  82. prop="transferProgress"
  83. align="center"
  84. label="进度"
  85. min-width="200"
  86. >
  87. <template slot-scope="scope">
  88. <el-progress
  89. v-if="scope.row.transferState == 0"
  90. :indeterminate="true"
  91. :stroke-width="20"
  92. :percentage="scope.row.transferProgress"
  93. class="animated-progress"
  94. ></el-progress>
  95. <span v-else>/</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="" align="center" label="状态" min-width="100">
  99. <template slot-scope="scope">
  100. <span v-if="scope.row.transferState == -1">未转换</span>
  101. <span v-else-if="scope.row.transferState == 0" style="color: #f90"
  102. >转换中</span
  103. >
  104. <span
  105. v-else-if="scope.row.transferState == 1"
  106. style="color: #4caf50"
  107. >转换成功</span
  108. >
  109. <span v-else-if="scope.row.transferState == 2" style="color: #f00"
  110. >转换失败</span
  111. >
  112. <span v-else>/</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. prop=""
  117. align="center"
  118. label="异常状态"
  119. min-width="100"
  120. >
  121. <template slot-scope="scope">
  122. {{ scope.row.transferState == 2 ? "异常" : "未异常" }}
  123. </template>
  124. </el-table-column>
  125. <el-table-column
  126. prop="abnormal"
  127. label="异常信息"
  128. min-width="100"
  129. align="center"
  130. >
  131. <template slot-scope="scope">
  132. <el-button
  133. v-if="scope.row.transferState == 2"
  134. @click="particulars(scope.row)"
  135. type="text"
  136. size="small"
  137. >详情</el-button
  138. >
  139. <span v-else>/</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. prop="transferFinishTime"
  144. align="center"
  145. label="转换时间"
  146. min-width="230"
  147. >
  148. </el-table-column>
  149. <el-table-column
  150. prop="transition"
  151. align="center"
  152. fixed="right"
  153. label="操作"
  154. min-width="150"
  155. >
  156. <template slot-scope="scope">
  157. <el-button
  158. v-if="
  159. scope.row.transferState !== -1 &&
  160. (scope.row.transferAddr !== null ||
  161. scope.row.transferAddr !== '')
  162. "
  163. @click="handleEdit(scope.row)"
  164. type="text"
  165. size="small"
  166. >编辑</el-button
  167. >
  168. <el-button
  169. @click="handleClick(scope.row.downloadUrl)"
  170. type="text"
  171. size="small"
  172. >下载</el-button
  173. >
  174. <el-button
  175. v-if="
  176. scope.row.transferState == -1 &&
  177. (scope.row.transferAddr === null ||
  178. scope.row.transferAddr === '')
  179. "
  180. @click="editTransferState(scope.row, '转换')"
  181. type="text"
  182. size="small"
  183. >转换</el-button
  184. >
  185. <el-button
  186. v-else
  187. @click="editTransferState(scope.row, '重新转换')"
  188. type="text"
  189. size="small"
  190. :disabled="scope.row.transferState == 0"
  191. >重新转换</el-button
  192. >
  193. </template>
  194. </el-table-column>
  195. </el-table>
  196. <div class="pagination-container">
  197. <el-pagination
  198. @current-change="handleCurrentChange"
  199. :current-page.sync="formInline.pageNum"
  200. layout="total, prev, pager, next"
  201. :page-size="formInline.pageSize"
  202. :total="formInline.totalSize"
  203. >
  204. </el-pagination>
  205. </div>
  206. </div>
  207. <!-- 弹出层 -->
  208. <!-- 新增 -->
  209. <el-dialog
  210. title="新增(批次列表为空时,请前往性能分析下批次管理中添加批次!)"
  211. :visible.sync="nuedialog"
  212. class="dialogBox"
  213. width="900px"
  214. :before-close="handleCloses"
  215. >
  216. <div v-loading="loadingView" class="views">
  217. <el-form ref="form" :model="newform" label-width="150px">
  218. <el-row>
  219. <el-form-item
  220. label="批次名称:"
  221. prop="batchCode"
  222. :rules="batchCodeRules"
  223. >
  224. <el-select
  225. filterable
  226. v-model="newform.batchCode"
  227. placeholder="请选择批次名称"
  228. size="small"
  229. >
  230. <el-option
  231. v-for="item in batchList"
  232. :key="item.batchCode"
  233. :label="item.batchName"
  234. :value="item.batchCode"
  235. ></el-option>
  236. </el-select>
  237. </el-form-item>
  238. </el-row>
  239. <el-row
  240. v-for="(item, index) in newform.dataTransferTypePathDtoList"
  241. :key="item.transferType"
  242. >
  243. <el-col :span="11">
  244. <el-form-item
  245. :label="item.transferTypeName + ':'"
  246. :prop="'transferAddr_' + index"
  247. :rules="getFileAddrRules(index)"
  248. >
  249. <el-input
  250. :min="1"
  251. v-model="item.transferAddr"
  252. :placeholder="'请输入' + item.transferTypeName"
  253. size="small"
  254. @change="ensureMinValue(item, 'transferAddr')"
  255. ></el-input>
  256. </el-form-item>
  257. </el-col>
  258. <el-col :span="13">
  259. <el-form-item
  260. :label="item.timeGranularityName + ':'"
  261. :prop="'timeGranularity_' + index"
  262. :rules="getTimeGranularityRules(index)"
  263. >
  264. <el-input
  265. type="number"
  266. :min="1"
  267. v-model="item.timeGranularity"
  268. :placeholder="'请输入' + item.timeGranularityName"
  269. size="small"
  270. @input="ensureMinValue(item, 'timeGranularity')"
  271. >
  272. <template slot="append">秒</template></el-input
  273. >
  274. </el-form-item>
  275. </el-col>
  276. </el-row>
  277. </el-form>
  278. <span slot="footer" class="dialog-footer">
  279. <el-button @click="cancel('form')" size="small">取 消</el-button>
  280. <el-button type="primary" @click="newly('form')" size="small"
  281. >确 定</el-button
  282. >
  283. </span>
  284. </div>
  285. </el-dialog>
  286. <!-- 编辑 -->
  287. <el-dialog
  288. title="编辑"
  289. :visible.sync="editNuedialog"
  290. class="dialogBox"
  291. width="900px"
  292. :before-close="handleCloses"
  293. >
  294. <div v-loading="loadingViewEdit" class="views">
  295. <el-form
  296. ref="editForm"
  297. :model="newEditForm"
  298. label-width="160px"
  299. :rules="editRules"
  300. >
  301. <el-row>
  302. <el-form-item label="批次名称:" prop="batchCode">
  303. <el-select
  304. v-model="newEditForm.batchName"
  305. placeholder="请选择批次名称"
  306. size="small"
  307. disabled
  308. >
  309. <el-option
  310. v-for="item in batchList"
  311. :key="item.batchCode"
  312. :label="item.batchName"
  313. :value="item.batchCode"
  314. ></el-option>
  315. </el-select>
  316. </el-form-item>
  317. </el-row>
  318. <el-row>
  319. <el-col :span="11">
  320. <el-form-item prop="dataTransferTypePathDtoList.0.transferAddr">
  321. <span slot="label">
  322. <el-tooltip
  323. content="路径输入例如:/XX/XX/XX路径"
  324. placement="bottom-start"
  325. >
  326. <i class="el-icon-question"></i>
  327. </el-tooltip>
  328. {{
  329. newEditForm.dataTransferTypePathDtoList[0]
  330. .transferTypeName + ":"
  331. }}
  332. </span>
  333. <!-- :rules="{
  334. required: true,
  335. message:
  336. '请输入' +
  337. newEditForm.dataTransferTypePathDtoList[0].transferTypeName,
  338. trigger: 'blur',
  339. }" -->
  340. <el-input
  341. disabled
  342. v-model="
  343. newEditForm.dataTransferTypePathDtoList[0].transferAddr
  344. "
  345. :placeholder="
  346. '请输入' +
  347. newEditForm.dataTransferTypePathDtoList[0].transferTypeName
  348. "
  349. size="small"
  350. >
  351. </el-input>
  352. </el-form-item>
  353. </el-col>
  354. <el-col :span="13">
  355. <el-form-item
  356. :label="
  357. newEditForm.dataTransferTypePathDtoList[0]
  358. .timeGranularityName + ':'
  359. "
  360. prop="dataTransferTypePathDtoList.0.timeGranularity"
  361. :rules="{
  362. required: true,
  363. message:
  364. '请输入' +
  365. newEditForm.dataTransferTypePathDtoList[0]
  366. .timeGranularityName,
  367. trigger: 'blur',
  368. }"
  369. >
  370. <el-input
  371. type="number"
  372. :min="1"
  373. v-model="
  374. newEditForm.dataTransferTypePathDtoList[0].timeGranularity
  375. "
  376. :placeholder="
  377. '请输入' +
  378. newEditForm.dataTransferTypePathDtoList[0]
  379. .timeGranularityName
  380. "
  381. size="small"
  382. >
  383. <template slot="append">秒</template></el-input
  384. >
  385. </el-form-item>
  386. </el-col>
  387. </el-row>
  388. <el-row> </el-row>
  389. </el-form>
  390. <span slot="footer" class="dialog-footer">
  391. <el-button @click="editCancel('editForm')" size="small"
  392. >取 消</el-button
  393. >
  394. <el-button type="primary" @click="editly('editForm')" size="small"
  395. >确 定</el-button
  396. >
  397. </span>
  398. </div>
  399. </el-dialog>
  400. <!-- 异常信息详情 -->
  401. <el-dialog
  402. title="异常详情"
  403. :visible.sync="unusualdialog"
  404. width="800px"
  405. :before-close="handleCloses"
  406. >
  407. {{ errInfo }}
  408. </el-dialog>
  409. <!-- 转换\重新转换 -->
  410. <el-dialog
  411. :title="editTransferStateTitle"
  412. :visible.sync="editTransferStateLoading"
  413. width="900px"
  414. :before-close="handleCloses"
  415. >
  416. <div v-loading="loadingViewEdit" class="views">
  417. <el-form
  418. ref="editStateForm"
  419. :model="editTransferStateForm"
  420. label-width="160px"
  421. >
  422. <el-row>
  423. <el-form-item label="批次名称:" prop="batchCode">
  424. <el-select
  425. v-model="editTransferStateForm.batchName"
  426. placeholder="请选择批次名称"
  427. size="small"
  428. disabled
  429. >
  430. <el-option
  431. v-for="item in batchList"
  432. :key="item.batchCode"
  433. :label="item.batchName"
  434. :value="item.batchCode"
  435. ></el-option>
  436. </el-select>
  437. </el-form-item>
  438. </el-row>
  439. <el-row>
  440. <el-col :span="12">
  441. <el-form-item
  442. prop="dataTransferTypePath"
  443. :rules="{
  444. required: true,
  445. message: `请输入${editTransferStateForm.transferTypeName}`,
  446. trigger: 'blur',
  447. }"
  448. >
  449. <span slot="label">
  450. <el-tooltip
  451. content="路径输入例如:/XX/XX/XX路径"
  452. placement="bottom-start"
  453. >
  454. <i class="el-icon-question"></i>
  455. </el-tooltip>
  456. {{ editTransferStateForm.transferTypeName + ":" }}
  457. </span>
  458. <el-input
  459. v-model="editTransferStateForm.dataTransferTypePath"
  460. :placeholder="'请输入数据转换路径'"
  461. size="small"
  462. ></el-input>
  463. </el-form-item>
  464. </el-col>
  465. <el-col :span="12">
  466. <el-form-item
  467. label="时间粒度"
  468. prop="timeGranularity"
  469. :rules="{
  470. required: true,
  471. message: '请输入时间粒度',
  472. trigger: 'blur',
  473. }"
  474. >
  475. <el-input
  476. type="number"
  477. :min="1"
  478. v-model="editTransferStateForm.timeGranularity"
  479. placeholder="
  480. 请输入时间粒度
  481. "
  482. size="small"
  483. >
  484. <template slot="append">秒</template></el-input
  485. >
  486. </el-form-item>
  487. </el-col>
  488. </el-row>
  489. </el-form>
  490. <span slot="footer" class="dialog-footer">
  491. <el-button @click="editstateCancel('editStateForm')" size="small"
  492. >取 消</el-button
  493. >
  494. <el-button
  495. type="primary"
  496. @click="editStately('editStateForm')"
  497. size="small"
  498. >确 定</el-button
  499. >
  500. </span>
  501. </div>
  502. </el-dialog>
  503. </div>
  504. </template>
  505. <script>
  506. import {
  507. queryDataTransferList,
  508. fieldBatchListForDataTransfer,
  509. addDataTransferList,
  510. editTimeGranularityQuery,
  511. dataTransfer,
  512. } from "@/api/dataManage";
  513. import axios from "axios";
  514. export default {
  515. data() {
  516. return {
  517. intervalId: null,
  518. startTime: null,
  519. maxPollingTime: 5 * 60 * 1000, //轮询最大时间
  520. loading: false,
  521. editTransferStateForm: {
  522. transferAddr: "",
  523. dataTransferTypePath: "",
  524. batchName: "",
  525. batchCode: "",
  526. timeGranularity: "",
  527. },
  528. editTransferStateTitle: "",
  529. editTransferStateLoading: false,
  530. loadingView: false,
  531. formInline: {
  532. batchName: "",
  533. transferState: "",
  534. pageNum: 1,
  535. pageSize: 10,
  536. totalSize: 0,
  537. },
  538. batchCodeRules: [
  539. {
  540. required: true,
  541. message: "批次编号不能为空",
  542. trigger: ["change", "blur"],
  543. },
  544. ],
  545. editRules: {
  546. batchCode: {
  547. required: true,
  548. message: "批次编号不能为空",
  549. trigger: ["change", "blur"],
  550. },
  551. },
  552. rules: {
  553. batchCode: {
  554. required: true,
  555. message: "批次编号不能为空",
  556. trigger: "change",
  557. },
  558. },
  559. errInfo: "",
  560. stateDataList: [
  561. {
  562. lable: "未转换",
  563. value: -1,
  564. },
  565. {
  566. lable: "转换中",
  567. value: 0,
  568. },
  569. {
  570. lable: "转换成功",
  571. value: 1,
  572. },
  573. {
  574. lable: "转换失败",
  575. value: 2,
  576. },
  577. ],
  578. batchList: [],
  579. tableData: [],
  580. nuedialog: false,
  581. unusualdialog: false,
  582. newform: {
  583. batchCode: "",
  584. dataTransferTypePathDtoList: [],
  585. },
  586. editNuedialog: false,
  587. loadingViewEdit: false,
  588. newEditForm: {
  589. batchCode: "",
  590. batchName: "",
  591. dataTransferTypePathDtoList: [{}],
  592. },
  593. };
  594. },
  595. created() {
  596. this.getTableList();
  597. this.getBatchCodeList();
  598. },
  599. methods: {
  600. handleCloses(done) {
  601. this.$confirm("确认关闭?")
  602. .then((_) => {
  603. this.getBatchCodeList();
  604. done();
  605. })
  606. .catch((_) => {});
  607. },
  608. ensureMinValue(item, field) {
  609. if (item[field] < 1) {
  610. item[field] = 1;
  611. }
  612. },
  613. editstateCancel(formName) {
  614. this.$refs[formName] && this.$refs[formName].resetFields();
  615. this.editTransferStateForm = {
  616. transferAddr: "",
  617. dataTransferTypePath: "",
  618. batchName: "",
  619. batchCode: "",
  620. timeGranularity: "",
  621. transferType: "",
  622. transferTypeName: "",
  623. timeGranularityName: "",
  624. };
  625. this.editTransferStateLoading = false;
  626. this.loadingViewEdit = false;
  627. this.getBatchCodeList();
  628. },
  629. editStately(formName) {
  630. this.$refs[formName].validate((valid) => {
  631. if (valid) {
  632. this.loadingViewEdit = true;
  633. dataTransfer({
  634. dataTransferAddr: this.editTransferStateForm.dataTransferTypePath,
  635. dataTransferType: this.editTransferStateForm.transferType,
  636. batchCode: this.editTransferStateForm.batchCode,
  637. timeGranularity: this.editTransferStateForm.timeGranularity,
  638. })
  639. .then((res) => {
  640. this.$message({
  641. message: "操作成功",
  642. type: "success",
  643. });
  644. this.getTableList();
  645. this.editstateCancel();
  646. })
  647. .catch((error) => {
  648. this.loadingViewEdit = false;
  649. });
  650. } else {
  651. return false;
  652. }
  653. });
  654. },
  655. //转换\重新转换
  656. editTransferState(row, title) {
  657. console.log(row, "row");
  658. this.editTransferStateForm.timeGranularity = row.timeGranularity;
  659. this.editTransferStateForm.dataTransferTypePath = row.transferAddr
  660. ? row.transferAddr
  661. : "";
  662. this.editTransferStateForm.batchCode = row.batchCode;
  663. this.editTransferStateForm.batchName = row.batchName;
  664. this.editTransferStateForm.transferType = row.transferType;
  665. this.editTransferStateForm.transferTypeName = row.transferTypeName;
  666. this.editTransferStateForm.timeGranularityName = row.timeGranularityName;
  667. this.editTransferStateTitle = title;
  668. this.editTransferStateLoading = true;
  669. },
  670. handleEdit(row) {
  671. this.editNuedialog = true;
  672. this.newEditForm.batchCode = row.batchCode;
  673. this.newEditForm.batchName = row.batchName;
  674. this.newEditForm.dataTransferTypePathDtoList[0] = { ...row };
  675. console.log(this.newEditForm.dataTransferTypePathDtoList[0], "编辑");
  676. },
  677. editCancel() {
  678. this.newform = {
  679. batchCode: "",
  680. dataTransferTypePathDtoList: [{}],
  681. };
  682. this.editNuedialog = false;
  683. this.loadingViewEdit = false;
  684. this.getTableList();
  685. this.getBatchCodeList();
  686. },
  687. editly(formName) {
  688. this.$refs[formName].validate((valid) => {
  689. if (valid) {
  690. this.loadingViewEdit = true;
  691. editTimeGranularityQuery({
  692. timeGranularity:
  693. this.newEditForm.dataTransferTypePathDtoList[0].timeGranularity,
  694. dataTransferType:
  695. this.newEditForm.dataTransferTypePathDtoList[0].transferType,
  696. batchCode: this.newEditForm.batchCode,
  697. })
  698. .then((res) => {
  699. this.$message({
  700. message: "编辑成功",
  701. type: "success",
  702. });
  703. this.editCancel();
  704. })
  705. .catch((error) => {
  706. console.log("shibai", error);
  707. this.loadingViewEdit = false;
  708. });
  709. } else {
  710. return false;
  711. }
  712. });
  713. },
  714. getFileAddrRules(index) {
  715. return [{ validator: this.validateFileAddr, trigger: "blur" }];
  716. },
  717. getTimeGranularityRules(index) {
  718. return [
  719. {
  720. validator: (rule, value, callback) =>
  721. this.validateTimeGranularity(rule, value, callback, index),
  722. trigger: "blur",
  723. },
  724. ];
  725. },
  726. validateFileAddr(rule, value, callback) {
  727. // 判断是否至少有一项 transferAddr 有值
  728. const hasFileAddr = this.newform.dataTransferTypePathDtoList.some(
  729. (item) => item.transferAddr
  730. );
  731. if (!hasFileAddr) {
  732. callback(new Error("请至少填写一个数据路径"));
  733. } else {
  734. callback();
  735. }
  736. },
  737. validateTimeGranularity(rule, value, callback, index) {
  738. // 判断对应的 transferAddr 有值,则对应的 timeGranularity 也必须有值
  739. const currentItem = this.newform.dataTransferTypePathDtoList[index];
  740. if (currentItem.transferAddr && !currentItem.timeGranularity) {
  741. callback(new Error("请填写时间粒度"));
  742. } else {
  743. callback();
  744. }
  745. },
  746. cancel(formName) {
  747. this.$refs[formName] && this.$refs[formName].resetFields();
  748. this.newform = {
  749. batchCode: "",
  750. dataTransferTypePathDtoList: [],
  751. };
  752. this.getBatchCodeList();
  753. this.nuedialog = false;
  754. this.loadingView = false;
  755. },
  756. rowStyle() {
  757. return "text-align:center";
  758. },
  759. // 查询
  760. onSubmit() {
  761. this.getTableList();
  762. },
  763. // 重置
  764. reset(formName) {
  765. this.$refs[formName].resetFields();
  766. this.getTableList();
  767. },
  768. // 新增
  769. newly(formName) {
  770. this.$refs[formName].validate((valid) => {
  771. if (valid) {
  772. this.loadingView = true;
  773. addDataTransferList({ ...this.newform })
  774. .then((res) => {
  775. this.$message({
  776. message: "新增成功",
  777. type: "success",
  778. });
  779. this.getTableList();
  780. this.cancel();
  781. this.loadingView = false;
  782. })
  783. .catch(() => {
  784. this.loadingView = false;
  785. });
  786. } else {
  787. return false;
  788. }
  789. });
  790. },
  791. //异常详情
  792. particulars(row) {
  793. this.unusualdialog = true;
  794. this.errInfo = row.errInfo;
  795. },
  796. //下载
  797. async handleClick(downloadUrl) {
  798. let newWindow = window.open(downloadUrl, "_blank");
  799. if (
  800. !newWindow ||
  801. newWindow.closed ||
  802. typeof newWindow.closed == "undefined"
  803. ) {
  804. alert("弹出窗口已被阻止!请允许弹出式窗口访问本网站。");
  805. }
  806. },
  807. // async handleClick() {
  808. // try {
  809. // // 获取 HTML 内容
  810. // const response = await axios.get("/downLoadApi", {
  811. // responseType: "blob",
  812. // }); // 确保响应类型为 Blob
  813. // const reader = new FileReader();
  814. // reader.onload = function (event) {
  815. // const htmlContent = event.target.result; // 读取的 HTML 内容
  816. // const newWindow = window.open("", "_blank");
  817. // newWindow.document.open();
  818. // newWindow.document.write(htmlContent);
  819. // newWindow.document.close();
  820. // // 获取当前页面的 URL
  821. // const currentUrl = window.location.href;
  822. // const proxyUrl = currentUrl.substring(0, currentUrl.indexOf("/", 8)); // 从第8个字符开始搜索,找到第一个 "/" 为止
  823. // // 拼接代理地址和接口路径
  824. // const apiEndpoint = proxyUrl + "/downLoadApi";
  825. // // 拼接新的路径
  826. // const newUrl = apiEndpoint + "/downLoadApi";
  827. // // 设置 base 元素
  828. // const baseElement = newWindow.document.createElement("base");
  829. // baseElement.href = newUrl; // 使用代理地址和接口路径
  830. // newWindow.document.head.appendChild(baseElement);
  831. // };
  832. // reader.readAsText(response.data, "utf-8"); // 以 UTF-8 编码读取 Blob
  833. // } catch (error) {
  834. // console.error("Failed to fetch data:", error);
  835. // this.$message.error("无法打开新链接");
  836. // }
  837. // },
  838. async getTableList() {
  839. try {
  840. this.loading = true;
  841. const result = await queryDataTransferList({
  842. ...this.formInline,
  843. totalSize: undefined,
  844. });
  845. this.tableData = result.data.list;
  846. this.formInline.totalSize = result.data.totalSize;
  847. this.loading = false;
  848. } catch (error) {
  849. this.$message({
  850. type: "error",
  851. message: "请检查是否连接网络",
  852. });
  853. }
  854. },
  855. //分页数据切换
  856. handleCurrentChange(val) {
  857. this.formInline.pageNum = val;
  858. this.getTableList();
  859. },
  860. //新增按钮
  861. addData() {
  862. if (this.batchList === null || this.batchList.length === 0) {
  863. this.$confirm(
  864. "批次列表为空,请前往性能分析菜单下的批次管理中添加批次!确认跳转到批次管理菜单吗?",
  865. "提示",
  866. {
  867. confirmButtonText: "确定",
  868. cancelButtonText: "取消",
  869. type: "warning",
  870. }
  871. )
  872. .then(() => {
  873. this.$router.push("/home/performance/batchMag?id=22");
  874. this.$message({
  875. type: "success",
  876. message: "成功!",
  877. });
  878. })
  879. .catch(() => {
  880. this.$message({
  881. type: "info",
  882. message: "已取消",
  883. });
  884. });
  885. } else {
  886. this.nuedialog = true;
  887. }
  888. },
  889. //获取批次编号列表接口
  890. async getBatchCodeList() {
  891. this.loading = true;
  892. try {
  893. const result = await fieldBatchListForDataTransfer();
  894. this.batchList = result.data.batchCodeList;
  895. this.newform.dataTransferTypePathDtoList =
  896. result.data.dataTransferTypeVoList;
  897. this.loading = false;
  898. } catch (error) {
  899. this.loading = false;
  900. }
  901. },
  902. async fetchData() {
  903. try {
  904. const result = await queryDataTransferList({
  905. ...this.formInline,
  906. totalSize: undefined,
  907. });
  908. this.tableData = result.data.list;
  909. this.formInline.totalSize = result.data.totalSize;
  910. } catch (error) {
  911. this.$message({
  912. type: "error",
  913. message: "请检查是否连接网络",
  914. });
  915. }
  916. },
  917. stopPolling() {
  918. if (this.intervalId) {
  919. clearInterval(this.intervalId);
  920. this.intervalId = null;
  921. }
  922. },
  923. startPolling() {
  924. this.startTime = new Date().getTime();
  925. this.intervalId = setInterval(() => {
  926. const currentTime = new Date().getTime();
  927. if (currentTime - this.startTime >= this.maxPollingTime) {
  928. this.stopPolling();
  929. } else {
  930. this.fetchData();
  931. }
  932. }, 10000); // 每10秒调用一次
  933. },
  934. },
  935. mounted() {
  936. this.startPolling();
  937. },
  938. beforeDestroy() {
  939. this.stopPolling();
  940. },
  941. };
  942. </script>
  943. <style lang="scss" scoped>
  944. ::v-deep.dialogBox {
  945. .el-form-item__content .el-input--small .el-input__inner {
  946. width: 188px !important;
  947. }
  948. .el-row {
  949. margin: 5px 0;
  950. }
  951. .dialog-footer {
  952. margin-top: 20px;
  953. justify-content: center !important;
  954. }
  955. .el-input-group {
  956. width: auto;
  957. }
  958. }
  959. </style>
  960. <style scoped>
  961. @keyframes indeterminate {
  962. 0% {
  963. left: -100%;
  964. width: 100%;
  965. }
  966. 50% {
  967. left: 100%;
  968. width: 10%;
  969. }
  970. 100% {
  971. left: 100%;
  972. width: 100%;
  973. }
  974. }
  975. ::v-deep .el-progress__text {
  976. font-size: 14px !important;
  977. }
  978. .el-progress-bar__outer {
  979. position: relative;
  980. vertical-align: middle;
  981. }
  982. .el-progress-bar__inner {
  983. position: absolute;
  984. left: 0;
  985. top: 0;
  986. height: 100%;
  987. text-align: right;
  988. border-radius: 100px;
  989. line-height: 1;
  990. white-space: nowrap;
  991. transition: width 0.6s ease;
  992. }
  993. .animated-progress .el-progress-bar__inner {
  994. position: relative;
  995. transform: translateZ(0);
  996. animation: indeterminate 3s infinite;
  997. background-color: #409eff; /* 或者你想要的任何颜色 */
  998. }
  999. </style>