dqparsing.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="app-container">
  3. <div class="dark-el-button">
  4. <el-button type="primary" icon="el-icon-plus" @click="handleAdd" class="myButton">新增</el-button>
  5. </div>
  6. <!--上报对象表格-->
  7. <el-table
  8. :data="tableData"
  9. :header-cell-style="{background:'#ECF1FE',}"
  10. v-loading="tableLoading" border style="width: 100%">
  11. <!-- <el-table-column prop="fileName" align="center" label="文件名关键字" width="200px"></el-table-column>-->
  12. <el-table-column prop="dataType" align="center" label="数据类型" width="100px" :formatter="formatDataType"></el-table-column>
  13. <el-table-column prop="forecastTime" align="center" label="预测时间公式"></el-table-column>
  14. <el-table-column prop="fpValue" align="center" label="预测数据公式"></el-table-column>
  15. <el-table-column prop="openCapacity" align="center" label="预计开机容量公式"></el-table-column>
  16. <el-table-column prop="capacity" align="center" label="装机容量公式"></el-table-column>
  17. <!-- <el-table-column prop="stationCode" align="center" label="场站编号"></el-table-column>-->
  18. <el-table-column label="操作" align="center" width="150px">
  19. <template slot-scope="scope">
  20. <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
  21. <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. <div class="block">
  26. <el-pagination
  27. @size-change="handleSizeChange"
  28. @current-change="handleCurrentChange"
  29. :current-page=this.page.currentPage
  30. :page-sizes="[10, 15, 30, 50]"
  31. :page-size=this.page.pageSize
  32. layout="total, sizes, prev, pager, next, jumper"
  33. :total=this.page.total>
  34. </el-pagination>
  35. </div>
  36. <!--编辑框-->
  37. <div class="dark-el-dialog">
  38. <el-dialog :title="saveFlag==1?'新增':'编辑'" :visible.sync="visible" width="100%">
  39. <el-row :gutter="20">
  40. <el-col :span="16">
  41. <div>
  42. <span style="color: red">
  43. <font size="4px">灰色文本框需要点击后,在右侧进行编辑录入!</font>
  44. </span>
  45. </div>
  46. &nbsp;
  47. <div class="grid-content bg-purple">
  48. <el-form v-model="form" ref="form" :key="timer">
  49. <el-row :gutter="16">
  50. <!-- <el-col :span="12">-->
  51. <!-- <el-form-item prop="fileName" label-width="110px">-->
  52. <!-- <span slot="label">-->
  53. <!-- <font color="red">*</font>文件名关键字-->
  54. <!-- </span>-->
  55. <!-- <el-input v-model="form.fileName" @focus="clearformula"></el-input>-->
  56. <!-- </el-form-item>-->
  57. <!-- </el-col>-->
  58. <el-col :span="12">
  59. <el-form-item prop="dataType" label-width="110px">
  60. <span slot="label">
  61. <font color="red">*</font>数据类型
  62. </span>
  63. <el-select popper-class="cpp-popper" v-model="form.dataType" clearable @focus="clearformula">
  64. <el-option
  65. v-for="item in this.dataType"
  66. :key="item.value"
  67. :label="item.label"
  68. :value="item.value"/>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. <el-row :gutter="16">
  74. <el-col :span="12">
  75. <el-form-item prop="fpValue" label-width="110px" class="formulaColor">
  76. <span slot="label">
  77. <font color="red">*</font>预测数据公式
  78. </span>
  79. <el-input v-model="form.fpValue" readonly
  80. @click.native="ftck(form.fpValue,'form.fpValue','(预测数据)')"></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="12">
  84. <el-form-item prop="forecastTime" label-width="110px"
  85. class="formulaColor">
  86. <span slot="label">
  87. <font color="red">*</font>预测时间公式
  88. </span>
  89. <el-input v-model="form.forecastTime" readonly
  90. @click.native="ftck(form.forecastTime,'form.forecastTime','(预测时间)')"></el-input>
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. <el-row :gutter="16">
  95. <el-col :span="12">
  96. <el-form-item prop="openCapacity" label-width="110px" class="formulaColor">
  97. <span slot="label">
  98. <font color="red">*</font>预计开机容量公式
  99. </span>
  100. <el-input v-model="form.openCapacity" readonly
  101. @click.native="ftck(form.openCapacity,'form.openCapacity','(预计开机容量)')"></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="12">
  105. <el-form-item prop="capacity" label-width="110px"
  106. class="formulaColor">
  107. <span slot="label">
  108. <font color="red">*</font>装机容量公式
  109. </span>
  110. <el-input v-model="form.capacity" readonly
  111. @click.native="ftck(form.capacity,'form.capacity','(装机容量)')"></el-input>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. <!-- <el-row>-->
  116. <!-- <el-col :span="24">-->
  117. <!-- <el-form-item prop="stationCode" label-width="110px">-->
  118. <!-- <span slot="label">-->
  119. <!-- <font color="red">*</font>场站编号-->
  120. <!-- </span>-->
  121. <!-- <el-select popper-class="cpp-popper" v-model="form.stationCode" multiple clearable @focus="clearformula" style="width: 100%">-->
  122. <!-- <el-option-->
  123. <!-- v-for="item in this.stationCodeList"-->
  124. <!-- :key="item.stationCode"-->
  125. <!-- :label="item.stationCode"-->
  126. <!-- :value="item.stationCode"/>-->
  127. <!-- </el-select>-->
  128. <!-- </el-form-item>-->
  129. <!-- </el-col>-->
  130. <!-- </el-row>-->
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="handleSave('form')">
  134. <span v-if="saveFlag == 1">保 存</span>
  135. <span v-else>修 改</span>
  136. </el-button>
  137. <el-button @click="visible = false">取 消</el-button>
  138. </div>
  139. </div>
  140. </el-col>
  141. <el-col :span="1">
  142. <el-divider direction="vertical"></el-divider>
  143. </el-col>
  144. <el-col :span="6">
  145. <h2>公式编辑区{{ this.editinfo }}</h2>
  146. <el-form>
  147. <el-row>
  148. <el-col>
  149. <el-form-item prop="rownumber" label-width="110px">
  150. <span slot="label">
  151. <font color="red">*</font>解析行
  152. </span>
  153. <el-input v-model="pfform.rownumber"></el-input>
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. <el-row>
  158. <el-col>
  159. <el-form-item prop="columnumber" label-width="110px">
  160. <span slot="label">
  161. <font color="red">*</font>解析列
  162. </span>
  163. <el-input v-model="pfform.columnumber"></el-input>
  164. </el-form-item>
  165. </el-col>
  166. </el-row>
  167. <el-row>
  168. <el-col>
  169. <el-form-item label="标签名" prop="signname" label-width="110px">
  170. <el-input v-model="pfform.signname"></el-input>
  171. </el-form-item>
  172. </el-col>
  173. </el-row>
  174. <el-row>
  175. <el-col>
  176. <el-form-item label="时间格式" prop="timeformat" label-width="110px">
  177. <el-select popper-class="cpp-popper" v-model="pfform.timeformat" clearable>
  178. <el-option
  179. v-for="item in this.timeFormat"
  180. :key="item.value"
  181. :label="item.label"
  182. :value="item.value"/>
  183. </el-select>
  184. </el-form-item>
  185. </el-col>
  186. </el-row>
  187. <el-row>
  188. <el-button type="primary" @click="genformula">
  189. <span>生成公式</span>
  190. </el-button>
  191. <el-button type="primary" @click="destoryformula">
  192. <span>清除录入</span>
  193. </el-button>
  194. </el-row>
  195. </el-form>
  196. </el-col>
  197. </el-row>
  198. </el-dialog>
  199. </div>
  200. </div>
  201. </template>
  202. <script>
  203. export default {
  204. name: "index",
  205. data() {
  206. return {
  207. // stationCodeList: [],
  208. dataType: [
  209. {value: 's', label: '时间单行'},
  210. {value: 'm', label: '时间多行'}
  211. ],
  212. timeFormat: [
  213. {value: 'yyyy-MM-dd HH:mm:ss', label: 'yyyy-MM-dd HH:mm:ss'},
  214. {value: 'yyyy-MM-dd', label: 'yyyy-MM-dd'},
  215. {value: 'yyyy-MM-dd_HH:mm', label: 'yyyy-MM-dd_HH:mm'},
  216. {value: 'yyyy-MM-dd_HH:mm:ss', label: 'yyyy-MM-dd_HH:mm:ss'}
  217. ],
  218. editinfo: '',
  219. timer: new Date().getTime(),
  220. props: {multiple: true},
  221. staionList: [],//场站集合
  222. tableLoading: false,
  223. tableData: [],
  224. page: {
  225. total: 0, // 总页数
  226. currentPage: 1, // 当前页数
  227. pageSize: 10 // 每页显示多少条
  228. },
  229. info: '',
  230. visible: false,
  231. form: {
  232. // fileName: '',
  233. forecastTime: '',
  234. fpValue: '',
  235. dataType: 'm',
  236. // stationCode: ''
  237. openCapacity: '',
  238. capacity: ''
  239. },
  240. pfform: {
  241. rownumber: '',
  242. columnumber: '',
  243. signname: '',
  244. timeformat: ''
  245. },
  246. tempformulasign: '',
  247. saveFlag: 1
  248. };
  249. },
  250. mounted() {
  251. // this.getElectricFieldList()
  252. this.getTableList()
  253. },
  254. methods: {
  255. formatDataType(row, column) {
  256. let belongTo = '未知类型'
  257. for (let i = 0; i < this.dataType.length; i++) {
  258. if (row.dataType === this.dataType[i].value) {
  259. belongTo = this.dataType[i].label
  260. }
  261. }
  262. return belongTo
  263. },
  264. getTableList() {
  265. this.tableLoading = true
  266. const page = this.page
  267. // 获取列表
  268. this.$axios.get("/parsingDq/page", {
  269. params: {
  270. currentPage: page.currentPage,
  271. pageSize: page.pageSize
  272. }
  273. }).then(response => {
  274. this.tableData = response.data.records
  275. this.page.total = response.data.total
  276. this.tableLoading = false
  277. }).catch((e) => {
  278. this.tableLoading = false
  279. })
  280. },
  281. // getElectricFieldList() {
  282. // // 获取所有场站
  283. // this.$axios("/parsingInfo/getElectricField").then(response => {
  284. // this.stationCodeList = response.data
  285. // this.tableLoading = false
  286. // }).catch((e) => {
  287. // this.tableLoading = false
  288. // })
  289. // },
  290. destoryformula() {
  291. // 清空公式区字段
  292. if (this.tempformulasign == 'form.forecastTime') {
  293. this.form.forecastTime = ''
  294. } else if (this.tempformulasign == 'form.fpValue') {
  295. this.form.fpValue = ''
  296. }
  297. this.clearformula()
  298. },
  299. clearformula() {
  300. // 清空公式区字段
  301. this.pfform.rownumber = ''
  302. this.pfform.columnumber = ''
  303. this.pfform.signname = ''
  304. this.pfform.timeformat = ''
  305. this.editinfo = ''
  306. this.tempformulasign = ''
  307. },
  308. ftck(obj, sign, editname) {
  309. this.clearformula()
  310. if (obj != undefined && obj != null) {
  311. var objs = obj.split('<=>')
  312. for (let i = 0; i < objs.length; i++) {
  313. if (objs[i] != "") {
  314. if (i == 0) {
  315. this.pfform.rownumber = objs[i]
  316. } else if (i == 1) {
  317. this.pfform.columnumber = objs[i]
  318. } else if (i == 2) {
  319. this.pfform.signname = objs[i]
  320. } else if (i == 3) {
  321. this.pfform.timeformat = objs[i]
  322. }
  323. }
  324. }
  325. }
  326. this.tempformulasign = sign;
  327. this.editinfo = editname
  328. },
  329. genformula() {
  330. if (this.tempformulasign == '') {
  331. this.$message.warning('请先选定左侧公式项')
  332. return
  333. }
  334. if (!this.pfform.rownumber || !this.pfform.columnumber) {
  335. this.$message.warning('填写必填项')
  336. return
  337. }
  338. if ((this.pfform.signname && !this.pfform.timeformat) || (!this.pfform.signname && this.pfform.timeformat)) {
  339. this.$message.warning('标签名称和时间格式要同时填写')
  340. return
  341. }
  342. // 拼装公式
  343. var resultStr = ''
  344. if (this.pfform.rownumber) {
  345. resultStr = this.pfform.rownumber
  346. }
  347. if (this.pfform.columnumber) {
  348. resultStr = resultStr + '<=>' + this.pfform.columnumber
  349. }
  350. if (this.pfform.signname) {
  351. resultStr = resultStr + '<=>' + this.pfform.signname
  352. }
  353. if (this.pfform.timeformat) {
  354. resultStr = resultStr + '<=>' + this.pfform.timeformat
  355. }
  356. // 将生成的公式赋值到左侧表格中
  357. if (this.tempformulasign == 'form.forecastTime') {
  358. this.form.forecastTime = resultStr
  359. } else if (this.tempformulasign == 'form.fpValue') {
  360. this.form.fpValue = resultStr
  361. } else if (this.tempformulasign == 'form.openCapacity') {
  362. this.form.openCapacity = resultStr
  363. } else if (this.tempformulasign == 'form.capacity') {
  364. this.form.capacity = resultStr
  365. }
  366. this.timer = new Date().getTime()
  367. this.clearformula()
  368. },
  369. /*保存*/
  370. handleSave(formName) {
  371. if (!this.form.forecastTime || !this.form.fpValue || !this.form.dataType
  372. // !this.form.fileName || || this.form.stationCode == ""
  373. ) {
  374. this.$message.warning('填写必填项');
  375. return false;
  376. } else {
  377. // const data = this.form.stationCode
  378. // let data1 = "";
  379. // for (let n = 0; n < data.length; n++) {
  380. // for (let j = 0; j < this.stationCodeList.length; j++) {
  381. // if (data[n] == this.stationCodeList[j]["stationCode"]) {
  382. // data1 = data1 + this.stationCodeList[j]["stationCode"] + ","
  383. // }
  384. // }
  385. // }
  386. // data1 = data1.substr(0, data1.length - 1)
  387. // this.form.stationCode = data1
  388. if (this.saveFlag === 1) {
  389. console.log(this.form)
  390. this.$axios.post("/parsingDq", this.form).then(response => {
  391. this.dialogVisible = false
  392. this.getTableList()
  393. this.tableLoading = false
  394. this.$message.success(response.data)
  395. }).catch(() => {
  396. this.tableLoading = false
  397. })
  398. } else {
  399. this.$axios.put("/parsingDq", this.form).then(response => {
  400. this.dialogVisible = false
  401. this.getTableList()
  402. this.tableLoading = false
  403. this.$message.success(response.data)
  404. }).catch(() => {
  405. this.tableLoading = false
  406. })
  407. }
  408. this.visible = false
  409. }
  410. },
  411. /*上报对象*/
  412. handleAdd() {
  413. this.saveFlag = 1
  414. this.info = ''
  415. this.form ={
  416. // fileName: '',
  417. forecastTime: '',
  418. fpValue: '',
  419. dataType: 'm',
  420. // stationCode: ''
  421. openCapacity: '',
  422. capacity: ''
  423. }
  424. this.clearformula()
  425. this.visible = true
  426. },
  427. /*上报对象编辑*/
  428. handleEdit(row) {
  429. this.saveFlag = 2
  430. let newRow = Object.assign({}, row)
  431. // let tempStationCode = newRow.stationCode.split(',')
  432. this.form = newRow
  433. // this.form.stationCode = tempStationCode
  434. this.clearformula()
  435. this.visible = true
  436. },
  437. /*上报对象删除*/
  438. handleDelete(row) {
  439. this.$confirm('是否确认删除此条配置?', '提示', {
  440. confirmButtonText: '确定',
  441. cancelButtonText: '取消',
  442. type: 'warning'
  443. }).then(() => {
  444. this.$axios.delete("/parsingDq/" + row.id).then(response => {
  445. this.getTableList()
  446. this.$message.success(response.data)
  447. })
  448. })
  449. },
  450. /*上报对象pageSize改变*/
  451. handleSizeChange(val) {
  452. this.page.pageSize = val
  453. this.page.currentPage = 1
  454. this.getTableList()
  455. },
  456. /*上报对象currentPage改变*/
  457. handleCurrentChange(val) {
  458. this.page.currentPage = val
  459. this.getTableList()
  460. }
  461. }
  462. }
  463. </script>
  464. <style scoped>
  465. .block {
  466. float: right;
  467. }
  468. .myButton {
  469. margin-bottom: .5%;
  470. }
  471. .uploadno {
  472. background: #2d8cf0;
  473. width: 20px;
  474. height: 20px;
  475. border-radius: 50%;
  476. text-align: center;
  477. display: inline-block;
  478. color: #fff;
  479. }
  480. .el-divider--vertical {
  481. display: inline-block;
  482. width: 1px;
  483. height: 35em;
  484. margin: 0 8px;
  485. vertical-align: middle;
  486. position: relative;
  487. }
  488. /deep/ .formulaColor .el-input--small .el-input__inner {
  489. height: 32px;
  490. line-height: 32px;
  491. background-color: rgba(204, 204, 204, 0.5);
  492. }
  493. </style>