editModal.vue 58 KB

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