balanceData2.vue 52 KB

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