TaskConfigPanel.vue 109 KB

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