workingProcedure.vue 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="visible"
  6. :title="title"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. width="85%"
  10. :maxable="true"
  11. >
  12. <el-card shadow="never">
  13. <header-title title="物品信息"></header-title>
  14. <el-form
  15. label-width="100px"
  16. ref="form"
  17. :model="rowData"
  18. class="item-height"
  19. >
  20. <el-row>
  21. <el-col :span="6" label-width="100px">
  22. <el-form-item label="名称" prop="name">
  23. <el-input
  24. disabled
  25. placeholder="物品名称"
  26. v-model="treeData.name"
  27. ></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6" label-width="100px">
  31. <el-form-item label="编码" prop="categoryCode">
  32. <el-input
  33. disabled
  34. placeholder="物品编码"
  35. v-model="treeData.categoryCode"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="6" label-width="100px">
  40. <el-form-item label="型号" prop="modelType">
  41. <el-input
  42. disabled
  43. placeholder="物品型号"
  44. v-model="treeData.modelType"
  45. ></el-input>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6" label-width="100px">
  49. <el-form-item label="规格" prop="specification">
  50. <el-input
  51. disabled
  52. placeholder="物品规格"
  53. v-model="treeData.specification"
  54. ></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="6" label-width="100px">
  58. <el-form-item label="bom编码" prop="code">
  59. <el-input
  60. disabled
  61. placeholder="物品规格"
  62. v-model="treeData.code"
  63. ></el-input>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. </el-form>
  68. <header-title title="工序信息"></header-title>
  69. <el-form label-width="100px" ref="form" :model="rowData">
  70. <el-row>
  71. <el-col :span="6" label-width="100px">
  72. <el-form-item label="编码" prop="type">
  73. <el-input
  74. disabled
  75. placeholder="工序编码"
  76. v-model="rowData.code"
  77. ></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="6" label-width="100px">
  81. <el-form-item label="工序名称" prop="type">
  82. <el-input
  83. disabled
  84. placeholder="工序名称"
  85. v-model="rowData.name"
  86. ></el-input>
  87. </el-form-item>
  88. </el-col>
  89. <!-- <el-col :span="6" label-width="100px">
  90. <el-form-item label="名称" prop="type">
  91. <el-input
  92. disabled
  93. placeholder="物品名称"
  94. v-model="rowData.name"
  95. ></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="6" label-width="100px">
  99. <el-form-item label="物品编码" prop="type">
  100. <el-input
  101. disabled
  102. placeholder="工序名称"
  103. v-model="rowData.name"
  104. ></el-input>
  105. </el-form-item>
  106. </el-col> -->
  107. </el-row>
  108. </el-form>
  109. <el-tabs
  110. v-model="activeName"
  111. class="tab-box"
  112. type="border-card"
  113. @tab-click="tabsChange"
  114. >
  115. <el-tab-pane label="工艺参数" name="工艺参数">
  116. <ele-pro-table
  117. ref="table"
  118. :datasource="datasource"
  119. :immediate="true"
  120. :need-page="false"
  121. :columns="columns"
  122. >
  123. <!-- 表头工具栏 -->
  124. <template v-if="!isView" v-slot:toolbar>
  125. <el-button
  126. size="small"
  127. icon="el-icon-plus"
  128. class="ele-btn-icon"
  129. type="primary"
  130. @click.native="openParam('工艺')"
  131. >添加参数</el-button
  132. >
  133. </template>
  134. <template v-slot:sort="{ row }">
  135. <div v-if="isView">{{ row.sort }}</div>
  136. <el-input v-else v-model="row.sort"></el-input>
  137. </template>
  138. <!-- 默认值 -->
  139. <template v-slot:defaultValue="{ row }">
  140. <div v-if="isView">
  141. {{ row.defaultValue }}
  142. </div>
  143. <div v-else>
  144. <el-input
  145. v-if="
  146. row.textType == 1 ||
  147. row.textType == 4 ||
  148. row.textType == 3 ||
  149. row.textType == 5
  150. "
  151. v-model="row.defaultValue"
  152. placeholder="请输入"
  153. ></el-input>
  154. <el-select
  155. v-if="row.textType == 2"
  156. v-model="row.defaultValue"
  157. placeholder="请选择"
  158. >
  159. <el-option label="TRUE" :value="'TRUE'" />
  160. <el-option label="FALSE" :value="'FALSE'" />
  161. </el-select>
  162. </div>
  163. </template>
  164. <!-- 上限 -->
  165. <template v-slot:maxValue="{ row }">
  166. <div v-if="isView">
  167. {{ row.maxValue }}
  168. </div>
  169. <div v-else>
  170. <el-input
  171. v-if="row.textType == 3"
  172. v-model="row.maxValue"
  173. placeholder="请输入"
  174. ></el-input>
  175. </div>
  176. </template>
  177. <!-- 下限 -->
  178. <template v-slot:minValue="{ row }">
  179. <div v-if="isView">
  180. {{ row.minValue }}
  181. </div>
  182. <div v-else>
  183. <el-input
  184. v-if="row.textType == 3"
  185. v-model="row.minValue"
  186. placeholder="请输入"
  187. ></el-input>
  188. </div>
  189. </template>
  190. <!-- 单位 -->
  191. <template v-slot:unitName="{ row }">
  192. <div v-if="isView">
  193. {{ row.unitName }}
  194. </div>
  195. <div v-else>
  196. <DictSelection
  197. v-if="row.textType != 2 && row.textType != 5"
  198. dictName="工艺参数单位"
  199. clearable
  200. filterable
  201. v-model="row.unitName"
  202. >
  203. </DictSelection>
  204. <span v-if="row.textType == 5"> h(小时)</span>
  205. </div>
  206. </template>
  207. <!-- 操作列 -->
  208. <template v-slot:action="{ row }">
  209. <el-popconfirm
  210. class="ele-action"
  211. title="确定要删除当前参数吗?"
  212. @confirm="remove(row, '工艺')"
  213. >
  214. <template v-slot:reference>
  215. <el-link
  216. type="danger"
  217. :underline="false"
  218. icon="el-icon-delete"
  219. >
  220. 删除
  221. </el-link>
  222. </template>
  223. </el-popconfirm>
  224. </template>
  225. </ele-pro-table>
  226. </el-tab-pane>
  227. <el-tab-pane label="质检项参数" name="质检项参数">
  228. <term
  229. :qualityParam="qualityParam"
  230. :isView="isView"
  231. ref="qualityParamRef"
  232. ></term>
  233. </el-tab-pane>
  234. <el-tab-pane label="生产节拍" name="生产节拍">
  235. <el-form
  236. label-width="140px"
  237. ref="form"
  238. :model="beatParam"
  239. style="width: 800px; margin: auto"
  240. >
  241. <el-row>
  242. <el-col :span="16" label-width="100px">
  243. <el-form-item label="节拍生产数量" prop="beatNum">
  244. <el-input
  245. v-if="!isView"
  246. placeholder=""
  247. v-model="beatParam.beatNum"
  248. maxlength="9"
  249. ></el-input>
  250. <div v-else>{{ beatParam.beatNum }}</div>
  251. </el-form-item>
  252. </el-col>
  253. <el-col :span="8" label-width="100px">
  254. <el-form-item label="单位:" prop="unit">
  255. <el-select
  256. v-if="!isView"
  257. v-model="beatParam.unit"
  258. filterable
  259. class="ele-block"
  260. @change="changeUnit"
  261. >
  262. <el-option
  263. v-for="item in dictList"
  264. :key="item.value"
  265. :value="item.value"
  266. :label="item.label"
  267. ></el-option>
  268. </el-select>
  269. <div v-else>{{ beatParam.unit }}</div>
  270. </el-form-item>
  271. </el-col>
  272. </el-row>
  273. <el-row>
  274. <el-col :span="16" label-width="100px">
  275. <el-form-item label="生产时长" prop="newBeatTime">
  276. <el-input
  277. v-if="!isView"
  278. placeholder=""
  279. v-model="beatParam.newBeatTime"
  280. @blur="convertVal(beatParam.newBeatTime, 'beatTime')"
  281. maxlength="9"
  282. oninput="value = value.replace(/[^\d.]/g, '')"
  283. ></el-input>
  284. <div v-else>{{ beatParam.newBeatTime }}</div>
  285. </el-form-item>
  286. </el-col>
  287. <el-col :span="8" label-width="100px">
  288. <el-form-item label="单位:" prop="">
  289. <div>{{ beatParam.unit }}</div>
  290. </el-form-item>
  291. </el-col>
  292. </el-row>
  293. <el-row>
  294. <el-col :span="16" label-width="100px">
  295. <el-form-item label="准备时长" prop="newBeatPrepareTime">
  296. <el-input
  297. v-if="!isView"
  298. placeholder=""
  299. v-model="beatParam.newBeatPrepareTime"
  300. @blur="
  301. convertVal(
  302. beatParam.newBeatPrepareTime,
  303. 'beatPrepareTime'
  304. )
  305. "
  306. maxlength="9"
  307. oninput="value = value.replace(/[^\d.]/g, '')"
  308. ></el-input>
  309. <div v-else>{{ beatParam.newBeatPrepareTime }}</div>
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="8" label-width="100px">
  313. <el-form-item label="单位:" prop="">
  314. <div>{{ beatParam.unit }}</div>
  315. </el-form-item>
  316. </el-col>
  317. </el-row>
  318. <el-row>
  319. <el-col :span="16" label-width="140px">
  320. <el-form-item label="下道工序间隔时长" prop="newBeatRestTime">
  321. <el-input
  322. v-if="!isView"
  323. placeholder=""
  324. v-model="beatParam.newBeatRestTime"
  325. @blur="
  326. convertVal(beatParam.newBeatRestTime, 'beatRestTime')
  327. "
  328. maxlength="9"
  329. oninput="value = value.replace(/[^\d.]/g, '')"
  330. ></el-input>
  331. <div v-else>{{ beatParam.newBeatRestTime }}</div>
  332. </el-form-item>
  333. </el-col>
  334. <el-col :span="8" label-width="100px">
  335. <el-form-item label="单位:" prop="beatRestUnit">
  336. <div>{{ beatParam.unit }}</div>
  337. </el-form-item>
  338. </el-col>
  339. </el-row>
  340. <el-row>
  341. <el-col :span="16" label-width="100px">
  342. <el-form-item label="标准时长" prop="newTime">
  343. <el-input
  344. v-if="!isView"
  345. placeholder="标准时长"
  346. v-model="beatParam.newTime"
  347. @blur="convertVal(beatParam.newTime, 'time')"
  348. maxlength="9"
  349. oninput="value = value.replace(/[^\d.]/g, '')"
  350. ></el-input>
  351. <div v-else>{{ beatParam.newTime }}</div>
  352. </el-form-item>
  353. </el-col>
  354. <el-col :span="8" label-width="100px">
  355. <el-form-item label="单位:" prop="">
  356. <div>{{ beatParam.unit }}</div>
  357. </el-form-item>
  358. </el-col>
  359. </el-row>
  360. <el-row>
  361. <el-col :span="16" label-width="100px">
  362. <el-form-item label="工时单价" prop="taskPrice">
  363. <el-input
  364. v-if="!isView"
  365. placeholder=""
  366. v-model="beatParam.taskPrice"
  367. oninput="value = value.replace(/[^\d.]/g, '')"
  368. maxlength="7"
  369. ></el-input>
  370. <div v-else>{{ beatParam.taskPrice }}</div>
  371. </el-form-item>
  372. </el-col>
  373. <el-col :span="8" label-width="100px">
  374. <el-form-item label="单位:" prop="">
  375. <div>元</div>
  376. </el-form-item>
  377. </el-col>
  378. </el-row>
  379. <el-row>
  380. <el-col :span="24" label-width="100px">
  381. <el-form-item label="备注" prop="remark">
  382. <el-input
  383. v-if="!isView"
  384. placeholder=""
  385. v-model="beatParam.remark"
  386. type="textarea"
  387. :rows="4"
  388. ></el-input>
  389. <div v-else>{{ beatParam.remark }}</div>
  390. </el-form-item>
  391. </el-col>
  392. </el-row>
  393. </el-form>
  394. </el-tab-pane>
  395. <el-tab-pane label="材料定额" name="材料定额">
  396. <ele-pro-table
  397. ref="materialTable"
  398. :columns="columns1"
  399. :datasource="datasource"
  400. :need-page="false"
  401. :immediate="true"
  402. >
  403. <!-- 表头工具栏 -->
  404. <template v-slot:toolbar>
  405. <el-button
  406. type="primary"
  407. v-if="
  408. !isView &&
  409. attributeData.approvalStatus != 1 &&
  410. attributeData.approvalStatus != 2
  411. "
  412. @click="add"
  413. >添加</el-button
  414. >
  415. <el-button
  416. type="primary"
  417. v-if="
  418. !isView &&
  419. attributeData.approvalStatus != 1 &&
  420. attributeData.approvalStatus != 2
  421. "
  422. @click="detailsList"
  423. >从明细表导入</el-button
  424. >
  425. <div class="toolbar_box">
  426. <div>
  427. <el-form
  428. ref="form"
  429. :rules="rules"
  430. :model="form"
  431. label-width="80px"
  432. inline
  433. >
  434. <el-form-item prop="baseCount" label="基本数量">
  435. <el-input
  436. placeholder="请输入"
  437. disabled
  438. v-model.number="form.baseCount"
  439. >
  440. </el-input>
  441. </el-form-item>
  442. <el-form-item prop="baseCountUnit" label="单位">
  443. <!-- <DictSelection
  444. dictName="计量单位"
  445. clearable
  446. :disabled="true"
  447. v-model="form.baseCountUnit"
  448. ></DictSelection> -->
  449. <!-- <el-form-item label="单位:" prop="unit"> -->
  450. <el-select
  451. disabled
  452. v-model="form.baseCountUnit"
  453. filterable
  454. class="ele-block"
  455. @change="changeUnit"
  456. >
  457. <el-option
  458. v-for="item in unitList"
  459. :key="item.value"
  460. :value="item.value"
  461. :label="item.label"
  462. ></el-option>
  463. </el-select>
  464. <!-- </el-form-item> -->
  465. </el-form-item>
  466. </el-form>
  467. </div>
  468. </div>
  469. </template>
  470. <template
  471. v-if="
  472. attributeData.approvalStatus != 1 &&
  473. attributeData.approvalStatus != 2
  474. "
  475. v-slot:action="{ row, $index }"
  476. >
  477. <el-link type="danger" @click="handleDel(row, $index)"
  478. >删除</el-link
  479. >
  480. <el-link type="primary" @click="handSubstitution(row)"
  481. >替代料</el-link
  482. >
  483. </template>
  484. <template v-slot:subCode="{ row }">
  485. <div v-if="isView">{{ row.subCode }}</div>
  486. <el-input
  487. v-else
  488. v-model="row.subCode"
  489. placeholder="请输入"
  490. :disabled="
  491. attributeData.approvalStatus == 1 ||
  492. attributeData.approvalStatus == 2
  493. "
  494. ></el-input>
  495. </template>
  496. <template v-slot:isReworkBom="{ row }">
  497. <div v-if="isView">{{ isReworkBom[row.isReworkBom] }}</div>
  498. <div v-else>
  499. <el-select
  500. v-model="row.isReworkBom"
  501. :disabled="
  502. attributeData.approvalStatus == 1 ||
  503. attributeData.approvalStatus == 2
  504. "
  505. >
  506. <el-option
  507. v-for="item in isReworkBomList"
  508. :key="item.value"
  509. :label="item.label"
  510. :value="item.value"
  511. >
  512. </el-option>
  513. </el-select>
  514. </div>
  515. </template>
  516. <template v-slot:unit="{ row }">
  517. <div v-if="isView">{{ row.unit }}</div>
  518. <div v-else>
  519. <DictSelection
  520. dictName="计量单位"
  521. :isProhibit="true"
  522. v-model="row.unit"
  523. ></DictSelection>
  524. </div>
  525. </template>
  526. <template v-slot:count="{ row }">
  527. <div v-if="isView">{{ row.count }}</div>
  528. <el-input
  529. v-else
  530. v-model="row.count"
  531. placeholder="请输入"
  532. style="width: 90px"
  533. @input="handleInput(row)"
  534. :disabled="
  535. attributeData.approvalStatus == 1 ||
  536. attributeData.approvalStatus == 2
  537. "
  538. ></el-input>
  539. </template>
  540. <template v-slot:categoryName="{ row, $index }">
  541. <el-link
  542. type="primary"
  543. :underline="false"
  544. @click="handSubstitution(row)"
  545. v-if="
  546. isView ||
  547. attributeData.approvalStatus == 1 ||
  548. attributeData.approvalStatus == 2
  549. "
  550. >{{ row.categoryName }}</el-link
  551. >
  552. <div v-else
  553. ><el-input
  554. :value="row.categoryName"
  555. placeholder="请选择"
  556. @click.native="categorySelect(row, $index)"
  557. ></el-input
  558. ></div>
  559. </template>
  560. <template v-slot:bomArtFiles="{ row }">
  561. <fileMain
  562. v-model="row.bomArtFiles"
  563. :type="
  564. isView ||
  565. attributeData.approvalStatus == 1 ||
  566. attributeData.approvalStatus == 2
  567. ? 'view'
  568. : 'add'
  569. "
  570. size="mini"
  571. />
  572. </template>
  573. <template v-slot:remark="{ row }">
  574. <div v-if="isView">{{ row.remark }}</div>
  575. <el-input
  576. v-else
  577. v-model="row.remark"
  578. placeholder="请输入"
  579. :disabled="
  580. attributeData.approvalStatus == 1 ||
  581. attributeData.approvalStatus == 2
  582. "
  583. ></el-input>
  584. </template>
  585. </ele-pro-table>
  586. </el-tab-pane>
  587. <el-tab-pane label="关键设备" name="关键设备">
  588. <ele-pro-table
  589. ref="deviceTabRef"
  590. :columns="standardCol"
  591. :datasource="datasource"
  592. :need-page="false"
  593. :immediate="true"
  594. >
  595. <!-- 表头工具栏 -->
  596. <template v-if="!isView" v-slot:toolbar>
  597. <el-button type="primary" @click="add">添加</el-button>
  598. </template>
  599. <template v-slot:action="{ row, $index }">
  600. <el-link type="danger" @click="handleDel(row, $index)"
  601. >删除</el-link
  602. >
  603. </template>
  604. </ele-pro-table>
  605. </el-tab-pane>
  606. <el-tab-pane label="制造资源" name="制造资源">
  607. <ele-pro-table
  608. ref="resourceTable"
  609. :columns="columns1"
  610. :datasource="datasource"
  611. :need-page="false"
  612. :immediate="true"
  613. >
  614. <!-- 表头工具栏 -->
  615. <template v-if="!isView" v-slot:toolbar>
  616. <el-button type="primary" @click="add">添加</el-button>
  617. </template>
  618. <template v-slot:action="{ row, $index }">
  619. <el-link type="primary" @click="handleDel(row, $index)"
  620. >删除</el-link
  621. >
  622. </template>
  623. <template v-slot:subCode="{ row }">
  624. <div v-if="isView">{{ row.subCode }}</div>
  625. <el-input
  626. v-else
  627. v-model="row.subCode"
  628. placeholder="请输入"
  629. ></el-input>
  630. </template>
  631. <template v-slot:isReworkBom="{ row }">
  632. <div v-if="isView">{{ isReworkBom[row.isReworkBom] }}</div>
  633. <div v-else>
  634. <el-select v-model="row.isReworkBom">
  635. <el-option
  636. v-for="item in isReworkBomList"
  637. :key="item.value"
  638. :label="item.label"
  639. :value="item.value"
  640. >
  641. </el-option>
  642. </el-select>
  643. </div>
  644. </template>
  645. <template v-slot:unit="{ row }">
  646. <div v-if="isView">{{ row.unit }}</div>
  647. <div v-else>
  648. <DictSelection
  649. dictName="计量单位"
  650. v-model="row.unit"
  651. ></DictSelection>
  652. </div>
  653. </template>
  654. <template v-slot:count="{ row }">
  655. <div v-if="isView">{{ row.count }}</div>
  656. <el-input
  657. v-else
  658. v-model="row.count"
  659. placeholder="请输入"
  660. @input="
  661. (value) =>
  662. (row.count = value.replace(
  663. /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
  664. '$1$2.$3'
  665. ))
  666. "
  667. ></el-input>
  668. </template>
  669. <template v-slot:categoryName="{ row, $index }">
  670. <div v-if="isView">{{ row.categoryName }}</div>
  671. <div v-else
  672. ><el-input
  673. :value="row.categoryName"
  674. placeholder="请选择"
  675. @click.native="categorySelect(row, $index)"
  676. ></el-input
  677. ></div>
  678. </template>
  679. <template v-slot:bomArtFiles="{ row }">
  680. <fileUpload v-model="row.bomArtFiles" type="add" size="mini" />
  681. </template>
  682. <template v-slot:remark="{ row }">
  683. <div v-if="isView">{{ row.remark }}</div>
  684. <el-input
  685. v-else
  686. v-model="row.remark"
  687. placeholder="请输入"
  688. ></el-input>
  689. </template>
  690. </ele-pro-table>
  691. </el-tab-pane>
  692. <el-tab-pane label="工种" name="工种">
  693. <ele-pro-table
  694. ref="jobTable"
  695. :columns="jobColumns"
  696. :datasource="datasource"
  697. row-key="id"
  698. >
  699. <!-- 表头工具栏 -->
  700. <template v-slot:toolbar>
  701. <el-button
  702. size="small"
  703. type="primary"
  704. icon="el-icon-plus"
  705. class="ele-btn-icon"
  706. @click="addJob"
  707. >新增</el-button
  708. >
  709. </template>
  710. <template v-slot:action="{ row, $index }">
  711. <el-link type="primary" @click="handleDel(row, $index)"
  712. >删除</el-link
  713. >
  714. </template>
  715. </ele-pro-table>
  716. </el-tab-pane>
  717. <el-tab-pane label="工艺文件" name="工艺文件">
  718. <ele-pro-table
  719. ref="fileTable"
  720. :columns="jobColumns1"
  721. :datasource="datasource"
  722. :need-page="false"
  723. :immediate="true"
  724. >
  725. <!-- 表头工具栏 -->
  726. <template v-if="!isView" v-slot:toolbar>
  727. <el-button type="primary" @click="addFile">添加</el-button>
  728. </template>
  729. <template v-slot:action="{ row, $index }">
  730. <el-link type="primary" @click="handleDel(row, $index)"
  731. >删除</el-link
  732. >
  733. <el-link type="primary" @click="fileDetails(row)">详情</el-link>
  734. </template>
  735. </ele-pro-table>
  736. </el-tab-pane>
  737. <el-tab-pane label="标准产出" name="标准产出">
  738. <ele-pro-table
  739. ref="standard"
  740. :columns="standardCol"
  741. :datasource="datasource"
  742. :need-page="false"
  743. :immediate="true"
  744. >
  745. <!-- 表头工具栏 -->
  746. <template v-if="!isView" v-slot:toolbar>
  747. <el-button type="primary" @click="add">添加</el-button>
  748. </template>
  749. <template v-slot:action="{ row, $index }">
  750. <el-link type="danger" @click="handleDel(row, $index)"
  751. >删除</el-link
  752. >
  753. </template>
  754. </ele-pro-table>
  755. </el-tab-pane>
  756. <el-tab-pane label="过程控制" name="过程控制">
  757. <userSettingMatterProcess
  758. :produce-task-id="rowData.sourceTaskId"
  759. :produce-task-name="rowData.name"
  760. :produce-task-code="rowData.code"
  761. :bom-category-id="resourceBomId"
  762. ref="userSettingMatterProcessRef"
  763. ></userSettingMatterProcess>
  764. </el-tab-pane>
  765. </el-tabs>
  766. </el-card>
  767. <!-- 选择工艺参数 -->
  768. <jobDialog ref="jobRef" @chooseModal="chooseJob"></jobDialog>
  769. <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
  770. <ProductModal ref="productRefs" @changeProduct="determineChoose" />
  771. <ProductModalMultiple
  772. ref="productMultipleRefs"
  773. @selection="addProductList"
  774. ></ProductModalMultiple>
  775. <standardOutput
  776. ref="standardOutputRefs"
  777. @selection="chooseStandardList"
  778. ></standardOutput>
  779. <fileIndex v-if="fileShow" @close="fileClose"></fileIndex>
  780. <fileBrowse ref="browseRef"></fileBrowse>
  781. <replaceMaterialPop
  782. ref="replaceMaterialRef"
  783. @selected="replaceSelected"
  784. :isView="isView"
  785. ></replaceMaterialPop>
  786. <mbomDatailList ref="bomDetailList"></mbomDatailList>
  787. <div class="btns">
  788. <el-button
  789. type="primary"
  790. size="small"
  791. v-if="!isView"
  792. @click="save('save')"
  793. >
  794. 保存</el-button
  795. >
  796. <el-button type="primary" size="small" @click="save('close')">{{
  797. isView ? '确定' : '保存并关闭'
  798. }}</el-button>
  799. <el-button size="small" @click="handleClose">关闭</el-button>
  800. </div>
  801. </ele-modal>
  802. </template>
  803. <script>
  804. import dictMixins from '@/mixins/dictMixins';
  805. import * as dayjs from 'dayjs';
  806. import { getFile } from '@/api/system/file';
  807. // import fileUpload from '@/components/addDoc/index.vue';
  808. import { workingProcedureUpdate } from '@/api/material/BOM';
  809. import ParamModal from '@/views/technology/productParam/components/ParamModal.vue';
  810. import ProductModal from '@/components/select/bom/ProductModal.vue';
  811. import { getByCode } from '@/api/system/dictionary-data';
  812. import ProductModalMultiple from './ProductModalMultiple.vue';
  813. import userSearch from './user-search.vue';
  814. import jobDialog from './jobDialog.vue';
  815. import standardOutput from './standardOutput.vue';
  816. import term from '../qualityTesting/term';
  817. import fileIndex from '../file/index.vue';
  818. import fileBrowse from '../file/fileBrowse.vue';
  819. import replaceMaterialPop from './replaceMaterialPop.vue';
  820. import { newFilePageAPI } from '@/api/material/file';
  821. import { getBomGetById, getDetailList } from '@/api/material/BOM.js';
  822. import mbomDatailList from './mbomDatailList.vue';
  823. import { setFileUrl } from '@/components/addDoc/util.js';
  824. import userSettingMatterProcess from '@/views/technology/production/components/user-setting-matter-process.vue';
  825. export default {
  826. components: {
  827. userSearch,
  828. ParamModal,
  829. // fileUpload,
  830. ProductModal,
  831. jobDialog,
  832. ProductModalMultiple,
  833. standardOutput,
  834. term,
  835. fileIndex,
  836. fileBrowse,
  837. replaceMaterialPop,
  838. mbomDatailList,
  839. userSettingMatterProcess
  840. },
  841. mixins: [dictMixins],
  842. data() {
  843. return {
  844. rules: {
  845. baseCount: [
  846. { required: true, message: '请输入基本数量', trigger: 'blur' }
  847. ],
  848. baseCountUnit: [
  849. { required: true, message: '请选择单位', trigger: 'change' }
  850. ]
  851. },
  852. form: {
  853. baseCount: 0,
  854. baseCountUnit: ''
  855. },
  856. baseCountUnit: '',
  857. baseCount2: '',
  858. baseCountUnit2: '',
  859. isView: false,
  860. filedList: [],
  861. jobFiledList: [],
  862. activeName: '工艺参数',
  863. attributeData: {},
  864. visible: false,
  865. title: '配置',
  866. statusOption: [
  867. {
  868. label: '启用',
  869. value: 1
  870. },
  871. {
  872. label: '停用',
  873. value: 0
  874. }
  875. ],
  876. isReworkBom: ['否', '是'],
  877. isReworkBomList: [
  878. { label: '否', value: 0 },
  879. { label: '是', value: 1 }
  880. ],
  881. dictList: [], //单位下拉
  882. // 表格列配置
  883. columns1: [],
  884. defaultColumns1: [
  885. {
  886. type: 'index',
  887. width: 55,
  888. align: 'center'
  889. },
  890. {
  891. label: '子项编号',
  892. prop: 'subCode',
  893. slot: 'subCode',
  894. action: 'subCode'
  895. },
  896. {
  897. label: '物料名称',
  898. prop: 'categoryName',
  899. slot: 'categoryName',
  900. action: 'categoryName'
  901. },
  902. {
  903. label: '是否回收料',
  904. prop: 'isReworkBom',
  905. slot: 'isReworkBom',
  906. action: 'isReworkBom'
  907. },
  908. {
  909. label: '编码',
  910. prop: 'categoryCode'
  911. },
  912. {
  913. label: '牌号',
  914. prop: 'brandNum'
  915. },
  916. {
  917. label: '型号',
  918. prop: 'modelType'
  919. },
  920. {
  921. prop: 'specification',
  922. label: '规格',
  923. align: 'center',
  924. showOverflowTooltip: true
  925. },
  926. {
  927. label: '数量',
  928. slot: 'count',
  929. action: 'count'
  930. },
  931. {
  932. label: '单位',
  933. slot: 'unit',
  934. action: 'unit'
  935. },
  936. {
  937. label: '附件',
  938. slot: 'bomArtFiles',
  939. action: 'bomArtFiles',
  940. minWidth: 150
  941. },
  942. {
  943. label: '备注',
  944. slot: 'remark',
  945. action: 'remark'
  946. }
  947. ],
  948. columns: [],
  949. // 表格列配置
  950. defaultColumns: [
  951. {
  952. prop: 'sort',
  953. slot: 'sort',
  954. label: '排序',
  955. minWidth: 60
  956. },
  957. {
  958. prop: 'code',
  959. label: '参数编码',
  960. showOverflowTooltip: true,
  961. align: 'center',
  962. minWidth: 110
  963. },
  964. {
  965. prop: 'name',
  966. label: '参数名称',
  967. showOverflowTooltip: true,
  968. align: 'center',
  969. minWidth: 110
  970. },
  971. {
  972. align: 'center',
  973. prop: 'description',
  974. label: '文本描述',
  975. showOverflowTooltip: true,
  976. minWidth: 110
  977. },
  978. {
  979. prop: 'maxValue',
  980. slot: 'maxValue',
  981. label: '参数上限',
  982. align: 'center'
  983. },
  984. {
  985. prop: 'minValue',
  986. slot: 'minValue',
  987. label: '参数下限',
  988. align: 'center'
  989. },
  990. {
  991. prop: 'defaultValue',
  992. slot: 'defaultValue',
  993. label: '默认值',
  994. align: 'center'
  995. }
  996. ],
  997. levelOptions: [
  998. {
  999. label: '初级',
  1000. value: '1'
  1001. },
  1002. {
  1003. label: '中级',
  1004. value: '2'
  1005. },
  1006. {
  1007. label: '高级',
  1008. value: '3'
  1009. }
  1010. ],
  1011. // 表格列配置
  1012. jobColumns: [
  1013. {
  1014. label: '序号',
  1015. type: 'index',
  1016. width: 55,
  1017. align: 'center'
  1018. },
  1019. {
  1020. slot: 'type',
  1021. label: '类型',
  1022. showOverflowTooltip: true,
  1023. align: 'center',
  1024. minWidth: 110,
  1025. formatter: (_row) => {
  1026. return this.getDictValue('工种类型', _row.type);
  1027. }
  1028. },
  1029. {
  1030. align: 'center',
  1031. prop: 'code',
  1032. label: '编码',
  1033. showOverflowTooltip: true,
  1034. minWidth: 110
  1035. },
  1036. {
  1037. slot: 'name',
  1038. prop: 'name',
  1039. label: '名称',
  1040. showOverflowTooltip: true,
  1041. align: 'center',
  1042. minWidth: 110
  1043. },
  1044. {
  1045. slot: 'level',
  1046. prop: 'level',
  1047. label: '等级',
  1048. showOverflowTooltip: true,
  1049. align: 'center',
  1050. minWidth: 110,
  1051. formatter: (_row) => {
  1052. return this.levelOptions.filter(
  1053. (item) => _row.level == item.value
  1054. )[0].label;
  1055. }
  1056. },
  1057. {
  1058. slot: 'hourCost',
  1059. prop: 'hourCost',
  1060. label: '标准工时费',
  1061. showOverflowTooltip: true,
  1062. align: 'center',
  1063. minWidth: 110
  1064. },
  1065. {
  1066. columnKey: 'action',
  1067. label: '操作',
  1068. width: 260,
  1069. align: 'center',
  1070. resizable: false,
  1071. slot: 'action',
  1072. showOverflowTooltip: true
  1073. }
  1074. ],
  1075. // 表格选中数据
  1076. jobColumns1: [
  1077. {
  1078. label: '编码',
  1079. prop: 'code',
  1080. width: 180,
  1081. align: 'center',
  1082. showOverflowTooltip: true
  1083. },
  1084. {
  1085. prop: 'name',
  1086. label: '文档名称',
  1087. align: 'center',
  1088. slot: 'name',
  1089. showOverflowTooltip: true,
  1090. minWidth: 200
  1091. },
  1092. {
  1093. prop: 'storagePath',
  1094. label: '文件名称',
  1095. align: 'center',
  1096. showOverflowTooltip: true,
  1097. minWidth: 200,
  1098. formatter: (_row, _column, cellValue) => {
  1099. return cellValue[0]?.name;
  1100. }
  1101. },
  1102. {
  1103. prop: 'version',
  1104. label: '版本',
  1105. align: 'center',
  1106. showOverflowTooltip: true,
  1107. minWidth: 100
  1108. },
  1109. {
  1110. prop: 'createTime',
  1111. label: '创建时间',
  1112. showOverflowTooltip: true,
  1113. align: 'center',
  1114. minWidth: 110
  1115. },
  1116. {
  1117. columnKey: 'action',
  1118. label: '操作',
  1119. width: 260,
  1120. align: 'center',
  1121. resizable: false,
  1122. slot: 'action',
  1123. showOverflowTooltip: true
  1124. }
  1125. ],
  1126. standardCol: [
  1127. {
  1128. prop: 'code',
  1129. label: '编码'
  1130. },
  1131. {
  1132. prop: 'name',
  1133. label: '名称',
  1134. showOverflowTooltip: true
  1135. },
  1136. {
  1137. prop: 'brandNum',
  1138. label: '牌号'
  1139. },
  1140. {
  1141. prop: 'modelType',
  1142. label: '型号',
  1143. align: 'center',
  1144. showOverflowTooltip: true
  1145. },
  1146. {
  1147. prop: 'specification',
  1148. label: '规格',
  1149. align: 'center',
  1150. showOverflowTooltip: true
  1151. },
  1152. {
  1153. prop: 'measuringUnit',
  1154. label: '计量单位',
  1155. showOverflowTooltip: true,
  1156. minWidth: 90
  1157. },
  1158. {
  1159. columnKey: 'action',
  1160. label: '操作',
  1161. align: 'center',
  1162. resizable: false,
  1163. slot: 'action',
  1164. showOverflowTooltip: true
  1165. }
  1166. ],
  1167. rowData: {},
  1168. treeData: {},
  1169. currentIndex: 0,
  1170. tableData: {},
  1171. beatParam: {
  1172. newTime: '',
  1173. time: '',
  1174. newBeatPrepareTime: '',
  1175. beatPrepareTime: '',
  1176. newBeatTime: '',
  1177. beatTime: '',
  1178. newBeatRestTime: '',
  1179. beatRestTime: '',
  1180. taskPrice: ''
  1181. },
  1182. qualityParam: [],
  1183. qualityPointParam: [],
  1184. fileShow: false,
  1185. resourceBomId: '',
  1186. level: '',
  1187. attributeData: {},
  1188. unitList: []
  1189. };
  1190. },
  1191. created() {
  1192. this.requestDict('工种类型');
  1193. this.getDictList('time_unit');
  1194. this.getDicTUnitList('measuring_uint');
  1195. },
  1196. methods: {
  1197. addFile() {
  1198. this.fileShow = true;
  1199. },
  1200. fileClose(val) {
  1201. if (val == false) {
  1202. this.fileShow = false;
  1203. } else {
  1204. this.fileShow = false;
  1205. this.$refs.fileTable.setData([
  1206. ...val,
  1207. ...this.$refs.fileTable.getData()
  1208. ]);
  1209. this.$set(
  1210. this.tableData.taskParam[this.currentIndex],
  1211. 'fileParam',
  1212. this.$refs.fileTable.getData()
  1213. );
  1214. }
  1215. },
  1216. async getDicTUnitList(code) {
  1217. let { data: res } = await getByCode(code);
  1218. this.unitList = res.reduce((acc, curr) => {
  1219. let key = Object.keys(curr)[0]; // 获取当前对象的键
  1220. let value = curr[key]; // 获取当前对象的值
  1221. acc.push({ value, label: value }); // 将 { value, label } 格式的对象添加到数组中
  1222. return acc;
  1223. }, []); // 初始值为空数组 []
  1224. console.log(this.unitList, 'this.unitList');
  1225. },
  1226. handleInput(item) {
  1227. let newVal = item.count.replace(/[^\d.]/g, '');
  1228. // 2. 不能以点开头
  1229. if (newVal.startsWith('.')) {
  1230. newVal = '';
  1231. }
  1232. // 3. 只允许出现一个小数点
  1233. const firstDotIndex = newVal.indexOf('.');
  1234. if (firstDotIndex !== -1) {
  1235. newVal =
  1236. newVal.slice(0, firstDotIndex + 1) +
  1237. newVal.slice(firstDotIndex + 1).replace(/\./g, '');
  1238. }
  1239. // 4. 更新数据
  1240. item.count = newVal;
  1241. },
  1242. async detailsList() {
  1243. console.log(this.rowData, 'this.rowData');
  1244. await getDetailList({
  1245. bomType: this.attributeData.bomType,
  1246. bomCategoryId: this.resourceBomId,
  1247. taskId: this.rowData.id
  1248. }).then((res) => {
  1249. console.log(res);
  1250. this.$refs.materialTable.setData(res.data);
  1251. this.tableData.taskParam[this.currentIndex].materialQuota = res.data;
  1252. console.log(this.tableData, 'this.tableData');
  1253. });
  1254. // this.$refs.bomDetailList.open(this.resourceBomId, this.level)
  1255. },
  1256. fileDetails(row) {
  1257. window.open(setFileUrl(row));
  1258. },
  1259. addJob() {
  1260. this.$refs.jobRef.open();
  1261. },
  1262. chooseJob(data) {
  1263. this.$refs.jobTable.setData([
  1264. ...data,
  1265. ...this.$refs.jobTable.getData()
  1266. ]);
  1267. this.$set(
  1268. this.tableData.taskParam[this.currentIndex],
  1269. 'aptitudeParam',
  1270. this.$refs.jobTable.getData()
  1271. );
  1272. },
  1273. determineChoose(title, row, idx) {
  1274. let type = '';
  1275. if (this.activeName === '材料定额') {
  1276. type = 'materialQuota';
  1277. } else if (this.activeName === '制造资源') {
  1278. type = 'resource';
  1279. }
  1280. if (title == '选择物料') {
  1281. console.log(row, 'row');
  1282. this.$set(
  1283. this.tableData.taskParam[this.currentIndex][type][idx],
  1284. 'categoryName',
  1285. row.name
  1286. );
  1287. this.$set(
  1288. this.tableData.taskParam[this.currentIndex][type][idx],
  1289. 'categoryId',
  1290. row.id
  1291. );
  1292. this.$set(
  1293. this.tableData.taskParam[this.currentIndex][type][idx],
  1294. 'categoryCode',
  1295. row.code
  1296. );
  1297. this.$set(
  1298. this.tableData.taskParam[this.currentIndex][type][idx],
  1299. 'unit',
  1300. row.measuringUnit
  1301. );
  1302. this.$set(
  1303. this.tableData.taskParam[this.currentIndex][type][idx],
  1304. 'weightUnit',
  1305. row.weightUnit
  1306. );
  1307. this.$set(
  1308. this.tableData.taskParam[this.currentIndex][type][idx],
  1309. 'brandNum',
  1310. row.brandNum
  1311. );
  1312. this.$set(
  1313. this.tableData.taskParam[this.currentIndex][type][idx],
  1314. 'modelType',
  1315. row.modelType
  1316. );
  1317. this.$set(
  1318. this.tableData.taskParam[this.currentIndex][type][idx],
  1319. 'rootCategoryLevelId',
  1320. row.categoryLevelPathIdParent
  1321. );
  1322. this.$set(
  1323. this.tableData.taskParam[this.currentIndex][type][idx],
  1324. 'specification',
  1325. row.specification
  1326. );
  1327. this.$set(
  1328. this.tableData.taskParam[this.currentIndex][type][idx],
  1329. 'id',
  1330. row.id
  1331. );
  1332. }
  1333. },
  1334. uploadedSuccess(data, row) {
  1335. row.bomArtFiles = data[0].storePath;
  1336. this.filedList = [];
  1337. },
  1338. uploadedJobSuccess(data, row) {
  1339. row.path = data[0].storePath;
  1340. row.name = data[0].name;
  1341. this.jobFiledList = [];
  1342. },
  1343. downloadFile(url) {
  1344. getFile({ objectName: url }, '附件');
  1345. },
  1346. categorySelect(row, idx) {
  1347. this.$refs.productRefs.open(row, '选择物料', '1', idx);
  1348. },
  1349. handleDel(row, index) {
  1350. let type = '';
  1351. if (this.activeName === '材料定额') {
  1352. type = 'materialQuota';
  1353. } else if (this.activeName === '制造资源') {
  1354. type = 'resource';
  1355. } else if (this.activeName === '工种') {
  1356. type = 'aptitudeParam';
  1357. } else if (this.activeName === '工艺文件') {
  1358. type = 'fileParam';
  1359. } else if (this.activeName === '标准产出') {
  1360. type = 'standardOutput';
  1361. } else if (this.activeName === '关键设备') {
  1362. type = 'standardDevice';
  1363. }
  1364. this.tableData.taskParam[this.currentIndex][type].splice(index, 1);
  1365. },
  1366. addProductList(list) {
  1367. let subCode = 0;
  1368. let array = [];
  1369. list.map((item, index) => {
  1370. let max = '';
  1371. if (
  1372. this.tableData.taskParam[this.currentIndex]['materialQuota']
  1373. .length > 0
  1374. ) {
  1375. max =
  1376. Math.max(
  1377. ...this.tableData.taskParam[this.currentIndex][
  1378. 'materialQuota'
  1379. ].map((i) => i.subCode)
  1380. ) +
  1381. 10 * ++index +
  1382. '';
  1383. if (max.length < 4) {
  1384. max = new Array(4 - max.length).fill('0').join('') + max;
  1385. }
  1386. } else {
  1387. max = 10 * ++index + '';
  1388. if (max.length < 4) {
  1389. max = new Array(4 - max.length).fill('0').join('') + max;
  1390. }
  1391. }
  1392. console.log('item', this.isValueANumber(item.specification));
  1393. if (
  1394. item.categoryLevelPathIdParent == 8 &&
  1395. this.isValueANumber(this.baseCount) &&
  1396. this.isValueANumber(item.specification)
  1397. ) {
  1398. let num = this.baseCount / item.specification;
  1399. item.count = num == 'Infinity' ? '' : num.toFixed(3);
  1400. }
  1401. subCode = max.substring(0, max.length - 1) + '0';
  1402. array.push({
  1403. subCode,
  1404. id: item.id,
  1405. categoryName: item.name,
  1406. categoryCode: item.code,
  1407. isReworkBom: 0,
  1408. brandNum: item.brandNum,
  1409. count: item.count || '',
  1410. modelType: item.modelType,
  1411. unit: item.measuringUnit,
  1412. bomArtFiles: [],
  1413. remark: '',
  1414. specification: item.specification,
  1415. rootCategoryLevelId: item.categoryLevelPathIdParent,
  1416. extInfo: item.extInfo
  1417. });
  1418. });
  1419. let _arr =
  1420. this.tableData.taskParam[this.currentIndex].materialQuota.concat(
  1421. array
  1422. );
  1423. let uniqueArray = [];
  1424. uniqueArray = _arr.reduce((acc, current) => {
  1425. const existing = acc.find((item) => item.id === current.id);
  1426. if (!existing) {
  1427. acc.push(current);
  1428. }
  1429. return acc;
  1430. }, []);
  1431. this.tableData.taskParam[this.currentIndex].materialQuota = uniqueArray;
  1432. this.$refs.materialTable.setData(
  1433. this.tableData.taskParam[this.currentIndex].materialQuota
  1434. );
  1435. },
  1436. isValueANumber(variable) {
  1437. if (variable === undefined || variable === null) {
  1438. return false; // 变量没有值
  1439. }
  1440. if (typeof variable === 'number') {
  1441. return true; // 基本类型的数字
  1442. }
  1443. if (
  1444. (typeof variable === 'string' &&
  1445. !isNaN(variable) &&
  1446. !variable.includes('.')) ||
  1447. (variable.includes('.') && !variable.endsWith('.'))
  1448. ) {
  1449. // 字符串类型的数字(注意:这个正则表达式判断较为简单,可能需要根据实际情况调整)
  1450. // 或者使用 Number.isFinite(parseFloat(variable)) 来代替这部分逻辑,但要注意性能开销和边缘情况
  1451. const num = Number(variable);
  1452. return !isNaN(num) && isFinite(num);
  1453. }
  1454. return false; // 其他类型
  1455. },
  1456. add() {
  1457. let subCode = '0010';
  1458. let type = '';
  1459. if (this.activeName === '材料定额') {
  1460. this.$refs.productMultipleRefs.open(1);
  1461. return;
  1462. } else if (this.activeName === '标准产出') {
  1463. this.$refs.standardOutputRefs.open(9);
  1464. return;
  1465. } else if (this.activeName === '关键设备') {
  1466. this.$refs.standardOutputRefs.open(4);
  1467. return;
  1468. } else if (this.activeName === '制造资源') {
  1469. type = 'resource';
  1470. }
  1471. console.log(this.tableData.taskParam[this.currentIndex]);
  1472. if (this.tableData.taskParam[this.currentIndex][type].length) {
  1473. let max =
  1474. Math.max(
  1475. ...this.tableData.taskParam[this.currentIndex][type].map(
  1476. (i) => i.subCode
  1477. )
  1478. ) +
  1479. 10 +
  1480. '';
  1481. if (max.length < 4) {
  1482. max = new Array(4 - max.length).fill('0').join('') + max;
  1483. }
  1484. subCode = max.substring(0, max.length - 1) + '0';
  1485. }
  1486. this.tableData.taskParam[this.currentIndex][type].push({
  1487. subCode,
  1488. bomArtFiles: [],
  1489. categoryId: '',
  1490. categoryName: '',
  1491. isReworkBom: 0,
  1492. brandNum: '',
  1493. count: '',
  1494. modelType: '',
  1495. unit: '',
  1496. rootCategoryLevelId: '',
  1497. categoryCode: '',
  1498. specification: '',
  1499. id: ''
  1500. });
  1501. },
  1502. /* 表格数据源 */
  1503. async datasource() {
  1504. return [];
  1505. },
  1506. tabsChange() {
  1507. console.log(this.activeName);
  1508. console.log(this.tableData.taskParam[this.currentIndex]);
  1509. if (this.activeName === '工艺参数') {
  1510. // 工艺参数
  1511. this.$refs.table.setData(
  1512. this.tableData.taskParam[this.currentIndex].produceList || []
  1513. );
  1514. } else if (this.activeName === '质检项参数') {
  1515. this.qualityParam =
  1516. this.tableData.taskParam[this.currentIndex].qualityParam || [];
  1517. } else if (this.activeName === '生产节拍') {
  1518. this.beatParam =
  1519. this.tableData.taskParam[this.currentIndex].beatParam ||
  1520. this.beatParam;
  1521. } else if (this.activeName === '材料定额') {
  1522. this.$refs.materialTable.setData(
  1523. this.tableData.taskParam[this.currentIndex].materialQuota || []
  1524. );
  1525. } else if (this.activeName === '制造资源') {
  1526. this.$refs.resourceTable.setData(
  1527. this.tableData.taskParam[this.currentIndex].resource || []
  1528. );
  1529. } else if (this.activeName === '工种') {
  1530. if (
  1531. JSON.stringify(
  1532. this.tableData.taskParam[this.currentIndex].aptitudeParam
  1533. ) == '{}'
  1534. ) {
  1535. this.tableData.taskParam[this.currentIndex].aptitudeParam = [];
  1536. this.$refs.jobTable.setData([]);
  1537. } else {
  1538. this.$refs.jobTable.setData(
  1539. this.tableData.taskParam[this.currentIndex].aptitudeParam
  1540. );
  1541. }
  1542. } else if (this.activeName === '工艺文件') {
  1543. if (
  1544. JSON.stringify(
  1545. this.tableData.taskParam[this.currentIndex].fileParam
  1546. ) == '{}'
  1547. ) {
  1548. this.tableData.taskParam[this.currentIndex].fileParam = [];
  1549. this.$refs.fileTable.setData([]);
  1550. } else {
  1551. let fileId = this.tableData.taskParam[this.currentIndex].fileParam;
  1552. console.log('111111');
  1553. if (fileId.length > 0) {
  1554. this.fileParamDatasource(fileId);
  1555. }
  1556. // this.$refs.fileTable.setData(
  1557. // this.tableData.taskParam[this.currentIndex].fileParam
  1558. // );
  1559. }
  1560. } else if (this.activeName === '标准产出') {
  1561. this.$refs.standard.setData(
  1562. this.tableData.taskParam[this.currentIndex].standardOutput || []
  1563. );
  1564. } else if (this.activeName === '关键设备') {
  1565. this.$refs.deviceTabRef.setData(
  1566. this.tableData.taskParam[this.currentIndex].standardDevice || []
  1567. );
  1568. } else if (this.activeName === '过程控制') {
  1569. // 过程控制数据查询
  1570. }
  1571. },
  1572. openParam(type) {
  1573. let tableData = [];
  1574. if (type === '工艺') {
  1575. tableData = this.$refs.table.getData();
  1576. } else {
  1577. tableData = this.$refs.qualityTable.getData();
  1578. }
  1579. this.$refs.paramRefs.open(tableData);
  1580. },
  1581. chooseModal(data) {
  1582. let dom = null;
  1583. if (this.activeName === '工艺参数') {
  1584. dom = this.$refs.table;
  1585. }
  1586. dom.setData([...data, ...dom.getData()]);
  1587. this.$set(
  1588. this.tableData.taskParam[this.currentIndex],
  1589. this.activeName === '工艺参数' ? 'produceList' : '',
  1590. dom.getData()
  1591. );
  1592. },
  1593. chooseStandardList(type, data) {
  1594. let dom = null;
  1595. if (type == 9) {
  1596. dom = this.$refs.standard;
  1597. dom.setData([data[0]]);
  1598. this.$set(
  1599. this.tableData.taskParam[this.currentIndex],
  1600. 'standardOutput',
  1601. dom.getData()
  1602. );
  1603. } else if (type == 4) {
  1604. dom = this.$refs.deviceTabRef;
  1605. dom.setData([data[0]]);
  1606. this.$set(
  1607. this.tableData.taskParam[this.currentIndex],
  1608. 'standardDevice',
  1609. dom.getData()
  1610. );
  1611. }
  1612. },
  1613. remove(row, type) {
  1614. let dom = null;
  1615. if (type === '工艺') {
  1616. dom = this.$refs.table;
  1617. } else {
  1618. dom = this.$refs.qualityTable;
  1619. }
  1620. const data = dom.getData();
  1621. if (row.id) {
  1622. dom.setData(data.filter((d) => d.id !== row.id));
  1623. } else {
  1624. dom.setData(data.filter((d) => d.paramId !== row.paramId));
  1625. }
  1626. this.$set(
  1627. this.tableData.taskParam[this.currentIndex],
  1628. type === '工艺' ? 'produceList' : 'qualityParam',
  1629. dom.getData()
  1630. );
  1631. },
  1632. open(rowData, treeData, tableData, isView, attributeData, resourceBomId) {
  1633. // 工序信息
  1634. console.log('rowData', rowData);
  1635. // bom 信息
  1636. console.log('treeData', treeData);
  1637. // 工序信息列表 信息 包括工艺参数 材料定额等
  1638. console.log('tableData', tableData);
  1639. // 是否为详情 详情只能查看
  1640. console.log('isView', isView);
  1641. // bom 信息 和 treeData 一致
  1642. console.log('attributeData', attributeData);
  1643. // bom category id
  1644. console.log('resourceBomId', resourceBomId);
  1645. this.columns = [];
  1646. this.columns1 = [];
  1647. this.isView = isView; //true详情 false编辑
  1648. this.resourceBomId = resourceBomId;
  1649. this.attributeData = attributeData;
  1650. this.form.baseCount = attributeData.baseCount;
  1651. // if (rowData.baseCount) {
  1652. // this.form.baseCount = rowData.baseCount;
  1653. // } else {
  1654. // this.form.baseCount = attributeData.baseCount
  1655. // ? attributeData.baseCount
  1656. // : 1;
  1657. // }
  1658. // if (this.attributeData) {
  1659. // this.form.baseCount = this.attributeData.baseCount;
  1660. // } else {
  1661. // this.form.baseCount = 1;
  1662. // }
  1663. if (!this.isView) {
  1664. this.columns = this.defaultColumns.concat({
  1665. columnKey: 'action',
  1666. label: '操作',
  1667. align: 'center',
  1668. resizable: false,
  1669. slot: 'action',
  1670. showOverflowTooltip: true
  1671. });
  1672. this.columns1 = this.defaultColumns1.concat({
  1673. action: 'action',
  1674. slot: 'action',
  1675. label: '操作'
  1676. });
  1677. } else {
  1678. this.columns = this.defaultColumns;
  1679. this.columns1 = this.defaultColumns1;
  1680. }
  1681. this.rowData = JSON.parse(JSON.stringify(rowData));
  1682. this.treeData = JSON.parse(JSON.stringify(treeData));
  1683. this.tableData = JSON.parse(JSON.stringify(tableData));
  1684. this.currentIndex = tableData.taskParam.findIndex(
  1685. (item) => item.id === rowData.id
  1686. );
  1687. console.log('currentIndex', this.currentIndex);
  1688. this.activeName = '工艺参数';
  1689. // this.baseCount = rowData.baseCount;
  1690. // this.baseCountUnit = rowData.baseCountUnit;
  1691. console.log(rowData, 'rowData');
  1692. // this.form.baseCount = rowData.baseCount || 1;
  1693. this.form.baseCountUnit = rowData.baseCountUnit;
  1694. this.baseCount2 = rowData.baseCount2;
  1695. this.baseCountUnit2 = rowData.baseCountUnit2;
  1696. this.visible = true;
  1697. setTimeout(() => {
  1698. console.log(this.$refs);
  1699. // 工艺参数
  1700. this.$refs.table.setData(
  1701. this.tableData.taskParam[this.currentIndex]?.produceList || []
  1702. );
  1703. this.$refs.userSettingMatterProcessRef.getMatterList();
  1704. }, 500);
  1705. this.getBomLevel();
  1706. },
  1707. async getBomLevel() {
  1708. await getBomGetById(this.resourceBomId).then((res) => {
  1709. if (res.data.level) {
  1710. this.level = res.data.level;
  1711. }
  1712. });
  1713. },
  1714. handleClose() {
  1715. this.visible = false;
  1716. this.$refs.table.setSelectedRows([]);
  1717. this.selection = [];
  1718. },
  1719. save(type) {
  1720. if (this.activeName == '材料定额') {
  1721. }
  1722. this.$refs.form.validate((valid) => {
  1723. let isYs = true;
  1724. if (this.activeName == '材料定额') {
  1725. isYs = valid;
  1726. }
  1727. if (isYs) {
  1728. if (this.isView) {
  1729. this.handleClose();
  1730. } else {
  1731. // 保存生产节拍
  1732. let userInfo = JSON.parse(localStorage.getItem('info'));
  1733. this.beatParam.createName = userInfo.name;
  1734. this.beatParam.createTime = dayjs(new Date()).format(
  1735. 'YYYY-MM-DD HH:mm:ss'
  1736. );
  1737. this.beatParam.updateName = userInfo.name;
  1738. this.beatParam.updateTime = dayjs(new Date()).format(
  1739. 'YYYY-MM-DD HH:mm:ss'
  1740. );
  1741. this.tableData.taskParam[this.currentIndex].beatParam =
  1742. this.beatParam;
  1743. // 保存材料定额
  1744. this.tableData.taskParam[this.currentIndex].baseCount =
  1745. this.form.baseCount;
  1746. this.tableData.taskParam[this.currentIndex].baseCountUnit =
  1747. this.form.baseCountUnit;
  1748. const isCount = this.tableData.taskParam[
  1749. this.currentIndex
  1750. ].materialQuota.every((item) => {
  1751. if (!item.count) {
  1752. return false;
  1753. }
  1754. return true;
  1755. });
  1756. if (!isCount) {
  1757. this.$message.warning('材料定额数量不能为空');
  1758. return;
  1759. }
  1760. this.tableData.taskParam[this.currentIndex].baseCount2 =
  1761. this.baseCount2;
  1762. this.tableData.taskParam[this.currentIndex].baseCountUnit2 =
  1763. this.baseCountUnit2;
  1764. if (this.$refs.qualityParamRef) {
  1765. this.tableData.taskParam[this.currentIndex].qualityParam =
  1766. this.$refs.qualityParamRef.getDate() || [];
  1767. }
  1768. //工艺文件只传id
  1769. let fileParamArr = JSON.parse(
  1770. JSON.stringify(this.tableData.taskParam)
  1771. );
  1772. fileParamArr.map((item, index) => {
  1773. if (item.fileParam.length > 0) {
  1774. let val = [];
  1775. item.fileParam.map((fileItem) => {
  1776. let obj = {
  1777. id: fileItem.id
  1778. };
  1779. val.push(obj);
  1780. });
  1781. this.$set(this.tableData.taskParam[index], 'fileParam', val);
  1782. }
  1783. });
  1784. console.log('111112223344', this.tableData.taskParam);
  1785. // 保存过程控制事项
  1786. this.$refs.userSettingMatterProcessRef?.saveMatterList();
  1787. workingProcedureUpdate({
  1788. id: this.tableData.id,
  1789. categoryId: this.treeData.categoryId,
  1790. bomCategoryId: this.treeData.id,
  1791. categoryCode: this.treeData.categoryCode,
  1792. taskParam: this.tableData.taskParam
  1793. }).then(() => {
  1794. this.$message.success('保存成功');
  1795. this.$emit('chooseProcess');
  1796. if (type === 'close') {
  1797. this.handleClose();
  1798. }
  1799. });
  1800. }
  1801. }
  1802. });
  1803. },
  1804. //工艺文件表格回显
  1805. fileParamDatasource(fileParam) {
  1806. let fileId = fileParam.map((item) => item.id).join(',');
  1807. newFilePageAPI({
  1808. // pageNum: 1,
  1809. // size: 999,
  1810. // directoryId: null,
  1811. // lcyStatus: 1,
  1812. // fileType: 0,
  1813. // ids: fileId
  1814. ids: "'" + fileId + "'"
  1815. }).then((res) => {
  1816. this.$refs.fileTable.setData(res);
  1817. });
  1818. },
  1819. async getDictList(code) {
  1820. let { data: res } = await getByCode(code);
  1821. this.dictList = res.reduce((acc, curr) => {
  1822. let key = Object.keys(curr)[0]; // 获取当前对象的键
  1823. let value = curr[key]; // 获取当前对象的值
  1824. acc.push({ value, label: value }); // 将 { value, label } 格式的对象添加到数组中
  1825. return acc;
  1826. }, []); // 初始值为空数组 []
  1827. },
  1828. convertToSeconds(time) {
  1829. switch (this.beatParam.unit) {
  1830. case '秒':
  1831. return time;
  1832. case '分钟':
  1833. return time * 60;
  1834. case '小时':
  1835. return time * 3600;
  1836. case '天':
  1837. return time * 86400; // 24小时 * 60分钟 * 60秒
  1838. case '月':
  1839. // 近似值,一个月按30天计算
  1840. return time * 86400 * 30;
  1841. case '年':
  1842. // 近似值,一年按365天计算
  1843. return time * 86400 * 365;
  1844. case '毫秒':
  1845. return time / 1000;
  1846. case '微秒':
  1847. return time / 1000000;
  1848. default:
  1849. this.$message.error('不支持的时间单位: ' + unit);
  1850. }
  1851. },
  1852. convertVal(val, name) {
  1853. if (!this.beatParam.unit) {
  1854. return this.$message.error('请选择时间单位');
  1855. }
  1856. const isNumeric = /^\d*(\.\d+)?$/.test(val);
  1857. if (isNumeric) {
  1858. this.beatParam[name] = this.convertToSeconds(val);
  1859. } else {
  1860. this.$message.error('请输入数字');
  1861. this.beatParam[name] = '';
  1862. }
  1863. },
  1864. changeUnit() {
  1865. this.beatParam.newTime = '';
  1866. this.beatParam.time = '';
  1867. this.beatParam.newBeatPrepareTime = '';
  1868. this.beatParam.beatPrepareTime = '';
  1869. this.beatParam.newBeatTime = '';
  1870. this.beatParam.beatTime = '';
  1871. this.beatParam.newBeatRestTime = '';
  1872. this.beatParam.beatRestTime = '';
  1873. this.beatParam.taskPrice = '';
  1874. },
  1875. handSubstitution(row) {
  1876. this.$refs.replaceMaterialRef.open(row);
  1877. },
  1878. replaceSelected(id, list) {
  1879. let _arr = [];
  1880. _arr = this.tableData.taskParam[this.currentIndex].materialQuota;
  1881. _arr.forEach((item) => {
  1882. if (item.id === id) {
  1883. item.replaceMaterial = list;
  1884. }
  1885. });
  1886. this.tableData.taskParam[this.currentIndex].materialQuota = _arr;
  1887. }
  1888. }
  1889. };
  1890. </script>
  1891. <style lang="scss" scoped>
  1892. .btns {
  1893. text-align: center;
  1894. padding: 10px 0;
  1895. }
  1896. .downLoad {
  1897. display: flex;
  1898. }
  1899. .toolbar_box {
  1900. float: right;
  1901. margin-right: 10px;
  1902. > div {
  1903. display: flex;
  1904. align-items: center;
  1905. justify-content: center;
  1906. > span {
  1907. width: 150px;
  1908. }
  1909. > div {
  1910. margin-left: 10px;
  1911. }
  1912. }
  1913. }
  1914. .item-height {
  1915. margin-bottom: 20px;
  1916. }
  1917. </style>