index.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  1. <template>
  2. <ele-modal
  3. :before-close="cancel"
  4. :close-on-click-modal="false"
  5. :maxable="true"
  6. title="任务派单"
  7. :visible.sync="dispatchVisible"
  8. :width="modelWidth"
  9. append-to-body
  10. custom-class="ele-dialog-form"
  11. >
  12. <div class="form-wrapper">
  13. <el-form
  14. ref="form"
  15. :inline="true"
  16. :model="form"
  17. label-position="right"
  18. label-width="100px"
  19. >
  20. <el-row :gutter="10" class="basic" style="flex-wrap: wrap" type="flex">
  21. <el-col
  22. v-for="item in fieldList"
  23. :key="item.prop"
  24. :lg="8"
  25. :md="12"
  26. :sm="12"
  27. :xl="6"
  28. :xs="12"
  29. >
  30. <el-form-item :label="item.label">
  31. <!-- <div class="item_label">{{ current[item.prop] }}</div> -->
  32. <el-input v-model="current[item.prop]" disabled />
  33. </el-form-item>
  34. </el-col>
  35. </el-row>
  36. <el-row :gutter="10">
  37. <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
  38. <el-form-item label="所属工厂:">
  39. <el-input v-model="form.factoryName" :disabled="true"></el-input>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
  43. <el-form-item label="所属工作中心:">
  44. <el-select
  45. v-model="form.workCenterId"
  46. placeholder="请选择"
  47. style="width: 100%"
  48. @change="changeWork"
  49. >
  50. <el-option
  51. v-for="item in workCenterList"
  52. :key="item.centerId"
  53. :label="item.centerName"
  54. :value="item.centerId"
  55. >
  56. </el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :lg="8" :md="12" :sm="12" :xl="6" :xs="12">
  61. <el-form-item label="所属班组:" required>
  62. <el-select
  63. v-model="form.teamId"
  64. placeholder="请选择"
  65. style="width: 100%"
  66. @change="changeGroups"
  67. >
  68. <el-option
  69. v-for="item in teamList"
  70. :key="item.teamId"
  71. :label="item.teamName"
  72. :value="item.teamId"
  73. >
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <el-tabs
  80. v-model="processId"
  81. v-loading="tabsLoading"
  82. class="process_list"
  83. style="margin-bottom: 20px"
  84. type="border-card"
  85. @tab-click="handleClick"
  86. >
  87. <el-tab-pane
  88. v-for="(item, index) in processList"
  89. :key="item.id"
  90. :label="item.name"
  91. :name="item.id"
  92. >
  93. <span style="color: green">
  94. 工序编码:{{ item.code }},所属工作中心:{{
  95. item.workCenterName
  96. }}</span
  97. >
  98. <ele-pro-table
  99. :ref="`tableRef${index}`"
  100. v-loading="tabLoading"
  101. :columns="columns"
  102. :datasource="item.list"
  103. :pageSize="20"
  104. :selection.sync="item.selection"
  105. cache-key="systemRoleTable"
  106. row-key="id"
  107. class="table"
  108. >
  109. <template v-slot:toolbar>
  110. <div style="display: inline-block" v-if="!item.isSpecialField">
  111. <el-button
  112. :loading="toolbarLoading"
  113. type="primary"
  114. @click="dispatch(item, 1)"
  115. :disabled="!item.isDisable"
  116. >
  117. 派单
  118. </el-button>
  119. <el-button
  120. :loading="toolbarLoading"
  121. type="primary"
  122. @click="dispatch(item, 2)"
  123. :disabled="!item.isDisable"
  124. >
  125. 撤回
  126. </el-button>
  127. <el-button
  128. :loading="toolbarLoading"
  129. type="primary"
  130. @click="dispatch(item, 3)"
  131. :disabled="!item.isDisable"
  132. >
  133. 保存
  134. </el-button>
  135. </div>
  136. <div
  137. style="margin-left: 50px; display: inline-block"
  138. v-if="!item.isSpecialField"
  139. >
  140. <span
  141. class="text"
  142. style="
  143. font-weight: bold;
  144. font-size: 14px;
  145. margin-right: 8px;
  146. "
  147. >指派:</span
  148. >
  149. <el-radio-group
  150. v-model="item.assignType"
  151. size="mini"
  152. @change="(e) => changeRadio(e, index)"
  153. >
  154. <el-radio-button
  155. :disabled="radioBun(item, 'stationDis')"
  156. :label="1"
  157. >工位
  158. </el-radio-button>
  159. <el-radio-button
  160. :disabled="radioBun(item, 'staffDis')"
  161. :label="2"
  162. >人员
  163. </el-radio-button>
  164. <el-radio-button
  165. :disabled="radioBun(item, 'lineDis')"
  166. :label="3"
  167. >产线
  168. </el-radio-button>
  169. </el-radio-group>
  170. </div>
  171. <div
  172. v-if="item.isSpecialField"
  173. class="describe"
  174. style="color: #67c23a"
  175. >
  176. 该工序已完成派单!
  177. </div>
  178. <div
  179. style="margin-left: 50px; display: inline-block"
  180. v-if="timeSlot(item)"
  181. >
  182. 时间段: {{ item.startDate }} ----- {{ item.endDate }}
  183. </div>
  184. </template>
  185. <template v-slot:quantity="{ row }">
  186. <el-input
  187. v-model="row.quantity"
  188. :disabled="row.disposalStatus == 1"
  189. placeholder="请输入数量"
  190. type="number"
  191. @input="(e) => handleQuantityInput(e, row, item)"
  192. ></el-input>
  193. </template>
  194. <template v-slot:weight="{ row }">
  195. <el-input
  196. v-model="row.weight"
  197. :disabled="row.disposalStatus == 1"
  198. placeholder="请输入重量"
  199. type="number"
  200. @input="(e) => handleWeightInput(e, row, item)"
  201. ></el-input>
  202. </template>
  203. <template v-slot:teamTimeIds="{ row }">
  204. <el-select
  205. v-model="row.teamTimeIds"
  206. multiple
  207. placeholder="班次"
  208. :disabled="row.disposalStatus == 1"
  209. @change="(e) => shiftSelection(e, row, item)"
  210. >
  211. <el-option
  212. v-for="item in shiftList"
  213. :key="item.id"
  214. :label="item.name"
  215. :value="item.id"
  216. >
  217. </el-option>
  218. </el-select>
  219. </template>
  220. <template v-slot:startTime="{ row }">
  221. <el-date-picker
  222. v-model="row.startTime"
  223. :disabled="row.disposalStatus == 1"
  224. @change="handleStartTimeChange(row, item)"
  225. class="w100"
  226. placeholder="开始时间"
  227. type="datetime"
  228. value-format="yyyy-MM-dd HH:mm:ss"
  229. ></el-date-picker>
  230. </template>
  231. <template v-slot:endTime="{ row }">
  232. <el-date-picker
  233. v-model="row.endTime"
  234. :disabled="row.disposalStatus == 1"
  235. class="w100"
  236. placeholder="完成时间"
  237. type="datetime"
  238. value-format="yyyy-MM-dd HH:mm:ss"
  239. ></el-date-picker>
  240. </template>
  241. <template v-slot:action="{ row }">
  242. <!-- :disabled="resetBtnDis(row)" -->
  243. <el-popconfirm
  244. v-if="resetBtnDis(row)"
  245. title="确定要重置该条数据吗?"
  246. @confirm="resetData(row, item)"
  247. >
  248. <template v-slot:reference>
  249. <el-link :underline="false" type="primary"> 重置</el-link>
  250. </template>
  251. </el-popconfirm>
  252. </template>
  253. </ele-pro-table>
  254. </el-tab-pane>
  255. </el-tabs>
  256. </el-form>
  257. </div>
  258. <!-- <div slot="footer">-->
  259. <!-- <el-button plain @click="cancel">取消</el-button>-->
  260. <!-- <el-button :loading="toolbarLoading" type="primary" @click="confirm"-->
  261. <!-- >确定-->
  262. <!-- </el-button-->
  263. <!-- >-->
  264. <!-- </div>-->
  265. </ele-modal>
  266. </template>
  267. <script>
  268. import validDate from '@/utils/date';
  269. import {
  270. lineByCurrentUser,
  271. listAssign,
  272. listByFirstTaskId,
  273. listByMesWorkOrder,
  274. listByRoutingIds,
  275. listUserByIds,
  276. listWorkCenter,
  277. resetAssignee,
  278. taskAssignment,
  279. taskRevoked,
  280. taskSave,
  281. listByFactoryId
  282. } from '@/api/mainData/index.js';
  283. import { getUserInfo } from '@/api/produceOrder/index.js';
  284. export default {
  285. components: {},
  286. props: {
  287. current: {
  288. type: Object,
  289. default: () => {}
  290. },
  291. dispatchVisible: {
  292. type: Boolean,
  293. default: false
  294. }
  295. },
  296. data() {
  297. return {
  298. processId: '',
  299. tabLoading: false,
  300. dynamicName: '工位名称',
  301. form: {
  302. assignType: 1,
  303. crewIds: '',
  304. workstationIds: '',
  305. teamId: '',
  306. singleReport: '',
  307. workCenterId: '',
  308. taskAss: 1,
  309. factoryName: ''
  310. },
  311. toolbarLoading: false,
  312. processList: [],
  313. workCenterList: [],
  314. teamList: [],
  315. tabsLoading: false,
  316. stationList: [], // 工位的数据
  317. productionList: [], // 产线的数据
  318. crewList: [], // 人员的数据
  319. // procTaskDis: false, // 工序任务派单选择
  320. // firstTaskindex: '', // 首工序id 对应的工序列表数据下标
  321. fieldList: [
  322. { label: '生产订单号:', prop: 'code' },
  323. { label: '计划编号:', prop: 'productionPlanCode' },
  324. { label: '工艺路线:', prop: 'produceRoutingName' },
  325. // { label: '编码', prop: 'productCode' },
  326. { label: '名称:', prop: 'productName' },
  327. { label: '生产编号:', prop: 'productionCodes' },
  328. { label: '牌号:', prop: 'brandNo' },
  329. { label: '批次号:', prop: 'batchNo' },
  330. { label: '型号:', prop: 'model' },
  331. { label: '要求生产数量:', prop: 'formingNum' },
  332. { label: '要求生产重量:', prop: 'initialWeight' },
  333. { label: '计划开始时间:', prop: 'planStartTime' },
  334. { label: '计划结束时间:', prop: 'planCompleteTime' }
  335. ],
  336. shiftList: [],
  337. dateValue: '',
  338. factoriesId: '', // 工厂id
  339. dispatchType: 1,
  340. time_calc_code: '0', // 是否进行时间赋值 0 否 1 是
  341. validDate,
  342. userTeamList: []
  343. };
  344. },
  345. computed: {
  346. clientEnvironmentId() {
  347. return this.$store.state.user.info.clientEnvironmentId;
  348. },
  349. userInfo() {
  350. return this.$store.state.user.info;
  351. },
  352. modelWidth() {
  353. // if(this.form.taskAss == 1){
  354. // return '1000px'
  355. // }
  356. return '75vw';
  357. },
  358. // 重置按钮 的置灰权限 没有进行操作跟派单的数据 置灰
  359. resetBtnDis() {
  360. return (row) => {
  361. if (!row.status) return false;
  362. let flag = row.status.code != 1;
  363. return flag;
  364. };
  365. },
  366. // 指派单选框操作 已派单的 其它两个按钮不能操作
  367. radioBun() {
  368. return (row, type) => {
  369. if (!row.radioBun) return false;
  370. let flag = row.radioBun[type];
  371. return flag;
  372. };
  373. },
  374. // 列表输入框操作 已派单的不能操作
  375. permissions() {
  376. return (row, item) => {
  377. if (item.isSpecialField) return true;
  378. if (!row.status) return false;
  379. if (row.status.code == 1) return true;
  380. };
  381. },
  382. // 时间段显示
  383. timeSlot() {
  384. return (item) => {
  385. if (!item.startDate || !item.endDate) {
  386. return false;
  387. }
  388. return true;
  389. };
  390. },
  391. columns() {
  392. return [
  393. {
  394. columnKey: 'index',
  395. label: '序号',
  396. type: 'index',
  397. width: 55,
  398. align: 'center',
  399. showOverflowTooltip: true,
  400. fixed: 'left'
  401. },
  402. {
  403. width: 45,
  404. type: 'selection',
  405. columnKey: 'selection',
  406. align: 'center',
  407. fixed: 'left',
  408. selectable: (row, index) => {
  409. return row.disposalStatus != 1;
  410. }
  411. },
  412. {
  413. prop: 'name',
  414. label: this.dynamicName,
  415. align: 'center',
  416. showOverflowTooltip: true,
  417. width: 200
  418. },
  419. {
  420. prop: 'code',
  421. label: '编码',
  422. align: 'center',
  423. showOverflowTooltip: true,
  424. width: 200
  425. },
  426. {
  427. prop: 'status',
  428. label: '状态',
  429. align: 'center',
  430. showOverflowTooltip: true,
  431. width: 150,
  432. formatter: (row) => {
  433. if (!row.status) return '';
  434. return row.status.desc || '';
  435. }
  436. },
  437. {
  438. prop: 'disposalStatus',
  439. label: '接收状态',
  440. align: 'center',
  441. showOverflowTooltip: true,
  442. width: 150,
  443. formatter: (row) => {
  444. console.log('row', row);
  445. return row.disposalStatus == 1
  446. ? '已接收'
  447. : row.disposalStatus == 2
  448. ? '已拒绝'
  449. : '未接收';
  450. }
  451. },
  452. {
  453. slot: 'quantity',
  454. prop: 'quantity',
  455. label: '数量',
  456. align: 'center',
  457. width: 140
  458. },
  459. {
  460. slot: 'weight',
  461. prop: 'weight',
  462. label: `重量(${this.current.weightUnit})`,
  463. align: 'center',
  464. width: 140
  465. },
  466. {
  467. slot: 'teamTimeIds',
  468. prop: 'teamTimeIds',
  469. label: '班次',
  470. align: 'center',
  471. minWidth: 220
  472. },
  473. {
  474. slot: 'startTime',
  475. prop: 'startTime',
  476. label: '计划开始时间',
  477. align: 'center',
  478. minWidth: 240
  479. },
  480. {
  481. slot: 'endTime',
  482. prop: 'endTime',
  483. label: '计划完成时间',
  484. align: 'center',
  485. minWidth: 240
  486. },
  487. {
  488. columnKey: 'action',
  489. label: '操作',
  490. width: 120,
  491. align: 'center',
  492. resizable: false,
  493. fixed: 'right',
  494. slot: 'action'
  495. }
  496. ];
  497. }
  498. },
  499. watch: {},
  500. created() {
  501. this.dispatchType = this.current.singleReport || 0;
  502. this.workCenterData();
  503. this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
  504. this.dateValue = this.getFormattedDate();
  505. },
  506. methods: {
  507. getCode() {
  508. parameterGetByCode({
  509. code: 'time_calculation_rules'
  510. }).then((res) => {
  511. if (res) {
  512. this.time_calc_code = res.value || '0';
  513. }
  514. });
  515. },
  516. // 查询班次
  517. getClassesData() {
  518. if (!this.factoriesId) return;
  519. listByFactoryId(this.factoriesId).then((res) => {
  520. console.log(res, 'res ++++');
  521. if (!res) return;
  522. this.shiftList = res;
  523. });
  524. },
  525. // 获取当前年月日
  526. getFormattedDate() {
  527. const now = new Date();
  528. const year = now.getFullYear();
  529. const month = String(now.getMonth() + 1).padStart(2, '0');
  530. const date = String(now.getDate()).padStart(2, '0');
  531. return `${year}-${month}-${date}`;
  532. },
  533. // 查询工作中心
  534. // async workCenterData() {
  535. // const res = await listWorkCenter(this.current.taskInstanceId);
  536. // this.workCenterList = res;
  537. // if (res.length > 0) {
  538. // console.log(res, '工作中心');
  539. // this.form.factoryName = res[0].factoryName;
  540. // const userData = await getUserInfo(
  541. // this.$store.state.user.info.userId
  542. // );
  543. // console.log(userData, '用户的数据111111111');
  544. // this.form.workCenterId = res[0].id;
  545. // this.factoriesId = res[0].factoryId;
  546. // // 查首工序
  547. // this.changeWork(res[0].id); // 选择工作中心
  548. // this.getProductionData(res[0].id); // 查询产线
  549. // this.FirstTaskIdFn(); // 查询工位数据
  550. // this.getClassesData();
  551. // }
  552. // },
  553. async workCenterData() {
  554. const userData = await getUserInfo(this.$store.state.user.info.userId);
  555. this.factoriesId = userData.factoryId ? userData.factoryId : '';
  556. this.form.factoryName = userData.factoryName
  557. ? userData.factoryName
  558. : '';
  559. if (userData.centerList.length != 0) {
  560. this.form.workCenterId = userData.centerList[0].centerId;
  561. this.form.workCenterName = userData.centerList[0].centerName;
  562. this.workCenterList = userData.centerList;
  563. this.userTeamList = userData.teamList;
  564. this.changeWork(userData.centerList[0].centerId);
  565. this.getProductionData(userData.centerList[0].centerId);
  566. this.FirstTaskIdFn(); // 查询工位数据
  567. this.getClassesData();
  568. }
  569. },
  570. // 查询工序列表数据
  571. async changeDispatch(e) {
  572. this.tabsLoading = true;
  573. try {
  574. // /aps/assign/listByMesWorkOrder
  575. let allRes = await listByRoutingIds([this.current.produceRoutingId]); // 查询全部工序数据
  576. let params = {
  577. apsWorkOrderId: this.current.apsWorkOrderId,
  578. categoryId: this.current.categoryId,
  579. mesWorkOrderId: this.current.id,
  580. produceRoutingId: this.current.produceRoutingId
  581. };
  582. let existRes = await listByMesWorkOrder(params); // 存在的工序数据
  583. console.log(existRes, 'existRes ++++++');
  584. let res = [];
  585. if (!existRes || existRes.length === 0) {
  586. res = allRes;
  587. } else {
  588. // 先将 存在的工序数据 数组的 id 存入 Set
  589. const existIds = new Map(
  590. existRes.map((item) => [
  591. item.assignees.length ? item.taskId : null,
  592. true
  593. ])
  594. );
  595. // 过滤 全部工序数据 数组
  596. // res = allRes.map((aItem) => !existIds.has(aItem.sourceTaskId));
  597. res = allRes.map((aItem) => {
  598. return {
  599. ...aItem,
  600. isSpecialField: existIds.has(aItem.sourceTaskId)
  601. };
  602. });
  603. }
  604. // 如果没有首工序的数据 就不能选择工序任务派单
  605. if (!res || res.length === 0) {
  606. this.processList = [];
  607. // this.form.taskAss = 1;
  608. // this.procTaskDis = true;
  609. this.$message.warning('当前工单没有工序数据');
  610. return;
  611. }
  612. // this.procTaskDis = false;
  613. let list = [];
  614. res.forEach((item, index) => {
  615. let obj = {
  616. id: item.sourceTaskId, //工序 id
  617. name: item.name, //工序 名称
  618. assignType: 1, // 默认的指派数据
  619. assignName: '工位', // 默认指派数据名称
  620. list: [], // 当前工序下面的指派 绑定的表格
  621. selection: [], // 当前工序下面的指派 选中的数据
  622. code: item.code, // 工序 编码
  623. index: index, // 当前工序数据的下标
  624. // isSpecialField: item.isSpecialField,
  625. isSpecialField: false, //需求不清晰 为了满足江南需求 先默认false
  626. radioBun: {
  627. // 指派按钮的操作状态 绑定 默认false(可操作)
  628. stationDis: false, // 工位按钮
  629. staffDis: false, // 人员按钮
  630. lineDis: false // 产线按钮
  631. },
  632. isDisable:
  633. this.form.workCenterId == item.workCenterId ? true : false,
  634. startDate: '', // 开始日期 (当前工序中最早的计划开始时间)
  635. endDate: '', // 结束日期 (当前工序中最晚的计划结束时间)
  636. workCenterId: item.workCenterId,
  637. workCenterName: item.workCenterName
  638. };
  639. list.push(obj);
  640. });
  641. this.processList = list;
  642. console.log(this.processList, '所有的工序数据集合');
  643. this.processId = res[0].sourceTaskId;
  644. // this.handleClick({ name: res[0].sourceTaskId });
  645. this.initializeQuery();
  646. } catch (err) {
  647. this.processList = [];
  648. this.$message.error(err.message);
  649. } finally {
  650. this.tabsLoading = false;
  651. }
  652. },
  653. // 初始化查询 查询全部工序操作过的数据
  654. async initializeQuery() {
  655. try {
  656. // 不存在 班组数据的话 就不调用这个方法
  657. if (!this.form.teamId) {
  658. return;
  659. }
  660. let params = {
  661. workOrderId: this.current.id,
  662. workCenterId: this.form.workCenterId,
  663. teamId: this.form.teamId
  664. };
  665. let processMap = {};
  666. this.processList.map((el, index) => (processMap[el.id] = index));
  667. const res = await listAssign(params);
  668. let isFirstData = false; // 判断默认第一道工序是否操作过
  669. if (res && res.length > 0) {
  670. res.map((el) => {
  671. let index = processMap[el.taskId];
  672. if (index === 0 && el.assignees && el.assignees.length > 0) {
  673. isFirstData = true; // 操作过
  674. }
  675. // 这里第三个参数传空数组就好了 会自动计算的
  676. setTimeout(() => {
  677. this.operationalData(index, [el], []);
  678. });
  679. });
  680. // 没有操作过 默认获取一下表格数据
  681. if (!isFirstData) {
  682. this.handleClick({ name: this.processId });
  683. }
  684. } else {
  685. this.handleClick({ name: this.processId });
  686. }
  687. } catch (err) {}
  688. },
  689. // // 选择工作中心
  690. // async changeWork(e) {
  691. // this.form.workCenterId = e;
  692. // // this.changeDispatch(); // 查询工序列表
  693. // let data = this.workCenterList.find((item) => item.id == e);
  694. // this.form.workCenterName = data.name;
  695. // this.teamList = data.teamList || [];
  696. // if (this.teamList.length > 0) {
  697. // this.form.teamId = this.teamList[0].id;
  698. // await this.changeGroups(this.teamList[0].id);
  699. // } else {
  700. // // 如果没有 班组数据 将人员数据清空 并且判断
  701. // this.crewList = [];
  702. // this.form.teamId = '';
  703. // let data = this.processList.find((item) => item.id == this.processId);
  704. // if (data.assignType == 2) {
  705. // this.$set(data, 'list', []);
  706. // }
  707. // }
  708. // },
  709. // 选择工作中心
  710. async changeWork(e) {
  711. this.form.workCenterId = e;
  712. let data = this.userTeamList.filter((item) =>
  713. item.workCenterIds.includes(e)
  714. );
  715. this.teamList = data || [];
  716. if (this.teamList.length != 0) {
  717. this.form.teamId = this.teamList[0].teamId;
  718. await this.changeGroups(this.teamList[0].teamId);
  719. } else {
  720. // 如果没有 班组数据 将人员数据清空 并且判断
  721. this.crewList = [];
  722. this.form.teamId = '';
  723. let data = this.processList.find((item) => item.id == this.processId);
  724. if (data.assignType == 2) {
  725. this.$set(data, 'list', []);
  726. }
  727. }
  728. },
  729. // 选择班组 查询人员的数据
  730. async changeGroups(e) {
  731. let data = this.teamList.find((item) => item.teamId == e);
  732. this.form.teamName = data.teamName;
  733. try {
  734. const res = await listUserByIds([e]);
  735. this.crewList = res || [];
  736. if (!this.processId || this.processId == 0) {
  737. return;
  738. }
  739. this.handleClick({ name: this.processId });
  740. this.btnInit();
  741. } catch {
  742. this.crewList = [];
  743. }
  744. },
  745. // 工序按钮初始化
  746. btnInit() {
  747. let data = this.processList.find((item) => item.id == this.processId);
  748. this.$set(data.radioBun, 'lineDis', false);
  749. this.$set(data.radioBun, 'staffDis', false);
  750. this.$set(data.radioBun, 'stationDis', false);
  751. this.$set(data, 'assignName', '工位');
  752. this.$set(data, 'assignType', 1);
  753. },
  754. // 获取产线数据
  755. async getProductionData() {
  756. const res = await lineByCurrentUser(this.form.workCenterId);
  757. this.productionList = res || [];
  758. },
  759. // 查询工位数据
  760. FirstTaskIdFn() {
  761. listByFirstTaskId(this.current.taskInstanceId)
  762. .then((res) => {
  763. this.stationList = res;
  764. this.changeDispatch();
  765. })
  766. .catch((err) => {
  767. this.stationList = [];
  768. this.$message.error(err.message);
  769. });
  770. },
  771. // 重置(单个)
  772. resetData(row, item) {
  773. if (!row.changeId) {
  774. return this.$message.warning('只能对已撤回跟已保存的数据进行重置');
  775. }
  776. this.toolbarLoading = true;
  777. resetAssignee(row.changeId)
  778. .then((res) => {
  779. this.toolbarLoading = false;
  780. if (res) {
  781. this.$message.success('操作成功');
  782. // 更改当前表格数据
  783. this.setCurrentTab(item);
  784. }
  785. })
  786. .catch((err) => {
  787. this.toolbarLoading = false;
  788. this.$message.warning(err.message);
  789. });
  790. },
  791. // 派单/撤回 判断
  792. getWithdrawT(row, type) {
  793. // if (type != 2) {
  794. // return true;
  795. // }
  796. let isWithdraw = [];
  797. row.selection.forEach((item) => {
  798. //撤回逻辑
  799. if (type == 2) {
  800. if (!item.status || !item.status.code) {
  801. isWithdraw.push(item.name);
  802. }
  803. }
  804. if (type == 1) {
  805. if (item?.status?.code == 1) {
  806. isWithdraw.push(item.name);
  807. }
  808. }
  809. // if (!item.status.code) {
  810. // isFlag = false;
  811. // }
  812. });
  813. return isWithdraw;
  814. },
  815. // 派单
  816. dispatch(row, type) {
  817. if (row.selection.length == 0) {
  818. return this.$message.warning('请最少选择一条数据');
  819. }
  820. let isWithdraw = this.getWithdrawT(row, type);
  821. if (isWithdraw.length) {
  822. if (type == 1) {
  823. this.$message.warning(
  824. isWithdraw.toString() + ',状态为已派单,如需重新派单请先撤回!'
  825. );
  826. }
  827. if (type == 2) {
  828. this.$message.warning(
  829. isWithdraw.toString() + '还未派单,无需撤回!'
  830. );
  831. }
  832. return;
  833. }
  834. let assignees = [];
  835. let changeIds = [];
  836. let flag = true; // 是否填写 校验
  837. // let digit = true; // 数字校验
  838. row.selection.forEach((item) => {
  839. if (!item.quantity || !item.startTime || !item.endTime) {
  840. flag = false;
  841. return;
  842. }
  843. let Aobj = {
  844. assigneeId: item.id,
  845. quantity: item.quantity,
  846. weight: item.weight,
  847. startTime: item.startTime,
  848. endTime: item.endTime,
  849. assigneeType: row.assignType,
  850. assigneeName: item.name
  851. };
  852. if (item.teamTimeIds) {
  853. Aobj.teamTimeIds = item.teamTimeIds;
  854. }
  855. assignees.push(Aobj);
  856. changeIds.push(item.changeId);
  857. });
  858. if (!flag) {
  859. this.$message.warning(
  860. '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
  861. );
  862. return;
  863. }
  864. let data = null;
  865. this.toolbarLoading = true;
  866. if (type == 2) {
  867. data = changeIds;
  868. } else {
  869. data = {
  870. dispatchMethod: 0,
  871. dispatchType: this.dispatchType,
  872. taskId: this.processId,
  873. taskName: row.name,
  874. taskCode: row.code,
  875. teamName: this.form.teamName,
  876. teamId: this.form.teamId,
  877. workCenterId: this.form.workCenterId,
  878. workCenterName: this.form.workCenterName,
  879. workOrderId: this.current.apsWorkOrderId,
  880. sourceType: 2,
  881. mesWorkOrderId: this.current.id,
  882. mesWorkOrderCode: this.current.code,
  883. assignees
  884. };
  885. console.log(data, '数据999');
  886. }
  887. const api =
  888. type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
  889. api(data)
  890. .then((res) => {
  891. this.toolbarLoading = false;
  892. if (res) {
  893. this.$message.success('操作成功');
  894. // 更改当前表格数据
  895. this.setCurrentTab(row);
  896. }
  897. })
  898. .catch((err) => {
  899. this.toolbarLoading = false;
  900. this.$message.warning(err.message);
  901. });
  902. },
  903. cancel() {
  904. this.$emit('update:dispatchVisible', false);
  905. },
  906. // 按钮操作成功后 更改当前的表格数据
  907. setCurrentTab(row) {
  908. let arr = [];
  909. if (row.assignType == 1) {
  910. arr = this.stationList;
  911. } else if (row.assignType == 2) {
  912. arr = this.crewList;
  913. } else {
  914. arr = this.productionList;
  915. }
  916. this.getAssignData(row.index, arr);
  917. },
  918. // 工序选择
  919. async handleClick(tab) {
  920. let id = tab.name;
  921. this.processId = id;
  922. let data = this.processList.find((item) => item.id == this.processId);
  923. await this.changeRadio(data.assignType, data.index);
  924. },
  925. // 指派选择
  926. changeRadio(e, index) {
  927. let data = this.processList[index];
  928. if (e == 1) {
  929. this.dynamicName = '工位名称';
  930. data.assignName = '工位';
  931. this.getAssignData(index, this.stationList);
  932. } else if (e == 2) {
  933. this.dynamicName = '人员名称';
  934. data.assignName = '人员';
  935. this.getAssignData(index, this.crewList);
  936. } else {
  937. this.dynamicName = '产线名称';
  938. data.assignName = '产线';
  939. this.getAssignData(index, this.productionList);
  940. }
  941. },
  942. // 指派数据处理
  943. async getAssignData(index, arr) {
  944. let list = JSON.parse(JSON.stringify(arr));
  945. let dataRow = this.processList[index];
  946. // 不存在 班组数据的话 就不调用这个方法
  947. if (!this.form.teamId) {
  948. return;
  949. }
  950. let params = {
  951. workOrderId: this.current.apsWorkOrderId,
  952. workCenterId: this.form.workCenterId,
  953. teamId: this.form.teamId,
  954. taskId: this.processId
  955. };
  956. this.tabLoading = true;
  957. try {
  958. const res = await listAssign(params);
  959. this.tabLoading = false;
  960. // 如果 res 没有数据 说明未对数据进行操作 直接赋值
  961. if (res.length == 0) {
  962. this.$set(dataRow, 'list', list);
  963. return;
  964. }
  965. // 对有操作过的数据进行赋值
  966. this.operationalData(index, res, list);
  967. } catch (err) {
  968. this.tabLoading = false;
  969. this.$message.warning(err.message);
  970. }
  971. },
  972. // 操作过的数据 赋值
  973. operationalData(index, res, list) {
  974. const dataRow = this.processList[index];
  975. // 键值对存储 当前工序 操作的数据 指派的code(键) 数据(list:值)
  976. let arrMap = {};
  977. // 要先判断有没有操作的数据 如果有的话 其它的指派操作置灰
  978. let codeT = null; // 表示有已操作的数据(对应的 code)
  979. res[0].assignees.map((el) => {
  980. let code = el.assigneeType.code;
  981. if (arrMap[code]) {
  982. arrMap[code].arr.push(el);
  983. arrMap[code].bunDis = arrMap[code].bunDis
  984. ? arrMap[code].bunDis
  985. : el.status.desc
  986. ? true
  987. : false;
  988. } else {
  989. arrMap[code] = {
  990. arr: [el],
  991. bunDis: el.status.desc ? true : false
  992. };
  993. }
  994. codeT = codeT ? codeT : el.status.desc ? code : '';
  995. });
  996. let radioBun = {
  997. lineDis: false, // 产线 3
  998. staffDis: false, // 人员 2
  999. stationDis: false // 工位 1
  1000. };
  1001. // 默认是传递下来的 list 数据 但是如果 codeT有值 说明 工位 人员 产线 有派单数据
  1002. // 需要自动切换过去
  1003. let listArr = list;
  1004. if (codeT) {
  1005. if (codeT == 1) {
  1006. radioBun.staffDis = true;
  1007. radioBun.lineDis = true;
  1008. radioBun.stationDis = false;
  1009. listArr = JSON.parse(JSON.stringify(this.stationList));
  1010. dataRow.assignType = 1;
  1011. dataRow.assignName = '工位';
  1012. } else if (codeT == 2) {
  1013. radioBun.stationDis = true;
  1014. radioBun.lineDis = true;
  1015. radioBun.staffDis = false;
  1016. listArr = JSON.parse(JSON.stringify(this.crewList));
  1017. dataRow.assignType = 2;
  1018. dataRow.assignName = '人员';
  1019. } else {
  1020. radioBun.stationDis = true;
  1021. radioBun.staffDis = true;
  1022. radioBun.lineDis = false;
  1023. listArr = JSON.parse(JSON.stringify(this.productionList));
  1024. dataRow.assignType = 3;
  1025. dataRow.assignName = '产线';
  1026. }
  1027. }
  1028. // 切换完后 对 指派的数组数据进行赋值
  1029. let listMap = {};
  1030. listArr.map((el, index) => (listMap[el.id] = index));
  1031. let arrList = codeT ? arrMap[codeT].arr : res[0].assignees;
  1032. arrList.map((item) => {
  1033. if (item.assigneeType.code == dataRow.assignType) {
  1034. let idx = listMap[item.assigneeId];
  1035. listArr[idx].disposalStatus = item.disposalStatus;
  1036. listArr[idx].status = item.status;
  1037. listArr[idx].startTime = item.startTime;
  1038. listArr[idx].endTime = item.endTime;
  1039. listArr[idx].quantity = item.quantity;
  1040. listArr[idx].weight = item.weight;
  1041. listArr[idx].changeId = item.id;
  1042. listArr[idx].teamTimeIds = item.teamTimeIds;
  1043. this.compareAndSetTime(listArr[idx], dataRow);
  1044. this.compareEndSetTime(listArr[idx], dataRow);
  1045. }
  1046. });
  1047. // console.log(listArr,'listArr')
  1048. // console.log(listArr,'listArr')
  1049. this.$set(dataRow, 'list', listArr);
  1050. this.$set(dataRow, 'radioBun', radioBun);
  1051. },
  1052. // 时间比较与赋值方法 开始时间
  1053. compareAndSetTime(data, dataRow) {
  1054. // 如果startDate为空,直接赋值为startTime
  1055. if (!dataRow.startDate) {
  1056. dataRow.startDate = data['startTime'];
  1057. return;
  1058. }
  1059. // 转换为Date对象进行比较
  1060. const startTimeDate = new Date(data['startTime']);
  1061. const startDateDate = new Date(dataRow.startDate);
  1062. // 比较时间(getTime()获取时间戳)
  1063. if (startTimeDate.getTime() < startDateDate.getTime()) {
  1064. dataRow.startDate = data['startTime'];
  1065. }
  1066. },
  1067. // 时间比较与赋值方法 结束时间时间
  1068. compareEndSetTime(data, dataRow) {
  1069. // 如果startDate为空,直接赋值为endTime
  1070. if (!dataRow.endDate) {
  1071. dataRow.endDate = data['endTime'];
  1072. return;
  1073. }
  1074. // 转换为Date对象进行比较
  1075. const endTimeDate = new Date(data['endTime']);
  1076. const endDateDate = new Date(dataRow.endDate);
  1077. // 比较时间(getTime()获取时间戳)
  1078. if (endTimeDate.getTime() > endDateDate.getTime()) {
  1079. dataRow.endDate = data['endTime'];
  1080. }
  1081. },
  1082. assignRadio(e) {},
  1083. // 数量正则 quantity
  1084. handleQuantityInput(e, row, item) {
  1085. // 过滤非数字字符(包括负号)
  1086. let value = e.replace(/[^\d]/g, '');
  1087. // 限制不能以 0 开头(除非是 0 本身)
  1088. if (value.startsWith('0') && value.length > 1) {
  1089. value = value.slice(1);
  1090. }
  1091. // 更新绑定值
  1092. row.quantity = value;
  1093. this.calculateQuantity(row, item);
  1094. this.bringWeight(row.quantity, row);
  1095. this.selectedListData(row, item);
  1096. },
  1097. // 自动算重量
  1098. bringWeight(value, row) {
  1099. if (!this.current.formingWeight) {
  1100. this.$set(row, 'weight', 0);
  1101. return;
  1102. }
  1103. let weight =
  1104. (this.current.formingWeight / this.current.formingNum) * value;
  1105. if (weight > 0) {
  1106. weight = weight.toFixed(4) - 0;
  1107. }
  1108. this.$set(row, 'weight', weight);
  1109. },
  1110. calculateQuantity(row, item) {
  1111. // 如果没有该字段 就不做判断
  1112. if (!this.current.formingNum) {
  1113. return;
  1114. }
  1115. let total = 0;
  1116. item.list.forEach((el) => {
  1117. if (el.quantity) {
  1118. total = total + (el.quantity - 0);
  1119. }
  1120. });
  1121. if (total > this.current.formingNum - 0) {
  1122. this.$message.warning('列表数量相加不能大于目标要求生产数量');
  1123. row.quantity = 0;
  1124. }
  1125. },
  1126. // 计算重量
  1127. calculateWeight(row, item) {
  1128. // 如果没有该字段 就不做判断
  1129. if (!this.current.formingWeight) {
  1130. return;
  1131. }
  1132. let total = 0;
  1133. item.list.forEach((el) => {
  1134. if (el.weight) {
  1135. total = total + (el.weight - 0);
  1136. }
  1137. });
  1138. if (total > this.current.formingWeight - 0) {
  1139. this.$message.warning('列表数量相加不能大于目标要求生产数量');
  1140. row.weight = 0;
  1141. }
  1142. },
  1143. // 重量正则 weight
  1144. handleWeightInput(e, row, item) {
  1145. // 过滤非数字和非小数点字符(包括负号)
  1146. let value = e.replace(/[^\d.]/g, '');
  1147. // 限制只能有一个小数点
  1148. const dotCount = (value.match(/\./g) || []).length;
  1149. if (dotCount > 1) {
  1150. value = value.slice(0, value.lastIndexOf('.'));
  1151. }
  1152. // 限制不能以小数点开头
  1153. if (value.startsWith('.')) {
  1154. value = '0' + value;
  1155. }
  1156. // 更新绑定值
  1157. row.weight = value;
  1158. this.calculateWeight(row, item);
  1159. this.selectedListData(row, item);
  1160. },
  1161. // 选中班次
  1162. shiftSelection(e, row, item) {
  1163. // this.selectedListData(row, item);
  1164. let data = this.shifTimeData(e, row);
  1165. // let data = this.shiftList.find((item) => item.id == e);
  1166. let startTime = `${this.dateValue} ${data.startTime}`;
  1167. let endTime = `${this.dateValue} ${data.endTime}`;
  1168. this.$set(row, 'startTime', startTime);
  1169. this.$set(row, 'endTime', endTime);
  1170. this.handleStartTimeChange(row, item);
  1171. this.handleEndTimeChange(row, item);
  1172. },
  1173. // 默认选中当前更改数据
  1174. selectedListData(row, item) {
  1175. this.$nextTick(() => {
  1176. let data = item.selection.find((el) => el.id == row.id);
  1177. if (!data) {
  1178. let ids = item.selection.map((el) => el.id);
  1179. ids.push(row.id);
  1180. let tab = `tableRef${[item.index]}`;
  1181. this.$refs[tab][0].setSelectedRowKeys(ids);
  1182. }
  1183. });
  1184. },
  1185. // 多选班次时间数据
  1186. shifTimeData(e, row) {
  1187. if (!e || e.length == 0) {
  1188. return {
  1189. startTime: row.startTime,
  1190. endTime: row.endTime
  1191. };
  1192. }
  1193. let startTime = '';
  1194. let endTime = '';
  1195. e.map((el) => {
  1196. let obj = this.shiftList.find((item) => item.id == el);
  1197. if (!startTime) {
  1198. startTime = obj.startTime;
  1199. }
  1200. if (!endTime) {
  1201. endTime = obj.endTime;
  1202. }
  1203. // 获取更小的
  1204. startTime =
  1205. this.compareTime(startTime, obj.startTime) !== -1
  1206. ? obj.startTime
  1207. : startTime;
  1208. // 获取更大的
  1209. endTime =
  1210. this.compareTime(endTime, obj.endTime) !== 1
  1211. ? obj.endTime
  1212. : endTime;
  1213. });
  1214. return {
  1215. startTime,
  1216. endTime
  1217. };
  1218. },
  1219. // 将HH:mm:ss格式的时间转换为总秒数
  1220. timeToSeconds(timeStr) {
  1221. const [hours, minutes, seconds] = timeStr.split(':').map(Number);
  1222. return hours * 3600 + minutes * 60 + seconds;
  1223. },
  1224. // this.$refs.table.setSelectedRowKeys(ids);
  1225. // 比较两个时间的大小
  1226. compareTime(time1, time2) {
  1227. const sec1 = this.timeToSeconds(time1);
  1228. const sec2 = this.timeToSeconds(time2);
  1229. if (sec1 > sec2) {
  1230. return 1; // time1 更大
  1231. } else if (sec1 < sec2) {
  1232. return -1; // time2 更大
  1233. } else {
  1234. return 0; // 两个时间相等
  1235. }
  1236. },
  1237. // 【开始时间变化时】触发
  1238. handleStartTimeChange(row, item) {
  1239. if (!row.startTime) {
  1240. return;
  1241. }
  1242. this.selectedListData(row, item);
  1243. // 这一道工序的开始时间 不能小于前一道工序的结束时间
  1244. const startTime = new Date(row.startTime); // 开始时间
  1245. if (item.index !== 0) {
  1246. // let frontIdx = item.index - 1;
  1247. let frontIdx = this.calculateIndex(item.index).startIdx;
  1248. if (frontIdx !== 'none') {
  1249. let frontName = this.processList[frontIdx].name;
  1250. let time = this.processList[frontIdx].endDate;
  1251. const frontTime = new Date(time); // 前面工序的结束时间
  1252. if (time && startTime < frontTime) {
  1253. this.$message.closeAll();
  1254. this.$message.info(
  1255. `开始时间不能小于前面工序${frontName}的结束时间${time}`
  1256. );
  1257. // 判断是否 配置时间更改规则
  1258. if (this.time_calc_code == '1') {
  1259. row.startTime = time;
  1260. }
  1261. return;
  1262. }
  1263. }
  1264. }
  1265. // 这一道工序的开始时间更不能大于后一道工序的开始时间
  1266. if (item.index !== this.processList.length - 1) {
  1267. // let latterIdx = item.index + 1;
  1268. let latterIdx = this.calculateIndex(item.index).endIdx;
  1269. if (latterIdx !== 'none') {
  1270. let time = this.processList[latterIdx].startDate;
  1271. let latterName = this.processList[latterIdx].name;
  1272. const latterTime = new Date(time); // 下一道工序的结束时间
  1273. if (time && startTime > latterTime) {
  1274. this.$message.closeAll();
  1275. this.$message.info(
  1276. `开始时间不能大于后面工序${latterName}的开始时间${time}`
  1277. );
  1278. // 判断是否 配置时间更改规则
  1279. if (this.time_calc_code == '1') {
  1280. row.startTime = '';
  1281. }
  1282. return;
  1283. }
  1284. }
  1285. }
  1286. // 校验 是否 大于结束时间 wda
  1287. this.checkEndTimeValid(row);
  1288. },
  1289. // 当更改一个工序开始时间 结束时间的时候
  1290. // 开始时间 不能小于之前工序的结束时间 ( 要先去上一道工序找 是否存在结束时间 不存在就再往前找 直到 第一道工序 )
  1291. // 结束时间 不能大于后面工序的开始时间 ( 要先去后一道工序找 是否存在开始时间 不存在就再往后找 直到 最后一道工序 )
  1292. // 计算出当前下标数据 的前后 有 开始时间 结束时间的数据下标
  1293. calculateIndex(index) {
  1294. let startIdx = 'none';
  1295. let endIdx = 'none';
  1296. // 前面工序下标
  1297. for (let i = index - 1; i >= 0; i--) {
  1298. let row = this.processList[i];
  1299. if (row && row.endDate) {
  1300. startIdx = i;
  1301. break;
  1302. }
  1303. }
  1304. // 后面工序的下标
  1305. for (let i = index + 1; i <= this.processList.length; i++) {
  1306. let row = this.processList[i];
  1307. if (row && row.startDate) {
  1308. endIdx = i;
  1309. break;
  1310. }
  1311. }
  1312. return {
  1313. startIdx,
  1314. endIdx
  1315. };
  1316. },
  1317. // 【结束时间变化时】触发
  1318. handleEndTimeChange(row, item) {
  1319. if (!row.endTime) {
  1320. return;
  1321. }
  1322. this.selectedListData(row, item);
  1323. const endTime = new Date(row.endTime); // 结束时间
  1324. // 当前工序的结束时间 不能大于后一道工序的开始时间
  1325. if (item.index !== this.processList.length - 1) {
  1326. let latterIdx = this.calculateIndex(item.index).endIdx;
  1327. if (latterIdx !== 'none') {
  1328. let latterName = this.processList[latterIdx].name;
  1329. let time = this.processList[latterIdx].startDate;
  1330. const latterTime = new Date(time); // 后面工序的开始时间
  1331. if (time && endTime > latterTime) {
  1332. this.$message.closeAll();
  1333. this.$message.info(
  1334. `结束时间不能大于后面工序${latterName}的开始时间${time}`
  1335. );
  1336. // 判断是否 配置时间更改规则
  1337. if (this.time_calc_code == '1') {
  1338. row.endTime = time;
  1339. }
  1340. return;
  1341. }
  1342. }
  1343. }
  1344. // 这一道工序的开始时间更不能小于于前一道工序的结束时间
  1345. if (item.index !== 0) {
  1346. // let frontIdx = item.index - 1;
  1347. let frontIdx = this.calculateIndex(item.index).startIdx;
  1348. if (frontIdx !== 'none') {
  1349. let frontName = this.processList[frontIdx].name;
  1350. let time = this.processList[frontIdx].endDate;
  1351. const frontTime = new Date(time); // 上一道工序的结束时间
  1352. if (time && endTime < frontTime) {
  1353. this.$message.closeAll();
  1354. this.$message.info(
  1355. `结束时间不能小于前面工序${frontName}的结束时间${time}`
  1356. );
  1357. // 判断是否 配置时间更改规则
  1358. if (this.time_calc_code == '1') {
  1359. row.endTime = '';
  1360. }
  1361. return;
  1362. }
  1363. }
  1364. }
  1365. this.checkEndTimeValid(row, item);
  1366. },
  1367. // 时间校验
  1368. checkEndTimeValid(row) {
  1369. const { startTime: start, endTime: end } = row;
  1370. // if (!start || !end) return; // 开始/结束时间未填,跳过
  1371. const startTime = new Date(start); // 开始时间
  1372. const endTime = new Date(end); // 结束时间
  1373. if (endTime < startTime) {
  1374. row.endTime = new Date(startTime); // 修正为开始时间
  1375. this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
  1376. }
  1377. }
  1378. }
  1379. };
  1380. </script>
  1381. <style lang="scss" scoped>
  1382. .top-box {
  1383. display: flex;
  1384. margin-bottom: 10px;
  1385. .item-box {
  1386. flex: 1;
  1387. }
  1388. }
  1389. .radio-box {
  1390. margin: 10px 0;
  1391. }
  1392. .table {
  1393. margin-top: 20px;
  1394. }
  1395. ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  1396. background-color: #10d070;
  1397. border-color: #10d070;
  1398. }
  1399. ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  1400. box-shadow: none;
  1401. }
  1402. // ::v-deep .ele-block{
  1403. // width: 240px;
  1404. // }
  1405. // ::v-deep .basic {
  1406. // .el-form-item {
  1407. // width: 100%;
  1408. // }
  1409. // .form80 {
  1410. // .el-form-item__content {
  1411. // width: calc(100% - 80px);
  1412. // }
  1413. // }
  1414. // .form65 {
  1415. // .el-form-item__content {
  1416. // width: calc(100% - 65px);
  1417. // }
  1418. // }
  1419. // .el-form-item__label {
  1420. // padding: 0 4px 0 0;
  1421. // }
  1422. // .item_label {
  1423. // white-space: nowrap;
  1424. // overflow: hidden;
  1425. // text-overflow: ellipsis;
  1426. // width: 100%;
  1427. // }
  1428. // }
  1429. .describe {
  1430. display: inline-block;
  1431. }
  1432. </style>