workingProcedure.vue 48 KB

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