energyDispatch.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <!-- 能源调度日志 -->
  3. <div class="energyDispatch">
  4. <div class="box">
  5. <p class="bt">能源调度日志</p>
  6. <div class="box-top-gjl">
  7. </div>
  8. <el-row>
  9. <el-col :span="8">
  10. <div class="text-box">
  11. <span class="label">日志日期</span>
  12. <div class="text">
  13. <el-date-picker
  14. size="mini"
  15. v-model="clock"
  16. style="width: 100%;"
  17. type="date"
  18. @change="getMd"
  19. ></el-date-picker>
  20. </div>
  21. </div>
  22. </el-col>
  23. <el-col :span="16">
  24. <div style="float:right; text-align: right;">
  25. <el-button size="small" type="primary" @click="dataSave" :loading="loading">保存</el-button>
  26. </div>
  27. </el-col>
  28. </el-row>
  29. <el-row>
  30. <el-col :span="16">
  31. <el-form
  32. size="mini"
  33. ref="dialog_form_arr"
  34. label-width="0px"
  35. >
  36. <el-table stripe
  37. :data="tableData"
  38. style="width: 100%;"
  39. :height="'500px'"
  40. border
  41. size="mini"
  42. >
  43. <el-table-column
  44. sortable
  45. prop="time"
  46. label="时间"
  47. width="190px"
  48. >
  49. <template slot-scope="scope">
  50. <el-date-picker
  51. @change="checkt"
  52. value-format="yyyy-MM-dd HH:mm:ss"
  53. type="datetime"
  54. v-model="scope.row.tim"
  55. size="mini"
  56. style="width: 100%;"
  57. ></el-date-picker>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. sortable
  62. prop="actLog"
  63. label="工作实绩"
  64. min-width="100px"
  65. >
  66. <template slot-scope="scope">
  67. <el-input clearable
  68. v-model="scope.row.actLog"
  69. size="mini"
  70. style="width: 100%;"
  71. ></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. sortable
  76. prop="dataLog"
  77. label="数据"
  78. min-width="100px"
  79. >
  80. <template slot-scope="scope">
  81. <el-input clearable
  82. v-model="scope.row.dataLog"
  83. size="mini"
  84. style="width: 100%;"
  85. ></el-input>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作" width="70" align="center">
  89. <template slot-scope="scope">
  90. <el-button @click.native.prevent="deleteRow(scope.$index, scope.row)" type="text" size="small">移除</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </el-form>
  95. </el-col>
  96. <el-col :span="8">
  97. <div class="text">
  98. <p class="label">上级命令:</p>
  99. <textarea v-model="orderLog" :maxlength="300" clearable></textarea>
  100. </div>
  101. <div class="text">
  102. <p class="label">重要记事:</p>
  103. <textarea v-model="dLog" :maxlength="300" clearable></textarea>
  104. </div>
  105. </el-col>
  106. </el-row>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { getCookie, formatDate } from '@/utils/util.js';
  112. export default {
  113. name: 'energyDispatch',
  114. data () {
  115. return {
  116. clock: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1),
  117. orderLog: '', // 上级命令
  118. dLog: '', // 重要记事
  119. loading: false,
  120. tableData: [
  121. // {
  122. // tim: '2019-08-23 18:00:00',
  123. // actLog: 'actLog',
  124. // dataLog: 'dataLog'
  125. // }
  126. ]
  127. }
  128. },
  129. mounted () {
  130. let that = this;
  131. that.clock = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1);
  132. that.getMd(that.clock);
  133. },
  134. methods: {
  135. dataSave () {
  136. let that = this;
  137. if (!that.clock) {
  138. this.$message.error('请填写日志日期');
  139. return true;
  140. }
  141. let SubmitData = {
  142. clock: formatDate(that.clock, 'yyyy-MM-dd'),
  143. dLog: that.dLog,
  144. orderLog: that.orderLog,
  145. data: that.tableData
  146. };
  147. that.loading = true;
  148. that.axios.post('pass/ems/v1/dispatchenergylogs/', SubmitData, {contentType: 'application/json'})
  149. .then(function (res) {
  150. if (res.code === '0') {
  151. that.$message({
  152. message: '数据保存成功',
  153. type: 'success'
  154. });
  155. } else {
  156. that.$message.error(res.message);
  157. }
  158. that.loading = false;
  159. }).catch(function () {
  160. that.loading = false;
  161. });
  162. },
  163. // 获取日志信息
  164. getMd (val) {
  165. if (!val) {
  166. return true;
  167. }
  168. let that = this;
  169. that.tableData = [];
  170. that.orderLog = '';
  171. that.dLog = '';
  172. let url = 'pass/ems/v1/dispatchenergylogs/' + formatDate(val, 'yyyy-MM-dd');
  173. that.axios.get(url).then(function (res) {
  174. if (res.code === '0') {
  175. if (res.data != null) {
  176. that.orderLog = res.data.orderLog;
  177. that.dLog = res.data.dLog;
  178. let tdata = res.data.list;
  179. if (tdata.length < 1 || tdata.slice(-1)[0].tim) {
  180. tdata.splice(tdata.length, 0, {tim: '', actLog: '', dataLog: ''});
  181. }
  182. that.tableData = tdata;
  183. }
  184. } else {
  185. that.$message.error(res.message);
  186. }
  187. }).catch(function () {
  188. });
  189. },
  190. checkt () {
  191. let that = this;
  192. // 添加一行
  193. if (that.tableData.slice(-1)[0].tim) {
  194. that.tableData.splice(that.tableData.length, 0, {tim: '', actLog: '', dataLog: ''});
  195. }
  196. },
  197. deleteRow (index, row) {
  198. let that = this;
  199. // 最后一行
  200. if (that.tableData.length === index + 1) {
  201. that.tableData.splice(index, 1, {tim: '', actLog: '', dataLog: ''});
  202. } else {
  203. that.tableData.splice(index, 1);
  204. }
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="less">
  210. .energyDispatch {
  211. min-width: 1000px;
  212. height: 100%;
  213. .box {
  214. width: 1000px;
  215. margin: 0 0 0 10px;
  216. .bt {
  217. font-size: 16px;
  218. font-weight: 600;
  219. text-align: center;
  220. padding: 20px 10px 2px 10px;
  221. }
  222. .box-top-gjl {
  223. overflow: hidden;
  224. padding: 0 0 10px 0;
  225. }
  226. .text-box {
  227. height: 32px;
  228. .label {
  229. width: 80px;
  230. line-height: 32px;
  231. padding-right: 8px;
  232. display: block;
  233. text-align: right;
  234. float: left;
  235. }
  236. .text {
  237. height: 100%;
  238. margin:0 0 0 80px;
  239. padding:0;
  240. border: none;
  241. }
  242. }
  243. .text {
  244. height: 245px;
  245. position: relative;
  246. padding-top: 25px;
  247. margin: 0 0 10px 20px;
  248. border: 1px #c0c4cc solid;
  249. // border-radius: 4px;
  250. overflow: hidden;
  251. .label {
  252. position: absolute;
  253. top: 0;
  254. left: 0;
  255. width: 100%;
  256. height: 25px;
  257. padding: 1px 5px;
  258. background-color: #45A4F9;
  259. color: #FFF;
  260. }
  261. textarea {
  262. width: 100%;
  263. height: 100%;
  264. padding: 5px 8px;
  265. border: none;
  266. }
  267. }
  268. }
  269. }
  270. </style>