planProjectDataYear.vue 65 KB

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