workingProcedure.vue 58 KB

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