indexDataMaintain.vue 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. <template>
  2. <!-- 指标数据维护 -->
  3. <div class="indexDataMaintain">
  4. <div class="box">
  5. <div class="box-left" :style="listTopicTree.show ? null : { width: '22px' }">
  6. <div class="box-left-bt" style="overflow: hidden;">
  7. <span v-show="listTopicTree.show">指标</span>
  8. <div style="float: right;height: 100%;padding-right: 4px;">
  9. <span
  10. class="el-icon-d-arrow-right"
  11. style="cursor: pointer; transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;"
  12. :style="listTopicTree.show ? { transform: 'rotate(180deg)'} : { transform: 'rotate(0deg)'} "
  13. @click="listTopicTree.show = !listTopicTree.show;"
  14. ></span>
  15. </div>
  16. </div>
  17. <div class="box-left-tree">
  18. <el-tree
  19. v-show="listTopicTree.show"
  20. :data="listTopicTree.data"
  21. :props="listTopicTree.defaultProps"
  22. :load="loadNode"
  23. lazy
  24. v-loading="listTopicTree.loading"
  25. >
  26. <span
  27. class="custom-tree-node"
  28. :class="{'tree-row-on': filterForm.node.id === data.id}"
  29. style="width:100%; font-size:12px;"
  30. slot-scope="{ node, data }"
  31. >
  32. <p
  33. style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap;"
  34. :title="node.label"
  35. @click="selectByTopicId(data)"
  36. >{{ node.label }}</p>
  37. </span>
  38. </el-tree>
  39. </div>
  40. </div>
  41. <div class="box-right" :style="listTopicTree.show ? null : { 'margin-left': '22px' }">
  42. <div class="box-top">
  43. <div style="border-bottom: 1px solid #ccc;overflow: hidden;">
  44. <el-form
  45. style="overflow: hidden;"
  46. :style="filterForm.show ? null : { height: '0px' }"
  47. class="box-top-form"
  48. size="mini"
  49. label-width="70px"
  50. >
  51. <el-row>
  52. <el-col :span="8">
  53. <el-form-item label="时间粒度">
  54. <el-select
  55. filterable clearable
  56. v-model="filterForm.data.timegranid"
  57. placeholder=""
  58. style="width: 100%;"
  59. >
  60. <el-option
  61. v-for="item of nameObj.timegranid.arr"
  62. :key="item.id"
  63. :value="item.id"
  64. :label="item.name"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="8">
  70. <el-form-item label="时间">
  71. <zj-timegran-date
  72. v-model="filterForm.data.clock"
  73. style="width: 100%;"
  74. :type="'daterange'"
  75. :timegranId="filterForm.data.timegranid"
  76. :defaultOffset="-1"
  77. ></zj-timegran-date>
  78. </el-form-item>
  79. <!-- <el-form-item label="时间">
  80. <zj-timegran-date
  81. v-model="filterForm.data.clock"
  82. style="width: 100%;"
  83. :timegranId="filterForm.data.timegranid"
  84. :oneFoo="getTableData"
  85. ></zj-timegran-date>
  86. </el-form-item> -->
  87. </el-col>
  88. <el-col :span="8">
  89. <el-form-item label="项目编号">
  90. <el-input clearable
  91. v-model="filterForm.data.itemid"
  92. placeholder=""
  93. style="width: 100%;"
  94. @keyup.enter.native="getTableData(1)"
  95. ></el-input>
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. <el-row>
  100. <el-col :span="8">
  101. <el-form-item label="项目名称">
  102. <el-input clearable
  103. v-model="filterForm.data.itemname"
  104. placeholder=""
  105. style="width: 100%;"
  106. @keyup.enter.native="getTableData(1)"
  107. ></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-form-item label="用途">
  112. <el-select
  113. filterable clearable
  114. v-model="filterForm.data.itemtype"
  115. placeholder=""
  116. multiple
  117. collapse-tags
  118. style="width: 100%;"
  119. >
  120. <el-option
  121. v-for="item of nameObj.itemtype.arr"
  122. :key="item.id"
  123. :value="item.id"
  124. :label="item.name"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="8">
  130. <el-form-item label="指标类型">
  131. <el-select
  132. filterable clearable
  133. style="width: 100%;"
  134. v-model="filterForm.data.indextype"
  135. disabled
  136. >
  137. <el-option
  138. v-for="item of nameObj.indextype.arr"
  139. :key="item.id"
  140. :value="item.id"
  141. :label="item.name"
  142. ></el-option>
  143. </el-select>
  144. </el-form-item>
  145. </el-col>
  146. </el-row>
  147. <!-- <el-row>
  148. <el-col :span="8">
  149. <el-form-item label="指标类型1">
  150. <el-select
  151. filterable clearable
  152. v-model="filterForm.data.type1"
  153. placeholder=""
  154. style="width: 100%;"
  155. >
  156. <el-option
  157. v-for="item of nameObj.type1.arr"
  158. :key="item.id"
  159. :value="item.id"
  160. :label="item.name"
  161. ></el-option>
  162. </el-select>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="8">
  166. <el-form-item label="指标类型2">
  167. <el-select
  168. filterable clearable
  169. v-model="filterForm.data.type2"
  170. placeholder=""
  171. style="width: 100%;"
  172. >
  173. <el-option
  174. v-for="item of nameObj.type2.arr"
  175. :key="item.id"
  176. :value="item.id"
  177. :label="item.name"
  178. ></el-option>
  179. </el-select>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="8">
  183. <el-form-item label="指标类型3">
  184. <el-select
  185. filterable clearable
  186. v-model="filterForm.data.type3"
  187. placeholder=""
  188. style="width: 100%;"
  189. >
  190. <el-option
  191. v-for="item of nameObj.type3.arr"
  192. :key="item.id"
  193. :value="item.id"
  194. :label="item.name"
  195. ></el-option>
  196. </el-select>
  197. </el-form-item>
  198. </el-col>
  199. </el-row> -->
  200. <el-row>
  201. <el-col :span="8">
  202. <el-form-item label="能介">
  203. <el-select
  204. filterable clearable
  205. v-model="filterForm.data.energyid"
  206. placeholder=""
  207. multiple
  208. collapse-tags
  209. style="width: 100%;"
  210. >
  211. <el-option
  212. v-for="item of nameObj.energyid.arr"
  213. :key="item.id"
  214. :value="item.id"
  215. :label="item.name"
  216. ></el-option>
  217. </el-select>
  218. </el-form-item>
  219. </el-col>
  220. <el-col :span="8">
  221. <el-form-item label="工序">
  222. <el-select
  223. filterable clearable
  224. v-model="filterForm.data.workprocid"
  225. placeholder=""
  226. multiple
  227. collapse-tags
  228. style="width: 100%;"
  229. >
  230. <el-option
  231. v-for="item of nameObj.workprocid.arr"
  232. :key="item.id"
  233. :value="item.id"
  234. :label="item.name"
  235. ></el-option>
  236. </el-select>
  237. </el-form-item>
  238. </el-col>
  239. <el-col :span="8">
  240. <el-form-item label="工厂">
  241. <el-select
  242. filterable clearable
  243. v-model="filterForm.data.factoryid"
  244. placeholder=""
  245. style="width: 100%;"
  246. >
  247. <el-option
  248. v-for="item of nameObj.factoryid.arr"
  249. :key="item.id"
  250. :value="item.id"
  251. :label="item.name"
  252. ></el-option>
  253. </el-select>
  254. </el-form-item>
  255. </el-col>
  256. </el-row>
  257. </el-form>
  258. </div>
  259. </div>
  260. <div class="box-top-gjl">
  261. <el-button
  262. class="button"
  263. type="primary"
  264. size="mini"
  265. icon="el-icon-edit-outline"
  266. v-privilege="activeMenu + 'PUT'"
  267. @click="but_edit_plural()"
  268. :loading="loading"
  269. >修改</el-button>
  270. <el-button
  271. class="button"
  272. type="primary"
  273. size="mini"
  274. icon="el-icon-refresh"
  275. v-privilege="activeMenu + 'PUT'"
  276. :loading="loading"
  277. @click="but_re_compute()"
  278. >重新计算</el-button>
  279. <el-button
  280. class="button"
  281. type="primary"
  282. size="mini"
  283. v-privilege="activeMenu + 'PUT'"
  284. @click="but_redata()"
  285. :loading="loading"
  286. >重新生成数据</el-button>
  287. <div style="float:right; text-align: right;">
  288. <el-button
  289. class="button"
  290. type="primary"
  291. size="mini"
  292. icon="el-icon-search"
  293. v-privilege="activeMenu + 'QUERY'"
  294. @click="getTableData(1)"
  295. >查询</el-button>
  296. <el-button
  297. class="button"
  298. type="primary"
  299. size="mini"
  300. icon="el-icon-refresh"
  301. v-privilege="activeMenu + 'QUERY'"
  302. @click="tableDataCancel();"
  303. >重置</el-button>
  304. <el-button
  305. size="mini"
  306. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  307. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  308. @click="filterForm.show = !filterForm.show;
  309. $nextTick(() => {
  310. singleTableHeight = getRoleHeight($refs['box_bottom']) - 60;
  311. }
  312. );"
  313. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  314. </div>
  315. </div>
  316. <div ref="box_bottom" class="box-bottom">
  317. <el-form
  318. size="mini"
  319. ref="dialog_form_arr"
  320. label-width="0px"
  321. :model="tableFormDataObj"
  322. >
  323. <el-table
  324. stripe
  325. id="singleTable"
  326. :data="tableData"
  327. v-loading="table.tableLoading"
  328. style="width: 100%;"
  329. :height="singleTableHeight"
  330. border
  331. size="mini"
  332. highlight-current-row
  333. show-summary
  334. @selection-change="handleSelectionChange"
  335. :summary-method="getSummaries"
  336. :row-class-name="tableRowClassName"
  337. @cell-click="cellClick">
  338. <el-table-column
  339. type="selection"
  340. width="40"
  341. align="center"
  342. fixed="left"
  343. ></el-table-column>
  344. <el-table-column
  345. sortable
  346. prop="timegranid"
  347. label="时间粒度"
  348. width="72px"
  349. :show-overflow-tooltip="true"
  350. >
  351. <template slot-scope="scope">
  352. <span>{{ nameObj.timegranid.obj[scope.row.timegranid] ? nameObj.timegranid.obj[scope.row.timegranid] : scope.row.timegranid }}</span>
  353. </template>
  354. </el-table-column>
  355. <el-table-column
  356. sortable
  357. prop="clock"
  358. label="时间"
  359. width="78px"
  360. :show-overflow-tooltip="true"
  361. ></el-table-column>
  362. <el-table-column
  363. sortable
  364. prop="itemid"
  365. label="项目编号"
  366. width="190px"
  367. :show-overflow-tooltip="true"
  368. ></el-table-column>
  369. <el-table-column
  370. sortable
  371. prop="itemname"
  372. label="项目名称"
  373. width="290px"
  374. :show-overflow-tooltip="true"
  375. ></el-table-column>
  376. <el-table-column
  377. sortable
  378. prop="workprocid"
  379. label="工序名称"
  380. width="170px"
  381. :show-overflow-tooltip="true"
  382. >
  383. <template slot-scope="scope">
  384. <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
  385. </template>
  386. </el-table-column>
  387. <el-table-column
  388. sortable
  389. prop="energyid"
  390. label="能介"
  391. width="85px"
  392. :show-overflow-tooltip="true"
  393. >
  394. <template slot-scope="scope">
  395. <span>{{ nameObj.energyid.obj[scope.row.energyid] ? nameObj.energyid.obj[scope.row.energyid] : scope.row.energyid }}</span>
  396. </template>
  397. </el-table-column>
  398. <el-table-column
  399. sortable
  400. prop="itemtype"
  401. label="用途"
  402. width="60px"
  403. :show-overflow-tooltip="true"
  404. >
  405. <template slot-scope="scope">
  406. <span>{{ nameObj.itemtype.obj[scope.row.itemtype] ? nameObj.itemtype.obj[scope.row.itemtype] : scope.row.itemtype }}</span>
  407. </template>
  408. </el-table-column>
  409. <el-table-column
  410. sortable
  411. prop="actualvalue"
  412. label="计算值"
  413. width="90px"
  414. :show-overflow-tooltip="true"
  415. ></el-table-column>
  416. <el-table-column
  417. sortable
  418. prop="correctvalue"
  419. label="修正值"
  420. width="135px"
  421. :show-overflow-tooltip="true"
  422. >
  423. <template slot-scope="scope">
  424. <el-form-item
  425. v-if="scope.row.isSelection"
  426. :prop="'s' + scope.row.seq + '.correctvalue'"
  427. :rules="dialog.editorBox.form.rules.correctvalue"
  428. >
  429. <el-input @keydown.native="keyDown" :id="scope.column.id + scope.$index"
  430. clearable style="width: 100%;"
  431. v-model.trim="tableFormDataObj['s' + scope.row.seq].correctvalue"
  432. @change="getApportvalue('s' + scope.row.seq)"
  433. ></el-input>
  434. </el-form-item>
  435. <span v-else>{{scope.row.correctvalue}}</span>
  436. </template>
  437. </el-table-column>
  438. <el-table-column
  439. sortable
  440. prop="apportvalue"
  441. label="最终值"
  442. width="135px"
  443. :show-overflow-tooltip="true"
  444. >
  445. <template slot-scope="scope">
  446. <el-form-item
  447. v-if="scope.row.isSelection"
  448. :prop="'s' + scope.row.seq + '.apportvalue'"
  449. :rules="dialog.editorBox.form.rules.apportvalue"
  450. >
  451. <el-input @keydown.native="keyDown" :id="scope.column.id + scope.$index"
  452. clearable style="width: 100%;"
  453. v-model.trim="tableFormDataObj['s' + scope.row.seq].apportvalue"
  454. @change="getCorrectvalue('s' + scope.row.seq)"
  455. ></el-input>
  456. </el-form-item>
  457. <span v-else>{{scope.row.apportvalue}}</span>
  458. </template>
  459. </el-table-column>
  460. <el-table-column
  461. sortable
  462. prop="bz"
  463. label="备注"
  464. min-width="90px"
  465. :show-overflow-tooltip="true"
  466. >
  467. <template slot-scope="scope">
  468. <el-form-item
  469. v-if="scope.row.isSelection"
  470. :prop="'s' + scope.row.seq + '.bz'"
  471. :rules="dialog.editorBox.form.rules.bz"
  472. >
  473. <el-input @keydown.native="keyDown" :id="scope.column.id + scope.$index"
  474. clearable style="width: 100%;"
  475. v-model.trim="tableFormDataObj['s' + scope.row.seq].bz"
  476. ></el-input>
  477. </el-form-item>
  478. <span v-else>{{scope.row.bz}}</span>
  479. </template>
  480. </el-table-column>
  481. <el-table-column
  482. sortable
  483. :sort-by="function(row, index) { return sortFoo(row, index, 'unitid') }"
  484. prop="unitid"
  485. label="计量单位"
  486. width="100px"
  487. :show-overflow-tooltip="true"
  488. >
  489. <template slot-scope="scope">
  490. <span>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
  491. </template>
  492. </el-table-column>
  493. <el-table-column
  494. sortable
  495. prop="rectime"
  496. label="记录创建时间"
  497. width="130px"
  498. :show-overflow-tooltip="true"
  499. ></el-table-column>
  500. <el-table-column
  501. sortable
  502. prop="code"
  503. label="序号"
  504. width="100px"
  505. :show-overflow-tooltip="true"
  506. >
  507. <template slot-scope="scope">
  508. <el-form-item
  509. v-if="scope.row.isSelection"
  510. :prop="'s' + scope.row.seq + '.code'"
  511. :rules="dialog.editorBox.form.rules.code"
  512. >
  513. <el-input @keydown.native="keyDown" :id="scope.column.id + scope.$index"
  514. clearable style="width: 100%;"
  515. v-model.trim="tableFormDataObj['s' + scope.row.seq].code"
  516. ></el-input>
  517. </el-form-item>
  518. <span v-else>{{scope.row.code}}</span>
  519. </template>
  520. </el-table-column>
  521. <!-- <el-table-column
  522. sortable
  523. prop="modifyflag"
  524. label="修改标记"
  525. min-width="100px"
  526. :show-overflow-tooltip="true"
  527. ></el-table-column> -->
  528. <el-table-column
  529. class-name="gn-TableDownloadExcel-none"
  530. label="操作"
  531. align="center"
  532. width="86px"
  533. fixed="right"
  534. >
  535. <template slot-scope="scope">
  536. <div>
  537. <!-- <el-button
  538. type="primary"
  539. size="mini"
  540. @click="but_edit(scope.row)"
  541. >修改</el-button> -->
  542. <el-button
  543. type="primary"
  544. size="mini"
  545. v-privilege="activeMenu + 'QUERY'"
  546. @click="but_sdata(scope.row)"
  547. >计算过程</el-button>
  548. </div>
  549. </template>
  550. </el-table-column>
  551. </el-table>
  552. </el-form>
  553. <el-pagination
  554. layout="total, sizes, prev, pager, next, jumper"
  555. :total="table.total"
  556. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  557. :page-size="table.pageSize"
  558. :current-page.sync="table.pageNum"
  559. @size-change="tableSizeChange"
  560. @current-change="getTableData()"
  561. style="text-align: right;margin-top: 10px;"
  562. ></el-pagination>
  563. </div>
  564. </div>
  565. </div>
  566. <el-dialog
  567. :title="'数据 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
  568. :visible.sync="dialog.editorBox.show"
  569. width="320px"
  570. :close-on-click-modal="false"
  571. :show-close="!loading"
  572. >
  573. <div>
  574. <el-form
  575. ref="dialog_form"
  576. :model="dialog.editorBox.form.data"
  577. :rules="dialog.editorBox.form.rules"
  578. size="mini"
  579. label-width="65px"
  580. >
  581. <el-form-item label="计算值">
  582. <el-input clearable
  583. style="width: 95%;"
  584. v-model="dialog.editorBox.form.data.actualvalue"
  585. readonly
  586. ></el-input>
  587. </el-form-item>
  588. <el-form-item label="修正值" prop="correctvalue">
  589. <el-input clearable
  590. style="width: 95%;"
  591. v-model="dialog.editorBox.form.data.correctvalue"
  592. @change="dialog.editorBox.form.data.apportvalue = floatComputed(dialog.editorBox.form.data.actualvalue, dialog.editorBox.form.data.correctvalue, '+')"
  593. ></el-input>
  594. </el-form-item>
  595. <el-form-item label="最终值" prop="apportvalue">
  596. <el-input clearable
  597. style="width: 95%;"
  598. v-model="dialog.editorBox.form.data.apportvalue"
  599. @change="dialog.editorBox.form.data.correctvalue = floatComputed(dialog.editorBox.form.data.apportvalue, dialog.editorBox.form.data.actualvalue, '-')"
  600. ></el-input>
  601. </el-form-item>
  602. </el-form>
  603. </div>
  604. <span
  605. slot="footer"
  606. class="dialog-footer"
  607. >
  608. <el-button
  609. @click="dialog.editorBox.show = false"
  610. :loading="loading"
  611. >取 消</el-button>
  612. <el-button
  613. type="primary"
  614. @click="dataSave"
  615. :loading="loading"
  616. >保 存</el-button>
  617. </span>
  618. </el-dialog>
  619. </div>
  620. </template>
  621. <script>
  622. import { zCheckNumber1 } from '~/utils/validator.js'
  623. import timegranDate from '~/components/zg/timegranDate.vue'
  624. import {formatDate, XtcommonSummaries} from '@/utils/util.js';
  625. export default {
  626. name: 'indexDataMaintain',
  627. components: {
  628. 'zj-timegran-date': timegranDate
  629. },
  630. data () {
  631. return {
  632. rowIndex: '',
  633. columnId: '',
  634. focusTarget: null,
  635. seqArr: [],
  636. editSetFlag: '',
  637. multipleSelection: [],
  638. tableFormDataObj: {},
  639. activeMenu: '',
  640. filterForm: {
  641. show: true,
  642. node: {
  643. id: '',
  644. indextype: ''
  645. },
  646. data: {
  647. timegranid: 'MONTH',
  648. clock: '',
  649. itemid: '',
  650. itemname: '',
  651. itemtype: [],
  652. indextype: '',
  653. type1: '',
  654. type2: '',
  655. type3: '',
  656. type4: '',
  657. energyid: [],
  658. workprocid: [],
  659. factoryid: ''
  660. },
  661. rules: {
  662. }
  663. },
  664. listTopicTree: {
  665. show: true,
  666. loading: false,
  667. data: [],
  668. defaultProps: {
  669. children: 'children',
  670. label: 'name'
  671. }
  672. },
  673. tableData: [],
  674. table: {
  675. pageNum: 1,
  676. pageSize: 100,
  677. total: 0,
  678. tableLoading: false
  679. },
  680. nameObj: {
  681. timegranid: {
  682. obj: {
  683. 'DAY': '日',
  684. 'MONTH': '月',
  685. 'YEAR': '年'
  686. },
  687. arr: [{id: 'DAY', name: '日'}, {id: 'MONTH', name: '月'}, {id: 'YEAR', name: '年'}]
  688. },
  689. itemtype: {
  690. obj: {},
  691. arr: []
  692. },
  693. type1: {
  694. obj: {},
  695. arr: []
  696. },
  697. type2: {
  698. obj: {},
  699. arr: []
  700. },
  701. type3: {
  702. obj: {},
  703. arr: []
  704. },
  705. type4: {
  706. obj: {},
  707. arr: []
  708. },
  709. energyid: {
  710. obj: {},
  711. arr: []
  712. },
  713. workprocid: {
  714. obj: {},
  715. arr: []
  716. },
  717. factoryid: {
  718. obj: {},
  719. arr: []
  720. },
  721. indextype: {
  722. obj: {},
  723. arr: []
  724. },
  725. unitid: {
  726. obj: {},
  727. arr: []
  728. }
  729. },
  730. singleTableHeight: 100,
  731. loading: false,
  732. dialog: {
  733. editorBox: {
  734. show: false,
  735. type: '',
  736. form: {
  737. data: {
  738. itemid: '',
  739. clock: '',
  740. timegranid: '',
  741. actualvalue: '',
  742. correctvalue: '',
  743. apportvalue: '',
  744. code: ''
  745. },
  746. rules: {
  747. correctvalue: [
  748. { required: true, message: '该项不能为空', trigger: 'change' },
  749. { validator: zCheckNumber1, trigger: 'change' }
  750. ],
  751. apportvalue: [
  752. { required: true, message: '该项不能为空', trigger: 'change' },
  753. { validator: zCheckNumber1, trigger: 'change' }
  754. ],
  755. bz: [],
  756. code: []
  757. }
  758. }
  759. }
  760. }
  761. }
  762. },
  763. created () {
  764. this.activeMenu = window.localStorage.getItem('activeMenu');
  765. },
  766. mounted () {
  767. let that = this;
  768. window.PEDataObj = {
  769. // 将数据绑定到window上,供main页面使用
  770. vm: that,
  771. // tableArr:用于导出成Excel的表格的信息
  772. tableArr: [
  773. {
  774. name: '',
  775. id: 'singleTable'
  776. }
  777. ]
  778. };
  779. that.$nextTick(() => {
  780. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  781. setTimeout(() => {
  782. that.singleTableHeight = that.getRoleHeight(that.$refs['box_bottom']) - 60;
  783. }, 1);
  784. });
  785. // that.getTimeGranData();
  786. that.getEnergyIdData();
  787. that.getNodeData();
  788. that.getFactoryIdData();
  789. that.getUnitIdData();
  790. that.getType();
  791. that.getIndexItemTypeData();
  792. },
  793. methods: {
  794. // 获取指标用途类型
  795. getIndexItemTypeData () {
  796. let that = this
  797. let url = 'pass/ems/v1/trmindexitemtypes/?pageSize=500&pageNum=1';
  798. that.axios.get(url)
  799. .then(function (res) {
  800. if (res.code === '0') {
  801. let arr = [];
  802. let obj = {};
  803. for (let item of res.data.list) {
  804. arr.push({
  805. id: item.id,
  806. name: item.name
  807. })
  808. obj[item.id] = item.name;
  809. }
  810. that.nameObj.itemtype.arr = arr;
  811. that.nameObj.itemtype.obj = obj;
  812. } else {
  813. that.$message.error(res.message);
  814. }
  815. });
  816. },
  817. // 计算树区域高度
  818. getRoleHeight (dom) {
  819. return window.innerHeight - dom.offsetTop;
  820. },
  821. // 用于表格特殊列的过滤方法(:sort-by="function(row, index) { return sortFoo() }")
  822. sortFoo (row, index, objName, name) {
  823. name = name || objName;
  824. let s = this.nameObj[objName].obj[row[name]] ? this.nameObj[objName].obj[row[name]] : row[name];
  825. return s;
  826. },
  827. // 自定义的表格合计方法:只给指定列进行合计
  828. getSummaries (param) {
  829. const prop = []; // 合计列绑定的prop
  830. return XtcommonSummaries(param, prop);
  831. },
  832. // 获取时间粒度(指标数据数据维护)
  833. getTimeGranData () {
  834. let that = this
  835. let url = 'pass/ems/v1/tcmdatasourcetimegrans/getTimegranRmindexvalue';
  836. that.axios.get(url)
  837. .then(function (res) {
  838. if (res.code === '0') {
  839. let arr = [];
  840. let obj = {};
  841. for (let item of res.data) {
  842. arr.push({
  843. id: item.ID,
  844. name: item.NAME
  845. })
  846. obj[item.ID] = item.NAME;
  847. that.filterForm.data.timegranid = that.filterForm.data.timegranid ? that.filterForm.data.timegranid : item.ID;
  848. }
  849. that.nameObj.timegranid.arr = arr;
  850. that.nameObj.timegranid.obj = obj;
  851. } else {
  852. that.$message.error(res.message);
  853. }
  854. });
  855. },
  856. // 获取能介
  857. getEnergyIdData () {
  858. let that = this
  859. let url = 'pass/ems/v1/trmenergys/selectNameAndId/';
  860. that.axios.get(url)
  861. .then(function (res) {
  862. if (res.code === '0') {
  863. let arr = [];
  864. let obj = {};
  865. for (let item of res.data) {
  866. arr.push({
  867. id: item.id,
  868. name: item.name
  869. })
  870. obj[item.id] = item.name;
  871. }
  872. that.nameObj.energyid.arr = arr;
  873. that.nameObj.energyid.obj = obj;
  874. } else {
  875. that.$message.error(res.message);
  876. }
  877. });
  878. },
  879. // 获取工序列表
  880. getNodeData () {
  881. let that = this
  882. let url = 'pass/ems/v1/trmworkprocs/getIdAndName?isreal=1';
  883. that.axios.get(url)
  884. .then(function (res) {
  885. if (res.code === '0') {
  886. let arr = [];
  887. let obj = {};
  888. for (let item of res.data) {
  889. arr.push({
  890. id: item.id,
  891. name: item.name
  892. })
  893. obj[item.id] = item.name;
  894. }
  895. that.nameObj.workprocid.arr = arr;
  896. that.nameObj.workprocid.obj = obj;
  897. } else {
  898. that.$message.error(res.message);
  899. }
  900. });
  901. },
  902. // 获取工厂
  903. getFactoryIdData () {
  904. let that = this
  905. let url = 'pass/ems/v1/trmfactorys/getIAndName';
  906. that.axios.get(url)
  907. .then(function (res) {
  908. if (res.code === '0') {
  909. let arr = [];
  910. let obj = {};
  911. for (let item of res.data) {
  912. arr.push({
  913. id: item.id,
  914. name: item.name
  915. })
  916. obj[item.id] = item.name;
  917. }
  918. that.nameObj.factoryid.arr = arr;
  919. that.nameObj.factoryid.obj = obj;
  920. } else {
  921. that.$message.error(res.message);
  922. }
  923. });
  924. },
  925. // 获取标准计量单位
  926. getUnitIdData () {
  927. let that = this
  928. let url = 'pass/ems/v1/trmunits/getIdAndName';
  929. that.axios.get(url)
  930. .then(function (res) {
  931. if (res.code === '0') {
  932. let arr = [];
  933. let obj = {};
  934. for (let item of res.data) {
  935. arr.push({
  936. id: item.id,
  937. name: item.name
  938. })
  939. obj[item.id] = item.name;
  940. if (item.name === '吨') {
  941. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  942. }
  943. }
  944. that.nameObj.unitid.arr = arr;
  945. that.nameObj.unitid.obj = obj;
  946. } else {
  947. that.$message.error(res.message);
  948. }
  949. });
  950. },
  951. // 分类获取所有指标类型
  952. getType () {
  953. let that = this
  954. let url = 'pass/ems/v1/trmindextypes/?pageSize=1000000';
  955. that.axios.get(url)
  956. .then(function (res) {
  957. if (res.code === '0') {
  958. let arr = [],
  959. arr1 = [],
  960. arr2 = [],
  961. arr3 = [],
  962. arr4 = [];
  963. let obj = {},
  964. obj1 = {},
  965. obj2 = {},
  966. obj3 = {},
  967. obj4 = {};
  968. for (let item of res.data.list) {
  969. if (item.indexcol === 'INDEXTYPE') {
  970. arr.push({
  971. id: item.indexid,
  972. name: item.indexname
  973. })
  974. obj[item.indexid] = item.indexname;
  975. } else if (item.indexcol === 'TYPE1') {
  976. arr1.push({
  977. id: item.indexid,
  978. name: item.indexname
  979. })
  980. obj1[item.indexid] = item.indexname;
  981. } else if (item.indexcol === 'TYPE2') {
  982. arr2.push({
  983. id: item.indexid,
  984. name: item.indexname
  985. })
  986. obj2[item.indexid] = item.indexname;
  987. } else if (item.indexcol === 'TYPE3') {
  988. arr3.push({
  989. id: item.indexid,
  990. name: item.indexname
  991. })
  992. obj3[item.indexid] = item.indexname;
  993. } else if (item.indexcol === 'TYPE4') {
  994. arr4.push({
  995. id: item.indexid,
  996. name: item.indexname
  997. })
  998. obj4[item.indexid] = item.indexname;
  999. }
  1000. }
  1001. that.nameObj.indextype.arr = arr;
  1002. that.nameObj.indextype.obj = obj;
  1003. that.nameObj.type1.arr = arr1;
  1004. that.nameObj.type1.obj = obj1;
  1005. that.nameObj.type2.arr = arr2;
  1006. that.nameObj.type2.obj = obj2;
  1007. that.nameObj.type3.arr = arr3;
  1008. that.nameObj.type3.obj = obj3;
  1009. that.nameObj.type4.arr = arr4;
  1010. that.nameObj.type4.obj = obj4;
  1011. } else {
  1012. that.$message.error(res.message);
  1013. }
  1014. });
  1015. },
  1016. selectByTopicId (data) {
  1017. let that = this;
  1018. // console.log(data);
  1019. that.filterForm.node.id = data.id;
  1020. that.filterForm.node.indextype = data.indextype;
  1021. that.filterForm.data.indextype = that.filterForm.node.indextype;
  1022. that.getTableData(1);
  1023. },
  1024. // 懒加载节点数
  1025. loadNode (node, resolve) {
  1026. let that = this;
  1027. // console.log(node)
  1028. if (node.level === 0) {
  1029. let url = 'pass/ems/v1/trmindextypes/getIdAndName';
  1030. that.axios.get(url)
  1031. .then(function (res) {
  1032. if (res.code === '0') {
  1033. let arr = [];
  1034. for (let item of res.data) {
  1035. arr.push({
  1036. id: item.indexid,
  1037. name: item.indexname,
  1038. desc: item.indexdesc,
  1039. level: node.level + 1,
  1040. indextype: item.indexid
  1041. })
  1042. }
  1043. return resolve(arr);
  1044. } else {
  1045. that.$message.error(res.message);
  1046. }
  1047. });
  1048. }
  1049. if (node.level === 1 || node.level === 2) {
  1050. let url = 'pass/ems/v1/trmindexitems/getTrees?pageSize=1000000',
  1051. params = {};
  1052. if (node.level === 1) {
  1053. params = {
  1054. indextype: node.data.id,
  1055. itemflag: 1
  1056. }
  1057. } else {
  1058. params = {
  1059. parentid: node.data.id
  1060. }
  1061. }
  1062. that.axios.get(url, {
  1063. params: params
  1064. })
  1065. .then(function (res) {
  1066. if (res.code === '0') {
  1067. let arr = [];
  1068. for (let item of res.data.list) {
  1069. arr.push({
  1070. id: item.ITEMID,
  1071. name: item.ITEMNAME,
  1072. desc: item.ITEMDESC,
  1073. level: node.level + 1,
  1074. indextype: item.INDEXTYPE
  1075. })
  1076. }
  1077. return resolve(arr);
  1078. } else {
  1079. that.$message.error(res.message);
  1080. }
  1081. });
  1082. }
  1083. if (node.level === 3) {
  1084. return resolve([]);
  1085. }
  1086. },
  1087. // 获取表格中的数据
  1088. getTableData (pageNum) {
  1089. let that = this,
  1090. params = {
  1091. timegranid: that.filterForm.data.timegranid,
  1092. clock: that.filterForm.data.clock[0],
  1093. clocke: that.filterForm.data.clock[1],
  1094. itemid: that.filterForm.data.itemid,
  1095. itemname: that.filterForm.data.itemname,
  1096. itemtype: that.filterForm.data.itemtype.join(','),
  1097. indextype: that.filterForm.data.indextype,
  1098. type1: that.filterForm.data.type1,
  1099. type2: that.filterForm.data.type2,
  1100. type3: that.filterForm.data.type3,
  1101. type4: that.filterForm.data.type4,
  1102. energyid: that.filterForm.data.energyid.join(','),
  1103. workprocid: that.filterForm.data.workprocid.join(','),
  1104. factoryid: that.filterForm.data.factoryid,
  1105. parentid: that.filterForm.node.id,
  1106. code: that.filterForm.data.code
  1107. };
  1108. that.table.pageNum = pageNum || that.table.pageNum;
  1109. that.table.tableLoading = true;
  1110. let url = 'pass/ems/v1/trmindexvalues/getTRmIndexValues/?pageNum=' + that.table.pageNum + '&pageSize=' + that.table.pageSize;
  1111. that.axios.get(url, {
  1112. params: params
  1113. })
  1114. .then(function (res) {
  1115. if (res.code === '0') {
  1116. let arr = [];
  1117. for (let i = 0; i < res.data.list.length; i++) {
  1118. let item = res.data.list[i];
  1119. arr.push({
  1120. seq: i,
  1121. itemid: item.ITEMID,
  1122. clock: item.CLOCK,
  1123. timegranid: item.TIMEGRANID,
  1124. itemname: item.ITEMNAME,
  1125. actualvalue: item.ACTUALVALUE,
  1126. correctvalue: item.CORRECTVALUE,
  1127. apportvalue: item.APPORTVALUE,
  1128. sumvalue: item.SUMVALUE,
  1129. unitid: item.UNITID,
  1130. rectime: item.REC_TIME,
  1131. modifyflag: item.MODIFYFLAG,
  1132. itemtype: item.ITEMTYPE,
  1133. bz: item.BZ,
  1134. workprocid: item.WORKPROCID,
  1135. energyid: item.ENERGYID,
  1136. code: item.CODE
  1137. })
  1138. }
  1139. that.tableData = arr;
  1140. that.table.total = res.data.total;
  1141. } else {
  1142. that.$message.error(res.message);
  1143. }
  1144. that.table.tableLoading = false;
  1145. }).catch(function () {
  1146. that.table.tableLoading = false;
  1147. });
  1148. },
  1149. // 改变表格显示条数
  1150. tableSizeChange (val) {
  1151. let that = this;
  1152. that.table.pageSize = val;
  1153. that.getTableData(1);
  1154. },
  1155. // 重置搜索
  1156. tableDataCancel () {
  1157. let that = this;
  1158. for (let key in that.filterForm.data) {
  1159. if (that.filterForm.data[key] instanceof Array) {
  1160. that.filterForm.data[key] = [];
  1161. } else {
  1162. that.filterForm.data[key] = '';
  1163. }
  1164. }
  1165. that.filterForm.data.indextype = that.filterForm.node.indextype;
  1166. that.getTableData(1);
  1167. },
  1168. but_edit (row) {
  1169. let that = this;
  1170. that.dialog.editorBox.form.data.itemid = row.itemid;
  1171. that.dialog.editorBox.form.data.clock = row.clock;
  1172. that.dialog.editorBox.form.data.timegranid = row.timegranid;
  1173. that.dialog.editorBox.form.data.actualvalue = row.actualvalue;
  1174. that.dialog.editorBox.form.data.correctvalue = row.correctvalue;
  1175. that.dialog.editorBox.form.data.apportvalue = row.apportvalue;
  1176. that.dialog.editorBox.type = 'edit';
  1177. that.dialog.editorBox.show = true;
  1178. },
  1179. dataSave () {
  1180. let that = this;
  1181. let SubmitData = {
  1182. itemid: that.dialog.editorBox.form.data.itemid,
  1183. clock: that.dialog.editorBox.form.data.clock,
  1184. timegranid: that.dialog.editorBox.form.data.timegranid,
  1185. correctvalue: that.dialog.editorBox.form.data.correctvalue,
  1186. apportvalue: that.dialog.editorBox.form.data.apportvalue,
  1187. actualvalue: that.dialog.editorBox.form.data.actualvalue
  1188. };
  1189. that.$refs['dialog_form'].validate((valid) => {
  1190. if (valid) {
  1191. that.loading = true;
  1192. that.axios.put('pass/ems/v1/trmindexvalues/update', SubmitData)
  1193. .then(function (res) {
  1194. if (res.code === '0') {
  1195. that.$message({
  1196. message: '修改成功',
  1197. type: 'success'
  1198. });
  1199. that.getTableData();
  1200. that.dialog.editorBox.show = false;
  1201. } else {
  1202. that.$message.error(res.message);
  1203. }
  1204. that.loading = false;
  1205. }).catch(function () {
  1206. that.loading = false;
  1207. });
  1208. }
  1209. });
  1210. },
  1211. // 表格中多选按钮的相关方法
  1212. handleSelectionChange (val) {
  1213. let that = this;
  1214. let tableFormDataObj = {};
  1215. let arr = [];
  1216. for (let item of val) {
  1217. arr.push(item.seq);
  1218. }
  1219. this.seqArr = arr.sort(sortNumber);
  1220. for (let item of that.tableData) {
  1221. item.isSelection = false;
  1222. }
  1223. for (let item of val) {
  1224. let obj = {};
  1225. let xId = 's' + item.seq;
  1226. if (that.tableFormDataObj[xId]) {
  1227. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  1228. } else {
  1229. for (let key in item) {
  1230. obj[key] = item[key];
  1231. }
  1232. tableFormDataObj[xId] = obj;
  1233. }
  1234. item.isSelection = true;
  1235. }
  1236. that.tableFormDataObj = tableFormDataObj;
  1237. that.multipleSelection = val;
  1238. },
  1239. tableRowClassName ({row, rowIndex}) {
  1240. // 把每一行的索引放进row
  1241. row.index = rowIndex;
  1242. },
  1243. cellClick (row, column, cell, event) {
  1244. let _this = this;
  1245. this.rowIndex = row.index;
  1246. this.columnId = column.id;
  1247. _this.editSetFlag = column.id + row.index;
  1248. _this.focusTarget = event.target;
  1249. while (_this.focusTarget.tagName !== 'TD') {
  1250. _this.focusTarget = _this.focusTarget.parentElement;
  1251. }
  1252. _this.$nextTick(() => {
  1253. let target = this.focusTarget;
  1254. $(target).find('input').focus();
  1255. });
  1256. },
  1257. keyDown (event1) {
  1258. let tdTarget = event1.target;
  1259. let _this = this;
  1260. while (tdTarget.tagName !== 'TD') {
  1261. tdTarget = tdTarget.parentElement;
  1262. }
  1263. // 如果按下键盘下键或者回车键
  1264. if (event.keyCode === 40 || event.keyCode === 13) {
  1265. let index = parseInt(this.rowIndex);
  1266. if (index !== this.seqArr[this.seqArr.length - 1]) {
  1267. for (let i = 0; i < this.seqArr.length; i++) {
  1268. if (index === this.seqArr[i]) {
  1269. index = this.seqArr[i + 1];
  1270. break;
  1271. }
  1272. }
  1273. }
  1274. this.editSetFlag = this.columnId + index;
  1275. let id = '#' + this.editSetFlag;
  1276. this.$nextTick(() => {
  1277. $(id).click();
  1278. });
  1279. } else if (event.keyCode === 38) { // 键盘上键
  1280. let index = parseInt(this.rowIndex);
  1281. if (index !== this.seqArr[0]) {
  1282. for (let i = 0; i < this.seqArr.length; i++) {
  1283. if (index === this.seqArr[i]) {
  1284. index = this.seqArr[i - 1];
  1285. break;
  1286. }
  1287. }
  1288. }
  1289. this.editSetFlag = this.columnId + index;
  1290. let id = '#' + this.editSetFlag;
  1291. this.$nextTick(() => {
  1292. $(id).click();
  1293. });
  1294. } else if (event.keyCode === 37) { // 键盘左键
  1295. $(tdTarget).prev().click();
  1296. $(tdTarget).prev().find('input').select();
  1297. } else if (event.keyCode === 39) { // 键盘右键
  1298. $(tdTarget).next().click();
  1299. $(tdTarget).next().find('input').select();
  1300. }
  1301. },
  1302. // 计算最终值
  1303. getApportvalue (ids) {
  1304. let that = this;
  1305. let apportvalue = that.floatComputed(that.tableFormDataObj[ids].actualvalue, that.tableFormDataObj[ids].correctvalue, '+');
  1306. that.tableFormDataObj[ids].apportvalue = apportvalue;
  1307. },
  1308. // 计算修正值
  1309. getCorrectvalue (ids) {
  1310. console.log(this.tableFormDataObj[ids].correctvalue)
  1311. let that = this;
  1312. let correctvalue = that.floatComputed(that.tableFormDataObj[ids].apportvalue, that.tableFormDataObj[ids].actualvalue, '-');
  1313. that.tableFormDataObj[ids].correctvalue = correctvalue;
  1314. },
  1315. // 批量修改
  1316. but_edit_plural () {
  1317. let that = this;
  1318. if (that.multipleSelection.length > 0) {
  1319. that.$refs['dialog_form_arr'].validate((valid, obj) => {
  1320. if (valid) {
  1321. let SubmitData = [];
  1322. for (let key in that.tableFormDataObj) {
  1323. SubmitData.push({
  1324. itemid: that.tableFormDataObj[key].itemid,
  1325. clock: that.tableFormDataObj[key].clock,
  1326. timegranid: that.tableFormDataObj[key].timegranid,
  1327. correctvalue: that.tableFormDataObj[key].correctvalue,
  1328. apportvalue: that.tableFormDataObj[key].apportvalue,
  1329. actualvalue: that.tableFormDataObj[key].actualvalue,
  1330. bz: that.tableFormDataObj[key].bz,
  1331. code: that.tableFormDataObj[key].code
  1332. });
  1333. }
  1334. that.loading = true;
  1335. that.axios.put('pass/ems/v1/trmindexvalues/batchupdate', SubmitData)
  1336. .then(function (res) {
  1337. if (res.code === '0') {
  1338. that.$message({
  1339. message: '修改成功',
  1340. type: 'success'
  1341. });
  1342. that.getTableData();
  1343. } else {
  1344. that.$message.error(res.message);
  1345. }
  1346. that.loading = false;
  1347. }).catch(function () {
  1348. that.loading = false;
  1349. });
  1350. } else {
  1351. this.$message.error('数据不完整或者格式错误');
  1352. }
  1353. });
  1354. } else {
  1355. this.$message.error('至少要选择一条数据');
  1356. }
  1357. },
  1358. // 批量重新计算
  1359. but_re_compute () {
  1360. let that = this;
  1361. if (that.multipleSelection.length > 0) {
  1362. that.$refs['dialog_form_arr'].validate((valid) => {
  1363. if (valid) {
  1364. let SubmitData = [];
  1365. for (let key in that.tableFormDataObj) {
  1366. SubmitData.push({
  1367. clock: that.tableFormDataObj[key].clock,
  1368. timegranid: that.tableFormDataObj[key].timegranid,
  1369. itemid: that.tableFormDataObj[key].itemid
  1370. });
  1371. }
  1372. that.loading = true;
  1373. that.axios.put('pass/ems/v1/trmindexvalues/batchCompute', SubmitData)
  1374. .then(function (res) {
  1375. if (res.code === '0') {
  1376. that.$message({
  1377. message: '重新生成数据成功',
  1378. type: 'success'
  1379. });
  1380. that.getTableData();
  1381. } else {
  1382. that.$message.error(res.message);
  1383. }
  1384. that.loading = false;
  1385. }).catch(function () {
  1386. that.loading = false;
  1387. });
  1388. }
  1389. });
  1390. } else {
  1391. this.$message.error('至少要选择一条数据');
  1392. }
  1393. },
  1394. // 重新生成数据
  1395. but_redata () {
  1396. let that = this;
  1397. if (!that.filterForm.data.clock || that.filterForm.data.clock.length === 0) {
  1398. that.$message.warning('请选择时间范围');
  1399. return true;
  1400. }
  1401. if (!that.filterForm.data.clock[0] || !that.filterForm.data.clock[1]) {
  1402. that.$message.warning('请选择开始时间与结束时间');
  1403. return true;
  1404. }
  1405. if (!that.filterForm.data.timegranid) {
  1406. that.$message.warning('请选择时间粒度');
  1407. return true;
  1408. }
  1409. let params = {
  1410. timegranid: that.filterForm.data.timegranid,
  1411. clock: that.filterForm.data.clock[0],
  1412. clocke: that.filterForm.data.clock[1],
  1413. itemid: that.filterForm.data.itemid,
  1414. itemname: that.filterForm.data.itemname,
  1415. itemtype: that.filterForm.data.itemtype.join(','),
  1416. indextype: that.filterForm.data.indextype,
  1417. type1: that.filterForm.data.type1,
  1418. type2: that.filterForm.data.type2,
  1419. type3: that.filterForm.data.type3,
  1420. type4: that.filterForm.data.type4,
  1421. energyid: that.filterForm.data.energyid.join(','),
  1422. workprocid: that.filterForm.data.workprocid.join(','),
  1423. factoryid: that.filterForm.data.factoryid,
  1424. parentid: that.filterForm.node.id
  1425. };
  1426. that.$confirm('是否重新生成数据?日期跨度不易太长!否则运行时间较长', '提示', {
  1427. confirmButtonText: '确定',
  1428. cancelButtonText: '取消',
  1429. state: 'warning'
  1430. }).then(() => {
  1431. that.loading = true;
  1432. let url = 'pass/ems/v1/trmindexvalues/reData'
  1433. that.axios.get(url, {
  1434. params: params
  1435. })
  1436. .then(function (res) {
  1437. if (res.code === '0') {
  1438. if (res.message && res.message !== '操作成功') {
  1439. that.$message.warning('重新生成数据成功, 其中【' + res.message + '】');
  1440. } else {
  1441. that.$message({
  1442. message: '重新生成数据成功',
  1443. type: 'success'
  1444. });
  1445. }
  1446. that.getTableData();
  1447. } else {
  1448. that.$message.error(res.message);
  1449. }
  1450. that.loading = false;
  1451. }).catch(function () {
  1452. that.loading = false;
  1453. });
  1454. }).catch(() => {
  1455. });
  1456. },
  1457. // 计算过程
  1458. but_sdata (row) {
  1459. let that = this;
  1460. let params = {
  1461. timegranid: row.timegranid,
  1462. clock: row.clock, // 开始时间
  1463. itemid: row.itemid // 项目编号
  1464. };
  1465. that.axios.get('pass/ems/v1/formulas/getAnaByVal/', {
  1466. params: params
  1467. }).then(function (res) {
  1468. if (res.code === '0') {
  1469. that.$message({
  1470. message: res.data,
  1471. type: 'success'
  1472. });
  1473. } else {
  1474. that.$message.error(res.message);
  1475. }
  1476. }).catch(function () {});
  1477. }
  1478. }
  1479. }
  1480. function sortNumber (a, b) {
  1481. return a - b
  1482. }
  1483. </script>
  1484. <style lang="less">
  1485. .indexDataMaintain {
  1486. min-width: 700px;
  1487. height: 100%;
  1488. .box {
  1489. height: 100%;
  1490. padding: 15px 15px 0 15px;
  1491. .box-left {
  1492. float: left;
  1493. width: 200px;
  1494. height: calc(100% - 3px);
  1495. overflow: auto;
  1496. .box-left-bt {
  1497. line-height: 35px;
  1498. font-size: 16px;
  1499. border-bottom: 1px solid #ccc;
  1500. }
  1501. .box-left-tree {
  1502. height: calc(100% - 50px);
  1503. overflow: auto;
  1504. padding: 7px 7px 0 0;
  1505. .tree-row-on {
  1506. color: #3279e8;
  1507. font-weight: 600;
  1508. }
  1509. }
  1510. }
  1511. .box-right {
  1512. // float: left;
  1513. // width: calc(100% - 200px);
  1514. margin-left: 200px;
  1515. border-left: 1px solid #ccc;
  1516. .box-top {
  1517. .box-top-form {
  1518. padding-left: 7px;
  1519. .el-form-item {
  1520. margin-bottom: 7px;
  1521. }
  1522. }
  1523. margin-bottom: 6px;
  1524. }
  1525. .box-top-gjl {
  1526. overflow: hidden;
  1527. padding-left: 7px;
  1528. margin-bottom: 6px;
  1529. }
  1530. .box-bottom {
  1531. padding-left: 7px;
  1532. }
  1533. }
  1534. .el-table__body .el-form-item--mini.el-form-item {
  1535. margin: 0px;
  1536. .error {
  1537. overflow: hidden;
  1538. color: #f56c6c;
  1539. font-size: 12px;
  1540. line-height: 1;
  1541. }
  1542. }
  1543. }
  1544. }
  1545. </style>