productMaterialsInOut.vue 42 KB

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