editModal.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897
  1. <template>
  2. <ele-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. :close-on-click-modal="false"
  6. @close="handleClose"
  7. resizable
  8. maxable
  9. width="80%"
  10. >
  11. <div v-loading="loading">
  12. <div
  13. class="switch"
  14. v-if="details && details.processInstanceId"
  15. :maxable="true"
  16. style="margin-bottom: 20px"
  17. >
  18. <div class="switch_left">
  19. <ul>
  20. <li
  21. v-for="item in tabOptions"
  22. :key="item.key"
  23. :class="{ active: activeComp == item.key }"
  24. @click="activeComp = item.key"
  25. >
  26. {{ item.name }}
  27. </li>
  28. </ul>
  29. </div>
  30. </div>
  31. <el-form
  32. v-if="activeComp == 'main'"
  33. ref="formRef"
  34. :model="form"
  35. :rules="rules"
  36. label-width="130px"
  37. :disabled="type == 'detail'"
  38. >
  39. <header-title title="事项信息"></header-title>
  40. <el-row style="margin-bottom: 20px">
  41. <el-col :span="8">
  42. <el-form-item label="记录编码">
  43. <el-input
  44. v-model="form.code"
  45. placeholder="系统自动生成"
  46. disabled
  47. ></el-input>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="8">
  51. <el-form-item label="类型" required prop="itemType">
  52. <DictSelection
  53. dictName="记录规则事项类型"
  54. v-model="form.itemType"
  55. @change="itemTypeChange"
  56. :disabled="reportWorkType == 4"
  57. >
  58. </DictSelection>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="8">
  62. <el-form-item label="配置执行方式" required prop="executeMethod">
  63. <DictSelection
  64. dictName="记录规则执行方式"
  65. v-model="form.executeMethod"
  66. disabled
  67. >
  68. </DictSelection>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. <el-row>
  73. <el-col :span="8">
  74. <el-form-item
  75. v-if="form.itemType == '1'"
  76. label="选择设备"
  77. required
  78. prop="deviceName"
  79. >
  80. <div class="mask-box" @click="selectDeviceId">
  81. <el-input
  82. v-model="form.deviceName"
  83. placeholder="请选择设备"
  84. size="small"
  85. :readonly="true"
  86. >
  87. <template #append>
  88. <el-button size="small">选择设备</el-button>
  89. </template>
  90. </el-input>
  91. </div>
  92. </el-form-item>
  93. </el-col>
  94. <el-col v-if="form.itemType == '3'" :span="8">
  95. <el-form-item label="关联任务">
  96. <el-input
  97. v-model="form.itemTaskName"
  98. placeholder="请输入任务名称"
  99. ></el-input>
  100. </el-form-item>
  101. </el-col>
  102. <el-col v-if="form.itemType == '2'" :span="8">
  103. <el-form-item label="关联记录规则" required prop="ruleName">
  104. <div class="mask-box" @click="selectReleaseId">
  105. <el-input
  106. v-model="form.ruleName"
  107. placeholder="请选择记录规则名称"
  108. size="small"
  109. readonly
  110. >
  111. <template #append>
  112. <el-button size="small">选择规则</el-button>
  113. </template>
  114. </el-input>
  115. </div>
  116. </el-form-item>
  117. </el-col>
  118. <el-col v-if="form.itemType == '2'" :span="8">
  119. <el-form-item label="记录规则分类">
  120. <DictSelection
  121. dictName="记录规则类型"
  122. v-model="form.recordRulesClassify"
  123. disabled
  124. >
  125. </DictSelection>
  126. </el-form-item>
  127. </el-col>
  128. <el-col v-if="form.itemType == '1'" :span="8">
  129. <el-form-item label="关联事项规则" required prop="ruleName">
  130. <div class="mask-box" @click="selectRulesId">
  131. <el-input
  132. v-model="form.ruleName"
  133. placeholder="请选择设备有关计划规则,如保养规则,巡点检规则等"
  134. size="small"
  135. readonly
  136. >
  137. <template #append>
  138. <el-button size="small">选择规则</el-button>
  139. </template>
  140. </el-input>
  141. </div>
  142. </el-form-item></el-col
  143. >
  144. </el-row>
  145. <header-title
  146. title="基本信息"
  147. v-if="form.itemType == 2 && reportWorkType != 4"
  148. style="margin-top: 20px"
  149. ></header-title>
  150. <template v-if="form.itemType == 2 && reportWorkType != 4">
  151. <el-row style="margin-bottom: 20px">
  152. <el-col :span="8">
  153. <el-form-item
  154. v-if="form.recordRulesClassify == 3"
  155. label="关联设备"
  156. >
  157. <el-input
  158. v-model="form.deviceName"
  159. placeholder="自动带出"
  160. disabled
  161. ></el-input>
  162. </el-form-item>
  163. <el-form-item v-else label="车间区域">
  164. <el-select
  165. v-model="form.workshopAreaId"
  166. placeholder="请选择车间区域"
  167. filterable
  168. clearable
  169. style="width: 100%"
  170. @change="workshopAreaIdChange"
  171. >
  172. <el-option
  173. v-for="item in workshopAreaList"
  174. :key="item.id"
  175. :label="item.name"
  176. :value="item.id"
  177. />
  178. </el-select>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="8">
  182. <el-form-item label="检查开始时间" required prop="checkStartTime">
  183. <el-date-picker
  184. v-model="form.checkStartTime"
  185. type="datetime"
  186. format="yyyy-MM-dd HH:mm:ss"
  187. value-format="yyyy-MM-dd HH:mm:ss"
  188. placeholder="选择日期"
  189. style="width: 100%"
  190. :picker-options="{
  191. disabledDate: (time) => time.getTime() > Date.now()
  192. }"
  193. @change="computedDuration"
  194. >
  195. </el-date-picker>
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="8">
  199. <el-form-item
  200. label="检查结束时间"
  201. required
  202. prop="checkFinishTime"
  203. >
  204. <el-date-picker
  205. v-model="form.checkFinishTime"
  206. type="datetime"
  207. format="yyyy-MM-dd HH:mm:ss"
  208. value-format="yyyy-MM-dd HH:mm:ss"
  209. placeholder="选择日期"
  210. style="width: 100%"
  211. :picker-options="{
  212. disabledDate: (time) => time.getTime() > Date.now()
  213. }"
  214. @change="computedDuration"
  215. >
  216. </el-date-picker>
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. <el-row style="margin-bottom: 20px">
  221. <el-col :span="8">
  222. <el-form-item label="执行人" required prop="teamId">
  223. <div style="display: flex">
  224. <el-select
  225. v-model="form.teamId"
  226. placeholder="请选择班组"
  227. filterable
  228. style="width: 120px"
  229. @change="checkTeamList(form.teamId)"
  230. >
  231. <el-option
  232. v-for="item in teamList"
  233. :label="item.name"
  234. :value="item.id"
  235. :key="item.id"
  236. >
  237. </el-option>
  238. </el-select>
  239. <el-select
  240. v-model="form.executeUsersIds"
  241. placeholder="请选择执行人"
  242. filterable
  243. multiple
  244. @change="changeId"
  245. style="max-width: 100%"
  246. >
  247. <div class="checkboxWrapper">
  248. <el-checkbox v-model="checked" @change="checkChange">
  249. 全选
  250. </el-checkbox>
  251. </div>
  252. <el-option
  253. v-for="item in teamUserList"
  254. :label="item.name"
  255. :value="item.id"
  256. :key="item.id"
  257. >
  258. </el-option>
  259. </el-select>
  260. </div>
  261. </el-form-item>
  262. </el-col>
  263. <el-col :span="8">
  264. <el-form-item label="工时" required prop="duration">
  265. <el-input
  266. placeholder="请输入"
  267. v-model="form.duration"
  268. type="number"
  269. min="0"
  270. step="0.1"
  271. @change="durationChagne"
  272. >
  273. <template slot="append">
  274. <div style="width: 40px; box-sizing: border-box">小时</div>
  275. </template>
  276. </el-input>
  277. </el-form-item>
  278. </el-col>
  279. <el-col :span="8">
  280. <el-form-item label="检查有效期">
  281. <el-input
  282. placeholder="请输入"
  283. v-model="form.checkValidity"
  284. type="text"
  285. >
  286. <template slot="append">
  287. <div style="width: 40px; box-sizing: border-box">
  288. <el-form-item
  289. class="checkValidityUnit"
  290. style="margin-bottom: 0"
  291. >
  292. <DictSelection
  293. dictName="检查有效期单位"
  294. clearable
  295. v-model="form.checkValidityUnit"
  296. placeholder="单位"
  297. style="width: auto"
  298. >
  299. </DictSelection>
  300. </el-form-item>
  301. </div>
  302. </template>
  303. </el-input>
  304. </el-form-item>
  305. </el-col>
  306. </el-row>
  307. <el-row style="margin-bottom: 20px">
  308. <el-col v-if="form.recordRulesExecuteMethodName" :span="8">
  309. <el-form-item label="执行方式">
  310. <el-input
  311. v-model="form.recordRulesExecuteMethodName"
  312. placeholder="自动带出"
  313. disabled
  314. ></el-input>
  315. </el-form-item>
  316. </el-col>
  317. <el-col v-if="reportWorkType == 2" :span="8">
  318. <el-form-item label="产出物">
  319. <el-select
  320. v-model="form.outputType"
  321. placeholder="请选择产出物类型"
  322. filterable
  323. style="width: 100%"
  324. >
  325. <el-option
  326. v-for="item in outputTypeList"
  327. :key="item.value"
  328. :label="item.label"
  329. :value="item.value"
  330. />
  331. </el-select>
  332. </el-form-item>
  333. </el-col>
  334. <el-col :span="8">
  335. <el-form-item label="结论" required prop="conclusion">
  336. <el-radio-group v-model="form.conclusion">
  337. <el-radio :label="1">合格</el-radio>
  338. <el-radio :label="2">不合格</el-radio>
  339. </el-radio-group>
  340. </el-form-item>
  341. </el-col>
  342. </el-row>
  343. </template>
  344. <header-title title="关联产品" style="margin-top: 20px"></header-title>
  345. <el-row style="margin-bottom: 20px">
  346. <el-col :span="8">
  347. <el-form-item label="生产工单号" prop="workOrderCode">
  348. <!-- <el-select
  349. v-model="form.workOrderCode"
  350. placeholder="请选择生产工单"
  351. style="width: 100%"
  352. filterable
  353. remote
  354. clearable
  355. :remote-method="getWorkOrderList"
  356. @change="workOrderCodeChange"
  357. >
  358. <el-option
  359. v-for="item in workOrderList"
  360. :key="item.id"
  361. :label="item.code"
  362. :value="item.code"
  363. >
  364. </el-option>
  365. </el-select> -->
  366. <el-input
  367. v-model="form.workOrderCode"
  368. placeholder="请选择生产工单"
  369. @click.native="openWorkOrderDialog"
  370. readonly
  371. />
  372. </el-form-item>
  373. </el-col>
  374. <el-col :span="8">
  375. <el-form-item
  376. v-if="reportWorkType != 4"
  377. label="工序名称"
  378. prop="produceTaskId"
  379. >
  380. <el-select
  381. v-model="form.produceTaskId"
  382. placeholder="请选择工序"
  383. style="width: 100%"
  384. @change="produceTaskIdChange"
  385. >
  386. <el-option
  387. v-for="item in produceTaskList"
  388. :key="item.taskId"
  389. :label="item.taskTypeName"
  390. :value="item.sourceTaskId"
  391. >
  392. </el-option>
  393. </el-select>
  394. </el-form-item>
  395. </el-col>
  396. <el-col :span="8">
  397. <el-form-item label="牌号">
  398. <el-input v-model="form.brandNo" placeholder="牌号"></el-input>
  399. </el-form-item>
  400. </el-col>
  401. </el-row>
  402. <el-row style="margin-bottom: 20px">
  403. <el-col :span="8">
  404. <el-form-item
  405. label="产品编码"
  406. :required="form.recordRulesClassify != '4' && reportWorkType != 4"
  407. :prop="
  408. form.recordRulesClassify != '4' && reportWorkType != 4
  409. ? 'productCode'
  410. : ''
  411. "
  412. >
  413. <el-input
  414. v-model="form.productCode"
  415. placeholder="请选择产品信息"
  416. @click.native="openProductDialog"
  417. readonly
  418. >
  419. <template #append>
  420. <el-button size="small">选择产品</el-button>
  421. </template>
  422. </el-input>
  423. </el-form-item>
  424. </el-col>
  425. <el-col :span="8">
  426. <el-form-item
  427. label="产品名称"
  428. :required="form.recordRulesClassify != '4' && reportWorkType != 4"
  429. :prop="
  430. form.recordRulesClassify != '4' && reportWorkType != 4
  431. ? 'productName'
  432. : ''
  433. "
  434. >
  435. <el-input
  436. v-model="form.productName"
  437. placeholder="请选择产品信息"
  438. @click.native="openProductDialog"
  439. readonly
  440. >
  441. <template #append>
  442. <el-button size="small">选择产品</el-button>
  443. </template>
  444. </el-input>
  445. </el-form-item>
  446. </el-col>
  447. <el-col :span="8">
  448. <el-form-item label="批次号" prop="batchNo">
  449. <el-input
  450. v-model="form.batchNo"
  451. placeholder="批次号"
  452. :disabled="Boolean(form.workOrderId)"
  453. ></el-input>
  454. </el-form-item>
  455. </el-col>
  456. </el-row>
  457. <el-row style="margin-bottom: 20px">
  458. <el-col :span="8">
  459. <el-form-item label="规格" prop="specification">
  460. <el-input
  461. v-model="form.specification"
  462. placeholder="规格"
  463. :disabled="Boolean(form.workOrderId)"
  464. ></el-input>
  465. </el-form-item>
  466. </el-col>
  467. <el-col :span="8">
  468. <el-form-item label="型号" prop="productModel">
  469. <el-input
  470. v-model="form.productModel"
  471. placeholder="型号"
  472. :disabled="Boolean(form.workOrderId)"
  473. ></el-input>
  474. </el-form-item>
  475. </el-col>
  476. <el-col :span="8">
  477. <el-form-item
  478. label="要求生产数量"
  479. :prop="
  480. form.recordRulesClassify != '4' && reportWorkType != 4
  481. ? 'formingNum'
  482. : ''
  483. "
  484. >
  485. <el-input
  486. v-model.number="form.formingNum"
  487. placeholder="要求生产数量"
  488. :disabled="Boolean(form.workOrderId)"
  489. >
  490. <template slot="append" v-if="workOrderInfo">
  491. {{ workOrderInfo.unit }}
  492. </template>
  493. </el-input>
  494. </el-form-item>
  495. </el-col>
  496. </el-row>
  497. <material
  498. v-if="
  499. form.produceTaskId &&
  500. form.produceTaskInstanceId &&
  501. workOrderInfo &&
  502. reportWorkType == 2 &&
  503. form.itemType == 2
  504. "
  505. ref="materialRef"
  506. :pickDetails.sync="form.pickDetails"
  507. :outputDetails.sync="form.outputDetails"
  508. :preOutputDetails="preOutputDetails"
  509. :sumOutputDetails="sumOutputDetails"
  510. :workOrderId="form.workOrderId"
  511. :ruleId="form.ruleId"
  512. :produceTaskId="form.produceTaskId"
  513. :produceTaskName="form.produceTaskName"
  514. :produceTaskInstanceId="form.produceTaskInstanceId"
  515. :bomCategoryId="workOrderInfo.bomCategoryId"
  516. :outputType="form.outputType"
  517. :categoryId="workOrderInfo.categoryId"
  518. :record-id="form.id"
  519. @refresh="getListByWorkOrderId"
  520. ></material>
  521. <header-title
  522. v-if="form.itemType == 2"
  523. title="检查项目"
  524. style="margin-top: 20px"
  525. ></header-title>
  526. <template v-if="form.itemType == 2 && form.reportWorkType == 4">
  527. <el-tabs v-model="statisticsType" type="card">
  528. <el-tab-pane
  529. v-for="i in statisticsTypeList"
  530. :label="i.label"
  531. :name="i.value"
  532. :key="i.value"
  533. >
  534. </el-tab-pane>
  535. </el-tabs>
  536. <statistics
  537. ref="statisticsRef"
  538. :details.sync="form.details"
  539. :statisticsType="statisticsType"
  540. :workOrderId="workOrderInfo ? workOrderInfo.id : ''"
  541. :routingId="workOrderInfo ? workOrderInfo.produceRoutingId : ''"
  542. :bomCategoryId="workOrderInfo ? workOrderInfo.bomCategoryId : ''"
  543. :ruleId="form.ruleId"
  544. :rulesDetailList="rulesDetailList"
  545. :unit="workOrderInfo ? workOrderInfo.unit : ''"
  546. :formingNum="workOrderInfo ? workOrderInfo.formingNum : 0"
  547. ></statistics>
  548. </template>
  549. <ele-pro-table
  550. v-if="form.itemType == 2 && reportWorkType != 4"
  551. v-loading="loading"
  552. ref="table"
  553. row-key="id"
  554. :columns="detailsColumns"
  555. :datasource="form.details"
  556. cacheKey="mes-releaseRulesDialong-2510311656"
  557. :needPage="false"
  558. >
  559. <template v-slot:toolkit>
  560. <el-button
  561. v-if="form.recordRulesClassify != 4"
  562. type="primary"
  563. @click="batchCheck"
  564. >批量检查</el-button
  565. >
  566. <el-button
  567. v-if="form.recordRulesClassify != 4"
  568. type="primary"
  569. @click="batchQualified"
  570. >批量合格</el-button
  571. >
  572. </template>
  573. <template v-slot:paramValue="{ row }">
  574. <div v-if="form.recordRulesClassify == 4">
  575. {{ row.productName || row.name }}
  576. </div>
  577. <div v-else>
  578. {{ row.paramValue }}
  579. </div>
  580. </template>
  581. <template v-slot:toolNames="{ row }">
  582. <el-link :underline="false" style="cursor: pointer">
  583. <div class="ele-cell">
  584. <div @click="handleAdd(row)">
  585. {{ row.toolNames ? row.toolNames : '请选择' }}
  586. </div>
  587. <i
  588. v-if="!row.toolNames"
  589. class="el-icon-arrow-down"
  590. @click="handleAdd(row)"
  591. ></i>
  592. <i v-else class="el-icon-close" @click="clearTool(row)"></i>
  593. </div>
  594. </el-link>
  595. </template>
  596. <template v-slot:checkUsersIds="{ row }">
  597. <div>
  598. <el-select
  599. v-model="row.checkUsersIds"
  600. placeholder="请选择检查人"
  601. filterable
  602. multiple
  603. @change="checkUsersIdsChange(row)"
  604. >
  605. <el-option
  606. v-for="item in activeTeamUserList"
  607. :label="item.name"
  608. :value="item.id"
  609. :key="item.id"
  610. >
  611. </el-option>
  612. </el-select>
  613. </div>
  614. </template>
  615. <template v-slot:checkStatus="{ row }">
  616. <div>
  617. <el-radio-group v-model="row.checkStatus">
  618. <el-radio :label="1">已检查</el-radio>
  619. <el-radio :label="0">未检查</el-radio>
  620. </el-radio-group>
  621. </div>
  622. </template>
  623. <template v-slot:errorMsg="{ row }">
  624. <div>
  625. <el-input
  626. type="text"
  627. :rows="1"
  628. placeholder="请输入"
  629. v-model="row.errorMsg"
  630. >
  631. <template v-if="row.unitName" slot="append">
  632. <div>{{ row.unitName }}</div>
  633. </template>
  634. </el-input>
  635. </div></template
  636. >
  637. <template v-slot:checkResult="{ row }">
  638. <div>
  639. <el-radio-group v-model="row.checkResult">
  640. <el-radio :label="1">合格</el-radio>
  641. <el-radio :label="0">不合格</el-radio>
  642. </el-radio-group>
  643. </div>
  644. </template>
  645. </ele-pro-table>
  646. </el-form>
  647. <bpmDetail
  648. v-if="activeComp == 'bpm' && details && details.processInstanceId"
  649. :id="details.processInstanceId"
  650. >
  651. </bpmDetail>
  652. </div>
  653. <template v-if="type == 'detail'" v-slot:footer>
  654. <el-button @click="handleClose" :loading="butLoading">关 闭</el-button>
  655. </template>
  656. <template v-else v-slot:footer>
  657. <el-button
  658. type="primary"
  659. @click="save"
  660. :loading="butLoading"
  661. :disabled="form.executeStatus == 2"
  662. >保存</el-button
  663. >
  664. <el-button
  665. type="primary"
  666. @click="submit('submit')"
  667. :loading="butLoading"
  668. :disabled="form.executeStatus == 2"
  669. >报工</el-button
  670. >
  671. <el-button
  672. v-if="
  673. $hasPermission('mes:producetaskrecordrulesrecord:res') &&
  674. form.executeStatus == 2
  675. "
  676. type="primary"
  677. @click="submit('submit-reset')"
  678. :loading="butLoading"
  679. >重新报工</el-button
  680. >
  681. <el-button @click="handleClose" :loading="butLoading">取 消</el-button>
  682. </template>
  683. <selectDevices
  684. ref="deviceSelectDialog"
  685. selectType="single"
  686. @chooseEquipment="chooseEquipment"
  687. ></selectDevices>
  688. <selectMatterRules
  689. ref="selectMatterRulesRef"
  690. @chooseRules="chooseRules"
  691. :filterType="[1, 2, 5]"
  692. ></selectMatterRules>
  693. <selectReleaseRules
  694. ref="selectReleaseRulesRef"
  695. @chooseRules="chooseReleaseRules"
  696. :notProduceTaskConfig="reportWorkType == 2"
  697. ></selectReleaseRules>
  698. <programRulesDialog
  699. ref="programRulesDialogRef"
  700. :dialogTitle="dialogTitle"
  701. @reload="reload"
  702. :isTempRecord="1"
  703. />
  704. <releaseRulesDialog
  705. v-model="showReleaseRulesDialog"
  706. ref="releaseRulesDialogRef"
  707. @reload="reload"
  708. :isTempRecord="1"
  709. />
  710. <taskDialog ref="taskDialogRef" @reload="reload" :isTempRecord="1" />
  711. <EquipmentDialog ref="EquipmentDialogRef" isMultiple="0" @choose="choose" />
  712. <!-- 选择用户 -->
  713. <SelectUser
  714. ref="SelectUserRef"
  715. v-model="showSelectUser"
  716. multipleSelect
  717. @selectUserFinished="selectUserFinished"
  718. ></SelectUser>
  719. <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
  720. <!-- 选择生产工单 -->
  721. <selectWorkOrder
  722. ref="selectWorkOrderRef"
  723. @confirm="selectWorkOrderConfirm"
  724. :multiple="false"
  725. ></selectWorkOrder>
  726. </ele-modal>
  727. </template>
  728. <script>
  729. import dictMixins from '@/mixins/dictMixins';
  730. import selectMatterRules from '@/components/selectMatterRules/select-matter-rules.vue';
  731. import selectReleaseRules from '@/components/selectReleaseRules/select-release-rules.vue';
  732. import selectDevices from '@/components/selectDevices/index.vue';
  733. import { produceOrder } from '@/api/aps/index.js';
  734. import { getTaskInstanceList } from '@/api/produce/job.js';
  735. import {
  736. tempSaveOrUpdate,
  737. saveRuleRecord
  738. } from '@/api/producetaskrulerecord/index.js';
  739. import programRulesDialog from '@/views/produce/components/prenatalExamination/programRulesDialog.vue';
  740. import releaseRulesDialog from '@/views/produce/components/prenatalExamination/releaseRulesDialog.vue';
  741. import taskDialog from '@/views/produce/components/prenatalExamination/taskDialog.vue';
  742. import { getById } from '@/api/produceOrder/index.js';
  743. import EquipmentDialog from './EquipmentDialog.vue';
  744. import { recordRulesDetailPage } from '@/api/recordRules/index.js';
  745. import SelectUser from '@/components/select/SelectUser/index.vue';
  746. import toolModal from './toolModal.vue';
  747. import {
  748. getById as producetaskrulerecordGetById,
  749. queryListByWorkOrderId,
  750. saveOrUpdate,
  751. saveOrUpdateAndSubmit,
  752. resetSubmit
  753. } from '@/api/producetaskrecordrulesrecord/index.js';
  754. import bpmDetail from '@/views/bpm/processInstance/detail.vue';
  755. import bpmTask from '@/components/bpmTask/bpmTask.vue';
  756. import { getFactoryarea } from '@/api/aps/index';
  757. import { getTeam } from '@/api/produce/job.js';
  758. import material from '@/views/produce/components/prenatalExamination/material.vue';
  759. import statistics from './statistics.vue';
  760. import selectWorkOrder from '@/views/checklistManagement/components/selectWorkOrder.vue';
  761. export default {
  762. name: 'editModal',
  763. mixins: [dictMixins],
  764. emits: ['reload'],
  765. components: {
  766. selectMatterRules,
  767. selectReleaseRules,
  768. selectDevices,
  769. programRulesDialog,
  770. releaseRulesDialog,
  771. EquipmentDialog,
  772. taskDialog,
  773. SelectUser,
  774. toolModal,
  775. bpmDetail,
  776. bpmTask,
  777. material,
  778. statistics,
  779. selectWorkOrder
  780. },
  781. props: {
  782. // 1-产前准备,2-过程监测,3-产后检查 4-生产统计
  783. reportWorkType: {
  784. type: Number,
  785. default: 1
  786. }
  787. },
  788. watch: {
  789. 'form.details': {
  790. handler(details) {
  791. if (this.form.itemType == 2) {
  792. const any = details.some((i) => i.checkResult === null);
  793. if (any || details.length === 0) return;
  794. const every = details.every((i) => i.checkResult == 1);
  795. this.form.conclusion = every ? 1 : 2;
  796. }
  797. },
  798. deep: true
  799. }
  800. },
  801. data() {
  802. const formBaseData = {
  803. id: null,
  804. code: '',
  805. // 设备id
  806. deviceId: null,
  807. //设备名称
  808. deviceName: '',
  809. // 记录规则执行方式,参考字典项:produce_task_config_execute_method
  810. executeMethod: '2',
  811. // 执行状态
  812. executeStatus: 0,
  813. // 记录规则事项类型,参考字典项:record_rules_item_type
  814. itemType: '2',
  815. // 工序ID
  816. produceTaskId: null,
  817. produceTaskInstanceId: '',
  818. produceTaskConfigId: '',
  819. produceRoutingId: '',
  820. produceRoutingName: '',
  821. // 工序名称
  822. produceTaskName: '',
  823. // 记录规则报工类型,参考字典项:record_rules_report_work_type
  824. reportWorkType: null,
  825. // 规则id,包括事项规则id,记录规则id,根据事项类型区分
  826. ruleId: null,
  827. // 规则名称
  828. ruleName: '',
  829. // 任务id
  830. taskId: null,
  831. itemTaskName: '',
  832. // mes生产工单表工单号 code
  833. workOrderCode: '',
  834. // workOrderId mes生产工单表id
  835. workOrderId: null,
  836. // 产品编码
  837. productCode: null,
  838. // 产品型号
  839. productModel: null,
  840. // 产品名称
  841. productName: null,
  842. // 记录规则分类,字典项:record_sheet
  843. recordRulesClassify: '',
  844. // 产品批次号
  845. batchNo: '',
  846. // 牌号
  847. brandNo: '',
  848. // 产品规格
  849. specification: '',
  850. // 要求生产数量
  851. formingNum: null,
  852. // 是否临时执行
  853. isTempRecord: 1,
  854. // 记录规则详情
  855. details: [],
  856. // 物品清单
  857. pickDetails: [],
  858. // 本次产出明细
  859. outputDetails: [],
  860. executeUsersIds: [],
  861. workshopAreaId: null,
  862. workshopArea: '',
  863. checkStartTime: null,
  864. checkFinishTime: null,
  865. executeUsersIds: [],
  866. executeUsers: [],
  867. teamId: null,
  868. duration: null,
  869. checkValidity: null,
  870. checkValidityUnit: '',
  871. recordRulesExecuteMethodName: '',
  872. recordRulesExecuteMethodId: null,
  873. conclusion: null,
  874. outputType: 1
  875. };
  876. return {
  877. loading: false,
  878. visible: false,
  879. title: '',
  880. formBaseData,
  881. form: JSON.parse(JSON.stringify(formBaseData)),
  882. // 生产工单列表
  883. workOrderList: [],
  884. //工序名称列表
  885. produceTaskList: [],
  886. // 工单信息
  887. workOrderInfo: null,
  888. butLoading: false,
  889. showReleaseRulesDialog: false,
  890. dialogTitle: '',
  891. showSelectUser: false,
  892. currentRow: null,
  893. type: '',
  894. rules: {
  895. itemType: [
  896. { required: true, message: '请选择规则事项类型', trigger: 'blur' }
  897. ],
  898. deviceName: [
  899. { required: true, message: '请选择设备', trigger: 'blur' }
  900. ],
  901. ruleName: [
  902. { required: true, message: '请选择规则', trigger: 'blur' },
  903. { required: true, message: '请选择规则', trigger: 'change' }
  904. ],
  905. productCode: [
  906. {
  907. required: true,
  908. message: '请输入产品编码',
  909. trigger: 'blur'
  910. },
  911. {
  912. required: true,
  913. message: '请输入产品编码',
  914. trigger: 'change'
  915. }
  916. ],
  917. productName: [
  918. {
  919. required: true,
  920. message: '请输入产品名称',
  921. trigger: 'blur'
  922. },
  923. {
  924. required: true,
  925. message: '请输入产品编码',
  926. trigger: 'change'
  927. }
  928. ],
  929. formingNum: [
  930. {
  931. required: true,
  932. message: '请输入要求生产数量',
  933. trigger: 'blur'
  934. },
  935. {
  936. required: true,
  937. message: '请输入产品编码',
  938. trigger: 'change'
  939. }
  940. ],
  941. // produceTaskId: [
  942. // {
  943. // validator: (rule, value, callback) => {
  944. // if (this.form.workOrderCode) {
  945. // if (!this.form.produceTaskId) {
  946. // callback(new Error('请选择工序'));
  947. // }
  948. // }
  949. // callback();
  950. // },
  951. // trigger: 'blur'
  952. // }
  953. // ],
  954. checkStartTime: [
  955. { required: true, message: '请选择检查开始时间', trigger: 'blur' },
  956. {
  957. required: true,
  958. message: '请选择检查开始时间',
  959. trigger: 'change'
  960. },
  961. {
  962. validator: (rule, value, callback) => {
  963. if (!value) return callback();
  964. const start = new Date(value).getTime();
  965. const now = Date.now();
  966. if (start > now) {
  967. callback(new Error('开始时间不能超过当前时间'));
  968. } else {
  969. callback();
  970. }
  971. },
  972. trigger: 'blur'
  973. }
  974. ],
  975. checkFinishTime: [
  976. { required: true, message: '请选择检查完成时间', trigger: 'blur' },
  977. {
  978. required: true,
  979. message: '请选择检查完成时间',
  980. trigger: 'change'
  981. },
  982. {
  983. validator: (rule, value, callback) => {
  984. if (!value) return callback();
  985. const start = new Date(this.form.checkStartTime).getTime();
  986. const finish = new Date(value).getTime();
  987. const now = Date.now();
  988. if (finish <= start) {
  989. callback(new Error('结束时间必须大于开始时间'));
  990. } else if (finish > now) {
  991. callback(new Error('结束时间不能超过当前时间'));
  992. } else {
  993. callback();
  994. }
  995. },
  996. trigger: 'blur'
  997. }
  998. ],
  999. conclusion: [
  1000. { required: true, message: '请选择结论', trigger: 'blur' },
  1001. { required: true, message: '请选择结论', trigger: 'change' }
  1002. ],
  1003. duration: [
  1004. { required: true, message: '请输入工时', trigger: 'blur' },
  1005. { required: true, message: '请输入工时', trigger: 'change' },
  1006. {
  1007. validator: (rule, value, callback) => {
  1008. if (value === '' || value === null) {
  1009. callback();
  1010. } else if (Number(value) <= 0) {
  1011. callback(new Error('工时必须大于0'));
  1012. } else {
  1013. callback();
  1014. }
  1015. },
  1016. trigger: 'blur'
  1017. }
  1018. ],
  1019. teamId: [
  1020. { required: true, message: '请选择班组', trigger: 'blur' },
  1021. { required: true, message: '请选择班组', trigger: 'change' }
  1022. ]
  1023. },
  1024. details: null,
  1025. tabOptions: [
  1026. { key: 'main', name: '事项信息' },
  1027. { key: 'bpm', name: '流程详情' }
  1028. ],
  1029. activeComp: 'main',
  1030. workshopAreaList: [],
  1031. checked: false,
  1032. teamUserList: [],
  1033. teamList: [],
  1034. teamAllList: [],
  1035. preOutputDetails: [],
  1036. sumOutputDetails: [],
  1037. outputTypeList: [
  1038. { label: '原材料', value: 1 },
  1039. { label: '在制品', value: 2 },
  1040. { label: 'BOM标准产出', value: 3 }
  1041. ],
  1042. // 1-成品统计,2-物料统计,3-工序统计"
  1043. statisticsType: '1',
  1044. statisticsTypeList: [
  1045. { label: '成品统计', value: '1' },
  1046. { label: '物料统计', value: '2' },
  1047. { label: '工序统计', value: '3' }
  1048. ],
  1049. rulesDetailList: []
  1050. };
  1051. },
  1052. computed: {
  1053. reportWorkTypeName() {
  1054. switch (this.reportWorkType) {
  1055. case 1:
  1056. return '产前准备';
  1057. case 2:
  1058. return '过程监测';
  1059. case 3:
  1060. return '产后检查';
  1061. case 4:
  1062. return '生产统计';
  1063. default:
  1064. return '';
  1065. }
  1066. },
  1067. // 规则详情表头
  1068. detailsColumns() {
  1069. let list = [
  1070. {
  1071. width: 45,
  1072. type: 'index',
  1073. columnKey: 'index',
  1074. align: 'center'
  1075. },
  1076. {
  1077. label: '检查内容',
  1078. prop: 'paramValue',
  1079. minWidth: 120,
  1080. slot: 'paramValue'
  1081. }
  1082. ];
  1083. if (this.form.recordRulesClassify != '4') {
  1084. list = [
  1085. ...list,
  1086. {
  1087. label: '检查工具',
  1088. prop: 'toolNames',
  1089. minWidth: 120,
  1090. slot: 'toolNames'
  1091. },
  1092. {
  1093. label: '检查人',
  1094. prop: 'checkUsersIds',
  1095. minWidth: 120,
  1096. slot: 'checkUsersIds'
  1097. },
  1098. {
  1099. label: '检查情况',
  1100. prop: 'checkStatus',
  1101. minWidth: 120,
  1102. slot: 'checkStatus'
  1103. },
  1104. {
  1105. label: '描述',
  1106. prop: 'errorMsg',
  1107. minWidth: 120,
  1108. slot: 'errorMsg'
  1109. },
  1110. {
  1111. label: '检查结果',
  1112. prop: 'checkResult',
  1113. minWidth: 120,
  1114. slot: 'checkResult'
  1115. }
  1116. ];
  1117. } else {
  1118. list.push({
  1119. label: '描述',
  1120. prop: 'errorMsg',
  1121. minWidth: 120,
  1122. slot: 'errorMsg'
  1123. });
  1124. }
  1125. return list;
  1126. },
  1127. activeTeamUserList() {
  1128. return this.teamUserList.filter((user) =>
  1129. this.form.executeUsersIds.includes(user.id)
  1130. );
  1131. }
  1132. },
  1133. created() {
  1134. this.requestDict('记录规则报工类型');
  1135. this.requestDict('记录规则执行方式');
  1136. this.requestDict('记录规则事项类型');
  1137. this.getWorkOrderList();
  1138. if (localStorage.getItem('singleUserInfo') == '1') {
  1139. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  1140. this.getTeamList(data.teamId);
  1141. } else {
  1142. this.getTeamList(this.$store.state.user.info.teamId);
  1143. }
  1144. this.getWorkshopArea();
  1145. },
  1146. methods: {
  1147. // 外部调用,打开弹窗
  1148. open(type, data) {
  1149. console.log('data', type, data);
  1150. this.type = type;
  1151. this.form.reportWorkType = this.reportWorkType;
  1152. if (type == 'add') {
  1153. this.title = `新增${this.reportWorkTypeName}事项`;
  1154. } else if (type == 'edit') {
  1155. this.title = `编辑${this.reportWorkTypeName}事项`;
  1156. this.form.workOrderId = data.workOrderId;
  1157. this.form.id = data.id;
  1158. console.log('this.form', this.form);
  1159. if (this.form.workOrderId) {
  1160. this.getProductTaskList(this.form.workOrderId);
  1161. // 根据工单id 获取详情
  1162. this.getWorkOrderById(this.form.workOrderId);
  1163. this.getDetias();
  1164. }
  1165. if (data.ruleId) {
  1166. this.getRulesDetiasList(data.ruleId);
  1167. }
  1168. } else if (type == 'detail') {
  1169. this.title = `${this.reportWorkTypeName}事项`;
  1170. this.form.workOrderId = data.workOrderId;
  1171. this.form.id = data.id;
  1172. if (this.form.workOrderId) {
  1173. this.getProductTaskList(this.form.workOrderId);
  1174. // 根据工单id 获取详情
  1175. this.getWorkOrderById(this.form.workOrderId);
  1176. this.getDetias();
  1177. }
  1178. if (data.ruleId) {
  1179. this.getRulesDetiasList(data.ruleId);
  1180. }
  1181. } else {
  1182. }
  1183. this.visible = true;
  1184. },
  1185. // 查询详情
  1186. async getDetias() {
  1187. this.loading = true;
  1188. const data = await producetaskrulerecordGetById(this.form.id);
  1189. data.tools = data.tools || [];
  1190. this.details = data;
  1191. console.log('data 详情', data);
  1192. this.$util.assignObject(this.form, data);
  1193. this.form.details = this.form.details.map((i) => {
  1194. i.checkUsersIds = i.checkUsers.map((j) => j.userId);
  1195. return {
  1196. ...i,
  1197. toolNames: i.tools.map((i) => i.toolName).join(',')
  1198. };
  1199. });
  1200. // 工时毫秒转小时
  1201. this.form.duration = (this.form.duration / (1000 * 60 * 60)).toFixed(2);
  1202. this.form.executeUsersIds = this.form.executeUsers.map((i) => i.userId);
  1203. this.form.teamId =
  1204. this.form.executeUsers.length > 0
  1205. ? this.form.executeUsers[0].teamId
  1206. : '';
  1207. // 加载班组人员列表
  1208. if (this.form.teamId) {
  1209. const index = this.teamList.findIndex(
  1210. (item) => item.id == this.form.teamId
  1211. );
  1212. this.teamUserList = this.teamAllList[index];
  1213. }
  1214. console.log('this.form', this.form);
  1215. this.loading = false;
  1216. this.getListByWorkOrderId();
  1217. },
  1218. // 查询规则详情
  1219. async getRulesDetias() {
  1220. if (this.form.ruleId) {
  1221. const { list } = await recordRulesDetailPage({
  1222. pageNum: 1,
  1223. size: 999,
  1224. rulesId: this.form.ruleId
  1225. });
  1226. this.form.details = list.map((i) => {
  1227. return {
  1228. ...i,
  1229. id: null,
  1230. checkResult: null,
  1231. checkStatus: null,
  1232. checkStatusDesc: i.defaultValue || '',
  1233. errorMsg: '',
  1234. checkUsers: [],
  1235. paramValue: i.paramValue,
  1236. toolNames: i.tools.map((i) => i.toolName).join(',')
  1237. };
  1238. });
  1239. this.rulesDetailList = JSON.parse(JSON.stringify(this.form.details));
  1240. console.log('this.form.details', this.form.details);
  1241. }
  1242. },
  1243. // 查询规则详情
  1244. async getRulesDetiasList(ruleId) {
  1245. if (ruleId) {
  1246. const { list } = await recordRulesDetailPage({
  1247. pageNum: 1,
  1248. size: 999,
  1249. rulesId: ruleId
  1250. });
  1251. this.rulesDetailList = list.map((i) => {
  1252. return {
  1253. ...i,
  1254. id: null,
  1255. checkResult: null,
  1256. checkStatus: null,
  1257. checkStatusDesc: i.defaultValue || '',
  1258. errorMsg: '',
  1259. checkUsers: [],
  1260. paramValue: i.paramValue,
  1261. toolNames: i.tools.map((i) => i.toolName).join(',')
  1262. };
  1263. });
  1264. console.log('this.rulesDetailList', this.rulesDetailList);
  1265. }
  1266. },
  1267. // 关闭时清理表单
  1268. handleClose() {
  1269. this.form = JSON.parse(JSON.stringify(this.formBaseData));
  1270. this.produceTaskList = [];
  1271. this.rulesDetailListj = [];
  1272. this.statisticsType = '1';
  1273. this.details = null;
  1274. this.workOrderInfo = null;
  1275. this.$nextTick(() => {
  1276. this.$refs.formRef.clearValidate();
  1277. this.visible = false;
  1278. });
  1279. },
  1280. // 修改规则事项类型
  1281. itemTypeChange() {
  1282. this.form.executeMethod = this.form.itemType;
  1283. this.form.ruleId = null;
  1284. this.form.ruleName = '';
  1285. this.form.details = [];
  1286. this.$nextTick(() => {
  1287. this.$refs.formRef.clearValidate();
  1288. });
  1289. },
  1290. // 去选择设备
  1291. selectDeviceId() {
  1292. if (this.type == 'detail') return;
  1293. this.$refs.deviceSelectDialog.open([]);
  1294. },
  1295. // 设备选
  1296. chooseEquipment(data, index, categoryId) {
  1297. console.log('data', data, index, categoryId);
  1298. this.form.deviceId = data?.id;
  1299. this.form.deviceName = data?.name;
  1300. },
  1301. // 去选择记录规则
  1302. selectReleaseId() {
  1303. if (this.type == 'detail') return;
  1304. this.$refs.selectReleaseRulesRef.open(
  1305. this.reportWorkType,
  1306. this.form.produceTaskId
  1307. );
  1308. },
  1309. // 选择记录规则
  1310. chooseReleaseRules(rules) {
  1311. console.log('rules', rules);
  1312. this.form.ruleId = rules?.id;
  1313. this.form.ruleName = rules?.name;
  1314. this.form.recordRulesClassify = rules?.classify + '';
  1315. this.form.recordRulesExecuteMethodId = rules?.executeMethodId;
  1316. this.form.recordRulesExecuteMethodName = rules?.executeMethodName;
  1317. this.getRulesDetias();
  1318. // 重置表单验证
  1319. this.$nextTick(() => {
  1320. this.$refs.formRef.clearValidate([
  1321. 'productCode',
  1322. 'productName',
  1323. 'formingNum'
  1324. ]);
  1325. });
  1326. },
  1327. // 去选择事项规则
  1328. selectRulesId() {
  1329. this.$refs.selectMatterRulesRef.open([this.form.ruleId]);
  1330. },
  1331. // 选择事项规则
  1332. chooseRules(rules) {
  1333. console.log('rules', rules);
  1334. this.form.ruleId = rules?.id;
  1335. this.form.ruleName = rules?.name;
  1336. },
  1337. // 获取生产工单号
  1338. async getWorkOrderList(code = '') {
  1339. if (typeof code != 'string') {
  1340. code = '';
  1341. }
  1342. const { list } = await produceOrder({
  1343. code,
  1344. pageNum: 1,
  1345. size: 50
  1346. });
  1347. console.log('生产工单', list);
  1348. this.workOrderList = list;
  1349. },
  1350. // 获取工序列表
  1351. async getProductTaskList(id) {
  1352. // 生产统计不关联工序
  1353. if (this.reportWorkType == 4) return;
  1354. const data = await getTaskInstanceList(id);
  1355. console.log('data 工序列表', data);
  1356. this.produceTaskList = data.filter(
  1357. (i) => i.taskId != '-2' && i.taskId != '-1'
  1358. );
  1359. // 赋值工序实例id
  1360. this.form.produceTaskInstanceId = data.find(
  1361. (i) => i.sourceTaskId == this.form.produceTaskId
  1362. )?.taskId;
  1363. },
  1364. // 选择工序
  1365. produceTaskIdChange() {
  1366. const prodceTask = this.produceTaskList.find(
  1367. (i) => i.sourceTaskId == this.form.produceTaskId
  1368. );
  1369. if (prodceTask) {
  1370. this.form.produceTaskName = prodceTask.taskTypeName;
  1371. this.form.produceTaskInstanceId = prodceTask.taskId;
  1372. }
  1373. // 查询物料信息
  1374. this.getListByWorkOrderId();
  1375. },
  1376. // 执行
  1377. submit(type = '') {
  1378. this.$refs.formRef.validate(async (valid) => {
  1379. if (!valid) {
  1380. return '';
  1381. }
  1382. console.log('this.form', this.form);
  1383. if (this.form.executeMethod == 1) {
  1384. // 设备保养计划相关逻辑
  1385. this.dialogTitle = '新增设备保养计划';
  1386. this.$refs.programRulesDialogRef.init(
  1387. this.form,
  1388. this.workOrderInfo ? this.workOrderInfo : this.form,
  1389. {
  1390. name: this.form.produceTaskName
  1391. }
  1392. );
  1393. } else if (this.form.executeMethod == 2) {
  1394. this.releaseRulesSaveOrSubmit(type);
  1395. } else {
  1396. // 任务确认
  1397. this.saveRuleRecord();
  1398. }
  1399. });
  1400. },
  1401. // 保存
  1402. save() {
  1403. console.log('this.form', this.form);
  1404. this.$refs.formRef.validate(async (valid) => {
  1405. if (!valid) {
  1406. return '';
  1407. }
  1408. try {
  1409. if (this.form.itemType == 2) {
  1410. // 记录规则保存
  1411. return this.releaseRulesSaveOrSubmit('save');
  1412. }
  1413. this.butLoading = true;
  1414. // 事项和任务确认保存
  1415. const id = await tempSaveOrUpdate(this.form);
  1416. this.form.id = id;
  1417. this.$message.success('保存成功!');
  1418. this.$emit('reload');
  1419. this.handleClose();
  1420. this.butLoading = false;
  1421. } catch (error) {
  1422. this.butLoading = false;
  1423. }
  1424. });
  1425. },
  1426. // 记录规则保存或者 一键报工
  1427. async releaseRulesSaveOrSubmit(type) {
  1428. if (this.form.executeUsersIds.length == 0 && this.reportWorkType != 4) {
  1429. this.$message.warning('请选择执行人!');
  1430. return;
  1431. }
  1432. if (this.form.duration <= 0 && this.reportWorkType != 4) {
  1433. this.$message.warning('工时必须大于0!');
  1434. return;
  1435. }
  1436. // 报工需要验证 缓存不验证 排除 recordRulesClassify ==4 物料添加 的情况
  1437. if (
  1438. type.includes('submit') &&
  1439. this.form.recordRulesClassify != '4' &&
  1440. this.reportWorkType != 4
  1441. ) {
  1442. // 验证检查项目
  1443. const detailRequired = this.form.details.some((i) => {
  1444. return (
  1445. i.checkResult == null ||
  1446. !i.checkStatus ||
  1447. i.checkUsers?.length == 0
  1448. );
  1449. });
  1450. if (detailRequired) {
  1451. return this.$message.warning(
  1452. '请先完善 检查人、检查情况、检查结果 内容!'
  1453. );
  1454. }
  1455. }
  1456. if (this.$refs.materialRef) {
  1457. // 验证产出物数量;
  1458. const valid = this.$refs.materialRef.validateOutputQuantities();
  1459. if (!valid) {
  1460. return;
  1461. }
  1462. }
  1463. if (
  1464. this.$refs.statisticsRef &&
  1465. type != 'cache' &&
  1466. type != 'submit-reset'
  1467. ) {
  1468. // 验证统计项目
  1469. const valid = this.$refs.statisticsRef.validateStatisticsFilled();
  1470. if (!valid) {
  1471. return;
  1472. }
  1473. }
  1474. const body = JSON.parse(JSON.stringify(this.form));
  1475. if (body.duration) {
  1476. // 工时小时转毫秒
  1477. body.duration = Number(body.duration);
  1478. body.duration = body.duration * 60 * 60 * 1000;
  1479. }
  1480. this.butLoading = true;
  1481. console.log('body', body);
  1482. try {
  1483. if (type == 'submit') {
  1484. await saveOrUpdateAndSubmit(body);
  1485. this.$message.success('报工成功!');
  1486. } else if (type == 'submit-reset') {
  1487. await resetSubmit(body);
  1488. this.$message.success('重新报工成功!');
  1489. } else {
  1490. const id = await saveOrUpdate(body);
  1491. this.form.id = id;
  1492. this.$message.success('保存成功!');
  1493. }
  1494. this.butLoading = false;
  1495. // 返回
  1496. this.handleClose();
  1497. this.$emit('reload');
  1498. } catch (error) {
  1499. this.butLoading = false;
  1500. }
  1501. },
  1502. // 任务确认报工
  1503. async saveRuleRecord() {
  1504. this.butLoading = true;
  1505. await saveRuleRecord(this.form);
  1506. this.$message.success('报工成功!');
  1507. this.butLoading = false;
  1508. // 返回
  1509. this.handleClose();
  1510. this.$emit('reload');
  1511. },
  1512. // 执行完成
  1513. reload() {
  1514. this.$emit('reload');
  1515. this.handleClose();
  1516. },
  1517. // 获取工单详情
  1518. async getWorkOrderById(id) {
  1519. const data = await getById(id);
  1520. console.log('工单详情', data);
  1521. this.workOrderInfo = data;
  1522. },
  1523. openProductDialog() {
  1524. if (this.form.workOrderId) {
  1525. return this.$message.warning('已选择生产工单,不能修改产品信息');
  1526. }
  1527. this.$refs.EquipmentDialogRef.open();
  1528. },
  1529. // 选择产品
  1530. choose(data) {
  1531. console.log('data', data);
  1532. const info = data[0];
  1533. if (info) {
  1534. this.form.productCode = info.code;
  1535. this.form.productName = info.name;
  1536. this.form.productModel = info.model;
  1537. this.form.specification = info.specification;
  1538. }
  1539. },
  1540. showCheckUserNames(userList) {
  1541. if (userList.length == 0) return '请选择部门-选择员工';
  1542. return userList
  1543. .map((i) => {
  1544. return (i.groupName || i.teamName) + '-' + i.userName;
  1545. })
  1546. .join(',');
  1547. },
  1548. openSelectUser(row) {
  1549. this.currentRow = row;
  1550. console.log('row', row);
  1551. this.showSelectUser = true;
  1552. },
  1553. selectUserFinished(userInfo) {
  1554. console.log('userInfo', userInfo);
  1555. this.currentRow.checkUsers = userInfo.map((i) => {
  1556. // 构建参数和接口的对应上
  1557. return { ...i, userName: i.name, userId: i.id };
  1558. });
  1559. },
  1560. // 选择工具
  1561. handleAdd(row) {
  1562. this.currentRow = row;
  1563. this.$refs.toolModalRef.open(row.tools.map((i) => i.toolCode));
  1564. },
  1565. chooseModal(data) {
  1566. console.log('data', data);
  1567. this.currentRow.tools = data.map((i) => {
  1568. return {
  1569. toolCode: i.code,
  1570. toolName: i.name
  1571. };
  1572. });
  1573. this.currentRow.toolNames = this.currentRow.tools
  1574. .map((i) => i.toolName)
  1575. .join(',');
  1576. },
  1577. clearTool(row) {
  1578. row.tools = [];
  1579. row.toolNames = '';
  1580. },
  1581. async getListByWorkOrderId(type = '') {
  1582. if (
  1583. !this.form.produceTaskId ||
  1584. this.reportWorkType != 2 ||
  1585. this.form.itemType != 2
  1586. )
  1587. return;
  1588. // 查询物料信息
  1589. const materialObject = await queryListByWorkOrderId({
  1590. workOrderId: this.form.workOrderId,
  1591. recordId: this.form.id,
  1592. produceTaskId: this.form.produceTaskId,
  1593. ruleId: this.form.ruleId
  1594. });
  1595. console.log('materialObject 物料信息', materialObject);
  1596. this.form.outputDetails = materialObject.outputDetails.map((i) => {
  1597. i.reportQuantityCopy = i.reportQuantity;
  1598. const sumItem = materialObject.sumOutputDetails.find(
  1599. (i) => i.categoryId === i.categoryId
  1600. );
  1601. if (sumItem) {
  1602. i.reportQuantity = sumItem.reportQuantity;
  1603. } else {
  1604. i.reportQuantity = i.reportQuantity || 0;
  1605. }
  1606. return i;
  1607. });
  1608. const pickDetails = materialObject.pickDetails.map((i) => {
  1609. // 物料清单中如果存在则 selected 设置为 true
  1610. const any = this.form.outputDetails.find(
  1611. (j) => j.categoryId === i.categoryId
  1612. );
  1613. if (any) {
  1614. i.selected = true;
  1615. } else {
  1616. i.selected = false;
  1617. }
  1618. return i;
  1619. });
  1620. const preOutputDetails = materialObject.preOutputDetails.map((i) => {
  1621. i.quantity = i.qualifiedQuantity;
  1622. return i;
  1623. });
  1624. this.preOutputDetails = preOutputDetails.filter(
  1625. (i) => i.outputType != 1
  1626. );
  1627. this.sumOutputDetails = materialObject.sumOutputDetails;
  1628. this.form.pickDetails = [
  1629. ...preOutputDetails.filter((i) => i.outputType == 1),
  1630. ...pickDetails
  1631. ];
  1632. // this.preOutputDetails 是否存在outputType=2的数据
  1633. const hasInProcess = this.preOutputDetails.some(
  1634. (i) => i.outputType == 2
  1635. );
  1636. if (hasInProcess) {
  1637. // 产出物为在制品
  1638. this.form.outputType = 2;
  1639. // 不可选择
  1640. }
  1641. },
  1642. // qualifiedQuantityMax 最大合格数量
  1643. qualifiedQuantityMax(row) {
  1644. return row.reportQuantity - row.noQualifiedQuantity;
  1645. },
  1646. noQualifiedQuantityMax(row) {
  1647. return row.reportQuantity - row.qualifiedQuantity;
  1648. },
  1649. // 批量检查
  1650. batchCheck() {
  1651. this.form.details = this.form.details.map((i) => {
  1652. i.checkStatus = 1;
  1653. return i;
  1654. });
  1655. },
  1656. // 批量合格
  1657. batchQualified() {
  1658. this.form.details = this.form.details.map((i) => {
  1659. i.checkResult = 1;
  1660. return i;
  1661. });
  1662. },
  1663. workshopAreaIdChange(e) {
  1664. const area = this.workshopAreaList.find((i) => i.id === e);
  1665. if (area) {
  1666. this.form.workshopArea = area.name;
  1667. } else {
  1668. this.form.workshopArea = '';
  1669. }
  1670. },
  1671. // 查询车间区域
  1672. async getWorkshopArea() {
  1673. const data = await getFactoryarea({
  1674. pageNum: 1,
  1675. size: 999,
  1676. type: 3
  1677. });
  1678. console.log('list', data.list);
  1679. this.workshopAreaList = data.list;
  1680. },
  1681. // 计算工时
  1682. computedDuration() {
  1683. if (
  1684. this.form.checkStartTime &&
  1685. this.form.checkFinishTime &&
  1686. this.form.executeUsersIds.length > 0
  1687. ) {
  1688. const start = new Date(this.form.checkStartTime);
  1689. const finish = new Date(this.form.checkFinishTime);
  1690. const diff = finish - start; // 毫秒差值
  1691. const hours = diff / (1000 * 60 * 60); // 转换为小时
  1692. const totalDuration = hours * this.form.executeUsersIds.length;
  1693. this.form.duration = totalDuration.toFixed(1);
  1694. }
  1695. },
  1696. checkTeamList(id) {
  1697. this.form.executeUsersIds = [];
  1698. const index = this.teamList.findIndex((item) => item.id == id);
  1699. this.teamUserList = this.teamAllList[index];
  1700. console.log('this.teamUserList', this.teamUserList);
  1701. },
  1702. async getTeamList(id) {
  1703. const ids = id.split(',');
  1704. this.teamList = [];
  1705. this.teamUserList = [];
  1706. const list = ids.map((item) => getTeam(item));
  1707. const dataList = await Promise.all(list);
  1708. dataList.forEach((item) => {
  1709. this.teamList.push({
  1710. name: item.name,
  1711. id: item.id
  1712. });
  1713. this.teamAllList.push(item.userVOList);
  1714. });
  1715. },
  1716. changeId() {
  1717. if (this.form.executeUsersIds.length == this.teamUserList.length) {
  1718. this.checked = true;
  1719. } else {
  1720. this.checked = false;
  1721. }
  1722. // 同步 executeUsers
  1723. this.form.executeUsers = this.form.executeUsersIds
  1724. .map((id) => {
  1725. const user = this.teamUserList.find((item) => item.id === id);
  1726. console.log('user', user);
  1727. if (user) {
  1728. return {
  1729. teamId: this.form.teamId,
  1730. teamName: this.teamList.find(
  1731. (team) => team.id == this.form.teamId
  1732. )?.name,
  1733. userId: user.id,
  1734. userName: user.name
  1735. };
  1736. } else {
  1737. return null;
  1738. }
  1739. })
  1740. .filter((item) => item !== null);
  1741. console.log('this.form.executeUsers', this.form.executeUsers);
  1742. this.computedDuration();
  1743. // 同步详情执行人
  1744. this.form.details.forEach((detail) => {
  1745. detail.checkUsersIds = this.form.executeUsersIds;
  1746. detail.checkUsers = this.form.executeUsers;
  1747. });
  1748. },
  1749. checkChange() {
  1750. this.form.executeUsersIds = [];
  1751. if (this.checked) {
  1752. this.form.executeUsersIds = this.teamUserList.map((item) => item.id);
  1753. } else {
  1754. this.form.executeUsersIds = [];
  1755. }
  1756. },
  1757. durationChagne() {
  1758. // 保留小数后一位
  1759. if (this.form.duration && this.form.duration.toString().includes('.')) {
  1760. this.form.duration = Number(this.form.duration).toFixed(1);
  1761. }
  1762. },
  1763. checkUsersIdsChange(row) {
  1764. // 同步 checkUsers
  1765. row.checkUsers = row.checkUsersIds.map((i) => {
  1766. const user = this.activeTeamUserList.find((item) => item.id === i);
  1767. return {
  1768. teamId: this.form.teamId,
  1769. teamName: this.teamList.find((team) => team.id == this.form.teamId)
  1770. ?.name,
  1771. userId: user.id,
  1772. userName: user.name
  1773. };
  1774. });
  1775. console.log('row', row);
  1776. },
  1777. // 打开选择工单弹窗
  1778. openWorkOrderDialog() {
  1779. this.$refs.selectWorkOrderRef.open();
  1780. },
  1781. selectWorkOrderConfirm(workOrder) {
  1782. console.log('workOrder', workOrder);
  1783. this.workOrderInfo = workOrder;
  1784. this.form.workOrderId = workOrder.id;
  1785. this.form.workOrderCode = workOrder.code;
  1786. // 赋值产品信息
  1787. this.form.productCode = workOrder.productCode;
  1788. this.form.productModel = workOrder.productModel;
  1789. this.form.productName = workOrder.productName;
  1790. this.form.batchNo = workOrder.batchNo;
  1791. this.form.specification = workOrder.specification;
  1792. this.form.formingNum = workOrder.formingNum;
  1793. this.form.brandNo = workOrder.brandNo;
  1794. this.form.produceRoutingId = workOrder.produceRoutingId;
  1795. this.getProductTaskList(workOrder.id);
  1796. this.form.produceTaskId = null;
  1797. this.form.produceTaskName = '';
  1798. this.form.produceTaskInstanceId = '';
  1799. this.$nextTick(() => {
  1800. // 工单变化构建物料和工序数据
  1801. if (this.$refs.statisticsRef) {
  1802. this.$refs.statisticsRef.rebuildMaterialAndProcessData();
  1803. }
  1804. });
  1805. }
  1806. }
  1807. };
  1808. </script>
  1809. <style scoped lang="scss">
  1810. .mask-box {
  1811. position: relative;
  1812. &::after {
  1813. content: '';
  1814. width: 100%;
  1815. height: 100%;
  1816. position: absolute;
  1817. top: 0;
  1818. left: 0;
  1819. background: rgba(0, 0, 0, 0);
  1820. cursor: pointer;
  1821. }
  1822. }
  1823. .checkboxWrapper {
  1824. padding: 8px 20px;
  1825. border-bottom: 1px solid #ccc;
  1826. }
  1827. </style>