investAndProduceManage.vue 38 KB

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