workOrderReport.vue 37 KB

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