TaskConfigPanel.vue 115 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699
  1. <template>
  2. <div
  3. :class="['config-panel', { 'dispatch-config-panel': orderDispatchStyle }]"
  4. >
  5. <template v-if="orderDispatchStyle">
  6. <el-empty v-if="taskList.length === 0" description="暂无工序"></el-empty>
  7. <div v-else class="dispatch-style-panel">
  8. <div class="dispatch-report-type">
  9. <span class="dispatch-required">*</span>
  10. <span class="dispatch-report-label">报工类型:</span>
  11. <el-radio-group v-model="dispatchReportType">
  12. <el-radio :label="1">单件报工</el-radio>
  13. <el-radio :label="0">批量报工</el-radio>
  14. </el-radio-group>
  15. <div class="dispatch-plan-info">
  16. <span class="dispatch-plan-item">
  17. <span class="dispatch-plan-label">已派单数量:</span>
  18. <span class="dispatch-plan-value">
  19. {{ quantityLimit || 0 }}{{ currentPlan.unit }}
  20. </span>
  21. </span>
  22. <span class="dispatch-plan-item">
  23. <span class="dispatch-plan-label">未派单数量:</span>
  24. <span class="dispatch-plan-value">
  25. {{ currentPlan.productNum - quantityLimit || 0
  26. }}{{ currentPlan.unit }}
  27. </span>
  28. </span>
  29. <span class="dispatch-plan-item">
  30. <span class="dispatch-plan-label">计划数量:</span>
  31. <span class="dispatch-plan-value">
  32. {{ dispatchPlanQuantityDisplay }}
  33. </span>
  34. </span>
  35. <span class="dispatch-plan-item">
  36. <span class="dispatch-plan-label">计划时间:</span>
  37. <span class="dispatch-plan-value">
  38. {{ dispatchPlanTimeDisplay }}
  39. </span>
  40. </span>
  41. </div>
  42. </div>
  43. <el-tabs
  44. v-model="activeTaskKey"
  45. type="border-card"
  46. class="dispatch-process-tabs"
  47. >
  48. <el-tab-pane
  49. v-for="(item, index) in dispatchTaskTabs"
  50. :key="dispatchTaskGroupKey(item)"
  51. :label="taskName(item, index)"
  52. :name="dispatchTaskGroupKey(item)"
  53. />
  54. </el-tabs>
  55. <div class="dispatch-process-meta">
  56. 工序编码:{{ taskCodeDisplay(activeTask) }},所属班组:{{
  57. dispatchTeamDisplay(activeTask)
  58. }},班组长:{{ dispatchTeamLeaderDisplay(activeTask) }}
  59. </div>
  60. <div class="dispatch-toolbar">
  61. <div class="dispatch-toolbar-left">
  62. <el-button
  63. v-if="showFirstTaskConfirmButton"
  64. type="primary"
  65. size="mini"
  66. :loading="dispatchToolbarLoading"
  67. :disabled="readonlyMode || isDispatchToolbarDisabled('confirm')"
  68. @click="handleFirstTaskConfirm"
  69. >
  70. 确定
  71. </el-button>
  72. <el-button
  73. type="primary"
  74. size="mini"
  75. :loading="dispatchToolbarLoading"
  76. :disabled="readonlyMode || isDispatchToolbarDisabled(1)"
  77. @click="handleDispatchToolbarAction(1)"
  78. >
  79. 任务派单
  80. </el-button>
  81. <el-button
  82. type="primary"
  83. size="mini"
  84. :loading="dispatchToolbarLoading"
  85. :disabled="readonlyMode || isDispatchToolbarDisabled(2)"
  86. @click="handleDispatchToolbarAction(2)"
  87. >
  88. 撤回
  89. </el-button>
  90. <el-button
  91. type="primary"
  92. size="mini"
  93. :loading="dispatchToolbarLoading"
  94. :disabled="readonlyMode || isDispatchToolbarDisabled(3)"
  95. @click="handleDispatchToolbarAction(3)"
  96. >
  97. 保存
  98. </el-button>
  99. <el-button
  100. type="success"
  101. size="mini"
  102. :loading="dispatchToolbarLoading"
  103. :disabled="
  104. readonlyMode || isDispatchToolbarDisabled('addStation')
  105. "
  106. @click="handleDispatchAddStation"
  107. >
  108. 添加工位
  109. </el-button>
  110. </div>
  111. <div class="dispatch-assign-mode">
  112. <span class="dispatch-assign-label">指派:</span>
  113. <el-radio-group :value="1" size="mini">
  114. <el-radio-button :label="1">工位</el-radio-button>
  115. <!-- <el-radio-button :label="3">产线</el-radio-button> -->
  116. </el-radio-group>
  117. </div>
  118. <div class="dispatch-toolbar-icons">
  119. <el-tooltip content="刷新" placement="top">
  120. <el-button
  121. square
  122. size="mini"
  123. :loading="dispatchRefreshLoading"
  124. @click="handleDispatchRefresh"
  125. >
  126. <i class="el-icon-refresh"></i>
  127. </el-button>
  128. </el-tooltip>
  129. <el-popover
  130. placement="bottom-end"
  131. width="220"
  132. trigger="click"
  133. popper-class="dispatch-column-popover"
  134. >
  135. <div class="dispatch-column-settings">
  136. <div class="dispatch-column-settings__title">列设置</div>
  137. <el-checkbox-group
  138. v-model="dispatchVisibleColumns"
  139. class="dispatch-column-settings__list"
  140. @change="handleDispatchColumnVisibleChange"
  141. >
  142. <el-checkbox
  143. v-for="column in dispatchColumnOptions"
  144. :key="column.key"
  145. :label="column.key"
  146. >
  147. {{ column.label }}
  148. </el-checkbox>
  149. </el-checkbox-group>
  150. </div>
  151. <el-button slot="reference" square size="mini">
  152. <i class="el-icon-s-operation"></i>
  153. </el-button>
  154. </el-popover>
  155. <el-tooltip
  156. :content="dotLineFullscreen ? '退出全屏' : '全屏展示'"
  157. placement="top"
  158. >
  159. <el-button square size="mini" @click="$emit('toggle-fullscreen')">
  160. <i
  161. :class="
  162. dotLineFullscreen
  163. ? 'el-icon-_screen-restore'
  164. : 'el-icon-full-screen'
  165. "
  166. ></i>
  167. </el-button>
  168. </el-tooltip>
  169. </div>
  170. </div>
  171. <div class="dispatch-table-wrap">
  172. <el-table
  173. ref="dispatchTable"
  174. :data="pagedDispatchObjectRows"
  175. border
  176. size="small"
  177. :row-key="dispatchObjectRowKey"
  178. :row-class-name="getDispatchTableRowClassName"
  179. height="100%"
  180. class="config-table dispatch-table"
  181. >
  182. <el-table-column
  183. type="index"
  184. label="序号"
  185. width="52"
  186. align="center"
  187. />
  188. <el-table-column width="44" align="center">
  189. <template slot="header">
  190. <el-checkbox
  191. class="dispatch-state-checkbox"
  192. :value="isCurrentPageDispatchChecked"
  193. :indeterminate="isCurrentPageDispatchIndeterminate"
  194. :disabled="
  195. readonlyMode || !currentPageSelectableDispatchRows.length
  196. "
  197. @change="handleCurrentPageDispatchCheckChange"
  198. />
  199. </template>
  200. <template slot-scope="{ row }">
  201. <el-tooltip
  202. :disabled="!isDeviceSnapshotLocked(row)"
  203. content="该工序已制定设备类型"
  204. placement="top"
  205. popper-class="dispatch-device-lock-tooltip"
  206. >
  207. <span class="dispatch-checkbox-wrap">
  208. <el-checkbox
  209. class="dispatch-state-checkbox"
  210. :value="isSelectedDispatchObject(row)"
  211. :disabled="isDispatchRowControlDisabled(row)"
  212. @change="handleDispatchObjectCheckChange(row, $event)"
  213. />
  214. </span>
  215. </el-tooltip>
  216. </template>
  217. </el-table-column>
  218. <el-table-column
  219. v-if="isDispatchColumnVisible('displayName')"
  220. prop="displayName"
  221. label="工位名称"
  222. align="center"
  223. min-width="180"
  224. >
  225. <template slot-scope="{ row }">
  226. <el-tooltip
  227. :disabled="!isDeviceSnapshotLocked(row) && !row.displayName"
  228. :content="
  229. isDeviceSnapshotLocked(row)
  230. ? '该工序已制定设备类型'
  231. : row.displayName || ''
  232. "
  233. placement="top"
  234. :popper-class="
  235. isDeviceSnapshotLocked(row)
  236. ? 'dispatch-device-lock-tooltip'
  237. : 'dispatch-workstation-tooltip'
  238. "
  239. >
  240. <span class="dispatch-workstation-name">
  241. {{ row.displayName }}
  242. </span>
  243. </el-tooltip>
  244. </template>
  245. </el-table-column>
  246. <el-table-column
  247. v-if="isDispatchColumnVisible('code')"
  248. prop="code"
  249. label="编码"
  250. align="center"
  251. min-width="140"
  252. show-overflow-tooltip
  253. />
  254. <el-table-column
  255. v-if="isDispatchColumnVisible('assetCode')"
  256. prop="assetCode"
  257. label="设备编码"
  258. align="center"
  259. min-width="140"
  260. show-overflow-tooltip
  261. />
  262. <el-table-column
  263. v-if="isDispatchColumnVisible('assetName')"
  264. prop="assetName"
  265. label="设备名称"
  266. align="center"
  267. min-width="140"
  268. show-overflow-tooltip
  269. />
  270. <el-table-column
  271. v-if="isDispatchColumnVisible('userNames')"
  272. prop="userNames"
  273. label="人员"
  274. align="center"
  275. min-width="140"
  276. show-overflow-tooltip
  277. />
  278. <el-table-column
  279. v-if="isDispatchColumnVisible('assetModelType')"
  280. prop="assetModelType"
  281. label="设备型号"
  282. align="center"
  283. min-width="140"
  284. show-overflow-tooltip
  285. />
  286. <el-table-column
  287. v-if="isDispatchColumnVisible('assetCategoryLevelPath')"
  288. prop="assetCategoryLevelPath"
  289. label="设备类型"
  290. align="center"
  291. min-width="140"
  292. show-overflow-tooltip
  293. />
  294. <el-table-column
  295. v-if="isDispatchColumnVisible('status')"
  296. prop="status"
  297. label="状态"
  298. align="center"
  299. width="120"
  300. >
  301. <template slot-scope="{ row }">
  302. <span
  303. v-if="getDispatchStatusText(row.status)"
  304. :class="[
  305. 'dispatch-status-badge',
  306. { 'is-assigned': isDispatchRowAssigned(row) }
  307. ]"
  308. >
  309. {{ getDispatchStatusText(row.status) }}
  310. </span>
  311. </template>
  312. </el-table-column>
  313. <el-table-column
  314. v-if="isDispatchColumnVisible('quantity')"
  315. label="数量"
  316. align="center"
  317. width="140"
  318. >
  319. <template slot-scope="{ row }">
  320. <el-tooltip
  321. :disabled="!isDeviceSnapshotLocked(row)"
  322. content="该工序已制定设备类型"
  323. placement="top"
  324. popper-class="dispatch-device-lock-tooltip"
  325. >
  326. <span class="dispatch-disabled-field">
  327. <el-input
  328. :value="row.quantity"
  329. placeholder="请输入数量"
  330. class="config-table-control"
  331. :disabled="isDispatchRowControlDisabled(row)"
  332. @input="handleDispatchRowQuantityInput(row, $event)"
  333. />
  334. </span>
  335. </el-tooltip>
  336. </template>
  337. </el-table-column>
  338. <el-table-column
  339. v-if="isDispatchColumnVisible('standardHours')"
  340. label="标准工时(小时)"
  341. align="center"
  342. min-width="120"
  343. >
  344. <template slot-scope="{ row }">
  345. <el-tooltip
  346. :disabled="!isDeviceSnapshotLocked(row)"
  347. content="该工序已制定设备类型"
  348. placement="top"
  349. popper-class="dispatch-device-lock-tooltip"
  350. >
  351. <span class="dispatch-disabled-field">
  352. <el-input
  353. :value="row.standardHours"
  354. placeholder="请输入标准工时"
  355. :disabled="isDispatchRowControlDisabled(row)"
  356. type="number"
  357. class="config-table-control"
  358. @input="(value) => handleDispatchRowStandardHoursChange(row, value)"
  359. />
  360. </span>
  361. </el-tooltip>
  362. </template>
  363. </el-table-column>
  364. <el-table-column
  365. v-if="isDispatchColumnVisible('startTime')"
  366. label="计划开始时间"
  367. align="center"
  368. min-width="220"
  369. >
  370. <template slot-scope="{ row }">
  371. <el-tooltip
  372. :disabled="!isDeviceSnapshotLocked(row)"
  373. content="该工序已制定设备类型"
  374. placement="top"
  375. popper-class="dispatch-device-lock-tooltip"
  376. >
  377. <span class="dispatch-disabled-field">
  378. <el-date-picker
  379. v-model="row.executionStartTime"
  380. type="datetime"
  381. value-format="yyyy-MM-dd HH:mm:ss"
  382. placeholder="开始时间"
  383. clearable
  384. class="config-table-control"
  385. :disabled="isDispatchRowControlDisabled(row)"
  386. @change="handleDispatchRowStartTimeChange(row)"
  387. />
  388. </span>
  389. </el-tooltip>
  390. </template>
  391. </el-table-column>
  392. <el-table-column
  393. v-if="isDispatchColumnVisible('endTime')"
  394. label="计划完成时间"
  395. align="center"
  396. min-width="220"
  397. >
  398. <template slot-scope="{ row }">
  399. <div
  400. :class="{
  401. 'last-end-over-plan-wrap': isExecutionEndOverPlanEnd(
  402. getDispatchRowTask(row)
  403. ),
  404. 'end-over-delivery-wrap': isExecutionEndOverDelivery(
  405. getDispatchRowTask(row)
  406. )
  407. }"
  408. >
  409. <el-tooltip
  410. :disabled="!isDeviceSnapshotLocked(row)"
  411. content="该工序已制定设备类型"
  412. placement="top"
  413. popper-class="dispatch-device-lock-tooltip"
  414. >
  415. <span class="dispatch-disabled-field">
  416. <el-date-picker
  417. v-model="row.executionEndTime"
  418. type="datetime"
  419. value-format="yyyy-MM-dd HH:mm:ss"
  420. placeholder="完成时间"
  421. clearable
  422. class="config-table-control"
  423. :disabled="isDispatchRowControlDisabled(row)"
  424. @change="handleDispatchRowEndTimeChange(row)"
  425. />
  426. </span>
  427. </el-tooltip>
  428. </div>
  429. </template>
  430. </el-table-column>
  431. <el-table-column
  432. v-if="isDispatchColumnVisible('action')"
  433. label="操作"
  434. width="88"
  435. align="center"
  436. >
  437. <template slot-scope="{ row }">
  438. <el-link
  439. v-if="canDeleteAddedDispatchStation(row)"
  440. type="danger"
  441. :underline="false"
  442. @click="handleDeleteAddedDispatchStation(row)"
  443. >
  444. 删除
  445. </el-link>
  446. <el-popconfirm
  447. v-if="canResetDispatchRow(row)"
  448. title="确定要重置该条数据吗?"
  449. @confirm="handleDispatchRowReset(row)"
  450. >
  451. <template v-slot:reference>
  452. <el-link type="primary" :underline="false">重置</el-link>
  453. </template>
  454. </el-popconfirm>
  455. </template>
  456. </el-table-column>
  457. </el-table>
  458. </div>
  459. <div v-if="dispatchObjectRows.length" class="dispatch-pagination">
  460. <el-pagination
  461. background
  462. :current-page="dispatchPage"
  463. :page-size="dispatchPageSize"
  464. :page-sizes="[10, 20, 50, 100]"
  465. :total="dispatchObjectRows.length"
  466. layout="total, sizes, prev, pager, next, jumper"
  467. @size-change="handleDispatchPageSizeChange"
  468. @current-change="handleDispatchPageChange"
  469. />
  470. </div>
  471. </div>
  472. </template>
  473. <template v-else>
  474. <div class="panel-header">
  475. <div class="panel-title">工艺配置</div>
  476. <div class="panel-actions">
  477. <span v-if="readonlyMode" class="readonly-tip">
  478. 当前状态仅支持查看
  479. </span>
  480. <el-tooltip
  481. :content="dotLineFullscreen ? '退出全屏' : '全屏展示'"
  482. placement="top"
  483. >
  484. <el-button circle size="mini" @click="$emit('toggle-fullscreen')">
  485. <i
  486. :class="
  487. dotLineFullscreen
  488. ? 'el-icon-_screen-restore'
  489. : 'el-icon-full-screen'
  490. "
  491. ></i>
  492. </el-button>
  493. </el-tooltip>
  494. <el-button
  495. v-if="showApproveButton"
  496. type="primary"
  497. size="mini"
  498. :loading="approveLoading"
  499. :disabled="approveButtonDisabled"
  500. @click="$emit('approve')"
  501. >
  502. 审批
  503. </el-button>
  504. <el-button
  505. type="primary"
  506. size="mini"
  507. :disabled="!currentPlan || dotLineLoading || readonlyMode"
  508. @click="$emit('submit')"
  509. >
  510. 保存
  511. </el-button>
  512. </div>
  513. </div>
  514. <el-empty v-if="taskList.length === 0" description="暂无工艺"></el-empty>
  515. <div v-else class="task-config-table-wrap">
  516. <el-table
  517. :data="taskList"
  518. border
  519. size="small"
  520. row-key="_taskKey"
  521. :height="normalTableHeight"
  522. :max-height="normalTableMaxHeight"
  523. class="config-table"
  524. >
  525. <el-table-column
  526. type="index"
  527. label="序号"
  528. width="46"
  529. align="center"
  530. class-name="config-table-index-col"
  531. />
  532. <el-table-column
  533. label="工序名称"
  534. min-width="82"
  535. show-overflow-tooltip
  536. class-name="task-name-cell"
  537. align="center"
  538. >
  539. <template slot-scope="{ row, $index }">
  540. <span class="task-name-text">{{ taskName(row, $index) }}</span>
  541. </template>
  542. </el-table-column>
  543. <el-table-column label="工序并行" min-width="92" align="center">
  544. <template slot-scope="{ row }">
  545. <el-select
  546. v-model="row.isParallel"
  547. placeholder="工序并行"
  548. :disabled="readonlyMode"
  549. class="config-table-control"
  550. @change="$emit('parallelism-change', row)"
  551. >
  552. <el-option label="否" :value="0" />
  553. <el-option label="是" :value="1" />
  554. </el-select>
  555. </template>
  556. </el-table-column>
  557. <el-table-column label="执行模式" min-width="84" align="center">
  558. <template slot-scope="{ row }">
  559. <el-select
  560. v-model="row.executionType"
  561. placeholder="执行模式"
  562. clearable
  563. :disabled="readonlyMode"
  564. class="config-table-control"
  565. @change="$emit('execution-type-change', row)"
  566. >
  567. <el-option
  568. v-for="opt in executionTypeOptions"
  569. :key="opt.value"
  570. :label="opt.label"
  571. :value="opt.value"
  572. />
  573. </el-select>
  574. </template>
  575. </el-table-column>
  576. <el-table-column
  577. :label="homemadeObjectLabel"
  578. min-width="116"
  579. align="center"
  580. >
  581. <template slot-scope="{ row }">
  582. <el-select
  583. v-if="execTypeNum(row) === execType.HOMEMADE"
  584. v-model="row.executionTeamId"
  585. placeholder="请选择"
  586. clearable
  587. filterable
  588. :disabled="readonlyMode"
  589. class="config-table-control"
  590. @change="$emit('execution-object-change', row)"
  591. >
  592. <!-- 班组排程需要按当前工序过滤工位;工厂排程回退为原 teamOptions。 -->
  593. <el-option
  594. v-for="team in homemadeOptions(row)"
  595. :key="team.id"
  596. :label="team.name"
  597. :value="team.id"
  598. />
  599. </el-select>
  600. <el-select
  601. v-else-if="execTypeNum(row) === execType.ENTRUST"
  602. v-model="row.executionFactoryId"
  603. placeholder="请选择"
  604. clearable
  605. filterable
  606. :disabled="readonlyMode"
  607. class="config-table-control"
  608. @change="$emit('execution-object-change', row)"
  609. >
  610. <el-option
  611. v-for="factory in factoryList"
  612. :key="factory.value"
  613. :label="factory.label"
  614. :value="factory.value"
  615. />
  616. </el-select>
  617. <el-select
  618. v-else-if="execTypeNum(row) === execType.OUTSOURCE"
  619. :value="''"
  620. placeholder="委外无需选择"
  621. disabled
  622. class="config-table-control"
  623. />
  624. <el-select
  625. v-else
  626. :value="''"
  627. placeholder="请先选择执行模式"
  628. disabled
  629. class="config-table-control"
  630. />
  631. </template>
  632. </el-table-column>
  633. <el-table-column
  634. v-if="showQuantityColumn"
  635. label="数量"
  636. min-width="82"
  637. align="center"
  638. >
  639. <!-- 数量只在班组排程工序配置中开放,工厂排程不渲染该列。 -->
  640. <template slot-scope="{ row }">
  641. <el-input-number
  642. v-model="row.quantity"
  643. :min="0"
  644. :controls="false"
  645. :precision="3"
  646. placeholder="请输入数量"
  647. :disabled="readonlyMode"
  648. class="config-table-control"
  649. />
  650. </template>
  651. </el-table-column>
  652. <el-table-column label="标准工时(小时)" min-width="120" align="center">
  653. <template slot-scope="{ row }">
  654. <el-input
  655. v-model="row.standardHours"
  656. placeholder="请输入标准工时"
  657. :disabled="readonlyMode"
  658. type="number"
  659. class="config-table-control"
  660. @input="(value) => handleStandardHoursChange(row, value)"
  661. >
  662. <!-- <template slot="append">
  663. <span>H</span>
  664. </template> -->
  665. </el-input>
  666. </template>
  667. </el-table-column>
  668. <el-table-column label="执行开始时间" min-width="164" align="center">
  669. <template slot-scope="{ row }">
  670. <el-date-picker
  671. v-model="row.executionStartTime"
  672. type="datetime"
  673. value-format="yyyy-MM-dd HH:mm:ss"
  674. placeholder="执行开始时间"
  675. clearable
  676. :disabled="readonlyMode"
  677. class="config-table-control"
  678. @change="$emit('time-change', row, 'executionStartTime')"
  679. />
  680. </template>
  681. </el-table-column>
  682. <el-table-column label="执行结束时间" min-width="164" align="center">
  683. <template slot-scope="{ row }">
  684. <div
  685. :class="{
  686. 'last-end-over-plan-wrap': isExecutionEndOverPlanEnd(row),
  687. 'end-over-delivery-wrap': isExecutionEndOverDelivery(row)
  688. }"
  689. >
  690. <el-date-picker
  691. v-model="row.executionEndTime"
  692. type="datetime"
  693. value-format="yyyy-MM-dd HH:mm:ss"
  694. placeholder="执行结束时间"
  695. clearable
  696. :disabled="readonlyMode"
  697. class="config-table-control"
  698. @change="$emit('time-change', row, 'executionEndTime')"
  699. />
  700. </div>
  701. </template>
  702. </el-table-column>
  703. <el-table-column label="操作" width="64" align="center">
  704. <template slot-scope="{ row }">
  705. <el-button
  706. type="text"
  707. size="small"
  708. :disabled="!currentPlan || dotLineLoading || readonlyMode"
  709. @click="$emit('row-submit', row)"
  710. >
  711. 缓存
  712. </el-button>
  713. </template>
  714. </el-table-column>
  715. </el-table>
  716. </div>
  717. </template>
  718. <choose-station
  719. v-if="orderDispatchStyle"
  720. ref="chooseStationRef"
  721. @chooseStationList="handleChooseStationList"
  722. />
  723. </div>
  724. </template>
  725. <script>
  726. import chooseStation from '@/views/workOrder/components/chooseStation.vue';
  727. import {
  728. checkAssignConfirm,
  729. checkAssignSourceType,
  730. listAssign,
  731. listByPlanIdAndTaskId,
  732. parameterGetByCode,
  733. resetAssignee,
  734. taskAssignment,
  735. taskRevoked,
  736. taskSave
  737. } from '@/api/mainData/index.js';
  738. import {
  739. getcheckLoginUserIsTeamLeader,
  740. releaseWorkOrder
  741. } from '@/api/workOrder/index.js';
  742. const DISPATCH_TEAM_ID_KEYS = [
  743. 'dispatchTeamId',
  744. 'teamId',
  745. 'firstTaskTeamId',
  746. 'firstTeamId',
  747. 'teamIds'
  748. ];
  749. const DISPATCH_TEAM_NAME_KEYS = [
  750. 'dispatchTeamName',
  751. 'teamName',
  752. 'firstTaskTeamName',
  753. 'firstTeamName',
  754. 'teamNames'
  755. ];
  756. export default {
  757. name: 'TaskConfigPanel',
  758. components: {
  759. chooseStation
  760. },
  761. props: {
  762. dotLineFullscreen: {
  763. type: Boolean,
  764. default: false
  765. },
  766. isCurrentPlanReadonly: {
  767. type: Boolean,
  768. default: false
  769. },
  770. orderDetailReadonly: {
  771. type: Boolean,
  772. default: false
  773. },
  774. currentPlan: {
  775. type: Object,
  776. default: null
  777. },
  778. dotLineLoading: {
  779. type: Boolean,
  780. default: false
  781. },
  782. taskList: {
  783. type: Array,
  784. default: () => []
  785. },
  786. executionTypeOptions: {
  787. type: Array,
  788. default: () => []
  789. },
  790. teamOptions: {
  791. type: Array,
  792. default: () => []
  793. },
  794. getHomemadeOptions: {
  795. type: Function,
  796. default: null
  797. },
  798. homemadeObjectLabel: {
  799. type: String,
  800. default: '执行对象'
  801. },
  802. showQuantityColumn: {
  803. type: Boolean,
  804. default: false
  805. },
  806. orderDispatchStyle: {
  807. type: Boolean,
  808. default: false
  809. },
  810. showApproveButton: {
  811. type: Boolean,
  812. default: false
  813. },
  814. approveButtonDisabled: {
  815. type: Boolean,
  816. default: true
  817. },
  818. approveLoading: {
  819. type: Boolean,
  820. default: false
  821. },
  822. tableMaxHeight: {
  823. type: Number,
  824. default: 390
  825. },
  826. fillTableHeight: {
  827. type: Boolean,
  828. default: false
  829. },
  830. factoryList: {
  831. type: Array,
  832. default: () => []
  833. },
  834. execType: {
  835. type: Object,
  836. required: true
  837. },
  838. taskName: {
  839. type: Function,
  840. required: true
  841. },
  842. execTypeNum: {
  843. type: Function,
  844. required: true
  845. },
  846. isExecutionEndOverDelivery: {
  847. type: Function,
  848. required: true
  849. },
  850. isExecutionEndOverPlanEnd: {
  851. type: Function,
  852. required: true
  853. }
  854. },
  855. data() {
  856. return {
  857. activeTaskKey: '',
  858. dispatchPage: 1,
  859. dispatchPageSize: 20,
  860. dispatchRowDraftMap: {},
  861. dispatchAssignmentMap: {},
  862. dispatchDeviceSnapshotMap: {},
  863. dispatchDeviceSnapshotLoading: false,
  864. dispatchDeviceSnapshotRequestKey: '',
  865. dispatchToolbarLoading: false,
  866. dispatchRefreshLoading: false,
  867. dispatchReportType: 1,
  868. dispatchColumnOptions: [
  869. { key: 'displayName', label: '工位名称' },
  870. { key: 'code', label: '编码' },
  871. { key: 'assetCode', label: '设备编码' },
  872. { key: 'assetName', label: '设备名称' },
  873. { key: 'userNames', label: '人员' },
  874. { key: 'assetModelType', label: '设备型号' },
  875. { key: 'assetCategoryLevelPath', label: '设备类型' },
  876. { key: 'status', label: '状态' },
  877. { key: 'quantity', label: '数量' },
  878. { key: 'standardHours', label: '标准工时(小时)' },
  879. { key: 'startTime', label: '计划开始时间' },
  880. { key: 'endTime', label: '计划完成时间' },
  881. { key: 'action', label: '操作' }
  882. ],
  883. dispatchColumnVisible: {
  884. displayName: true,
  885. code: true,
  886. assetCode: true,
  887. assetName: true,
  888. userNames: true,
  889. assetModelType: true,
  890. assetCategoryLevelPath: true,
  891. status: true,
  892. quantity: true,
  893. standardHours: true,
  894. startTime: true,
  895. endTime: true,
  896. action: true
  897. },
  898. suppressTaskListAssignReloadUntil: 0
  899. };
  900. },
  901. computed: {
  902. readonlyMode() {
  903. return this.orderDetailReadonly || this.isCurrentPlanReadonly;
  904. },
  905. dispatchVisibleColumns: {
  906. get() {
  907. return this.dispatchColumnOptions
  908. .filter((item) => this.dispatchColumnVisible[item.key] !== false)
  909. .map((item) => item.key);
  910. },
  911. set(keys) {
  912. const visibleKeys = new Set(keys);
  913. this.dispatchColumnOptions.forEach((item) => {
  914. this.$set(
  915. this.dispatchColumnVisible,
  916. item.key,
  917. visibleKeys.has(item.key)
  918. );
  919. });
  920. }
  921. },
  922. dispatchTaskTabs() {
  923. const groupMap = new Map();
  924. (this.taskList || []).forEach((item) => {
  925. const groupKey = this.dispatchTaskGroupKey(item);
  926. if (!groupMap.has(groupKey)) {
  927. groupMap.set(groupKey, item);
  928. }
  929. });
  930. return Array.from(groupMap.values());
  931. },
  932. activeTask() {
  933. return (
  934. (this.taskList || []).find(
  935. (item) => this.dispatchTaskGroupKey(item) === this.activeTaskKey
  936. ) ||
  937. this.dispatchTaskTabs[0] ||
  938. null
  939. );
  940. },
  941. showFirstTaskConfirmButton() {
  942. return (
  943. this.orderDispatchStyle &&
  944. !this.readonlyMode &&
  945. this.isFirstDispatchTask(this.activeTask)
  946. );
  947. },
  948. reportTypeValue() {
  949. return this.normalizeDispatchReportType(this.dispatchReportType);
  950. },
  951. dispatchPlanQuantityDisplay() {
  952. const plan = this.currentPlan || {};
  953. const num =
  954. plan.productNum ??
  955. plan.formingNum ??
  956. plan.planNum ??
  957. plan.requiredFormingNum ??
  958. '';
  959. const unit = plan.measuringUnit || plan.unit || '';
  960. const text = [num, unit]
  961. .filter((item) => item !== null && item !== undefined && item !== '')
  962. .join('');
  963. return text || '--';
  964. },
  965. dispatchPlanQuantityLimit() {
  966. const plan = this.currentPlan || {};
  967. return this.parseDispatchQuantity(
  968. plan.productNum ??
  969. plan.formingNum ??
  970. plan.planNum ??
  971. plan.requiredFormingNum ??
  972. ''
  973. );
  974. },
  975. dispatchPlanTimeDisplay() {
  976. const plan = this.currentPlan || {};
  977. const start =
  978. plan.startTime || plan.planStartTime || plan.executionStartTime || '';
  979. const end =
  980. plan.endTime ||
  981. plan.planEndTime ||
  982. plan.planCompleteTime ||
  983. plan.executionEndTime ||
  984. '';
  985. const startText = this.formatDispatchDateTime(start);
  986. const endText = this.formatDispatchDateTime(end);
  987. if (startText && endText) {
  988. return `${startText} 至 ${endText}`;
  989. }
  990. return startText || endText || '--';
  991. },
  992. dispatchObjectRows() {
  993. if (!this.activeTask) {
  994. return [];
  995. }
  996. return this.homemadeOptions(this.activeTask)
  997. .filter((item) => item.objectType !== 'person')
  998. .map((item) => {
  999. const displayName = String(item.name || '').replace(
  1000. /^工位[::]/,
  1001. ''
  1002. );
  1003. const rowKey = this.dispatchObjectRowKey(item);
  1004. const task = this.getDispatchRowTask(item);
  1005. const draft =
  1006. this.dispatchRowDraftMap[this.dispatchRowDraftKey(item)] || {};
  1007. const assignment = this.getDispatchAssignment(item);
  1008. const defaultStartTime =
  1009. this.activeTask.dispatchDefaultStartTime || '';
  1010. const defaultEndTime = this.activeTask.dispatchDefaultEndTime || '';
  1011. return {
  1012. ...item,
  1013. id: rowKey,
  1014. displayName,
  1015. quantity:
  1016. draft.quantity !== undefined
  1017. ? draft.quantity
  1018. : task
  1019. ? this.formatDispatchRowQuantity(task.quantity)
  1020. : assignment
  1021. ? this.formatDispatchRowQuantity(assignment.quantity)
  1022. : '',
  1023. standardHours:
  1024. draft.standardHours !== undefined
  1025. ? draft.standardHours
  1026. : task?.standardHours || '',
  1027. executionStartTime:
  1028. draft.executionStartTime !== undefined
  1029. ? draft.executionStartTime
  1030. : task?.executionStartTime ||
  1031. assignment?.executionStartTime ||
  1032. defaultStartTime,
  1033. executionEndTime:
  1034. draft.executionEndTime !== undefined
  1035. ? draft.executionEndTime
  1036. : task?.executionEndTime ||
  1037. assignment?.executionEndTime ||
  1038. defaultEndTime,
  1039. status: assignment?.status || '',
  1040. changeId: assignment?.changeId || '',
  1041. teamTimeIds: task?.teamTimeIds || assignment?.teamTimeIds,
  1042. weight: task?.weight || assignment?.weight || item.weight || '',
  1043. code: item.code || item.workstationCode || '',
  1044. assetCode: this.pickDispatchSingleValue([
  1045. {
  1046. source: item,
  1047. keys: ['assetCode', 'deviceCode']
  1048. },
  1049. {
  1050. source: item.extInfo,
  1051. keys: ['assetCode', 'deviceCode']
  1052. }
  1053. ]),
  1054. assetName: this.pickDispatchSingleValue([
  1055. {
  1056. source: item,
  1057. keys: ['assetName', 'deviceName']
  1058. },
  1059. {
  1060. source: item.extInfo,
  1061. keys: ['assetName', 'deviceName']
  1062. }
  1063. ]),
  1064. userNames: this.pickDispatchTextValue([
  1065. {
  1066. source: item,
  1067. keys: ['userNames']
  1068. },
  1069. {
  1070. source: item.extInfo,
  1071. keys: ['userNames']
  1072. }
  1073. ]),
  1074. assetModelType: item.assetModelType || item.deviceModel || '',
  1075. assetCategoryLevelPath:
  1076. item.assetCategoryLevelPath || item.deviceType || ''
  1077. };
  1078. });
  1079. },
  1080. pagedDispatchObjectRows() {
  1081. const start = (this.dispatchPage - 1) * this.dispatchPageSize;
  1082. return this.dispatchObjectRows.slice(
  1083. start,
  1084. start + this.dispatchPageSize
  1085. );
  1086. },
  1087. selectedDispatchObjectRows() {
  1088. return this.dispatchObjectRows.filter(
  1089. (row) =>
  1090. !this.isDeviceSnapshotLocked(row) &&
  1091. this.isSelectedDispatchObject(row)
  1092. );
  1093. },
  1094. currentPageSelectableDispatchRows() {
  1095. return this.pagedDispatchObjectRows.filter(
  1096. (row) => !this.isDeviceSnapshotLocked(row)
  1097. );
  1098. },
  1099. currentPageSelectedDispatchRows() {
  1100. return this.currentPageSelectableDispatchRows.filter((row) =>
  1101. this.isSelectedDispatchObject(row)
  1102. );
  1103. },
  1104. isCurrentPageDispatchChecked() {
  1105. return (
  1106. this.currentPageSelectableDispatchRows.length > 0 &&
  1107. this.currentPageSelectedDispatchRows.length ===
  1108. this.currentPageSelectableDispatchRows.length
  1109. );
  1110. },
  1111. isCurrentPageDispatchIndeterminate() {
  1112. return (
  1113. this.currentPageSelectedDispatchRows.length > 0 &&
  1114. this.currentPageSelectedDispatchRows.length <
  1115. this.currentPageSelectableDispatchRows.length
  1116. );
  1117. },
  1118. normalTableHeight() {
  1119. return this.fillTableHeight ? '100%' : undefined;
  1120. },
  1121. normalTableMaxHeight() {
  1122. return this.fillTableHeight ? undefined : this.tableMaxHeight;
  1123. },
  1124. quantityLimit() {
  1125. return this.pagedDispatchObjectRows?.reduce((total, row) => {
  1126. return total + this.parseDispatchQuantity(row.quantity);
  1127. }, 0);
  1128. }
  1129. },
  1130. watch: {
  1131. activeTaskKey(newKey, oldKey) {
  1132. this.clearDispatchSelectionsByTaskKey(oldKey);
  1133. this.dispatchPage = 1;
  1134. this.loadDispatchAssignData();
  1135. this.loadDispatchDeviceSnapshots();
  1136. },
  1137. currentPlan: {
  1138. immediate: true,
  1139. handler() {
  1140. this.dispatchReportType = this.getDefaultDispatchReportType();
  1141. this.dispatchRowDraftMap = {};
  1142. this.dispatchAssignmentMap = {};
  1143. this.dispatchDeviceSnapshotMap = {};
  1144. this.dispatchPage = 1;
  1145. this.loadDispatchAssignData();
  1146. this.loadDispatchDeviceSnapshots();
  1147. }
  1148. },
  1149. dispatchObjectRows() {
  1150. const maxPage = Math.max(
  1151. 1,
  1152. Math.ceil(this.dispatchObjectRows.length / this.dispatchPageSize)
  1153. );
  1154. if (this.dispatchPage > maxPage) {
  1155. this.dispatchPage = maxPage;
  1156. }
  1157. },
  1158. taskList: {
  1159. immediate: true,
  1160. handler(list) {
  1161. if (!Array.isArray(list) || list.length === 0) {
  1162. this.activeTaskKey = '';
  1163. this.dispatchRowDraftMap = {};
  1164. this.dispatchDeviceSnapshotMap = {};
  1165. this.dispatchPage = 1;
  1166. return;
  1167. }
  1168. const hasActive = list.some(
  1169. (item) => this.dispatchTaskGroupKey(item) === this.activeTaskKey
  1170. );
  1171. if (!hasActive) {
  1172. this.activeTaskKey = this.dispatchTaskGroupKey(list[0]);
  1173. }
  1174. if (Date.now() < this.suppressTaskListAssignReloadUntil) {
  1175. return;
  1176. }
  1177. this.$nextTick(() => {
  1178. this.loadDispatchAssignData();
  1179. this.loadDispatchDeviceSnapshots();
  1180. });
  1181. }
  1182. }
  1183. },
  1184. methods: {
  1185. normalizeDispatchReportType(value) {
  1186. return String(value) === '0' ? 0 : 1;
  1187. },
  1188. getDefaultDispatchReportType() {
  1189. const value =
  1190. this.currentPlan?.singleReport ??
  1191. this.currentPlan?.reportType ??
  1192. this.currentPlan?.workOrderSingleReport;
  1193. return this.normalizeDispatchReportType(value);
  1194. },
  1195. isDispatchColumnVisible(key) {
  1196. return this.dispatchColumnVisible[key] !== false;
  1197. },
  1198. handleDispatchColumnVisibleChange(keys) {
  1199. if (!keys.length) {
  1200. this.dispatchVisibleColumns = ['displayName'];
  1201. this.$message.warning('至少保留一列');
  1202. }
  1203. this.$nextTick(() => {
  1204. this.$refs.dispatchTable?.doLayout?.();
  1205. });
  1206. },
  1207. parseDispatchQuantity(value) {
  1208. if (value === null || value === undefined || value === '') {
  1209. return null;
  1210. }
  1211. const text = String(value).trim();
  1212. if (!/^([1-9]\d*(\.\d+)?|0\.\d*[1-9]\d*)$/.test(text)) {
  1213. return null;
  1214. }
  1215. const num = Number(text);
  1216. return Number.isFinite(num) ? num : null;
  1217. },
  1218. formatDispatchDateTime(value) {
  1219. if (!value) {
  1220. return '';
  1221. }
  1222. const text = String(value);
  1223. if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(text)) {
  1224. return text.slice(0, 16);
  1225. }
  1226. if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(text)) {
  1227. return text.replace('T', ' ').slice(0, 16);
  1228. }
  1229. return text;
  1230. },
  1231. getDispatchPlanStartTime() {
  1232. const plan = this.currentPlan || {};
  1233. return (
  1234. plan.startTime || plan.planStartTime || plan.executionStartTime || ''
  1235. );
  1236. },
  1237. getDispatchPlanEndTime() {
  1238. const plan = this.currentPlan || {};
  1239. return (
  1240. plan.endTime ||
  1241. plan.planEndTime ||
  1242. plan.planCompleteTime ||
  1243. plan.executionEndTime ||
  1244. ''
  1245. );
  1246. },
  1247. getDispatchTaskDefaultStartTime(row = this.activeTask) {
  1248. return row?.executionStartTime || row?.startTime || '';
  1249. },
  1250. getDispatchTaskDefaultEndTime(row = this.activeTask) {
  1251. return row?.executionEndTime || row?.endTime || '';
  1252. },
  1253. parseDispatchTime(value) {
  1254. if (!value) {
  1255. return null;
  1256. }
  1257. if (value instanceof Date) {
  1258. const dateTime = value.getTime();
  1259. return Number.isFinite(dateTime) ? dateTime : null;
  1260. }
  1261. const text = String(value).replace('T', ' ').replace(/-/g, '/');
  1262. const dateTime = new Date(text).getTime();
  1263. return Number.isFinite(dateTime) ? dateTime : null;
  1264. },
  1265. getDispatchSourceTaskId(row) {
  1266. return (
  1267. row?.sourceTaskId ?? row?.firstTaskId ?? row?.taskId ?? row?.id ?? ''
  1268. );
  1269. },
  1270. dispatchTaskGroupKey(row) {
  1271. return String(
  1272. row?.sourceTaskId ??
  1273. row?.firstTaskId ??
  1274. row?.taskId ??
  1275. row?.id ??
  1276. row?._taskKey ??
  1277. ''
  1278. );
  1279. },
  1280. isFirstDispatchTask(row) {
  1281. if (!row) {
  1282. return false;
  1283. }
  1284. const firstTaskId =
  1285. this.currentPlan?.firstTaskId ??
  1286. this.currentPlan?.taskId ??
  1287. this.currentPlan?.sourceTaskId ??
  1288. '';
  1289. if (
  1290. firstTaskId !== null &&
  1291. firstTaskId !== undefined &&
  1292. firstTaskId !== ''
  1293. ) {
  1294. return (
  1295. String(
  1296. row.sourceTaskId ?? row.firstTaskId ?? row.taskId ?? row.id
  1297. ) === String(firstTaskId)
  1298. );
  1299. }
  1300. const index = this.dispatchTaskTabs.findIndex(
  1301. (item) =>
  1302. this.dispatchTaskGroupKey(item) === this.dispatchTaskGroupKey(row)
  1303. );
  1304. return index === 0;
  1305. },
  1306. dispatchObjectRowKey(row) {
  1307. const rawId =
  1308. row?.rawId ??
  1309. row?.workstationId ??
  1310. row?.factoryWorkstationId ??
  1311. row?.stationId ??
  1312. row?.id ??
  1313. row?.code ??
  1314. row?.workstationCode ??
  1315. '';
  1316. if (rawId !== null && rawId !== undefined && rawId !== '') {
  1317. return String(row?.objectType || 'workstation') + ':' + String(rawId);
  1318. }
  1319. return String(row?.name || row?.displayName || '');
  1320. },
  1321. getDispatchAssignmentKey(row) {
  1322. return `${this.dispatchTaskGroupKey(
  1323. this.activeTask
  1324. )}::${this.dispatchObjectRowKey(row)}`;
  1325. },
  1326. getDispatchAssignment(row) {
  1327. return this.dispatchAssignmentMap[this.getDispatchAssignmentKey(row)];
  1328. },
  1329. removeDispatchAssignment(row) {
  1330. const key = this.getDispatchAssignmentKey(row);
  1331. if (key) {
  1332. this.$delete(this.dispatchAssignmentMap, key);
  1333. }
  1334. },
  1335. getDispatchWorkOrderId() {
  1336. const plan = this.currentPlan || {};
  1337. return plan.workOrderId || plan.orderId || plan.sourceWorkOrderId || '';
  1338. },
  1339. getDispatchPlanId() {
  1340. const plan = this.currentPlan || {};
  1341. return plan.productionPlanId || plan.planId || plan.id || '';
  1342. },
  1343. getDeviceSnapshotRequestKey(row = this.activeTask) {
  1344. const planId = this.getDispatchPlanId();
  1345. const taskId = this.getDispatchSourceTaskId(row);
  1346. return planId && taskId ? `${planId}::${taskId}` : '';
  1347. },
  1348. normalizeDeviceSnapshotCode(value) {
  1349. if (value === null || value === undefined || value === '') {
  1350. return '';
  1351. }
  1352. return String(value).trim();
  1353. },
  1354. getDispatchDeviceSnapshotCandidateCodes(row) {
  1355. return [
  1356. row?.assetCode,
  1357. row?.deviceCode,
  1358. row?.extInfo?.assetCode,
  1359. row?.extInfo?.deviceCode
  1360. ]
  1361. .map((item) => this.normalizeDeviceSnapshotCode(item))
  1362. .filter(Boolean);
  1363. },
  1364. isDispatchDeviceSnapshotCodeMatched(row, snapshotCodes = {}) {
  1365. return this.getDispatchDeviceSnapshotCandidateCodes(row).some(
  1366. (code) => snapshotCodes[code]
  1367. );
  1368. },
  1369. hasDispatchDeviceSnapshotMatchedRow(snapshotCodes = {}) {
  1370. return this.dispatchObjectRows.some((row) =>
  1371. this.isDispatchDeviceSnapshotCodeMatched(row, snapshotCodes)
  1372. );
  1373. },
  1374. isDeviceSnapshotLocked(row) {
  1375. if (!this.orderDispatchStyle || !row) {
  1376. return false;
  1377. }
  1378. const requestKey = this.getDeviceSnapshotRequestKey();
  1379. if (
  1380. !requestKey ||
  1381. !Object.prototype.hasOwnProperty.call(
  1382. this.dispatchDeviceSnapshotMap,
  1383. requestKey
  1384. )
  1385. ) {
  1386. return false;
  1387. }
  1388. const snapshotCodes = this.dispatchDeviceSnapshotMap[requestKey] || {};
  1389. if (
  1390. !Object.keys(snapshotCodes).length ||
  1391. !this.hasDispatchDeviceSnapshotMatchedRow(snapshotCodes)
  1392. ) {
  1393. return false;
  1394. }
  1395. return !this.isDispatchDeviceSnapshotCodeMatched(row, snapshotCodes);
  1396. },
  1397. clearDeviceSnapshotLockedSelections() {
  1398. this.dispatchObjectRows.forEach((row) => {
  1399. if (
  1400. this.isDeviceSnapshotLocked(row) &&
  1401. this.isSelectedDispatchObject(row)
  1402. ) {
  1403. this.clearDispatchObject(row);
  1404. }
  1405. });
  1406. },
  1407. async loadDispatchDeviceSnapshots() {
  1408. if (
  1409. !this.orderDispatchStyle ||
  1410. this.readonlyMode ||
  1411. !this.activeTask ||
  1412. !this.currentPlan
  1413. ) {
  1414. return;
  1415. }
  1416. const planId = this.getDispatchPlanId();
  1417. const taskId = this.getDispatchSourceTaskId(this.activeTask);
  1418. const requestKey = this.getDeviceSnapshotRequestKey(this.activeTask);
  1419. if (!planId || !taskId || !requestKey) {
  1420. return;
  1421. }
  1422. this.dispatchDeviceSnapshotLoading = true;
  1423. this.dispatchDeviceSnapshotRequestKey = requestKey;
  1424. try {
  1425. const res = await listByPlanIdAndTaskId({ planId, taskId });
  1426. if (this.dispatchDeviceSnapshotRequestKey !== requestKey) {
  1427. return;
  1428. }
  1429. const snapshotCodes = {};
  1430. (Array.isArray(res) ? res : []).forEach((item) => {
  1431. const code = this.normalizeDeviceSnapshotCode(item?.deviceCode);
  1432. if (code) {
  1433. snapshotCodes[code] = true;
  1434. }
  1435. });
  1436. this.$set(this.dispatchDeviceSnapshotMap, requestKey, snapshotCodes);
  1437. this.clearDeviceSnapshotLockedSelections();
  1438. } catch (e) {
  1439. if (this.dispatchDeviceSnapshotRequestKey === requestKey) {
  1440. this.$delete(this.dispatchDeviceSnapshotMap, requestKey);
  1441. }
  1442. this.$message.warning(e.message || '获取工序设备快照失败');
  1443. } finally {
  1444. if (this.dispatchDeviceSnapshotRequestKey === requestKey) {
  1445. this.dispatchDeviceSnapshotLoading = false;
  1446. }
  1447. }
  1448. },
  1449. getDispatchWorkCenterId(row = this.activeTask) {
  1450. const plan = this.currentPlan || {};
  1451. return (
  1452. row?.workCenterId ||
  1453. row?.workcenterId ||
  1454. row?.sourceWorkCenterId ||
  1455. plan.workCenterId ||
  1456. ''
  1457. );
  1458. },
  1459. getDispatchWorkCenterName(row = this.activeTask) {
  1460. const plan = this.currentPlan || {};
  1461. return (
  1462. row?.workCenterName ||
  1463. row?.workcenterName ||
  1464. row?.sourceWorkCenterName ||
  1465. plan.workCenterName ||
  1466. ''
  1467. );
  1468. },
  1469. normalizeDispatchSingleValue(value) {
  1470. if (Array.isArray(value)) {
  1471. return value.length
  1472. ? this.normalizeDispatchSingleValue(value[0])
  1473. : '';
  1474. }
  1475. if (value === null || value === undefined) {
  1476. return '';
  1477. }
  1478. const text = String(value).trim();
  1479. if (!text) {
  1480. return '';
  1481. }
  1482. if (['undefined', 'null'].includes(text.toLowerCase())) {
  1483. return '';
  1484. }
  1485. return text.includes(',') ? text.split(',')[0].trim() : text;
  1486. },
  1487. normalizeDispatchTextValue(value) {
  1488. if (Array.isArray(value)) {
  1489. return value
  1490. .map((item) => this.normalizeDispatchTextValue(item))
  1491. .filter(Boolean)
  1492. .join(',');
  1493. }
  1494. if (value === null || value === undefined) {
  1495. return '';
  1496. }
  1497. const text = String(value).trim();
  1498. if (!text) {
  1499. return '';
  1500. }
  1501. return ['undefined', 'null'].includes(text.toLowerCase()) ? '' : text;
  1502. },
  1503. pickDispatchTextValue(groups = []) {
  1504. for (const group of groups) {
  1505. const source = group?.source || {};
  1506. const keys = Array.isArray(group?.keys) ? group.keys : [];
  1507. for (const key of keys) {
  1508. const value = this.normalizeDispatchTextValue(source[key]);
  1509. if (value) {
  1510. return value;
  1511. }
  1512. }
  1513. }
  1514. return '';
  1515. },
  1516. pickDispatchSingleValue(groups = []) {
  1517. for (const group of groups) {
  1518. const source = group?.source || {};
  1519. const keys = Array.isArray(group?.keys) ? group.keys : [];
  1520. for (const key of keys) {
  1521. const value = this.normalizeDispatchSingleValue(source[key]);
  1522. if (value) {
  1523. return value;
  1524. }
  1525. }
  1526. }
  1527. return '';
  1528. },
  1529. pickDispatchTeamId(groups = []) {
  1530. for (const group of groups) {
  1531. const source = group?.source || {};
  1532. const keys = Array.isArray(group?.keys) ? group.keys : [];
  1533. for (const key of keys) {
  1534. const value = this.normalizeDispatchSingleValue(source[key]);
  1535. if (value && !String(value).includes(':')) {
  1536. return value;
  1537. }
  1538. }
  1539. }
  1540. return '';
  1541. },
  1542. getDispatchTeamId() {
  1543. const plan = this.currentPlan || {};
  1544. const task = this.activeTask || {};
  1545. return this.pickDispatchTeamId([
  1546. { source: task, keys: DISPATCH_TEAM_ID_KEYS },
  1547. { source: plan, keys: DISPATCH_TEAM_ID_KEYS }
  1548. ]);
  1549. },
  1550. getDispatchTeamName() {
  1551. const plan = this.currentPlan || {};
  1552. const task = this.activeTask || {};
  1553. return this.pickDispatchSingleValue([
  1554. { source: task, keys: DISPATCH_TEAM_NAME_KEYS },
  1555. { source: plan, keys: DISPATCH_TEAM_NAME_KEYS }
  1556. ]);
  1557. },
  1558. getDispatchTaskTeamId(row = this.activeTask) {
  1559. const teamIdKeys = [
  1560. 'dispatchTeamId',
  1561. 'teamId',
  1562. 'firstTaskTeamId',
  1563. 'firstTeamId',
  1564. 'teamIds',
  1565. 'executionTeamId'
  1566. ];
  1567. return this.pickDispatchTeamId([
  1568. { source: row || {}, keys: teamIdKeys },
  1569. { source: this.currentPlan || {}, keys: teamIdKeys }
  1570. ]);
  1571. },
  1572. getDispatchTaskLeaderId(row = this.activeTask) {
  1573. const leaderKeys = [
  1574. 'dispatchTeamLeaderId',
  1575. 'executionTeamLeaderId',
  1576. 'teamLeaderUserId',
  1577. 'leaderUserId',
  1578. 'executionLeaderId'
  1579. ];
  1580. return this.pickDispatchSingleValue([
  1581. { source: row || {}, keys: leaderKeys },
  1582. { source: this.currentPlan || {}, keys: leaderKeys }
  1583. ]);
  1584. },
  1585. getUserSingleValueSet(value) {
  1586. const result = new Set();
  1587. const append = (source) => {
  1588. if (Array.isArray(source)) {
  1589. source.forEach(append);
  1590. return;
  1591. }
  1592. if (source === null || source === undefined || source === '') {
  1593. return;
  1594. }
  1595. String(source)
  1596. .split(',')
  1597. .map((item) => item.trim())
  1598. .filter(Boolean)
  1599. .forEach((item) => result.add(String(item)));
  1600. };
  1601. append(value);
  1602. return result;
  1603. },
  1604. getCurrentUserInfo() {
  1605. return this.$store?.state?.user?.info || {};
  1606. },
  1607. getCurrentUserTeamIdSet() {
  1608. const userInfo = this.getCurrentUserInfo();
  1609. const ids = this.getUserSingleValueSet(userInfo.teamId);
  1610. (userInfo.teamList || []).forEach((item) => {
  1611. const id = item?.teamId ?? item?.id;
  1612. if (id !== null && id !== undefined && id !== '') {
  1613. ids.add(String(id));
  1614. }
  1615. });
  1616. return ids;
  1617. },
  1618. getCurrentUserWorkCenterIdSet() {
  1619. const userInfo = this.getCurrentUserInfo();
  1620. const ids = this.getUserSingleValueSet(userInfo.workCenterIds);
  1621. (userInfo.centerList || []).forEach((item) => {
  1622. const id = item?.centerId ?? item?.id;
  1623. if (id !== null && id !== undefined && id !== '') {
  1624. ids.add(String(id));
  1625. }
  1626. });
  1627. return ids;
  1628. },
  1629. getDispatchToolbarPermissionState(action) {
  1630. if (this.readonlyMode) {
  1631. return { allowed: false, message: '当前状态仅支持查看' };
  1632. }
  1633. if (!this.activeTask) {
  1634. return { allowed: false, message: '请选择工序' };
  1635. }
  1636. const teamId = this.getDispatchTaskTeamId(this.activeTask);
  1637. const userTeamIds = this.getCurrentUserTeamIdSet();
  1638. if (!teamId || !userTeamIds.has(String(teamId))) {
  1639. return {
  1640. allowed: false,
  1641. message: '当前登录人不属于该工序所属班组'
  1642. };
  1643. }
  1644. const leaderId = this.getDispatchTaskLeaderId(this.activeTask);
  1645. const userId = this.getCurrentUserInfo().userId;
  1646. if (!leaderId || String(leaderId) !== String(userId)) {
  1647. return { allowed: false, message: '当前班组不是对应组长' };
  1648. }
  1649. if (
  1650. action === 'addStation' &&
  1651. Number(this.activeTask.assignType ?? 1) === 3
  1652. ) {
  1653. return { allowed: false, message: '产线指派不能添加工位' };
  1654. }
  1655. return { allowed: true, message: '' };
  1656. },
  1657. isDispatchToolbarDisabled(action) {
  1658. return !this.getDispatchToolbarPermissionState(action).allowed;
  1659. },
  1660. validateDispatchToolbarPermission(action) {
  1661. const state = this.getDispatchToolbarPermissionState(action);
  1662. if (!state.allowed) {
  1663. this.$message.warning(state.message);
  1664. return false;
  1665. }
  1666. return true;
  1667. },
  1668. getDispatchAssigneeId(row) {
  1669. const rawId =
  1670. row?.rawId ??
  1671. row?.workstationId ??
  1672. row?.factoryWorkstationId ??
  1673. row?.stationId ??
  1674. row?.assigneeId ??
  1675. row?.id ??
  1676. '';
  1677. return String(rawId).replace(/^(workstation|person|team):/, '');
  1678. },
  1679. normalizeDispatchLongId(value) {
  1680. if (value === null || value === undefined || value === '') {
  1681. return '';
  1682. }
  1683. const text = String(value).trim();
  1684. return /^\d+$/.test(text) ? text : '';
  1685. },
  1686. getDispatchDeviceId(row) {
  1687. return (
  1688. this.normalizeDispatchLongId(row?.assetId) ||
  1689. this.normalizeDispatchLongId(row?.extInfo?.assetId) ||
  1690. this.normalizeDispatchLongId(row?.deviceId) ||
  1691. this.normalizeDispatchLongId(row?.extInfo?.deviceId) ||
  1692. ''
  1693. );
  1694. },
  1695. getAssignmentTypeCode(value) {
  1696. if (value && typeof value === 'object') {
  1697. return value.code ?? value.value ?? value.id ?? '';
  1698. }
  1699. return value ?? '';
  1700. },
  1701. getDispatchStatusText(status) {
  1702. if (status === null || status === undefined || status === '') {
  1703. return '';
  1704. }
  1705. if (typeof status === 'object') {
  1706. return status.desc || status.name || status.label || '';
  1707. }
  1708. return String(status);
  1709. },
  1710. canResetDispatchRow(row) {
  1711. if (!this.getDispatchToolbarPermissionState('reset').allowed) {
  1712. return false;
  1713. }
  1714. const data = this.getDispatchActionRowData(row);
  1715. if (
  1716. data.status === null ||
  1717. data.status === undefined ||
  1718. data.status === ''
  1719. ) {
  1720. return false;
  1721. }
  1722. return String(this.getAssignmentTypeCode(data.status)) !== '1';
  1723. },
  1724. canDeleteAddedDispatchStation(row) {
  1725. if (!row || String(row.isNew ?? '') !== '1') {
  1726. return false;
  1727. }
  1728. const data = this.getDispatchActionRowData(row);
  1729. const rawStatusCode = this.getAssignmentTypeCode(data?.status);
  1730. const statusCode =
  1731. rawStatusCode === null ||
  1732. rawStatusCode === undefined ||
  1733. rawStatusCode === ''
  1734. ? NaN
  1735. : Number(rawStatusCode);
  1736. const statusText = this.getDispatchStatusText(data?.status);
  1737. return (
  1738. statusCode !== 0 &&
  1739. statusCode !== 1 &&
  1740. statusText !== '已保存' &&
  1741. statusText !== '保存' &&
  1742. statusText !== '已派单' &&
  1743. statusText !== '派单'
  1744. );
  1745. },
  1746. isDispatchRowAssigned(row) {
  1747. const data =
  1748. typeof this.getDispatchActionRowData === 'function'
  1749. ? this.getDispatchActionRowData(row)
  1750. : row || {};
  1751. const statusCode = this.getAssignmentTypeCode(data?.status);
  1752. if (String(statusCode) === '1') {
  1753. return true;
  1754. }
  1755. const statusText = this.getDispatchStatusText(data?.status);
  1756. return statusText === '已派单' || statusText === '派单';
  1757. },
  1758. isDispatchRowControlDisabled(row) {
  1759. return this.readonlyMode || this.isDeviceSnapshotLocked(row);
  1760. },
  1761. getDispatchTableRowClassName({ row }) {
  1762. if (this.isDeviceSnapshotLocked(row)) {
  1763. return 'dispatch-row-device-locked';
  1764. }
  1765. return this.readonlyMode && this.isDispatchRowAssigned(row)
  1766. ? 'dispatch-row-assigned'
  1767. : '';
  1768. },
  1769. normalizeDispatchAssignment(item) {
  1770. const assigneeId =
  1771. item.assigneeId || item.workStationId || item.workstationId || '';
  1772. return {
  1773. quantity: item.quantity,
  1774. weight: item.weight,
  1775. executionStartTime: item.startTime || item.executionStartTime || '',
  1776. executionEndTime: item.endTime || item.executionEndTime || '',
  1777. changeId: item.id || item.changeId || '',
  1778. status: item.status,
  1779. teamTimeIds: item.teamTimeIds,
  1780. assigneeId
  1781. };
  1782. },
  1783. async loadDispatchAssignData() {
  1784. if (!this.orderDispatchStyle || !this.activeTask || !this.currentPlan) {
  1785. return;
  1786. }
  1787. const taskId = this.getDispatchSourceTaskId(this.activeTask);
  1788. const workOrderId = this.getDispatchWorkOrderId();
  1789. const teamId = this.getDispatchTeamId();
  1790. if (!taskId || !workOrderId || !teamId) {
  1791. return;
  1792. }
  1793. const groupKey = this.dispatchTaskGroupKey(this.activeTask);
  1794. const params = {
  1795. workOrderId,
  1796. workCenterId: this.getDispatchWorkCenterId(),
  1797. taskId,
  1798. teamId
  1799. };
  1800. try {
  1801. const res = await listAssign(params);
  1802. const nextMap = Object.keys(this.dispatchAssignmentMap).reduce(
  1803. (map, key) => {
  1804. if (!key.startsWith(`${groupKey}::`)) {
  1805. map[key] = this.dispatchAssignmentMap[key];
  1806. }
  1807. return map;
  1808. },
  1809. {}
  1810. );
  1811. (Array.isArray(res) ? res : []).forEach((assignRecord) => {
  1812. (assignRecord.assignees || []).forEach((item) => {
  1813. const typeCode = this.getAssignmentTypeCode(item.assigneeType);
  1814. if (String(typeCode) !== '1') {
  1815. return;
  1816. }
  1817. const assignment = this.normalizeDispatchAssignment(item);
  1818. const key = `${groupKey}::workstation:${assignment.assigneeId}`;
  1819. nextMap[key] = assignment;
  1820. });
  1821. });
  1822. this.dispatchAssignmentMap = nextMap;
  1823. } catch (e) {
  1824. this.$message.warning(e.message || '获取派单数据失败');
  1825. }
  1826. },
  1827. async handleDispatchRefresh() {
  1828. if (this.dispatchRefreshLoading) {
  1829. return;
  1830. }
  1831. this.dispatchRefreshLoading = true;
  1832. try {
  1833. await this.loadDispatchAssignData();
  1834. this.$nextTick(() => {
  1835. this.$refs.dispatchTable?.doLayout?.();
  1836. });
  1837. } finally {
  1838. this.dispatchRefreshLoading = false;
  1839. }
  1840. },
  1841. isEmptyDispatchQuantity(value) {
  1842. if (value === null || value === undefined || value === '') {
  1843. return true;
  1844. }
  1845. const text = String(value).trim();
  1846. return text === '0' || /^0\.0*$/.test(text);
  1847. },
  1848. shouldClearDispatchQuantity(value) {
  1849. if (value === null || value === undefined || value === '') {
  1850. return true;
  1851. }
  1852. return false;
  1853. },
  1854. formatDispatchRowQuantity(value) {
  1855. return this.isEmptyDispatchQuantity(value) ? '' : value;
  1856. },
  1857. updateDispatchRowDraft(row, patch) {
  1858. const key = this.dispatchRowDraftKey(row);
  1859. this.$set(this.dispatchRowDraftMap, key, {
  1860. ...(this.dispatchRowDraftMap[key] || {}),
  1861. ...patch
  1862. });
  1863. },
  1864. dispatchRowDraftKey(row, task = this.activeTask) {
  1865. return [
  1866. this.getDispatchWorkOrderId() || this.currentPlan?.id || '',
  1867. this.dispatchTaskGroupKey(task) || '',
  1868. this.dispatchObjectRowKey(row)
  1869. ].join('::');
  1870. },
  1871. getDispatchTaskQuantityTotal(row) {
  1872. const groupKey = this.dispatchTaskGroupKey(row);
  1873. if (
  1874. this.orderDispatchStyle &&
  1875. this.activeTask &&
  1876. groupKey === this.dispatchTaskGroupKey(this.activeTask)
  1877. ) {
  1878. return this.dispatchObjectRows.reduce((total, item) => {
  1879. const data = this.getDispatchActionRowData(item);
  1880. return total + (this.parseDispatchQuantity(data.quantity) || 0);
  1881. }, 0);
  1882. }
  1883. return (this.taskList || []).reduce((total, item) => {
  1884. if (this.dispatchTaskGroupKey(item) !== groupKey) {
  1885. return total;
  1886. }
  1887. return total + (this.parseDispatchQuantity(item.quantity) || 0);
  1888. }, 0);
  1889. },
  1890. clearDispatchQuantity(row) {
  1891. if (row) {
  1892. this.$set(row, 'quantity', '');
  1893. }
  1894. },
  1895. validateDispatchQuantity(row, showMessage = true) {
  1896. if (!row) {
  1897. return false;
  1898. }
  1899. if (
  1900. row.quantity === null ||
  1901. row.quantity === undefined ||
  1902. row.quantity === ''
  1903. ) {
  1904. return true;
  1905. }
  1906. const quantity = this.parseDispatchQuantity(row.quantity);
  1907. if (quantity === null) {
  1908. this.clearDispatchQuantity(row);
  1909. if (showMessage) {
  1910. this.$message.warning('数量只能输入非0开头的整数或小数');
  1911. }
  1912. return false;
  1913. }
  1914. const planQuantity = this.dispatchPlanQuantityLimit;
  1915. if (planQuantity !== null) {
  1916. const total = this.getDispatchTaskQuantityTotal(row);
  1917. if (total > planQuantity) {
  1918. this.clearDispatchQuantity(row);
  1919. if (showMessage) {
  1920. this.$message.warning('工位数量合计不能大于计划数量');
  1921. }
  1922. return false;
  1923. }
  1924. }
  1925. return true;
  1926. },
  1927. handleDispatchQuantityInput(row) {
  1928. return this.validateDispatchQuantity(row);
  1929. },
  1930. getDispatchTaskRows() {
  1931. const groupKey = this.dispatchTaskGroupKey(this.activeTask);
  1932. return (this.taskList || []).filter(
  1933. (item) => this.dispatchTaskGroupKey(item) === groupKey
  1934. );
  1935. },
  1936. getDispatchRowTask(row) {
  1937. return this.getDispatchTaskRows().find((item) =>
  1938. this.optionMatchesDispatchObject(item.executionTeamId, row)
  1939. );
  1940. },
  1941. getDispatchTaskRowsByKey(groupKey) {
  1942. if (!groupKey) {
  1943. return [];
  1944. }
  1945. return (this.taskList || []).filter(
  1946. (item) => this.dispatchTaskGroupKey(item) === groupKey
  1947. );
  1948. },
  1949. emitDispatchTaskListChange(eventName, row) {
  1950. this.suppressTaskListAssignReloadUntil = Date.now() + 300;
  1951. this.$emit(eventName, row);
  1952. },
  1953. clearDispatchSelectionsByTaskKey(groupKey) {
  1954. if (!this.orderDispatchStyle || !groupKey) {
  1955. return;
  1956. }
  1957. this.getDispatchTaskRowsByKey(groupKey).forEach((task) => {
  1958. if (!task?.executionTeamId || this.isDispatchRowAssigned(task)) {
  1959. return;
  1960. }
  1961. if (task._dispatchDraft) {
  1962. this.emitDispatchTaskListChange('remove-task-row', task);
  1963. return;
  1964. }
  1965. this.$set(task, 'executionTeamId', '');
  1966. this.$set(task, 'rawExecutionTeamId', '');
  1967. this.$set(task, 'executionObjectType', '');
  1968. this.$set(task, 'executionObjectName', '');
  1969. this.$set(task, 'executionTeamName', '');
  1970. // this.$set(task, 'executionTeamLeader', '');
  1971. // this.$set(task, 'executionTeamLeaderId', '');
  1972. });
  1973. },
  1974. createDispatchTaskRow(row) {
  1975. const source = this.activeTask || {};
  1976. const next = {
  1977. ...source,
  1978. id: undefined,
  1979. _dispatchDraft: true,
  1980. quantity: '',
  1981. executionStartTime: row.executionStartTime || '',
  1982. executionEndTime: row.executionEndTime || '',
  1983. _taskKey: `${this.dispatchTaskGroupKey(
  1984. source
  1985. )}-${this.dispatchObjectRowKey(row)}`
  1986. };
  1987. this.emitDispatchTaskListChange('add-task-row', next);
  1988. return next;
  1989. },
  1990. clearDispatchObject(row, task = this.getDispatchRowTask(row)) {
  1991. this.$delete(this.dispatchRowDraftMap, this.dispatchRowDraftKey(row));
  1992. if (!task) {
  1993. row.quantity = '';
  1994. row.executionStartTime = '';
  1995. row.executionEndTime = '';
  1996. return;
  1997. }
  1998. row.quantity = '';
  1999. row.executionStartTime = '';
  2000. row.executionEndTime = '';
  2001. if (task._dispatchDraft) {
  2002. this.emitDispatchTaskListChange('remove-task-row', task);
  2003. return;
  2004. }
  2005. this.$set(task, 'quantity', '');
  2006. this.$set(task, 'executionStartTime', '');
  2007. this.$set(task, 'executionEndTime', '');
  2008. this.$set(task, 'executionTeamId', '');
  2009. this.$set(task, 'rawExecutionTeamId', '');
  2010. this.$set(task, 'executionObjectType', '');
  2011. this.$set(task, 'executionObjectName', '');
  2012. this.$set(task, 'executionTeamName', '');
  2013. // this.$set(task, 'executionTeamLeader', '');
  2014. // this.$set(task, 'executionTeamLeaderId', '');
  2015. },
  2016. clearDispatchTaskBinding(row, task = this.getDispatchRowTask(row)) {
  2017. if (!task) {
  2018. return;
  2019. }
  2020. if (task._dispatchDraft) {
  2021. this.emitDispatchTaskListChange('remove-task-row', task);
  2022. return;
  2023. }
  2024. this.$set(task, 'quantity', '');
  2025. this.$set(task, 'executionTeamId', '');
  2026. this.$set(task, 'rawExecutionTeamId', '');
  2027. this.$set(task, 'executionObjectType', '');
  2028. this.$set(task, 'executionObjectName', '');
  2029. this.$set(task, 'executionTeamName', '');
  2030. // this.$set(task, 'executionTeamLeader', '');
  2031. // this.$set(task, 'executionTeamLeaderId', '');
  2032. },
  2033. clearDispatchQuantityInput(row) {
  2034. this.clearDispatchObject(row);
  2035. this.$nextTick(() => {
  2036. row.quantity = '';
  2037. this.$forceUpdate();
  2038. });
  2039. },
  2040. ensureDispatchObjectSelected(row) {
  2041. if (!this.activeTask || !row || this.isDeviceSnapshotLocked(row)) {
  2042. return null;
  2043. }
  2044. const existed = this.getDispatchRowTask(row);
  2045. const canUseActiveTask = !this.activeTask.executionTeamId;
  2046. const task =
  2047. existed ||
  2048. (canUseActiveTask
  2049. ? this.activeTask
  2050. : this.createDispatchTaskRow(row));
  2051. if (!this.optionMatchesDispatchObject(task.executionTeamId, row)) {
  2052. this.selectDispatchObject(row, task);
  2053. }
  2054. return task;
  2055. },
  2056. handleDispatchRowQuantityInput(row, value) {
  2057. if (this.isDispatchRowControlDisabled(row)) {
  2058. return;
  2059. }
  2060. this.$set(row, 'quantity', value);
  2061. this.updateDispatchRowDraft(row, { quantity: value });
  2062. const quantity = this.parseDispatchQuantity(value);
  2063. if (this.shouldClearDispatchQuantity(value)) {
  2064. this.clearDispatchQuantityInput(row);
  2065. return;
  2066. }
  2067. const text = String(value || '').trim();
  2068. if (/^0\d+/.test(text)) {
  2069. this.clearDispatchQuantityInput(row);
  2070. return;
  2071. }
  2072. if (
  2073. quantity === null &&
  2074. (/^[1-9]\d*\.\d*$/.test(text) || /^0(\.\d*)?$/.test(text))
  2075. ) {
  2076. this.clearDispatchTaskBinding(row);
  2077. return;
  2078. }
  2079. const task = this.ensureDispatchObjectSelected(row);
  2080. if (!task) {
  2081. return;
  2082. }
  2083. this.$set(task, 'quantity', value);
  2084. const valid = this.handleDispatchQuantityInput(task);
  2085. if (!valid) {
  2086. this.updateDispatchRowDraft(row, { quantity: '' });
  2087. }
  2088. row.quantity = this.formatDispatchRowQuantity(task.quantity);
  2089. },
  2090. handleDispatchObjectCheckChange(row, checked) {
  2091. if (this.isDispatchRowControlDisabled(row)) {
  2092. return;
  2093. }
  2094. if (checked) {
  2095. const task = this.ensureDispatchObjectSelected(row);
  2096. if (task && row.quantity) {
  2097. this.$set(task, 'quantity', row.quantity);
  2098. }
  2099. if (task) {
  2100. this.$set(task, 'executionStartTime', row.executionStartTime || '');
  2101. this.$set(task, 'executionEndTime', row.executionEndTime || '');
  2102. }
  2103. return;
  2104. }
  2105. const task = this.getDispatchRowTask(row);
  2106. if (!task) {
  2107. return;
  2108. }
  2109. this.updateDispatchRowDraft(row, {
  2110. quantity: row.quantity,
  2111. executionStartTime:
  2112. row.executionStartTime || task.executionStartTime || '',
  2113. executionEndTime: row.executionEndTime || task.executionEndTime || ''
  2114. });
  2115. if (task._dispatchDraft) {
  2116. this.emitDispatchTaskListChange('remove-task-row', task);
  2117. return;
  2118. }
  2119. this.$set(task, 'quantity', '');
  2120. this.$set(task, 'executionTeamId', '');
  2121. this.$set(task, 'rawExecutionTeamId', '');
  2122. this.$set(task, 'executionObjectType', '');
  2123. this.$set(task, 'executionObjectName', '');
  2124. this.$set(task, 'executionTeamName', '');
  2125. // this.$set(task, 'executionTeamLeader', '');
  2126. // this.$set(task, 'executionTeamLeaderId', '');
  2127. },
  2128. clearDispatchStartTime(row) {
  2129. if (row) {
  2130. this.$set(row, 'executionStartTime', '');
  2131. this.$forceUpdate();
  2132. }
  2133. },
  2134. clearDispatchEndTime(row) {
  2135. if (row) {
  2136. this.$set(row, 'executionEndTime', '');
  2137. this.$forceUpdate();
  2138. }
  2139. },
  2140. validateDispatchStartTime(row, showMessage = true) {
  2141. if (!row?.executionStartTime) {
  2142. return true;
  2143. }
  2144. const startTime = this.parseDispatchTime(row.executionStartTime);
  2145. const planStartTime = this.parseDispatchTime(
  2146. this.getDispatchPlanStartTime()
  2147. );
  2148. if (
  2149. startTime !== null &&
  2150. planStartTime !== null &&
  2151. startTime < planStartTime
  2152. ) {
  2153. this.clearDispatchStartTime(row);
  2154. if (showMessage) {
  2155. this.$message.warning('开始时间不能小于计划开始时间');
  2156. }
  2157. return false;
  2158. }
  2159. const planEndTime = this.parseDispatchTime(
  2160. this.getDispatchPlanEndTime()
  2161. );
  2162. if (
  2163. startTime !== null &&
  2164. planEndTime !== null &&
  2165. startTime > planEndTime
  2166. ) {
  2167. this.clearDispatchStartTime(row);
  2168. if (showMessage) {
  2169. this.$message.warning('开始时间不能大于计划结束时间');
  2170. }
  2171. return false;
  2172. }
  2173. return true;
  2174. },
  2175. validateDispatchEndTime(row, showMessage = true) {
  2176. if (!row?.executionEndTime) {
  2177. return true;
  2178. }
  2179. const endTime = this.parseDispatchTime(row.executionEndTime);
  2180. const startTime = this.parseDispatchTime(row.executionStartTime);
  2181. if (endTime !== null && startTime !== null && endTime < startTime) {
  2182. this.clearDispatchEndTime(row);
  2183. if (showMessage) {
  2184. this.$message.warning('结束时间不能小于开始时间');
  2185. }
  2186. return false;
  2187. }
  2188. const planEndTime = this.parseDispatchTime(
  2189. this.getDispatchPlanEndTime()
  2190. );
  2191. if (endTime !== null && planEndTime !== null && endTime > planEndTime) {
  2192. this.clearDispatchEndTime(row);
  2193. if (showMessage) {
  2194. this.$message.warning('结束时间不能大于计划结束时间');
  2195. }
  2196. return false;
  2197. }
  2198. return true;
  2199. },
  2200. validateDispatchTime(row, showMessage = true) {
  2201. return (
  2202. this.validateDispatchStartTime(row, showMessage) &&
  2203. this.validateDispatchEndTime(row, showMessage)
  2204. );
  2205. },
  2206. handleDispatchStartTimeChange(row) {
  2207. if (!this.validateDispatchStartTime(row)) {
  2208. return;
  2209. }
  2210. const endTimeValid = this.validateDispatchEndTime(row);
  2211. this.$emit('time-change', row, 'executionStartTime');
  2212. if (!endTimeValid) {
  2213. this.$emit('time-change', row, 'executionEndTime');
  2214. }
  2215. },
  2216. handleDispatchEndTimeChange(row) {
  2217. if (!this.validateDispatchEndTime(row)) {
  2218. return;
  2219. }
  2220. this.$emit('time-change', row, 'executionEndTime');
  2221. },
  2222. handleDispatchRowStartTimeChange(row) {
  2223. if (this.isDispatchRowControlDisabled(row)) {
  2224. return;
  2225. }
  2226. const task = this.ensureDispatchObjectSelected(row);
  2227. if (!task) {
  2228. return;
  2229. }
  2230. this.$set(task, 'executionStartTime', row.executionStartTime || '');
  2231. this.handleDispatchStartTimeChange(task);
  2232. row.executionStartTime = task.executionStartTime || '';
  2233. row.executionEndTime =
  2234. task.executionEndTime || row.executionEndTime || '';
  2235. this.updateDispatchRowDraft(row, {
  2236. executionStartTime: row.executionStartTime,
  2237. executionEndTime: row.executionEndTime
  2238. });
  2239. },
  2240. handleDispatchRowEndTimeChange(row) {
  2241. if (this.isDispatchRowControlDisabled(row)) {
  2242. return;
  2243. }
  2244. const task = this.ensureDispatchObjectSelected(row);
  2245. if (!task) {
  2246. return;
  2247. }
  2248. this.$set(task, 'executionEndTime', row.executionEndTime || '');
  2249. this.handleDispatchEndTimeChange(task);
  2250. row.executionEndTime = task.executionEndTime || '';
  2251. this.updateDispatchRowDraft(row, {
  2252. executionStartTime: row.executionStartTime,
  2253. executionEndTime: row.executionEndTime
  2254. });
  2255. },
  2256. handleDispatchRowStandardHoursChange(row, value) {
  2257. if (!row || this.isDispatchRowControlDisabled(row)) {
  2258. return;
  2259. }
  2260. // 同步输入值:el-input 的 :value 已展示 row.standardHours,这里以参数兜底
  2261. if (value !== undefined && value !== null) {
  2262. this.$set(row, 'standardHours', value);
  2263. }
  2264. const hours = this.parseStandardHours(row.standardHours);
  2265. if (hours === null) {
  2266. this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
  2267. return;
  2268. }
  2269. const startTimeText = row.executionStartTime;
  2270. if (!startTimeText) {
  2271. this.$message.warning('请先填写计划开始时间');
  2272. this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
  2273. return;
  2274. }
  2275. const startMs = this.parseDispatchTime(startTimeText);
  2276. if (startMs === null) {
  2277. this.$message.warning('计划开始时间格式不合法');
  2278. this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
  2279. return;
  2280. }
  2281. const endDate = new Date(startMs + hours * 60 * 60 * 1000);
  2282. const formatted = this.formatExecutionEndTime(endDate);
  2283. const task = this.ensureDispatchObjectSelected(row);
  2284. if (task) {
  2285. this.$set(task, 'standardHours', row.standardHours);
  2286. this.$set(task, 'executionEndTime', formatted);
  2287. }
  2288. this.$set(row, 'executionEndTime', formatted);
  2289. this.updateDispatchRowDraft(row, {
  2290. standardHours: row.standardHours,
  2291. executionStartTime: row.executionStartTime,
  2292. executionEndTime: formatted
  2293. });
  2294. if (task) {
  2295. this.$emit('time-change', task, 'executionEndTime');
  2296. }
  2297. this.$forceUpdate();
  2298. },
  2299. handleCurrentPageDispatchCheckChange(checked) {
  2300. if (this.readonlyMode) {
  2301. return;
  2302. }
  2303. this.currentPageSelectableDispatchRows.forEach((row) => {
  2304. this.handleDispatchObjectCheckChange(row, checked);
  2305. });
  2306. },
  2307. getDispatchActionRowData(row) {
  2308. const task = this.getDispatchRowTask(row);
  2309. const assignment = this.getDispatchAssignment(row);
  2310. return {
  2311. ...row,
  2312. quantity: task?.quantity ?? row.quantity,
  2313. standardHours: task?.standardHours ?? row.standardHours,
  2314. executionStartTime:
  2315. task?.executionStartTime ?? row.executionStartTime,
  2316. executionEndTime: task?.executionEndTime ?? row.executionEndTime,
  2317. changeId: assignment?.changeId ?? row.changeId,
  2318. status: assignment?.status ?? row.status,
  2319. teamTimeIds: task?.teamTimeIds ?? row.teamTimeIds,
  2320. weight: task?.weight ?? row.weight
  2321. };
  2322. },
  2323. isDispatchWithdrawable(row) {
  2324. const statusCode = this.getAssignmentTypeCode(row?.status);
  2325. return !!row?.changeId && !!statusCode;
  2326. },
  2327. async handleDispatchRowReset(row) {
  2328. if (!this.validateDispatchToolbarPermission('reset')) {
  2329. return;
  2330. }
  2331. const data = this.getDispatchActionRowData(row);
  2332. if (!data.changeId) {
  2333. this.$message.warning('只能对已撤回跟已保存的数据进行重置');
  2334. return;
  2335. }
  2336. this.dispatchToolbarLoading = true;
  2337. try {
  2338. const res = await resetAssignee(data.changeId);
  2339. if (res) {
  2340. this.removeDispatchAssignment(row);
  2341. this.clearDispatchObject(row);
  2342. this.$message.success('操作成功');
  2343. this.$emit('dispatch-action-success', {
  2344. type: 'reset',
  2345. task: this.activeTask
  2346. });
  2347. }
  2348. } catch (e) {
  2349. this.$message.error(e.message || '操作失败');
  2350. } finally {
  2351. this.dispatchToolbarLoading = false;
  2352. }
  2353. },
  2354. handleDeleteAddedDispatchStation(row) {
  2355. if (!this.canDeleteAddedDispatchStation(row)) {
  2356. this.$message.warning(
  2357. '只有通过添加工位新增且状态不是保存或派单的数据才能删除'
  2358. );
  2359. return;
  2360. }
  2361. const task = this.getDispatchRowTask(row);
  2362. this.clearDispatchObject(row, task);
  2363. this.$emit('remove-dispatch-station', {
  2364. task: this.activeTask,
  2365. row
  2366. });
  2367. this.$message.success('删除成功');
  2368. },
  2369. validateDispatchActionRows(rows, type) {
  2370. if (!rows.length) {
  2371. this.$message.warning('请最少选择一条数据');
  2372. return false;
  2373. }
  2374. if (
  2375. !this.getDispatchWorkOrderId() ||
  2376. !this.getDispatchSourceTaskId(this.activeTask)
  2377. ) {
  2378. this.$message.warning('当前订单或工序信息不完整,无法操作');
  2379. return false;
  2380. }
  2381. const invalidRequired = rows.some((row) => {
  2382. const data = this.getDispatchActionRowData(row);
  2383. return (
  2384. !this.parseDispatchQuantity(data.quantity) ||
  2385. !data.executionStartTime ||
  2386. !data.executionEndTime
  2387. );
  2388. });
  2389. if (invalidRequired) {
  2390. this.$message.warning(
  2391. '请将所选数据的 数量,开始时间,完成时间 填写完毕'
  2392. );
  2393. return false;
  2394. }
  2395. const invalidTime = rows.some((row) => {
  2396. const data = this.getDispatchActionRowData(row);
  2397. return !this.validateDispatchTime(data, false);
  2398. });
  2399. if (invalidTime) {
  2400. this.$message.warning('请检查所选数据的开始时间和完成时间');
  2401. return false;
  2402. }
  2403. if (
  2404. type === 2 &&
  2405. rows.some((row) => !this.isDispatchWithdrawable(row))
  2406. ) {
  2407. this.$message.warning('只有状态为派单的数据才能进行撤回');
  2408. return false;
  2409. }
  2410. return true;
  2411. },
  2412. buildDispatchAssignees(rows) {
  2413. const measuringUnit =
  2414. this.currentPlan?.measuringUnit || this.currentPlan?.unit || '';
  2415. return rows.map((row) => {
  2416. const data = this.getDispatchActionRowData(row);
  2417. const assigneeId = this.getDispatchAssigneeId(row);
  2418. const assigneeName =
  2419. row.displayName || String(row.name || '').replace(/^工位[::]/, '');
  2420. const assignee = {
  2421. assigneeId,
  2422. quantity: data.quantity,
  2423. weight: data.weight || '',
  2424. startTime: data.executionStartTime,
  2425. endTime: data.executionEndTime,
  2426. assigneeType: 1,
  2427. assigneeName,
  2428. measuringUnit,
  2429. isNew: row.isNew ? row.isNew : '',
  2430. deviceId: this.getDispatchDeviceId(row),
  2431. deviceName:
  2432. row.assetName || row.deviceName || row.extInfo?.assetName || '',
  2433. workStationId: assigneeId,
  2434. workStationName: assigneeName
  2435. };
  2436. if (data.teamTimeIds) {
  2437. assignee.teamTimeIds = data.teamTimeIds;
  2438. }
  2439. return assignee;
  2440. });
  2441. },
  2442. buildDispatchActionPayload(rows) {
  2443. const row = this.activeTask || {};
  2444. return {
  2445. taskId: this.getDispatchSourceTaskId(row),
  2446. taskName: row.taskName || row.name,
  2447. taskCode: row.taskCode || row.code,
  2448. teamName: this.getDispatchTeamName(),
  2449. teamId: this.getDispatchTeamId(),
  2450. workCenterId: this.getDispatchWorkCenterId(row),
  2451. workCenterName: this.getDispatchWorkCenterName(row),
  2452. workOrderId: this.getDispatchWorkOrderId(),
  2453. dispatchMethod: 0,
  2454. dispatchingMethod:
  2455. this.currentPlan?.dispatchingMethod ??
  2456. this.currentPlan?.taskAss ??
  2457. 0,
  2458. assignType: 1,
  2459. singleReport: this.reportTypeValue,
  2460. dispatchType: this.reportTypeValue,
  2461. assignees: this.buildDispatchAssignees(rows)
  2462. };
  2463. },
  2464. async validateDispatchSourceConflict(payload, type) {
  2465. if (!this.orderDispatchStyle || (type !== 1 && type !== 3)) {
  2466. return true;
  2467. }
  2468. const checked = await checkAssignSourceType(payload);
  2469. if (checked && checked.result === true) {
  2470. this.$message.warning(
  2471. checked.message || '当前派单数据存在冲突,请调整后再操作'
  2472. );
  2473. }
  2474. return true;
  2475. },
  2476. validateFirstTaskConfirmReportType() {
  2477. if (this.reportTypeValue === 0 || this.reportTypeValue === 1) {
  2478. return true;
  2479. }
  2480. this.$message.warning('请先选择报工类型');
  2481. return false;
  2482. },
  2483. async validateFirstTaskConfirmLeader(teamId) {
  2484. try {
  2485. const permissionRes = await parameterGetByCode({
  2486. code: 'production_order_dispatch_permission'
  2487. });
  2488. if (String(permissionRes?.value || 0) !== '1') {
  2489. return true;
  2490. }
  2491. const isTeamLeader = await getcheckLoginUserIsTeamLeader(teamId);
  2492. if (!isTeamLeader) {
  2493. this.$message.warning('当前班组不是对应组长');
  2494. return false;
  2495. }
  2496. return true;
  2497. } catch (e) {
  2498. this.$message.error(e.message || '校验组长身份失败');
  2499. return false;
  2500. }
  2501. },
  2502. getFirstTaskAssignedRows() {
  2503. return this.dispatchObjectRows.filter((row) =>
  2504. this.isDispatchRowAssigned(row)
  2505. );
  2506. },
  2507. buildFirstTaskConfirmPayload(assignedRows) {
  2508. const row = this.activeTask || {};
  2509. const assignType = Number(row.assignType ?? 1);
  2510. const dispatchIds = assignedRows.map((item) =>
  2511. this.getDispatchAssigneeId(item)
  2512. );
  2513. const payload = {
  2514. assignType,
  2515. singleReport: this.reportTypeValue,
  2516. teamId: this.getDispatchTeamId(),
  2517. dispatchingMethod:
  2518. this.currentPlan?.dispatchingMethod ??
  2519. this.currentPlan?.taskAss ??
  2520. 0,
  2521. crewIds: [],
  2522. workstationIds: [],
  2523. factoryLineIds: [],
  2524. id: this.getDispatchWorkOrderId() || this.currentPlan?.id || '',
  2525. planStartTime: this.getDispatchPlanStartTime(),
  2526. planEndTime: this.getDispatchPlanEndTime()
  2527. };
  2528. if (assignType === 2) {
  2529. payload.crewIds = dispatchIds;
  2530. } else if (assignType === 3) {
  2531. payload.factoryLineIds = dispatchIds;
  2532. } else {
  2533. payload.workstationIds = dispatchIds;
  2534. }
  2535. return payload;
  2536. },
  2537. async handleFirstTaskConfirm() {
  2538. if (!this.validateDispatchToolbarPermission('confirm')) {
  2539. return;
  2540. }
  2541. if (!this.validateFirstTaskConfirmReportType()) {
  2542. return;
  2543. }
  2544. const teamId = this.getDispatchTeamId();
  2545. if (!teamId) {
  2546. this.$message.warning('请先选择班组');
  2547. return;
  2548. }
  2549. const workCenterId = this.getDispatchWorkCenterId(this.activeTask);
  2550. const workOrderId =
  2551. this.getDispatchWorkOrderId() || this.currentPlan?.id;
  2552. if (!workCenterId || !workOrderId) {
  2553. this.$message.warning('当前订单或工序信息不完整,无法操作');
  2554. return;
  2555. }
  2556. if (!(await this.validateFirstTaskConfirmLeader(teamId))) {
  2557. return;
  2558. }
  2559. const assignedRows = this.getFirstTaskAssignedRows();
  2560. if (!assignedRows.length) {
  2561. const taskName =
  2562. this.activeTask?.taskName || this.activeTask?.name || '';
  2563. this.$message.warning(`请您先进行首工序任务(${taskName}工序)派单`);
  2564. return;
  2565. }
  2566. this.dispatchToolbarLoading = true;
  2567. try {
  2568. const checked = await checkAssignConfirm({
  2569. teamId,
  2570. workCenterId,
  2571. workOrderId
  2572. });
  2573. if (!checked) {
  2574. return;
  2575. }
  2576. const response = await releaseWorkOrder(
  2577. this.buildFirstTaskConfirmPayload(assignedRows)
  2578. );
  2579. if (response) {
  2580. this.$message.success('操作成功');
  2581. await this.loadDispatchAssignData();
  2582. this.$emit('dispatch-action-success', {
  2583. type: 'confirm',
  2584. task: this.activeTask
  2585. });
  2586. }
  2587. } catch (e) {
  2588. this.$message.error(e.message || '操作失败');
  2589. } finally {
  2590. this.dispatchToolbarLoading = false;
  2591. }
  2592. },
  2593. async handleDispatchToolbarAction(type) {
  2594. if (!this.validateDispatchToolbarPermission(type)) {
  2595. return;
  2596. }
  2597. const rows = this.selectedDispatchObjectRows;
  2598. if (!this.validateDispatchActionRows(rows, type)) {
  2599. return;
  2600. }
  2601. const data =
  2602. type === 2
  2603. ? rows.map((row) => this.getDispatchActionRowData(row).changeId)
  2604. : this.buildDispatchActionPayload(rows);
  2605. const api =
  2606. type === 1 ? taskAssignment : type === 2 ? taskRevoked : taskSave;
  2607. this.dispatchToolbarLoading = true;
  2608. try {
  2609. if (!(await this.validateDispatchSourceConflict(data, type))) {
  2610. return;
  2611. }
  2612. await api(data);
  2613. await this.loadDispatchAssignData();
  2614. this.$message.success('操作成功');
  2615. this.$emit('dispatch-action-success', {
  2616. type,
  2617. task: this.activeTask
  2618. });
  2619. } catch (e) {
  2620. this.$message.error(e.message || '操作失败');
  2621. } finally {
  2622. this.dispatchToolbarLoading = false;
  2623. }
  2624. },
  2625. handleDispatchAddStation() {
  2626. if (!this.validateDispatchToolbarPermission('addStation')) {
  2627. return;
  2628. }
  2629. if (!this.activeTask) {
  2630. this.$message.warning('请选择工序');
  2631. return;
  2632. }
  2633. const workCenterId = this.getDispatchWorkCenterId(this.activeTask);
  2634. if (!workCenterId) {
  2635. this.$message.warning('当前工序缺少工作中心,无法添加工位');
  2636. return;
  2637. }
  2638. const index = this.dispatchTaskTabs.findIndex(
  2639. (item) =>
  2640. this.dispatchTaskGroupKey(item) ===
  2641. this.dispatchTaskGroupKey(this.activeTask)
  2642. );
  2643. const existedStations = this.dispatchObjectRows.map((row) => ({
  2644. ...row,
  2645. id: this.getDispatchAssigneeId(row)
  2646. }));
  2647. this.$refs.chooseStationRef?.open(
  2648. workCenterId,
  2649. existedStations,
  2650. index,
  2651. 2,
  2652. this.getDispatchTeamId()
  2653. );
  2654. },
  2655. handleChooseStationList(list, index) {
  2656. const task = this.dispatchTaskTabs[index];
  2657. const stations = (Array.isArray(list) ? list : []).map((item) => ({
  2658. ...item,
  2659. isNew: 1,
  2660. assetCode: this.pickDispatchSingleValue([
  2661. {
  2662. source: item,
  2663. keys: ['assetCode', 'deviceCode']
  2664. },
  2665. {
  2666. source: item.extInfo,
  2667. keys: ['assetCode', 'deviceCode']
  2668. }
  2669. ]),
  2670. assetId:
  2671. this.normalizeDispatchLongId(item.assetId) ||
  2672. this.normalizeDispatchLongId(item.extInfo?.assetId) ||
  2673. '',
  2674. assetName: this.pickDispatchSingleValue([
  2675. {
  2676. source: item,
  2677. keys: ['assetName', 'deviceName']
  2678. },
  2679. {
  2680. source: item.extInfo,
  2681. keys: ['assetName', 'deviceName']
  2682. }
  2683. ])
  2684. }));
  2685. this.$emit('add-dispatch-stations', {
  2686. task,
  2687. index,
  2688. list: stations
  2689. });
  2690. },
  2691. handleDispatchSubmit(row) {
  2692. if (
  2693. !this.validateDispatchQuantity(row) ||
  2694. !this.validateDispatchTime(row)
  2695. ) {
  2696. return;
  2697. }
  2698. this.$emit('row-submit', row);
  2699. },
  2700. parseStandardHours(value) {
  2701. if (value === null || value === undefined || value === '') {
  2702. return null;
  2703. }
  2704. const text = String(value).trim();
  2705. if (!text) {
  2706. return null;
  2707. }
  2708. const num = Number(text);
  2709. if (!Number.isFinite(num) || num < 0) {
  2710. return null;
  2711. }
  2712. return num;
  2713. },
  2714. formatExecutionEndTime(date) {
  2715. if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
  2716. return '';
  2717. }
  2718. const pad = (n) => String(n).padStart(2, '0');
  2719. return (
  2720. `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
  2721. date.getDate()
  2722. )} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
  2723. date.getSeconds()
  2724. )}`
  2725. );
  2726. },
  2727. handleStandardHoursChange(row, value) {
  2728. if (!row || this.readonlyMode) {
  2729. return;
  2730. }
  2731. // 同步输入值:el-input 的 v-model 已写入 row.standardHours,这里以参数兜底
  2732. if (value !== undefined && value !== null) {
  2733. this.$set(row, 'standardHours', value);
  2734. }
  2735. const hours = this.parseStandardHours(row.standardHours);
  2736. if (hours === null) {
  2737. return;
  2738. }
  2739. const startTimeText = row.executionStartTime;
  2740. if (!startTimeText) {
  2741. this.$message.warning('请先填写执行开始时间');
  2742. return;
  2743. }
  2744. const startMs = this.parseDispatchTime(startTimeText);
  2745. if (startMs === null) {
  2746. this.$message.warning('执行开始时间格式不合法');
  2747. return;
  2748. }
  2749. const endDate = new Date(startMs + hours * 60 * 60 * 1000);
  2750. const formatted = this.formatExecutionEndTime(endDate);
  2751. this.$set(row, 'executionEndTime', formatted);
  2752. this.$emit('time-change', row, 'executionEndTime');
  2753. this.$forceUpdate();
  2754. },
  2755. handleDispatchRowSubmit(row) {
  2756. const task = this.ensureDispatchObjectSelected(row);
  2757. if (!task) {
  2758. return;
  2759. }
  2760. this.handleDispatchSubmit(task);
  2761. },
  2762. taskRowKey(row, index) {
  2763. return String(row?._taskKey ?? row?.id ?? row?.taskId ?? index);
  2764. },
  2765. taskCodeDisplay(row) {
  2766. return (
  2767. row?.taskCode ||
  2768. row?.code ||
  2769. row?.sourceTaskCode ||
  2770. row?.firstTaskCode ||
  2771. '-'
  2772. );
  2773. },
  2774. dispatchTeamDisplay(row = this.activeTask) {
  2775. const plan = this.currentPlan || {};
  2776. return (
  2777. this.pickDispatchSingleValue([
  2778. { source: row || {}, keys: DISPATCH_TEAM_NAME_KEYS },
  2779. { source: plan, keys: DISPATCH_TEAM_NAME_KEYS }
  2780. ]) || '所有班组'
  2781. );
  2782. },
  2783. dispatchTeamLeaderDisplay(row) {
  2784. return (
  2785. row?.executionTeamLeader ||
  2786. '-'
  2787. );
  2788. },
  2789. handleDispatchPageSizeChange(size) {
  2790. this.dispatchPageSize = size;
  2791. this.dispatchPage = 1;
  2792. },
  2793. handleDispatchPageChange(page) {
  2794. this.dispatchPage = page;
  2795. },
  2796. homemadeOptions(row) {
  2797. // 由父组件按模式决定选项来源:
  2798. // - 工厂排程:直接返回班组选项。
  2799. // - 班组排程:返回人员 + 当前工序可派工位。
  2800. return this.getHomemadeOptions
  2801. ? this.getHomemadeOptions(row)
  2802. : this.teamOptions;
  2803. },
  2804. optionMatchesDispatchObject(optionId, row) {
  2805. return (
  2806. String(optionId || '') ===
  2807. String(this.dispatchObjectRowKey(row) || '')
  2808. );
  2809. },
  2810. ensureDispatchTeamSnapshot(task) {
  2811. if (!task) {
  2812. return;
  2813. }
  2814. const snapshot = {};
  2815. if (!task.dispatchTeamId) {
  2816. const teamId = this.pickDispatchTeamId([
  2817. {
  2818. source: task,
  2819. keys: [
  2820. 'teamId',
  2821. 'firstTaskTeamId',
  2822. 'firstTeamId',
  2823. 'teamIds',
  2824. 'executionTeamId'
  2825. ]
  2826. },
  2827. { source: this.currentPlan || {}, keys: DISPATCH_TEAM_ID_KEYS }
  2828. ]);
  2829. if (teamId) {
  2830. snapshot.dispatchTeamId = teamId;
  2831. }
  2832. }
  2833. if (!task.dispatchTeamName) {
  2834. const teamName = this.pickDispatchSingleValue([
  2835. {
  2836. source: task,
  2837. keys: [
  2838. 'teamName',
  2839. 'firstTaskTeamName',
  2840. 'firstTeamName',
  2841. 'teamNames',
  2842. 'executionTeamName'
  2843. ]
  2844. },
  2845. { source: this.currentPlan || {}, keys: DISPATCH_TEAM_NAME_KEYS }
  2846. ]);
  2847. if (teamName) {
  2848. snapshot.dispatchTeamName = teamName;
  2849. }
  2850. }
  2851. if (!task.dispatchTeamLeaderId) {
  2852. const leaderId = this.pickDispatchSingleValue([
  2853. {
  2854. source: task,
  2855. keys: [
  2856. 'teamLeaderUserId',
  2857. 'leaderUserId',
  2858. 'executionTeamLeaderId'
  2859. ]
  2860. },
  2861. {
  2862. source: this.currentPlan || {},
  2863. keys: ['dispatchTeamLeaderId', 'teamLeaderUserId', 'leaderUserId']
  2864. }
  2865. ]);
  2866. if (leaderId) {
  2867. snapshot.dispatchTeamLeaderId = leaderId;
  2868. }
  2869. }
  2870. Object.keys(snapshot).forEach((key) => {
  2871. this.$set(task, key, snapshot[key]);
  2872. });
  2873. },
  2874. isSelectedDispatchObject(row) {
  2875. const task = this.getDispatchRowTask(row);
  2876. return !!task;
  2877. },
  2878. selectDispatchObject(row, targetTask) {
  2879. const task = targetTask || this.activeTask;
  2880. if (!task || !row) {
  2881. return;
  2882. }
  2883. this.ensureDispatchTeamSnapshot(task);
  2884. this.$set(task, 'executionType', this.execType.HOMEMADE);
  2885. this.$set(task, 'executionTeamId', this.dispatchObjectRowKey(row));
  2886. this.$set(task, 'rawExecutionTeamId', row.rawId);
  2887. this.$set(task, 'executionObjectType', row.objectType);
  2888. this.$set(task, 'executionObjectName', row.name);
  2889. this.$set(task, 'executionTeamName', row.name);
  2890. this.$set(task, 'executionTeamLeader', row.leaderUserName || '');
  2891. this.$set(task, 'executionTeamLeaderId', row.leaderUserId || '');
  2892. this.$emit('execution-object-change', task);
  2893. }
  2894. }
  2895. };
  2896. </script>
  2897. <style lang="scss" scoped>
  2898. .config-panel {
  2899. width: 100%;
  2900. max-width: 100%;
  2901. min-width: 0;
  2902. box-sizing: border-box;
  2903. border: 1px solid #d8e3ef;
  2904. border-radius: 10px;
  2905. padding: 8px 10px 10px;
  2906. background: linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
  2907. margin-top: 10px;
  2908. }
  2909. .config-panel.factory-task-config-panel {
  2910. margin-top: 0;
  2911. padding: 6px 8px 8px;
  2912. }
  2913. .dispatch-config-panel {
  2914. height: 100%;
  2915. margin-top: 0;
  2916. padding: 0;
  2917. border: 0;
  2918. border-radius: 10px;
  2919. overflow: hidden;
  2920. }
  2921. .dispatch-style-panel {
  2922. display: flex;
  2923. flex-direction: column;
  2924. height: 100%;
  2925. width: 100%;
  2926. min-width: 0;
  2927. overflow: hidden;
  2928. background: transparent;
  2929. }
  2930. .dispatch-config-panel ::v-deep .el-empty {
  2931. height: 100%;
  2932. min-height: 240px;
  2933. padding: 24px 0;
  2934. box-sizing: border-box;
  2935. border-radius: 10px;
  2936. background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  2937. }
  2938. .dispatch-config-panel ::v-deep .el-empty__image {
  2939. width: 118px;
  2940. }
  2941. .dispatch-config-panel ::v-deep .el-empty__description {
  2942. margin-top: 10px;
  2943. }
  2944. .dispatch-report-type {
  2945. display: flex;
  2946. flex: 0 0 auto;
  2947. align-items: center;
  2948. gap: 8px;
  2949. min-height: 38px;
  2950. padding: 5px 12px;
  2951. box-sizing: border-box;
  2952. color: #606266;
  2953. font-size: 14px;
  2954. background: linear-gradient(180deg, #ffffff 0%, #f4f9fd 100%);
  2955. border-bottom: 1px solid #e5edf6;
  2956. }
  2957. .dispatch-required {
  2958. color: #f56c6c;
  2959. font-size: 14px;
  2960. }
  2961. .dispatch-report-label {
  2962. color: #606266;
  2963. font-weight: 500;
  2964. }
  2965. .dispatch-plan-info {
  2966. display: inline-flex;
  2967. flex: 1 1 auto;
  2968. align-items: center;
  2969. justify-content: flex-end;
  2970. gap: 10px;
  2971. min-width: 0;
  2972. color: #008000;
  2973. }
  2974. .dispatch-plan-item {
  2975. display: inline-flex;
  2976. align-items: baseline;
  2977. gap: 4px;
  2978. min-width: 0;
  2979. padding: 3px 8px;
  2980. border: 1px solid #c8e8cf;
  2981. border-radius: 7px;
  2982. background: linear-gradient(180deg, #f4fcf6 0%, #edf9f0 100%);
  2983. white-space: nowrap;
  2984. }
  2985. .dispatch-plan-label {
  2986. color: #008000;
  2987. font-weight: 600;
  2988. }
  2989. .dispatch-plan-value {
  2990. max-width: 280px;
  2991. overflow: hidden;
  2992. color: #008000;
  2993. font-weight: 600;
  2994. text-overflow: ellipsis;
  2995. }
  2996. .dispatch-process-tabs ::v-deep {
  2997. flex: 0 0 auto;
  2998. border: 0;
  2999. box-shadow: none;
  3000. .el-tabs__header {
  3001. margin: 0;
  3002. background: #f8fbff;
  3003. border-bottom-color: #e5edf6;
  3004. }
  3005. .el-tabs__nav-scroll {
  3006. padding: 0 10px;
  3007. }
  3008. .el-tabs__item {
  3009. display: inline-flex;
  3010. align-items: center;
  3011. justify-content: center;
  3012. height: 34px;
  3013. line-height: 1;
  3014. min-width: 82px;
  3015. margin-right: 6px;
  3016. padding: 0 14px;
  3017. border-radius: 8px 8px 0 0;
  3018. font-size: 14px;
  3019. font-weight: 500;
  3020. color: #909399;
  3021. text-align: center;
  3022. transition: all 0.18s ease;
  3023. }
  3024. .el-tabs__item:not(.is-active):hover {
  3025. color: #1683d8;
  3026. background: rgba(31, 140, 235, 0.06);
  3027. }
  3028. .el-tabs__item.is-active {
  3029. color: #0f75bd;
  3030. background: #fff;
  3031. font-weight: 600;
  3032. box-shadow: inset 0 -2px 0 #16b8a6;
  3033. }
  3034. .el-tabs__content {
  3035. display: none;
  3036. }
  3037. }
  3038. .dispatch-process-meta {
  3039. flex: 0 0 auto;
  3040. position: relative;
  3041. margin: 6px 12px;
  3042. padding: 6px 10px 6px 14px;
  3043. border: 1px solid #c8e8cf;
  3044. border-radius: 9px;
  3045. color: #008000;
  3046. font-size: 14px;
  3047. font-weight: 600;
  3048. background: linear-gradient(90deg, #f2fbf4 0%, #fbfffb 100%);
  3049. }
  3050. .dispatch-process-meta::before {
  3051. position: absolute;
  3052. top: 8px;
  3053. bottom: 8px;
  3054. left: 0;
  3055. width: 3px;
  3056. border-radius: 0 3px 3px 0;
  3057. background: #30b24a;
  3058. content: '';
  3059. }
  3060. .dispatch-toolbar {
  3061. flex: 0 0 auto;
  3062. display: flex;
  3063. align-items: center;
  3064. gap: 8px;
  3065. min-height: 40px;
  3066. padding: 5px 12px;
  3067. box-sizing: border-box;
  3068. border-top: 1px solid #eef3f8;
  3069. border-bottom: 1px solid #e5edf6;
  3070. background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
  3071. }
  3072. .dispatch-toolbar-left,
  3073. .dispatch-toolbar-icons,
  3074. .dispatch-assign-mode {
  3075. display: inline-flex;
  3076. align-items: center;
  3077. gap: 8px;
  3078. }
  3079. .dispatch-toolbar-left {
  3080. flex: 0 0 auto;
  3081. gap: 7px;
  3082. }
  3083. .dispatch-toolbar-left ::v-deep .el-button + .el-button {
  3084. margin-left: 0;
  3085. }
  3086. .dispatch-toolbar ::v-deep .el-button {
  3087. min-height: 28px;
  3088. border-radius: 7px;
  3089. font-weight: 600;
  3090. transition: all 0.18s ease;
  3091. }
  3092. .dispatch-toolbar ::v-deep .el-button:not(.el-button--primary):hover {
  3093. color: #1683d8;
  3094. border-color: #bfdcf5;
  3095. background: #f4f9ff;
  3096. }
  3097. .dispatch-toolbar-left ::v-deep .el-button--primary {
  3098. border-color: #1f8ceb;
  3099. background: linear-gradient(180deg, #2a9af0 0%, #1684df 100%);
  3100. box-shadow: 0 3px 8px rgba(31, 140, 235, 0.2);
  3101. }
  3102. .dispatch-toolbar-left ::v-deep .el-button--success {
  3103. border-color: #58c234;
  3104. background: linear-gradient(180deg, #8edc66 0%, #5fc238 100%);
  3105. box-shadow: 0 3px 8px rgba(95, 194, 56, 0.2);
  3106. }
  3107. .dispatch-toolbar-left ::v-deep .el-button.is-disabled,
  3108. .dispatch-toolbar-left ::v-deep .el-button.is-disabled:hover,
  3109. .dispatch-toolbar-left ::v-deep .el-button.is-disabled:focus,
  3110. .dispatch-toolbar-left ::v-deep .el-button.is-disabled:active {
  3111. color: #9aa6b2;
  3112. border-color: #d8e1eb;
  3113. background: #edf2f7;
  3114. box-shadow: none;
  3115. cursor: not-allowed;
  3116. }
  3117. .dispatch-assign-mode {
  3118. flex: 1 1 auto;
  3119. justify-content: center;
  3120. }
  3121. .dispatch-assign-label {
  3122. color: #606266;
  3123. font-size: 14px;
  3124. font-weight: 600;
  3125. }
  3126. .dispatch-assign-mode ::v-deep .el-button--primary {
  3127. box-shadow: 0 2px 6px rgba(31, 140, 235, 0.2);
  3128. }
  3129. .dispatch-toolbar-icons {
  3130. flex: 0 0 auto;
  3131. }
  3132. .dispatch-table-wrap {
  3133. flex: 1 1 auto;
  3134. min-height: 0;
  3135. padding: 0 8px;
  3136. box-sizing: border-box;
  3137. overflow: hidden;
  3138. background: #fff;
  3139. }
  3140. .dispatch-table {
  3141. height: 100%;
  3142. border-color: #e5edf6;
  3143. border-radius: 9px;
  3144. }
  3145. .dispatch-status-badge {
  3146. display: inline-flex;
  3147. align-items: center;
  3148. justify-content: center;
  3149. min-width: 58px;
  3150. height: 24px;
  3151. padding: 0 10px;
  3152. border: 1px solid #d8e1eb;
  3153. border-radius: 999px;
  3154. color: #606b78;
  3155. background: #f8fafc;
  3156. font-size: 13px;
  3157. font-weight: 600;
  3158. line-height: 22px;
  3159. box-sizing: border-box;
  3160. }
  3161. .dispatch-status-badge.is-assigned {
  3162. border-color: #8fd19e;
  3163. color: #008000;
  3164. background: #eefaf0;
  3165. box-shadow: inset 0 0 0 1px rgba(48, 178, 74, 0.08);
  3166. }
  3167. .dispatch-empty-control {
  3168. display: inline-flex;
  3169. align-items: center;
  3170. justify-content: center;
  3171. min-height: 30px;
  3172. width: 100%;
  3173. color: #c0c4cc;
  3174. }
  3175. .dispatch-state-checkbox {
  3176. cursor: pointer;
  3177. }
  3178. .dispatch-pagination {
  3179. display: flex;
  3180. flex: 0 0 auto;
  3181. align-items: center;
  3182. justify-content: center;
  3183. min-height: 42px;
  3184. padding: 4px 10px;
  3185. border-top: 1px solid #e5edf6;
  3186. background: linear-gradient(180deg, #ffffff 0%, #f1f6fb 100%);
  3187. box-shadow: 0 -3px 10px rgba(31, 45, 61, 0.04);
  3188. }
  3189. .panel-title {
  3190. font-size: 14px;
  3191. font-weight: 600;
  3192. margin-bottom: 10px;
  3193. }
  3194. .panel-header {
  3195. display: flex;
  3196. align-items: center;
  3197. justify-content: space-between;
  3198. gap: 8px;
  3199. margin-bottom: 5px;
  3200. flex-wrap: wrap;
  3201. }
  3202. .factory-task-config-panel .panel-header {
  3203. min-height: 28px;
  3204. margin-bottom: 4px;
  3205. }
  3206. .panel-header .panel-title {
  3207. margin-bottom: 0;
  3208. }
  3209. .panel-actions {
  3210. display: inline-flex;
  3211. align-items: center;
  3212. gap: 8px;
  3213. flex: 0 0 auto;
  3214. }
  3215. .factory-task-config-panel .panel-actions ::v-deep .el-button {
  3216. min-height: 26px;
  3217. padding: 6px 10px;
  3218. }
  3219. .readonly-tip {
  3220. color: #e6a23c;
  3221. font-size: 12px;
  3222. }
  3223. .task-config-table-wrap,
  3224. .last-end-over-plan-wrap,
  3225. .end-over-delivery-wrap {
  3226. width: 100%;
  3227. }
  3228. .task-config-table-wrap {
  3229. min-height: 0;
  3230. overflow: hidden;
  3231. }
  3232. .factory-task-config-panel .task-config-table-wrap {
  3233. flex: 1 1 auto;
  3234. height: 100%;
  3235. }
  3236. .last-end-over-plan-wrap ::v-deep .el-input__inner,
  3237. .end-over-delivery-wrap ::v-deep .el-input__inner {
  3238. color: #f56c6c;
  3239. border-color: #f56c6c;
  3240. }
  3241. .last-end-over-plan-wrap ::v-deep .el-input__inner:focus,
  3242. .end-over-delivery-wrap ::v-deep .el-input__inner:focus {
  3243. border-color: #f56c6c;
  3244. }
  3245. .config-table ::v-deep {
  3246. .dispatch-table.el-table {
  3247. font-size: 14px;
  3248. }
  3249. td.config-table-index-col .cell {
  3250. font-size: 14px !important;
  3251. }
  3252. .el-table td > .cell {
  3253. font-size: 14px;
  3254. text-align: center;
  3255. }
  3256. .el-table th > .cell,
  3257. .el-table__body .cell {
  3258. padding-left: 4px;
  3259. padding-right: 4px;
  3260. }
  3261. td.task-name-cell .task-name-text {
  3262. font-size: 14px;
  3263. font-weight: 500;
  3264. line-height: 1.4;
  3265. }
  3266. .config-table-control .el-input__inner {
  3267. height: 28px;
  3268. padding-left: 10px;
  3269. padding-right: 10px;
  3270. font-size: 13px;
  3271. line-height: 28px;
  3272. }
  3273. .config-table-control .el-input__prefix,
  3274. .config-table-control .el-input__suffix {
  3275. top: 0;
  3276. height: 100%;
  3277. display: inline-flex;
  3278. align-items: center;
  3279. }
  3280. .config-table-control .el-input__prefix {
  3281. left: 8px;
  3282. }
  3283. .config-table-control .el-input__suffix {
  3284. right: 6px;
  3285. }
  3286. .config-table-control .el-input__icon {
  3287. display: inline-flex;
  3288. align-items: center;
  3289. justify-content: center;
  3290. height: 100%;
  3291. line-height: 1;
  3292. }
  3293. .config-table-control .el-select__caret {
  3294. line-height: 1;
  3295. }
  3296. .el-table td,
  3297. .el-table th {
  3298. padding-top: 4px;
  3299. padding-bottom: 4px;
  3300. }
  3301. .el-table__row {
  3302. height: 34px;
  3303. }
  3304. .el-table__body-wrapper {
  3305. padding-bottom: 1px;
  3306. box-sizing: border-box;
  3307. }
  3308. .el-table__body tr:last-child td {
  3309. border-bottom: 1px solid #ebeef5;
  3310. }
  3311. .el-button--small {
  3312. min-width: 36px;
  3313. padding: 7px 0;
  3314. }
  3315. .config-table-control {
  3316. width: 100% !important;
  3317. }
  3318. .config-table-control.el-date-editor {
  3319. max-width: 100%;
  3320. }
  3321. .config-table-control.el-date-editor .el-input__inner {
  3322. padding-left: 28px;
  3323. padding-right: 20px;
  3324. }
  3325. .el-input-number .el-input__inner {
  3326. text-align: left;
  3327. }
  3328. }
  3329. .factory-task-config-panel .config-table ::v-deep {
  3330. .el-table td,
  3331. .el-table th {
  3332. padding-top: 3px;
  3333. padding-bottom: 3px;
  3334. }
  3335. .el-table__row {
  3336. height: 32px;
  3337. }
  3338. .config-table-control .el-input__inner {
  3339. height: 26px;
  3340. line-height: 26px;
  3341. }
  3342. .config-table-control.el-select .el-input__inner {
  3343. padding-right: 30px;
  3344. }
  3345. .config-table-control .el-input--prefix .el-input__inner {
  3346. padding-left: 28px;
  3347. }
  3348. }
  3349. .dispatch-table ::v-deep {
  3350. font-size: 14px;
  3351. .el-table th {
  3352. background: linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
  3353. color: #253244;
  3354. font-size: 14px;
  3355. font-weight: 600;
  3356. position: sticky;
  3357. top: 0;
  3358. z-index: 2;
  3359. }
  3360. .el-table td,
  3361. .el-table th {
  3362. border-bottom-color: #e9eff6;
  3363. }
  3364. .el-table__row:hover > td.el-table__cell {
  3365. background: #f5faff;
  3366. }
  3367. .el-table__body tr.current-row > td.el-table__cell {
  3368. background: #eaf5ff;
  3369. }
  3370. .el-table__body tr.dispatch-row-assigned > td.el-table__cell {
  3371. position: relative;
  3372. color: #52606d;
  3373. background: #f4fbf5;
  3374. }
  3375. .el-table__body tr.dispatch-row-assigned:hover > td.el-table__cell {
  3376. background: #e9f7ed;
  3377. }
  3378. .el-table__body tr.dispatch-row-assigned > td:first-child::before {
  3379. position: absolute;
  3380. top: 8px;
  3381. bottom: 8px;
  3382. left: 0;
  3383. width: 3px;
  3384. border-radius: 0 3px 3px 0;
  3385. background: #30b24a;
  3386. content: '';
  3387. }
  3388. .el-table__body tr.dispatch-row-device-locked > td.el-table__cell {
  3389. color: #8a96a3;
  3390. background: #f4f6f8;
  3391. cursor: not-allowed;
  3392. }
  3393. .el-table__body tr.dispatch-row-device-locked:hover > td.el-table__cell {
  3394. background: #eef2f6;
  3395. }
  3396. .el-table__body-wrapper::-webkit-scrollbar {
  3397. width: 8px;
  3398. height: 8px;
  3399. }
  3400. .el-table__body-wrapper::-webkit-scrollbar-thumb {
  3401. border: 2px solid #fff;
  3402. border-radius: 999px;
  3403. background: #bdcad8;
  3404. }
  3405. .el-table__body-wrapper::-webkit-scrollbar-thumb:hover {
  3406. background: #aeb9c8;
  3407. }
  3408. .el-table td,
  3409. .el-table th {
  3410. padding-top: 4px;
  3411. padding-bottom: 4px;
  3412. }
  3413. .el-table__row {
  3414. height: 36px;
  3415. }
  3416. .el-table__fixed-right {
  3417. box-shadow: -4px 0 8px rgba(0, 0, 0, 0.04);
  3418. }
  3419. .el-table__body-wrapper {
  3420. background: linear-gradient(
  3421. 90deg,
  3422. rgba(31, 140, 235, 0.025) 1px,
  3423. transparent 1px
  3424. ),
  3425. #fff;
  3426. background-size: 48px 48px;
  3427. }
  3428. .config-table-control .el-input__inner {
  3429. border-color: #dce7f2;
  3430. background: #fbfdff;
  3431. }
  3432. .dispatch-row-assigned .config-table-control .el-input__inner,
  3433. .dispatch-row-assigned
  3434. .config-table-control.el-date-editor
  3435. .el-input__inner {
  3436. color: #5f6977;
  3437. border-color: #b9d7bf;
  3438. background: #eef6f0;
  3439. box-shadow: inset 3px 0 0 #30b24a;
  3440. -webkit-text-fill-color: #5f6977;
  3441. }
  3442. .dispatch-row-assigned .config-table-control .el-input__prefix,
  3443. .dispatch-row-assigned .config-table-control .el-input__suffix {
  3444. color: #6aa875;
  3445. }
  3446. .config-table-control .el-input__inner:focus {
  3447. border-color: #1f8ceb;
  3448. box-shadow: 0 0 0 2px rgba(31, 140, 235, 0.08);
  3449. }
  3450. }
  3451. .dispatch-checkbox-wrap,
  3452. .dispatch-workstation-name,
  3453. .dispatch-disabled-field {
  3454. display: inline-block;
  3455. width: 100%;
  3456. }
  3457. .dispatch-workstation-name {
  3458. overflow: hidden;
  3459. text-overflow: ellipsis;
  3460. white-space: nowrap;
  3461. }
  3462. @media (max-width: 576px) {
  3463. .config-panel {
  3464. padding: 8px;
  3465. }
  3466. .dispatch-config-panel {
  3467. padding: 0;
  3468. }
  3469. .panel-header {
  3470. align-items: flex-start;
  3471. }
  3472. .dispatch-toolbar {
  3473. align-items: flex-start;
  3474. flex-direction: column;
  3475. padding: 12px;
  3476. }
  3477. .dispatch-report-type {
  3478. align-items: flex-start;
  3479. flex-wrap: wrap;
  3480. padding: 10px 12px;
  3481. }
  3482. .dispatch-plan-info {
  3483. flex-basis: 100%;
  3484. justify-content: flex-start;
  3485. gap: 10px;
  3486. }
  3487. .dispatch-assign-mode {
  3488. justify-content: flex-start;
  3489. }
  3490. }
  3491. </style>
  3492. <style lang="scss">
  3493. .dispatch-column-popover {
  3494. padding: 12px 14px;
  3495. border: 1px solid #e6edf5;
  3496. border-radius: 8px;
  3497. box-shadow: 0 8px 24px rgba(31, 45, 61, 0.12);
  3498. .dispatch-column-settings__title {
  3499. margin-bottom: 10px;
  3500. color: #263445;
  3501. font-size: 14px;
  3502. font-weight: 600;
  3503. }
  3504. .dispatch-column-settings__list {
  3505. display: grid;
  3506. grid-template-columns: repeat(2, minmax(0, 1fr));
  3507. gap: 8px 10px;
  3508. }
  3509. .el-checkbox {
  3510. margin-right: 0;
  3511. color: #4b5563;
  3512. line-height: 22px;
  3513. }
  3514. .el-checkbox__label {
  3515. padding-left: 6px;
  3516. font-size: 13px;
  3517. }
  3518. }
  3519. .dispatch-workstation-tooltip {
  3520. max-width: 260px;
  3521. z-index: 4000 !important;
  3522. line-height: 1.5;
  3523. word-break: break-all;
  3524. }
  3525. .dispatch-device-lock-tooltip {
  3526. min-width: 190px;
  3527. max-width: 320px;
  3528. z-index: 7000 !important;
  3529. padding: 10px 14px 10px 18px;
  3530. border: 1px solid #ff8a00;
  3531. border-left: 4px solid #ff5f00;
  3532. border-radius: 6px;
  3533. color: #7a2d00 !important;
  3534. background: linear-gradient(180deg, #fff7dc 0%, #ffe8bd 100%) !important;
  3535. box-shadow: 0 10px 24px rgba(180, 83, 9, 0.28),
  3536. inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  3537. font-size: 14px;
  3538. font-weight: 700;
  3539. line-height: 1.45;
  3540. }
  3541. .dispatch-device-lock-tooltip[x-placement^='top'] .popper__arrow {
  3542. border-top-color: #ff9f1a !important;
  3543. }
  3544. .dispatch-device-lock-tooltip[x-placement^='top'] .popper__arrow::after {
  3545. border-top-color: #fff3dc !important;
  3546. }
  3547. .dispatch-device-lock-tooltip[x-placement^='bottom'] .popper__arrow {
  3548. border-bottom-color: #ff9f1a !important;
  3549. }
  3550. .dispatch-device-lock-tooltip[x-placement^='bottom'] .popper__arrow::after {
  3551. border-bottom-color: #fff3dc !important;
  3552. }
  3553. .dispatch-device-lock-tooltip[x-placement^='left'] .popper__arrow {
  3554. border-left-color: #ff9f1a !important;
  3555. }
  3556. .dispatch-device-lock-tooltip[x-placement^='left'] .popper__arrow::after {
  3557. border-left-color: #fff3dc !important;
  3558. }
  3559. .dispatch-device-lock-tooltip[x-placement^='right'] .popper__arrow {
  3560. border-right-color: #ff9f1a !important;
  3561. }
  3562. .dispatch-device-lock-tooltip[x-placement^='right'] .popper__arrow::after {
  3563. border-right-color: #fff3dc !important;
  3564. }
  3565. </style>