CreateMis.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div>
  3. <div class="createMisBox" v-if="selects == 1">
  4. <div>
  5. <p>新建检测任务</p>
  6. </div>
  7. <div class="formBox">
  8. <el-form :inline="true" label-position="top" :model="newMission" class="demo-form-inline"
  9. style="width: 1200px;margin: 0 auto;" :rules="missionRules" require-asterisk-position="right"
  10. label-width="500px">
  11. <el-form-item label="检测任务名称" prop="misName">
  12. <el-input class="bestInput" v-model="newMission.misName" placeholder="请输入任务名称" clearable />
  13. </el-form-item>
  14. <el-form-item label="任务编号" prop="misNum">
  15. <el-input class="bestInput" disabled v-model="newMission.misNum" placeholder="自动生成任务编号..."
  16. clearable />
  17. </el-form-item>
  18. <el-form-item label="检测变电站" prop="flashId">
  19. <el-select style="width: 340px;" v-model="newMission.flashId" placeholder="请选择变电站" clearable
  20. @change="flashChange">
  21. <template v-for="(item, index) in flashList">
  22. <el-option :label="item.label" :value="item.value" />
  23. </template>
  24. </el-select>
  25. <img @click="addFlash" style="width: 40px;height: 40px;"
  26. src="../../../assets/icon/create_misBtn.png" alt="">
  27. </el-form-item>
  28. <el-form-item label="检测模型" prop="">
  29. <el-input class="bestInput" style="width: 600px;" disabled placeholder="输入内容"
  30. v-model="cmodel"></el-input>
  31. <el-button @click="modelOpen" style="height: 40px;margin-left: 5px;" type="primary"
  32. plain>选择模型</el-button>
  33. </el-form-item>
  34. <el-form-item label="报告模板" prop="reportNow">
  35. <el-select class="bestInput" style="width: 400px;" @chang="bmChange" v-model="newMission.reportNow"
  36. placeholder="请选择模板" clearable>
  37. <el-option v-for="(item, index) in rmList" :label="item.name" :value="item.id" />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="任务说明" prop="misMes">
  41. <el-input style="width: 1136px;" v-model="newMission.misMes"></el-input>
  42. </el-form-item>
  43. <el-form-item label="SCD文件">
  44. <el-upload ref="upload" class="upload-demo" :http-request="nowUpload" :limit="2"
  45. element-loading-text="上传中..." element-loading-background="rgba(255, 255, 255, 0.8)"
  46. :show-file-list="false">
  47. <template #trigger>
  48. <el-button style="border-bottom: 1px solid #7BBAFD;width: calc(100vw - 1000px);"
  49. type="primary" plain>点击选择scd文件</el-button>
  50. </template>
  51. </el-upload>
  52. <span v-loading="scdLoading">{{ scdLoading ? '正在进行间隔装置分析' : '分析完成' }}
  53. </span>
  54. </el-form-item>
  55. </el-form>
  56. </div>
  57. <!-- 间隔、装置列表 -->
  58. <div>
  59. <el-button style="width: 200px;height: 30px;" @click="backMent">返回</el-button>
  60. <el-button style="width: 200px;height: 30px;" @click="saveMent" type="primary">保存</el-button>
  61. </div>
  62. <div class="gapAndUnit" v-if="successScd">
  63. <!-- 间隔列表 -->
  64. <div class="gapBox">
  65. <div style="display: flex;justify-content: flex-start;align-items: center;margin: 5px;">
  66. <div>
  67. <img src="../../../assets/icon/DotsNine.png" alt="">
  68. </div>
  69. <div>
  70. <span>间隔列表</span>
  71. </div>
  72. </div>
  73. <!-- <p :class="jgSelect == index ? 'result' : ''" v-for="(item, index) in jgList"
  74. style="text-align: left;cursor: pointer;" @click="jgClick(item, index)">
  75. {{ item.name }}
  76. </p> -->
  77. <el-tree :props="anyProps" :data="anyData" @node-click="handleCheckChange" />
  78. </div>
  79. <!-- 装置列表 -->
  80. <div class="unitBox">
  81. <div style="display: flex;justify-content: flex-start;align-items: center;margin: 10px 10px;">
  82. <div>
  83. <img src="../../../assets/icon/HardDrives.png" alt="">
  84. </div>
  85. <div style="margin-left: 5px;">
  86. <span>装置列表——间隔:<em>{{ jg }}</em></span>
  87. </div>
  88. <div style="margin-left: 5px;">
  89. <!-- <span>检测模型:<em v-for="(item, index) in mx">{{ mx[index] }}</em></span> -->
  90. <el-button type="primary" size="small" plain @click="checkTime">选择装置</el-button>
  91. </div>
  92. </div>
  93. <div v-loading="iedLoading">
  94. <!-- <div v-for="(item, index) in mx">
  95. {{ item.ied_name }}
  96. </div> -->
  97. <el-tag v-for="(item, index) in mx" :key="item.ied_name" size="large" class="mx-1" type="info"
  98. closable effect="plain" @close="tagClose(item, index)">
  99. {{ item.ied_name }}
  100. </el-tag>
  101. </div>
  102. </div>
  103. </div>
  104. <div v-if="successScd">
  105. <el-button style="width: 200px;height: 30px;" type="primary" @click="iedSave">保存</el-button>
  106. </div>
  107. </div>
  108. <!-- 模态框组件 -->
  109. <div>
  110. <LookScd v-if="scdLooks" :scdLooks="scdLooks" @nowBack="nowBack" @lookNum="lookNum"></LookScd>
  111. <ModelTree v-if="treeMool" :treeMool="treeMool" @treeBack="treeBack" @treeNum="treeNum"></ModelTree>
  112. <FlashCreate v-if="fcModal" :fcModal="fcModal" @fcBack="fcBack"></FlashCreate>
  113. <CheckIed v-if="iedModal" :iedModal="iedModal" :loadScdId="loadScdId" @iedBack="iedBack"
  114. @iedArrBack="iedArrBack"></CheckIed>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import { ref, onMounted, reactive } from 'vue';
  120. import flashPower from '../../../api/flashPower'
  121. import report from '@/api/report';
  122. import scd from "@/api/scd"
  123. import task from '@/api/task';
  124. import cid from '@/api/cid/cid';
  125. import LookScd from '../modalComp/LookScd.vue';
  126. import ModelTree from '../modalComp/ModelTree.vue';
  127. import FlashCreate from '../modalComp/FlashCreate.vue';
  128. import CheckIed from '../modalComp/CheckIed.vue';
  129. import { ElMessage, ElLoading } from 'element-plus';
  130. export default {
  131. props: {
  132. btnSelect: {
  133. type: Number,
  134. require: true
  135. },
  136. taskList: {
  137. type: Array,
  138. require: true
  139. }
  140. },
  141. setup(props, { emit }) {
  142. let selects = props.btnSelect
  143. let arrList = props.taskList
  144. let newMission = ref({
  145. misName: "",
  146. misNum: "",
  147. flashId: "",
  148. reportNow: "",
  149. misMes: "",
  150. scdFolder: "",
  151. })//创建任务提交表单
  152. let missionRules = ref({
  153. misName: [
  154. { required: true, message: '请输入名称', trigger: 'blur' },
  155. ],
  156. flashId: [
  157. { required: true, message: "请选择变电站", trigger: "change" }
  158. ],
  159. reportNow: [
  160. { required: true, message: "请选择模板", trigger: "change" }
  161. ],
  162. })//表单验证
  163. let flashList = ref([])//表单选择的变电站
  164. let scdLooks = ref(false)//选择scd文件时的显示与否
  165. let treeMool = ref(false)//选择模型模态框
  166. let btnName = ref('点击选择scd文件')
  167. let jg = ref("请选择")
  168. let jgList = ref([])//间隔列表
  169. let jgSelect = ref()//选择间隔
  170. let jgid = ref("")//间隔id
  171. let mx = ref([])
  172. let mxList = ref([])//模型列表
  173. let mxId = ref("")//模型id
  174. let rmList = ref([])//报告模板list
  175. let scdId = ref('')//lookscd.vue返回的scdid
  176. let scdName = ref('')//lookscd.vue返回的scdname
  177. let cmodel = ref('')
  178. let fcModal = ref(false)//创建变电站模态框
  179. let scdLoading = ref(false)//上传scd文件后进行分析
  180. let loadScdId = ref(0)//上传成功后拿到的scdid
  181. let successScd = ref(false)//保存任务后继续选择的间隔模型
  182. let iedModal = ref(false)//checkied.vue模态框状态
  183. let loadAreaId = ref("")
  184. let iedName = ref("")//一串ied名称字符串
  185. let iedLoading = ref(false)//加载ied
  186. let anyProps = ref({
  187. label: "area_name",
  188. id: "area_id",
  189. })
  190. let anyData = ref([])
  191. function searchAllFlash() {
  192. flashPower.getAllArea({}).then(res => {
  193. flashPower.getAllFlashPower({ pid: res.data[0].pid }).then(res => {
  194. flashList.value = res.data.map(item => {
  195. return {
  196. label: item.area_name,
  197. value: item.id
  198. }
  199. })
  200. })
  201. })
  202. report.getReport({}).then(res => {
  203. rmList.value = res.data
  204. })
  205. }
  206. //变电站下拉框change事件
  207. function flashChange(e) {
  208. // searchScd(e)
  209. newMission.value.flashId = e
  210. }
  211. function bmChange(e) {
  212. newMission.value.reportNow = e.id
  213. }
  214. function jgClick(row, num) {
  215. jg.value = row.name
  216. jgSelect.value = num
  217. jgid.value = row.id
  218. }
  219. // 选择scd文件
  220. function chooseScdFile() {
  221. scdLooks.value = true
  222. }
  223. // lookscd组件传回得数据
  224. function nowBack(data, names, sid) {
  225. scdLooks.value = data
  226. if (names && sid) {
  227. newMission.value.scdFolder = sid
  228. btnName.value = names
  229. scd.getScdMiddle({ scd_id: sid }).then(res => {
  230. console.log(res, 'sid');
  231. })
  232. scd.getIedMiddle({ scd_id: sid }).then(res => {
  233. console.log(res, 'ied');
  234. })
  235. }
  236. }
  237. function saveMent() {//保存检测任务
  238. task.createTask({
  239. name: newMission.value.misName,
  240. station_id: newMission.value.flashId - 0,
  241. memo: newMission.value.misMes,
  242. report_id: newMission.value.reportNow - 0,
  243. scd_id: loadScdId.value - 0,
  244. modelids: mxId.value.toString()
  245. }).then(res => {
  246. if (res.code == 0) {
  247. ElMessage({
  248. message: "创建成功",
  249. type: "success"
  250. })
  251. // emit("createBack", 0)
  252. scd.getLoadScd({ scd_id: loadScdId.value - 0 }).then(res => {
  253. if (res.code == 0) {
  254. successScd.value = true
  255. anyData.value = res.data
  256. }
  257. })
  258. }
  259. })
  260. }
  261. function nowUpload(e) {
  262. const loading = ElLoading.service({
  263. lock: true,
  264. text: '文件上传中',
  265. background: 'rgba(0, 0, 0, 0.7)',
  266. })
  267. cid.fileUpload({ station_id: 861, data_type: 'a_scd', file: e.file }).then(res => {
  268. scdLoading.value = true
  269. if (res.code == 0) {
  270. loading.close()
  271. }
  272. scd.loadScd({ station_id: 861, scd_path: res.data.path, scd_name: res.data.filename }).then(the => {
  273. // scd.getLoadScd({ scd_id: the.data - 0 }).then(lod => {
  274. // console.log(lod,'rsasdas');
  275. if (the.code == 0) {
  276. loadScdId.value = the.data - 0
  277. scdLoading.value = false
  278. }
  279. // })
  280. })
  281. })
  282. }
  283. function handleCheckChange(e) {
  284. loadAreaId.value = e.area_id
  285. iedLoading.value = true
  286. scd.getTikIed({ scd_id: loadScdId.value - 0, area_id: e.area_id - 0 }).then(res => {
  287. if (res.data != null) {
  288. mx.value = res.data
  289. iedName.value = mx.value.map(item => item.ied_name).join(',')
  290. iedLoading.value = false
  291. } else {
  292. mx.value = []
  293. iedLoading.value = false
  294. }
  295. })
  296. }
  297. function iedSave() {
  298. scd.stickIed({ scd_id: loadScdId.value - 0, area_id: loadAreaId.value - 0, ied_ids: iedName.value }).then(res => {
  299. console.log(res, 'res');
  300. if (res.code == 0) {
  301. ElMessage({
  302. type: "success",
  303. message: "添加ied成功!",
  304. duration: 1500,
  305. })
  306. emit("createBack", 0)
  307. } else {
  308. ElMessage({
  309. type: "error",
  310. message: res.msg,
  311. duration: 1500,
  312. })
  313. }
  314. })
  315. }
  316. function tagClose(row, num) {
  317. mx.value.splice(mx.value.indexOf(row), 1)
  318. iedName.value = mx.value.map(item => item.ied_name).join(', ');
  319. console.log(iedName,'iedname');
  320. }
  321. function checkTime() {
  322. iedModal.value = true
  323. }
  324. function addFlash() {
  325. fcModal.value = true
  326. }
  327. function backMent() {
  328. emit("createBack", 0)
  329. }
  330. function treeBack(data) {
  331. treeMool.value = data
  332. }
  333. function modelOpen() {
  334. treeMool.value = true
  335. }
  336. function treeNum(data, name) {
  337. mxId.value = data
  338. // mx.value = name
  339. cmodel.value = name.toString()
  340. }
  341. function lookNum(name, id) {
  342. scdId.value = id
  343. scd.getScdMiddle({ scd_id: id }).then(res => {
  344. jgList.value = res.data
  345. })
  346. scdName.value = name
  347. }
  348. function fcBack(data) {
  349. fcModal.value = data
  350. }
  351. function iedBack(data) {
  352. iedModal.value = data
  353. }
  354. function iedArrBack(data) {
  355. mx.value = mx.value.concat(data)
  356. iedName.value = mx.value.map(item => item.ied_name).join(', ');
  357. }
  358. onMounted(() => {
  359. searchAllFlash()
  360. })
  361. return {
  362. selects,
  363. arrList,
  364. newMission,
  365. searchAllFlash,//获取变电站
  366. missionRules,//表单验证
  367. flashList,//表单选择的变电站
  368. flashChange,//变电站下拉框change事件
  369. scdLooks,//选择scd文件时的显示与否
  370. chooseScdFile,// 选择scd文件
  371. nowBack, // lookscd组件传回得数据
  372. btnName,//按钮内修改文字
  373. treeMool,//选择模型显示与否
  374. treeBack,//modeltree传回数据
  375. modelOpen,//选择模型打开模态框
  376. jg,//间隔
  377. jgList,//间隔列表
  378. jgSelect,//选择
  379. jgClick,//间隔点击
  380. jgid,//间隔id
  381. mx,//模型
  382. mxList,//模型列表
  383. treeNum,//modelTree.vue返回的id函数
  384. mxId,//模型id
  385. rmList,//报告模板列表
  386. scdId,//lookscd.vue返回的数据
  387. scdName,//lookscd.vue返回的数据
  388. saveMent,//保存检测任务
  389. bmChange,
  390. backMent,//返回切换
  391. cmodel,
  392. addFlash,//新建变电站
  393. fcModal,//创建变电站模态框
  394. fcBack,//flashcreate.vue返回的模态框值
  395. nowUpload,//文件上传
  396. scdLoading,
  397. loadScdId,//上传成功后拿到的scdid
  398. successScd,//保存任务后继续选择的间隔模型
  399. handleCheckChange,//树形组件
  400. anyData,
  401. anyProps,
  402. iedModal,//checkied.vue模态框状态
  403. iedBack,//checkied.vue返回模态框状态
  404. checkTime,//打开选择ied
  405. iedArrBack,//checkied.vue返回选择数组
  406. tagClose,
  407. loadAreaId,//area_id
  408. iedSave,//保存ied状态
  409. iedName,//一串ied字符串
  410. iedLoading,
  411. }
  412. },
  413. components: {
  414. LookScd,
  415. ModelTree,//选择模型
  416. FlashCreate,//创建变电站
  417. CheckIed,//选择ied
  418. }
  419. }
  420. </script>
  421. <style scoped>
  422. em {
  423. font-style: normal;
  424. color: #5779D7;
  425. margin-right: 5px;
  426. }
  427. .createMisBox {
  428. width: 100%;
  429. height: calc(100vh - 150px);
  430. text-align: center;
  431. margin-top: 20px;
  432. /* line-height: calc(100vh - 150px); */
  433. }
  434. .formBox {
  435. width: 1136px;
  436. height: 339px;
  437. margin: 0 auto;
  438. /* border-bottom: 1px dashed #dbdbdb; */
  439. }
  440. .bestInput {
  441. width: 340px;
  442. height: 40px;
  443. border-radius: 2px 2px 2px 2px;
  444. }
  445. .gapAndUnit {
  446. width: 1136px;
  447. /* height: 150px; */
  448. /* border: 1px solid black; */
  449. margin: 5px auto;
  450. display: flex;
  451. justify-content: space-around;
  452. align-items: center;
  453. }
  454. .gapBox {
  455. width: 288px;
  456. height: calc(100vh - 600px);
  457. overflow-y: auto;
  458. border: 1px solid #5779D7;
  459. }
  460. .unitBox {
  461. width: 832px;
  462. height: calc(100vh - 600px);
  463. overflow-y: auto;
  464. border: 1px solid #5779D7;
  465. position: relative;
  466. }
  467. .result {
  468. color: #5779D7;
  469. }
  470. .chooseSpan {
  471. width: 150px;
  472. height: 30px;
  473. margin-left: 10px;
  474. border: 1px solid blue;
  475. text-align: center;
  476. line-height: 30px;
  477. }
  478. .mx-1{
  479. margin-right: 10px;
  480. border: 1px solid #5779D7;
  481. }
  482. </style>