workOrderReport.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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 :span="8" v-if="pageName == 'steamInjectionInspectionRecord'">
  155. <el-form-item label="甲方检查人" required prop="contactName">
  156. <el-input
  157. clearable
  158. v-model="addForm.contactName"
  159. @click.native="handParent"
  160. placeholder="请选择"
  161. readonly
  162. />
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="8" v-if="pageName == 'solidWasteRecord'">
  166. <el-form-item label="处理方" required prop="supplierName">
  167. <el-input
  168. clearable
  169. v-model="addForm.supplierName"
  170. @click.native="handParent"
  171. placeholder="请选择"
  172. readonly
  173. />
  174. </el-form-item>
  175. </el-col>
  176. <el-col
  177. :span="8"
  178. v-if="
  179. pageName == 'productionRecords' || pageName == 'QualityInspection'
  180. "
  181. >
  182. <el-form-item label="供应商" required prop="supplierName">
  183. <el-input
  184. clearable
  185. v-model="addForm.supplierName"
  186. @click.native="handParent"
  187. placeholder="请选择"
  188. readonly
  189. />
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="8" v-if="pageName == 'QualityInspection'">
  193. <el-form-item label="采购订单" required prop="purchaseOrderNo">
  194. <el-input
  195. clearable
  196. v-model="addForm.purchaseOrderNo"
  197. @click.native="openOrd"
  198. placeholder="请选择"
  199. readonly
  200. />
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="8" v-if="pageName == 'QualityInspection'">
  204. <el-form-item
  205. label="检查卸车是否到位"
  206. required
  207. prop="unloadCheckStatus"
  208. >
  209. <el-radio-group v-model="addForm.unloadCheckStatus">
  210. <el-radio :label="1">已到位</el-radio>
  211. <el-radio :label="2">未到位</el-radio>
  212. </el-radio-group>
  213. </el-form-item>
  214. </el-col>
  215. <el-col :span="9" v-if="pageName == 'QualityInspection'">
  216. <el-form-item label="车辆照片" prop="vehiclePhotoUrl">
  217. <WithView
  218. :assetName="''"
  219. v-model="addForm.vehiclePhotoUrl"
  220. style="max-height: 370px"
  221. v-if="type != 'detail'"
  222. ></WithView>
  223. </el-form-item>
  224. </el-col>
  225. <el-col :span="8" v-if="pageName == 'qualityTestRecords'">
  226. <el-form-item label="联合站检查人" required prop="contactName">
  227. <el-input
  228. clearable
  229. v-model="addForm.contactName"
  230. @click.native="handParent"
  231. placeholder="请选择"
  232. readonly
  233. />
  234. </el-form-item>
  235. </el-col>
  236. </el-row>
  237. <header-title title="记录数据" :style="`margin-top: 20px`"></header-title>
  238. <ele-pro-table
  239. v-loading="loading"
  240. ref="table"
  241. row-key="id"
  242. :columns="detailsColumns"
  243. :datasource="addForm.detailList"
  244. :needPage="false"
  245. :page-size="defPageSize"
  246. >
  247. <template v-slot:toolkit>
  248. <el-button
  249. v-if="pageName != 'productionRecords'"
  250. type="primary"
  251. @click="batchCheck"
  252. >批量检查</el-button
  253. >
  254. <el-button
  255. v-if="pageName != 'productionRecords'"
  256. type="primary"
  257. @click="batchQualified"
  258. >批量合格</el-button
  259. >
  260. </template>
  261. <template v-slot:paramValue="{ row }">
  262. <!-- <div v-if="addForm.recordTemplateStyle == '3'">
  263. {{ row.productName }}
  264. </div>
  265. <div v-else>
  266. {{ row.paramValue }}
  267. <span v-if="row.paramValue">{{ row.paramValue }}</span>
  268. <span v-else>
  269. {{ row.productName }}
  270. </span>
  271. </div> -->
  272. <div> {{ row.paramValue }}</div>
  273. </template>
  274. <template v-slot:checkUsersIds="{ row }">
  275. <div>
  276. <el-select
  277. v-model="row.checkUsersIds"
  278. placeholder="请选择检查人"
  279. filterable
  280. multiple
  281. @change="checkUsersIdsChange(row)"
  282. >
  283. <el-option
  284. v-for="item in addForm.executeUsers"
  285. :label="item.userName"
  286. :value="item.userId"
  287. :key="item.userId"
  288. >
  289. </el-option>
  290. </el-select>
  291. </div>
  292. </template>
  293. <template v-slot:checkStatus="{ row }">
  294. <div>
  295. <el-radio-group v-model="row.checkStatus">
  296. <el-radio :label="1">已检查</el-radio>
  297. <el-radio :label="0">未检查</el-radio>
  298. </el-radio-group>
  299. </div>
  300. </template>
  301. <!-- <template v-slot:errorMsg="{ row }">
  302. <div>
  303. <el-input
  304. type="text"
  305. :rows="1"
  306. placeholder="请输入"
  307. v-model="row.errorMsg"
  308. >
  309. <template v-if="row.unitName" slot="append">
  310. <div>{{ row.unitName }}</div>
  311. </template>
  312. </el-input>
  313. </div></template
  314. > -->
  315. <template v-slot:num="{ row }">
  316. <div>
  317. <el-input
  318. type="text"
  319. placeholder="请输入"
  320. v-model="row.num"
  321. @input="setValue"
  322. >
  323. <template v-if="row.unitName" slot="append">
  324. <div>{{ row.unitName }}</div>
  325. </template>
  326. </el-input>
  327. </div>
  328. </template>
  329. <template v-slot:checkResult="{ row }">
  330. <div>
  331. <el-radio-group v-model="row.checkResult">
  332. <el-radio :label="1">合格</el-radio>
  333. <el-radio :label="0">不合格</el-radio>
  334. </el-radio-group>
  335. </div>
  336. </template>
  337. </ele-pro-table>
  338. </el-form>
  339. <parentList
  340. :classType="
  341. pageName == 'solidWasteRecord' ||
  342. pageName == 'QualityInspection' ||
  343. pageName == 'productionRecords'
  344. ? '2'
  345. : '1'
  346. "
  347. :type="
  348. pageName == 'solidWasteRecord' ||
  349. pageName == 'QualityInspection' ||
  350. pageName == 'productionRecords'
  351. ? '19'
  352. : '17'
  353. "
  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. // productLineId: [
  556. // { required: true, message: '请选择场站', trigger: 'blur' },
  557. // { required: true, message: '请选择场站', trigger: 'change' }
  558. // ]
  559. },
  560. loading: false,
  561. butLoading: false,
  562. checked: false,
  563. teamUserList: [],
  564. teamList: [],
  565. teamAllList: [],
  566. executorList: [],
  567. allTeamList: [],
  568. productLineList: []
  569. };
  570. },
  571. computed: {
  572. // title() {
  573. // if (this.addForm.recordRulesClassify) {
  574. // const dictValue = this.getDictValue(
  575. // '记录规则类型',
  576. // this.addForm.recordRulesClassify
  577. // );
  578. // return dictValue + '记录表';
  579. // }
  580. // return '记录表';
  581. // },
  582. activeTeamUserList() {
  583. return this.teamUserList.filter((user) =>
  584. this.addForm.executeUsersIds.includes(user.id)
  585. );
  586. },
  587. // 规则详情表头
  588. detailsColumns() {
  589. let list = [
  590. {
  591. width: 45,
  592. type: 'index',
  593. columnKey: 'index',
  594. align: 'center'
  595. },
  596. {
  597. label: '检查内容',
  598. prop: 'paramValue',
  599. minWidth: 120,
  600. slot: 'paramValue'
  601. },
  602. {
  603. label: '物联点位',
  604. prop: 'iotPointName',
  605. minWidth: 120
  606. },
  607. {
  608. label: '设备名称',
  609. prop: 'substanceName',
  610. minWidth: 120
  611. },
  612. {
  613. label: '值',
  614. prop: 'num',
  615. minWidth: 120,
  616. slot: 'num'
  617. },
  618. {
  619. label: '检查人',
  620. prop: 'checkUsersIds',
  621. minWidth: 120,
  622. slot: 'checkUsersIds',
  623. isNone: this.pageName != 'qualityTestRecords'
  624. },
  625. // {
  626. // label: '描述',
  627. // prop: 'errorMsg',
  628. // minWidth: 120,
  629. // slot: 'errorMsg',
  630. // isNone: this.pageName != 'qualityTestRecords'
  631. // },
  632. {
  633. label: '检查情况',
  634. prop: 'checkStatus',
  635. minWidth: 120,
  636. slot: 'checkStatus',
  637. isNone:
  638. this.pageName == 'productionRecords' ||
  639. this.pageName == 'QualityInspection'
  640. },
  641. {
  642. label: '检查结果',
  643. prop: 'checkResult',
  644. minWidth: 120,
  645. isNone:
  646. this.pageName == 'productionRecords' ||
  647. this.pageName == 'QualityInspection',
  648. slot: 'checkResult'
  649. }
  650. ];
  651. return list.filter((item) => !item.isNone);
  652. }
  653. },
  654. created() {
  655. if (localStorage.getItem('singleUserInfo') == '1') {
  656. const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
  657. this.getTeamList(data.teamId);
  658. } else {
  659. this.getTeamList(this.$store.state.user.info.teamId);
  660. }
  661. // 获取审核人列表、巡点检人员
  662. },
  663. methods: {
  664. // 外部调用,打开弹窗
  665. async open(type = 'add', data) {
  666. this.type = type;
  667. console.log('data', data);
  668. if (type == 'add') {
  669. this.title = '报工';
  670. } else {
  671. this.title = '详情';
  672. }
  673. await this.getUserList();
  674. await this.getAllTeamList();
  675. await this.getOrderDetials(data.id);
  676. this.visible = true;
  677. },
  678. handParent() {
  679. this.$refs.parentListRef.open();
  680. },
  681. changeParent(data) {
  682. this.addForm.contactName = data.name;
  683. this.addForm.contactId = data.id;
  684. this.addForm.supplierName = data.name;
  685. this.addForm.supplierId = data.id;
  686. if (this.pageName == 'QualityInspection') {
  687. //来煤获取采购订单
  688. getTableList({
  689. pageNum: 1,
  690. size: 999,
  691. orderStatus: 2,
  692. isOutsourcing: 1,
  693. partbId: data.id
  694. }).then((res) => {
  695. if (res.list?.length == 1) {
  696. this.addForm.purchaseOrderId = res.list[0].id;
  697. this.addForm.purchaseOrderNo = res.list[0].orderNo;
  698. }
  699. });
  700. }
  701. },
  702. // 获取工单详情
  703. async getOrderDetials(id) {
  704. try {
  705. const data = await getById(id);
  706. console.log('data', data);
  707. data.detailList = data.detailList.map((i) => {
  708. i.toolNames = i.tools.map((j) => j.toolName).join(',');
  709. if (i.checkUsers && i.checkUsers.length > 0) {
  710. console.log('i.checkUsers', i.checkUsers);
  711. i.checkUsersIds = i.checkUsers.map((j) => j.userId);
  712. }
  713. if (
  714. (!i.checkUsersIds || i.checkUsersIds.length == 0) &&
  715. data.executeUsers.length > 0
  716. ) {
  717. // 默认执行人作为检查人
  718. i.checkUsersIds = data.executeUsers
  719. .filter((i) => i.userId)
  720. .map((j) => j.userId);
  721. i.checkUsers = data.executeUsers
  722. .filter((i) => i.userId)
  723. .map((j) => {
  724. return {
  725. teamId: j.teamId,
  726. teamName: j.teamName,
  727. userId: j.userId,
  728. userName: j.userName
  729. };
  730. });
  731. }
  732. return i;
  733. });
  734. // <el-col :span="8">
  735. // <el-form-item label="检查时间" required prop="checkStartTime">
  736. // <el-date-picker
  737. // v-model="addForm.checkStartTime"
  738. // type="datetime"
  739. // format="yyyy-MM-dd HH:mm:ss"
  740. // value-format="yyyy-MM-dd HH:mm:ss"
  741. // placeholder="选择日期"
  742. // style="width: 100%"
  743. // :picker-options="{
  744. // disabledDate: (time) => time.getTime() > Date.now()
  745. // }"
  746. // >
  747. // </el-date-picker>
  748. // </el-form-item>
  749. // </el-col>
  750. // <el-col :span="8">
  751. // <el-form-item label="报工时间" required prop="checkFinishTime">
  752. // <el-date-picker
  753. // v-model="addForm.checkFinishTime"
  754. // type="datetime"
  755. // format="yyyy-MM-dd HH:mm:ss"
  756. // value-format="yyyy-MM-dd HH:mm:ss"
  757. // placeholder="选择日期"
  758. // style="width: 100%"
  759. // :picker-options="{
  760. // disabledDate: (time) => time.getTime() > Date.now()
  761. // }"
  762. // >
  763. // </el-date-picker>
  764. // </el-form-item>
  765. // </el-col>
  766. Object.assign(this.addForm, data);
  767. this.addForm.unloadCheckStatus = this.addForm.unloadCheckStatus || 1;
  768. this.addForm.checkStartTime =
  769. this.addForm.checkStartTime ||
  770. dayjs(new Date()).format('YYYY-M-D HH:mm:ss');
  771. this.addForm.checkFinishTime =
  772. this.addForm.checkFinishTime ||
  773. dayjs(new Date()).format('YYYY-M-D HH:mm:ss');
  774. console.log(
  775. this.addForm.checkStartTime,
  776. 'this.addForm.checkStartTime'
  777. );
  778. // 处理数据
  779. this.addForm.executeUsersIds = this.addForm.executeUsers
  780. .map((i) => i.userId)
  781. .filter((i) => i); // 过滤掉 undefined
  782. // this.addForm.teamId =
  783. // this.addForm.executeUsers.length > 0
  784. // ? this.addForm.executeUsers[0].teamId
  785. // : '';
  786. if (this.addForm.executeUsers.length > 0 && !this.addForm.type) {
  787. this.addForm.groupId = this.addForm.executeUsers[0]?.groupId + '';
  788. this.addForm.groupName = this.addForm.executeUsers[0]?.groupName;
  789. if (this.addForm.groupId) {
  790. this.searchDeptNodeClick(this.addForm.groupId, 'init');
  791. }
  792. }
  793. if (!this.addForm.teamId && this.teamList.length > 0) {
  794. this.addForm.teamId = this.teamList[0].id;
  795. }
  796. this.addForm.recordRulesClassify += '';
  797. // 加载班组人员列表
  798. if (this.addForm.teamId) {
  799. const index = this.allTeamList.findIndex(
  800. (item) => item.id == this.addForm.teamId
  801. );
  802. console.log(this.allTeamList[index], 'dsadas');
  803. this.teamUserList = this.allTeamList[index].userVOList;
  804. this.productLineList = [];
  805. this.allTeamList[index].factoryWorkstationVOList.forEach((item) => {
  806. if (
  807. !this.productLineList.find(
  808. (p) => p.id === item.productionLineId
  809. )
  810. ) {
  811. this.productLineList.push({
  812. name: item.productionLineName,
  813. id: item.productionLineId
  814. });
  815. }
  816. });
  817. console.log('this.teamUserList', this.teamUserList);
  818. }
  819. this.setValue();
  820. this.$nextTick(() => {
  821. this.$refs.formRef.clearValidate();
  822. this.loading = false;
  823. });
  824. } catch (error) {
  825. console.log('error', error);
  826. this.loading = false;
  827. }
  828. },
  829. openOrd() {
  830. if (!this.addForm.supplierId) {
  831. this.$message.warning('请先选择供应商!');
  832. return;
  833. }
  834. this.$refs.orderListDialogRef.open(this.addForm.supplierId);
  835. },
  836. orderListDialogSuccess(data) {
  837. this.addForm.purchaseOrderId = data.id;
  838. this.addForm.purchaseOrderNo = data.orderNo;
  839. },
  840. setValue() {
  841. if (this.title == '报工') {
  842. this.addForm.detailList.forEach((item, index) => {
  843. if (this.pageName == 'productionRecords') {
  844. if (item.paramValue == '用煤量') {
  845. let num1 = this.addForm.detailList.find(
  846. (item1) => item1.paramValue == '用水量'
  847. )?.num;
  848. console.log(num1, 'num1');
  849. let num = 0;
  850. if (num1) {
  851. num = (62 / 600) * num1;
  852. }
  853. this.$set(
  854. this.addForm.detailList[index],
  855. 'num',
  856. parseFloat(num.toFixed(5))
  857. );
  858. }
  859. }
  860. if (this.pageName == 'qualityTestRecords') {
  861. if (item.paramValue == '检测干度值-干度') {
  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. this.$set(
  873. this.addForm.detailList[index],
  874. 'num',
  875. parseFloat(num.toFixed(5)) * 100
  876. );
  877. }
  878. }
  879. });
  880. }
  881. },
  882. // 关闭时清理表单
  883. handleClose() {
  884. this.addForm = JSON.parse(JSON.stringify(this.formBaseData));
  885. this.$nextTick(() => {
  886. this.$refs.formRef.clearValidate();
  887. this.visible = false;
  888. });
  889. },
  890. // 提交
  891. submit() {
  892. this.$refs.formRef.validate(async (valid) => {
  893. if (valid) {
  894. console.log('this.addForm', this.addForm);
  895. // this.handleClose();
  896. if (this.addForm.executeUsersIds.length == 0) {
  897. this.$message.warning('请选择执行人!');
  898. return;
  899. }
  900. // 报工需要验证 缓存不验证 排除 recordTemplateStyle ==3 物料添加 == 4生产统计 模板
  901. if (
  902. this.pageName != 'productionRecords' &&
  903. this.pageName != 'QualityInspection'
  904. ) {
  905. // 验证检查项目
  906. const detailRequired = this.addForm.detailList.some((i) => {
  907. return i.checkResult == null || i.checkStatus == null;
  908. });
  909. if (detailRequired) {
  910. return this.$message.warning(
  911. '请先完善、检查情况、检查结果 内容!'
  912. );
  913. }
  914. }
  915. const body = JSON.parse(JSON.stringify(this.addForm));
  916. console.log(body);
  917. // return
  918. this.butLoading = true;
  919. try {
  920. await producetaskrulerecordSaveOrUpdateAndSubmit(body);
  921. this.$message.success('报工成功!');
  922. this.butLoading = false;
  923. this.$emit('refresh');
  924. this.handleClose();
  925. } catch (error) {
  926. this.butLoading = false;
  927. }
  928. }
  929. });
  930. },
  931. checkTeamList(id) {
  932. const index = this.teamList.findIndex((item) => item.id == id);
  933. this.teamUserList = this.teamAllList[index];
  934. this.addForm.teamName = this.teamList[index].name;
  935. console.log('this.teamUserList', this.teamUserList);
  936. },
  937. async getTeamList(id) {
  938. if (!id) return;
  939. const ids = id.split(',');
  940. this.teamList = [];
  941. this.teamUserList = [];
  942. const list = ids.map((item) => getTeam(item));
  943. const dataList = await Promise.all(list);
  944. dataList.forEach((item) => {
  945. this.teamList.push({
  946. name: item.name,
  947. id: item.id
  948. });
  949. this.teamAllList.push(item.userVOList);
  950. });
  951. },
  952. changeId() {
  953. if (this.addForm.executeUsersIds.length == this.teamUserList.length) {
  954. this.checked = true;
  955. } else {
  956. this.checked = false;
  957. }
  958. const deleteUserIds = this.addForm.executeUsers
  959. .map((i) => i.userId)
  960. .filter((id) => !this.addForm.executeUsersIds.includes(id));
  961. const addUserIds = this.addForm.executeUsersIds.filter(
  962. (id) => !this.addForm.executeUsers.map((i) => i.userId).includes(id)
  963. );
  964. // 删除 用户
  965. if (deleteUserIds.length > 0) {
  966. this.addForm.executeUsers = this.addForm.executeUsers.filter(
  967. (item) => !deleteUserIds.includes(item.userId)
  968. );
  969. }
  970. // 添加 用户
  971. addUserIds.forEach((id) => {
  972. const user = this.teamUserList.find((item) => item.id === id);
  973. if (user) {
  974. this.addForm.executeUsers.push({
  975. teamId: this.addForm.teamId,
  976. teamName: this.teamList.find(
  977. (team) => team.id == this.addForm.teamId
  978. )?.name,
  979. userId: user.id,
  980. userName: user.name
  981. });
  982. }
  983. });
  984. this.addForm.detailList.forEach((detail) => {
  985. detail.checkUsersIds = this.addForm.executeUsersIds;
  986. detail.checkUsers = this.addForm.executeUsers;
  987. });
  988. },
  989. checkUsersIdsChange(row) {
  990. // 同步 checkUsers
  991. row.checkUsers = row.checkUsersIds.map((i) => {
  992. const user = this.addForm.executeUsers.find(
  993. (item) => item.userId === i
  994. );
  995. return user;
  996. });
  997. console.log('row', row);
  998. },
  999. checkChange() {
  1000. this.addForm.executeUsersIds = [];
  1001. if (this.checked) {
  1002. this.addForm.executeUsersIds = this.teamUserList.map(
  1003. (item) => item.id
  1004. );
  1005. } else {
  1006. this.addForm.executeUsersIds = [];
  1007. }
  1008. this.changeId();
  1009. },
  1010. // 批量检查
  1011. batchCheck() {
  1012. this.addForm.detailList = this.addForm.detailList.map((i) => {
  1013. i.checkStatus = 1;
  1014. return i;
  1015. });
  1016. },
  1017. // 批量合格
  1018. batchQualified() {
  1019. this.addForm.detailList = this.addForm.detailList.map((i) => {
  1020. i.checkResult = 1;
  1021. return i;
  1022. });
  1023. },
  1024. // 获取审核人列表、巡点检人员
  1025. async getUserList(params) {
  1026. try {
  1027. let data = { pageNum: 1, size: -1 };
  1028. // 如果传了参数就是获取部门人员数据
  1029. if (params) {
  1030. data = Object.assign(data, params);
  1031. }
  1032. const res = await getUserPage(data);
  1033. if (params) {
  1034. this.executorList = res.list;
  1035. } else {
  1036. this.uerList = res.list;
  1037. }
  1038. } catch (error) {}
  1039. },
  1040. //选择部门(搜索)
  1041. async searchDeptNodeClick(groupId, type) {
  1042. if (groupId) {
  1043. // 根据部门获取人员
  1044. const params = { groupId: groupId };
  1045. await this.getUserList(params);
  1046. } else {
  1047. this.addForm.groupId = null;
  1048. }
  1049. if (type != 'init') {
  1050. this.addForm.detailList.forEach((detail) => {
  1051. detail.checkUsersIds = [];
  1052. detail.checkUsers = [];
  1053. });
  1054. this.addForm.executeUsers = [];
  1055. this.addForm.executeUsersIds = [];
  1056. }
  1057. },
  1058. // 负责人变更 同步执行人列表
  1059. executeIdListChange() {
  1060. this.addForm.executeUsers = this.addForm.executeUsersIds
  1061. .map((userId) => {
  1062. const user = this.executorList.find((u) => u.id === userId);
  1063. if (!user) return null;
  1064. return {
  1065. userId: user.id,
  1066. userName: user.name,
  1067. groupId: user.groupId,
  1068. groupName: user.groupName
  1069. };
  1070. })
  1071. .filter((i) => i);
  1072. // 同步详情执行人
  1073. this.addForm.detailList.forEach((detail) => {
  1074. detail.checkUsersIds = this.addForm.executeUsersIds;
  1075. detail.checkUsers = this.addForm.executeUsers;
  1076. });
  1077. console.log('this.addForm.executeUsers', this.addForm.executeUsers);
  1078. },
  1079. async getAllTeamList() {
  1080. const { list } = await getteampage({
  1081. pageNum: 1,
  1082. size: -1
  1083. });
  1084. console.log('teamAllList 班组', list);
  1085. this.allTeamList = list;
  1086. }
  1087. }
  1088. };
  1089. </script>
  1090. <style scoped lang="scss">
  1091. :deep(.el-form) {
  1092. .el-form-item:last-child {
  1093. margin-bottom: 22px !important;
  1094. }
  1095. }
  1096. ::v-deep .el-row {
  1097. display: flex;
  1098. flex-wrap: wrap;
  1099. }
  1100. .checkboxWrapper {
  1101. padding: 8px 20px;
  1102. border-bottom: 1px solid #ccc;
  1103. }
  1104. ::v-deep .el-select__tags {
  1105. flex-wrap: nowrap;
  1106. overflow: auto;
  1107. }
  1108. /* 输入框最大宽度*/
  1109. ::v-deep .el-select__tags-text {
  1110. max-width: 90px;
  1111. }
  1112. /* 底部滚动条的高度*/
  1113. ::v-deep .el-select__tags::-webkit-scrollbar {
  1114. height: 2px !important;
  1115. }
  1116. .footer-box {
  1117. display: flex;
  1118. align-items: center;
  1119. justify-content: flex-end;
  1120. gap: 15px;
  1121. margin-top: 20px;
  1122. }
  1123. </style>