productMaterialsInput.vue 41 KB

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