processAndMaterial.vue 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. <template>
  2. <!-- 工序与原材料关联 -->
  3. <div class="processAndMaterial">
  4. <div class="box">
  5. <div
  6. class="box-left"
  7. :style="listTopicTree.show ? null : { width: '22px' }"
  8. >
  9. <div
  10. class="box-left-bt"
  11. style="overflow: hidden;"
  12. >
  13. <span v-show="listTopicTree.show">工序结构</span>
  14. <div style="float: right;height: 100%;padding-right: 4px;">
  15. <span
  16. class="el-icon-d-arrow-right"
  17. style="cursor: pointer; transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;"
  18. :style="listTopicTree.show ? { transform: 'rotate(180deg)'} : { transform: 'rotate(0deg)'} "
  19. @click="listTopicTree.show = !listTopicTree.show;"
  20. ></span>
  21. </div>
  22. </div>
  23. <div class="box-left-tree">
  24. <el-tree
  25. v-show="listTopicTree.show"
  26. :data="listTopicTree.data"
  27. :props="listTopicTree.defaultProps"
  28. v-loading="listTopicTree.loading"
  29. >
  30. <span
  31. class="custom-tree-node"
  32. :class="{'tree-row-on': filterForm.data.workprocid === data.id}"
  33. style="width:100%; font-size:12px;"
  34. slot-scope="{ node, data }"
  35. >
  36. <p
  37. style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap;"
  38. :title="node.label"
  39. @click="selectByTopicId(data)"
  40. >{{ node.label }}</p>
  41. </span>
  42. </el-tree>
  43. </div>
  44. </div>
  45. <div
  46. class="box-right"
  47. :style="listTopicTree.show ? null : { 'margin-left': '22px' }"
  48. >
  49. <div class="box-top">
  50. <el-form
  51. style="overflow: hidden;"
  52. :style="filterForm.show ? null : { height: '0px' }"
  53. class="box-top-form"
  54. size="mini"
  55. label-width="60px"
  56. >
  57. <el-row>
  58. <el-col :span="8">
  59. <el-form-item label="原材料">
  60. <el-select
  61. filterable
  62. clearable
  63. v-model="filterForm.data.materialid"
  64. placeholder="原材料"
  65. style="width: 100%;"
  66. >
  67. <el-option
  68. v-for="item of nameObj.materialid.arr"
  69. :key="item.id"
  70. :value="item.id"
  71. :label="item.name"
  72. ></el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="8">
  77. <el-form-item label="工序">
  78. <el-select
  79. filterable
  80. clearable
  81. v-model="filterForm.data.workprocid"
  82. placeholder="工序"
  83. style="width: 100%;"
  84. >
  85. <el-option
  86. v-for="item of nameObj.workprocid.arr"
  87. :key="item.id"
  88. :value="item.id"
  89. :label="item.name"
  90. ></el-option>
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="8">
  95. <el-form-item label="公式版本">
  96. <el-date-picker
  97. type="month"
  98. v-model="filterForm.data.version"
  99. placeholder="公式版本"
  100. style="width: 100%;"
  101. format="yyyyMM"
  102. value-format="yyyyMM00"
  103. ></el-date-picker>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="8">
  107. <el-form-item label="关联ID">
  108. <el-input clearable
  109. v-model="filterForm.data.aid"
  110. placeholder="关联ID"
  111. style="width: 100%;"
  112. ></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="8">
  116. <el-form-item label="物料编码">
  117. <el-input clearable
  118. v-model="filterForm.data.materialCode"
  119. placeholder="NC物料编码"
  120. style="width: 100%;"
  121. ></el-input>
  122. </el-form-item>
  123. </el-col>
  124. </el-row>
  125. </el-form>
  126. <div class="box-top-gjl">
  127. <el-button
  128. class="button"
  129. type="primary"
  130. size="mini"
  131. icon="el-icon-plus"
  132. v-privilege="activeMenu + 'ADD'"
  133. @click="but_add"
  134. >新增</el-button>
  135. <el-button
  136. class="button"
  137. type="primary"
  138. size="mini"
  139. icon="el-icon-edit-outline"
  140. v-privilege="activeMenu + 'PUT'"
  141. @click="but_edit_plural()"
  142. :loading="loading"
  143. >修改</el-button>
  144. <el-button
  145. class="button"
  146. type="danger"
  147. size="mini"
  148. icon="el-icon-delete"
  149. v-privilege="activeMenu + 'DELETE'"
  150. @click="but_del_plural()"
  151. :loading="loading"
  152. >删除</el-button>
  153. <div style="float:right; text-align: right;">
  154. <el-button
  155. class="button"
  156. type="primary"
  157. size="mini"
  158. icon="el-icon-search"
  159. v-privilege="activeMenu + 'QUERY'"
  160. @click="getTableData(1)"
  161. >查询</el-button>
  162. <el-button
  163. class="button"
  164. type="primary"
  165. size="mini"
  166. icon="el-icon-refresh"
  167. v-privilege="activeMenu + 'QUERY'"
  168. @click="tableDataCancel();"
  169. >重置</el-button>
  170. <el-button
  171. size="mini"
  172. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  173. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  174. @click="filterForm.show = !filterForm.show;
  175. $nextTick(() => {
  176. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  177. }
  178. );"
  179. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  180. </div>
  181. </div>
  182. </div>
  183. <div class="box-bottom">
  184. <el-form
  185. size="mini"
  186. ref="dialog_form_arr"
  187. label-width="0px"
  188. :model="tableFormDataObj"
  189. >
  190. <el-table
  191. stripe
  192. id="singleTable"
  193. ref="singleTable"
  194. :data="tableData"
  195. v-loading="tableLoading"
  196. style="width: 100%;"
  197. :height="singleTableHeight"
  198. border
  199. size="mini"
  200. highlight-current-row
  201. @selection-change="handleSelectionChange"
  202. >
  203. <el-table-column
  204. type="selection"
  205. width="40"
  206. align="center"
  207. fixed="left"
  208. ></el-table-column>
  209. <el-table-column
  210. sortable
  211. prop="itemid"
  212. label="关联ID"
  213. min-width="100px"
  214. :show-overflow-tooltip="true"
  215. ></el-table-column>
  216. <el-table-column
  217. sortable
  218. prop="materialid"
  219. label="原材料"
  220. min-width="100px"
  221. :show-overflow-tooltip="true"
  222. >
  223. <template slot-scope="scope">
  224. <span>{{ nameObj.materialid.obj[scope.row.materialid] ? nameObj.materialid.obj[scope.row.materialid] : scope.row.materialid }}</span>
  225. </template>
  226. </el-table-column>
  227. <el-table-column
  228. sortable
  229. prop="workprocid"
  230. label="工序"
  231. min-width="100px"
  232. :show-overflow-tooltip="true"
  233. >
  234. <template slot-scope="scope">
  235. <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
  236. </template>
  237. </el-table-column>
  238. <el-table-column
  239. sortable
  240. prop="unitid"
  241. label="单位"
  242. min-width="100px"
  243. :show-overflow-tooltip="true"
  244. > <template slot-scope="scope">
  245. <el-form-item
  246. v-if="scope.row.isSelection"
  247. :prop="scope.row.itemid + '.unitid'"
  248. :rules="dialog.editorBox.form.rules.unitid"
  249. >
  250. <el-select
  251. filterable
  252. clearable
  253. style="width: 100%;"
  254. v-model="tableFormDataObj[scope.row.itemid].unitid"
  255. >
  256. <el-option
  257. v-for="item of nameObj.unitid.arr"
  258. :key="item.id"
  259. :value="item.id"
  260. :label="item.name"
  261. ></el-option>
  262. </el-select>
  263. <template
  264. slot="error"
  265. slot-scope="scope"
  266. >
  267. <p
  268. class="error"
  269. :title="scope.error"
  270. >{{ scope.error }}</p>
  271. </template>
  272. </el-form-item>
  273. <span v-else>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
  274. </template>
  275. </el-table-column>
  276. <el-table-column
  277. sortable
  278. prop="seqno"
  279. label="顺序号"
  280. min-width="100px"
  281. :show-overflow-tooltip="true"
  282. > <template slot-scope="scope">
  283. <el-form-item
  284. v-if="scope.row.isSelection"
  285. :prop="scope.row.itemid + '.seqno'"
  286. :rules="dialog.editorBox.form.rules.seqno"
  287. >
  288. <el-input
  289. clearable
  290. style="width: 100%;"
  291. v-model.trim="tableFormDataObj[scope.row.itemid].seqno"
  292. ></el-input>
  293. <template
  294. slot="error"
  295. slot-scope="scope"
  296. >
  297. <p
  298. class="error"
  299. :title="scope.error"
  300. >{{ scope.error }}</p>
  301. </template>
  302. </el-form-item>
  303. <span v-else>{{scope.row.seqno}}</span>
  304. </template>
  305. </el-table-column>
  306. <el-table-column
  307. sortable
  308. prop="mes_materialcode"
  309. label="NC物料编码"
  310. min-width="100px"
  311. v-if="activeMenu + 'NC'"
  312. :show-overflow-tooltip="true"
  313. ></el-table-column>
  314. <el-table-column
  315. sortable
  316. prop="isFinanceData"
  317. label="财务物料"
  318. min-width="100px"
  319. :show-overflow-tooltip="true"
  320. >
  321. <template slot-scope="scope">
  322. <el-form-item
  323. v-if="scope.row.isSelection"
  324. :prop="scope.row.itemid + '.isFinanceData'"
  325. :rules="dialog.editorBox.form.rules.isFinanceData"
  326. >
  327. <el-select
  328. filterable
  329. clearable
  330. style="width: 100%;"
  331. v-model="tableFormDataObj[scope.row.itemid].isFinanceData"
  332. >
  333. <el-option
  334. label="是"
  335. value="1"
  336. ></el-option>
  337. <el-option
  338. label="否"
  339. value="0"
  340. ></el-option>
  341. </el-select>
  342. <template
  343. slot="error"
  344. slot-scope="scope"
  345. >
  346. <p
  347. class="error"
  348. :title="scope.error"
  349. >{{ scope.error }}</p>
  350. </template>
  351. </el-form-item>
  352. <span
  353. v-else
  354. :class="{color_yes: scope.row.isFinanceData === '1', color_no: scope.row.isFinanceData === '0'}"
  355. >{{ scope.row.isFinanceData === '0' ? '否' : scope.row.isFinanceData === '1' ? '是' : '' }}</span>
  356. </template>
  357. </el-table-column>
  358. <el-table-column
  359. sortable
  360. prop="mes_prodline"
  361. label="MES产线"
  362. min-width="100px"
  363. v-if="activeMenu + 'MES'"
  364. :show-overflow-tooltip="true"
  365. > <template slot-scope="scope">
  366. <el-form-item
  367. v-if="scope.row.isSelection"
  368. :prop="scope.row.itemid + '.mes_prodline'"
  369. :rules="dialog.editorBox.form.rules.mes_prodline"
  370. >
  371. <el-input
  372. clearable
  373. style="width: 100%;"
  374. v-model.trim="tableFormDataObj[scope.row.itemid].mes_prodline"
  375. ></el-input>
  376. </el-form-item>
  377. <span v-else>{{scope.row.mes_prodline}}</span>
  378. </template>
  379. </el-table-column>
  380. <el-table-column
  381. sortable
  382. prop="digits"
  383. label="精度"
  384. width="90px"
  385. :show-overflow-tooltip="true"
  386. ><template slot-scope="scope">
  387. <el-form-item
  388. v-if="scope.row.isSelection"
  389. :prop="scope.row.itemid + '.digits'"
  390. :rules="dialog.editorBox.form.rules.digits"
  391. >
  392. <el-input
  393. clearable
  394. style="width: 100%;"
  395. v-model.trim="tableFormDataObj[scope.row.itemid].digits"
  396. ></el-input>
  397. </el-form-item>
  398. <span v-else>{{scope.row.digits}}</span>
  399. </template></el-table-column>
  400. <el-table-column
  401. sortable
  402. prop="code"
  403. label="使用公式编辑"
  404. min-width="100px"
  405. :show-overflow-tooltip="true"
  406. > <template slot-scope="scope">
  407. <el-form-item
  408. v-if="scope.row.isSelection"
  409. :prop="scope.row.itemid + '.code'"
  410. :rules="dialog.editorBox.form.rules.code"
  411. >
  412. <el-select
  413. filterable
  414. clearable
  415. style="width: 100%;"
  416. v-model="tableFormDataObj[scope.row.itemid].code"
  417. >
  418. <el-option
  419. label="是"
  420. value="1"
  421. ></el-option>
  422. <el-option
  423. label="否"
  424. value="0"
  425. ></el-option>
  426. </el-select>
  427. <template
  428. slot="error"
  429. slot-scope="scope"
  430. >
  431. <p
  432. class="error"
  433. :title="scope.error"
  434. >{{ scope.error }}</p>
  435. </template>
  436. </el-form-item>
  437. <span
  438. v-else
  439. :class="{color_yes: scope.row.code === '1', color_no: scope.row.code === '0'}"
  440. >{{ scope.row.code === '0' ? '否' : scope.row.code === '1' ? '是' : '' }}</span>
  441. </template>
  442. </el-table-column>
  443. <el-table-column
  444. sortable
  445. prop="createman"
  446. label="创建人"
  447. width="60px"
  448. :show-overflow-tooltip="true"
  449. ></el-table-column>
  450. <el-table-column
  451. sortable
  452. prop="createtime"
  453. label="创建时间"
  454. width="125px"
  455. :show-overflow-tooltip="true"
  456. ></el-table-column>
  457. <el-table-column
  458. sortable
  459. prop="updateman"
  460. label="修改人"
  461. width="60px"
  462. :show-overflow-tooltip="true"
  463. ></el-table-column>
  464. <el-table-column
  465. sortable
  466. prop="updatetime"
  467. label="修改时间"
  468. width="125px"
  469. :show-overflow-tooltip="true"
  470. ></el-table-column>
  471. <el-table-column
  472. class-name="gn-TableDownloadExcel-none"
  473. label="操作"
  474. align="center"
  475. width="90px"
  476. fixed="right"
  477. >
  478. <template slot-scope="scope">
  479. <div>
  480. <el-button
  481. type="primary"
  482. size="mini"
  483. @click="but_equationEditing(scope.row)"
  484. :disabled="scope.row.code === '0'"
  485. >公式编辑</el-button>
  486. <!-- <el-button
  487. type="primary"
  488. size="mini"
  489. v-privilege="activeMenu + 'PUT'"
  490. @click="but_edit(scope.row)"
  491. >修改</el-button>
  492. <el-button
  493. type="danger"
  494. size="mini"
  495. v-privilege="activeMenu + 'DELETE'"
  496. @click="but_del(scope.row)"
  497. >删除</el-button> -->
  498. </div>
  499. </template>
  500. </el-table-column>
  501. </el-table>
  502. </el-form>
  503. <el-pagination
  504. layout="total, sizes, prev, pager, next, jumper"
  505. :total="total"
  506. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  507. :page-size="pageSize"
  508. :current-page.sync="pageNum"
  509. @size-change="tableSizeChange"
  510. @current-change="getTableData()"
  511. style="text-align: right;margin-top: 10px;"
  512. ></el-pagination>
  513. </div>
  514. </div>
  515. </div>
  516. <el-dialog
  517. :title="'工序与原材料关联 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
  518. :visible.sync="dialog.editorBox.show"
  519. width="600px"
  520. :close-on-click-modal="false"
  521. :show-close="!loading"
  522. >
  523. <div>
  524. <el-form
  525. ref="dialog_form"
  526. :model="dialog.editorBox.form.data"
  527. :rules="dialog.editorBox.form.rules"
  528. size="mini"
  529. label-width="95px"
  530. >
  531. <el-row>
  532. <el-col :span="12">
  533. <el-form-item
  534. label="原材料"
  535. prop="materialid"
  536. >
  537. <el-select
  538. filterable
  539. clearable
  540. style="width: 100%;"
  541. v-model="dialog.editorBox.form.data.materialid"
  542. :disabled="dialog.editorBox.type !== 'add'"
  543. >
  544. <el-option
  545. v-for="item of nameObj.materialid.arr"
  546. :key="item.id"
  547. :value="item.id"
  548. :label="item.name"
  549. ></el-option>
  550. </el-select>
  551. </el-form-item>
  552. </el-col>
  553. <el-col :span="12">
  554. <el-form-item
  555. label="工序"
  556. prop="workprocid"
  557. >
  558. <el-select
  559. filterable
  560. clearable
  561. style="width: 100%;"
  562. v-model="dialog.editorBox.form.data.workprocid"
  563. disabled
  564. >
  565. <el-option
  566. v-for="item of nameObj.workprocid.arr"
  567. :key="item.id"
  568. :value="item.id"
  569. :label="item.name"
  570. ></el-option>
  571. </el-select>
  572. </el-form-item>
  573. </el-col>
  574. </el-row>
  575. <el-row>
  576. <el-col :span="12">
  577. <el-form-item
  578. label="单位"
  579. prop="unitid"
  580. >
  581. <el-select
  582. filterable
  583. clearable
  584. style="width: 100%;"
  585. v-model="dialog.editorBox.form.data.unitid"
  586. >
  587. <el-option
  588. v-for="item of nameObj.unitid.arr"
  589. :key="item.id"
  590. :value="item.id"
  591. :label="item.name"
  592. ></el-option>
  593. </el-select>
  594. </el-form-item>
  595. </el-col>
  596. <el-col :span="12">
  597. <el-form-item
  598. label="顺序号"
  599. prop="seqno"
  600. >
  601. <el-input
  602. clearable
  603. style="width: 100%;"
  604. v-model="dialog.editorBox.form.data.seqno"
  605. ></el-input>
  606. </el-form-item>
  607. </el-col>
  608. </el-row>
  609. <el-row>
  610. <el-col :span="12">
  611. <el-form-item
  612. label="使用公式编辑"
  613. prop="code"
  614. >
  615. <el-select
  616. filterable
  617. clearable
  618. style="width: 100%;"
  619. v-model="dialog.editorBox.form.data.code"
  620. >
  621. <el-option
  622. value="0"
  623. label="否"
  624. ></el-option>
  625. <el-option
  626. value="1"
  627. label="是"
  628. ></el-option>
  629. </el-select>
  630. </el-form-item>
  631. </el-col>
  632. <el-col v-if="activeMenu + 'MES'" :span="12">
  633. <el-form-item
  634. label="MES产线"
  635. prop="mes_prodline"
  636. >
  637. <el-input
  638. clearable
  639. style="width: 100%;"
  640. :maxlength="40"
  641. v-model="dialog.editorBox.form.data.mes_prodline"
  642. ></el-input>
  643. </el-form-item>
  644. </el-col>
  645. </el-row>
  646. <el-row>
  647. <el-col :span="12">
  648. <el-form-item
  649. label="精度"
  650. prop="digits"
  651. >
  652. <el-input
  653. clearable
  654. style="width: 100%;"
  655. :maxlength="40"
  656. v-model="dialog.editorBox.form.data.digits"
  657. ></el-input>
  658. </el-form-item>
  659. </el-col>
  660. </el-row>
  661. </el-form>
  662. </div>
  663. <span
  664. slot="footer"
  665. class="dialog-footer"
  666. >
  667. <el-button
  668. @click="dialog.editorBox.show = false"
  669. :loading="loading"
  670. >取 消</el-button>
  671. <el-button
  672. type="primary"
  673. @click="dataSave"
  674. :loading="loading"
  675. >保 存</el-button>
  676. </span>
  677. </el-dialog>
  678. <zj-formulaEditor :equationEditing="dialog.equationEditing"></zj-formulaEditor>
  679. </div>
  680. </template>
  681. <script>
  682. import formulaEditor from '~/components/zg/formulaEditor.vue';
  683. import { zCheckNumber1 } from '~/utils/validator.js';
  684. import { formatDate } from '@/utils/util.js';
  685. export default {
  686. name: 'processAndMaterial',
  687. components: {
  688. 'zj-formulaEditor': formulaEditor
  689. },
  690. data () {
  691. return {
  692. multipleSelection: [],
  693. tableFormDataObj: {},
  694. activeMenu: '',
  695. filterForm: {
  696. show: true,
  697. data: {
  698. materialid: '',
  699. workprocid: '',
  700. version: formatDate(new Date(), 'yyyyMM00'),
  701. aid: '',
  702. materialCode: ''
  703. },
  704. rules: {
  705. }
  706. },
  707. listTopicTree: {
  708. show: true,
  709. loading: false,
  710. data: [],
  711. defaultProps: {
  712. children: 'children',
  713. label: 'name'
  714. }
  715. },
  716. pageNum: 1,
  717. pageSize: 20,
  718. total: 0,
  719. singleTableHeight: 100,
  720. tableData: [
  721. // {
  722. // itemid: '010000C001R',
  723. // materialid: '混合矿',
  724. // workprocid: '球团',
  725. // unitid: '吨',
  726. // seqno: '1'
  727. // }
  728. ],
  729. nameObj: {
  730. workprocid: {
  731. obj: {},
  732. arr: []
  733. },
  734. materialid: {
  735. obj: {},
  736. arr: []
  737. },
  738. unitid: {
  739. obj: {},
  740. arr: []
  741. }
  742. },
  743. loading: false,
  744. tableLoading: false,
  745. dialog: {
  746. editorBox: {
  747. show: false,
  748. type: '',
  749. form: {
  750. default: {
  751. workprocid: ''
  752. },
  753. data: {
  754. itemid: '',
  755. materialid: '',
  756. workprocid: '',
  757. unitid: '',
  758. seqno: '',
  759. mes_prodline: '',
  760. code: '',
  761. digits: ''
  762. },
  763. rules: {
  764. materialid: [
  765. { required: true, message: '该项不能为空', trigger: 'change' }
  766. ],
  767. workprocid: [
  768. { required: true, message: '该项不能为空', trigger: 'change' }
  769. ],
  770. seqno: [
  771. { validator: zCheckNumber1, trigger: 'change' }
  772. ],
  773. mes_prodline: [
  774. ],
  775. digits: []
  776. }
  777. }
  778. },
  779. equationEditing: {
  780. show: false,
  781. form: {
  782. data: {
  783. clock: '',
  784. code: ''
  785. }
  786. }
  787. }
  788. }
  789. }
  790. },
  791. created () {
  792. this.activeMenu = window.localStorage.getItem('activeMenu');
  793. },
  794. mounted () {
  795. let that = this;
  796. window.PEDataObj = {
  797. // 将数据绑定到window上,供main页面使用
  798. vm: that,
  799. // tableArr:用于导出成Excel的表格的信息
  800. tableArr: [
  801. {
  802. name: '',
  803. id: 'singleTable'
  804. }
  805. ]
  806. };
  807. that.$nextTick(() => {
  808. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  809. setTimeout(() => {
  810. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  811. }, 1);
  812. });
  813. that.getNodeData();
  814. that.getNodeTreeData();
  815. that.getMaterialIdData();
  816. that.getUnitIdData();
  817. that.getTableData();
  818. },
  819. methods: {
  820. // 计算树区域高度
  821. getRoleHeight (dom) {
  822. return window.innerHeight - dom.offsetTop;
  823. },
  824. // 获取工序列表
  825. getNodeData () {
  826. let that = this
  827. let url = 'pass/ems/v1/trmworkprocs/getIdAndName';
  828. that.axios.get(url)
  829. .then(function (res) {
  830. if (res.code === '0') {
  831. let arr = [];
  832. let obj = {};
  833. for (let item of res.data) {
  834. arr.push({
  835. id: item.id,
  836. name: item.name
  837. })
  838. obj[item.id] = item.name;
  839. }
  840. that.nameObj.workprocid.arr = arr;
  841. that.nameObj.workprocid.obj = obj;
  842. } else {
  843. that.$message.error(res.message);
  844. }
  845. });
  846. },
  847. // 获取工序节点树
  848. getNodeTreeData () {
  849. let that = this
  850. let url = 'pass/ems/v1/trmworkprocs/gettree/';
  851. that.listTopicTree.loading = true;
  852. that.axios.get(url)
  853. .then(function (res) {
  854. if (res.code === '0') {
  855. that.listTopicTree.data = [{
  856. id: '',
  857. name: '所有记录',
  858. children: res.data
  859. }];
  860. } else {
  861. that.$message.error(res.message);
  862. }
  863. that.listTopicTree.loading = false;
  864. });
  865. },
  866. // 获取原材料
  867. getMaterialIdData () {
  868. let that = this
  869. let url = 'pass/ems/v1/trmmaterials/getIdAndName';
  870. that.axios.get(url)
  871. .then(function (res) {
  872. if (res.code === '0') {
  873. let arr = [];
  874. let obj = {};
  875. for (let item of res.data) {
  876. arr.push({
  877. id: item.id,
  878. name: item.name
  879. })
  880. obj[item.id] = item.name;
  881. }
  882. that.nameObj.materialid.arr = arr;
  883. that.nameObj.materialid.obj = obj;
  884. } else {
  885. that.$message.error(res.message);
  886. }
  887. });
  888. },
  889. // 获取标准计量单位
  890. getUnitIdData () {
  891. let that = this
  892. let url = 'pass/ems/v1/trmunits/getIdAndName';
  893. that.axios.get(url)
  894. .then(function (res) {
  895. if (res.code === '0') {
  896. let arr = [];
  897. let obj = {};
  898. for (let item of res.data) {
  899. arr.push({
  900. id: item.id,
  901. name: item.name
  902. })
  903. obj[item.id] = item.name;
  904. if (item.name === '吨') {
  905. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  906. }
  907. }
  908. that.nameObj.unitid.arr = arr;
  909. that.nameObj.unitid.obj = obj;
  910. } else {
  911. that.$message.error(res.message);
  912. }
  913. });
  914. },
  915. // 获取表格中的数据
  916. getTableData (pageNum) {
  917. let that = this,
  918. params = {
  919. materialid: that.filterForm.data.materialid,
  920. workprocid: that.filterForm.data.workprocid,
  921. version: that.filterForm.data.version,
  922. itemid: that.filterForm.data.aid,
  923. mes_materialcode: that.filterForm.data.materialCode
  924. };
  925. that.pageNum = pageNum || that.pageNum;
  926. that.tableLoading = true;
  927. that.dialog.editorBox.form.default.workprocid = that.filterForm.data.workprocid;
  928. let url = 'pass/ems/v1/trmworkprocmaterials/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize + '&itemtype=R';
  929. that.axios.get(url, {
  930. params: params
  931. })
  932. .then(function (res) {
  933. if (res.code === '0') {
  934. let arr = [];
  935. for (let item of res.data.list) {
  936. arr.push({
  937. itemid: item.itemid,
  938. materialid: item.materialid,
  939. workprocid: item.workprocid,
  940. unitid: item.unitid,
  941. seqno: item.seqno,
  942. mes_materialcode: item.mesMaterialcode,
  943. isFinanceData: item.isfinancedata,
  944. mes_prodline: item.mesProdline,
  945. code: item.code,
  946. createman: item.createman,
  947. createtime: item.createtime,
  948. updateman: item.updateman,
  949. updatetime: item.updatetime,
  950. digits: item.digits
  951. })
  952. }
  953. that.tableData = arr;
  954. that.total = res.data.total;
  955. } else {
  956. that.$message.error(res.message);
  957. }
  958. that.tableLoading = false;
  959. }).catch(function () {
  960. that.tableLoading = false;
  961. });
  962. },
  963. // 改变表格显示条数
  964. tableSizeChange (val) {
  965. let that = this;
  966. that.pageSize = val;
  967. that.getTableData(1);
  968. },
  969. // 重置搜索
  970. tableDataCancel () {
  971. let that = this;
  972. that.filterForm.data.materialid = '';
  973. that.filterForm.data.workprocid = '';
  974. that.filterForm.data.version = '';
  975. that.getTableData(1);
  976. },
  977. // 表格中多选按钮的相关方法
  978. handleSelectionChange (val) {
  979. let that = this;
  980. let tableFormDataObj = {};
  981. for (let item of that.tableData) {
  982. item.isSelection = false;
  983. }
  984. for (let item of val) {
  985. let obj = {};
  986. let xId = item.itemid;
  987. if (that.tableFormDataObj[xId]) {
  988. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  989. } else {
  990. for (let key in item) {
  991. obj[key] = item[key];
  992. }
  993. tableFormDataObj[xId] = obj;
  994. }
  995. item.isSelection = true;
  996. }
  997. that.tableFormDataObj = tableFormDataObj;
  998. that.multipleSelection = val;
  999. },
  1000. but_add () {
  1001. let that = this;
  1002. if (!that.dialog.editorBox.form.default.workprocid) {
  1003. that.$message.error('请先选择左侧的详细工序');
  1004. return;
  1005. }
  1006. that.dialog.editorBox.form.data.itemid = '';
  1007. that.dialog.editorBox.form.data.materialid = '';
  1008. that.dialog.editorBox.form.data.mes_prodline = '';
  1009. that.dialog.editorBox.form.data.workprocid = that.dialog.editorBox.form.default.workprocid;
  1010. that.dialog.editorBox.form.data.unitid = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : '';
  1011. that.dialog.editorBox.form.data.seqno = '';
  1012. that.dialog.editorBox.form.data.code = '0';
  1013. that.dialog.editorBox.type = 'add';
  1014. that.dialog.editorBox.show = true;
  1015. setTimeout(() => {
  1016. that.$refs['dialog_form'].clearValidate();
  1017. }, 100);
  1018. },
  1019. // 批量修改
  1020. but_edit_plural () {
  1021. let that = this;
  1022. if (that.multipleSelection.length > 0) {
  1023. that.$refs['dialog_form_arr'].validate((valid) => {
  1024. if (valid) {
  1025. let SubmitData = [];
  1026. for (let key in that.tableFormDataObj) {
  1027. SubmitData.push({
  1028. itemid: that.tableFormDataObj[key].itemid,
  1029. unitid: that.tableFormDataObj[key].unitid,
  1030. seqno: that.tableFormDataObj[key].seqno,
  1031. code: that.tableFormDataObj[key].code,
  1032. isFinanceData: that.tableFormDataObj[key].isFinanceData,
  1033. mes_prodline: that.tableFormDataObj[key].mes_prodline,
  1034. digits: that.tableFormDataObj[key].digits
  1035. });
  1036. }
  1037. that.loading = true;
  1038. that.axios.put('pass/ems/v1/trmworkprocmaterials/', SubmitData)
  1039. .then(function (res) {
  1040. if (res.code === '0') {
  1041. that.$message({
  1042. message: '修改成功',
  1043. type: 'success'
  1044. });
  1045. that.getTableData();
  1046. that.dialog.editorBox.show = false;
  1047. } else {
  1048. that.$message.error(res.message);
  1049. }
  1050. that.loading = false;
  1051. }).catch(function () {
  1052. that.loading = false;
  1053. });
  1054. }
  1055. });
  1056. } else {
  1057. this.$message.error('至少要选择一条数据');
  1058. }
  1059. },
  1060. // 批量删除
  1061. but_del_plural () {
  1062. let that = this;
  1063. if (that.multipleSelection.length > 0) {
  1064. let ids = [];
  1065. for (let item of that.multipleSelection) {
  1066. ids.push(item.itemid);
  1067. }
  1068. that.$confirm('是否删除已选数据?', '提示', {
  1069. confirmButtonText: '确定',
  1070. cancelButtonText: '取消',
  1071. state: 'warning'
  1072. }).then(() => {
  1073. that.axios.delete('pass/ems/v1/trmworkprocmaterials/' + ids.toString())
  1074. .then(function (res) {
  1075. if (res.code === '0') {
  1076. that.$message({
  1077. message: '删除成功',
  1078. type: 'success'
  1079. });
  1080. that.getTableData();
  1081. } else {
  1082. if (res.code === '51') {
  1083. }
  1084. that.$message.error(res.message);
  1085. }
  1086. }).catch(function () {
  1087. });
  1088. }).catch(() => {
  1089. });
  1090. } else {
  1091. this.$message.error('至少要选择一条数据');
  1092. }
  1093. },
  1094. // but_edit (row) {
  1095. // let that = this;
  1096. // that.dialog.editorBox.form.data.itemid = row.itemid;
  1097. // that.dialog.editorBox.form.data.materialid = row.materialid;
  1098. // that.dialog.editorBox.form.data.workprocid = row.workprocid;
  1099. // that.dialog.editorBox.form.data.unitid = row.unitid;
  1100. // that.dialog.editorBox.form.data.seqno = row.seqno;
  1101. // that.dialog.editorBox.form.data.code = row.code;
  1102. // that.dialog.editorBox.type = 'edit';
  1103. // that.dialog.editorBox.show = true;
  1104. // },
  1105. // but_del (row) {
  1106. // let that = this;
  1107. // that.$confirm('是否删除该条数据?', '提示', {
  1108. // confirmButtonText: '确定',
  1109. // cancelButtonText: '取消',
  1110. // state: 'warning'
  1111. // }).then(() => {
  1112. // that.axios.delete('pass/ems/v1/trmworkprocmaterials/' + row.itemid)
  1113. // .then(function (res) {
  1114. // if (res.code === '0') {
  1115. // that.$message({
  1116. // message: '删除成功',
  1117. // type: 'success'
  1118. // });
  1119. // that.getTableData();
  1120. // } else {
  1121. // that.$message.error(res.message);
  1122. // }
  1123. // }).catch(function () {
  1124. // });
  1125. // }).catch(() => {
  1126. // });
  1127. // },
  1128. dataSave () {
  1129. let that = this;
  1130. let SubmitData = {
  1131. itemid: that.dialog.editorBox.form.data.itemid,
  1132. materialid: that.dialog.editorBox.form.data.materialid,
  1133. workprocid: that.dialog.editorBox.form.data.workprocid,
  1134. unitid: that.dialog.editorBox.form.data.unitid,
  1135. seqno: that.dialog.editorBox.form.data.seqno,
  1136. code: that.dialog.editorBox.form.data.code,
  1137. mes_prodline: that.dialog.editorBox.form.data.mes_prodline,
  1138. digits: that.dialog.editorBox.form.data.digits,
  1139. itemtype: 'R'
  1140. };
  1141. that.$refs['dialog_form'].validate((valid) => {
  1142. if (valid) {
  1143. if (that.dialog.editorBox.type === 'add') {
  1144. that.loading = true;
  1145. that.axios.post('pass/ems/v1/trmworkprocmaterials/', SubmitData, {
  1146. contentType: 'application/json'
  1147. })
  1148. .then(function (res) {
  1149. if (res.code === '0') {
  1150. that.$message({
  1151. message: '新增成功',
  1152. type: 'success'
  1153. });
  1154. that.getTableData();
  1155. that.dialog.editorBox.show = false;
  1156. } else {
  1157. that.$message.error(res.message);
  1158. }
  1159. that.loading = false;
  1160. }).catch(function () {
  1161. that.loading = false;
  1162. });
  1163. } else {
  1164. that.loading = true;
  1165. that.axios.put('pass/ems/v1/trmworkprocmaterials/' + SubmitData.itemid, SubmitData)
  1166. .then(function (res) {
  1167. if (res.code === '0') {
  1168. that.$message({
  1169. message: '修改成功',
  1170. type: 'success'
  1171. });
  1172. that.getTableData();
  1173. that.dialog.editorBox.show = false;
  1174. } else {
  1175. that.$message.error(res.message);
  1176. }
  1177. that.loading = false;
  1178. }).catch(function () {
  1179. that.loading = false;
  1180. });
  1181. }
  1182. }
  1183. });
  1184. },
  1185. but_equationEditing (row) {
  1186. let that = this;
  1187. that.dialog.equationEditing.form.data.clock = that.filterForm.data.version;
  1188. that.dialog.equationEditing.form.data.code = row.itemid;
  1189. that.dialog.equationEditing.show = true;
  1190. },
  1191. selectByTopicId (data) {
  1192. let that = this;
  1193. that.filterForm.data.workprocid = data.id;
  1194. that.getTableData(1);
  1195. }
  1196. }
  1197. }
  1198. </script>
  1199. <style lang="less">
  1200. .processAndMaterial {
  1201. min-width: 700px;
  1202. height: 100%;
  1203. .box {
  1204. height: 100%;
  1205. padding: 15px 15px 0 15px;
  1206. .box-left {
  1207. float: left;
  1208. width: 200px;
  1209. height: calc(100% - 3px);
  1210. overflow: auto;
  1211. .box-left-bt {
  1212. line-height: 35px;
  1213. font-size: 16px;
  1214. border-bottom: 1px solid #ccc;
  1215. }
  1216. .box-left-tree {
  1217. height: calc(100% - 50px);
  1218. overflow: auto;
  1219. padding: 7px 7px 0 0;
  1220. .tree-row-on {
  1221. color: #3279e8;
  1222. font-weight: 600;
  1223. }
  1224. }
  1225. }
  1226. .box-right {
  1227. border-left: 1px solid #ccc;
  1228. margin-left: 200px;
  1229. .box-top {
  1230. .box-top-form {
  1231. padding-left: 7px;
  1232. .el-form-item {
  1233. margin-bottom: 7px;
  1234. }
  1235. }
  1236. .box-top-gjl {
  1237. overflow: hidden;
  1238. // margin-top: -7px;
  1239. padding: 7px 0 7px 7px;
  1240. border-top: 1px solid #ccc;
  1241. // border-bottom: 1px solid #ccc;
  1242. // margin-bottom: 6px;
  1243. }
  1244. }
  1245. .box-bottom {
  1246. padding-left: 7px;
  1247. }
  1248. }
  1249. .el-table .el-table__row {
  1250. height: 35px;
  1251. }
  1252. .el-table__body .el-form-item--mini.el-form-item {
  1253. margin: 0px;
  1254. .error {
  1255. overflow: hidden;
  1256. color: #f56c6c;
  1257. font-size: 12px;
  1258. line-height: 1;
  1259. }
  1260. }
  1261. }
  1262. .color_no {
  1263. color: #7a7a7a;
  1264. }
  1265. .color_yes {
  1266. color: #1a9f17;
  1267. }
  1268. }
  1269. </style>