work.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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)"
  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. operationRecords: '',
  660. notes: '',
  661. prodProductionRecordList: []
  662. },
  663. submitDialogFormRules: {
  664. operationRecords: [
  665. { required: true, message: '完成记录说明不能为空', trigger: 'blur' }
  666. ],
  667. disqualificationNodeId: [{ required: true, message: '请选择', trigger: 'blur' }]
  668. }
  669. }
  670. },
  671. created () {
  672. let state = this.$route.query.state
  673. if (state) {
  674. this.dataForm.state = state
  675. }
  676. this.getDataList()
  677. },
  678. methods: {
  679. // 查询
  680. queryData () {
  681. this.pageIndex = 1
  682. this.showProgress = this.dataForm.state !== '2'
  683. this.getDataList()
  684. },
  685. // 获取数据列表
  686. getDataList () {
  687. this.dataListLoading = true
  688. let params = {
  689. current: this.pageIndex,
  690. size: this.pageSize,
  691. state: this.dataForm.state,
  692. userId: this.dataForm.userId ? this.dataForm.userId : null
  693. }
  694. getMyTaskList(params).then(({ data }) => {
  695. if (data && data.code === '200') {
  696. this.dataList = data.data.records
  697. this.totalPage = Number(data.data.total)
  698. } else {
  699. this.dataList = []
  700. this.totalPage = 0
  701. }
  702. this.dataListLoading = false
  703. })
  704. },
  705. // 每页数
  706. sizeChangeHandle (val) {
  707. this.pageSize = val
  708. this.pageIndex = 1
  709. this.getDataList()
  710. },
  711. // 当前页
  712. currentChangeHandle (val) {
  713. this.pageIndex = val
  714. this.getDataList()
  715. },
  716. // 多选
  717. selectionChangeHandle (val) {
  718. this.dataListSelections = val
  719. },
  720. // 开始
  721. startTask (taskId) {
  722. this.$confirm('是否开始任务?', '提示', {
  723. confirmButtonText: '确定',
  724. cancelButtonText: '取消',
  725. type: 'warning'
  726. })
  727. .then(() => {
  728. startTask({ taskId }).then(({ data }) => {
  729. if (data && data.code === '200') {
  730. this.$message({
  731. type: 'success',
  732. message: '操作成功!'
  733. })
  734. this.getDataList()
  735. } else {
  736. this.$message({
  737. type: 'error',
  738. message: data.msg
  739. })
  740. }
  741. })
  742. })
  743. .catch(() => {
  744. this.$message({
  745. type: 'info',
  746. message: '已取消'
  747. })
  748. })
  749. },
  750. // 移交
  751. transferTask (item) {
  752. let {taskId, workTypeId, taskType} = item
  753. this.transferDialogFormVisible = true
  754. this.transferDialogForm.taskId = taskId
  755. this.transferDialogForm.taskType = taskType
  756. if (taskType !== 'routine') {
  757. workTypeMasterList(workTypeId).then(({ data }) => {
  758. if (data && data.code === '200') {
  759. this.transferUserList = data.data
  760. }
  761. })
  762. }
  763. },
  764. // 确认移交
  765. transferSubmit () {
  766. this.$refs['transferDialogForm'].validate((valid) => {
  767. if (valid) {
  768. transferTask(this.transferDialogForm).then(({ data }) => {
  769. if (data && data.code === '200') {
  770. this.$message({
  771. type: 'success',
  772. message: '移交成功!'
  773. })
  774. this.transferDialogFormVisible = false
  775. this.getDataList()
  776. } else {
  777. this.$message({
  778. type: 'error',
  779. message: data.msg
  780. })
  781. }
  782. })
  783. }
  784. })
  785. },
  786. // 完成
  787. completeTask (taskId) {
  788. this.finishDialogFormVisible = true
  789. this.finishDialogForm.taskId = taskId
  790. },
  791. // 确认完成
  792. finishSubmit () {
  793. this.$refs['finishDialogForm'].validate((valid) => {
  794. if (valid) {
  795. let submitData = this.finishDialogForm
  796. if (this.checkDialogBatch) {
  797. // 批量
  798. batchCompleteTask(submitData).then(({ data }) => {
  799. if (data && data.code === '200') {
  800. this.$message({
  801. type: 'success',
  802. message: '操作成功!'
  803. })
  804. this.finishDialogFormVisible = false
  805. this.checkDialogBatch = false
  806. this.getDataList()
  807. } else {
  808. this.$message({
  809. type: 'error',
  810. message: data.msg
  811. })
  812. }
  813. })
  814. } else {
  815. completeTask(submitData).then(({ data }) => {
  816. if (data && data.code === '200') {
  817. this.$message({
  818. type: 'success',
  819. message: '操作成功!'
  820. })
  821. this.finishDialogFormVisible = false
  822. this.getDataList()
  823. } else {
  824. this.$message({
  825. type: 'error',
  826. message: data.msg
  827. })
  828. }
  829. })
  830. }
  831. }
  832. })
  833. },
  834. // 检验
  835. checkTask (taskId, checkType) {
  836. this.checkDialogForm.taskId = taskId
  837. if (checkType === 1) {
  838. // 查询工艺详情
  839. getTaskDetail(this.checkDialogForm.taskId).then(({ data }) => {
  840. if (data && data.code === '200') {
  841. let list = data.data.prodProductionRequireList
  842. if (list && list.length > 0) {
  843. list.map((item) => {
  844. item.requireId = item.id
  845. })
  846. }
  847. this.checkDialogForm.prodProductionRecordList = list
  848. }
  849. })
  850. this.checkDialogForm.checkType = checkType
  851. this.passTask()
  852. } else {
  853. this.checkDialogForm.checkType = 2
  854. getTechList(this.checkDialogForm.taskId).then(({data}) => {
  855. if (data && data.code === '200') {
  856. this.techOptions = data.data
  857. }
  858. })
  859. this.refuseTask()
  860. }
  861. },
  862. // 通过
  863. passTask () {
  864. this.checkDialogFormVisible = true
  865. },
  866. // 不通过
  867. refuseTask () {
  868. this.checkDialogFormVisible = true
  869. },
  870. // 确认检验
  871. checkSubmit () {
  872. this.$refs['checkDialogForm'].validate((valid) => {
  873. if (valid) {
  874. let submitData = this.checkDialogForm
  875. // console.log(submitData);
  876. if (this.checkDialogBatch) {
  877. batchCheckTask(submitData).then(({ data }) => {
  878. if (data && data.code === '200') {
  879. this.$message({
  880. type: 'success',
  881. message: '批量检验成功!'
  882. })
  883. this.checkDialogFormVisible = false
  884. this.checkDialogBatch = false
  885. this.getDataList()
  886. } else {
  887. this.$message({
  888. type: 'error',
  889. message: data.msg
  890. })
  891. }
  892. })
  893. } else {
  894. checkTask(submitData).then(({ data }) => {
  895. if (data && data.code === '200') {
  896. this.$message({
  897. type: 'success',
  898. message: '检验成功!'
  899. })
  900. this.checkDialogFormVisible = false
  901. this.getDataList()
  902. } else {
  903. this.$message({
  904. type: 'error',
  905. message: data.msg
  906. })
  907. }
  908. })
  909. }
  910. }
  911. })
  912. },
  913. // 操作损坏
  914. damageTask (nodeId, productionId) {
  915. this.damageDialogFormVisible = true
  916. this.damageDialogForm.nodeId = nodeId
  917. this.damageDialogForm.productionId = productionId
  918. },
  919. // 确认操作损坏
  920. damageSubmit () {
  921. this.$refs['damageDialogForm'].validate((valid) => {
  922. if (valid) {
  923. let submitData = this.damageDialogForm
  924. damageTask(submitData).then(({ data }) => {
  925. if (data && data.code === '200') {
  926. this.$message({
  927. type: 'success',
  928. message: '操作成功!'
  929. })
  930. this.damageDialogFormVisible = false
  931. this.getDataList()
  932. } else {
  933. this.$message({
  934. type: 'error',
  935. message: data.msg
  936. })
  937. }
  938. })
  939. }
  940. })
  941. },
  942. // 预览
  943. previewFile (fileName, url) {
  944. this.previewVisible = true
  945. this.$nextTick(() => {
  946. this.$refs.preview.init(fileName, url)
  947. })
  948. },
  949. // 计算进度百分比,返回0到100的整数
  950. getPercentage (completeNum, totalNum) {
  951. completeNum = completeNum == null ? 0 : parseInt(completeNum)
  952. totalNum = totalNum == null ? 100 : parseInt(totalNum)
  953. if (totalNum === 0) {
  954. return 100
  955. }
  956. return (completeNum / totalNum).toFixed(2) * 100
  957. },
  958. // 用户选择
  959. userChanged (val) {
  960. this.dataForm.userId = val
  961. this.getDataList()
  962. },
  963. changeDetails (attachList) {
  964. this.$nextTick(() => {
  965. this.$refs.attachDetail.init(attachList)
  966. })
  967. },
  968. // 多选-选中事件
  969. handleSelectionChange (val) {
  970. this.multipleSelection = val
  971. },
  972. selected (row, index) {
  973. if (this.multipleSelection.length === 0) {
  974. return true
  975. }
  976. if (this.multipleSelection.length > 0 && this.multipleSelection[0].nodeId === row.nodeId) {
  977. return true
  978. }
  979. return false
  980. },
  981. // 批量开始
  982. batchStart () {
  983. this.$confirm('是否批量开始任务?', '提示', {
  984. confirmButtonText: '确定',
  985. cancelButtonText: '取消',
  986. type: 'warning'
  987. })
  988. .then(() => {
  989. if (this.multipleSelection.length === 0) {
  990. this.$message({
  991. type: 'error',
  992. message: '请先选择数据,再操作批量开始'
  993. })
  994. } else {
  995. let param = {
  996. taskIds: this.multipleSelection.map(t => t.taskId)
  997. }
  998. batchStart(param).then(({ data }) => {
  999. if (data && data.code === '200') {
  1000. this.$message({
  1001. type: 'success',
  1002. message: '操作成功!'
  1003. })
  1004. this.multipleSelection = []
  1005. this.queryData()
  1006. } else {
  1007. this.$message({
  1008. type: 'error',
  1009. message: data.msg
  1010. })
  1011. }
  1012. })
  1013. }
  1014. })
  1015. .catch(() => {
  1016. this.$message({
  1017. type: 'info',
  1018. message: '已取消'
  1019. })
  1020. })
  1021. },
  1022. // 批量报工 或 批量通过
  1023. batchFinishOrCheck () {
  1024. this.checkDialogBatch = true
  1025. this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1026. // 检验、总检 -> 批量通过
  1027. if (this.multipleSelection[0].taskType === 'check' || this.multipleSelection[0].taskType === 't-check') {
  1028. this.checkDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1029. this.checkTask(this.checkDialogForm.taskIds[0], 1)
  1030. }
  1031. // 常规 -> 批量报工
  1032. if (this.multipleSelection[0].taskType === 'routine' || this.multipleSelection[0].taskType === 'produce' || this.multipleSelection[0].taskType === 'start') {
  1033. this.finishDialogFormVisible = true
  1034. this.finishDialogForm.taskIds = this.multipleSelection.map(t => t.taskId)
  1035. }
  1036. },
  1037. submitTask () {
  1038. this.submitDialogFormVisible = true
  1039. },
  1040. submitSubmit () {
  1041. this.$refs['submitDialogForm'].validate((valid) => {
  1042. if (valid) {
  1043. let submitData = this.submitDialogForm
  1044. submitTask(submitData).then(({ data }) => {
  1045. if (data && data.code === '200') {
  1046. this.$message({
  1047. type: 'success',
  1048. message: '操作成功!'
  1049. })
  1050. this.damageDialogFormVisible = false
  1051. this.getDataList()
  1052. } else {
  1053. this.$message({
  1054. type: 'error',
  1055. message: data.msg
  1056. })
  1057. }
  1058. })
  1059. }
  1060. })
  1061. }
  1062. }
  1063. }
  1064. </script>
  1065. <style lang="scss" scoped>
  1066. /deep/ .el-tabs .el-tabs__header {
  1067. margin: 0;
  1068. }
  1069. </style>