maintain.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div>
  3. <div class="title-list">
  4. <div class="search">
  5. <div class="date">风场:</div>
  6. <el-select class="inputs" v-model="selectValue" placeholder="请选择" @change="handleChange()">
  7. <el-option v-for="item in stationList" :key="item.aname" :label="item.aname" :value="item.id">
  8. </el-option>
  9. </el-select>
  10. </div>
  11. <div class="search">
  12. <div class="date">机组:</div>
  13. <el-select class="inputs" clearable v-model="groupId" placeholder="请选择">
  14. <el-option v-for="item in groupList" :key="item.code" :label="item.code" :value="item.id">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <div class="query-item">
  19. <div class="lable">开始日期:</div>
  20. <div class="search-input">
  21. <el-date-picker v-model="timeValue" type="datetimerange" range-separator="至"
  22. start-placeholder="开始日期" end-placeholder="结束日期">
  23. </el-date-picker>
  24. </div>
  25. </div>
  26. <div class="query-actions">
  27. <button class="button" @click="getDatas">查询</button>
  28. <button class="button" @click="add">新增</button>
  29. <button class="button" @click="exportExcel">导出</button>
  30. </div>
  31. </div>
  32. <div>
  33. <el-table height="90vh" ref="multipleTable" empty-text="暂无数据" :data="tableList" stripe
  34. style="width: 100%; margin-bottom: 10px">
  35. <el-table-column prop="projectname" label="期次" align="center" width="220" sortable></el-table-column>
  36. <el-table-column label="场站名称" prop="wpname" align="center" sortable>
  37. </el-table-column>
  38. <el-table-column label="风机名称" prop="wtname" align="center" sortable>
  39. </el-table-column>
  40. <el-table-column label="开始时间" prop="showbegindate" align="center" sortable>
  41. </el-table-column>
  42. <el-table-column label="结束时间" prop="showenddate" align="center" sortable>
  43. </el-table-column>
  44. <el-table-column label="维护内容" prop="defecteliminating" align="center" sortable>
  45. </el-table-column>
  46. <el-table-column label="损失电量" prop="powerloss" align="center" sortable>
  47. </el-table-column>
  48. <el-table-column label="故障时长" prop="faultduration" align="center" sortable>
  49. </el-table-column>
  50. <el-table-column label="时长影响容量" prop="impactcapacity" align="center" sortable>
  51. </el-table-column>
  52. <el-table-column label="内报/外报" prop="type" align="center" sortable>
  53. </el-table-column>
  54. <el-table-column label="操作" align="center">
  55. <template #default="scope">
  56. <el-button type="text" style="color: #597ef7" @click="handleEdit(scope.row)">编辑</el-button>
  57. <el-button type="text" style="color: #b3bdc0" @click="handleDelete(scope.row)">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. </div>
  62. <el-dialog v-model="dialogVisible" title="逆变器详情" width="45%" top="10vh" :show-close="true">
  63. <div class="table-list">
  64. <div class="lists">
  65. <div class="rows">
  66. <div class="rows-name">开始时间:</div>
  67. <el-date-picker v-model="sendData.begindate" type="datetime" placeholder="选择开始时间">
  68. </el-date-picker>
  69. </div>
  70. <div class="rows">
  71. <div class="rows-name">结束时间:</div>
  72. <el-date-picker v-model="sendData.enddate" type="datetime" placeholder="选择结束时间">
  73. </el-date-picker>
  74. </div>
  75. </div>
  76. <div class="lists">
  77. <div class="rows">
  78. <div class="rows-name">维护内容:</div>
  79. <el-input type="textarea" class="rows-input" v-model="sendData.defecteliminating"
  80. placeholder="请输入维护内容"></el-input>
  81. </div>
  82. </div>
  83. <div class="lists" style="margin-bottom: 40px">
  84. <div class="rows">
  85. <div class="rows-name">损失电量:</div>
  86. <el-input class="rows-inputs" v-model="sendData.powerloss" placeholder="请输入损失电量"></el-input>
  87. </div>
  88. <div class="rows">
  89. <div class="rows-name">内报/外报:</div>
  90. <el-select class="inputs" clearable v-model="sendData.type" placeholder="请选择">
  91. <el-option v-for="item in typesList" :key="item.name" :label="item.name" :value="item.name">
  92. </el-option>
  93. </el-select>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="submit">
  98. <el-button type="primary" plain @click="sunmit">提交</el-button>
  99. </div>
  100. </el-dialog>
  101. </div>
  102. </template>
  103. <script>
  104. import api from "api/index";
  105. import dayjs from "dayjs";
  106. import XLSX from "xlsx";
  107. export default {
  108. data() {
  109. return {
  110. timeValue: [],
  111. groupId: '',
  112. groupList: [
  113. ],
  114. stationList: [
  115. {
  116. "id":"WNS_FDC",
  117. "code":"WNS_FDC",
  118. "name":"太旗卧牛山风电场",
  119. "address":"太旗卧牛山风电场",
  120. "telephone":null,
  121. "capacity":148.5,
  122. "capacityunit":"MW",
  123. "quantity":99,
  124. "aname":"太旗卧牛山",
  125. "longitude":1000,
  126. "latitude":1000,
  127. "photo":null,
  128. "companyid":"1",
  129. "systemmanufact":null,
  130. "headfarm":null,
  131. "headfarmphone":null,
  132. "model":"UP77-1500/UP77-1500-1/UP77-1500-2",
  133. "ordernum":1,
  134. "altitude":1000,
  135. "height":null
  136. },
  137. {
  138. "id":"YY_FDC",
  139. "code":"YY_FDC",
  140. "name":"右玉高家堡风电场 ",
  141. "address":"右玉高家堡风电场 ",
  142. "telephone":null,
  143. "capacity":198,
  144. "capacityunit":"MW",
  145. "quantity":132,
  146. "aname":"右玉高家堡",
  147. "longitude":1000,
  148. "latitude":1000,
  149. "photo":null,
  150. "companyid":"1",
  151. "systemmanufact":null,
  152. "headfarm":null,
  153. "headfarmphone":null,
  154. "model":"UP82-1500/UP82-1500-1/UP86-1500/UP86-1500-1/UP86-1500-2/UP86-1500-3/UP86-1500-4/MY-1.5se",
  155. "ordernum":2,
  156. "altitude":1000,
  157. "height":null
  158. },
  159. {
  160. "id":"PL_FDC",
  161. "code":"PL_FDC",
  162. "name":"平鲁虎头山风电场 ",
  163. "address":"平鲁虎头山风电场 ",
  164. "telephone":null,
  165. "capacity":223.5,
  166. "capacityunit":"MW",
  167. "quantity":110,
  168. "aname":"平鲁虎头山",
  169. "longitude":1000,
  170. "latitude":1000,
  171. "photo":null,
  172. "companyid":"1",
  173. "systemmanufact":null,
  174. "headfarm":null,
  175. "headfarmphone":null,
  176. "model":"GW77-1500/GW82-1500/UP3000-120/GW109-2500",
  177. "ordernum":3,
  178. "altitude":1000,
  179. "height":null
  180. },
  181. ],
  182. defaultProps: {
  183. children: "data",
  184. label: 'code',
  185. value: 'id',
  186. },
  187. selectValue: '',
  188. typeList: [
  189. {
  190. name: '变频器',
  191. },
  192. {
  193. name: '发电机',
  194. },
  195. {
  196. name: '齿轮箱',
  197. },
  198. {
  199. name: '箱变',
  200. },
  201. {
  202. name: '偏航系统',
  203. },
  204. {
  205. name: '液压站',
  206. },
  207. {
  208. name: '电网',
  209. },
  210. {
  211. name: '风速风向',
  212. },
  213. {
  214. name: '主轴',
  215. },
  216. {
  217. name: '变桨系统',
  218. },
  219. {
  220. name: '安全链',
  221. },
  222. {
  223. name: '机舱柜',
  224. },
  225. {
  226. name: '塔底柜',
  227. },
  228. {
  229. name: '塔筒',
  230. },
  231. {
  232. name: '机舱',
  233. },
  234. {
  235. name: '其他',
  236. },
  237. ],
  238. tableList: [
  239. ],
  240. resultsList: [
  241. {
  242. name: '已处理'
  243. },
  244. {
  245. name: '未处理'
  246. }
  247. ],
  248. typesList: [
  249. {
  250. name: '内报'
  251. },
  252. {
  253. name: '外报'
  254. }
  255. ],
  256. dialogVisible: false,
  257. sendData: {
  258. begindate: '',
  259. enddate: '',
  260. faultphenomenon: '',
  261. defecteliminating: '',
  262. processingresults: '',
  263. powerloss: '',
  264. type: '',
  265. },
  266. isEdit: false,
  267. };
  268. },
  269. created() {
  270. let date = new Date();
  271. this.timeValue[0] = new Date(new Date(new Date().toLocaleDateString()).getTime());
  272. this.timeValue[1] = date.getTime();
  273. this.getStation()
  274. },
  275. methods: {
  276. getStation() {
  277. api.getStation().then(res => {
  278. if (res.data) {
  279. let arr = [
  280. {
  281. id: "",
  282. aname: '全部',
  283. code: "",
  284. }
  285. ]
  286. this.stationList = [ ...arr , ...res.data.data]
  287. console.log(this.stationList);
  288. this.getGroupList(this.stationList[0].code)
  289. this.selectValue = this.stationList[0].id
  290. this.getDatas()
  291. }
  292. })
  293. },
  294. getGroupList(groupId) {
  295. api.getGroupList({
  296. wpid: groupId
  297. }).then(res => {
  298. this.groupList = res.data.data
  299. })
  300. },
  301. handleChange() {
  302. this.getGroupList(this.selectValue)
  303. },
  304. getDatas() {
  305. api.mainrecord({
  306. wpid: this.selectValue,
  307. wtid: this.groupId,
  308. begin: new Date(this.timeValue[0]).getTime(),
  309. end: new Date(this.timeValue[1]).getTime(),
  310. }).then(res => {
  311. if (res.data) {
  312. res.data.data.forEach(item => {
  313. item.showbegindate = dayjs(item.begindate).format("YYYY-MM-DD HH:mm:ss")
  314. item.showenddate = dayjs(item.enddate).format("YYYY-MM-DD HH:mm:ss")
  315. })
  316. this.tableList = res.data.data
  317. }
  318. })
  319. },
  320. add() {
  321. if (this.groupId) {
  322. this.sendData = {
  323. begindate: '',
  324. enddate: '',
  325. defecteliminating: '',
  326. powerloss: '',
  327. type: '',
  328. }
  329. this.dialogVisible = true
  330. this.isEdit = false
  331. } else {
  332. this.$message({
  333. message: '请选择风机',
  334. type: 'warning'
  335. });
  336. }
  337. },
  338. sunmit() {
  339. if (this.isEdit) {
  340. this.sendData.begindate = new Date(this.sendData.begindate).getTime()
  341. this.sendData.enddate = new Date(this.sendData.enddate).getTime()
  342. let pairs = this.sendData
  343. api.mainrecordEdit(pairs).then(res => {
  344. if (res.data) {
  345. this.$message({
  346. type: 'success',
  347. message: '修改成功!'
  348. });
  349. this.dialogVisible = false
  350. this.getDatas()
  351. }
  352. })
  353. } else {
  354. this.sendData.wtid = this.groupId
  355. this.sendData.begindate = new Date(this.sendData.begindate).getTime()
  356. this.sendData.enddate = new Date(this.sendData.enddate).getTime()
  357. let pairs = this.sendData
  358. api.mainrecordAdd(pairs).then(res => {
  359. if (res.data) {
  360. this.$message({
  361. type: 'success',
  362. message: '添加成功!'
  363. });
  364. this.dialogVisible = false
  365. this.getDatas()
  366. }
  367. })
  368. }
  369. },
  370. handleEdit(val) {
  371. this.isEdit = true
  372. this.sendData = val
  373. this.dialogVisible = true
  374. },
  375. handleDelete(val) {
  376. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  377. confirmButtonText: '确定',
  378. cancelButtonText: '取消',
  379. type: 'warning'
  380. }).then(() => {
  381. api.mainrecordDel({
  382. id: val.id
  383. }).then(res => {
  384. if (res.data) {
  385. this.$message({
  386. type: 'success',
  387. message: '删除成功!'
  388. });
  389. this.getDatas()
  390. }
  391. })
  392. }).catch(() => {
  393. this.$message({
  394. type: 'info',
  395. message: '已取消删除'
  396. });
  397. });
  398. },
  399. exportExcel() {
  400. // 数据源
  401. let data = [];
  402. this.tableList.forEach((item) => {
  403. let values = {
  404. 期次: item.projectname,
  405. 场站名称: item.wpname,
  406. 风机名称: item.wtname,
  407. 开始时间: item.showbegindate,
  408. 结束时间: item.showenddate,
  409. 维护内容: item.defecteliminating,
  410. 损失电量: item.powerloss,
  411. 故障时长: item.faultduration,
  412. 时长影响容量: item.impactcapacity,
  413. 内报外报: item.type,
  414. };
  415. data.push(values);
  416. });
  417. // 下载的路径
  418. let fileName = `维护录入.xlsx`;
  419. let filePath = fileName;
  420. // 新建workbook
  421. const wb = XLSX.utils.book_new();
  422. // 新建worksheet,并载入数据
  423. const ws = XLSX.utils.json_to_sheet(data);
  424. // 设置每列的列宽,10代表10个字符,注意中文占2个字符
  425. ws["!cols"] = [{ wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 25 }, { wch: 25 },];
  426. // 生成xlsx文件(workbook,worksheet数据,sheet命名)
  427. XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
  428. // 写文件(workbook,xlsx文件路径+文件名)
  429. XLSX.writeFile(wb, filePath);
  430. },
  431. },
  432. }
  433. </script>
  434. <style lang="less" scoped>
  435. .title-list {
  436. display: flex;
  437. flex-direction: row;
  438. align-items: center;
  439. margin-top: 10px;
  440. .search {
  441. display: flex;
  442. flex-direction: row;
  443. align-items: center;
  444. margin-left: 30px;
  445. .date {
  446. margin-right: 20px;
  447. font-size: 18px;
  448. }
  449. }
  450. .query-item {
  451. display: flex;
  452. flex-direction: row;
  453. align-items: center;
  454. margin-left: 30px;
  455. .lable {
  456. margin-right: 20px;
  457. font-size: 18px;
  458. }
  459. }
  460. .button {
  461. width: 80px;
  462. height: 40px;
  463. margin-left: 30px;
  464. }
  465. }
  466. .table-list {
  467. min-height: 40vh;
  468. }
  469. .lists {
  470. width: 90%;
  471. display: flex;
  472. flex-direction: row;
  473. align-items: center;
  474. justify-content: space-between;
  475. margin: 0 5% 20px 5%;
  476. }
  477. .rows {
  478. display: flex;
  479. flex-direction: row;
  480. align-items: center;
  481. .rows-name {
  482. width: 100px;
  483. }
  484. .rows-input {
  485. width: 400px;
  486. }
  487. .rows-inputs {
  488. width: 220px;
  489. }
  490. }
  491. .submit {
  492. position: absolute;
  493. right: 20px;
  494. bottom: 20px;
  495. }
  496. </style>