projectwData.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. <template>
  2. <!-- 能介上报数据维护 -->
  3. <div class="projectwData">
  4. <div class="box">
  5. <div class="box-top">
  6. <el-form
  7. style="overflow: hidden;"
  8. :style="filterForm.show ? null : { height: '0px' }"
  9. size="mini"
  10. label-width="70px"
  11. >
  12. <el-row>
  13. <el-col :span="6">
  14. <el-form-item label="时间粒度">
  15. <el-select
  16. filterable clearable
  17. v-model="filterForm.data.timegranid"
  18. placeholder=""
  19. style="width: 100%;"
  20. >
  21. <el-option
  22. v-for="item of nameObj.timegranid.arr"
  23. :key="item.id"
  24. :value="item.id"
  25. :label="item.name"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="时间">
  32. <zj-timegran-date
  33. v-model="filterForm.data.clock"
  34. style="width: 100%;"
  35. :type="'daterange'"
  36. :timegranId="filterForm.data.timegranid"
  37. :oneFoo="getTableData"
  38. :defaultOffset="-1"
  39. ></zj-timegran-date>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="6">
  43. <el-form-item label="工序">
  44. <el-select
  45. filterable
  46. clearable
  47. multiple
  48. collapse-tags
  49. v-model="filterForm.data.workprocid"
  50. placeholder=""
  51. style="width: 100%;"
  52. >
  53. <el-option
  54. v-for="item of nameObj.workprocid.arr"
  55. :key="item.id"
  56. :value="item.id"
  57. :label="item.name"
  58. ></el-option>
  59. </el-select>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="6">
  63. <el-form-item label="能介">
  64. <el-select
  65. filterable
  66. clearable
  67. multiple
  68. collapse-tags
  69. v-model="filterForm.data.energyid"
  70. placeholder=""
  71. style="width: 100%;"
  72. >
  73. <el-option
  74. v-for="item of nameObj.energyid.arr"
  75. :key="item.id"
  76. :value="item.id"
  77. :label="item.name"
  78. ></el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. <el-row>
  84. <el-col :span="6">
  85. <el-form-item label="属性">
  86. <el-select
  87. filterable
  88. clearable
  89. multiple
  90. collapse-tags
  91. v-model="filterForm.data.propertyid"
  92. placeholder=""
  93. style="width: 100%;"
  94. >
  95. <el-option
  96. v-for="item of nameObj.propertyid.arr"
  97. :key="item.id"
  98. :value="item.id"
  99. :label="item.name"
  100. ></el-option>
  101. </el-select>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="6">
  105. <el-form-item label="项目编号">
  106. <el-tooltip content="精准查询,多个用逗号隔开" placement="bottom">
  107. <el-input clearable
  108. v-model.trim="filterForm.data.itemid"
  109. placeholder=""
  110. style="width: 100%;"
  111. @keyup.enter.native="getTableData(1)"
  112. ></el-input>
  113. </el-tooltip>
  114. </el-form-item>
  115. </el-col>
  116. <!-- <el-col :span="6">
  117. <el-form-item label="项目名称">
  118. <el-tooltip content="模糊查询" placement="bottom">
  119. <el-input clearable
  120. v-model.trim="filterForm.data.itemname"
  121. placeholder=""
  122. style="width: 100%;"
  123. @keyup.enter.native="getTableData(1)"
  124. ></el-input>
  125. </el-tooltip>
  126. </el-form-item>
  127. </el-col> -->
  128. <el-col :span="6">
  129. <el-form-item label="项目描述">
  130. <el-tooltip content="模糊查询" placement="bottom">
  131. <el-input clearable
  132. v-model.trim="filterForm.data.itemdesc"
  133. placeholder=""
  134. style="width: 100%;"
  135. @keyup.enter.native="getTableData(1)"
  136. ></el-input>
  137. </el-tooltip>
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. </el-form>
  142. <div class="box-top-gjl">
  143. <el-button
  144. class="button"
  145. type="primary"
  146. size="mini"
  147. @click="but_more()"
  148. >保存</el-button>
  149. <el-button
  150. class="button"
  151. type="primary"
  152. size="mini"
  153. icon="el-icon-refresh"
  154. :loading="loading"
  155. @click="but_re_compute()"
  156. >重新计算</el-button>
  157. <el-button
  158. class="button"
  159. type="primary"
  160. size="mini"
  161. v-privilege="activeMenu + 'PUT'"
  162. @click="but_redata()"
  163. :loading="loading"
  164. >重新生成数据</el-button>
  165. <div style="float:right; text-align: right;">
  166. <el-tooltip content="每月1、2号早上9点生成上月数据" placement="left">
  167. <el-button
  168. class="button"
  169. type="primary"
  170. size="mini"
  171. icon="el-icon-search"
  172. v-privilege="activeMenu + 'QUERY'"
  173. @click="getTableData(1)"
  174. >查询</el-button>
  175. </el-tooltip>
  176. <el-button
  177. class="button"
  178. type="primary"
  179. size="mini"
  180. icon="el-icon-refresh"
  181. v-privilege="activeMenu + 'QUERY'"
  182. @click="tableDataCancel();"
  183. >重置</el-button>
  184. <el-button
  185. size="mini"
  186. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  187. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  188. @click="filterForm.show = !filterForm.show;
  189. $nextTick(() => {
  190. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  191. }
  192. );"
  193. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  194. </div>
  195. </div>
  196. </div>
  197. <div class="box-bottom">
  198. <el-form
  199. size="mini"
  200. ref="dialog_form_arr"
  201. label-width="0px"
  202. :model="tableFormDataObj"
  203. >
  204. <el-table
  205. stripe
  206. id="singleTable"
  207. ref="singleTable"
  208. :data="tableData"
  209. v-loading="tableLoading"
  210. style="width: 100%;"
  211. :height="singleTableHeight"
  212. border
  213. size="mini"
  214. highlight-current-row
  215. @selection-change="handleSelectionChange"
  216. :row-class-name="tableRowClassName"
  217. @cell-click="cellClick"
  218. show-summary
  219. :summary-method="getSummaries">
  220. <el-table-column type="selection" width="40" align="center" fixed="left"></el-table-column>
  221. <el-table-column
  222. sortable
  223. prop="timegranid"
  224. label="粒度"
  225. width="52px"
  226. :show-overflow-tooltip="true"
  227. >
  228. <template slot-scope="scope">
  229. <span>{{ nameObj.timegranid.obj[scope.row.timegranid] ? nameObj.timegranid.obj[scope.row.timegranid] : scope.row.timegranid }}</span>
  230. </template>
  231. </el-table-column>
  232. <el-table-column
  233. sortable
  234. prop="clock"
  235. label="时间"
  236. width="65px"
  237. :show-overflow-tooltip="true"
  238. ></el-table-column>
  239. <el-table-column
  240. sortable
  241. prop="itemid"
  242. label="项目编号"
  243. width="105px"
  244. :show-overflow-tooltip="true"
  245. ></el-table-column>
  246. <el-table-column
  247. sortable
  248. prop="workprocid"
  249. label="工序"
  250. width="75px"
  251. :show-overflow-tooltip="true"
  252. :sort-by="function(row, index) { return sortFoo(row, index, 'workprocid') }"
  253. >
  254. <template slot-scope="scope">
  255. <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
  256. </template>
  257. </el-table-column>
  258. <el-table-column
  259. sortable
  260. prop="energyid"
  261. label="能介"
  262. width="75px"
  263. :show-overflow-tooltip="true"
  264. :sort-by="function(row, index) { return sortFoo(row, index, 'energyid') }"
  265. >
  266. <template slot-scope="scope">
  267. <span>{{ nameObj.energyid.obj[scope.row.energyid] ? nameObj.energyid.obj[scope.row.energyid] : scope.row.energyid }}</span>
  268. </template>
  269. </el-table-column>
  270. <el-table-column
  271. sortable
  272. prop="propertyid"
  273. label="属性"
  274. width="60px"
  275. :show-overflow-tooltip="true"
  276. :sort-by="function(row, index) { return sortFoo(row, index, 'propertyid') }"
  277. >
  278. <template slot-scope="scope">
  279. <span>{{ nameObj.propertyid.obj[scope.row.propertyid] ? nameObj.propertyid.obj[scope.row.propertyid] : scope.row.propertyid }}</span>
  280. </template>
  281. </el-table-column>
  282. <!-- <el-table-column
  283. sortable
  284. prop="itemname"
  285. label="项目名称"
  286. width="175px"
  287. :show-overflow-tooltip="true"
  288. ></el-table-column> -->
  289. <el-table-column
  290. sortable
  291. prop="itemdesc"
  292. label="项目描述"
  293. width="150px"
  294. :show-overflow-tooltip="true"
  295. ></el-table-column>
  296. <el-table-column
  297. sortable
  298. prop="productvalue"
  299. label="系统产量(t)"
  300. align="right"
  301. width="85px"
  302. :show-overflow-tooltip="true"
  303. ></el-table-column>
  304. <el-table-column
  305. sortable
  306. prop="ucvalue"
  307. label="系统单耗"
  308. align="right"
  309. width="80px"
  310. :show-overflow-tooltip="true"
  311. > </el-table-column>
  312. <el-table-column
  313. sortable
  314. prop="apportvalue"
  315. label="系统最终值"
  316. align="right"
  317. width="85px"
  318. :show-overflow-tooltip="true"
  319. ></el-table-column>
  320. <!-- <el-table-column
  321. sortable
  322. prop="stdvalue"
  323. label="系统折标值"
  324. width="118px"
  325. :show-overflow-tooltip="true"
  326. ></el-table-column> -->
  327. <el-table-column
  328. sortable
  329. prop="productwvalue"
  330. label="上报产量(t)"
  331. align="right"
  332. width="85px"
  333. :show-overflow-tooltip="true"
  334. ></el-table-column>
  335. <el-table-column
  336. sortable
  337. prop="ucwvalue0"
  338. label="上报单耗"
  339. align="right"
  340. width="80px"
  341. :show-overflow-tooltip="true"
  342. ></el-table-column>
  343. <el-table-column
  344. sortable
  345. prop="apportwvalue"
  346. label="上报最终值"
  347. align="right"
  348. width="110px"
  349. :show-overflow-tooltip="true"
  350. >
  351. <template slot-scope="scope">
  352. <el-form-item
  353. v-if="scope.row.isSelection"
  354. :prop="'s' + scope.row.seq + '.apportwvalue'"
  355. :rules="tableFormRules.numbers"
  356. >
  357. <el-input clearable
  358. style="width: 100%;" @keydown.native="keyDown" :id="scope.column.id + scope.$index"
  359. v-model.trim="tableFormDataObj['s' + scope.row.seq].apportwvalue"
  360. refcous="true"
  361. @change="getUcwvalue(scope.row.seq, 's' + scope.row.seq)"
  362. ></el-input>
  363. </el-form-item>
  364. <span v-else>{{scope.row.apportwvalue}}</span>
  365. </template>
  366. </el-table-column>
  367. <el-table-column
  368. sortable
  369. prop="unitid"
  370. label="最终单位"
  371. width="70px"
  372. :show-overflow-tooltip="true"
  373. >
  374. <template slot-scope="scope">
  375. <span>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
  376. </template>
  377. </el-table-column>
  378. <el-table-column
  379. sortable
  380. prop="upuser"
  381. label="确认人"
  382. width="65px"
  383. :show-overflow-tooltip="true">
  384. </el-table-column>
  385. <el-table-column
  386. sortable
  387. prop="uptime"
  388. label="确认时间"
  389. width="125px"
  390. :show-overflow-tooltip="true"
  391. ></el-table-column>
  392. <el-table-column
  393. sortable
  394. prop="createman"
  395. label="创建人"
  396. width="65px"
  397. :show-overflow-tooltip="true"
  398. ></el-table-column>
  399. <el-table-column
  400. sortable
  401. prop="rectime"
  402. label="创建时间"
  403. width="125px"
  404. :show-overflow-tooltip="true"
  405. ></el-table-column>
  406. <el-table-column
  407. class-name="gn-TableDownloadExcel-none"
  408. label="操作"
  409. align="center"
  410. width="85px"
  411. fixed="right"
  412. >
  413. <template slot-scope="scope">
  414. <div>
  415. <el-button
  416. type="primary"
  417. size="mini"
  418. @click="but_sdata(scope.row)"
  419. >计算过程</el-button>
  420. </div>
  421. </template>
  422. </el-table-column>
  423. </el-table>
  424. </el-form>
  425. <el-pagination
  426. layout="total, sizes, prev, pager, next, jumper"
  427. :total="total"
  428. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  429. :page-size="pageSize"
  430. :current-page.sync="pageNum"
  431. @size-change="tableSizeChange"
  432. @current-change="getTableData()"
  433. style="text-align: right;margin-top: 10px;"
  434. ></el-pagination>
  435. </div>
  436. </div>
  437. </div>
  438. </template>
  439. <script>
  440. import { zCheckNumber1 } from '~/utils/validator.js'
  441. import store from '@/store/index.js';
  442. import timegranDate from '~/components/zg/timegranDate.vue'
  443. import {formatDate, XtcommonSummaries} from '@/utils/util.js';
  444. export default {
  445. name: 'projectwData',
  446. components: {
  447. 'zj-timegran-date': timegranDate
  448. },
  449. data () {
  450. let start = new Date(new Date().getFullYear(), new Date().getMonth() - 1, '01');
  451. return {
  452. rowIndex: '',
  453. columnId: '',
  454. focusTarget: null,
  455. seqArr: [],
  456. editSetFlag: '',
  457. multipleSelection: [],
  458. tableFormDataObj: {},
  459. store,
  460. activeMenu: '',
  461. filterForm: {
  462. show: true,
  463. data: {
  464. timegranid: 'MONTH',
  465. clock: [formatDate(start, 'yyyy-MM'), formatDate(start, 'yyyy-MM')],
  466. workprocid: '',
  467. energyid: '',
  468. propertyid: '',
  469. itemid: '',
  470. itemname: '',
  471. itemdesc: ''
  472. },
  473. rules: {}
  474. },
  475. tableFormRules: {
  476. numbers: [
  477. { validator: zCheckNumber1, trigger: 'change' }
  478. ]
  479. },
  480. pageNum: 1,
  481. pageSize: 100,
  482. total: 0,
  483. singleTableHeight: 100,
  484. tableData: [],
  485. nameObj: {
  486. timegranid: {
  487. obj: {'MONTH': '月', 'YEAR': '年'},
  488. arr: [{id: 'MONTH', name: '月'}, {id: 'YEAR', name: '年'}]
  489. },
  490. workprocid: {
  491. obj: {},
  492. arr: []
  493. },
  494. energyid: {
  495. obj: {},
  496. arr: []
  497. },
  498. propertyid: {
  499. obj: {},
  500. arr: []
  501. },
  502. unitid: {
  503. obj: {},
  504. arr: []
  505. }
  506. },
  507. loading: false,
  508. tableLoading: false,
  509. dialog: {
  510. editorBox: {
  511. type: '',
  512. form: {
  513. data: {
  514. itemid: '',
  515. clock: '',
  516. timegranid: '',
  517. actualvalue: '',
  518. correctvalue: '',
  519. apportvalue: ''
  520. },
  521. rules: {
  522. correctvalue: [
  523. { required: true, message: '该项不能为空', trigger: 'change' },
  524. { validator: zCheckNumber1, trigger: 'change' }
  525. ],
  526. apportvalue: [
  527. { required: true, message: '该项不能为空', trigger: 'change' },
  528. { validator: zCheckNumber1, trigger: 'change' }
  529. ]
  530. }
  531. }
  532. }
  533. }
  534. }
  535. },
  536. created () {
  537. this.activeMenu = window.localStorage.getItem('activeMenu');
  538. },
  539. mounted () {
  540. let that = this;
  541. window.PEDataObj = {
  542. // 将数据绑定到window上,供main页面使用
  543. vm: that,
  544. // tableArr:用于导出成Excel的表格的信息
  545. tableArr: [
  546. {
  547. name: '',
  548. id: 'singleTable'
  549. }
  550. ]
  551. };
  552. that.$nextTick(() => {
  553. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  554. setTimeout(() => {
  555. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  556. }, 1);
  557. });
  558. that.getEnergyIdData();
  559. that.getWorkprocIdData();
  560. that.getPropertyIdData();
  561. that.getUnitIdData();
  562. that.getTableData();
  563. },
  564. methods: {
  565. // 计算树区域高度
  566. getRoleHeight (dom) {
  567. return window.innerHeight - dom.offsetTop;
  568. },
  569. // 用于表格特殊列的过滤方法(:sort-by="function(row, index) { return sortFoo() }")
  570. sortFoo (row, index, objName, name) {
  571. name = name || objName;
  572. let s = this.nameObj[objName].obj[row[name]] ? this.nameObj[objName].obj[row[name]] : row[name];
  573. return s;
  574. },
  575. // 自定义的表格合计方法:只给指定列进行合计
  576. getSummaries (param) {
  577. const prop = ['apportvalue', 'apportwvalue', 'productvalue', 'productwvalue']; // 合计列绑定的prop
  578. return XtcommonSummaries(param, prop);
  579. },
  580. // 获取工序(供需实际)
  581. getWorkprocIdData () {
  582. let that = this;
  583. let url = 'pass/ems/v1/trmworkprocs/getIdAndName?id=ZY3000,ZY4000,ZY5000,ZY6000,ZY7000,ZY8000,ZY9000,ZY9300,ZY9400,ZY0000'; // ZYA000,ZY1000
  584. that.axios.get(url)
  585. .then(function (res) {
  586. if (res.code === '0') {
  587. let arr = [];
  588. let obj = {};
  589. for (let item of res.data) {
  590. arr.push({
  591. id: item.id,
  592. name: item.name
  593. })
  594. obj[item.id] = item.name;
  595. }
  596. that.nameObj.workprocid.arr = arr;
  597. that.nameObj.workprocid.obj = obj;
  598. } else {
  599. that.$message.error(res.message);
  600. }
  601. });
  602. },
  603. // 获取能介(供需实际)
  604. getEnergyIdData () {
  605. let that = this
  606. let url = 'pass/ems/v1/trmenergys/selectNameAndId/?isreal=1';
  607. that.axios.get(url)
  608. .then(function (res) {
  609. if (res.code === '0') {
  610. let arr = [];
  611. let obj = {};
  612. for (let item of res.data) {
  613. arr.push({
  614. id: item.id,
  615. name: item.name
  616. })
  617. obj[item.id] = item.name;
  618. }
  619. that.nameObj.energyid.arr = arr;
  620. that.nameObj.energyid.obj = obj;
  621. } else {
  622. that.$message.error(res.message);
  623. }
  624. });
  625. },
  626. // 获取属性
  627. getPropertyIdData () {
  628. let that = this
  629. let url = 'pass/ems/v1/trmenergypropertys/getidandname/';
  630. that.axios.get(url)
  631. .then(function (res) {
  632. if (res.code === '0') {
  633. let arr = [];
  634. let obj = {};
  635. for (let item of res.data) {
  636. arr.push({
  637. id: item.id,
  638. name: item.name
  639. })
  640. obj[item.id] = item.name;
  641. }
  642. that.nameObj.propertyid.arr = arr;
  643. that.nameObj.propertyid.obj = obj;
  644. } else {
  645. that.$message.error(res.message);
  646. }
  647. });
  648. },
  649. // 获取标准计量单位
  650. getUnitIdData () {
  651. let that = this
  652. let url = 'pass/ems/v1/trmunits/getIdAndName';
  653. that.axios.get(url)
  654. .then(function (res) {
  655. if (res.code === '0') {
  656. let arr = [];
  657. let obj = {};
  658. for (let item of res.data) {
  659. arr.push({
  660. id: item.id,
  661. name: item.name
  662. })
  663. obj[item.id] = item.name;
  664. }
  665. that.nameObj.unitid.arr = arr;
  666. that.nameObj.unitid.obj = obj;
  667. } else {
  668. that.$message.error(res.message);
  669. }
  670. });
  671. },
  672. // 获取表格中的数据
  673. getTableData (pageNum) {
  674. let that = this,
  675. params = {
  676. timegranid: that.filterForm.data.timegranid,
  677. startDate: that.filterForm.data.clock[0],
  678. endDate: that.filterForm.data.clock[1],
  679. workprocid: that.filterForm.data.workprocid.toString(),
  680. energyid: that.filterForm.data.energyid.toString(),
  681. propertyid: that.filterForm.data.propertyid.toString(),
  682. itemid: that.filterForm.data.itemid,
  683. itemname: that.filterForm.data.itemname,
  684. itemdesc: that.filterForm.data.itemdesc
  685. };
  686. that.pageNum = pageNum || that.pageNum;
  687. that.tableLoading = true;
  688. let url = 'pass/ems/v1/trmdwvalues/getProjectwData/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  689. that.axios.get(url, {
  690. params: params
  691. })
  692. .then(function (res) {
  693. if (res.code === '0') {
  694. let arr = [];
  695. for (let i = 0; i < res.data.list.length; i++) {
  696. let item = res.data.list[i];
  697. arr.push({
  698. seq: i,
  699. itemid: item.ITEMID,
  700. clock: item.CLOCK,
  701. timegranid: item.TIMEGRANID,
  702. itemname: item.ITEMNAME,
  703. itemdesc: item.ITEMDESC,
  704. unitid: item.UNITID,
  705. productvalue: item.PRODUCTVALUE,
  706. apportvalue: item.APPORTVALUE,
  707. stdvalue: item.STDVALUE,
  708. ucvalue: item.UCVALUE,
  709. productwvalue: item.PRODUCTWVALUE,
  710. apportwvalue: item.APPORTWVALUE,
  711. stdwvalue: item.STDWVALUE,
  712. ucwvalue: item.UCWVALUE,
  713. ucwvalue0: item.UCWVALUE,
  714. workprocid: item.WORKPROCID,
  715. energyid: item.ENERGYID,
  716. propertyid: item.PROPERTYID,
  717. seqno: item.SEQNO,
  718. showno: item.SHOWNO,
  719. createman: item.CREATEMAN,
  720. rectime: item.REC_TIME,
  721. upuser: item.UPUSER,
  722. uptime: item.UPTIME,
  723. defaultvalue: item.DEFAULTVALUE
  724. })
  725. }
  726. that.tableData = arr;
  727. that.total = res.data.total;
  728. } else {
  729. that.$message.error(res.message);
  730. }
  731. that.tableLoading = false;
  732. }).catch(function () {
  733. that.tableLoading = false;
  734. });
  735. },
  736. // 改变表格显示条数
  737. tableSizeChange (val) {
  738. let that = this;
  739. that.pageSize = val;
  740. that.getTableData(1);
  741. },
  742. // 重置搜索
  743. tableDataCancel () {
  744. let that = this;
  745. for (let key in that.filterForm.data) {
  746. if (that.filterForm.data[key] instanceof Array) {
  747. that.filterForm.data[key] = [];
  748. } else {
  749. that.filterForm.data[key] = '';
  750. }
  751. }
  752. that.getTableData(1);
  753. },
  754. // 计算上报单耗值
  755. getUcwvalue (seq, ids) {
  756. let that = this;
  757. if (that.tableFormDataObj[ids].apportwvalue && that.tableFormDataObj[ids].productwvalue) {
  758. let apportwvalue = that.floatComputed(that.tableFormDataObj[ids].apportwvalue, that.tableFormDataObj[ids].defaultvalue, '*');
  759. let ucwvalue = that.floatComputed(apportwvalue, that.tableFormDataObj[ids].productwvalue, '/');
  760. that.tableFormDataObj[ids].ucwvalue0 = Number(ucwvalue).toFixed(3);
  761. that.showRealValue(seq, that.tableFormDataObj[ids].ucwvalue0);
  762. }
  763. },
  764. // 展示上报单耗值
  765. showRealValue (seq, value) {
  766. let that = this;
  767. for (let i = 0; i < that.tableData.length; i++) {
  768. if (that.tableData[i].seq === seq) {
  769. that.tableData[i].ucwvalue0 = value;
  770. }
  771. }
  772. },
  773. // 批量重新计算
  774. but_re_compute () {
  775. let that = this;
  776. if (that.multipleSelection.length > 0) {
  777. that.$refs['dialog_form_arr'].validate((valid) => {
  778. if (valid) {
  779. let SubmitData = [];
  780. for (let key in that.tableFormDataObj) {
  781. SubmitData.push({
  782. clock: that.tableFormDataObj[key].clock,
  783. timegranid: that.tableFormDataObj[key].timegranid,
  784. itemid: that.tableFormDataObj[key].itemid
  785. });
  786. }
  787. that.loading = true;
  788. that.axios.put('pass/ems/v1/trmdwvalues/batchCompute', SubmitData)
  789. .then(function (res) {
  790. if (res.code === '0') {
  791. that.$message({
  792. message: '重新生成数据成功',
  793. type: 'success'
  794. });
  795. that.getTableData();
  796. } else {
  797. that.$message.error(res.message);
  798. }
  799. that.loading = false;
  800. }).catch(function () {
  801. that.loading = false;
  802. });
  803. }
  804. });
  805. } else {
  806. this.$message.error('至少要选择一条数据');
  807. }
  808. },
  809. // 批量修改
  810. but_more () {
  811. let that = this;
  812. if (that.multipleSelection.length > 0) {
  813. that.$refs['dialog_form_arr'].validate((valid, obj) => {
  814. if (valid) {
  815. let SubmitData = [];
  816. for (let obj in that.tableFormDataObj) {
  817. SubmitData.push({
  818. itemid: that.tableFormDataObj[obj].itemid,
  819. clock: that.tableFormDataObj[obj].clock,
  820. timegranid: that.tableFormDataObj[obj].timegranid,
  821. apportwvalue: that.tableFormDataObj[obj].apportwvalue
  822. })
  823. }
  824. that.loading = true;
  825. that.axios.put('pass/ems/v1/trmdwvalues/batchUpdate', SubmitData)
  826. .then(function (res) {
  827. if (res.code === '0') {
  828. that.$message({
  829. message: '修改成功',
  830. type: 'success'
  831. });
  832. that.getTableData();
  833. } else {
  834. that.$message.error(res.message);
  835. }
  836. that.loading = false;
  837. }).catch(function () {
  838. that.loading = false;
  839. });
  840. } else {
  841. let col = Object.keys(obj)[0].split('.')[1];
  842. if (col && col === 'correctvalue') {
  843. this.$message.error('请填写正确的修正值');
  844. } else if (col && col === 'apportvalue') {
  845. this.$message.error('请填写正确的最终值');
  846. } else {
  847. this.$message.error('数据不完整或者格式错误');
  848. }
  849. }
  850. });
  851. } else {
  852. this.$message.error('至少要选择一条数据');
  853. }
  854. },
  855. // 表格中多选按钮的相关方法
  856. handleSelectionChange (val) {
  857. let that = this;
  858. let tableFormDataObj = {};
  859. let arr = [];
  860. for (let item of val) {
  861. arr.push(item.seq);
  862. }
  863. this.seqArr = arr.sort(sortNumber);
  864. for (let item of that.tableData) {
  865. item.isSelection = false;
  866. }
  867. for (let item of val) {
  868. let obj = {};
  869. let xId = 's' + item.seq;
  870. if (that.tableFormDataObj[xId]) {
  871. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  872. } else {
  873. for (let key in item) {
  874. obj[key] = item[key];
  875. }
  876. tableFormDataObj[xId] = obj;
  877. }
  878. item.isSelection = true;
  879. }
  880. for (let item of that.tableData) {
  881. if (item.isSelection === false) {
  882. item.ucwvalue0 = item.ucwvalue;
  883. }
  884. }
  885. that.tableFormDataObj = tableFormDataObj;
  886. that.multipleSelection = val;
  887. },
  888. tableRowClassName ({row, rowIndex}) {
  889. // 把每一行的索引放进row
  890. row.index = rowIndex;
  891. },
  892. cellClick (row, column, cell, event) {
  893. let _this = this;
  894. this.rowIndex = row.index;
  895. this.columnId = column.id;
  896. _this.editSetFlag = column.id + row.index;
  897. _this.focusTarget = event.target;
  898. while (_this.focusTarget.tagName !== 'TD') {
  899. _this.focusTarget = _this.focusTarget.parentElement;
  900. }
  901. _this.$nextTick(() => {
  902. let target = this.focusTarget;
  903. $(target).find('input').focus();
  904. });
  905. },
  906. keyDown (event1) {
  907. let tdTarget = event1.target;
  908. let _this = this;
  909. while (tdTarget.tagName !== 'TD') {
  910. tdTarget = tdTarget.parentElement;
  911. }
  912. // 如果按下键盘下键或者回车键
  913. if (event.keyCode === 40 || event.keyCode === 13) {
  914. let index = parseInt(this.rowIndex);
  915. if (index !== this.seqArr[this.seqArr.length - 1]) {
  916. for (let i = 0; i < this.seqArr.length; i++) {
  917. if (index === this.seqArr[i]) {
  918. index = this.seqArr[i + 1];
  919. break;
  920. }
  921. }
  922. }
  923. this.editSetFlag = this.columnId + index;
  924. let id = '#' + this.editSetFlag;
  925. this.$nextTick(() => {
  926. $(id).click();
  927. });
  928. } else if (event.keyCode === 38) { // 键盘上键
  929. let index = parseInt(this.rowIndex);
  930. if (index !== this.seqArr[0]) {
  931. for (let i = 0; i < this.seqArr.length; i++) {
  932. if (index === this.seqArr[i]) {
  933. index = this.seqArr[i - 1];
  934. break;
  935. }
  936. }
  937. }
  938. this.editSetFlag = this.columnId + index;
  939. let id = '#' + this.editSetFlag;
  940. this.$nextTick(() => {
  941. $(id).click();
  942. });
  943. } else if (event.keyCode === 37) { // 键盘左键
  944. $(tdTarget).prev().click();
  945. $(tdTarget).prev().find('input').select();
  946. } else if (event.keyCode === 39) { // 键盘右键
  947. $(tdTarget).next().click();
  948. $(tdTarget).next().find('input').select();
  949. }
  950. },
  951. // 重新生成数据
  952. but_redata () {
  953. let that = this;
  954. if (!that.filterForm.data.clock || that.filterForm.data.clock.length === 0) {
  955. that.$message.warning('请选择日期范围');
  956. return true;
  957. }
  958. if (!that.filterForm.data.clock[0] || !that.filterForm.data.clock[1]) {
  959. that.$message.warning('请选择开始日期与结束日期');
  960. return true;
  961. }
  962. if (!that.filterForm.data.timegranid) {
  963. that.$message.warning('请选择时间粒度');
  964. return true;
  965. }
  966. let params = {
  967. timegranid: that.filterForm.data.timegranid,
  968. clock: that.filterForm.data.clock[0], // 开始时间
  969. clocke: that.filterForm.data.clock[1], // 结束时间
  970. workprocid: that.filterForm.data.workprocid.toString(), // 工序
  971. energyid: that.filterForm.data.energyid.toString(), // 能介
  972. propertyid: that.filterForm.data.propertyid.toString(), // 用能属性
  973. itemid: that.filterForm.data.itemid, // 项目编号
  974. itemname: that.filterForm.data.itemname, // 项目名称
  975. itemdesc: that.filterForm.data.itemdesc, // 项目描述
  976. itemtype: 'W' // 上报项目
  977. };
  978. that.$confirm('是否重新生成数据?日期跨度不易太长!否则运行时间较长', '提示', {
  979. confirmButtonText: '确定',
  980. cancelButtonText: '取消',
  981. state: 'warning'
  982. }).then(() => {
  983. that.loading = true;
  984. let url = 'pass/ems/v1/trmactitems/reData'
  985. that.axios.get(url, {
  986. params: params
  987. })
  988. .then(function (res) {
  989. if (res.code === '0') {
  990. if (res.message && res.message !== '操作成功') {
  991. that.$message.warning('重新生成数据成功, 其中【' + res.message + '】');
  992. } else {
  993. that.$message({
  994. message: '重新生成数据成功',
  995. type: 'success'
  996. });
  997. }
  998. that.getTableData();
  999. } else {
  1000. that.$message.error(res.message);
  1001. }
  1002. that.loading = false;
  1003. }).catch(function () {
  1004. that.loading = false;
  1005. });
  1006. }).catch(() => {
  1007. });
  1008. },
  1009. // 计算过程
  1010. but_sdata (row) {
  1011. let that = this;
  1012. let params = {
  1013. timegranid: row.timegranid,
  1014. clock: row.clock, // 开始时间
  1015. itemid: row.itemid // 项目编号
  1016. };
  1017. that.axios.get('pass/ems/v1/formulas/getAnaByVal/', {
  1018. params: params
  1019. }).then(function (res) {
  1020. if (res.code === '0') {
  1021. that.$message({
  1022. dangerouslyUseHTMLString: true,
  1023. message: res.data,
  1024. type: 'success'
  1025. });
  1026. } else {
  1027. that.$message.error(res.message);
  1028. }
  1029. }).catch(function () {});
  1030. }
  1031. }
  1032. }
  1033. function sortNumber (a, b) {
  1034. return a - b
  1035. }
  1036. </script>
  1037. <style lang="less">
  1038. .projectwData {
  1039. min-width: 700px;
  1040. height: 100%;
  1041. .box {
  1042. height: 100%;
  1043. padding: 15px 15px 0 15px;
  1044. .box-top {
  1045. .el-form-item {
  1046. margin-bottom: 7px;
  1047. }
  1048. .box-top-gjl {
  1049. overflow: hidden;
  1050. padding: 7px 0;
  1051. border-top: 1px solid #ccc;
  1052. // margin-bottom: 6px;
  1053. }
  1054. }
  1055. }
  1056. .el-table__body .el-form-item--mini.el-form-item {
  1057. margin: 0px;
  1058. .error {
  1059. overflow: hidden;
  1060. color: #f56c6c;
  1061. font-size: 12px;
  1062. line-height: 1;
  1063. }
  1064. }
  1065. .el-table__body input {
  1066. font-weight: normal;
  1067. padding-left: 8px;
  1068. padding-right: 25px;
  1069. }
  1070. }
  1071. </style>