work.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. <!-- 我的工单 -->
  2. <template>
  3. <div class="works">
  4. <el-form :model="dataForm" :inline="true">
  5. <el-form-item label="选择用户">
  6. <user-component
  7. v-model="dataForm.userId"
  8. :user-id="dataForm.userId"
  9. @userSelected="userChanged"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button @click="queryData()" v-reClick>查询</el-button>
  14. <el-button @click="batchStart()" v-reClick v-if="dataForm.state === '1'">批量开始</el-button>
  15. <el-button @click="batchFinishOrCheck()" v-reClick v-if="dataForm.state === '2'">批量报工/通过</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-tabs v-model="dataForm.state" @tab-click="queryData">
  19. <el-tab-pane label="未开始" name="1"></el-tab-pane>
  20. <el-tab-pane label="待操作" name="2"></el-tab-pane>
  21. <el-tab-pane label="已完成" name="3"></el-tab-pane>
  22. </el-tabs>
  23. <el-table
  24. :data="dataList"
  25. border
  26. v-loading="dataListLoading"
  27. style="width: 100%;"
  28. @selection-change="handleSelectionChange"
  29. >
  30. <el-table-column
  31. type="selection"
  32. :selectable="selected"
  33. width="55">
  34. </el-table-column>
  35. <el-table-column label="序号" type="index" width="50" align="center">
  36. </el-table-column>
  37. <el-table-column
  38. prop="ranks"
  39. header-align="center"
  40. align="center"
  41. min-width="140"
  42. :show-tooltip-when-overflow="true"
  43. label="级别"
  44. >
  45. <template slot-scope="scope">
  46. <span>
  47. {{
  48. rankTypeOption.findIndex((t) => t.value == scope.row.ranks) > -1
  49. ? rankTypeOption.find((t) => t.value == scope.row.ranks).label
  50. : ''
  51. }}
  52. </span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. prop="taskType"
  57. header-align="center"
  58. align="center"
  59. min-width="160"
  60. label="工单类型"
  61. >
  62. <template slot-scope="scope">
  63. <span>
  64. {{
  65. taskTypeOption.findIndex((t) => t.value == scope.row.taskType) > -1
  66. ? taskTypeOption.find((t) => t.value == scope.row.taskType).label
  67. : ''
  68. }}
  69. </span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column
  73. prop="taskName"
  74. header-align="center"
  75. align="center"
  76. min-width="140"
  77. :show-tooltip-when-overflow="true"
  78. label="工单名称"
  79. >
  80. </el-table-column>
  81. <el-table-column
  82. prop="content"
  83. header-align="center"
  84. align="center"
  85. min-width="140"
  86. :show-tooltip-when-overflow="true"
  87. label="工单内容"
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. prop="planCompletionTime"
  92. header-align="center"
  93. align="center"
  94. min-width="160"
  95. label="规定完成时间"
  96. >
  97. </el-table-column>
  98. <el-table-column
  99. prop="attachList"
  100. header-align="center"
  101. align="center"
  102. width="80"
  103. label="工单附件"
  104. >
  105. <template slot-scope="scope">
  106. <el-button :disabled="!scope.row.attachList || scope.row.attachList.length === 0" type="text" size="small" @click="changeDetails(scope.row.attachList)">查看</el-button>
  107. </template>
  108. </el-table-column>
  109. <el-table-column
  110. prop="attachListComplete"
  111. header-align="center"
  112. align="center"
  113. width="80"
  114. label="报工附件"
  115. >
  116. <template slot-scope="scope">
  117. <el-button :disabled="!scope.row.attachListComplete || scope.row.attachListComplete.length === 0" type="text" size="small" @click="changeDetails(scope.row.attachListComplete)">查看</el-button>
  118. </template>
  119. </el-table-column>
  120. <el-table-column
  121. prop="historicalOperationRecords"
  122. header-align="center"
  123. align="center"
  124. width="160"
  125. :show-tooltip-when-overflow="true"
  126. label="操作记录"
  127. >
  128. </el-table-column>
  129. <el-table-column
  130. prop="nextOperator"
  131. header-align="center"
  132. align="center"
  133. min-width="140"
  134. :show-tooltip-when-overflow="true"
  135. label="下道工序"
  136. >
  137. </el-table-column>
  138. <el-table-column
  139. prop="backExplain"
  140. header-align="center"
  141. align="center"
  142. min-width="140"
  143. :show-tooltip-when-overflow="true"
  144. label="退回说明"
  145. >
  146. </el-table-column>
  147. <el-table-column
  148. prop="remark"
  149. header-align="center"
  150. align="center"
  151. min-width="160"
  152. :show-tooltip-when-overflow="true"
  153. label="备注"
  154. >
  155. </el-table-column>
  156. <el-table-column
  157. prop="receiverName"
  158. header-align="center"
  159. align="center"
  160. width="160"
  161. :show-tooltip-when-overflow="true"
  162. label="操作人"
  163. >
  164. </el-table-column>
  165. <el-table-column
  166. v-if="opColVisible"
  167. fixed="right"
  168. header-align="center"
  169. align="center"
  170. width="180"
  171. label="操作"
  172. >
  173. <template slot-scope="scope">
  174. <el-button
  175. v-if="isAuth('work:clt:start') && Number(scope.row.state) < 2"
  176. :disabled="Number(scope.row.state) === 0"
  177. type="text"
  178. size="small"
  179. @click="startTask(scope.row.taskId)"
  180. >开始</el-button
  181. >
  182. <!-- <el-button v-if="isAuth('work:clt:start')" type="text" size="small" @click="startTask(scope.row.taskId)">开始</el-button>-->
  183. <el-button
  184. v-if="isAuth('work:clt:transfer') && Number(scope.row.state) !== 3"
  185. type="text"
  186. size="small"
  187. @click="transferTask(scope.row)"
  188. >转单</el-button
  189. >
  190. <el-button
  191. v-if="
  192. isAuth('work:clt:complete') &&
  193. Number(scope.row.state) === 2 &&
  194. (scope.row.taskType == null ||
  195. scope.row.taskType === 'start' ||
  196. scope.row.taskType === 'produce' ||
  197. scope.row.taskType === 'routine')
  198. "
  199. type="text"
  200. size="small"
  201. @click="completeTask(scope.row.taskId)"
  202. >报工</el-button
  203. >
  204. <el-button
  205. v-if="
  206. isAuth('work:clt:check') &&
  207. Number(scope.row.state) === 2 &&
  208. (scope.row.taskType === 'check' ||
  209. scope.row.taskType === 't-check')
  210. "
  211. type="text"
  212. size="small"
  213. @click="checkTask(scope.row.taskId, 1)"
  214. >通过</el-button
  215. >
  216. <el-button
  217. v-if="
  218. isAuth('work:clt:check') &&
  219. Number(scope.row.state) === 2 &&
  220. (scope.row.taskType === 'check' ||
  221. scope.row.taskType === 't-check')
  222. "
  223. type="text"
  224. size="small"
  225. @click="checkTask(scope.row.taskId, 2)"
  226. >不通过</el-button
  227. >
  228. <el-button
  229. v-if="
  230. isAuth('work:clt:damage') &&
  231. Number(scope.row.state) === 2 &&
  232. (scope.row.taskType == null || scope.row.taskType === 'produce')
  233. "
  234. type="text"
  235. size="small"
  236. @click="damageTask(scope.row.nodeId, scope.row.productionId)"
  237. >报损</el-button
  238. >
  239. <el-button
  240. v-if="
  241. isAuth('work:clt:check') &&
  242. Number(scope.row.state) === 2 &&
  243. scope.row.taskType !== 'routine'
  244. "
  245. type="text"
  246. size="small"
  247. @click="submitTask(scope.row.nodeId, scope.row.productionId, scope.row.taskId)"
  248. >提审理单</el-button
  249. >
  250. </template>
  251. </el-table-column>
  252. </el-table>
  253. <el-pagination
  254. @size-change="sizeChangeHandle"
  255. @current-change="currentChangeHandle"
  256. :current-page="pageIndex"
  257. :page-sizes="[10, 20, 50, 100]"
  258. :page-size="pageSize"
  259. :total="totalPage"
  260. layout="total, sizes, prev, pager, next, jumper"
  261. >
  262. </el-pagination>
  263. <el-dialog
  264. title="移交任务"
  265. width="30%"
  266. :visible.sync="transferDialogFormVisible"
  267. >
  268. <el-form
  269. :model="transferDialogForm"
  270. :rules="transferDialogFormRules"
  271. ref="transferDialogForm"
  272. >
  273. <!-- <el-form-item label="检验类型" prop="checkType" label-width="120px">
  274. <el-select v-model="transferDialogForm.checkType" placeholder="请选择检验类型">
  275. <el-option label="通过" value="1"></el-option>
  276. <el-option label="不通过" value="2"></el-option>
  277. </el-select>
  278. </el-form-item> -->
  279. <el-form-item label="移交类型" prop="transferType" label-width="120px">
  280. <el-select
  281. v-model="transferDialogForm.transferType"
  282. placeholder="请选择移交类型"
  283. >
  284. <el-option label="工作移交" value="1"></el-option>
  285. </el-select>
  286. </el-form-item>
  287. <el-form-item
  288. label="移交用户"
  289. prop="transferUserId"
  290. label-width="120px"
  291. >
  292. <user-component v-if="transferDialogForm.taskType === 'routine'" v-model="transferDialogForm.transferUserId" :user-id.sync="transferDialogForm.transferUserId"></user-component>
  293. <el-select
  294. v-else
  295. v-model="transferDialogForm.transferUserId"
  296. placeholder="请选择移交用户"
  297. >
  298. <el-option
  299. v-for="item in transferUserList"
  300. :key="item.userId"
  301. :label="item.name"
  302. :value="item.userId"
  303. >
  304. </el-option>
  305. </el-select>
  306. </el-form-item>
  307. <el-form-item
  308. label="移交说明"
  309. prop="transferExplain"
  310. label-width="120px"
  311. >
  312. <el-input
  313. v-model="transferDialogForm.transferExplain"
  314. placeholder="请输入"
  315. ></el-input>
  316. </el-form-item>
  317. </el-form>
  318. <div slot="footer">
  319. <el-button @click="transferDialogFormVisible = false">取 消</el-button>
  320. <el-button type="primary" @click="transferSubmit" v-reClick>确 定</el-button>
  321. </div>
  322. </el-dialog>
  323. <el-dialog
  324. title="检验任务"
  325. width="50%"
  326. :visible.sync="checkDialogFormVisible"
  327. >
  328. <el-form
  329. :model="checkDialogForm"
  330. :rules="checkDialogFormRules"
  331. ref="checkDialogForm"
  332. >
  333. <el-form-item
  334. label="完成记录说明"
  335. prop="operationRecords"
  336. label-width="120px"
  337. >
  338. <el-input
  339. v-model="checkDialogForm.operationRecords"
  340. type="textarea"
  341. :rows="2"
  342. placeholder="请输入"
  343. ></el-input>
  344. </el-form-item>
  345. <el-form-item label="附件" prop="attachList" label-width="120px">
  346. <upload-component :accept="'*'" v-model="checkDialogForm.attachList" />
  347. </el-form-item>
  348. <el-form-item label="发生工序节点" prop="disqualificationNodeId" label-width="120px" v-if="checkDialogForm.checkType === 2">
  349. <el-select v-model="checkDialogForm.disqualificationNodeId">
  350. <el-option v-for="item in techOptions" :key="item.id" :value="item.id" :label="item.nodeName"></el-option>
  351. </el-select>
  352. </el-form-item>
  353. <el-row v-if="checkDialogForm.checkType !== 2">
  354. <el-table
  355. :data="checkDialogForm.prodProductionRecordList"
  356. style="width: 100%"
  357. >
  358. <el-table-column prop="pageNo" label="页次/图区"> </el-table-column>
  359. <el-table-column prop="inspectionParam" label="检查参数">
  360. </el-table-column>
  361. <el-table-column prop="inspectionMethod" label="检验方法">
  362. <template slot-scope="scope">
  363. <span>{{
  364. inspectionMethodOptions[scope.row.inspectionMethod]
  365. }}</span>
  366. </template>
  367. </el-table-column>
  368. <el-table-column prop="allowValues" label="允许值">
  369. </el-table-column>
  370. <el-table-column prop="measureRecord1" label="实测记录1">
  371. <template slot-scope="scope">
  372. <el-form-item
  373. :prop="
  374. 'prodProductionRecordList.' +
  375. scope.$index +
  376. '.measureRecord1'
  377. "
  378. :rules="checkDialogFormRules.measureRecord1"
  379. label-width="0px"
  380. >
  381. <el-input v-model="scope.row.measureRecord1"></el-input>
  382. </el-form-item>
  383. </template>
  384. </el-table-column>
  385. <el-table-column prop="measureRecord2" label="实测纪录2">
  386. <template slot-scope="scope">
  387. <el-form-item
  388. :prop="
  389. 'prodProductionRecordList.' +
  390. scope.$index +
  391. '.measureRecord2'
  392. "
  393. :rules="checkDialogFormRules.measureRecord2"
  394. label-width="0px"
  395. >
  396. <el-input v-model="scope.row.measureRecord2"></el-input>
  397. </el-form-item>
  398. </template>
  399. </el-table-column>
  400. <el-table-column prop="remarks" label="备注">
  401. <template slot-scope="scope">
  402. <el-form-item
  403. :prop="
  404. 'prodProductionRecordList.' + scope.$index + '.remarks'
  405. "
  406. label-width="0px"
  407. >
  408. <el-input v-model="scope.row.remarks"></el-input>
  409. </el-form-item>
  410. </template>
  411. </el-table-column>
  412. </el-table>
  413. </el-row>
  414. </el-form>
  415. <div slot="footer">
  416. <el-button @click="checkDialogFormVisible = false">取 消</el-button>
  417. <el-button type="primary" @click="checkSubmit" v-reClick>确 定</el-button>
  418. </div>
  419. </el-dialog>
  420. <el-dialog
  421. title="操作损坏"
  422. width="30%"
  423. :visible.sync="damageDialogFormVisible"
  424. >
  425. <el-form
  426. :model="damageDialogForm"
  427. :rules="damageDialogFormRules"
  428. ref="damageDialogForm"
  429. >
  430. <el-form-item label="损坏原因" prop="damageReason" label-width="80px">
  431. <el-input
  432. v-model="damageDialogForm.damageReason"
  433. type="textarea"
  434. :rows="2"
  435. placeholder="请输入"
  436. ></el-input>
  437. </el-form-item>
  438. </el-form>
  439. <div slot="footer">
  440. <el-button @click="damageDialogFormVisible = false">取 消</el-button>
  441. <el-button type="primary" @click="damageSubmit" v-reClick>确 定</el-button>
  442. </div>
  443. </el-dialog>
  444. <el-dialog
  445. title="完成任务"
  446. width="30%"
  447. :visible.sync="finishDialogFormVisible"
  448. >
  449. <el-form
  450. :model="finishDialogForm"
  451. :rules="finishDialogFormRules"
  452. ref="finishDialogForm"
  453. >
  454. <el-form-item
  455. label="完成记录说明"
  456. prop="operationRecords"
  457. label-width="120px"
  458. >
  459. <el-input
  460. v-model="finishDialogForm.operationRecords"
  461. type="textarea"
  462. :rows="2"
  463. placeholder="请输入"
  464. ></el-input>
  465. </el-form-item>
  466. <el-form-item label="附件" prop="attachList" label-width="120px">
  467. <upload-component :accept="'*'" v-model="finishDialogForm.attachList" />
  468. </el-form-item>
  469. </el-form>
  470. <div slot="footer">
  471. <el-button @click="finishDialogFormVisible = false">取 消</el-button>
  472. <el-button type="primary" @click="finishSubmit" v-reClick>确 定</el-button>
  473. </div>
  474. </el-dialog>
  475. <!-- 提审理单 -->
  476. <el-dialog
  477. title="提审理单"
  478. width="50%"
  479. :visible.sync="submitDialogFormVisible"
  480. >
  481. <el-form
  482. :model="submitDialogForm"
  483. :rules="submitDialogFormRules"
  484. ref="submitDialogForm"
  485. >
  486. <el-form-item
  487. label="完成记录说明"
  488. prop="operationRecords"
  489. label-width="120px"
  490. >
  491. <el-input
  492. v-model="submitDialogForm.operationRecords"
  493. type="textarea"
  494. :rows="2"
  495. placeholder="请输入"
  496. ></el-input>
  497. </el-form-item>
  498. <el-form-item label="发生工序节点" prop="disqualificationNodeId" label-width="120px" >
  499. <el-select v-model="submitDialogForm.disqualificationNodeId">
  500. <el-option v-for="item in techOptions" :key="item.id" :value="item.id" :label="item.nodeName"></el-option>
  501. </el-select>
  502. </el-form-item>
  503. <el-form-item label="附件" prop="attachList" label-width="120px">
  504. <upload-component :accept="'*'" v-model="submitDialogForm.attachList" />
  505. </el-form-item>
  506. </el-form>
  507. <div slot="footer">
  508. <el-button @click="submitDialogFormVisible = false">取 消</el-button>
  509. <el-button type="primary" @click="submitSubmit" v-reClick>确 定</el-button>
  510. </div>
  511. </el-dialog>
  512. <!-- 文件预览 -->
  513. <preview-component v-if="previewVisible" ref="preview" />
  514. <attach-detail-dialog ref="attachDetail"/>
  515. </div>
  516. </template>
  517. <script>
  518. import {
  519. getMyTaskList,
  520. startTask,
  521. transferTask,
  522. completeTask,
  523. checkTask,
  524. damageTask,
  525. getTaskDetail,
  526. getTechList,
  527. batchStart,
  528. batchCheckTask,
  529. batchCompleteTask,
  530. submitTask
  531. } from '@/api/task'
  532. import { workTypeMasterList } from '@/api/worktype'
  533. import templateList from '../warehouse/template-list'
  534. import PreviewComponent from '../common/preview-component'
  535. import UserComponent from '@/views/modules/common/user-component'
  536. import { taskTypeOption, rankTypeOption } from '@/utils/enums'
  537. import AttachDetailDialog from '../common/attach-detail-dialog'
  538. import UploadComponent from '../common/upload-component-v2'
  539. export default {
  540. components: { UserComponent, PreviewComponent, templateList, AttachDetailDialog, UploadComponent },
  541. name: 'work',
  542. computed: {
  543. userId: {
  544. get () {
  545. return this.$store.state.user.id
  546. }
  547. }
  548. },
  549. watch: {
  550. 'dataForm.userId' (value) {
  551. this.opColVisible =
  552. Number(this.dataForm.state) !== 3 && value === this.userId
  553. },
  554. 'dataForm.state' (value) {
  555. this.opColVisible = this.dataForm.userId
  556. ? Number(value) !== 3 && this.dataForm.userId === this.userId
  557. : Number(value) !== 3
  558. }
  559. },
  560. data () {
  561. return {
  562. previewVisible: false,
  563. addOrUpdateVisible: false,
  564. opColVisible: true,
  565. dataForm: {
  566. state: '1'
  567. },
  568. dataList: [],
  569. pageIndex: 1,
  570. pageSize: 10,
  571. totalPage: 0,
  572. dataListLoading: false,
  573. dataListSelections: [],
  574. // optionsState: [
  575. // {
  576. // code: '1',
  577. // value: '未开始'
  578. // },
  579. // {
  580. // code: '2',
  581. // value: '待操作'
  582. // },
  583. // {
  584. // code: '3',
  585. // value: '已完成'
  586. // }
  587. // ],
  588. transferDialogFormVisible: false,
  589. transferDialogForm: {},
  590. finishDialogFormVisible: false,
  591. finishDialogForm: {},
  592. finishDialogFormRules: {
  593. operationRecords: [
  594. { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
  595. ]
  596. },
  597. transferUserList: [],
  598. transferDialogFormRules: {
  599. transferType: [
  600. { required: true, message: '请选择移交类型', trigger: 'blur' }
  601. ],
  602. transferUserId: [
  603. { required: true, message: '请选择移交用户', trigger: 'blur' }
  604. ]
  605. },
  606. checkDialogFormVisible: false,
  607. checkDialogForm: {
  608. checkType: '',
  609. operationRecords: '',
  610. notes: '',
  611. prodProductionRecordList: []
  612. },
  613. checkDialogBatch: false, // 是否是批量操作
  614. checkDialogFormRules: {
  615. operationRecords: [
  616. { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
  617. ],
  618. checkType: [{ required: true, message: '请选择', trigger: 'blur' }],
  619. disqualificationNodeId: [{ required: true, message: '请选择', trigger: 'blur' }],
  620. measureRecord1: [
  621. { required: true, message: '请输入', trigger: 'blur' }
  622. ],
  623. measureRecord2: [
  624. { required: true, message: '请输入', trigger: 'blur' }
  625. ]
  626. },
  627. damageDialogFormVisible: false,
  628. damageDialogForm: {},
  629. damageDialogFormRules: {
  630. damageReason: [{ required: true, message: '请输入', trigger: 'blur' }]
  631. },
  632. // 是否显示进度条列
  633. showProgress: true,
  634. inspectionMethodOptions: {
  635. 1: '游标卡尺',
  636. 2: '千分尺',
  637. 3: '高度尺',
  638. 4: '百分表',
  639. 5: 'R规',
  640. 6: '环规、塞规',
  641. 7: '游标角度尺',
  642. 8: '三坐标',
  643. 9: '模具',
  644. 10: '样板',
  645. 11: '夹具',
  646. 12: '目测',
  647. 13: '组合测量',
  648. 14: '精密测量',
  649. 15: '敲击',
  650. 16: '测厚仪',
  651. 17: '其他'
  652. },
  653. taskTypeOption: taskTypeOption,
  654. rankTypeOption: rankTypeOption,
  655. techOptions: [],
  656. multipleSelection: [], // 多选的数据
  657. submitDialogFormVisible: false,
  658. submitDialogForm: {
  659. taskId: undefined,
  660. operationRecords: '',
  661. notes: '',
  662. prodProductionRecordList: []
  663. },
  664. submitDialogFormRules: {
  665. operationRecords: [
  666. { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
  667. ],
  668. disqualificationNodeId: [{ required: true, message: '请选择', trigger: 'blur' }]
  669. }
  670. }
  671. },
  672. created () {
  673. let state = this.$route.query.state
  674. if (state) {
  675. this.dataForm.state = state
  676. }
  677. this.getDataList()
  678. },
  679. methods: {
  680. // 查询
  681. queryData () {
  682. this.pageIndex = 1
  683. this.showProgress = this.dataForm.state !== '2'
  684. this.getDataList()
  685. },
  686. // 获取数据列表
  687. getDataList () {
  688. this.dataListLoading = true
  689. let params = {
  690. current: this.pageIndex,
  691. size: this.pageSize,
  692. state: this.dataForm.state,
  693. userId: this.dataForm.userId ? this.dataForm.userId : null
  694. }
  695. getMyTaskList(params).then(({ data }) => {
  696. if (data && data.code === '200') {
  697. this.dataList = data.data.records
  698. this.totalPage = Number(data.data.total)
  699. } else {
  700. this.dataList = []
  701. this.totalPage = 0
  702. }
  703. this.dataListLoading = false
  704. })
  705. },
  706. // 每页数
  707. sizeChangeHandle (val) {
  708. this.pageSize = val
  709. this.pageIndex = 1
  710. this.getDataList()
  711. },
  712. // 当前页
  713. currentChangeHandle (val) {
  714. this.pageIndex = val
  715. this.getDataList()
  716. },
  717. // 多选
  718. selectionChangeHandle (val) {
  719. this.dataListSelections = val
  720. },
  721. // 开始
  722. startTask (taskId) {
  723. this.$confirm('是否开始任务?', '提示', {
  724. confirmButtonText: '确定',
  725. cancelButtonText: '取消',
  726. type: 'warning'
  727. })
  728. .then(() => {
  729. startTask({ taskId }).then(({ data }) => {
  730. if (data && data.code === '200') {
  731. this.$message({
  732. type: 'success',
  733. message: '操作成功!'
  734. })
  735. this.getDataList()
  736. } else {
  737. this.$message({
  738. type: 'error',
  739. message: data.msg
  740. })
  741. }
  742. })
  743. })
  744. .catch(() => {
  745. this.$message({
  746. type: 'info',
  747. message: '已取消'
  748. })
  749. })
  750. },
  751. // 移交
  752. transferTask (item) {
  753. let {taskId, workTypeId, taskType} = item
  754. this.transferDialogFormVisible = true
  755. this.transferDialogForm.taskId = taskId
  756. this.transferDialogForm.taskType = taskType
  757. if (taskType !== 'routine') {
  758. workTypeMasterList(workTypeId).then(({ data }) => {
  759. if (data && data.code === '200') {
  760. this.transferUserList = data.data
  761. }
  762. })
  763. }
  764. },
  765. // 确认移交
  766. transferSubmit () {
  767. this.$refs['transferDialogForm'].validate((valid) => {
  768. if (valid) {
  769. transferTask(this.transferDialogForm).then(({ data }) => {
  770. if (data && data.code === '200') {
  771. this.$message({
  772. type: 'success',
  773. message: '移交成功!'
  774. })
  775. this.transferDialogFormVisible = false
  776. this.getDataList()
  777. } else {
  778. this.$message({
  779. type: 'error',
  780. message: data.msg
  781. })
  782. }
  783. })
  784. }
  785. })
  786. },
  787. // 完成
  788. completeTask (taskId) {
  789. this.finishDialogFormVisible = true
  790. this.finishDialogForm.taskId = taskId
  791. },
  792. // 确认完成
  793. finishSubmit () {
  794. this.$refs['finishDialogForm'].validate((valid) => {
  795. if (valid) {
  796. let submitData = this.finishDialogForm
  797. if (this.checkDialogBatch) {
  798. // 批量
  799. batchCompleteTask(submitData).then(({ data }) => {
  800. if (data && data.code === '200') {
  801. this.$message({
  802. type: 'success',
  803. message: '操作成功!'
  804. })
  805. this.finishDialogFormVisible = false
  806. this.checkDialogBatch = false
  807. this.getDataList()
  808. } else {
  809. this.$message({
  810. type: 'error',
  811. message: data.msg
  812. })
  813. }
  814. })
  815. } else {
  816. completeTask(submitData).then(({ data }) => {
  817. if (data && data.code === '200') {
  818. this.$message({
  819. type: 'success',
  820. message: '操作成功!'
  821. })
  822. this.finishDialogFormVisible = false
  823. this.getDataList()
  824. } else {
  825. this.$message({
  826. type: 'error',
  827. message: data.msg
  828. })
  829. }
  830. })
  831. }
  832. }
  833. })
  834. },
  835. // 检验
  836. checkTask (taskId, checkType) {
  837. this.checkDialogForm.taskId = taskId
  838. if (checkType === 1) {
  839. // 查询工艺详情
  840. getTaskDetail(this.checkDialogForm.taskId).then(({ data }) => {
  841. if (data && data.code === '200') {
  842. let list = data.data.prodProductionRequireList
  843. if (list && list.length > 0) {
  844. list.map((item) => {
  845. item.requireId = item.id
  846. })
  847. }
  848. this.checkDialogForm.prodProductionRecordList = list
  849. }
  850. })
  851. this.checkDialogForm.checkType = checkType
  852. this.passTask()
  853. } else {
  854. this.checkDialogForm.checkType = 2
  855. getTechList(this.checkDialogForm.taskId).then(({data}) => {
  856. if (data && data.code === '200') {
  857. this.techOptions = data.data
  858. }
  859. })
  860. this.refuseTask()
  861. }
  862. },
  863. // 通过
  864. passTask () {
  865. this.checkDialogFormVisible = true
  866. },
  867. // 不通过
  868. refuseTask () {
  869. this.checkDialogFormVisible = true
  870. },
  871. // 确认检验
  872. checkSubmit () {
  873. this.$refs['checkDialogForm'].validate((valid) => {
  874. if (valid) {
  875. let submitData = this.checkDialogForm
  876. // console.log(submitData);
  877. if (this.checkDialogBatch) {
  878. batchCheckTask(submitData).then(({ data }) => {
  879. if (data && data.code === '200') {
  880. this.$message({
  881. type: 'success',
  882. message: '批量检验成功!'
  883. })
  884. this.checkDialogFormVisible = false
  885. this.checkDialogBatch = false
  886. this.getDataList()
  887. } else {
  888. this.$message({
  889. type: 'error',
  890. message: data.msg
  891. })
  892. }
  893. })
  894. } else {
  895. checkTask(submitData).then(({ data }) => {
  896. if (data && data.code === '200') {
  897. this.$message({
  898. type: 'success',
  899. message: '检验成功!'
  900. })
  901. this.checkDialogFormVisible = false
  902. this.getDataList()
  903. } else {
  904. this.$message({
  905. type: 'error',
  906. message: data.msg
  907. })
  908. }
  909. })
  910. }
  911. }
  912. })
  913. },
  914. // 操作损坏
  915. damageTask (nodeId, productionId) {
  916. this.damageDialogFormVisible = true
  917. this.damageDialogForm.nodeId = nodeId
  918. this.damageDialogForm.productionId = productionId
  919. },
  920. // 确认操作损坏
  921. damageSubmit () {
  922. this.$refs['damageDialogForm'].validate((valid) => {
  923. if (valid) {
  924. let submitData = this.damageDialogForm
  925. damageTask(submitData).then(({ data }) => {
  926. if (data && data.code === '200') {
  927. this.$message({
  928. type: 'success',
  929. message: '操作成功!'
  930. })
  931. this.damageDialogFormVisible = false
  932. this.getDataList()
  933. } else {
  934. this.$message({
  935. type: 'error',
  936. message: data.msg
  937. })
  938. }
  939. })
  940. }
  941. })
  942. },
  943. // 预览
  944. previewFile (fileName, url) {
  945. this.previewVisible = true
  946. this.$nextTick(() => {
  947. this.$refs.preview.init(fileName, url)
  948. })
  949. },
  950. // 计算进度百分比,返回0到100的整数
  951. getPercentage (completeNum, totalNum) {
  952. completeNum = completeNum == null ? 0 : parseInt(completeNum)
  953. totalNum = totalNum == null ? 100 : parseInt(totalNum)
  954. if (totalNum === 0) {
  955. return 100
  956. }
  957. return (completeNum / totalNum).toFixed(2) * 100
  958. },
  959. // 用户选择
  960. userChanged (val) {
  961. this.dataForm.userId = val
  962. this.getDataList()
  963. },
  964. changeDetails (attachList) {
  965. this.$nextTick(() => {
  966. this.$refs.attachDetail.init(attachList)
  967. })
  968. },
  969. // 多选-选中事件
  970. handleSelectionChange (val) {
  971. this.multipleSelection = val
  972. },
  973. selected (row, index) {
  974. if (this.multipleSelection.length === 0) {
  975. return true
  976. }
  977. if (this.multipleSelection.length > 0 && this.multipleSelection[0].nodeId === row.nodeId) {
  978. return true
  979. }
  980. return false
  981. },
  982. // 批量开始
  983. batchStart () {
  984. this.$confirm('是否批量开始任务?', '提示', {
  985. confirmButtonText: '确定',
  986. cancelButtonText: '取消',
  987. type: 'warning'
  988. })
  989. .then(() => {
  990. if (this.multipleSelection.length === 0) {
  991. this.$message({
  992. type: 'error',
  993. message: '请先选择数据,再操作批量开始'
  994. })
  995. } else {
  996. let param = {
  997. taskIds: this.multipleSelection.map(t => t.taskId)
  998. }
  999. batchStart(param).then(({ data }) => {
  1000. if (data && data.code === '200') {
  1001. this.$message({
  1002. type: 'success',
  1003. message: '操作成功!'
  1004. })
  1005. this.multipleSelection = []
  1006. this.queryData()
  1007. } else {
  1008. this.$message({
  1009. type: 'error',
  1010. message: data.msg
  1011. })
  1012. }
  1013. })
  1014. }
  1015. })
  1016. .catch(() => {
  1017. this.$message({
  1018. type: 'info',
  1019. message: '已取消'
  1020. })
  1021. })
  1022. },
  1023. // 批量报工 或 批量通过
  1024. batchFinishOrCheck () {
  1025. this.checkDialogBatch = true
  1026. this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1027. // 检验、总检 -> 批量通过
  1028. if (this.multipleSelection[0].taskType === 'check' || this.multipleSelection[0].taskType === 't-check') {
  1029. this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1030. this.checkTask(this.checkDialogForm.taskIds[0], 1)
  1031. }
  1032. // 常规 -> 批量报工
  1033. if (this.multipleSelection[0].taskType === 'routine' || this.multipleSelection[0].taskType === 'produce' || this.multipleSelection[0].taskType === 'start') {
  1034. this.finishDialogFormVisible = true
  1035. this.finishDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1036. }
  1037. },
  1038. submitTask (nodeId, productionId, taskId) {
  1039. this.submitDialogForm = {
  1040. taskIds: [taskId]
  1041. }
  1042. getTechList(taskId).then(({data}) => {
  1043. if (data && data.code === '200') {
  1044. this.techOptions = data.data
  1045. }
  1046. })
  1047. this.submitDialogFormVisible = true
  1048. },
  1049. submitSubmit () {
  1050. this.$refs['submitDialogForm'].validate((valid) => {
  1051. if (valid) {
  1052. submitTask(this.submitDialogForm).then(({ data }) => {
  1053. if (data && data.code === '200') {
  1054. this.$message({
  1055. type: 'success',
  1056. message: '操作成功!'
  1057. })
  1058. this.submitDialogFormVisible = false
  1059. this.getDataList()
  1060. } else {
  1061. this.$message({
  1062. type: 'error',
  1063. message: data.msg
  1064. })
  1065. }
  1066. })
  1067. }
  1068. })
  1069. }
  1070. }
  1071. }
  1072. </script>
  1073. <style lang="scss" scoped>
  1074. /deep/ .el-tabs .el-tabs__header {
  1075. margin: 0;
  1076. }
  1077. </style>