planProjectSinter.vue 76 KB

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