workOrderReport.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  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. append-to-body
  10. width="80%"
  11. >
  12. <header-title title="基本信息"></header-title>
  13. <el-form
  14. ref="formRef"
  15. :model="addForm"
  16. :rules="rules"
  17. label-width="150px"
  18. v-loading="loading"
  19. :disabled="type == 'detail'"
  20. >
  21. <el-row>
  22. <el-col :span="8">
  23. <el-form-item label="记录规则名称" required>
  24. <el-input
  25. v-model="addForm.ruleName"
  26. placeholder="自动带出"
  27. disabled
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="记录规则分类" required>
  33. <DictSelection
  34. dictName="记录规则类型"
  35. clearable
  36. v-model="addForm.recordRulesClassify"
  37. disabled
  38. >
  39. </DictSelection>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="8">
  43. <el-form-item label="检查时间" required prop="checkStartTime">
  44. <el-date-picker
  45. v-model="addForm.checkStartTime"
  46. type="datetime"
  47. format="yyyy-MM-dd HH:mm:ss"
  48. value-format="yyyy-MM-dd HH:mm:ss"
  49. placeholder="选择日期"
  50. style="width: 100%"
  51. :picker-options="{
  52. disabledDate: (time) => time.getTime() > Date.now()
  53. }"
  54. >
  55. </el-date-picker>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="报工时间" required prop="checkFinishTime">
  60. <el-date-picker
  61. v-model="addForm.checkFinishTime"
  62. type="datetime"
  63. format="yyyy-MM-dd HH:mm:ss"
  64. value-format="yyyy-MM-dd HH:mm:ss"
  65. placeholder="选择日期"
  66. style="width: 100%"
  67. :picker-options="{
  68. disabledDate: (time) => time.getTime() > Date.now()
  69. }"
  70. >
  71. </el-date-picker>
  72. </el-form-item>
  73. </el-col>
  74. <el-col v-if="!addForm.type" :span="8">
  75. <el-form-item label="部门">
  76. <deptSelect
  77. v-model="addForm.groupId"
  78. @changeGroup="searchDeptNodeClick"
  79. />
  80. </el-form-item>
  81. </el-col>
  82. <el-col v-if="!addForm.type" :span="8">
  83. <el-form-item label="指定负责人" prop="executeUsersIds">
  84. <el-select
  85. v-model="addForm.executeUsersIds"
  86. size="small"
  87. style="width: 100%"
  88. multiple
  89. filterable
  90. @change="executeIdListChange"
  91. key="executeUsersIds"
  92. >
  93. <el-option
  94. v-for="item in executorList"
  95. :key="item.id"
  96. :value="item.id"
  97. :label="item.name"
  98. ></el-option>
  99. </el-select>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="8" v-if="addForm.type">
  103. <el-form-item label="班组" required prop="teamId">
  104. <el-input
  105. v-model="addForm.teamName"
  106. placeholder=" "
  107. disabled
  108. ></el-input>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="8" v-if="addForm.type">
  112. <el-form-item label="执行人" required prop="executeUsersIds">
  113. <el-select
  114. v-model="addForm.executeUsersIds"
  115. placeholder="请选择执行人"
  116. filterable
  117. multiple
  118. @change="changeId"
  119. style="width: 100%"
  120. >
  121. <div class="checkboxWrapper">
  122. <el-checkbox v-model="checked" @change="checkChange">
  123. 全选
  124. </el-checkbox>
  125. </div>
  126. <el-option
  127. v-for="item in teamUserList"
  128. :label="item.name"
  129. :value="item.id"
  130. :key="item.id"
  131. >
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="8" v-if="addForm.type">
  137. <el-form-item label="场站" prop="productLineId">
  138. <el-select
  139. v-model="addForm.productLineId"
  140. placeholder="请选择场站"
  141. filterable
  142. >
  143. <el-option
  144. v-for="item in productLineList"
  145. :label="item.name"
  146. :value="item.id"
  147. :key="item.id"
  148. @click.native="addForm.productLineName = item.name"
  149. >
  150. </el-option>
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col
  155. :span="8"
  156. v-if="
  157. pageName == 'productionRecords' || pageName == 'qualityTestRecords'
  158. "
  159. >
  160. <el-form-item label="客户" required prop="contactName">
  161. <el-input
  162. clearable
  163. v-model="addForm.contactName"
  164. @click.native="handParent"
  165. placeholder="请选择"
  166. readonly
  167. />
  168. </el-form-item>
  169. </el-col>
  170. <el-col
  171. :span="8"
  172. v-if="
  173. ['QualityInspection', 'TransportAsh', 'HaulSlag'].includes(pageName)
  174. "
  175. >
  176. <el-form-item label="供应商" required prop="supplierName">
  177. <el-input
  178. clearable
  179. v-model="addForm.supplierName"
  180. @click.native="handParent"
  181. placeholder="请选择"
  182. readonly
  183. />
  184. </el-form-item>
  185. </el-col>
  186. <el-col
  187. :span="8"
  188. v-if="
  189. ['QualityInspection', 'TransportAsh', 'HaulSlag'].includes(pageName)
  190. "
  191. >
  192. <el-form-item label="采购订单" required prop="purchaseOrderNo">
  193. <el-input
  194. clearable
  195. v-model="addForm.purchaseOrderNo"
  196. @click.native="openOrd"
  197. placeholder="请选择"
  198. readonly
  199. />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="8" v-if="pageName == 'QualityInspection'">
  203. <el-form-item
  204. label="检查卸车是否到位"
  205. required
  206. prop="unloadCheckStatus"
  207. >
  208. <el-radio-group v-model="addForm.unloadCheckStatus">
  209. <el-radio :label="1">已到位</el-radio>
  210. <el-radio :label="2">未到位</el-radio>
  211. </el-radio-group>
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="9" v-if="pageName == 'QualityInspection'">
  215. <el-form-item label="车辆照片" prop="vehiclePhotoUrl">
  216. <WithView
  217. :assetName="''"
  218. v-model="addForm.vehiclePhotoUrl"
  219. style="max-height: 370px"
  220. ></WithView>
  221. </el-form-item>
  222. </el-col>
  223. </el-row>
  224. <header-title title="记录数据" :style="`margin-top: 20px`"></header-title>
  225. <ele-pro-table
  226. v-loading="loading"
  227. ref="table"
  228. row-key="id"
  229. :columns="detailsColumns"
  230. :datasource="addForm.detailList"
  231. :needPage="false"
  232. :page-size="defPageSize"
  233. >
  234. <template v-slot:toolkit>
  235. <el-button
  236. v-if="
  237. ![
  238. 'qualityTestRecords',
  239. 'productionRecords',
  240. 'QualityInspection',
  241. 'HaulSlag',
  242. 'TransportAsh'
  243. ].includes(pageName)
  244. "
  245. type="primary"
  246. @click="batchCheck"
  247. >批量检查</el-button
  248. >
  249. <el-button
  250. v-if="
  251. ![
  252. 'qualityTestRecords',
  253. 'productionRecords',
  254. 'QualityInspection',
  255. 'HaulSlag',
  256. 'TransportAsh'
  257. ].includes(pageName)
  258. "
  259. type="primary"
  260. @click="batchQualified"
  261. >批量合格</el-button
  262. >
  263. </template>
  264. <template v-slot:paramValue="{ row }">
  265. <!-- <div v-if="addForm.recordTemplateStyle == '3'">
  266. {{ row.productName }}
  267. </div>
  268. <div v-else>
  269. {{ row.paramValue }}
  270. <span v-if="row.paramValue">{{ row.paramValue }}</span>
  271. <span v-else>
  272. {{ row.productName }}
  273. </span>
  274. </div> -->
  275. <div> {{ row.paramValue }}</div>
  276. </template>
  277. <template v-slot:checkUsersIds="{ row }">
  278. <div>
  279. <el-select
  280. v-model="row.checkUsersIds"
  281. placeholder="请选择检查人"
  282. filterable
  283. multiple
  284. @change="checkUsersIdsChange(row)"
  285. >
  286. <el-option
  287. v-for="item in addForm.executeUsers"
  288. :label="item.userName"
  289. :value="item.userId"
  290. :key="item.userId"
  291. >
  292. </el-option>
  293. </el-select>
  294. </div>
  295. </template>
  296. <template v-slot:checkStatus="{ row }">
  297. <div>
  298. <el-radio-group v-model="row.checkStatus">
  299. <el-radio :label="1">已检查</el-radio>
  300. <el-radio :label="0">未检查</el-radio>
  301. </el-radio-group>
  302. </div>
  303. </template>
  304. <!-- <template v-slot:errorMsg="{ row }">
  305. <div>
  306. <el-input
  307. type="text"
  308. :rows="1"
  309. placeholder="请输入"
  310. v-model="row.errorMsg"
  311. >
  312. <template v-if="row.unitName" slot="append">
  313. <div>{{ row.unitName }}</div>
  314. </template>
  315. </el-input>
  316. </div></template
  317. > -->
  318. <template v-slot:num="{ row }">
  319. <div>
  320. <el-input
  321. type="text"
  322. placeholder="请输入"
  323. v-model="row.num"
  324. @input="setValue"
  325. >
  326. <template v-if="row.unitName" slot="append">
  327. <div>{{ row.unitName }}</div>
  328. </template>
  329. </el-input>
  330. </div>
  331. </template>
  332. <template v-slot:checkResult="{ row }">
  333. <div>
  334. <el-radio-group v-model="row.checkResult">
  335. <el-radio :label="1">合格</el-radio>
  336. <el-radio :label="0">不合格</el-radio>
  337. </el-radio-group>
  338. </div>
  339. </template>
  340. </ele-pro-table>
  341. </el-form>
  342. <parentList
  343. :classType="
  344. pageName == 'productionRecords' || pageName == 'qualityTestRecords'
  345. ? '1'
  346. : '2'
  347. "
  348. :type="
  349. pageName == 'productionRecords' || pageName == 'qualityTestRecords'
  350. ? '17'
  351. : '19'
  352. "
  353. :code="getCode()"
  354. ref="parentListRef"
  355. @changeParent="changeParent"
  356. >
  357. </parentList>
  358. <template v-slot:footer>
  359. <el-button
  360. v-if="type == 'add'"
  361. type="primary"
  362. @click="submit"
  363. :loading="butLoading"
  364. >提 交</el-button
  365. >
  366. <el-button @click="handleClose">取 消</el-button>
  367. </template>
  368. <orderListDialog
  369. ref="orderListDialogRef"
  370. @changeParent="orderListDialogSuccess"
  371. ></orderListDialog>
  372. </ele-modal>
  373. </template>
  374. <script>
  375. import dictMixins from '@/mixins/dictMixins';
  376. import parentList from '@/components/contact/parentList.vue';
  377. import {
  378. producetaskrulerecordSaveOrUpdateAndSubmit,
  379. getById
  380. } from '@/api/recordRules/index.js';
  381. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  382. import orderListDialog from '@/components/orderListDialog/orderListDialog.vue';
  383. import { getUserPage } from '@/api/system/organization';
  384. import { getteampage, getTeam } from '@/api/main/index.js';
  385. import WithView from '@/components/upload/WithViewNew.vue';
  386. import dayjs from 'dayjs';
  387. import { getTableList } from '@/api/purchasingManage/purchaseOrder';
  388. export default {
  389. mixins: [dictMixins],
  390. components: {
  391. deptSelect,
  392. parentList,
  393. orderListDialog,
  394. WithView
  395. },
  396. props: {
  397. pageName: {
  398. type: String,
  399. default: 'productionRecords'
  400. }
  401. },
  402. watch: {
  403. 'addForm.detailList': {
  404. handler(details) {
  405. // 排除 物料添加 和 生产统计 模板
  406. if (this.pageName == 'productionRecords') return;
  407. const any = details.some((i) => i.checkResult === null);
  408. if (any || details.length === 0) return;
  409. const every = details.every((i) => i.checkResult == 1);
  410. this.addForm.conclusion = every ? 1 : 2;
  411. console.log('this.addForm.conclusion', this.addForm.conclusion);
  412. },
  413. deep: true
  414. }
  415. },
  416. data() {
  417. const formBaseData = {
  418. id: null,
  419. workshopArea: '',
  420. workshopAreaId: null,
  421. checkFinishTime: '',
  422. checkStartTime: '',
  423. checkValidity: null,
  424. checkValidityUnit: '',
  425. conclusion: null,
  426. isTempRecord: this.isTempRecord,
  427. unloadCheckStatus: 1,
  428. vehiclePhotoUrl: '',
  429. detailList: [],
  430. deviceId: 0,
  431. deviceName: '',
  432. batchNo: '',
  433. executeMethod: 0,
  434. formingNum: 0,
  435. itemType: 0,
  436. produceRoutingId: 0,
  437. produceRoutingName: '',
  438. produceTaskConfigId: 0,
  439. produceTaskId: 0,
  440. produceTaskName: '',
  441. productCode: '',
  442. productModel: '',
  443. productName: '',
  444. recordRulesClassify: null,
  445. recordTemplateStyle: null,
  446. ruleId: 0,
  447. ruleName: '',
  448. reportWorkType: 0,
  449. specification: '',
  450. workOrderCode: '',
  451. workOrderId: 0,
  452. itemTaskName: '',
  453. brandNo: '',
  454. duration: null,
  455. // 执行人
  456. executeUsersIds: [],
  457. executeUsers: [],
  458. // 班组id
  459. teamId: '',
  460. groupId: null,
  461. // 物料字段name
  462. pickDetails: [],
  463. // 本次产出明细
  464. outputDetails: [],
  465. recordRulesExecuteMethodId: null,
  466. recordRulesExecuteMethodName: '',
  467. // 产出类型 1-原材料,2-在制品,3.BOM标准产出
  468. outputType: 1,
  469. type: 0,
  470. contactName: '',
  471. contactId: '',
  472. supplierId: '',
  473. supplierName: '',
  474. productLineId: null,
  475. productLineName: '',
  476. purchaseOrderId: '',
  477. purchaseOrderNo: ''
  478. };
  479. return {
  480. visible: false,
  481. activeIndex: 0,
  482. type: 'add',
  483. title: '报工',
  484. formBaseData,
  485. addForm: JSON.parse(JSON.stringify(formBaseData)),
  486. rules: {
  487. checkStartTime: [
  488. { required: true, message: '请选择检查时间', trigger: 'blur' },
  489. {
  490. required: true,
  491. message: '请选择检查时间',
  492. trigger: 'change'
  493. },
  494. {
  495. validator: (rule, value, callback) => {
  496. if (!value) return callback();
  497. const start = new Date(value).getTime();
  498. const now = Date.now();
  499. if (start > now) {
  500. callback(new Error('检查时间不能超过当前时间'));
  501. } else {
  502. callback();
  503. }
  504. },
  505. trigger: 'blur'
  506. }
  507. ],
  508. checkFinishTime: [
  509. { required: true, message: '请选择报工时间', trigger: 'blur' },
  510. {
  511. required: true,
  512. message: '请选择报工时间',
  513. trigger: 'change'
  514. },
  515. {
  516. validator: (rule, value, callback) => {
  517. if (!value) return callback();
  518. const start = new Date(this.addForm.checkStartTime).getTime();
  519. const finish = new Date(value).getTime();
  520. const now = Date.now();
  521. if (finish < start) {
  522. callback(new Error('报工时间必须大于检查开始时间'));
  523. } else if (finish > now) {
  524. callback(new Error('报工时间不能超过当前时间'));
  525. } else {
  526. callback();
  527. }
  528. },
  529. trigger: 'blur'
  530. }
  531. ],
  532. vehiclePhotoUrl: [
  533. { required: true, message: '请选择', trigger: 'blur' }
  534. ],
  535. contactName: [
  536. { required: true, message: '请选择', trigger: 'blur' },
  537. { required: true, message: '请选择', trigger: 'change' }
  538. ],
  539. supplierName: [
  540. { required: true, message: '请选择', trigger: 'blur' },
  541. { required: true, message: '请选择', trigger: 'change' }
  542. ],
  543. teamId: [
  544. { required: true, message: '请选择班组', trigger: 'blur' },
  545. { required: true, message: '请选择班组', trigger: 'change' }
  546. ],
  547. executeUsersIds: [
  548. { required: true, message: '请选择', trigger: 'blur' },
  549. { required: true, message: '请选择', trigger: 'change' }
  550. ],
  551. purchaseOrderNo: [
  552. { required: true, message: '请选择', trigger: 'blur' },
  553. { required: true, message: '请选择', trigger: 'change' }
  554. ]
  555. },
  556. loading: false,
  557. butLoading: false,
  558. checked: false,
  559. teamUserList: [],
  560. teamList: [],
  561. teamAllList: [],
  562. executorList: [],
  563. allTeamList: [],
  564. productLineList: []
  565. };
  566. },
  567. computed: {
  568. activeTeamUserList() {
  569. return this.teamUserList.filter((user) =>
  570. this.addForm.executeUsersIds.includes(user.id)
  571. );
  572. },
  573. // 规则详情表头
  574. detailsColumns() {
  575. let list = [
  576. {
  577. width: 45,
  578. type: 'index',
  579. columnKey: 'index',
  580. align: 'center'
  581. },
  582. {
  583. label: '检查内容',
  584. prop: 'paramValue',
  585. minWidth: 120,
  586. slot: 'paramValue'
  587. },
  588. {
  589. label: '物联点位',
  590. prop: 'iotPointName',
  591. minWidth: 120
  592. },
  593. {
  594. label: '设备名称',
  595. prop: 'substanceName',
  596. minWidth: 120
  597. },
  598. {
  599. label: '值',
  600. prop: 'num',
  601. minWidth: 120,
  602. slot: 'num'
  603. },
  604. {
  605. label: '检查人',
  606. prop: 'checkUsersIds',
  607. minWidth: 120,
  608. slot: 'checkUsersIds',
  609. isNone: this.pageName != 'qualityTestRecords'
  610. },
  611. {
  612. label: '检查情况',
  613. prop: 'checkStatus',
  614. minWidth: 120,
  615. slot: 'checkStatus',
  616. isNone: [
  617. 'qualityTestRecords',
  618. 'productionRecords',
  619. 'QualityInspection',
  620. 'HaulSlag',
  621. 'TransportAsh'
  622. ].includes(this.pageName)
  623. },
  624. {
  625. label: '检查结果',
  626. prop: 'checkResult',
  627. minWidth: 120,
  628. isNone: [
  629. 'qualityTestRecords',
  630. 'productionRecords',
  631. 'QualityInspection',
  632. 'HaulSlag',
  633. 'TransportAsh'
  634. ].includes(this.pageName),
  635. slot: 'checkResult'
  636. }
  637. ];
  638. return list.filter((item) => !item.isNone);
  639. }
  640. },
  641. created() {
  642. if (localStorage.getItem('singleUserInfo') == '1') {
  643. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  644. this.getTeamList(data.teamId);
  645. } else {
  646. this.getTeamList(this.$store.state.user.info.teamId);
  647. }
  648. // 获取审核人列表、巡点检人员
  649. },
  650. methods: {
  651. // 外部调用,打开弹窗
  652. async open(type = 'add', data) {
  653. this.type = type;
  654. console.log('data', data);
  655. if (type == 'add') {
  656. this.title = '报工';
  657. } else {
  658. this.title = '详情';
  659. }
  660. await this.getUserList();
  661. await this.getAllTeamList();
  662. await this.getOrderDetials(data.id);
  663. this.visible = true;
  664. },
  665. handParent() {
  666. this.$refs.parentListRef.open();
  667. },
  668. changeParent(data) {
  669. this.addForm.contactName = data.name;
  670. this.addForm.contactId = data.id;
  671. this.addForm.supplierName = data.name;
  672. this.addForm.supplierId = data.id;
  673. if (
  674. ['QualityInspection', 'HaulSlag', 'TransportAsh'].includes(
  675. this.pageName
  676. )
  677. ) {
  678. let data = {
  679. pageNum: 1,
  680. size: 999,
  681. orderStatus: 2,
  682. partbId: data.id
  683. };
  684. //来煤获取采购订单
  685. getTableList({
  686. pageNum: 1,
  687. size: 999,
  688. orderStatus: 2,
  689. partbId: data.id
  690. }).then((res) => {
  691. if (res.list?.length == 1) {
  692. this.addForm.purchaseOrderId = res.list[0].id;
  693. this.addForm.purchaseOrderNo = res.list[0].orderNo;
  694. }
  695. });
  696. }
  697. },
  698. getCode() {
  699. if (this.$store.state.user.info.clientEnvironmentId == 10) {
  700. return this.pageName == 'QualityInspection'
  701. ? '06mei'
  702. : this.pageName == 'TransportAsh'
  703. ? '07lafei'
  704. : this.pageName == 'HaulSlag'
  705. ? '08lazha'
  706. : '';
  707. } else {
  708. return '';
  709. }
  710. },
  711. // 获取工单详情
  712. async getOrderDetials(id) {
  713. try {
  714. const data = await getById(id);
  715. console.log('data', data);
  716. data.detailList = data.detailList.map((i) => {
  717. i.toolNames = i.tools.map((j) => j.toolName).join(',');
  718. if (i.checkUsers && i.checkUsers.length > 0) {
  719. console.log('i.checkUsers', i.checkUsers);
  720. i.checkUsersIds = i.checkUsers.map((j) => j.userId);
  721. }
  722. if (
  723. (!i.checkUsersIds || i.checkUsersIds.length == 0) &&
  724. data.executeUsers.length > 0
  725. ) {
  726. // 默认执行人作为检查人
  727. i.checkUsersIds = data.executeUsers
  728. .filter((i) => i.userId)
  729. .map((j) => j.userId);
  730. i.checkUsers = data.executeUsers
  731. .filter((i) => i.userId)
  732. .map((j) => {
  733. return {
  734. teamId: j.teamId,
  735. teamName: j.teamName,
  736. userId: j.userId,
  737. userName: j.userName
  738. };
  739. });
  740. }
  741. return i;
  742. });
  743. Object.assign(this.addForm, data);
  744. this.addForm.unloadCheckStatus = this.addForm.unloadCheckStatus || 1;
  745. this.addForm.checkStartTime =
  746. this.addForm.checkStartTime ||
  747. dayjs(new Date()).format('YYYY-M-D HH:mm:ss');
  748. this.addForm.checkFinishTime =
  749. this.addForm.checkFinishTime ||
  750. dayjs(new Date()).format('YYYY-M-D HH:mm:ss');
  751. console.log(
  752. this.addForm.checkStartTime,
  753. 'this.addForm.checkStartTime'
  754. );
  755. // 处理数据
  756. this.addForm.executeUsersIds = this.addForm.executeUsers
  757. .map((i) => i.userId)
  758. .filter((i) => i); // 过滤掉 undefined
  759. // this.addForm.teamId =
  760. // this.addForm.executeUsers.length > 0
  761. // ? this.addForm.executeUsers[0].teamId
  762. // : '';
  763. if (this.addForm.executeUsers.length > 0 && !this.addForm.type) {
  764. this.addForm.groupId = this.addForm.executeUsers[0]?.groupId + '';
  765. this.addForm.groupName = this.addForm.executeUsers[0]?.groupName;
  766. if (this.addForm.groupId) {
  767. this.searchDeptNodeClick(this.addForm.groupId, 'init');
  768. }
  769. }
  770. if (!this.addForm.teamId && this.teamList.length > 0) {
  771. this.addForm.teamId = this.teamList[0].id;
  772. }
  773. this.addForm.recordRulesClassify += '';
  774. // 加载班组人员列表
  775. if (this.addForm.teamId) {
  776. const index = this.allTeamList.findIndex(
  777. (item) => item.id == this.addForm.teamId
  778. );
  779. console.log(this.allTeamList[index], 'dsadas');
  780. this.teamUserList = this.allTeamList[index].userVOList;
  781. this.productLineList = [];
  782. this.allTeamList[index].factoryWorkstationVOList.forEach((item) => {
  783. if (
  784. !this.productLineList.find(
  785. (p) => p.id === item.productionLineId
  786. )
  787. ) {
  788. this.productLineList.push({
  789. name: item.productionLineName,
  790. id: item.productionLineId
  791. });
  792. }
  793. });
  794. console.log('this.teamUserList', this.teamUserList);
  795. }
  796. //宇信
  797. if (
  798. this.$store.state.user.info.clientEnvironmentId == 10 &&
  799. ['productionRecords', 'qualityTestRecords'].includes(this.pageName)
  800. ) {
  801. //客户:5#和6#默认是重油公司7#默认是红山 2008389016775864321==7#
  802. if (this.addForm.productLineId == '2008389016775864321') {
  803. this.addForm.contactId =
  804. this.addForm.contactId || '2008562263580520449';
  805. this.addForm.contactName =
  806. this.addForm.contactName || '克拉玛依红山油田有限责任公司';
  807. } else {
  808. this.addForm.contactId =
  809. this.addForm.contactId || '2008383566202318850';
  810. this.addForm.contactName =
  811. this.addForm.contactName || '中国石油新疆油田分公司(重油公司)';
  812. }
  813. }
  814. this.setValue();
  815. this.$nextTick(() => {
  816. this.$refs.formRef.clearValidate();
  817. this.loading = false;
  818. });
  819. } catch (error) {
  820. console.log('error', error);
  821. this.loading = false;
  822. }
  823. },
  824. openOrd() {
  825. if (!this.addForm.supplierId) {
  826. this.$message.warning('请先选择供应商!');
  827. return;
  828. }
  829. this.$refs.orderListDialogRef.open(
  830. this.addForm.supplierId,
  831. //渣和灰拿委外订单
  832. ['TransportAsh', 'HaulSlag'].includes(this.pageName)
  833. ? '3,4,5,6,7'
  834. : ''
  835. );
  836. },
  837. orderListDialogSuccess(data) {
  838. this.addForm.purchaseOrderId = data.id;
  839. this.addForm.purchaseOrderNo = data.orderNo;
  840. },
  841. setValue() {
  842. if (this.title == '报工') {
  843. this.addForm.detailList.forEach((item, index) => {
  844. if (this.pageName == 'productionRecords') {
  845. if (item.paramValue == '用煤量') {
  846. let num1 = this.addForm.detailList.find(
  847. (item1) => item1.paramValue == '用水量'
  848. )?.num;
  849. console.log(num1, 'num1');
  850. let num = 0;
  851. if (num1) {
  852. num = (62 / 600) * num1;
  853. }
  854. this.$set(
  855. this.addForm.detailList[index],
  856. 'num',
  857. parseFloat(num.toFixed(5))
  858. );
  859. }
  860. }
  861. if (this.pageName == 'qualityTestRecords') {
  862. let num1 = this.addForm.detailList.find(
  863. (item1) => item1.paramValue == '给水量'
  864. )?.num;
  865. let num2 = this.addForm.detailList.find(
  866. (item1) => item1.paramValue == '炉水量'
  867. )?.num;
  868. let num = 0;
  869. if (num1 && num2) {
  870. num = (num2 - num1) / num2;
  871. }
  872. if (item.paramValue == '干度') {
  873. this.$set(
  874. this.addForm.detailList[index],
  875. 'num',
  876. parseFloat(num.toFixed(5)) * 100
  877. );
  878. }
  879. if (item.paramValue == '是否合格' && num1) {
  880. this.$set(
  881. this.addForm.detailList[index],
  882. 'num',
  883. parseFloat(num.toFixed(5)) * 100 >= 90 ? '合格' : '不合格'
  884. );
  885. }
  886. }
  887. if (this.pageName == 'productionRecords') {
  888. let num1 = this.addForm.detailList.find(
  889. (item1) => item1.paramValue == '日用水量'
  890. )?.num;
  891. let num = 0;
  892. if (num1) {
  893. num = num1 * 0.1034;
  894. }
  895. if (item.paramValue == '日用煤量') {
  896. this.$set(
  897. this.addForm.detailList[index],
  898. 'num',
  899. parseFloat(num.toFixed(5))
  900. );
  901. }
  902. }
  903. });
  904. }
  905. },
  906. // 关闭时清理表单
  907. handleClose() {
  908. this.addForm = JSON.parse(JSON.stringify(this.formBaseData));
  909. this.$nextTick(() => {
  910. this.$refs.formRef.clearValidate();
  911. this.visible = false;
  912. });
  913. },
  914. // 提交
  915. submit() {
  916. this.$refs.formRef.validate(async (valid) => {
  917. if (valid) {
  918. console.log('this.addForm', this.addForm);
  919. // this.handleClose();
  920. if (this.addForm.executeUsersIds.length == 0) {
  921. this.$message.warning('请选择执行人!');
  922. return;
  923. }
  924. // 报工需要验证 缓存不验证 排除 recordTemplateStyle ==3 物料添加 == 4生产统计 模板
  925. if (
  926. ![
  927. 'qualityTestRecords',
  928. 'productionRecords',
  929. 'QualityInspection',
  930. 'HaulSlag',
  931. 'TransportAsh'
  932. ].includes(this.pageName)
  933. ) {
  934. // 验证检查项目
  935. const detailRequired = this.addForm.detailList.some((i) => {
  936. return i.checkResult == null || i.checkStatus == null;
  937. });
  938. if (detailRequired) {
  939. return this.$message.warning(
  940. '请先完善、检查情况、检查结果 内容!'
  941. );
  942. }
  943. }
  944. const body = JSON.parse(JSON.stringify(this.addForm));
  945. console.log(body);
  946. // return
  947. this.butLoading = true;
  948. try {
  949. await producetaskrulerecordSaveOrUpdateAndSubmit(body);
  950. this.$message.success('报工成功!');
  951. this.butLoading = false;
  952. this.$emit('refresh');
  953. this.handleClose();
  954. } catch (error) {
  955. this.butLoading = false;
  956. }
  957. }
  958. });
  959. },
  960. checkTeamList(id) {
  961. const index = this.teamList.findIndex((item) => item.id == id);
  962. this.teamUserList = this.teamAllList[index];
  963. this.addForm.teamName = this.teamList[index].name;
  964. console.log('this.teamUserList', this.teamUserList);
  965. },
  966. async getTeamList(id) {
  967. if (!id) return;
  968. const ids = id.split(',');
  969. this.teamList = [];
  970. this.teamUserList = [];
  971. const list = ids.map((item) => getTeam(item));
  972. const dataList = await Promise.all(list);
  973. dataList.forEach((item) => {
  974. this.teamList.push({
  975. name: item.name,
  976. id: item.id
  977. });
  978. this.teamAllList.push(item.userVOList);
  979. });
  980. },
  981. changeId() {
  982. if (this.addForm.executeUsersIds.length == this.teamUserList.length) {
  983. this.checked = true;
  984. } else {
  985. this.checked = false;
  986. }
  987. const deleteUserIds = this.addForm.executeUsers
  988. .map((i) => i.userId)
  989. .filter((id) => !this.addForm.executeUsersIds.includes(id));
  990. const addUserIds = this.addForm.executeUsersIds.filter(
  991. (id) => !this.addForm.executeUsers.map((i) => i.userId).includes(id)
  992. );
  993. // 删除 用户
  994. if (deleteUserIds.length > 0) {
  995. this.addForm.executeUsers = this.addForm.executeUsers.filter(
  996. (item) => !deleteUserIds.includes(item.userId)
  997. );
  998. }
  999. // 添加 用户
  1000. addUserIds.forEach((id) => {
  1001. const user = this.teamUserList.find((item) => item.id === id);
  1002. if (user) {
  1003. this.addForm.executeUsers.push({
  1004. teamId: this.addForm.teamId,
  1005. teamName: this.teamList.find(
  1006. (team) => team.id == this.addForm.teamId
  1007. )?.name,
  1008. userId: user.id,
  1009. userName: user.name
  1010. });
  1011. }
  1012. });
  1013. this.addForm.detailList.forEach((detail) => {
  1014. detail.checkUsersIds = this.addForm.executeUsersIds;
  1015. detail.checkUsers = this.addForm.executeUsers;
  1016. });
  1017. },
  1018. checkUsersIdsChange(row) {
  1019. // 同步 checkUsers
  1020. row.checkUsers = row.checkUsersIds.map((i) => {
  1021. const user = this.addForm.executeUsers.find(
  1022. (item) => item.userId === i
  1023. );
  1024. return user;
  1025. });
  1026. console.log('row', row);
  1027. },
  1028. checkChange() {
  1029. this.addForm.executeUsersIds = [];
  1030. if (this.checked) {
  1031. this.addForm.executeUsersIds = this.teamUserList.map(
  1032. (item) => item.id
  1033. );
  1034. } else {
  1035. this.addForm.executeUsersIds = [];
  1036. }
  1037. this.changeId();
  1038. },
  1039. // 批量检查
  1040. batchCheck() {
  1041. this.addForm.detailList = this.addForm.detailList.map((i) => {
  1042. i.checkStatus = 1;
  1043. return i;
  1044. });
  1045. },
  1046. // 批量合格
  1047. batchQualified() {
  1048. this.addForm.detailList = this.addForm.detailList.map((i) => {
  1049. i.checkResult = 1;
  1050. return i;
  1051. });
  1052. },
  1053. // 获取审核人列表、巡点检人员
  1054. async getUserList(params) {
  1055. try {
  1056. let data = { pageNum: 1, size: -1 };
  1057. // 如果传了参数就是获取部门人员数据
  1058. if (params) {
  1059. data = Object.assign(data, params);
  1060. }
  1061. const res = await getUserPage(data);
  1062. if (params) {
  1063. this.executorList = res.list;
  1064. } else {
  1065. this.uerList = res.list;
  1066. }
  1067. } catch (error) {}
  1068. },
  1069. //选择部门(搜索)
  1070. async searchDeptNodeClick(groupId, type) {
  1071. if (groupId) {
  1072. // 根据部门获取人员
  1073. const params = { groupId: groupId };
  1074. await this.getUserList(params);
  1075. } else {
  1076. this.addForm.groupId = null;
  1077. }
  1078. if (type != 'init') {
  1079. this.addForm.detailList.forEach((detail) => {
  1080. detail.checkUsersIds = [];
  1081. detail.checkUsers = [];
  1082. });
  1083. this.addForm.executeUsers = [];
  1084. this.addForm.executeUsersIds = [];
  1085. }
  1086. },
  1087. // 负责人变更 同步执行人列表
  1088. executeIdListChange() {
  1089. this.addForm.executeUsers = this.addForm.executeUsersIds
  1090. .map((userId) => {
  1091. const user = this.executorList.find((u) => u.id === userId);
  1092. if (!user) return null;
  1093. return {
  1094. userId: user.id,
  1095. userName: user.name,
  1096. groupId: user.groupId,
  1097. groupName: user.groupName
  1098. };
  1099. })
  1100. .filter((i) => i);
  1101. // 同步详情执行人
  1102. this.addForm.detailList.forEach((detail) => {
  1103. detail.checkUsersIds = this.addForm.executeUsersIds;
  1104. detail.checkUsers = this.addForm.executeUsers;
  1105. });
  1106. console.log('this.addForm.executeUsers', this.addForm.executeUsers);
  1107. },
  1108. async getAllTeamList() {
  1109. const { list } = await getteampage({
  1110. pageNum: 1,
  1111. size: -1
  1112. });
  1113. console.log('teamAllList 班组', list);
  1114. this.allTeamList = list;
  1115. }
  1116. }
  1117. };
  1118. </script>
  1119. <style scoped lang="scss">
  1120. :deep(.el-form) {
  1121. .el-form-item:last-child {
  1122. margin-bottom: 22px !important;
  1123. }
  1124. }
  1125. ::v-deep .el-row {
  1126. display: flex;
  1127. flex-wrap: wrap;
  1128. }
  1129. .checkboxWrapper {
  1130. padding: 8px 20px;
  1131. border-bottom: 1px solid #ccc;
  1132. }
  1133. ::v-deep .el-select__tags {
  1134. flex-wrap: nowrap;
  1135. overflow: auto;
  1136. }
  1137. /* 输入框最大宽度*/
  1138. ::v-deep .el-select__tags-text {
  1139. max-width: 90px;
  1140. }
  1141. /* 底部滚动条的高度*/
  1142. ::v-deep .el-select__tags::-webkit-scrollbar {
  1143. height: 2px !important;
  1144. }
  1145. .footer-box {
  1146. display: flex;
  1147. align-items: center;
  1148. justify-content: flex-end;
  1149. gap: 15px;
  1150. margin-top: 20px;
  1151. }
  1152. </style>