planProjectDataMonth.vue 75 KB

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