scdTree.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <div>
  3. <div class="btnBox">
  4. <div @click="checkNow">
  5. <img :src="addPng" alt="" />
  6. <span>新的比对</span>
  7. </div>
  8. <div @click="reloadCheck">
  9. <img :src="againPng" alt="" />
  10. <span>重新比对</span>
  11. </div>
  12. <div @click="excelPort">
  13. <img :src="dervicePng" alt="" />
  14. <span>导出所有结果</span>
  15. </div>
  16. </div>
  17. <div class="tableBox">
  18. <el-table
  19. ref="multipleTableRef"
  20. :data="tableList"
  21. style="width: 100%; height: calc(100vh - 320px)"
  22. stripe
  23. @selection-change="handleSelectionChange"
  24. @select-all="chooseAll"
  25. :header-cell-style="{
  26. background: '#F7F8FB !important',
  27. color: '#7484AB',
  28. borderBottom: '1px solid #A3ADE0 !important',
  29. fontWeight: '400',
  30. }"
  31. >
  32. <el-table-column type="selection" width="55" />
  33. <el-table-column
  34. label="对比scd"
  35. width="190"
  36. :show-overflow-tooltip="true"
  37. >
  38. <template #default="scope">{{ scope.row.name }}</template>
  39. </el-table-column>
  40. <el-table-column
  41. property="CREATED_TIME"
  42. label="时间"
  43. width="auto"
  44. :show-overflow-tooltip="true"
  45. />
  46. <el-table-column fixed="right" label="操作" width="120">
  47. <template #default="scope">
  48. <el-button
  49. link
  50. type="primary"
  51. size="small"
  52. @click="searchScdCheck(scope.row)"
  53. ><el-icon> <View /> </el-icon>查看</el-button
  54. >
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. </div>
  59. <!-- <div>新的对比
  60. <LookScd
  61. v-if="lookScdModal"
  62. :lookScdModal="lookScdModal"
  63. :aktType="aktType"
  64. @lookScdBack="lookScdBack"
  65. >
  66. </LookScd>
  67. </div> -->
  68. <!-- 新的对比弹窗 -->
  69. <el-dialog
  70. @close="cancelClick"
  71. v-model="lookScdModal"
  72. width="30vw"
  73. style="height: 400px"
  74. append-to-body
  75. draggable
  76. >
  77. <template #header>
  78. <div class="my-header">
  79. <div class="title">请选择对比的SCD文件</div>
  80. </div>
  81. </template>
  82. <div
  83. class="uploda-file"
  84. v-loading="loadingAdd"
  85. element-loading-text="上传文件中..."
  86. >
  87. <span class="file-title">选择文件</span>
  88. <el-input
  89. v-model="chooseFile"
  90. class="w-50 m-2"
  91. placeholder="点击右侧按钮上传文件"
  92. clearable
  93. @clear="clearFile"
  94. >
  95. <template #suffix>
  96. <img
  97. v-if="chooseFile"
  98. :src="uploadSPng"
  99. alt=""
  100. style="width: 20px; height: 20px"
  101. />
  102. <img
  103. v-if="loadingAddError"
  104. :src="uploadEPng"
  105. alt=""
  106. style="width: 20px; height: 20px"
  107. />
  108. </template>
  109. </el-input>
  110. <el-upload
  111. v-model:file-list="fileList"
  112. :limit="1"
  113. class="upload-demo"
  114. :http-request="uploadFile"
  115. :on-exceed="exceed"
  116. :show-file-list="false"
  117. >
  118. <template #trigger>
  119. <div class="upload-title">
  120. <img :src="uploadPng" alt="" />
  121. <span>上传文件</span>
  122. </div>
  123. </template>
  124. </el-upload>
  125. </div>
  126. <div class="sure-file">
  127. <div v-if="!isAnalysis && AnalysisProcess" class="analysis success">
  128. 文件解析完成
  129. </div>
  130. <div v-else-if="isAnalysis && AnalysisProcess" class="analysis fail">
  131. 文件解析失败
  132. </div>
  133. <div v-if="chooseFile && !AnalysisProcess" class="analysis">
  134. 文件正在解析中,请等待...
  135. </div>
  136. <!-- <div
  137. class="sures"
  138. :class="{ 'sures-success': !isAnalysis && AnalysisProcess }"
  139. >
  140. 确认上传
  141. </div> -->
  142. <div
  143. class="sures sures-success"
  144. v-if="!isAnalysis && AnalysisProcess"
  145. @click="yesAnalysisClick"
  146. >
  147. 开始对比
  148. </div>
  149. <div class="sures" v-else @click="noAnalysisClick">开始对比</div>
  150. </div>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script setup>
  155. import {
  156. ref,
  157. onMounted,
  158. toRefs,
  159. watch,
  160. nextTick,
  161. defineEmits,
  162. onUnmounted,
  163. } from "vue";
  164. import scdCheck from "@/api/scdCheck/scdCheck";
  165. import {
  166. uploadfile,
  167. tmpParse,
  168. compStart,
  169. compstatView,
  170. } from "@/api/scdCheck/scdCheck2";
  171. import scd from "@/api/scd";
  172. import systemRow from "@/api/systemRow";
  173. import {
  174. ElMessage,
  175. ElLoading,
  176. ElMessageBox,
  177. ElNotification,
  178. } from "element-plus";
  179. import LookScd from "../modalCom/LookScd.vue";
  180. import dervicePng from "@/assets/image/scdcheck/derive.png";
  181. import againPng from "@/assets/image/scdcheck/again.png";
  182. import addPng from "@/assets/image/scdcheck/add.png";
  183. import uploadPng from "@/assets/image/scdcheck/upload.png";
  184. import uploadSPng from "@/assets/image/scdcheck/upload_success.png";
  185. import uploadEPng from "@/assets/image/scdcheck/upload_error.png";
  186. import { useRoute } from "vue-router";
  187. import createds from "@/utils/scdMqtt.js";
  188. const route = useRoute();
  189. const emit = defineEmits(["scdTreeBack","scdView","scdJpadList"]);
  190. let tableList = ref([]);
  191. let multipleTableRef = ref();
  192. let alreadyTriggered = ref(false);
  193. let scdid = ref([]);
  194. const loading = ref(false);
  195. let lookScdArr = ref([]);
  196. let lookScdModal = ref(false);
  197. const fileList = ref([]); //上传的文件
  198. const loadingAdd = ref(false); //文件上传的加载状态
  199. const loadingAddError = ref(false); //文件上传的加载状态
  200. const chooseFile = ref("");
  201. const handleSelectionChange = (e) => {
  202. //复选
  203. };
  204. const chooseAll = (e) => {
  205. //全选
  206. };
  207. const checkNow = (e) => {
  208. //scd比对
  209. lookScdModal.value = true;
  210. };
  211. const excelPort = () => {
  212. //导出excel
  213. systemRow
  214. .portExcel({
  215. code: "scd-comp-result",
  216. })
  217. .then((res) => {
  218. if (res.data) {
  219. return;
  220. } else {
  221. ElMessage({
  222. message: res.msg,
  223. type: "info",
  224. });
  225. }
  226. });
  227. };
  228. const reloadCheck = () => {
  229. //重新比对
  230. checkNow();
  231. };
  232. const exceed = (files) => {
  233. if (fileList.value.length > 0) {
  234. ElMessage({
  235. type: "warning",
  236. message: "请清除选择文件后重新选择!",
  237. });
  238. }
  239. };
  240. const uploadFile = async (e) => {
  241. fileList.value = [];
  242. chooseFile.value = "";
  243. loadingAddError.value = false;
  244. loadingAdd.value = true;
  245. const fileRes = await uploadfile({
  246. file: e.file,
  247. station_id: route.query.stationId,
  248. is_checkin: 0,
  249. data_type: "a_scd",
  250. });
  251. if (fileRes.code == 0) {
  252. fileList.value.push(fileRes.data);
  253. chooseFile.value = fileRes.data.filename;
  254. loadingAdd.value = false;
  255. ElMessage({
  256. type: "success",
  257. message: "上传成功!",
  258. });
  259. const resParse = await tmpParse({
  260. station_id: route.query.stationId,
  261. scd_name: fileRes.data.filename,
  262. scd_path: fileRes.data.path,
  263. });
  264. startMqtt(`/jujutong/scd_check_tools/parse/#`);
  265. } else {
  266. loadingAdd.value = false;
  267. loadingAddError.value = true;
  268. ElMessage({
  269. type: "error",
  270. message: "上传失败!",
  271. });
  272. }
  273. };
  274. //查看scd对比
  275. let data = {};
  276. const searchScdCheck = async (row) => {
  277. data = {}
  278. data = row;
  279. emit('scdView',data)
  280. const loading = ElLoading.service({
  281. lock: true,
  282. text: "正在查询数据",
  283. background: "rgba(0, 0, 0, 0.7)",
  284. });
  285. const res = await compstatView({
  286. comp_id: row.id,
  287. });
  288. if (res.code == 0) {
  289. emit('scdJpadList',res.data)
  290. loading.close();
  291. }
  292. };
  293. const lookScdBack = (data, row) => {
  294. //选择scd文件模态框返回数据
  295. lookScdModal.value = data;
  296. lookScdArr.value = row;
  297. emit("scdTreeBack", lookScdArr.value);
  298. };
  299. const aktType = () => {
  300. //初始化数据
  301. scdCheck
  302. .flashStationDui({ station_id: route.query.stationId })
  303. .then((res) => {
  304. //获取差异纪录列表
  305. tableList.value = res.data;
  306. });
  307. };
  308. // mqtt=======
  309. const PublicMqtt = ref(null);
  310. const mesg = ref(null); //订阅成功的消息
  311. const isAnalysis = ref(false); //解析是否成功
  312. const AnalysisProcess = ref(false); //解析是否完成
  313. const startMqtt = (val) => {
  314. //val = 订阅地址
  315. //设置订阅地址
  316. PublicMqtt.value = new createds(val);
  317. //初始化mqtt
  318. PublicMqtt.value.init();
  319. //链接mqtt
  320. PublicMqtt.value.link();
  321. getMessage();
  322. };
  323. //获取订阅数据
  324. const getMessage = () => {
  325. PublicMqtt.value.client.on("message", (topic, message) => {
  326. // topic包含error就表示解析错误,message此时就是错误信息
  327. AnalysisProcess.value = true;
  328. mesg.value = JSON.parse(message.toString());
  329. if (topic.includes("error")) {
  330. isAnalysis.value = true;
  331. ElMessage({
  332. type: "error",
  333. message: mesg.value,
  334. });
  335. } else {
  336. isAnalysis.value = false;
  337. }
  338. console.log(mesg.value, "返回的数据", topic);
  339. });
  340. };
  341. //取消MQTT订阅
  342. const unsubscribe = () => {
  343. //如果页面并没有初始化MQTT,无需取消订阅
  344. if (PublicMqtt.value) {
  345. PublicMqtt.unsubscribes();
  346. }
  347. };
  348. onUnmounted(() => {
  349. //页面销毁结束订阅
  350. if (PublicMqtt.value) {
  351. PublicMqtt.value.unsubscribes();
  352. PublicMqtt.value.over();
  353. }
  354. });
  355. // mqtt=======
  356. // 取消弹窗
  357. const cancelClick = () => {
  358. loadingAddError.value = false;
  359. loadingAdd.value = false;
  360. };
  361. //点击输入框中的清除按钮
  362. const clearFile = () => {
  363. fileList.value = [];
  364. };
  365. watch(
  366. () => chooseFile.value,
  367. (newValue) => {
  368. if (!newValue) {
  369. fileList.value = [];
  370. }
  371. }
  372. );
  373. //解析完成开始对比的点击
  374. const yesAnalysisClick = () => {
  375. ElMessageBox.confirm(
  376. "该操作耗时较长,校验开始后将清除原有校验结果且无法中止,确定开始吗?",
  377. "Warning",
  378. {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "warning",
  382. }
  383. )
  384. .then(async () => {
  385. ElNotification({
  386. title: "信息",
  387. message: "正在进行SCD的一致性比对...请稍候",
  388. duration: 0,
  389. });
  390. const anRes = await compStart({
  391. type: "SCD",
  392. station_id: route.query.stationId,
  393. source_scd_id: route.query.id,
  394. target_scd_id: mesg.value.rootid,
  395. comp_id: 0,
  396. });
  397. if (anRes.code == 0) {
  398. ElNotification.closeAll();
  399. loadingAdd.value = false;
  400. aktType();
  401. ElMessage({
  402. type: "success",
  403. message: "对比完成!",
  404. });
  405. }
  406. })
  407. .catch((err) => {
  408. });
  409. };
  410. //解析失败活未完成开始对比的点击
  411. const noAnalysisClick = () => {
  412. ElMessage({
  413. type: "warning",
  414. message: "请上传文件并等待文件解析完成!",
  415. });
  416. };
  417. const parentData = ref(null);
  418. onMounted(() => {
  419. parentData.value = JSON.parse(route.query.parentData);
  420. aktType();
  421. });
  422. </script>
  423. <style scoped lang="scss">
  424. .btnBox > div,
  425. .upload-title {
  426. height: 50px;
  427. display: flex;
  428. align-items: center;
  429. justify-content: center;
  430. margin-right: 8px;
  431. cursor: pointer;
  432. background: url("~@/assets/image/scdcheck/bgscd.png") no-repeat center;
  433. border-radius: 2px;
  434. font-size: 14px;
  435. color: #255ce7;
  436. img {
  437. width: 20px;
  438. height: 20px;
  439. margin: 0 4px 0 0;
  440. }
  441. }
  442. .upload-title {
  443. width: 102px;
  444. background-size: 103px 50px;
  445. margin-top: 4px;
  446. }
  447. .btnBox {
  448. display: flex;
  449. margin-bottom: 12px;
  450. & > div:first-child,
  451. & > div:nth-child(2) {
  452. width: 102px;
  453. background-size: 102px 45px;
  454. }
  455. & > div:last-child {
  456. width: 128px;
  457. background-size: 128px 45px;
  458. }
  459. }
  460. .my-header {
  461. border-bottom: 1px solid #a3ade0;
  462. font-size: 16px;
  463. color: #1a2447;
  464. .title {
  465. padding-bottom: 15px;
  466. }
  467. }
  468. .uploda-file {
  469. display: flex;
  470. align-items: center;
  471. }
  472. .upload-demo {
  473. display: flex;
  474. }
  475. .sure-file {
  476. display: flex;
  477. flex-direction: column;
  478. justify-content: center;
  479. align-items: center;
  480. }
  481. .sures {
  482. background: #dfe8ff;
  483. margin-left: 60px;
  484. color: #fff;
  485. width: 124px;
  486. height: 32px;
  487. margin-top: 60px;
  488. line-height: 32px;
  489. text-align: center;
  490. cursor: pointer;
  491. }
  492. .sures-success {
  493. background: #255ce7;
  494. }
  495. .sureUpload {
  496. }
  497. .file-title {
  498. width: 90px;
  499. color: #1a2447;
  500. font-size: 14px;
  501. margin-right: 8px;
  502. }
  503. :deep(.el-input__wrapper) {
  504. height: 38px;
  505. border: 1px solid #a3ade0;
  506. }
  507. .analysis {
  508. margin-left: 67px;
  509. margin-top: 10px;
  510. color: #255ce7;
  511. }
  512. .analysis.success {
  513. color: #3be078;
  514. }
  515. .analysis.fail {
  516. color: #e50505;
  517. }
  518. :deep(.el-message-box) {
  519. vertical-align: inherit !important;
  520. }
  521. </style>