workingProcedure.vue 56 KB

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