SecurityFile.vue 58 KB

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