assetssMag.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="global-variable">
  3. <div class="condition">
  4. <el-form
  5. :inline="true"
  6. ref="ruleForm"
  7. :model="formInline"
  8. class="demo-form-inline"
  9. :rules="rules"
  10. >
  11. <el-form-item label="风场名称:" prop="fieldName">
  12. <el-input
  13. size="small"
  14. v-model="formInline.fieldName"
  15. placeholder="请输入风场名称"
  16. ></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="primary" @click="onSubmit" size="small"
  20. >查询</el-button
  21. >
  22. <el-button @click="reset('ruleForm')" size="small">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <div class="list-page">
  27. <el-table
  28. v-loading="loading"
  29. class="center-align-table"
  30. :data="tableData"
  31. border
  32. :cell-style="rowStyle"
  33. >
  34. <el-table-column
  35. align="center"
  36. fixed
  37. prop="fieldName"
  38. label="风场名称"
  39. min-width="200"
  40. >
  41. </el-table-column>
  42. <el-table-column
  43. align="center"
  44. label="批次名称"
  45. prop="batchName"
  46. min-width="200"
  47. >
  48. </el-table-column>
  49. <el-table-column
  50. prop="loginName"
  51. align="center"
  52. label="进度"
  53. min-width="150"
  54. >
  55. <template slot-scope="scope">
  56. <el-progress
  57. v-if="scope.row.analysisState == 20"
  58. :text-inside="true"
  59. :stroke-width="20"
  60. :percentage="scope.row.analysisProgress"
  61. :class="{
  62. 'indeterminate-progress': scope.row.analysisProgress < 100,
  63. 'animated-progress': true,
  64. }"
  65. ></el-progress>
  66. <span v-else>/</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. prop="loginName"
  71. align="center"
  72. label="分析状态"
  73. min-width="150"
  74. >
  75. <template slot-scope="scope">
  76. <span v-if="scope.row.analysisState == -1">未分析</span>
  77. <span
  78. v-else-if="
  79. scope.row.analysisState == 20 && scope.row.errState == 0
  80. "
  81. style="color: #f90"
  82. >分析中</span
  83. >
  84. <span v-else-if="scope.row.errState == 1" style="color: #f00"
  85. >分析异常</span
  86. >
  87. <span
  88. v-else-if="scope.row.analysisState == 30"
  89. style="color: #4caf50"
  90. >分析完成</span
  91. >
  92. <span
  93. v-else-if="scope.row.analysisState == 10"
  94. style="color: #4caf50"
  95. >排队中</span
  96. >
  97. <span v-else>/</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column
  101. prop="errState"
  102. align="center"
  103. label="异常状态"
  104. min-width="120"
  105. >
  106. <template slot-scope="scope">
  107. <span>
  108. {{
  109. scope.row.errState == 0 && scope.row.analysisState !== -1
  110. ? "未异常"
  111. : scope.row.errState === 1
  112. ? "异常"
  113. : "/"
  114. }}</span
  115. >
  116. </template>
  117. </el-table-column>
  118. <el-table-column
  119. prop="roleName"
  120. align="center"
  121. label="异常信息"
  122. min-width="120"
  123. >
  124. <template slot-scope="scope">
  125. <el-button
  126. v-if="scope.row.errState == 1"
  127. @click="abnormalDialog(scope.row, '异常详情')"
  128. type="text"
  129. size="small"
  130. >异常详情</el-button
  131. >
  132. <span v-else>/</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. prop="roleName"
  137. align="center"
  138. label="分析记录"
  139. min-width="120"
  140. >
  141. <template slot-scope="scope">
  142. <!-- 分析完成 -->
  143. <el-button
  144. v-if="scope.row.analysisState == 30 && scope.row.errState !== 1"
  145. @click="handleAssetssDetail(scope.row, '1')"
  146. type="text"
  147. size="small"
  148. >分析详情</el-button
  149. >
  150. <!-- 分析中 -->
  151. <el-button
  152. v-else-if="
  153. scope.row.analysisState == 20 && scope.row.errState == 0
  154. "
  155. @click="handleAssetssDetail(scope.row, '0')"
  156. type="text"
  157. size="small"
  158. >分析详情</el-button
  159. >
  160. <span v-else>/</span>
  161. </template>
  162. </el-table-column>
  163. <el-table-column
  164. prop="createTime"
  165. align="center"
  166. label="创建时间"
  167. min-width="230"
  168. >
  169. </el-table-column>
  170. <el-table-column
  171. prop="errState"
  172. align="center"
  173. label="报告"
  174. min-width="120"
  175. >
  176. <template slot-scope="scope">
  177. <span>
  178. {{
  179. scope.row.errState == 0 && scope.row.analysisState !== -1
  180. ? "查看报告"
  181. : "/"
  182. }}</span
  183. >
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. prop="transition"
  188. align="center"
  189. fixed="right"
  190. label="操作"
  191. min-width="220"
  192. >
  193. <template slot-scope="scope">
  194. <el-button
  195. @click="upLoadeAssetss(scope.row)"
  196. type="text"
  197. size="small"
  198. >上传报告</el-button
  199. >
  200. <el-button
  201. @click="handleAssetss(scope.row)"
  202. type="text"
  203. size="small"
  204. >分析</el-button
  205. >
  206. <el-button
  207. @click="abnormalDialog(scope.row, '异常描述')"
  208. type="text"
  209. size="small"
  210. >异常描述</el-button
  211. >
  212. <el-button
  213. @click="HandleOnOffAuto(scope.row)"
  214. type="text"
  215. size="small"
  216. >{{
  217. scope.row.onOffCall === 0 ? "开启自动分析" : "关闭自动分析"
  218. }}</el-button
  219. >
  220. </template>
  221. </el-table-column>
  222. </el-table>
  223. <div class="pagination-container">
  224. <el-pagination
  225. @current-change="handleCurrentChange"
  226. :current-page.sync="formInline.pageNum"
  227. layout="total, prev, pager, next"
  228. :page-size="formInline.pageSize"
  229. :total="formInline.totalSize"
  230. >
  231. </el-pagination>
  232. </div>
  233. </div>
  234. <!-- 弹出层 -->
  235. <!-- 异常信息 /异常描述-->
  236. <my-dialog
  237. :visible="dialogVisible"
  238. :errorInfo="errorInfo"
  239. :title="title"
  240. :rowInfo="rowInfo"
  241. @confirm="handleConfirm"
  242. >
  243. <div slot="tableEl">
  244. <el-empty description="暂无数据"></el-empty>
  245. </div>
  246. </my-dialog>
  247. </div>
  248. </template>
  249. <script>
  250. import MyDialog from "./components/dialogCom.vue";
  251. import { getAnalysisResultList, onOffAutoAnalysis } from "@/api/performance";
  252. export default {
  253. components: {
  254. MyDialog,
  255. },
  256. data() {
  257. return {
  258. intervalId: null,
  259. startTime: null,
  260. maxPollingTime: 5 * 60 * 1000, //轮询最大时间
  261. dialogVisible: false,
  262. loadingView: false,
  263. loading: false, //数据加载中
  264. errorInfo: "",
  265. rules: {
  266. fieldName: { trigger: "blur" },
  267. },
  268. roleList: [],
  269. formInline: {
  270. fieldName: undefined,
  271. pageNum: 1,
  272. pageSize: 10,
  273. totalSize: 0,
  274. },
  275. tableData: [],
  276. rowInfo: {},
  277. title: "",
  278. };
  279. },
  280. created() {
  281. this.getTableList();
  282. },
  283. methods: {
  284. upLoadeAssetss(row) {},
  285. async HandleOnOffAuto(row) {
  286. try {
  287. const form = new FormData();
  288. form.append("batchCode", row.batchCode);
  289. form.append("onOffCall", row.onOffCall === 0 ? 1 : 0);
  290. const res = await onOffAutoAnalysis(form);
  291. if (res.code === 200) {
  292. this.getTableList();
  293. this.$message({
  294. type: "success",
  295. message: `${row.onOffCall === 0 ? "开启" : "关闭"}成功`,
  296. });
  297. }
  298. } catch (err) {
  299. console.error(err);
  300. }
  301. },
  302. //分析
  303. handleAssetss(row) {
  304. this.$router.push({
  305. path: "/home/performance/editAssets",
  306. query: {
  307. batchCode: row.batchCode,
  308. analysisTypeCode: row.analysisTypeCode,
  309. fieldEngineCode: row.fieldCode,
  310. },
  311. });
  312. },
  313. //分析详情
  314. handleAssetssDetail(row, state) {
  315. const navigateToDetails = () => {
  316. this.$router.push({
  317. path: "/home/performance/assetssDetail",
  318. query: {
  319. batchCode: row.batchCode,
  320. // analysisTypeCode: row.analysisTypeCode,
  321. fieldCode: row.fieldCode,
  322. },
  323. });
  324. };
  325. if (state === "0") {
  326. // 分析状态为分析中
  327. this.$confirm(
  328. "当前查看的分析记录为历史分析结果,最新分析记录还未分析完成不展示!"
  329. )
  330. .then(() => {
  331. navigateToDetails();
  332. })
  333. .catch(() => {});
  334. } else {
  335. navigateToDetails();
  336. }
  337. },
  338. abnormalDialog(row, title) {
  339. this.dialogVisible = true;
  340. if (title === "异常详情") {
  341. this.errorInfo = row.errInfo;
  342. this.rowInfo = {};
  343. } else if (title === "异常描述") {
  344. this.errorInfo = "";
  345. this.rowInfo = { ...row };
  346. }
  347. this.title = title;
  348. },
  349. handleConfirm() {
  350. this.dialogVisible = false;
  351. },
  352. //分页数据切换
  353. handleCurrentChange(val) {
  354. this.formInline.pageNum = val;
  355. this.getTableList();
  356. },
  357. async getTableList() {
  358. try {
  359. this.loading = true;
  360. const result = await getAnalysisResultList({
  361. ...this.formInline,
  362. totalSize: undefined,
  363. });
  364. this.tableData = result.data.list;
  365. this.formInline.totalSize = result.data.totalSize;
  366. this.loading = false;
  367. } catch (error) {
  368. this.$message({
  369. type: "error",
  370. message: "请检查是否连接网络",
  371. });
  372. }
  373. },
  374. rowStyle() {
  375. return "text-align:center";
  376. },
  377. // 查询
  378. onSubmit() {
  379. this.getTableList();
  380. },
  381. // 重置
  382. reset(formName) {
  383. this.$refs[formName].resetFields();
  384. this.getTableList();
  385. },
  386. async fetchData() {
  387. try {
  388. const result = await getAnalysisResultList({
  389. ...this.formInline,
  390. totalSize: undefined,
  391. });
  392. this.tableData = result.data.list;
  393. this.formInline.totalSize = result.data.totalSize;
  394. } catch (error) {
  395. this.$message({
  396. type: "error",
  397. message: "请检查是否连接网络",
  398. });
  399. }
  400. },
  401. stopPolling() {
  402. if (this.intervalId) {
  403. clearInterval(this.intervalId);
  404. this.intervalId = null;
  405. }
  406. },
  407. startPolling() {
  408. this.startTime = new Date().getTime();
  409. this.intervalId = setInterval(() => {
  410. const currentTime = new Date().getTime();
  411. if (currentTime - this.startTime >= this.maxPollingTime) {
  412. this.stopPolling();
  413. } else {
  414. this.fetchData();
  415. }
  416. }, 10000); // 每10秒调用一次
  417. },
  418. },
  419. mounted() {
  420. this.startPolling();
  421. },
  422. beforeDestroy() {
  423. this.stopPolling();
  424. },
  425. };
  426. </script>
  427. <style lang="scss" scoped>
  428. @keyframes striped-flow {
  429. from {
  430. background-position: 0 100px;
  431. }
  432. to {
  433. background-position: 1.25em 1.25em;
  434. }
  435. }
  436. .general {
  437. display: flex;
  438. flex-wrap: wrap;
  439. .condition {
  440. width: 50%;
  441. display: flex;
  442. p {
  443. width: 100px;
  444. text-align: right;
  445. line-height: 40px;
  446. }
  447. span {
  448. line-height: 40px;
  449. padding-left: 20px;
  450. }
  451. .el-select {
  452. width: 100%;
  453. margin-bottom: 20px;
  454. }
  455. .el-input {
  456. margin-bottom: 20px;
  457. }
  458. }
  459. }
  460. .attachment {
  461. display: flex;
  462. padding-top: 10px;
  463. p {
  464. margin-right: 20px;
  465. color: #409eff;
  466. }
  467. }
  468. .addition {
  469. display: flex;
  470. justify-content: flex-end;
  471. margin-bottom: 10px;
  472. }
  473. .demo-ruleForm {
  474. .el-form-item {
  475. margin-bottom: 25px;
  476. }
  477. }
  478. ::v-deep .animated-progress .el-progress-bar__outer {
  479. height: 15px; /* Adjust height as needed */
  480. background-color: rgb(235, 238, 245);
  481. background-image: linear-gradient(
  482. 45deg,
  483. rgba(0, 0, 0, 0.1) 25%,
  484. transparent 25%,
  485. transparent 50%,
  486. rgba(0, 0, 0, 0.1) 50%,
  487. rgba(0, 0, 0, 0.1) 75%,
  488. transparent 75%,
  489. transparent
  490. );
  491. background-size: 1.25em 1.25em;
  492. animation: striped-flow 3s linear infinite;
  493. }
  494. </style>