planProjectPuddling.vue 78 KB

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