planProjectCoke.vue 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. <template>
  2. <!-- 年度计划编制-机焦厂-副产品 -->
  3. <!-- 当有审核与取消审核权限时,默认其为审核人,审核人无法修改数据 -->
  4. <div class="outElectricity">
  5. <div class="box">
  6. <div class="box-top">
  7. <el-form
  8. style="overflow: hidden;"
  9. :style="filterForm.show ? null : { height: '0px' }"
  10. size="mini"
  11. label-width="75px"
  12. >
  13. <el-row>
  14. <el-col :span="5">
  15. <!-- <el-form-item label="工序">
  16. <el-select
  17. filterable clearable
  18. v-model="filterForm.data.networkid"
  19. multiple
  20. collapse-tags
  21. placeholder="机焦厂"
  22. style="width: 100%;"
  23. disabled
  24. @change="connn()"
  25. >
  26. <el-option
  27. v-for="item of nameObj.networkid.arr"
  28. :key="item.id"
  29. :value="item.id"
  30. :label="item.name"
  31. ></el-option>
  32. </el-select>
  33. </el-form-item> -->
  34. </el-col>
  35. <el-col :span="6">
  36. <el-form-item label="年份">
  37. <zj-timegran-date
  38. v-model="filterForm.data.yearmonth"
  39. style="width: 100%;"
  40. :timegranId="'YEAR'"
  41. :oneFoo="getTableData"
  42. :custom="1"
  43. ></zj-timegran-date>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="5">
  47. </el-col>
  48. <el-col :span="5">
  49. </el-col>
  50. </el-row>
  51. </el-form>
  52. <div class="box-top-gjl">
  53. <el-form size="mini" label-width="75px">
  54. <el-row>
  55. <el-col :span="16">
  56. <el-button
  57. class="button"
  58. type="primary"
  59. size="mini"
  60. icon="el-icon-plus"
  61. @click="but_add"
  62. :loading="loading"
  63. >新增</el-button>
  64. <el-button
  65. class="button"
  66. type="primary"
  67. size="mini"
  68. icon="el-icon-plus"
  69. @click="but_copy"
  70. :loading="loading"
  71. v-if="butPrivilege.PUT && !isCheck"
  72. >复制</el-button>
  73. <el-button
  74. class="button"
  75. type="primary"
  76. size="mini"
  77. icon="el-icon-edit-outline"
  78. @click="but_edit_plural()"
  79. :loading="loading"
  80. v-if="butPrivilege.PUT && !isCheck"
  81. >修改</el-button>
  82. <el-button
  83. class="button"
  84. type="danger"
  85. size="mini"
  86. icon="el-icon-delete"
  87. v-if="butPrivilege.PUT && !isCheck"
  88. @click="but_del_plural()"
  89. :loading="loading"
  90. >删除</el-button>
  91. <!-- 当有审核与取消审核权限时,默认其为审核人,审核人无法修改数据 -->
  92. <el-button
  93. class="button"
  94. type="primary"
  95. size="mini"
  96. icon="el-icon-view"
  97. @click="upState()"
  98. :loading="loading"
  99. v-if="butPrivilege.CHECK && isCheck"
  100. >审核</el-button>
  101. <el-button
  102. class="button"
  103. size="mini"
  104. icon="el-icon-refresh"
  105. @click="upState('1')"
  106. :loading="loading"
  107. v-if="butPrivilege.UNDOCHECK && isCheck"
  108. >撤销审核</el-button>
  109. </el-col>
  110. <el-col :span="8">
  111. <div style="float:right; text-align: right;">
  112. <el-button
  113. class="button"
  114. type="primary"
  115. size="mini"
  116. icon="el-icon-search"
  117. v-if="butPrivilege.QUERY"
  118. @click="getTableData(1)"
  119. >查询</el-button>
  120. <el-button
  121. size="mini"
  122. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  123. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  124. @click="filterForm.show = !filterForm.show;
  125. $nextTick(() => {
  126. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  127. }
  128. );"
  129. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  130. </div>
  131. </el-col>
  132. </el-row>
  133. </el-form>
  134. </div>
  135. </div>
  136. <div class="box-bottom">
  137. <el-form
  138. size="mini"
  139. ref="dialog_form_arr"
  140. label-width="0px"
  141. :model="tableFormDataObj"
  142. >
  143. <el-table stripe
  144. id="singleTable"
  145. ref="singleTable"
  146. :data="tableData"
  147. v-loading="tableLoading"
  148. style="width: 100%;"
  149. :height="singleTableHeight"
  150. border
  151. size="mini"
  152. highlight-current-row
  153. @selection-change="handleSelectionChange"
  154. show-summary
  155. :summary-method="getSummaries"
  156. :span-method="arraySpanMethod"
  157. :row-class-name="tableRowClassName"
  158. @cell-click="cellClick"
  159. >
  160. <el-table-column
  161. type="selection"
  162. width="40"
  163. align="center"
  164. :selectable='checkboxT'
  165. fixed="left"
  166. class-name="cnspicuous"
  167. ></el-table-column>
  168. <el-table-column
  169. sortable
  170. prop="index"
  171. type="index"
  172. label="序号"
  173. fixed="left"
  174. width="50px"
  175. :show-overflow-tooltip="true"
  176. ></el-table-column>
  177. <el-table-column
  178. prop="yearmonth"
  179. label="月份"
  180. fixed="left"
  181. width="80px"
  182. :show-overflow-tooltip="true"
  183. ></el-table-column>
  184. <!-- <el-table-column
  185. prop="line"
  186. label="产品"
  187. fixed="left"
  188. width="160px"
  189. :show-overflow-tooltip="true"
  190. >
  191. <template slot-scope="scope">
  192. <span>{{ nameObj.workprocid.obj[scope.row.line] ? nameObj.workprocid.obj[scope.row.line].name : scope.row.line }}</span>
  193. </template>
  194. </el-table-column> -->
  195. <el-table-column
  196. fixed="left"
  197. prop="unit"
  198. label="计量单位"
  199. width="100px"
  200. :show-overflow-tooltip="true"
  201. >
  202. <template slot-scope="scope">
  203. <span>{{ nameObj.unitid.obj[scope.row.unit] ? nameObj.unitid.obj[scope.row.unit] : scope.row.unit }}</span>
  204. </template>
  205. </el-table-column>
  206. <el-table-column
  207. prop="weight"
  208. label="焦油"
  209. width="120px"
  210. :show-overflow-tooltip="true"
  211. >
  212. <template slot-scope="scope">
  213. <el-form-item
  214. v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
  215. :prop="scope.row.seq + '.weight'"
  216. >
  217. <el-input clearable
  218. v-for="(itemform, key) in tableFormDataObj[scope.row.seq].weight"
  219. style="width: 100%;"
  220. v-model="itemform['AT3024']"
  221. v-if="!isNaN(Number(itemform['AT3024']))"
  222. refcous="true"
  223. :rules="tableFormRules.weight"
  224. oninput="this.value = this.value.replace(/[^\d.]/g,'');"
  225. @keydown.native="keyDown" :id="scope.$index + scope.column.id"
  226. @change="chnageSecondVal(scope.row.seq, tableFormDataObj[scope.row.seq].secondVal, scope.$index)"
  227. :key="key"
  228. ></el-input>
  229. <template slot="error" slot-scope="scope">
  230. <p class="error" :title="scope.error">{{ scope.error }}</p>
  231. </template>
  232. </el-form-item>
  233. <span v-else v-for="(item, index) in tableData[scope.row.index].weight" :key="index">{{item['AT3024']}}</span>
  234. </template>
  235. </el-table-column>
  236. <el-table-column
  237. prop="weight"
  238. label="粗苯"
  239. width="120px"
  240. :show-overflow-tooltip="true"
  241. >
  242. <template slot-scope="scope">
  243. <el-form-item
  244. v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
  245. :prop="scope.row.seq + '.weight'"
  246. >
  247. <el-input clearable
  248. v-for="(itemform, key) in tableFormDataObj[scope.row.seq].weight"
  249. style="width: 100%;"
  250. v-model="itemform['AT3009']"
  251. v-if="!isNaN(Number(itemform['AT3009']))"
  252. refcous="true"
  253. :rules="tableFormRules.weight"
  254. oninput="this.value = this.value.replace(/[^\d.]/g,'');"
  255. @keydown.native="keyDown" :id="scope.$index + scope.column.id"
  256. @change="chnageSecondVal(scope.row.seq, tableFormDataObj[scope.row.seq].secondVal, scope.$index)"
  257. :key="key"
  258. ></el-input>
  259. <template slot="error" slot-scope="scope">
  260. <p class="error" :title="scope.error">{{ scope.error }}</p>
  261. </template>
  262. </el-form-item>
  263. <span v-else v-for="(item, index) in tableData[scope.row.index].weight" :key="index">{{item['AT3009']}}</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column
  267. prop="weight"
  268. label="硫铵"
  269. width="120px"
  270. :show-overflow-tooltip="true"
  271. >
  272. <template slot-scope="scope">
  273. <el-form-item
  274. v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
  275. :prop="scope.row.seq + '.weight'"
  276. >
  277. <el-input clearable
  278. v-for="(itemform, key) in tableFormDataObj[scope.row.seq].weight"
  279. style="width: 100%;"
  280. v-model="itemform['AT3010']"
  281. v-if="!isNaN(Number(itemform['AT3010']))"
  282. refcous="true"
  283. :rules="tableFormRules.weight"
  284. oninput="this.value = this.value.replace(/[^\d.]/g,'');"
  285. @keydown.native="keyDown" :id="scope.$index + scope.column.id"
  286. @change="chnageSecondVal(scope.row.seq, tableFormDataObj[scope.row.seq].secondVal, scope.$index)"
  287. :key="key"
  288. ></el-input>
  289. <template slot="error" slot-scope="scope">
  290. <p class="error" :title="scope.error">{{ scope.error }}</p>
  291. </template>
  292. </el-form-item>
  293. <span v-else v-for="(item, index) in tableData[scope.row.index].weight" :key="index">{{item['AT3010']}}</span>
  294. </template>
  295. </el-table-column>
  296. <el-table-column
  297. prop="total"
  298. label="合计产量"
  299. fixed="left"
  300. width="160px"
  301. ><template slot-scope="scope">
  302. <span v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'">{{ rowSum(scope.row) }}</span>
  303. <span v-else>{{ scope.row.total }}</span>
  304. </template></el-table-column>
  305. <el-table-column
  306. prop="cjsj"
  307. label="创建时间"
  308. width="220px"
  309. :show-overflow-tooltip="true"
  310. ></el-table-column>
  311. <el-table-column
  312. prop="cjr"
  313. label="创建人"
  314. width="160px"
  315. :show-overflow-tooltip="true"
  316. ></el-table-column>
  317. <el-table-column
  318. prop="xgsj"
  319. label="修改时间"
  320. width="220px"
  321. :show-overflow-tooltip="true"
  322. >
  323. </el-table-column>
  324. <el-table-column
  325. prop="xgr"
  326. label="修改人"
  327. width="160px"
  328. :show-overflow-tooltip="true"
  329. ></el-table-column>
  330. <el-table-column
  331. prop="memo"
  332. label="备注"
  333. :show-overflow-tooltip="true"
  334. >
  335. <template slot-scope="scope">
  336. <el-form-item
  337. v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
  338. :prop="scope.row.seq + '.memo'"
  339. :rules="tableFormRules.memo"
  340. >
  341. <el-input clearable
  342. style="width: 100%;"
  343. v-model="tableFormDataObj[scope.row.seq].memo"
  344. @keydown.native="keyDown" :id="scope.$index + scope.column.id"
  345. ></el-input>
  346. <template slot="error" slot-scope="scope">
  347. <p class="error" :title="scope.error">{{ scope.error }}</p>
  348. </template>
  349. </el-form-item>
  350. <span v-else>{{scope.row.memo}}</span>
  351. </template>
  352. </el-table-column>
  353. <el-table-column
  354. prop="id"
  355. label="ID"
  356. width="140px"
  357. v-if="filterForm.data.show"
  358. ></el-table-column>
  359. </el-table>
  360. </el-form>
  361. <el-pagination
  362. layout="total, sizes, prev, pager, next, jumper"
  363. :total="total"
  364. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  365. :page-size="pageSize"
  366. :current-page.sync="pageNum"
  367. @size-change="tableSizeChange"
  368. @current-change="getTableData()"
  369. style="text-align: right;margin-top: 10px;"
  370. ></el-pagination>
  371. </div>
  372. </div>
  373. <el-dialog
  374. title="年计划编制-机焦厂(副产品)新增"
  375. :visible.sync="dialog.editorBox.show"
  376. width="600px"
  377. :close-on-click-modal="false"
  378. :show-close="!loading"
  379. >
  380. <div>
  381. <el-form
  382. :model="dialog.editorBox.form.data"
  383. ref="dialog_form"
  384. size="mini"
  385. label-width="95px"
  386. :rules="dialog.editorBox.form.rules"
  387. >
  388. <el-row>
  389. <el-col :span="12">
  390. <el-form-item
  391. label="化产工序"
  392. prop="line"
  393. >
  394. <el-select
  395. placeholder=""
  396. prop="line"
  397. v-model="dialog.editorBox.form.data.line"
  398. style="width: 100%;"
  399. :rules="dialog.editorBox.form.line"
  400. >
  401. <el-option
  402. v-for="item of nameObj.line.arr"
  403. :key="item.id"
  404. :value="item.id"
  405. :label="item.name"
  406. ></el-option>
  407. </el-select>
  408. </el-form-item>
  409. </el-col>
  410. <el-col :span="12">
  411. <el-form-item
  412. label="月份"
  413. prop="yearmonth"
  414. >
  415. <zj-timegran-date
  416. v-model="dialog.editorBox.form.data.yearmonth"
  417. style="width: 100%;"
  418. :timegranId="'MONTH'"
  419. :defaultOffset="-1"
  420. :rules="dialog.editorBox.form.yearmonth"
  421. ></zj-timegran-date>
  422. </el-form-item>
  423. </el-col>
  424. </el-row>
  425. <el-row>
  426. <!-- <el-col :span="12">
  427. <el-form-item
  428. label="计量单位"
  429. prop="unit"
  430. >
  431. <el-select
  432. placeholder=""
  433. prop="unitid"
  434. v-model="dialog.editorBox.form.data.unitid"
  435. style="width: 100%;"
  436. :rules="dialog.editorBox.form.unitid"
  437. >
  438. <el-option
  439. v-for="item of nameObj.unitid.arr"
  440. :key="item.id"
  441. :value="item.id"
  442. :label="item.name"
  443. ></el-option>
  444. </el-select>
  445. </el-form-item>
  446. </el-col> -->
  447. <el-col :span="12">
  448. <el-form-item
  449. label="计划量"
  450. prop="weight"
  451. >
  452. <el-input
  453. clearable
  454. v-model="dialog.editorBox.form.data.weight"
  455. style="width: 100%;"
  456. :rules="dialog.editorBox.form.weight"
  457. >
  458. </el-input>
  459. </el-form-item>
  460. </el-col>
  461. <!-- </el-row>
  462. <el-row> -->
  463. <el-col :span="12">
  464. <el-form-item
  465. label="备注"
  466. prop=""
  467. >
  468. <el-input
  469. clearable
  470. v-model="dialog.editorBox.form.data.memo"
  471. style="width: 100%;"
  472. >
  473. </el-input>
  474. </el-form-item>
  475. </el-col>
  476. </el-row>
  477. </el-form>
  478. </div>
  479. <span
  480. slot="footer"
  481. class="dialog-footer"
  482. >
  483. <el-button
  484. :loading="loading"
  485. @click="dialog.editorBox.show = false"
  486. >取 消</el-button>
  487. <el-button
  488. type="primary"
  489. @click="dataSave"
  490. :loading="loading"
  491. >保 存</el-button>
  492. </span>
  493. </el-dialog>
  494. <el-dialog
  495. title="年计划编制-机焦厂(副产品)复制"
  496. :visible.sync="dialog.editorBox2.show"
  497. width="400px"
  498. :close-on-click-modal="false"
  499. :show-close="!loading"
  500. >
  501. <div>
  502. <el-form
  503. :model="dialog.editorBox2.form.data"
  504. ref="dialog_form2"
  505. size="mini"
  506. label-width="300px"
  507. :rules="dialog.editorBox2.form.rules"
  508. >
  509. <el-row>
  510. <el-col>
  511. <el-col :span="12">
  512. <el-form-item
  513. label="月份"
  514. prop="memo"
  515. label-width="60px"
  516. >
  517. <zj-timegran-date
  518. v-model="dialog.editorBox2.form.data.yearmonth"
  519. style="width: 150%;"
  520. :timegranId="'MONTH'"
  521. :defaultOffset="-1"
  522. :rules="dialog.editorBox.form.yearmonth"
  523. ></zj-timegran-date>
  524. </el-form-item>
  525. </el-col>
  526. </el-col>
  527. </el-row>
  528. </el-form>
  529. </div>
  530. <span
  531. slot="footer"
  532. class="dialog-footer"
  533. >
  534. <el-button
  535. :loading="loading"
  536. @click="dialog.editorBox2.show = false"
  537. >取 消</el-button>
  538. <el-button
  539. type="primary"
  540. @click="but_copy_plural"
  541. :loading="loading"
  542. >保 存</el-button>
  543. </span>
  544. </el-dialog>
  545. </div>
  546. </template>
  547. <script>
  548. import { zCheckNumber1 } from '~/utils/validator.js'
  549. import timegranDate from '~/components/zg/timegranDate.vue'
  550. import {formatDate, XtcommonSummaries, getCookie} from '@/utils/util.js';
  551. export default {
  552. name: 'outElectricity',
  553. components: {
  554. 'zj-timegran-date': timegranDate
  555. },
  556. data () {
  557. let setDate = new Date();
  558. setDate.setDate(15);
  559. setDate.setMonth((setDate.getMonth() - 1));
  560. return {
  561. rowIndex: '',
  562. columnId: '',
  563. focusTarget: null,
  564. seqArr: [],
  565. editSetFlag: '',
  566. isCheck: false, // 是否为审核人
  567. filterForm: {
  568. show: true,
  569. data: {
  570. clock: '',
  571. clockc: '',
  572. workprocid: [],
  573. location: [],
  574. networkid: [],
  575. state: '',
  576. itemname: '',
  577. searchtype: '0',
  578. measureid: '',
  579. line: '',
  580. productid: '',
  581. unit: '',
  582. yearmonth: '',
  583. weight: '',
  584. cjr: '',
  585. xgr: '',
  586. xgsj: '',
  587. memo: '',
  588. cp: '',
  589. sysl: '',
  590. wxsy: '',
  591. parentid: 'JJF',
  592. cjsj: '',
  593. jzsj: '',
  594. zt: '',
  595. show: false
  596. },
  597. rules: {
  598. },
  599. disabled: {
  600. networkid: false
  601. }
  602. },
  603. pageNum: 1,
  604. pageSize: 100,
  605. total: 0,
  606. singleTableHeight: 100,
  607. tableData: [
  608. ],
  609. loading: false,
  610. tableLoading: false,
  611. multipleSelection: [],
  612. tableFormDataObj: {},
  613. tableFormRules: {
  614. mintvalue: [
  615. // { required: true, message: '该项不能为空', trigger: 'change' },
  616. { validator: zCheckNumber1, trigger: 'change' }
  617. ],
  618. mendvalue: [
  619. // { required: true, message: '该项不能为空', trigger: 'change' },
  620. { validator: zCheckNumber1, trigger: 'change' }
  621. ],
  622. weight: [
  623. { required: true, message: '该项不能为空', trigger: 'change' },
  624. { validator: zCheckNumber1, trigger: 'change' }
  625. ],
  626. wastage: [
  627. { validator: zCheckNumber1, trigger: 'change' }
  628. ],
  629. secondVal: [
  630. { validator: zCheckNumber1, trigger: 'change' }
  631. ],
  632. memo: [
  633. ]
  634. },
  635. nameObj: {
  636. state: {
  637. obj: {
  638. '0': {
  639. name: '未编辑',
  640. color: '#7a7a7a'
  641. },
  642. '1': {
  643. name: '已编辑',
  644. color: 'rgb(28, 111, 217)'
  645. },
  646. '2': {
  647. name: '已审核',
  648. color: 'red'
  649. },
  650. '3': {
  651. name: '已接收',
  652. color: 'red'
  653. }
  654. },
  655. arr: [
  656. {
  657. id: '0',
  658. name: '未编辑'
  659. },
  660. {
  661. id: '1',
  662. name: '已编辑'
  663. },
  664. {
  665. id: '2',
  666. name: '已审核'
  667. },
  668. {
  669. name: '已接收',
  670. color: 'red'
  671. }
  672. ]
  673. },
  674. type: {
  675. obj: {
  676. '0': '否',
  677. '1': '是'
  678. },
  679. arr: [
  680. {
  681. id: '0',
  682. name: '否'
  683. },
  684. {
  685. id: '1',
  686. name: '是'
  687. }
  688. ]
  689. },
  690. unitid: {
  691. obj: {
  692. 't': {
  693. id: 't',
  694. name: '吨'
  695. }
  696. },
  697. arr: [
  698. {
  699. id: 't',
  700. name: '吨'
  701. }
  702. ]
  703. },
  704. workprocid: {
  705. obj: {
  706. 'AT3024': {
  707. id: 'AT3024',
  708. name: '焦油'
  709. },
  710. 'AT2011': {
  711. id: 'AT2011',
  712. name: '粗苯'
  713. },
  714. 'AT3010': {
  715. id: 'AT3010',
  716. name: '硫铵'
  717. }},
  718. arr: [{
  719. id: 'AT3024',
  720. name: '焦油'
  721. },
  722. {
  723. id: 'AT2011',
  724. name: '粗苯'
  725. },
  726. {
  727. id: 'AT3010',
  728. name: '硫铵'
  729. }]
  730. },
  731. line: {
  732. obj: {
  733. 'AT3024': {
  734. id: 'AT3024',
  735. name: '焦油'
  736. },
  737. 'AT3009': {
  738. id: 'AT3009',
  739. name: '粗苯'
  740. },
  741. 'AT3010': {
  742. id: 'AT3010',
  743. name: '硫铵'
  744. }},
  745. arr: [{
  746. id: 'AT3024',
  747. name: '焦油'
  748. },
  749. {
  750. id: 'AT3009',
  751. name: '粗苯'
  752. },
  753. {
  754. id: 'AT3010',
  755. name: '硫铵'
  756. }]
  757. },
  758. location: {
  759. obj: {},
  760. arr: [],
  761. showDataArr: []
  762. },
  763. locateid: {
  764. obj: {},
  765. arr: []
  766. },
  767. networkid: {
  768. obj: {},
  769. arr: []
  770. },
  771. userId: {
  772. obj: {},
  773. arr: []
  774. }
  775. },
  776. dialog: {
  777. fRow: null,
  778. editorBox: {
  779. show: false,
  780. type: '',
  781. form: {
  782. default: {
  783. workprocid: ''
  784. },
  785. data: {
  786. unitid: '',
  787. line: '',
  788. productid: '',
  789. yearmonth: '',
  790. weight: '',
  791. memo: ''
  792. },
  793. rules: {
  794. weight: [
  795. { required: true, message: '该项不能为空', trigger: 'change' },
  796. { validator: zCheckNumber1, trigger: 'change' }
  797. ],
  798. workprocid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
  799. productid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
  800. yearmonth: [{ required: true, message: '该项不能为空', trigger: 'change' }],
  801. unitid: [{ required: true, message: '该项不能为空', trigger: 'change' }],
  802. line: [{ required: true, message: '该项不能为空', trigger: 'change' }]
  803. }
  804. }
  805. },
  806. editorBox2: {
  807. show: false,
  808. type: '',
  809. form: {
  810. data: {
  811. yearmonth: ''
  812. },
  813. rules: {
  814. yearmonth: [{ required: true, message: '该项不能为空', trigger: 'change' }]
  815. }
  816. }
  817. }
  818. },
  819. butPrivilege: {
  820. QUERY: false,
  821. PUT: false,
  822. CHECK: false,
  823. UNDOCHECK: false
  824. },
  825. loginName: getCookie('loginName')
  826. }
  827. },
  828. created () {
  829. // 获取按钮权限
  830. this.activeMenu = window.localStorage.getItem('activeMenu');
  831. for (let key in this.butPrivilege) {
  832. this.butPrivilege[key] = this.checkPrivilege(this.activeMenu + key);
  833. }
  834. },
  835. mounted () {
  836. let that = this;
  837. window.PEDataObj = {
  838. // 将数据绑定到window上,供main页面使用
  839. vm: that,
  840. // tableArr:用于导出成Excel的表格的信息
  841. tableArr: [
  842. {
  843. name: '',
  844. id: 'singleTable'
  845. }
  846. ]
  847. };
  848. that.$nextTick(() => {
  849. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  850. setTimeout(() => {
  851. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  852. }, 1);
  853. });
  854. // 接收路由参数
  855. if (that.$route.query.networkid) {
  856. that.filterForm.disabled.networkid = true;
  857. that.filterForm.data.networkid = that.$route.query.networkid.split(',');
  858. }
  859. // 当有审核与取消审核权限时,默认其为审核人,审核人无法修改数据
  860. if (that.butPrivilege.CHECK || that.butPrivilege.UNDOCHECK) {
  861. that.isCheck = true;
  862. }
  863. // 管理员在这里录入数据
  864. if (that.loginName === 'admin' && that.filterForm.disabled.networkid) {
  865. that.isCheck = false;
  866. }
  867. // that.getLocation();
  868. that.getLocateIdData();
  869. that.getNetworkIdData();
  870. // that.getTableData();
  871. that.getUnitIdData();
  872. },
  873. methods: {
  874. // 计算树区域高度
  875. getRoleHeight (dom) {
  876. return window.innerHeight - dom.offsetTop;
  877. },
  878. // 自定义的表格合计方法:只给指定列进行合计
  879. getSummaries (param) {
  880. const prop = ['apportvalue', 'realvalue', 'wastage', 'total']; // 合计列绑定的prop
  881. const {columns, data} = param;
  882. const sums = XtcommonSummaries(param, prop);
  883. let that = this;
  884. columns.forEach((column, index) => {
  885. if (index === 1) {
  886. sums[index] = '合计';
  887. return;
  888. };
  889. let lineTotal = 0;
  890. let weiItem = 0;
  891. switch (column.property) {
  892. case 'weight':
  893. lineTotal = 0;
  894. for (let i = 0; i < that.tableData.length; i++) {
  895. switch (0) {
  896. case index % 7:
  897. that.tableData[i].weight.forEach((item, key) => {
  898. weiItem = (isNaN(item['AT3010']) ? 0 : item['AT3010']);
  899. lineTotal += Number(weiItem);
  900. });
  901. break;
  902. case index % 6:
  903. that.tableData[i].weight.forEach((item, key) => {
  904. weiItem = (isNaN(item['AT3009']) ? 0 : item['AT3009']);
  905. lineTotal += Number(weiItem);
  906. });
  907. break;
  908. default:
  909. that.tableData[i].weight.forEach((item, key) => {
  910. weiItem = (isNaN(item['AT3024']) ? 0 : item['AT3024']);
  911. lineTotal += Number(weiItem);
  912. });
  913. break;
  914. }
  915. };
  916. sums[index] = lineTotal;
  917. break;
  918. default:
  919. break;
  920. }
  921. });
  922. return sums;
  923. },
  924. // 获取工序列表
  925. // getNodeData () {
  926. // let that = this
  927. // let url = 'pass/ems/v1/trmworkprocs/getIdAndName?issettle=1';
  928. // that.axios.get(url)
  929. // .then(function (res) {
  930. // if (res.code === '0') {
  931. // let arr = [];
  932. // let obj = {};
  933. // for (let item of res.data) {
  934. // arr.push({
  935. // id: item.id,
  936. // name: item.name
  937. // })
  938. // obj[item.id] = item.name;
  939. // }
  940. // that.nameObj.workprocid.arr = arr;
  941. // that.nameObj.workprocid.obj = obj;
  942. // that.connn();
  943. // } else {
  944. // that.$message.error(res.message);
  945. // }
  946. // });
  947. // },
  948. getUnitIdData () {
  949. let that = this
  950. let url = 'pass/ems/v1/trmunits/getIdAndName';
  951. that.axios.get(url)
  952. .then(function (res) {
  953. if (res.code === '0') {
  954. let arr = [];
  955. let obj = {};
  956. for (let item of res.data) {
  957. arr.push({
  958. id: item.id,
  959. name: item.name
  960. })
  961. obj[item.id] = item.name;
  962. if (item.name === '吨') {
  963. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  964. }
  965. }
  966. that.nameObj.unitid.arr = arr;
  967. that.nameObj.unitid.obj = obj;
  968. } else {
  969. that.$message.error(res.message);
  970. }
  971. });
  972. },
  973. // 获取站所
  974. getNetworkIdData () {
  975. let that = this
  976. let url = 'pass/ems/v1/trmstations/getidandname/';
  977. that.axios.get(url)
  978. .then(function (res) {
  979. if (res.code === '0') {
  980. let arr = [];
  981. let obj = {};
  982. for (let item of res.data) {
  983. arr.push({
  984. id: item.id,
  985. name: item.name
  986. })
  987. obj[item.id] = item.name;
  988. }
  989. that.nameObj.networkid.arr = arr;
  990. that.nameObj.networkid.obj = obj;
  991. } else {
  992. that.$message.error(res.message);
  993. }
  994. });
  995. },
  996. but_copy_plural () {
  997. let that = this;
  998. let SubmitData = [];
  999. for (let key in that.tableFormDataObj) {
  1000. let memoArr = that.tableFormDataObj[key].memo.split(';');
  1001. for (let i = 0; i < that.tableFormDataObj[key].weight.length; i++) {
  1002. for (let keyname in that.tableFormDataObj[key].weight[i]) {
  1003. SubmitData.push({
  1004. weight: that.tableFormDataObj[key].weight[i][keyname],
  1005. memo: memoArr[i],
  1006. unit: that.tableFormDataObj[key].unit,
  1007. parentid: that.filterForm.data.parentid,
  1008. line: that.tableFormDataObj[key].line[i][i],
  1009. yearmonth: that.dialog.editorBox2.form.data.yearmonth
  1010. });
  1011. };
  1012. };
  1013. }
  1014. that.$refs['dialog_form2'].validate((valid) => {
  1015. if (valid) {
  1016. that.loading = true;
  1017. that.axios.post('pass/ems/v1/emsprodplanyears/', SubmitData, {
  1018. contentType: 'application/json'
  1019. })
  1020. .then(function (res) {
  1021. if (res.code === '0') {
  1022. that.$message({
  1023. message: '复制成功',
  1024. type: 'success'
  1025. });
  1026. that.getTableData();
  1027. that.dialog.editorBox2.show = false;
  1028. } else {
  1029. that.$message.error(res.message);
  1030. }
  1031. that.loading = false;
  1032. }).catch(function () {
  1033. that.loading = false;
  1034. });
  1035. } else {
  1036. this.$message.error('至少选择一条数据');
  1037. }
  1038. });
  1039. },
  1040. connn () {
  1041. let that = this;
  1042. if (!that.filterForm.data.networkid || that.filterForm.data.networkid.length === 0) {
  1043. that.nameObj.location.showDataArr = that.nameObj.workprocid.arr;
  1044. } else {
  1045. let url = 'pass/ems/v1/trmelectricitylocations/getWorkprocs?workshop=' + that.filterForm.data.networkid.toString();
  1046. that.axios.get(url)
  1047. .then(function (res) {
  1048. if (res.code === '0') {
  1049. let arr = [];
  1050. for (let item of res.data) {
  1051. arr.push({
  1052. id: item.id,
  1053. name: item.name
  1054. })
  1055. }
  1056. that.nameObj.location.showDataArr = arr;
  1057. } else {
  1058. that.$message.error(res.message);
  1059. }
  1060. });
  1061. }
  1062. },
  1063. // 获取位置
  1064. getLocateIdData () {
  1065. let that = this
  1066. let url = 'pass/ems/v1/trmlocations/getidandname/';
  1067. that.axios.get(url)
  1068. .then(function (res) {
  1069. if (res.code === '0') {
  1070. let arr = [];
  1071. let obj = {};
  1072. for (let item of res.data) {
  1073. arr.push({
  1074. id: item.id,
  1075. name: item.name
  1076. })
  1077. obj[item.id] = item.name;
  1078. }
  1079. that.nameObj.locateid.arr = arr;
  1080. that.nameObj.locateid.obj = obj;
  1081. } else {
  1082. that.$message.error(res.message);
  1083. }
  1084. });
  1085. },
  1086. // 获取表格中的数据
  1087. getTableData (pageNum) {
  1088. let that = this,
  1089. params = {},
  1090. pData = {
  1091. yearmonth: that.filterForm.data.yearmonth,
  1092. workprocid: that.filterForm.data.workprocid.toString(),
  1093. location: that.filterForm.data.location.toString(),
  1094. networkid: that.filterForm.data.networkid.toString(),
  1095. itemname: that.filterForm.data.itemname,
  1096. zt: that.filterForm.data.zt,
  1097. measureid: that.filterForm.data.measureid,
  1098. exactsearch: that.filterForm.data.searchtype,
  1099. parentid: that.filterForm.data.parentid,
  1100. parentNum: that.nameObj.line.arr.length
  1101. };
  1102. for (let key in pData) {
  1103. if (pData[key]) {
  1104. params[key] = pData[key];
  1105. }
  1106. }
  1107. that.pageNum = pageNum || that.pageNum;
  1108. that.tableLoading = true;
  1109. // let url = 'pass/ems/v1/trmtransfereactvalues/getDateEditForPage/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  1110. // if (that.isCheck) {
  1111. // url = 'pass/ems/v1/trmtransfereactvalues/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  1112. // }
  1113. let url = 'pass/ems/v1/emsprodplanyears/getList?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  1114. that.axios.get(url, {
  1115. params: params
  1116. })
  1117. .then(function (res) {
  1118. if (res.code === '0') {
  1119. let arr = [];
  1120. let index = 0;
  1121. let chirItem = res.data.list[0];
  1122. for (let e in chirItem) {
  1123. let item = chirItem[e];
  1124. let weightArr = [];
  1125. let lineArr = [];
  1126. let noArr = [];
  1127. let memoArr = [];
  1128. let sum = 0;
  1129. let memoLong = '';
  1130. for (let i = 0; i < chirItem[e].length; i++) {
  1131. weightArr.push({
  1132. [item[i].line]: item[i].weight
  1133. });
  1134. lineArr.push({
  1135. [i]: item[i].line
  1136. });
  1137. memoArr.push({
  1138. [i]: item[i].memo
  1139. });
  1140. noArr.push({
  1141. [i]: item[i].no
  1142. });
  1143. if (item[i].memo !== null && item[i].memo !== '') {
  1144. memoLong = memoLong + item[i].memo + ';';
  1145. }
  1146. sum += item[i].weight;
  1147. };
  1148. arr.push({
  1149. seq: index,
  1150. unit: item[chirItem[e].length - 1].unit,
  1151. line: lineArr,
  1152. yearmonth: item[chirItem[e].length - 1].yearmonth,
  1153. weight: weightArr,
  1154. cjr: item[chirItem[e].length - 1].cjr,
  1155. cjsj: item[chirItem[e].length - 1].cjsj,
  1156. jzsj: item[chirItem[e].length - 1].jzsj,
  1157. xgr: item[chirItem[e].length - 1].xgr,
  1158. xgsj: item[chirItem[e].length - 1].xgsj,
  1159. cp: item[chirItem[e].length - 1].cp,
  1160. sysl: item[chirItem[e].length - 1].sysl,
  1161. wxsy: item[chirItem[e].length - 1].wxsy,
  1162. zt: item[chirItem[e].length - 1].zt,
  1163. parentid: item[chirItem[e].length - 1].parentid,
  1164. no: noArr,
  1165. id: item[chirItem[e].length - 1].id,
  1166. memo: memoLong,
  1167. total: sum
  1168. });
  1169. index = index + 1;
  1170. }
  1171. that.total = res.data.total;
  1172. that.tableData = JSON.parse(JSON.stringify(arr));
  1173. that.originalData = JSON.parse(JSON.stringify(arr));
  1174. that.getAdds();
  1175. } else {
  1176. that.$message.error(res.message);
  1177. }
  1178. that.$nextTick(() => {
  1179. setTimeout(() => {
  1180. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
  1181. }, 1);
  1182. });
  1183. that.tableLoading = false;
  1184. }).catch(function () {
  1185. that.tableLoading = false;
  1186. });
  1187. },
  1188. // 获取表格中的数据
  1189. getTableDataEdit () {
  1190. let that = this,
  1191. params = {},
  1192. pData = {
  1193. yearmonth: that.filterForm.data.yearmonth,
  1194. workprocid: that.filterForm.data.workprocid.toString(),
  1195. location: that.filterForm.data.location.toString(),
  1196. networkid: that.filterForm.data.networkid.toString(),
  1197. itemname: that.filterForm.data.itemname,
  1198. exactsearch: that.filterForm.data.searchtype,
  1199. parentid: that.filterForm.data.parentid
  1200. };
  1201. for (let key in pData) {
  1202. if (pData[key]) {
  1203. params[key] = pData[key];
  1204. }
  1205. }
  1206. that.tableLoading = true;
  1207. let url = 'pass/ems/v1/emsprodplanyears/getDateEditForPage/?pageNum=1&pageSize=' + that.pageSize;
  1208. that.axios.get(url, {
  1209. params: params
  1210. })
  1211. .then(function (res) {
  1212. if (res.code === '0') {
  1213. let arr = [];
  1214. for (let i = 0; i < res.data.list.length; i++) {
  1215. let item = res.data.list[i];
  1216. arr.push({
  1217. seq: i,
  1218. unit: item.unit,
  1219. line: item.line,
  1220. yearmonth: item.yearmonth,
  1221. weight: item.weight,
  1222. cjr: item.cjr,
  1223. cjsj: item.cjsj,
  1224. jzsj: item.jzsj,
  1225. xgr: item.xgr,
  1226. xgsj: item.xgsj,
  1227. cp: item.cp,
  1228. sysl: item.sysl,
  1229. zt: item.zt,
  1230. wxsy: item.wxsy,
  1231. productid: item.productid
  1232. });
  1233. }
  1234. that.total = res.data.total;
  1235. that.tableData = arr;
  1236. that.getAdds();
  1237. } else {
  1238. that.$message.error(res.message);
  1239. }
  1240. that.$nextTick(() => {
  1241. setTimeout(() => {
  1242. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
  1243. }, 1);
  1244. });
  1245. that.tableLoading = false;
  1246. }).catch(function () {
  1247. that.tableLoading = false;
  1248. });
  1249. },
  1250. // 合并相同的用电地点
  1251. arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
  1252. let that = this;
  1253. let tableData = this.$refs.singleTable.tableData
  1254. let c1 = row.workprocid;
  1255. let c2 = row.location;
  1256. let c3 = row.workshop;
  1257. let c4 = row.clock;
  1258. let c5 = row.clocke;
  1259. let rowsPan = 1;
  1260. // let adds = this.$refs.singleTable.tableData[rowIndex].realvalue;
  1261. if (column['property'] === 'workprocid' || column['property'] === 'adds') {
  1262. if (rowIndex > 0 && c1 === tableData[rowIndex - 1].workprocid && c2 === tableData[rowIndex - 1].location &&
  1263. c3 === tableData[rowIndex - 1].workshop && c4 === tableData[rowIndex - 1].clock && c5 === tableData[rowIndex - 1].clocke) {
  1264. return {
  1265. rowspan: 0,
  1266. colspan: 0
  1267. };
  1268. };
  1269. while (tableData[rowIndex + rowsPan] && c1 === tableData[rowIndex + rowsPan].workprocid && c2 === tableData[rowIndex + rowsPan].location &&
  1270. c3 === tableData[rowIndex + rowsPan].workshop && c4 === tableData[rowIndex + rowsPan].clock && c5 === tableData[rowIndex + rowsPan].clocke) {
  1271. rowsPan += 1
  1272. }
  1273. return {
  1274. rowspan: rowsPan,
  1275. colspan: 1
  1276. };
  1277. }
  1278. },
  1279. // 改变表格显示条数
  1280. tableSizeChange (val) {
  1281. let that = this;
  1282. that.pageSize = val;
  1283. that.getTableData(1);
  1284. },
  1285. // 重置搜索
  1286. tableDataCancel () {
  1287. let that = this;
  1288. for (let key in that.filterForm.data) {
  1289. if (!that.filterForm.disabled || !that.filterForm.disabled[key]) {
  1290. if (that.filterForm.data[key] instanceof Array) {
  1291. that.filterForm.data[key] = [];
  1292. } else {
  1293. that.filterForm.data[key] = '';
  1294. }
  1295. }
  1296. }
  1297. that.getTableData(1);
  1298. },
  1299. keyDown (event1, disabledFlag) {
  1300. let tdTarget = event1.target;
  1301. let _this = this;
  1302. while (tdTarget.tagName !== 'TD') {
  1303. tdTarget = tdTarget.parentElement;
  1304. }
  1305. // 如果按下键盘下键或者回车键
  1306. if (event.keyCode === 40 || event.keyCode === 13) {
  1307. let index = parseInt(this.rowIndex);
  1308. // index++;
  1309. if (index !== this.seqArr[this.seqArr.length - 1]) {
  1310. for (let i = 0; i < this.seqArr.length; i++) {
  1311. if (index === this.seqArr[i]) {
  1312. index = this.seqArr[i + 1];
  1313. break;
  1314. }
  1315. }
  1316. }
  1317. this.editSetFlag = index + this.columnId;
  1318. let id = '#' + this.editSetFlag;
  1319. this.$nextTick(() => {
  1320. $(id).click();
  1321. });
  1322. } else if (event.keyCode === 38) { // 键盘上键
  1323. let index = parseInt(this.rowIndex);
  1324. if (index !== this.seqArr[0]) {
  1325. for (let i = 0; i < this.seqArr.length; i++) {
  1326. if (index === this.seqArr[i]) {
  1327. index = this.seqArr[i - 1];
  1328. break;
  1329. }
  1330. }
  1331. }
  1332. this.editSetFlag = index + this.columnId;
  1333. let id = '#' + this.editSetFlag;
  1334. this.$nextTick(() => {
  1335. $(id).click();
  1336. });
  1337. } else if (event.keyCode === 37) { // 键盘左键
  1338. $(tdTarget).prevAll().find('input:text').last().click();
  1339. } else if (event.keyCode === 39) { // 键盘右键
  1340. $(tdTarget).nextAll().find('input').eq(0).click();
  1341. }
  1342. },
  1343. // 只允许对未接受的数据进行操作
  1344. checkboxT (row, index) {
  1345. if (row.zt === '2' && !this.isCheck) {
  1346. return false;
  1347. } else {
  1348. return true;
  1349. }
  1350. },
  1351. handleSelectionChange (val) {
  1352. let that = this;
  1353. let tableFormDataObj = {};
  1354. let arr = [];
  1355. for (let item of val) {
  1356. arr.push(item.seq);
  1357. }
  1358. this.seqArr = arr.sort(sortNumber);
  1359. for (let item of that.tableData) {
  1360. item.isSelection = false;
  1361. }
  1362. // 引用类型拷贝值JSON.parse(JSON.stringify(obj)
  1363. let arrcha = [...JSON.parse(JSON.stringify(that.originalData))].filter(x => [...val].every(y => y.id !== x.id));
  1364. for (let item of arrcha) {
  1365. // 取消选择时赋初始值
  1366. for (let weiIndex in that.tableData[item.seq].weight) {
  1367. for (let weiKey in that.tableData[item.seq].weight[weiIndex]) {
  1368. that.tableData[item.seq].weight[weiIndex][weiKey] = that.originalData[item.seq].weight[weiIndex][weiKey];
  1369. }
  1370. }
  1371. // that.tableData[item.seq] = JSON.parse(JSON.stringify(that.originalData[item.seq]));
  1372. };
  1373. for (let item of val) {
  1374. let obj = {};
  1375. let xId = item.seq;
  1376. if (that.tableFormDataObj[xId]) {
  1377. // 如果已存在该数据则使用该数据
  1378. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  1379. } else {
  1380. // 负责则从对应行中获取行内原数据
  1381. for (let key in item) {
  1382. obj[key] = item[key];
  1383. }
  1384. item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
  1385. tableFormDataObj[xId] = obj;
  1386. }
  1387. item.isSelection = true;
  1388. }
  1389. for (let item of that.tableData) {
  1390. if (item.isSelection === false) {
  1391. item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
  1392. }
  1393. }
  1394. that.tableFormDataObj = tableFormDataObj;
  1395. that.multipleSelection = val;
  1396. this.getAdds();
  1397. },
  1398. // 当上月底码发生改变时计算抄度与实际电量
  1399. getApportValue (seq, value, rowIndex, event) {
  1400. let that = this;
  1401. if (!isNaN(Number(value))) {
  1402. if (!isNaN(Number(that.tableFormDataObj[seq].mintvalue)) && !isNaN(Number(that.tableFormDataObj[seq].mendvalue)) && that.tableFormDataObj[seq].mintvalue !== null && that.tableFormDataObj[seq].mendvalue !== null) {
  1403. let poor = that.floatComputed(Number(that.tableFormDataObj[seq].mendvalue), Number(that.tableFormDataObj[seq].mintvalue), '-');
  1404. that.tableFormDataObj[seq].apportvalue = that.floatComputed(poor, Number(that.tableFormDataObj[seq].mods), '*').toFixed(0);
  1405. let rv1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
  1406. that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
  1407. that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
  1408. }
  1409. }
  1410. },
  1411. // 手动修改抄度后计算实际电量
  1412. chnageApportvalue (seq, value, rowIndex) {
  1413. let that = this;
  1414. if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].wastage))) {
  1415. that.tableFormDataObj[seq].realvalue = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].wastage), '+').toFixed(0);
  1416. }
  1417. that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
  1418. },
  1419. // 手动修改损耗后计算实际电量
  1420. chnageWastage (seq, value, rowIndex) {
  1421. let that = this;
  1422. if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
  1423. let rv1 = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].apportvalue), '+');
  1424. that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
  1425. that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
  1426. }
  1427. },
  1428. // 手动修改二次转供电后计算实际电量
  1429. chnageSecondVal (seq, value, rowIndex) {
  1430. let that = this;
  1431. if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
  1432. let val1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
  1433. that.tableFormDataObj[seq].realvalue = that.floatComputed(val1, Number(value), '-').toFixed(0);
  1434. that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
  1435. }
  1436. },
  1437. // 统计合计值
  1438. getAdds () {
  1439. let that = this;
  1440. let wlarr = [];
  1441. for (var i = 0; i < that.tableData.length; i++) {
  1442. wlarr.push(that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke);
  1443. }
  1444. let wls = [...new Set(wlarr)]
  1445. let arrs = [];
  1446. for (let wl of wls) {
  1447. let adds = 0;
  1448. for (let item of that.tableData) {
  1449. if (wl === item.workprocid + '-' + item.location + '-' + item.workshop + '-' + item.clock + '-' + item.clocke) {
  1450. adds = that.floatComputed(Number(item.realvalue), adds, '+');
  1451. }
  1452. }
  1453. for (let i = 0; i < that.tableData.length; i++) {
  1454. if (wl === that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke) {
  1455. that.tableData[i].adds = adds;
  1456. }
  1457. }
  1458. }
  1459. },
  1460. // 展示实际电量
  1461. showRealValue (rowIndex, value) {
  1462. let that = this;
  1463. for (let i = 0; i < that.tableData.length; i++) {
  1464. if (i === rowIndex) {
  1465. that.tableData[i].realvalue = value;
  1466. }
  1467. }
  1468. this.getAdds();
  1469. },
  1470. // 批量修改
  1471. but_edit_plural () {
  1472. let that = this;
  1473. if (that.multipleSelection.length > 0) {
  1474. that.$refs['dialog_form_arr'].validate((valid, obj) => {
  1475. if (valid) {
  1476. let SubmitData = [];
  1477. for (let key in that.tableFormDataObj) {
  1478. let memoArr = that.tableFormDataObj[key].memo.split(';');
  1479. for (let i = 0; i < that.tableFormDataObj[key].weight.length; i++) {
  1480. for (let keyname in that.tableFormDataObj[key].weight[i]) {
  1481. SubmitData.push({
  1482. weight: that.tableFormDataObj[key].weight[i][keyname],
  1483. no: that.tableFormDataObj[key].no[i][i],
  1484. memo: memoArr[i],
  1485. cjsj: that.tableFormDataObj[key].cjsj,
  1486. jzsj: that.tableFormDataObj[key].jzsj,
  1487. line: that.tableFormDataObj[key].line[i][i],
  1488. xgr: that.tableFormDataObj[key].xgr,
  1489. xgsj: that.tableFormDataObj[key].xgsj,
  1490. cp: that.tableFormDataObj[key].cp,
  1491. sysl: that.tableFormDataObj[key].sysl,
  1492. zt: that.tableFormDataObj[key].zt,
  1493. wxsy: that.tableFormDataObj[key].wxsy,
  1494. unit: that.tableFormDataObj[key].unit,
  1495. parentid: that.filterForm.data.parentid,
  1496. yearmonth: that.tableFormDataObj[key].yearmonth
  1497. });
  1498. };
  1499. }
  1500. }
  1501. that.loading = true;
  1502. that.axios.put('pass/ems/v1/emsprodplanyears/batchupdateList', SubmitData)
  1503. .then(function (res) {
  1504. if (res.code === '0') {
  1505. that.$message({
  1506. message: '修改成功',
  1507. type: 'success'
  1508. });
  1509. that.getTableData();
  1510. that.dialog.editorBox.show = false;
  1511. } else {
  1512. that.$message.error(res.message);
  1513. }
  1514. that.loading = false;
  1515. }).catch(function () {
  1516. that.loading = false;
  1517. });
  1518. }
  1519. });
  1520. } else {
  1521. this.$message.error('至少选择一条数据');
  1522. }
  1523. },
  1524. dataSave () {
  1525. let that = this;
  1526. let SubmitData = [];
  1527. SubmitData.push({
  1528. yearmonth: that.dialog.editorBox.form.data.yearmonth,
  1529. weight: that.dialog.editorBox.form.data.weight,
  1530. unit: that.dialog.editorBox.form.data.unitid,
  1531. line: that.dialog.editorBox.form.data.line,
  1532. productid: that.dialog.editorBox.form.data.productid,
  1533. parentid: that.filterForm.data.parentid,
  1534. memo: that.dialog.editorBox.form.data.memo
  1535. });
  1536. that.$refs['dialog_form'].validate((valid) => {
  1537. if (valid) {
  1538. that.loading = true;
  1539. that.axios.post('pass/ems/v1/emsprodplanyears/', SubmitData, {
  1540. contentType: 'application/json'
  1541. })
  1542. .then(function (res) {
  1543. if (res.code === '0') {
  1544. that.$message({
  1545. message: '新增成功',
  1546. type: 'success'
  1547. });
  1548. that.getTableData();
  1549. that.dialog.editorBox.show = false;
  1550. } else {
  1551. that.$message.error(res.message);
  1552. }
  1553. that.loading = false;
  1554. }).catch(function () {
  1555. that.loading = false;
  1556. });
  1557. }
  1558. }
  1559. );
  1560. },
  1561. // 批量删除
  1562. but_del_plural () {
  1563. let that = this;
  1564. if (that.multipleSelection.length > 0) {
  1565. let SubmitData = [];
  1566. for (let item of that.multipleSelection) {
  1567. if (item.zt === '2') {
  1568. this.$message.error('已经审核的数据不能删除');
  1569. return;
  1570. }
  1571. for (let noItem in item.no) {
  1572. SubmitData.push({
  1573. no: item.no[noItem][noItem]
  1574. });
  1575. }
  1576. }
  1577. that.$confirm('是否删除已选数据?', '提示', {
  1578. confirmButtonText: '确定',
  1579. cancelButtonText: '取消',
  1580. state: 'warning'
  1581. }).then(() => {
  1582. that.axios.delete('pass/ems/v1/emsprodplanyears/delete', {
  1583. data: SubmitData,
  1584. contentType: 'application/json;charset=UTF-8'
  1585. })
  1586. .then(function (res) {
  1587. if (res.code === '0') {
  1588. that.$message({
  1589. message: '删除成功',
  1590. type: 'success'
  1591. });
  1592. that.getTableData();
  1593. } else {
  1594. that.$message.error(res.message);
  1595. }
  1596. }).catch(function () {
  1597. });
  1598. }).catch(() => {
  1599. });
  1600. } else {
  1601. this.$message.error('至少要选择一条数据');
  1602. }
  1603. },
  1604. upState (state = '2') {
  1605. let that = this;
  1606. let dataArr = [];
  1607. for (let item of that.multipleSelection) {
  1608. if (item.state !== state) {
  1609. dataArr.push(item);
  1610. }
  1611. }
  1612. if (dataArr.length > 0) {
  1613. that.$confirm('本次将要' + (state === '2' ? '审核' : '撤销审核') + dataArr.length + '条数据,是否确定?', '提示', {
  1614. confirmButtonText: '确定',
  1615. cancelButtonText: '取消',
  1616. state: 'warning'
  1617. }).then(() => {
  1618. let SubmitData = [];
  1619. for (let item of dataArr) {
  1620. SubmitData.push({
  1621. state: state,
  1622. id: item.id
  1623. });
  1624. }
  1625. that.loading = true;
  1626. that.axios.put('pass/ems/v1/trmtransfereactvalues/batchcheck2', SubmitData)
  1627. .then(function (res) {
  1628. if (res.code === '0') {
  1629. that.$message({
  1630. message: (state === '2' ? '审核' : '撤销') + '成功',
  1631. type: 'success'
  1632. });
  1633. that.getTableData();
  1634. } else {
  1635. that.$message.error(res.message);
  1636. }
  1637. that.loading = false;
  1638. }).catch(function () {
  1639. that.loading = false;
  1640. });
  1641. }).catch(() => {
  1642. });
  1643. } else {
  1644. if (that.multipleSelection.length > 0) {
  1645. this.$message.error('没有需要' + (state === '2' ? '审核' : '撤销') + '的数据');
  1646. } else {
  1647. this.$message.error('至少要选择一条数据');
  1648. }
  1649. }
  1650. },
  1651. but_add () {
  1652. let that = this;
  1653. that.dialog.editorBox.show = true;
  1654. setTimeout(() => {
  1655. that.$refs['dialog_form'].clearValidate();
  1656. }, 100);
  1657. },
  1658. but_copy () {
  1659. let that = this;
  1660. if (that.multipleSelection.length > 0) {
  1661. that.dialog.editorBox2.show = true;
  1662. setTimeout(() => {
  1663. that.$refs['dialog_form2'].clearValidate();
  1664. }, 100);
  1665. } else {
  1666. this.$message.error('至少要选择一条数据');
  1667. }
  1668. },
  1669. tableRowClassName ({row, rowIndex}) {
  1670. // 把每一行的索引放进row
  1671. row.index = rowIndex;
  1672. },
  1673. cellClick (row, column, cell, event) {
  1674. let _this = this;
  1675. this.rowIndex = row.index;
  1676. this.columnId = column.id;
  1677. _this.editSetFlag = row.index + column.id;
  1678. _this.focusTarget = event.target;
  1679. while (_this.focusTarget.tagName !== 'TD') {
  1680. _this.focusTarget = _this.focusTarget.parentElement;
  1681. }
  1682. _this.$nextTick(() => {
  1683. let target = this.focusTarget;
  1684. $(target).find('input').focus();
  1685. });
  1686. },
  1687. // 获取一行的总和
  1688. rowSum: function (item, event) {
  1689. let result = 0;
  1690. let that = this;
  1691. for (let weiIndex in item.weight) {
  1692. for (let weiKey in item.weight[weiIndex]) {
  1693. result += Number(item.weight[weiIndex][weiKey]);
  1694. }
  1695. }
  1696. return result;
  1697. }
  1698. }
  1699. }
  1700. function sortNumber (a, b) {
  1701. return a - b
  1702. }
  1703. </script>
  1704. <style lang="less">
  1705. .outElectricity{
  1706. min-width: 700px;
  1707. height: 100%;
  1708. .box {
  1709. height: 100%;
  1710. padding: 15px 15px 0 15px;
  1711. .box-top {
  1712. .el-form-item {
  1713. margin-bottom: 7px;
  1714. }
  1715. .box-top-gjl {
  1716. overflow: hidden;
  1717. padding: 7px 0;
  1718. border-top: 1px solid #ccc;
  1719. }
  1720. }
  1721. .rowDisable td {
  1722. color: #6bb025 !important;
  1723. }
  1724. .el-table .el-table__row {
  1725. height: 35px;
  1726. }
  1727. .el-table__body .el-form-item--mini.el-form-item {
  1728. margin: 0px;
  1729. .error {
  1730. overflow: hidden;
  1731. color: #f56c6c;
  1732. font-size: 12px;
  1733. line-height: 1;
  1734. }
  1735. }
  1736. }
  1737. .color_no {
  1738. color: #7a7a7a;
  1739. }
  1740. .color_yes {
  1741. color: #1a9f17;
  1742. }
  1743. .cnspicuous .el-checkbox__input.is-disabled .el-checkbox__inner {
  1744. background-color: #dcdfe6;
  1745. border-color: #babbbf;
  1746. }
  1747. }
  1748. </style>