processAndRawMaterials.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. <template>
  2. <!-- 原材料消耗数据维护 -->
  3. <div class="processAndRawMaterials">
  4. <div class="box">
  5. <div class="box-top">
  6. <el-form
  7. style="overflow: hidden;"
  8. :style="filterForm.show ? null : { height: '0px' }"
  9. size="mini"
  10. label-width="70px"
  11. >
  12. <el-row>
  13. <el-col :span="6">
  14. <el-form-item label="时间粒度">
  15. <el-select
  16. filterable clearable
  17. v-model="filterForm.data.timegranid"
  18. placeholder=""
  19. style="width: 100%;"
  20. >
  21. <el-option
  22. v-for="item of nameObj.timegranid.arr"
  23. :key="item.id"
  24. :value="item.id"
  25. :label="item.name"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="时间">
  32. <!-- <el-date-picker
  33. v-model="filterForm.data.clock"
  34. type="date"
  35. placeholder=""
  36. style="width: 100%;"
  37. value-format="yyyy-MM-dd"
  38. ></el-date-picker> -->
  39. <zj-timegran-date
  40. v-model="filterForm.data.clock"
  41. style="width: 100%;"
  42. :type="'daterange'"
  43. :timegranId="filterForm.data.timegranid"
  44. :oneFoo="getTableData"
  45. :defaultOffset="-1"
  46. ></zj-timegran-date>
  47. <!-- :timegranId="filterForm.data.timegranid" -->
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="6">
  51. <el-form-item label="原材料">
  52. <el-select
  53. filterable clearable
  54. multiple
  55. collapse-tags
  56. v-model="filterForm.data.materialid"
  57. placeholder=""
  58. style="width: 100%;"
  59. >
  60. <el-option
  61. v-for="item of nameObj.materialid.arr"
  62. :key="item.id"
  63. :value="item.id"
  64. :label="item.name"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="6">
  70. <el-form-item label="工序">
  71. <el-select
  72. filterable clearable
  73. multiple
  74. collapse-tags
  75. v-model="filterForm.data.workprocid"
  76. placeholder=""
  77. style="width: 100%;"
  78. >
  79. <el-option
  80. v-for="item of nameObj.workprocid.arr"
  81. :key="item.id"
  82. :value="item.id"
  83. :label="item.name"
  84. ></el-option>
  85. </el-select>
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. <el-row>
  90. <el-col :span="6">
  91. <el-form-item label="项目编号">
  92. <el-input clearable
  93. v-model="filterForm.data.itemid"
  94. placeholder=""
  95. style="width: 100%;"
  96. @keyup.enter.native="getTableData(1)"
  97. ></el-input>
  98. </el-form-item>
  99. </el-col>
  100. </el-row>
  101. </el-form>
  102. <div class="box-top-gjl">
  103. <el-button
  104. class="button"
  105. type="primary"
  106. size="mini"
  107. icon="el-icon-save"
  108. @click="but_more()"
  109. >修改</el-button>
  110. <el-button
  111. class="button"
  112. type="primary"
  113. size="mini"
  114. icon="el-icon-refresh"
  115. @click="but_re_compute()"
  116. >重新计算</el-button>
  117. <el-button
  118. class="button"
  119. type="primary"
  120. size="mini"
  121. v-privilege="activeMenu + 'PUT'"
  122. @click="but_redata()"
  123. :loading="loading"
  124. >重新生成数据</el-button>
  125. <!-- <el-button
  126. class="button"
  127. type="primary"
  128. size="mini"
  129. icon="el-icon-refresh"
  130. >重新计算</el-button> -->
  131. <div style="float:right; text-align: right;">
  132. <el-button
  133. class="button"
  134. type="primary"
  135. size="mini"
  136. icon="el-icon-search"
  137. v-privilege="activeMenu + 'QUERY'"
  138. @click="getTableData(1)"
  139. >查询</el-button>
  140. <el-button
  141. class="button"
  142. type="primary"
  143. size="mini"
  144. icon="el-icon-refresh"
  145. v-privilege="activeMenu + 'QUERY'"
  146. @click="tableDataCancel();"
  147. >重置</el-button>
  148. <el-button
  149. size="mini"
  150. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  151. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  152. @click="filterForm.show = !filterForm.show;
  153. $nextTick(() => {
  154. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  155. }
  156. );"
  157. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="box-bottom">
  162. <el-form
  163. size="mini"
  164. ref="dialog_form_arr"
  165. label-width="0px"
  166. :model="tableFormDataObj"
  167. >
  168. <el-table stripe
  169. id="singleTable"
  170. ref="singleTable"
  171. :data="tableData"
  172. v-loading="tableLoading"
  173. style="width: 100%;"
  174. :height="singleTableHeight"
  175. border
  176. size="mini"
  177. highlight-current-row
  178. show-summary
  179. :summary-method="getSummaries"
  180. @selection-change="handleSelectionChange">
  181. >
  182. <el-table-column
  183. sortable
  184. type="selection"
  185. width="40"
  186. align="center"
  187. fixed="left"
  188. >
  189. </el-table-column>
  190. <el-table-column
  191. sortable
  192. prop="timegranid"
  193. label="时间粒度"
  194. min-width="100px"
  195. :show-overflow-tooltip="true"
  196. >
  197. <template slot-scope="scope">
  198. <span>{{ nameObj.timegranid.obj[scope.row.timegranid] ? nameObj.timegranid.obj[scope.row.timegranid] : scope.row.timegranid }}</span>
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. sortable
  203. prop="clock"
  204. label="时间"
  205. min-width="100px"
  206. :show-overflow-tooltip="true"
  207. ></el-table-column>
  208. <el-table-column
  209. sortable
  210. prop="itemid"
  211. label="项目编号"
  212. min-width="100px"
  213. :show-overflow-tooltip="true"
  214. ></el-table-column>
  215. <el-table-column
  216. sortable
  217. prop="workprocid"
  218. label="工序"
  219. min-width="100px"
  220. :show-overflow-tooltip="true"
  221. >
  222. <template slot-scope="scope">
  223. <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
  224. </template>
  225. </el-table-column>
  226. <el-table-column
  227. sortable
  228. prop="materialid"
  229. label="原材料"
  230. min-width="100px"
  231. :show-overflow-tooltip="true"
  232. >
  233. <template slot-scope="scope">
  234. <span>{{ nameObj.materialid.obj[scope.row.materialid] ? nameObj.materialid.obj[scope.row.materialid] : scope.row.materialid }}</span>
  235. </template>
  236. </el-table-column>
  237. <el-table-column
  238. sortable
  239. prop="actualvalue"
  240. label="计算值"
  241. min-width="100px"
  242. :show-overflow-tooltip="true"
  243. ></el-table-column>
  244. <el-table-column
  245. sortable
  246. prop="correctvalue"
  247. label="修正值"
  248. min-width="150px"
  249. :show-overflow-tooltip="true"
  250. >
  251. <template slot-scope="scope">
  252. <el-form-item
  253. v-if="scope.row.isSelection"
  254. >
  255. <el-input clearable
  256. style="width: 90%;"
  257. v-model="tableFormDataObj[scope.row.itemid].correctvalue"
  258. refcous="true"
  259. @change="correctvalueChange(scope.row.itemid)"
  260. ></el-input>
  261. <template slot="error" slot-scope="scope">
  262. <p class="error" :title="scope.error">{{ scope.error }}</p>
  263. </template>
  264. </el-form-item>
  265. <span v-else>{{scope.row.correctvalue}}</span>
  266. </template>
  267. </el-table-column>
  268. <el-table-column
  269. sortable
  270. prop="apportvalue"
  271. label="最终值"
  272. min-width="150px"
  273. :show-overflow-tooltip="true"
  274. >
  275. <template slot-scope="scope">
  276. <el-form-item
  277. v-if="scope.row.isSelection"
  278. >
  279. <el-input clearable
  280. style="width: 90%;"
  281. v-model="tableFormDataObj[scope.row.itemid].apportvalue"
  282. refcous="true"
  283. @change="apportvalueChange(scope.row.itemid)"
  284. ></el-input>
  285. <template slot="error" slot-scope="scope">
  286. <p class="error" :title="scope.error">{{ scope.error }}</p>
  287. </template>
  288. </el-form-item>
  289. <span v-else>{{scope.row.apportvalue}}</span>
  290. </template>
  291. </el-table-column>
  292. <!--<el-table-column
  293. sortable
  294. prop="stdvalue"
  295. label="折标值"
  296. min-width="100px"
  297. :show-overflow-tooltip="true"
  298. ></el-table-column>-->
  299. <!-- <el-table-column
  300. sortable
  301. prop="sumvalue"
  302. label="累计值"
  303. min-width="100px"
  304. :show-overflow-tooltip="true"
  305. ></el-table-column> -->
  306. <el-table-column
  307. sortable
  308. prop="ucvalue"
  309. label="单耗值"
  310. min-width="100px"
  311. :show-overflow-tooltip="true"
  312. ></el-table-column>
  313. <!-- <el-table-column
  314. sortable
  315. prop="sumucvalue"
  316. label="累计单耗值"
  317. min-width="100px"
  318. :show-overflow-tooltip="true"
  319. ></el-table-column> -->
  320. <el-table-column
  321. sortable
  322. prop="unitid"
  323. label="单位"
  324. min-width="100px"
  325. :show-overflow-tooltip="true"
  326. >
  327. <template slot-scope="scope">
  328. <span>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
  329. </template>
  330. </el-table-column>
  331. <el-table-column
  332. sortable
  333. prop="bz"
  334. label="备注"
  335. min-width="100px"
  336. :show-overflow-tooltip="true"
  337. ></el-table-column>
  338. <el-table-column
  339. sortable
  340. prop="USERID"
  341. label="创建人"
  342. min-width="100px"
  343. :show-overflow-tooltip="true"
  344. ></el-table-column>
  345. <el-table-column
  346. sortable
  347. prop="UPDATETIME"
  348. label="创建时间"
  349. min-width="100px"
  350. :show-overflow-tooltip="true"
  351. ></el-table-column>
  352. <el-table-column
  353. sortable
  354. prop="UPMAN"
  355. label="更新人"
  356. min-width="100px"
  357. :show-overflow-tooltip="true"
  358. ></el-table-column>
  359. <el-table-column
  360. sortable
  361. prop="UPTIME"
  362. label="更新时间"
  363. min-width="100px"
  364. :show-overflow-tooltip="true"
  365. ></el-table-column>
  366. <!-- <el-table-column
  367. class-name="gn-TableDownloadExcel-none"
  368. label="操作"
  369. align="center"
  370. width="75px"
  371. fixed="right"
  372. >
  373. <template slot-scope="scope">
  374. <div>
  375. <el-button
  376. type="primary"
  377. size="mini"
  378. v-privilege="activeMenu + 'PUT'"
  379. @click="but_edit(scope.row)"
  380. >修改</el-button>
  381. </div>
  382. </template>
  383. </el-table-column> -->
  384. </el-table>
  385. </el-form>
  386. <el-pagination
  387. layout="total, sizes, prev, pager, next, jumper"
  388. :total="total"
  389. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  390. :page-size="pageSize"
  391. :current-page.sync="pageNum"
  392. @size-change="tableSizeChange"
  393. @current-change="getTableData()"
  394. style="text-align: right;margin-top: 10px;"
  395. ></el-pagination>
  396. </div>
  397. </div>
  398. <el-dialog
  399. :title="'工序与原材料数据信息 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
  400. :visible.sync="dialog.editorBox.show"
  401. width="300px"
  402. :close-on-click-modal="false"
  403. :show-close="!loading"
  404. >
  405. <div>
  406. <el-form
  407. ref="dialog_form"
  408. :model="dialog.editorBox.form.data"
  409. :rules="dialog.editorBox.form.rules"
  410. size="mini"
  411. label-width="50px"
  412. >
  413. <el-form-item label="修正值" prop="correctvalue">
  414. <el-input clearable
  415. style="width: 100%;"
  416. v-model="dialog.editorBox.form.data.correctvalue"
  417. @change="dialog.editorBox.form.data.apportvalue = floatComputed(dialog.editorBox.form.data.actualvalue, dialog.editorBox.form.data.correctvalue, '+')"
  418. ></el-input>
  419. </el-form-item>
  420. <el-form-item label="最终值" prop="apportvalue">
  421. <el-input clearable
  422. style="width: 100%;"
  423. v-model="dialog.editorBox.form.data.apportvalue"
  424. @change="dialog.editorBox.form.data.correctvalue = floatComputed(dialog.editorBox.form.data.apportvalue, dialog.editorBox.form.data.actualvalue, '-')"
  425. ></el-input>
  426. </el-form-item>
  427. </el-form>
  428. </div>
  429. <span
  430. slot="footer"
  431. class="dialog-footer"
  432. >
  433. <el-button @click="dialog.editorBox.show = false" :loading="loading">取 消</el-button>
  434. <el-button
  435. type="primary"
  436. @click="dataSave"
  437. :loading="loading"
  438. >保 存</el-button>
  439. </span>
  440. </el-dialog>
  441. </div>
  442. </template>
  443. <script>
  444. import timegranDate from '~/components/zg/timegranDate.vue'
  445. import {formatDate, XtcommonSummaries} from '@/utils/util.js';
  446. export default {
  447. name: 'processAndRawMaterials',
  448. components: {
  449. 'zj-timegran-date': timegranDate
  450. },
  451. data () {
  452. return {
  453. activeMenu: '',
  454. filterForm: {
  455. show: true,
  456. data: {
  457. timegranid: '',
  458. clock: '',
  459. materialid: '',
  460. workprocid: '',
  461. itemid: ''
  462. },
  463. rules: {
  464. }
  465. },
  466. pageNum: 1,
  467. pageSize: 20,
  468. total: 0,
  469. singleTableHeight: 100,
  470. tableData: [
  471. // {
  472. // clock: '',
  473. // itemid: '010000C001R',
  474. // timegranid: '',
  475. // workprocid: '球团',
  476. // materialid: '混合矿',
  477. // actualvalue: '0',
  478. // correctvalue: '0',
  479. // apportvalue: '0',
  480. // stdvalue: '0',
  481. // sumvalue: '0',
  482. // ucvalue: '0',
  483. // sumucvalue: '0',
  484. // unitid: '吨',
  485. // bz: ''
  486. // }
  487. ],
  488. nameObj: {
  489. timegranid: {
  490. obj: {},
  491. arr: []
  492. },
  493. materialid: {
  494. obj: {},
  495. arr: []
  496. },
  497. workprocid: {
  498. obj: {},
  499. arr: []
  500. },
  501. unitid: {
  502. obj: {},
  503. arr: []
  504. }
  505. },
  506. loading: false,
  507. tableLoading: false,
  508. dialog: {
  509. editorBox: {
  510. show: false,
  511. type: '',
  512. form: {
  513. data: {
  514. clock: '',
  515. itemid: '',
  516. timegranid: '',
  517. actualvalue: '',
  518. correctvalue: '',
  519. apportvalue: ''
  520. },
  521. rules: {
  522. }
  523. }
  524. }
  525. },
  526. multipleSelection: [],
  527. tableFormDataObj: {}
  528. }
  529. },
  530. created () {
  531. this.activeMenu = window.localStorage.getItem('activeMenu');
  532. },
  533. mounted () {
  534. let that = this;
  535. window.PEDataObj = {
  536. // 将数据绑定到window上,供main页面使用
  537. vm: that,
  538. // tableArr:用于导出成Excel的表格的信息
  539. tableArr: [
  540. {
  541. name: '',
  542. id: 'singleTable'
  543. }
  544. ]
  545. };
  546. that.$nextTick(() => {
  547. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  548. setTimeout(() => {
  549. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  550. }, 1);
  551. });
  552. that.getTimeGranData();
  553. that.getMaterialIdData();
  554. that.getWorkprocIdData();
  555. that.getUnitIdData();
  556. // that.getTableData();
  557. },
  558. methods: {
  559. // 计算树区域高度
  560. getRoleHeight (dom) {
  561. return window.innerHeight - dom.offsetTop;
  562. },
  563. // 自定义的表格合计方法:只给指定列进行合计
  564. getSummaries (param) {
  565. const prop = ['actualvalue', 'correctvalue', 'apportvalue', 'sumvalue']; // 合计列绑定的prop
  566. return XtcommonSummaries(param, prop);
  567. },
  568. // 获取时间粒度(工序与原材料数据维护)
  569. getTimeGranData () {
  570. let that = this
  571. let url = 'pass/ems/v1/tcmdatasourcetimegrans/getTimegranRmWorkprocMaterialValue';
  572. that.axios.get(url)
  573. .then(function (res) {
  574. if (res.code === '0') {
  575. let arr = [];
  576. let obj = {};
  577. for (let item of res.data) {
  578. arr.push({
  579. id: item.ID,
  580. name: item.NAME
  581. })
  582. obj[item.ID] = item.NAME;
  583. that.filterForm.data.timegranid = that.filterForm.data.timegranid ? that.filterForm.data.timegranid : item.ID;
  584. }
  585. that.nameObj.timegranid.arr = arr;
  586. that.nameObj.timegranid.obj = obj;
  587. } else {
  588. that.$message.error(res.message);
  589. }
  590. });
  591. },
  592. // 获取原材料
  593. getMaterialIdData () {
  594. let that = this
  595. let url = 'pass/ems/v1/trmmaterials/?pageSize=1000000';
  596. that.axios.get(url)
  597. .then(function (res) {
  598. if (res.code === '0') {
  599. let arr = [];
  600. let obj = {};
  601. for (let item of res.data.list) {
  602. arr.push({
  603. id: item.id,
  604. name: item.name
  605. })
  606. obj[item.id] = item.name;
  607. }
  608. that.nameObj.materialid.arr = arr;
  609. that.nameObj.materialid.obj = obj;
  610. } else {
  611. that.$message.error(res.message);
  612. }
  613. });
  614. },
  615. // 获取工序
  616. getWorkprocIdData () {
  617. let that = this
  618. let url = 'pass/ems/v1/trmworkprocs/getIdAndName';
  619. that.axios.get(url)
  620. .then(function (res) {
  621. if (res.code === '0') {
  622. let arr = [];
  623. let obj = {};
  624. for (let item of res.data) {
  625. arr.push({
  626. id: item.id,
  627. name: item.name
  628. })
  629. obj[item.id] = item.name;
  630. }
  631. that.nameObj.workprocid.arr = arr;
  632. that.nameObj.workprocid.obj = obj;
  633. } else {
  634. that.$message.error(res.message);
  635. }
  636. });
  637. },
  638. // 获取标准计量单位
  639. getUnitIdData () {
  640. let that = this
  641. let url = 'pass/ems/v1/trmunits/getIdAndName';
  642. that.axios.get(url)
  643. .then(function (res) {
  644. if (res.code === '0') {
  645. let arr = [];
  646. let obj = {};
  647. for (let item of res.data) {
  648. arr.push({
  649. id: item.id,
  650. name: item.name
  651. })
  652. obj[item.id] = item.name;
  653. if (item.name === '吨') {
  654. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  655. }
  656. }
  657. that.nameObj.unitid.arr = arr;
  658. that.nameObj.unitid.obj = obj;
  659. } else {
  660. that.$message.error(res.message);
  661. }
  662. });
  663. },
  664. // 获取表格中的数据
  665. getTableData (pageNum) {
  666. let that = this,
  667. params = {
  668. timegranid: that.filterForm.data.timegranid,
  669. startDate: that.filterForm.data.clock[0],
  670. endDate: that.filterForm.data.clock[1],
  671. materialid: that.filterForm.data.materialid.toString(),
  672. workprocid: that.filterForm.data.workprocid.toString(),
  673. itemid: that.filterForm.data.itemid
  674. };
  675. that.pageNum = pageNum || that.pageNum;
  676. that.tableLoading = true;
  677. let url = 'pass/ems/v1/trmworkprocmaterialvalues/getWorkprocMaterialDetailForPage/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  678. that.axios.get(url, {
  679. params: params
  680. })
  681. .then(function (res) {
  682. if (res.code === '0') {
  683. let arr = [];
  684. for (let item of res.data.list) {
  685. arr.push({
  686. clock: item.CLOCK,
  687. itemid: item.ITEMID,
  688. timegranid: item.TIMEGRANID,
  689. workprocid: item.WORKPROCID,
  690. materialid: item.MATERIALID,
  691. actualvalue: item.ACTUALVALUE,
  692. correctvalue: item.CORRECTVALUE,
  693. apportvalue: item.APPORTVALUE,
  694. stdvalue: item.stdvalue,
  695. sumvalue: item.SUMVALUE,
  696. ucvalue: item.UCVALUE,
  697. sumucvalue: item.SUMUCVALUE,
  698. unitid: item.UNITID,
  699. bz: item.BZ,
  700. USERID: item.USERID,
  701. UPDATETIME: item.UPDATETIME,
  702. UPTIME: item.UPTIME,
  703. UPMAN: item.UPMAN
  704. })
  705. }
  706. that.tableData = arr;
  707. that.total = res.data.total;
  708. } else {
  709. that.$message.error(res.message);
  710. }
  711. that.tableLoading = false;
  712. }).catch(function () {
  713. that.tableLoading = false;
  714. });
  715. },
  716. // 改变表格显示条数
  717. tableSizeChange (val) {
  718. let that = this;
  719. that.pageSize = val;
  720. that.getTableData(1);
  721. },
  722. // 重置搜索
  723. tableDataCancel () {
  724. let that = this;
  725. that.filterForm.data.timegranid = '';
  726. that.filterForm.data.clock = '';
  727. that.filterForm.data.workprocid = '';
  728. that.filterForm.data.materialid = '';
  729. that.filterForm.data.itemid = '';
  730. that.getTableData(1);
  731. },
  732. but_edit (row) {
  733. let that = this;
  734. that.dialog.editorBox.form.data.itemid = row.itemid;
  735. that.dialog.editorBox.form.data.clock = row.clock;
  736. that.dialog.editorBox.form.data.timegranid = row.timegranid;
  737. that.dialog.editorBox.form.data.actualvalue = row.actualvalue;
  738. that.dialog.editorBox.form.data.correctvalue = row.correctvalue;
  739. that.dialog.editorBox.form.data.apportvalue = row.apportvalue;
  740. that.dialog.editorBox.type = 'edit';
  741. that.dialog.editorBox.show = true;
  742. },
  743. dataSave () {
  744. let that = this;
  745. let SubmitData = {
  746. itemid: that.dialog.editorBox.form.data.itemid,
  747. clock: that.dialog.editorBox.form.data.clock,
  748. timegranid: that.dialog.editorBox.form.data.timegranid,
  749. correctvalue: that.dialog.editorBox.form.data.correctvalue,
  750. apportvalue: that.dialog.editorBox.form.data.apportvalue
  751. };
  752. that.$refs['dialog_form'].validate((valid) => {
  753. if (valid) {
  754. that.loading = true;
  755. that.axios.put('pass/ems/v1/trmworkprocmaterialvalues/updateForUKey/', SubmitData)
  756. .then(function (res) {
  757. if (res.code === '0') {
  758. that.$message({
  759. message: '修改成功',
  760. type: 'success'
  761. });
  762. that.getTableData();
  763. that.dialog.editorBox.show = false;
  764. } else {
  765. that.$message.error(res.message);
  766. }
  767. that.loading = false;
  768. }).catch(function () {
  769. that.loading = false;
  770. });
  771. }
  772. });
  773. },
  774. handleSelectionChange (val) {
  775. let that = this;
  776. let tableFormDataObj = {};
  777. for (let item of that.tableData) {
  778. item.isSelection = false;
  779. }
  780. for (let item of val) {
  781. let obj = {};
  782. let xId = item.itemid;
  783. if (that.tableFormDataObj[xId]) {
  784. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  785. } else {
  786. for (let key in item) {
  787. obj[key] = item[key];
  788. }
  789. tableFormDataObj[xId] = obj;
  790. }
  791. item.isSelection = true;
  792. }
  793. that.tableFormDataObj = tableFormDataObj;
  794. console.log(that.tableFormDataObj)
  795. this.multipleSelection = val;
  796. },
  797. // 修改修正值
  798. correctvalueChange (id) {
  799. let that = this;
  800. let apportvalue = that.floatComputed(that.tableFormDataObj[id].correctvalue, that.tableFormDataObj[id].actualvalue, '+');
  801. that.tableFormDataObj[id].apportvalue = apportvalue;
  802. },
  803. // 修改最终值
  804. apportvalueChange (id) {
  805. let that = this;
  806. let correctvalue = that.floatComputed(that.tableFormDataObj[id].apportvalue, that.tableFormDataObj[id].actualvalue, '-');
  807. that.tableFormDataObj[id].correctvalue = correctvalue;
  808. },
  809. // 修改多条数据
  810. but_more () {
  811. let that = this;
  812. let url = 'pass/ems/v1/trmworkprocmaterialvalues/batchupdate/';
  813. let submitData = [];
  814. for (let item in that.tableFormDataObj) {
  815. submitData.push({
  816. itemid: that.tableFormDataObj[item].itemid,
  817. clock: that.tableFormDataObj[item].clock,
  818. timegranid: that.tableFormDataObj[item].timegranid,
  819. correctvalue: that.tableFormDataObj[item].correctvalue,
  820. apportvalue: that.tableFormDataObj[item].apportvalue
  821. })
  822. }
  823. that.axios.put(url, submitData)
  824. .then(function (res) {
  825. if (res.code === '0') {
  826. that.$message({
  827. message: '修改成功',
  828. type: 'success'
  829. });
  830. that.getTableData();
  831. that.dialog.editorBox.show = false;
  832. } else {
  833. that.$message.error(res.message);
  834. }
  835. that.loading = false;
  836. }).catch(function () {
  837. that.loading = false;
  838. });
  839. },
  840. // 批量重新计算
  841. but_re_compute () {
  842. let that = this;
  843. if (that.multipleSelection.length > 0) {
  844. that.$refs['dialog_form_arr'].validate((valid) => {
  845. if (valid) {
  846. let SubmitData = [];
  847. for (let key in that.tableFormDataObj) {
  848. SubmitData.push({
  849. clock: that.tableFormDataObj[key].clock,
  850. timegranid: that.tableFormDataObj[key].timegranid,
  851. itemid: that.tableFormDataObj[key].itemid
  852. });
  853. }
  854. that.loading = true;
  855. that.axios.put('pass/ems/v1/trmworkprocproductvalues/batchCompute', SubmitData)
  856. .then(function (res) {
  857. if (res.code === '0') {
  858. that.$message({
  859. message: '重新计算成功',
  860. type: 'success'
  861. });
  862. that.getTableData();
  863. } else {
  864. that.$message.error(res.message);
  865. }
  866. that.loading = false;
  867. }).catch(function () {
  868. that.loading = false;
  869. });
  870. }
  871. });
  872. } else {
  873. this.$message.error('至少要选择一条数据');
  874. }
  875. },
  876. // 重新生成数据
  877. but_redata () {
  878. let that = this;
  879. if (!that.filterForm.data.clock) {
  880. that.$message.warning('请选择日期');
  881. return true;
  882. }
  883. if (!that.filterForm.data.timegranid) {
  884. that.$message.warning('请选择时间粒度');
  885. return true;
  886. }
  887. let params = {
  888. workprocid: that.filterForm.data.workprocid.toString(),
  889. timegranid: that.filterForm.data.timegranid,
  890. clock: that.filterForm.data.clock[0],
  891. clocke: that.filterForm.data.clock[1],
  892. correctvalue: that.filterForm.data.correctvalue,
  893. apportvalue: that.filterForm.data.apportvalue,
  894. itemid: that.filterForm.data.itemid
  895. };
  896. that.$confirm('是否重新生成数据?', '提示', {
  897. confirmButtonText: '确定',
  898. cancelButtonText: '取消',
  899. state: 'warning'
  900. }).then(() => {
  901. that.loading = true;
  902. let url = 'pass/ems/v1/trmworkprocmaterialvalues/restatWmv'
  903. that.axios.get(url, {
  904. params: params
  905. })
  906. .then(function (res) {
  907. if (res.code === '0') {
  908. if (res.message && res.message !== '操作成功') {
  909. that.$message.warning('重新生成数据成功, 其中【' + res.message + '】');
  910. } else {
  911. that.$message({
  912. message: '重新生成数据成功',
  913. type: 'success'
  914. });
  915. }
  916. that.getTableData();
  917. } else {
  918. that.$message.error(res.message);
  919. }
  920. that.loading = false;
  921. }).catch(function () {
  922. that.loading = false;
  923. });
  924. }).catch(() => {
  925. });
  926. }
  927. }
  928. }
  929. </script>
  930. <style lang="less">
  931. .processAndRawMaterials {
  932. min-width: 700px;
  933. height: 100%;
  934. .box {
  935. height: 100%;
  936. padding: 15px 15px 0 15px;
  937. .box-top {
  938. .el-form-item {
  939. margin-bottom: 7px;
  940. }
  941. .box-top-gjl {
  942. overflow: hidden;
  943. // margin-top: -7px;
  944. padding: 7px 0;
  945. border-top: 1px solid #ccc;
  946. // border-bottom: 1px solid #ccc;
  947. // margin-bottom: 6px;
  948. }
  949. }
  950. }
  951. .el-table__body .el-form-item--mini.el-form-item {
  952. margin: 0px;
  953. .error {
  954. overflow: hidden;
  955. color: #f56c6c;
  956. font-size: 12px;
  957. line-height: 1;
  958. }
  959. }
  960. }
  961. </style>