newFactoryProductionScheduling.vue 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340
  1. <template>
  2. <ele-modal
  3. :key="dialogRenderKey"
  4. width="100%"
  5. :visible.sync="visible"
  6. :close-on-click-modal="false"
  7. custom-class="ele-dialog-form scheduling-dialog"
  8. :title="schedulingTitle"
  9. :maxable="true"
  10. >
  11. <projectGantt
  12. :style="{ height: ganttHeight }"
  13. :ganttTasks="tableData"
  14. :planList="planDataList"
  15. :calendarSourceData="calendarSourceData"
  16. :defaultTab="defaultGanttTab"
  17. :resource-tabs-config="resourceTabsConfig"
  18. :resource-label-mode="schedulingMode"
  19. :dateRange="dateRange"
  20. @tab-change="handleTabChange"
  21. >
  22. <template v-slot:toolbar>
  23. <el-date-picker
  24. v-model="dateRange"
  25. type="daterange"
  26. size="small"
  27. value-format="yyyy-MM-dd"
  28. range-separator="至"
  29. start-placeholder="计划开始时间"
  30. end-placeholder="计划结束时间"
  31. @input="handleDateInput"
  32. @change="handleDateChange"
  33. :append-to-body="false"
  34. ></el-date-picker>
  35. </template>
  36. </projectGantt>
  37. <ele-split-layout
  38. class="scheduling-content"
  39. space="0px"
  40. :width="splitPaneWidth"
  41. :resizable="true"
  42. :min-size="splitPaneMinSize"
  43. :max-size="splitPaneMaxSize"
  44. :left-style="{
  45. overflow: 'visible',
  46. width: '100%'
  47. }"
  48. :right-style="{
  49. overflow: 'hidden'
  50. }"
  51. :responsive="isCompactSchedulingLayout"
  52. :style="{ height: schedulingContentHeight }"
  53. >
  54. <div
  55. :class="[
  56. 'form-wrapper',
  57. {
  58. 'is-order-scheduling': isOrderScheduling,
  59. 'is-plan-scheduling': !isOrderScheduling
  60. }
  61. ]"
  62. >
  63. <div class="plan-table-status-tabs">
  64. <el-tabs
  65. v-model="planTableStatusTab"
  66. @tab-click="handlePlanTableStatusTabClick"
  67. >
  68. <el-tab-pane
  69. v-for="item in planTableStatusTabs"
  70. :key="item.name"
  71. :name="item.name"
  72. :label="item.label"
  73. />
  74. </el-tabs>
  75. </div>
  76. <ele-pro-table
  77. :key="planTableRenderKey"
  78. width="100%"
  79. ref="planTable"
  80. :columns="columns"
  81. :datasource="planDataList"
  82. row-key="id"
  83. :selection.sync="selection"
  84. :height="planTableHeight"
  85. :page-size="20"
  86. :pagination-class="planPaginationClass"
  87. @reload="handlePlanTableReload"
  88. @update:selection="handlePlanSelectionChange"
  89. >
  90. <template v-slot:action="{ row }">
  91. <el-link
  92. type="primary"
  93. :underline="false"
  94. @click="handlePublish(row)"
  95. >
  96. {{ getPlanActionText(row) }}
  97. </el-link>
  98. </template>
  99. <template v-slot:dotLineStatus="{ row }">
  100. <el-tag type="success" size="mini" v-if="row.dotLineStatus == 1">
  101. 已布点
  102. </el-tag>
  103. <el-tag type="danger" size="mini" v-if="row.dotLineStatus == 0">
  104. 未布点
  105. </el-tag>
  106. </template>
  107. </ele-pro-table>
  108. </div>
  109. <template v-slot:content>
  110. <div
  111. v-loading="dotLineLoading"
  112. :class="[
  113. 'plan-dot-line-side',
  114. {
  115. 'is-fullscreen': dotLineFullscreen,
  116. 'is-plan-scheduling': !isOrderScheduling
  117. }
  118. ]"
  119. >
  120. <div class="plan-dot-line-detail">
  121. <plan-route-panel
  122. v-if="!isOrderScheduling"
  123. :plan-start-display="planStartDisplay"
  124. :plan-end-display="planEndDisplay"
  125. :plan-num-display="planNumDisplay"
  126. :task-list="taskList"
  127. :route-steps-active="routeStepsActive"
  128. :route-des-index="routeDesIndex"
  129. :route-step-title="routeStepTitle"
  130. :compact="isOrderScheduling"
  131. />
  132. <div
  133. :class="[
  134. 'plan-dot-line-scrollable',
  135. {
  136. 'is-order-dispatch-scroll': isOrderScheduling,
  137. 'is-plan-config-scroll': !isOrderScheduling
  138. }
  139. ]"
  140. >
  141. <task-config-panel
  142. :key="taskConfigPanelRenderKey"
  143. :class="{ 'factory-task-config-panel': !isOrderScheduling }"
  144. :dot-line-fullscreen="dotLineFullscreen"
  145. :is-current-plan-readonly="isCurrentPlanReadonly"
  146. :order-detail-readonly="isOrderDetailReadonly"
  147. :current-plan="currentPlan"
  148. :dot-line-loading="dotLineLoading"
  149. :task-list="taskList"
  150. :execution-type-options="executionTypeOptions"
  151. :team-options="teamOptions"
  152. :get-homemade-options="getHomemadeOptions"
  153. :homemade-object-label="homemadeObjectLabel"
  154. :show-quantity-column="isOrderScheduling"
  155. :order-dispatch-style="isOrderScheduling"
  156. :show-approve-button="!isOrderScheduling"
  157. :approve-button-disabled="!canApproveCurrentPlan"
  158. :approve-loading="approvalLoading"
  159. :table-max-height="taskConfigTableMaxHeight"
  160. :fill-table-height="!isOrderScheduling"
  161. :factory-list="factoryList"
  162. :exec-type="EXEC_TYPE"
  163. :task-name="taskName"
  164. :exec-type-num="execTypeNum"
  165. :is-execution-end-over-delivery="isExecutionEndOverDelivery"
  166. :is-execution-end-over-plan-end="isExecutionEndOverPlanEnd"
  167. @toggle-fullscreen="toggleDotLineFullscreen"
  168. @submit="submitDotLineConfig"
  169. @execution-type-change="onExecutionTypeChange"
  170. @execution-object-change="onExecutionObjectChange"
  171. @time-change="handleTimeChange"
  172. @add-task-row="addTaskRow"
  173. @remove-task-row="removeTaskRow"
  174. @add-dispatch-stations="addDispatchStations"
  175. @dispatch-action-success="handleDispatchActionSuccess"
  176. @row-submit="submitDotLineRow"
  177. @approve="handleApproveCurrentPlan"
  178. />
  179. </div>
  180. </div>
  181. </div>
  182. </template>
  183. </ele-split-layout>
  184. <div slot="footer">
  185. <!-- <el-button plain @click="cancel">取消</el-button> -->
  186. <el-button @click="cancel">关闭</el-button>
  187. </div>
  188. <plan-picker-dialog
  189. ref="planPickerTable"
  190. :title="planPickerTitle"
  191. :visible.sync="planPickerVisible"
  192. :where.sync="planPickerWhere"
  193. :status-options="planPickerStatusOptions"
  194. :columns="columns"
  195. :loading="planPickerLoading"
  196. :datasource="planPickerDatasource"
  197. :selection.sync="planPickerSelection"
  198. @search="handlePlanPickerSearch"
  199. @reset-search="resetPlanPickerSearch"
  200. @confirm="confirmPlanPicker"
  201. @update:selection="handlePlanPickerSelectionChange"
  202. />
  203. </ele-modal>
  204. </template>
  205. <script>
  206. import projectGantt from './gantt/project-gantt.vue';
  207. import PlanPickerDialog from './newFactoryProductionScheduling/PlanPickerDialog.vue';
  208. import PlanRoutePanel from './newFactoryProductionScheduling/PlanRoutePanel.vue';
  209. import TaskConfigPanel from './newFactoryProductionScheduling/TaskConfigPanel.vue';
  210. import {
  211. getList,
  212. teamSchedulingGanttChart,
  213. workstationSchedulingGanttChart,
  214. factorySchedulingGanttChart,
  215. getPlansByIds
  216. } from '@/api/productionPlan/index.js';
  217. import { getTaskListById } from '@/api/materialPlan';
  218. import {
  219. listByFirstTaskId,
  220. parameterGetByCode,
  221. teamPage
  222. } from '@/api/mainData';
  223. import { getFactoryarea } from '@/api/saleOrder';
  224. import { getUserPage } from '@/api/system/organization';
  225. import { release, releaseByApproval } from '@/api/productionPlan/order.js';
  226. import {
  227. getPlanDotLine,
  228. savePlanDotLine
  229. } from '@/api/productionPlan/planDotLine';
  230. import { deepClone } from '@/utils';
  231. import {
  232. EXEC_TYPE,
  233. EXEC_TYPE_OPTIONS,
  234. PLAN_PICKER_STATUS_OPTIONS,
  235. READONLY_LAYOUT_STATUSES
  236. } from './newFactoryProductionScheduling.constants';
  237. import {
  238. createSchedulingColumns,
  239. createWorkOrderSchedulingColumns
  240. } from './newFactoryProductionScheduling.columns';
  241. import {
  242. createPlanPickerWhere,
  243. formatDotLineDateTime,
  244. isEndAfterPlanEnd,
  245. isEndBeforeStart,
  246. toSafeNumber
  247. } from './newFactoryProductionScheduling.utils';
  248. export default {
  249. components: {
  250. projectGantt,
  251. PlanPickerDialog,
  252. PlanRoutePanel,
  253. TaskConfigPanel
  254. },
  255. data() {
  256. const now = new Date();
  257. const startDate = `${now.getFullYear()}-${String(
  258. now.getMonth() + 1
  259. ).padStart(2, '0')}-01`;
  260. const lastDay = new Date(
  261. now.getFullYear(),
  262. now.getMonth() + 1,
  263. 0
  264. ).getDate();
  265. const endDate = `${now.getFullYear()}-${String(
  266. now.getMonth() + 1
  267. ).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`;
  268. return {
  269. visible: false,
  270. entryReadonly: false,
  271. form: {},
  272. currentPlan: null,
  273. planRoutingPayload: null,
  274. taskList: [],
  275. tableData: [],
  276. calendarSourceData: [],
  277. planDataList: [],
  278. allPlanDataList: [],
  279. selection: [],
  280. activeTab: 'factory',
  281. dateRange: [startDate, endDate],
  282. planPickerVisible: false,
  283. planPickerTitle: '添加计划',
  284. planPickerLoading: false,
  285. planPickerTimeDimensionPlanType: '',
  286. planPickerWhere: createPlanPickerWhere(),
  287. planPickerSelection: [],
  288. planPickerSelectionAll: [],
  289. planPickerSelectionSyncing: false,
  290. planTableSelectionSyncing: false,
  291. planTableStatusTab: 'published',
  292. planTableRenderKey: 0,
  293. dialogRenderKey: 0,
  294. dotLineLoading: false,
  295. dotLineFullscreen: false,
  296. approvalLoading: false,
  297. isReview: false,
  298. orderDetailReadonly: false,
  299. orderDetailActionMode: '',
  300. teamOptions: [],
  301. workstationOptionsMap: {},
  302. workstationOptionsLoadingMap: {},
  303. factoryList: [],
  304. executionTypeOptions: EXEC_TYPE_OPTIONS,
  305. planPickerStatusOptions: PLAN_PICKER_STATUS_OPTIONS,
  306. EXEC_TYPE,
  307. schedulingMode: 'plan',
  308. selectedWorkOrders: [],
  309. orderListLoader: null,
  310. orderDateReloadTimer: null,
  311. columns: createSchedulingColumns(),
  312. viewportWidth: typeof window === 'undefined' ? 1920 : window.innerWidth,
  313. viewportHeight: typeof window === 'undefined' ? 900 : window.innerHeight
  314. };
  315. },
  316. computed: {
  317. routeStepsActive() {
  318. const list = this.taskList;
  319. if (!list.length) return 0;
  320. for (let i = 0; i < list.length; i++) {
  321. if (!this.isTaskDone(list[i])) return i;
  322. }
  323. return list.length;
  324. },
  325. routeDesIndex() {
  326. const list = this.taskList;
  327. if (!list.length) return -1;
  328. const a = this.routeStepsActive;
  329. return a >= list.length ? list.length - 1 : a;
  330. },
  331. planStartDisplay() {
  332. const t = this.currentPlan?.startTime;
  333. return t ? formatDotLineDateTime(t) || String(t) : '—';
  334. },
  335. planEndDisplay() {
  336. const t = this.currentPlan?.endTime;
  337. return t ? formatDotLineDateTime(t) || String(t) : '—';
  338. },
  339. planNumDisplay() {
  340. const num = this.currentPlan?.productNum;
  341. const unit = this.currentPlan?.measuringUnit || this.currentPlan?.unit;
  342. const text = [num, unit]
  343. .filter((item) => item !== null && item !== undefined && item !== '')
  344. .join('');
  345. return text || '—';
  346. },
  347. isCurrentPlanReadonly() {
  348. return (
  349. (!this.isOrderScheduling && this.entryReadonly) ||
  350. this.isOrderDetailReadonly ||
  351. (!this.isOrderScheduling && this.isReadonlyPlan(this.currentPlan))
  352. );
  353. },
  354. isOrderDetailReadonly() {
  355. return (
  356. this.isOrderScheduling &&
  357. !!this.currentPlan &&
  358. this.orderDetailActionMode === 'view'
  359. );
  360. },
  361. // 当前弹窗同时承载两条业务链路:
  362. // 1. 工厂排程:从生产计划页面进入,不传 mode,保持默认 plan 模式。
  363. // 2. 班组排程:从工单页面进入,显式传入 mode = order。
  364. // 后续表格列、资源页签、执行对象和保存字段都以该判断隔离。
  365. isOrderScheduling() {
  366. return this.schedulingMode === 'order';
  367. },
  368. resourceTabsConfig() {
  369. if (this.isOrderScheduling) {
  370. return [
  371. { key: 'team', label: '工位' },
  372. { key: 'line', label: '设备' },
  373. { key: 'person', label: '人员' }
  374. ];
  375. }
  376. return undefined;
  377. },
  378. homemadeObjectLabel() {
  379. return this.isOrderScheduling ? '执行对象(人员/工位)' : '执行对象';
  380. },
  381. defaultGanttTab() {
  382. return this.isOrderScheduling ? 'team' : 'factory';
  383. },
  384. schedulingTitle() {
  385. return this.isOrderScheduling ? '班组排程' : '工厂排产';
  386. },
  387. taskConfigPanelRenderKey() {
  388. const planKey =
  389. this.currentPlan?.workOrderId || this.currentPlan?.id || 'empty';
  390. return [
  391. this.schedulingMode,
  392. this.planTableStatusTab,
  393. planKey,
  394. this.orderDetailActionMode || 'none',
  395. this.isCurrentPlanReadonly ? 'readonly' : 'edit'
  396. ].join('-');
  397. },
  398. planTableStatusTabs() {
  399. if (this.isOrderScheduling) {
  400. return [
  401. {
  402. name: 'dispatched',
  403. label: '已派单'
  404. },
  405. {
  406. name: 'undispatched',
  407. label: '未派单'
  408. }
  409. ];
  410. }
  411. return [
  412. {
  413. name: 'published',
  414. label: '已发布'
  415. },
  416. {
  417. name: 'unpublished',
  418. label: '未发布'
  419. }
  420. ];
  421. },
  422. isCompactSchedulingLayout() {
  423. return this.viewportWidth <= 1180;
  424. },
  425. splitPaneWidth() {
  426. if (this.isOrderScheduling) {
  427. if (this.viewportWidth <= 1280) return '36%';
  428. if (this.viewportWidth <= 1440) return '39%';
  429. if (this.viewportWidth <= 1680) return '42%';
  430. return '44%';
  431. }
  432. if (this.viewportWidth <= 1280) return '44%';
  433. if (this.viewportWidth <= 1440) return '50%';
  434. return '58%';
  435. },
  436. splitPaneMaxSize() {
  437. if (this.isOrderScheduling) {
  438. if (this.viewportWidth <= 1280) return -620;
  439. if (this.viewportWidth <= 1440) return -680;
  440. return -720;
  441. }
  442. return this.viewportWidth <= 1440 ? -520 : -420;
  443. },
  444. splitPaneMinSize() {
  445. if (this.viewportWidth <= 1280) return 280;
  446. if (this.viewportWidth <= 1440) return 320;
  447. return 360;
  448. },
  449. schedulingLayoutAvailableHeightValue() {
  450. const headerHeight = this.viewportHeight <= 760 ? 38 : 42;
  451. const footerHeight = this.viewportHeight <= 760 ? 34 : 38;
  452. const bodyVerticalPadding = this.viewportHeight <= 760 ? 8 : 12;
  453. const contentGap = this.viewportHeight <= 760 ? 5 : 6;
  454. return (
  455. this.viewportHeight -
  456. 10 -
  457. headerHeight -
  458. footerHeight -
  459. bodyVerticalPadding -
  460. contentGap
  461. );
  462. },
  463. ganttPanelHeightValue() {
  464. const minGanttHeight =
  465. this.viewportHeight <= 720
  466. ? 230
  467. : this.viewportHeight <= 820
  468. ? 300
  469. : this.viewportHeight <= 960
  470. ? 340
  471. : 380;
  472. const maxGanttHeight =
  473. this.viewportHeight <= 820
  474. ? 390
  475. : this.viewportHeight <= 1080
  476. ? 500
  477. : 560;
  478. const balancedHeight = Math.floor(
  479. this.schedulingLayoutAvailableHeightValue / 2
  480. );
  481. return Math.max(
  482. 232,
  483. Math.min(maxGanttHeight, Math.max(minGanttHeight, balancedHeight))
  484. );
  485. },
  486. schedulingContentHeightValue() {
  487. const remainingHeight =
  488. this.schedulingLayoutAvailableHeightValue -
  489. this.ganttPanelHeightValue;
  490. const minHeight =
  491. this.viewportHeight <= 720
  492. ? 230
  493. : this.viewportHeight <= 820
  494. ? 300
  495. : this.viewportHeight <= 900
  496. ? 340
  497. : 380;
  498. return Math.max(minHeight, remainingHeight);
  499. },
  500. ganttHeight() {
  501. return `${this.ganttPanelHeightValue}px`;
  502. },
  503. schedulingContentHeight() {
  504. return `${this.schedulingContentHeightValue}px`;
  505. },
  506. planTableHeight() {
  507. const tabHeight = 42;
  508. const paginationHeight = 44;
  509. const tableHeight = Math.max(
  510. 220,
  511. this.schedulingContentHeightValue - tabHeight - paginationHeight
  512. );
  513. if (tableHeight >= 0) {
  514. return `${tableHeight}px`;
  515. }
  516. if (this.isOrderScheduling) {
  517. // ele-pro-table 的 height 只作用在表格主体,工具栏和分页器会继续占用额外高度。
  518. // 班组排产右侧是自定义 flex 分页区,左侧需要略收表格主体高度,保证两个分页器垂直位置一致。
  519. if (this.viewportHeight <= 760) return `${360 - tabHeight}px`;
  520. if (this.viewportHeight <= 900) return `${420 - tabHeight}px`;
  521. return `${470 - tabHeight}px`;
  522. }
  523. if (this.viewportHeight <= 760) return `${360 - tabHeight}px`;
  524. if (this.viewportHeight <= 900) return `${420 - tabHeight}px`;
  525. return `${455 - tabHeight}px`;
  526. },
  527. planPaginationClass() {
  528. return this.isOrderScheduling
  529. ? 'ele-pagination-circle order-plan-pagination'
  530. : 'ele-pagination-circle plan-scheduling-pagination';
  531. },
  532. taskConfigTableMaxHeight() {
  533. if (this.isOrderScheduling) {
  534. return Math.max(260, this.schedulingContentHeightValue - 132);
  535. }
  536. return Math.max(280, this.schedulingContentHeightValue - 132);
  537. },
  538. canApproveCurrentPlan() {
  539. const row = this.currentPlan;
  540. const hasPermission =
  541. typeof this.$hasPermission !== 'function' ||
  542. this.$hasPermission('aps:productionplan:release');
  543. return (
  544. !this.isOrderScheduling &&
  545. !!row?.id &&
  546. this.planTableStatusTab === 'unpublished' &&
  547. String(row.status) === '2' &&
  548. String(row.dotLineStatus) === '1' &&
  549. row.splitBatch != 1 &&
  550. row.approvalStatus != 1 &&
  551. row.approvalStatus != 2 &&
  552. hasPermission
  553. );
  554. }
  555. },
  556. created() {
  557. this.loadTeamOptions();
  558. this.loadFactoryOptions();
  559. this.loadApprovalReviewConfig();
  560. },
  561. mounted() {
  562. this.updateViewportSize();
  563. window.addEventListener('resize', this.updateViewportSize);
  564. },
  565. beforeDestroy() {
  566. window.removeEventListener('resize', this.updateViewportSize);
  567. },
  568. methods: {
  569. updateViewportSize() {
  570. this.viewportWidth = window.innerWidth;
  571. this.viewportHeight = window.innerHeight;
  572. },
  573. normalizeId(value) {
  574. return value === null || value === undefined ? '' : String(value);
  575. },
  576. normalizeBackendLongId(value) {
  577. if (value === null || value === undefined || value === '') {
  578. return '';
  579. }
  580. const text = String(value).trim();
  581. return /^\d+$/.test(text) ? text : '';
  582. },
  583. normalizeOrderQuantity(value) {
  584. if (value === null || value === undefined || value === '') {
  585. return '';
  586. }
  587. const text = String(value).trim();
  588. return /^0+(\.0+)?$/.test(text) ? '' : value;
  589. },
  590. optionMatchesId(optionId, targetId) {
  591. return this.normalizeId(optionId) === this.normalizeId(targetId);
  592. },
  593. // Plan list helpers
  594. getPlanRowKey(row) {
  595. return String(row?.id ?? row?.planId ?? '');
  596. },
  597. isReadonlyPlan(row) {
  598. return READONLY_LAYOUT_STATUSES.includes(String(row?.status ?? ''));
  599. },
  600. getOrderStatusCode(row) {
  601. const status = row?.status;
  602. if (status && typeof status === 'object') {
  603. return String(status.code ?? status.value ?? status.id ?? '');
  604. }
  605. return String(status ?? '');
  606. },
  607. isOrderSchedulingReadonlyRow(row) {
  608. if (!this.isOrderScheduling) {
  609. return false;
  610. }
  611. return (
  612. this.planTableStatusTab === 'dispatched' ||
  613. ['4', '5', '6', '7'].includes(this.getOrderStatusCode(row))
  614. );
  615. },
  616. getPlanActionText(row) {
  617. if (this.isOrderSchedulingReadonlyRow(row)) {
  618. return '查看';
  619. }
  620. return !this.isOrderScheduling && this.isReadonlyPlan(row)
  621. ? '查看'
  622. : '布点';
  623. },
  624. getDefaultPlanTableStatusTab(mode = this.schedulingMode) {
  625. return mode === 'order' ? 'dispatched' : 'published';
  626. },
  627. getPlanTableStatusRequestWhere(tabName = this.planTableStatusTab) {
  628. if (this.isOrderScheduling) {
  629. return tabName === 'dispatched'
  630. ? { statusList: [4, 5, 6, 7] }
  631. : { statusList: [8] };
  632. }
  633. return tabName === 'published'
  634. ? { status: ['4'] }
  635. : { status: ['2', '3'] };
  636. },
  637. getPlanTableStatusRequestWhereList(tabName = this.planTableStatusTab) {
  638. return [this.getPlanTableStatusRequestWhere(tabName)];
  639. },
  640. async handlePlanTableStatusTabClick() {
  641. this.orderDetailReadonly = false;
  642. this.orderDetailActionMode = '';
  643. this.currentPlan = null;
  644. this.planRoutingPayload = null;
  645. this.taskList = [];
  646. this.selection = [];
  647. this.syncTableSelection('planTable', []);
  648. await this.reloadPlanTableByStatus();
  649. },
  650. async reloadPlanTableByStatus() {
  651. if (this.isOrderScheduling) {
  652. await this.reloadOrderSchedulingOrdersByDateRange(this.dateRange);
  653. } else {
  654. await this.reloadPlanSchedulingPlansByStatus();
  655. }
  656. },
  657. async reloadPlanSchedulingPlansByStatus(options = {}) {
  658. const preserveCurrent = !!options.preserveCurrent;
  659. const currentPlanKey = preserveCurrent
  660. ? this.getPlanRowKey(this.currentPlan)
  661. : '';
  662. this.orderDetailReadonly = false;
  663. this.orderDetailActionMode = '';
  664. const loading = this.$loading({
  665. lock: true,
  666. text: '加载计划中...'
  667. });
  668. let matchedCurrentPlan = null;
  669. try {
  670. const requestWhereList = this.getPlanTableStatusRequestWhereList();
  671. const resultList = await Promise.all(
  672. requestWhereList.map((where) =>
  673. getList({
  674. pageNum: 1,
  675. size: -1,
  676. ...this.getSchedulingDateRangeParams(),
  677. ...where
  678. })
  679. )
  680. );
  681. const rows = resultList.reduce(
  682. (list, data) => list.concat(data?.list || []),
  683. []
  684. );
  685. this.allPlanDataList = deepClone(rows);
  686. this.planDataList = this.buildPlanTableRows(rows, rows);
  687. if (preserveCurrent && currentPlanKey) {
  688. matchedCurrentPlan =
  689. this.planDataList.find(
  690. (item) => this.getPlanRowKey(item) === currentPlanKey
  691. ) || null;
  692. }
  693. this.planTableRenderKey += 1;
  694. } catch (e) {
  695. this.$message.error(e.message || '获取计划数据失败');
  696. } finally {
  697. loading.close();
  698. }
  699. if (preserveCurrent && matchedCurrentPlan) {
  700. this.currentPlan = {
  701. ...(this.currentPlan || {}),
  702. ...matchedCurrentPlan
  703. };
  704. this.selection = [matchedCurrentPlan];
  705. this.syncTableSelection('planTable', [matchedCurrentPlan]);
  706. return;
  707. }
  708. this.selection = [];
  709. this.currentPlan = null;
  710. this.planRoutingPayload = null;
  711. this.taskList = [];
  712. this.syncTableSelection('planTable', []);
  713. },
  714. async handlePlanTableReload() {
  715. if (this.isOrderScheduling) {
  716. await this.reloadOrderSchedulingOrdersByDateRange(this.dateRange);
  717. return;
  718. }
  719. await this.refreshSchedulingView();
  720. await this.reloadPlanSchedulingPlansByStatus({ preserveCurrent: true });
  721. if (this.currentPlan?.id) {
  722. await this.loadPlanDotLineDetail(this.currentPlan);
  723. }
  724. },
  725. getSchedulingDateRangeParams() {
  726. if (!Array.isArray(this.dateRange) || this.dateRange.length !== 2) {
  727. return {};
  728. }
  729. if (!this.dateRange[0] || !this.dateRange[1]) {
  730. return {};
  731. }
  732. return {
  733. startDate: this.dateRange[0],
  734. endDate: this.dateRange[1]
  735. };
  736. },
  737. async loadPlansByIds(ids = []) {
  738. const uniqueIds = Array.from(
  739. new Set(
  740. (ids || []).filter(
  741. (id) => id !== null && id !== undefined && id !== ''
  742. )
  743. )
  744. );
  745. if (!uniqueIds.length) {
  746. return [];
  747. }
  748. const data = await getList({
  749. pageNum: 1,
  750. size: uniqueIds.length,
  751. ids: uniqueIds
  752. });
  753. const orderMap = new Map(
  754. uniqueIds.map((id, index) => [String(id), index])
  755. );
  756. const list = Array.isArray(data?.list) ? data.list : [];
  757. return [...list].sort((a, b) => {
  758. const aIndex = orderMap.get(String(a?.id ?? ''));
  759. const bIndex = orderMap.get(String(b?.id ?? ''));
  760. return (
  761. (aIndex ?? Number.MAX_SAFE_INTEGER) -
  762. (bIndex ?? Number.MAX_SAFE_INTEGER)
  763. );
  764. });
  765. },
  766. buildPlanTableRows(selectedRows = [], sourceRows = []) {
  767. const sourceList =
  768. Array.isArray(sourceRows) && sourceRows.length
  769. ? sourceRows
  770. : selectedRows;
  771. const selectedKeySet = new Set(
  772. (selectedRows || [])
  773. .map((item) => this.getPlanRowKey(item))
  774. .filter((item) => item !== '')
  775. );
  776. return sourceList
  777. .filter((item) => selectedKeySet.has(this.getPlanRowKey(item)))
  778. .map((item, index) => ({
  779. ...deepClone(item),
  780. serialNumber: index + 1
  781. }));
  782. },
  783. buildWorkOrderTableRows(rows = []) {
  784. return (rows || []).map((item, index) => ({
  785. ...deepClone(item),
  786. id: item.id ?? item.code ?? `work-order-${index}`,
  787. serialNumber: index + 1
  788. }));
  789. },
  790. syncTableSelection(refName, rows) {
  791. this.$nextTick(() => {
  792. const table = this.$refs[refName];
  793. if (!table) {
  794. return;
  795. }
  796. if (refName === 'planPickerTable') {
  797. this.planPickerSelectionSyncing = true;
  798. }
  799. if (refName === 'planTable') {
  800. this.planTableSelectionSyncing = true;
  801. }
  802. setTimeout(() => {
  803. if (typeof table?.setSelectedRows === 'function') {
  804. table.setSelectedRows(rows || []);
  805. } else {
  806. table?.clearSelection?.();
  807. (rows || []).forEach((row) => {
  808. table?.toggleRowSelection?.(row, true);
  809. });
  810. }
  811. if (refName === 'planPickerTable') {
  812. this.$nextTick(() => {
  813. this.planPickerSelectionSyncing = false;
  814. });
  815. }
  816. if (refName === 'planTable') {
  817. this.$nextTick(() => {
  818. this.planTableSelectionSyncing = false;
  819. });
  820. }
  821. }, 0);
  822. });
  823. },
  824. // Plan picker flow
  825. async planPickerDatasource({ page, limit, where }) {
  826. this.planPickerLoading = true;
  827. try {
  828. const requestWhere = { ...(where || {}) };
  829. requestWhere.status = Array.isArray(requestWhere.status)
  830. ? requestWhere.status
  831. : requestWhere.status
  832. ? [requestWhere.status]
  833. : [];
  834. const data = await getList({
  835. ...requestWhere,
  836. pageNum: page,
  837. size: limit,
  838. timeDimensionPlanType: this.planPickerTimeDimensionPlanType
  839. });
  840. this.allPlanDataList = Array.isArray(data?.list) ? data.list : [];
  841. const selectedMap = new Map(
  842. (this.planPickerSelectionAll || []).map((item) => [
  843. this.getPlanRowKey(item),
  844. item
  845. ])
  846. );
  847. this.planPickerSelection = this.allPlanDataList.filter((item) =>
  848. selectedMap.has(this.getPlanRowKey(item))
  849. );
  850. this.syncTableSelection('planPickerTable', this.planPickerSelection);
  851. return data;
  852. } finally {
  853. this.planPickerLoading = false;
  854. }
  855. },
  856. async openPlanPicker(timeDimensionPlanType, title) {
  857. if (this.entryReadonly) {
  858. return;
  859. }
  860. this.planPickerTitle = title || '添加计划';
  861. this.planPickerTimeDimensionPlanType = timeDimensionPlanType;
  862. this.planPickerWhere = createPlanPickerWhere();
  863. this.planPickerSelectionAll = this.buildPlanTableRows(
  864. this.planDataList
  865. );
  866. this.planPickerSelection = [];
  867. this.allPlanDataList = [];
  868. this.planPickerVisible = true;
  869. this.$nextTick(() => {
  870. this.$refs.planPickerTable?.reload({ page: 1, where: {} });
  871. });
  872. },
  873. handlePlanPickerSearch() {
  874. this.$refs.planPickerTable?.reload({
  875. page: 1,
  876. where: { ...this.planPickerWhere }
  877. });
  878. },
  879. resetPlanPickerSearch() {
  880. this.planPickerWhere = createPlanPickerWhere();
  881. this.$refs.planPickerTable?.reload({ page: 1, where: {} });
  882. },
  883. handlePlanPickerSelectionChange(rows) {
  884. if (this.planPickerSelectionSyncing) {
  885. return;
  886. }
  887. const currentPageSelection = Array.isArray(rows) ? rows : [];
  888. const currentPageKeySet = new Set(
  889. (this.allPlanDataList || [])
  890. .map((item) => this.getPlanRowKey(item))
  891. .filter((item) => item !== '')
  892. );
  893. const selectedMap = new Map(
  894. (this.planPickerSelectionAll || [])
  895. .filter((item) => !currentPageKeySet.has(this.getPlanRowKey(item)))
  896. .map((item) => [this.getPlanRowKey(item), item])
  897. );
  898. currentPageSelection.forEach((item) => {
  899. selectedMap.set(this.getPlanRowKey(item), item);
  900. });
  901. this.planPickerSelection = currentPageSelection;
  902. this.planPickerSelectionAll = Array.from(selectedMap.values());
  903. },
  904. async confirmPlanPicker() {
  905. const nextPlanDataList = this.buildPlanTableRows(
  906. this.planPickerSelectionAll
  907. );
  908. if (!nextPlanDataList.length) {
  909. this.$message.warning('请至少选择一条计划');
  910. return;
  911. }
  912. const currentPlanKey = this.getPlanRowKey(this.currentPlan);
  913. const matchedCurrentPlan = nextPlanDataList.find(
  914. (item) => this.getPlanRowKey(item) === currentPlanKey
  915. );
  916. this.planPickerVisible = false;
  917. this.planDataList = nextPlanDataList;
  918. this.orderDetailReadonly = false;
  919. this.orderDetailActionMode = '';
  920. this.currentPlan = null;
  921. this.planRoutingPayload = null;
  922. this.taskList = [];
  923. this.workstationOptionsMap = {};
  924. this.workstationOptionsLoadingMap = {};
  925. this.selection = [];
  926. this.dotLineLoading = false;
  927. await this.refreshSchedulingView();
  928. this.selection = matchedCurrentPlan ? [matchedCurrentPlan] : [];
  929. this.syncTableSelection(
  930. 'planTable',
  931. matchedCurrentPlan ? [matchedCurrentPlan] : []
  932. );
  933. },
  934. // Selected plan detail
  935. handlePlanSelectionChange(rows) {
  936. if (this.planTableSelectionSyncing) {
  937. return;
  938. }
  939. const nextRows = Array.isArray(rows) ? rows : [];
  940. const row = nextRows[nextRows.length - 1];
  941. if (!row) {
  942. this.selection = [];
  943. this.syncTableSelection('planTable', []);
  944. return;
  945. }
  946. this.handlePublish(row);
  947. },
  948. resolveCurrentPlan(row) {
  949. if (!this.isOrderScheduling) {
  950. return row;
  951. }
  952. return {
  953. ...row,
  954. workOrderId: row.id,
  955. id: row.productionPlanId || row.id,
  956. code: row.productionPlanCode || row.code,
  957. productionOrderNumber: row.code,
  958. startTime: row.planStartTime || row.startTime,
  959. endTime: row.planCompleteTime || row.endTime,
  960. productNum: row.formingNum ?? row.productNum,
  961. unit: row.measuringUnit || row.unit
  962. };
  963. },
  964. handlePublish(row) {
  965. if (!row.bomCategoryId) {
  966. this.$message.warning('该计划没有配置BOM请先配置BOM');
  967. return;
  968. }
  969. const readonly = this.isOrderSchedulingReadonlyRow(row);
  970. this.orderDetailReadonly = readonly;
  971. this.orderDetailActionMode = readonly ? 'view' : 'edit';
  972. const currentPlan = this.resolveCurrentPlan(row);
  973. currentPlan._orderDetailReadonly = readonly;
  974. currentPlan.orderDetailReadonly = readonly;
  975. this.currentPlan = currentPlan;
  976. this.selection = [row];
  977. this.syncTableSelection('planTable', [row]);
  978. this.loadPlanDotLineDetail(currentPlan);
  979. },
  980. async loadPlanDotLineDetail(currentPlan) {
  981. this.dotLineLoading = true;
  982. this.planRoutingPayload = null;
  983. this.taskList = [];
  984. try {
  985. const planData = await getPlanDotLine({ planId: currentPlan.id });
  986. this.planRoutingPayload = planData || null;
  987. const details = planData?.detailList;
  988. if (details?.length) {
  989. this.taskList = [...details]
  990. .sort((a, b) => (a.taskSort ?? 0) - (b.taskSort ?? 0))
  991. .map((item, index) => this.normalizeDetailRow(item, index));
  992. // 班组排程的“执行对象”支持人员/工位,工位必须按当前工序查询;
  993. // 工厂排程仍然使用原来的班组执行对象,preload 内部会直接跳过。
  994. await this.preloadTaskWorkstationOptions();
  995. this.syncWorkOrderExecutionSelections();
  996. return;
  997. }
  998. if (!currentPlan.produceRoutingId) {
  999. this.$message.warning('暂无布点明细且缺少工艺路线,无法加载工序');
  1000. return;
  1001. }
  1002. const list = await getTaskListById(currentPlan.produceRoutingId);
  1003. this.taskList = (list || []).map((item, index) =>
  1004. this.normalizeRoutingTaskRow(item, index)
  1005. );
  1006. // 首次没有布点明细时会从工艺路线生成工序,班组排程仍需补齐
  1007. // 每道工序可派工位;工厂排程不加载这部分数据。
  1008. await this.preloadTaskWorkstationOptions();
  1009. this.syncWorkOrderExecutionSelections();
  1010. } catch (e) {
  1011. this.planRoutingPayload = null;
  1012. this.taskList = [];
  1013. this.$message.error(e.message || '获取工序布点信息失败');
  1014. } finally {
  1015. this.dotLineLoading = false;
  1016. }
  1017. },
  1018. normalizeDetailRow(item, index) {
  1019. const execType = toSafeNumber(item.executionType) ?? EXEC_TYPE.HOMEMADE;
  1020. const outsource = execType === EXEC_TYPE.OUTSOURCE;
  1021. const entrust = execType === EXEC_TYPE.ENTRUST;
  1022. const homemade = execType === EXEC_TYPE.HOMEMADE;
  1023. const orderMode = this.isOrderScheduling;
  1024. const savedObjectType =
  1025. orderMode && homemade
  1026. ? item.executionObjectType ||
  1027. item.executionTargetType ||
  1028. item.executionAssigneeType ||
  1029. (item.executionWorkstationId ? 'workstation' : 'person')
  1030. : '';
  1031. const objectId = orderMode
  1032. ? item.executionObjectId ||
  1033. item.executionAssigneeId ||
  1034. item.executionUserId ||
  1035. item.executionCrewId ||
  1036. item.executionWorkstationId ||
  1037. item.executionTeamId ||
  1038. ''
  1039. : item.executionTeamId ?? '';
  1040. const objectName = orderMode
  1041. ? item.executionObjectName ||
  1042. item.executionAssigneeName ||
  1043. item.executionUserName ||
  1044. item.executionCrewName ||
  1045. item.executionWorkstationName ||
  1046. item.executionTeamName ||
  1047. ''
  1048. : item.executionTeamName ?? '';
  1049. const dispatchTeamId =
  1050. item.dispatchTeamId ||
  1051. item.teamId ||
  1052. item.firstTaskTeamId ||
  1053. item.firstTeamId ||
  1054. item.executionTeamId ||
  1055. '';
  1056. const dispatchTeamName =
  1057. item.dispatchTeamName ||
  1058. item.teamName ||
  1059. item.firstTaskTeamName ||
  1060. item.firstTeamName ||
  1061. item.executionTeamName ||
  1062. '';
  1063. const dispatchTeamLeaderId =
  1064. item.dispatchTeamLeaderId ||
  1065. item.teamLeaderUserId ||
  1066. item.leaderUserId ||
  1067. item.executionTeamLeaderId ||
  1068. '';
  1069. const executionStartTime = formatDotLineDateTime(
  1070. item.executionStartTime
  1071. );
  1072. const executionEndTime = formatDotLineDateTime(item.executionEndTime);
  1073. return {
  1074. ...item,
  1075. _taskKey: item.id ?? `detail-${item.taskId ?? index}`,
  1076. executionStartTime,
  1077. executionEndTime,
  1078. dispatchDefaultStartTime: executionStartTime,
  1079. dispatchDefaultEndTime: executionEndTime,
  1080. executionType: execType,
  1081. executionFactoryId: entrust
  1082. ? item.executionFactoryId ?? item.executionTeamId ?? ''
  1083. : '',
  1084. executionFactoryName: entrust
  1085. ? item.executionFactoryName ?? item.executionTeamName ?? ''
  1086. : '',
  1087. executionTeamId:
  1088. homemade && orderMode && objectId
  1089. ? `${savedObjectType}:${objectId}`
  1090. : homemade
  1091. ? item.executionTeamId ?? ''
  1092. : '',
  1093. rawExecutionTeamId: homemade && orderMode ? objectId : '',
  1094. executionObjectType: homemade && orderMode ? savedObjectType : '',
  1095. executionObjectName: homemade && orderMode ? objectName : '',
  1096. dispatchTeamId,
  1097. dispatchTeamName,
  1098. dispatchTeamLeaderId,
  1099. quantity: orderMode
  1100. ? this.normalizeOrderQuantity(
  1101. item.quantity ??
  1102. item.taskQuantity ??
  1103. item.requiredFormingNum ??
  1104. item.productNum ??
  1105. ''
  1106. )
  1107. : item.quantity,
  1108. executionTeamLeader:
  1109. outsource || entrust ? '' : item.executionTeamLeader ?? '',
  1110. executionTeamLeaderId:
  1111. outsource || entrust ? '' : item.executionTeamLeaderId ?? '',
  1112. executionTeamName: outsource || entrust ? '' : objectName
  1113. };
  1114. },
  1115. normalizeRoutingTaskRow(item, index) {
  1116. const plan = this.currentPlan || {};
  1117. const taskId = item.id;
  1118. const row = {
  1119. ...item,
  1120. _taskKey: item.id ?? `new-${taskId ?? index}-${index}`,
  1121. taskId: taskId ?? undefined,
  1122. taskName: item.name ?? item.taskName,
  1123. taskCode: item.code ?? item.taskCode,
  1124. taskSort: item.taskSort ?? index + 1,
  1125. type: item.type ?? undefined,
  1126. sourceTaskId: item.sourceTaskId,
  1127. planId: plan.id,
  1128. planCode: plan.code,
  1129. routingId: plan.produceRoutingId,
  1130. routingName: plan.produceRoutingName ?? plan.routingName,
  1131. executionType: EXEC_TYPE.HOMEMADE,
  1132. executionTeamId: '',
  1133. executionObjectType: '',
  1134. executionObjectName: '',
  1135. dispatchTeamId:
  1136. item.dispatchTeamId ||
  1137. item.teamId ||
  1138. item.firstTaskTeamId ||
  1139. item.firstTeamId ||
  1140. item.executionTeamId ||
  1141. '',
  1142. dispatchTeamName:
  1143. item.dispatchTeamName ||
  1144. item.teamName ||
  1145. item.firstTaskTeamName ||
  1146. item.firstTeamName ||
  1147. item.executionTeamName ||
  1148. '',
  1149. dispatchTeamLeaderId:
  1150. item.dispatchTeamLeaderId ||
  1151. item.teamLeaderUserId ||
  1152. item.leaderUserId ||
  1153. item.executionTeamLeaderId ||
  1154. '',
  1155. executionTeamLeader: '',
  1156. executionTeamLeaderId: '',
  1157. executionTeamName: '',
  1158. executionStartTime: '',
  1159. executionEndTime: '',
  1160. dispatchDefaultStartTime: '',
  1161. dispatchDefaultEndTime: '',
  1162. executionFactoryId: '',
  1163. executionFactoryName: ''
  1164. };
  1165. if (this.isOrderScheduling) {
  1166. row.quantity = '';
  1167. }
  1168. return row;
  1169. },
  1170. taskName(item, index) {
  1171. return item.taskName || item.name || `工艺${index + 1}`;
  1172. },
  1173. routeStepTitle(item, index) {
  1174. return (
  1175. item.taskTypeName || item.taskName || item.name || `工艺${index + 1}`
  1176. );
  1177. },
  1178. isTaskDone(item) {
  1179. return item.executionType != null && item.executionType !== '';
  1180. },
  1181. execTypeNum(row) {
  1182. return toSafeNumber(row.executionType);
  1183. },
  1184. clearExecutionTeamFields(row) {
  1185. this.$set(row, 'executionTeamId', '');
  1186. this.$set(row, 'executionTeamName', '');
  1187. this.$set(row, 'executionObjectType', '');
  1188. this.$set(row, 'executionObjectName', '');
  1189. this.$set(row, 'executionTeamLeader', '');
  1190. this.$set(row, 'executionTeamLeaderId', '');
  1191. this.$set(row, 'executionFactoryId', '');
  1192. this.$set(row, 'executionFactoryName', '');
  1193. },
  1194. onExecutionTypeChange(row) {
  1195. if (this.isCurrentPlanReadonly) {
  1196. return;
  1197. }
  1198. this.clearExecutionTeamFields(row);
  1199. },
  1200. onExecutionObjectChange(row) {
  1201. if (this.isCurrentPlanReadonly) {
  1202. return;
  1203. }
  1204. const t = this.execTypeNum(row);
  1205. if (t === EXEC_TYPE.HOMEMADE) {
  1206. const team = this.findHomemadeOption(row);
  1207. row.executionTeamName = team?.name ?? '';
  1208. row.executionObjectType = team?.objectType ?? '';
  1209. row.executionObjectName = team?.name ?? '';
  1210. row.rawExecutionTeamId = team?.rawId ?? row.executionTeamId;
  1211. row.executionTeamLeader = team?.leaderUserName ?? '';
  1212. row.executionTeamLeaderId = team?.leaderUserId ?? '';
  1213. row.executionFactoryId = '';
  1214. row.executionFactoryName = '';
  1215. } else if (t === EXEC_TYPE.ENTRUST) {
  1216. const f = this.factoryList.find(
  1217. (x) => x.value === row.executionFactoryId
  1218. );
  1219. row.executionFactoryName = f?.label ?? '';
  1220. row.executionTeamId = '';
  1221. row.executionTeamName = '';
  1222. row.executionTeamLeader = '';
  1223. row.executionTeamLeaderId = '';
  1224. }
  1225. },
  1226. async loadTeamOptions() {
  1227. try {
  1228. const factoryId = this.$store.state.user.info.factoryId;
  1229. const res = await teamPage({ pageNum: 1, size: -1, factoryId });
  1230. this.teamOptions = (res?.list || []).map(
  1231. ({ id, name, leaderUserName, leaderUserId }) => ({
  1232. id,
  1233. name,
  1234. objectType: 'team',
  1235. leaderUserName,
  1236. leaderUserId
  1237. })
  1238. );
  1239. } catch {
  1240. this.teamOptions = [];
  1241. }
  1242. },
  1243. async loadApprovalReviewConfig() {
  1244. try {
  1245. const res = await parameterGetByCode({
  1246. code: 'planned_release_require'
  1247. });
  1248. this.isReview = res?.value == '1';
  1249. } catch (e) {
  1250. this.isReview = false;
  1251. }
  1252. },
  1253. async loadWorkOrderExecutionOptions() {
  1254. // 班组排程自制执行对象分两类:
  1255. // - 人员:打开弹窗时一次性加载,所有工序共用。
  1256. // - 工位:依赖具体工序,不能取全厂工位,需要在工序加载后按 taskId 查询。
  1257. try {
  1258. const res = await getUserPage({ pageNum: 1, size: -1 });
  1259. const users = Array.isArray(res?.list) ? res.list : [];
  1260. this.teamOptions = users.map((item) => ({
  1261. id: `person:${item.id}`,
  1262. rawId: item.id,
  1263. objectType: 'person',
  1264. name: `人员:${
  1265. item.name ||
  1266. item.userName ||
  1267. item.loginName ||
  1268. item.jobNumber ||
  1269. item.id
  1270. }`,
  1271. leaderUserName: item.name || item.userName || '',
  1272. leaderUserId: item.id
  1273. }));
  1274. } catch {
  1275. this.teamOptions = [];
  1276. }
  1277. this.syncWorkOrderExecutionSelections();
  1278. },
  1279. getTaskWorkstationKey(row) {
  1280. const rowTaskId = row?.taskId;
  1281. const currentTaskId = this.currentPlan?.taskId;
  1282. const taskId =
  1283. row?.sourceTaskId ??
  1284. row?.firstTaskId ??
  1285. (rowTaskId && Number(rowTaskId) >= 0 ? rowTaskId : undefined) ??
  1286. (currentTaskId && Number(currentTaskId) >= 0
  1287. ? currentTaskId
  1288. : undefined) ??
  1289. this.currentPlan?.firstTaskId ??
  1290. '';
  1291. return taskId === null || taskId === undefined || taskId === ''
  1292. ? ''
  1293. : String(taskId);
  1294. },
  1295. formatWorkstationOptions(list = []) {
  1296. return (Array.isArray(list) ? list : []).map((item) => {
  1297. const substance =
  1298. item.workstationSubstanceList?.[0]?.substance ||
  1299. item.substance ||
  1300. item.asset ||
  1301. {};
  1302. const category =
  1303. substance.category?.category || substance.category || {};
  1304. const name =
  1305. item.name || item.workstationName || item.stationName || item.id;
  1306. const code = item.code || item.workstationCode || item.stationCode;
  1307. const displayName = code ? `${name}(${code})` : name;
  1308. const rawId =
  1309. item.id ??
  1310. item.workstationId ??
  1311. item.factoryWorkstationId ??
  1312. item.stationId ??
  1313. code ??
  1314. name;
  1315. return {
  1316. id: `workstation:${rawId}`,
  1317. rawId,
  1318. objectType: 'workstation',
  1319. name: `工位:${displayName}`,
  1320. code: item.code || item.workstationCode || item.stationCode || '',
  1321. workstationCode:
  1322. item.workstationCode || item.code || item.stationCode || '',
  1323. assetCode:
  1324. item.assetCode ||
  1325. item.deviceCode ||
  1326. item.extInfo?.assetCode ||
  1327. substance.code ||
  1328. '',
  1329. assetId:
  1330. this.normalizeBackendLongId(item.assetId) ||
  1331. this.normalizeBackendLongId(item.deviceId) ||
  1332. this.normalizeBackendLongId(item.extInfo?.assetId) ||
  1333. this.normalizeBackendLongId(substance.id) ||
  1334. '',
  1335. assetName:
  1336. item.assetName ||
  1337. item.deviceName ||
  1338. item.extInfo?.assetName ||
  1339. substance.name ||
  1340. '',
  1341. assetModelType:
  1342. item.assetModelType ||
  1343. item.deviceModel ||
  1344. category.modelType ||
  1345. '',
  1346. assetCategoryLevelPath:
  1347. item.assetCategoryLevelPath ||
  1348. item.deviceType ||
  1349. category.categoryLevelPath?.split('-')?.[0] ||
  1350. '',
  1351. extInfo: item.extInfo || {},
  1352. isNew: item.isNew || '',
  1353. leaderUserName: item.leaderName || '',
  1354. leaderUserId: item.leaderId || ''
  1355. };
  1356. });
  1357. },
  1358. async loadWorkstationOptionsByTaskId(taskId) {
  1359. const key =
  1360. taskId === null || taskId === undefined || taskId === ''
  1361. ? ''
  1362. : String(taskId);
  1363. // 这里复用任务派单“工序派单”的工位来源:
  1364. // /main/factoryworkstation/listByFirstTaskId/{taskId}
  1365. // 这样每行工序只展示它能派发的工位。isOrderScheduling 用来保证
  1366. // 该接口不会在工厂排程中触发,避免改变现有工厂排程数据链路。
  1367. if (
  1368. !this.isOrderScheduling ||
  1369. !key ||
  1370. this.workstationOptionsMap[key] ||
  1371. this.workstationOptionsLoadingMap[key]
  1372. ) {
  1373. return;
  1374. }
  1375. this.$set(this.workstationOptionsLoadingMap, key, true);
  1376. try {
  1377. const res = await listByFirstTaskId(taskId);
  1378. this.$set(
  1379. this.workstationOptionsMap,
  1380. key,
  1381. this.formatWorkstationOptions(res)
  1382. );
  1383. this.syncWorkOrderExecutionSelections();
  1384. } catch {
  1385. this.$set(this.workstationOptionsMap, key, []);
  1386. } finally {
  1387. this.$delete(this.workstationOptionsLoadingMap, key);
  1388. }
  1389. },
  1390. preloadTaskWorkstationOptions(rows = this.taskList) {
  1391. if (!this.isOrderScheduling) {
  1392. return Promise.resolve();
  1393. }
  1394. // 多个工序可能引用同一个 taskId,去重后再请求,减少重复接口调用。
  1395. const taskIds = Array.from(
  1396. new Set(
  1397. (rows || [])
  1398. .map((row) => this.getTaskWorkstationKey(row))
  1399. .filter(Boolean)
  1400. )
  1401. );
  1402. return Promise.all(
  1403. taskIds.map((taskId) => this.loadWorkstationOptionsByTaskId(taskId))
  1404. );
  1405. },
  1406. getHomemadeOptions(row) {
  1407. if (!this.isOrderScheduling) {
  1408. return this.teamOptions;
  1409. }
  1410. // 班组排程的自制执行对象 = 人员 + 当前工序可派工位。
  1411. // 下拉框每一行调用一次该方法,因此这里按行拿 taskId,再合并该行的
  1412. // 工位缓存;若缓存还没回来,先显示人员,接口返回后 Vue 会刷新下拉。
  1413. const key = this.getTaskWorkstationKey(row);
  1414. if (key && !this.workstationOptionsMap[key]) {
  1415. this.loadWorkstationOptionsByTaskId(key);
  1416. }
  1417. return [
  1418. ...this.teamOptions,
  1419. ...(key ? this.workstationOptionsMap[key] || [] : [])
  1420. ];
  1421. },
  1422. findHomemadeOption(row) {
  1423. return this.getHomemadeOptions(row).find((option) =>
  1424. this.optionMatchesId(option.id, row.executionTeamId)
  1425. );
  1426. },
  1427. syncWorkOrderExecutionSelections() {
  1428. if (!this.isOrderScheduling) {
  1429. return;
  1430. }
  1431. // 前端下拉为避免人员和工位 id 冲突,会加 person:/workstation: 前缀,
  1432. // 所以工位选项加载完成后需要把原始 id 回填成下拉可识别的值。
  1433. this.taskList.forEach((row) => {
  1434. if (this.execTypeNum(row) !== EXEC_TYPE.HOMEMADE) return;
  1435. const objectType = row.executionObjectType || 'person';
  1436. const matched = this.getHomemadeOptions(row).find(
  1437. (option) =>
  1438. option.objectType === objectType &&
  1439. this.optionMatchesId(option.rawId, row.rawExecutionTeamId)
  1440. );
  1441. if (matched) {
  1442. this.$set(row, 'executionTeamId', matched.id);
  1443. this.$set(row, 'executionTeamName', matched.name);
  1444. this.$set(row, 'executionObjectName', matched.name);
  1445. this.$set(row, 'rawExecutionTeamId', matched.rawId);
  1446. }
  1447. });
  1448. },
  1449. async loadFactoryOptions() {
  1450. try {
  1451. const res = await getFactoryarea({ type: 1, size: 9999 });
  1452. if (res.list?.length) {
  1453. this.factoryList = res.list.map((el) => ({
  1454. value: el.id,
  1455. label: el.name
  1456. }));
  1457. } else {
  1458. this.factoryList = [];
  1459. }
  1460. } catch {
  1461. this.factoryList = [];
  1462. }
  1463. },
  1464. // Task config editing
  1465. handleTimeChange(row, changeKey) {
  1466. if (this.isCurrentPlanReadonly) {
  1467. return;
  1468. }
  1469. if (isEndBeforeStart(row.executionStartTime, row.executionEndTime)) {
  1470. this.$message.warning('执行结束时间不能小于执行开始时间');
  1471. this.$set(row, changeKey, '');
  1472. return;
  1473. }
  1474. if (!this.validateTaskSequence(row, { resetKey: changeKey })) {
  1475. return;
  1476. }
  1477. const deadline =
  1478. this.currentPlan?.planDeliveryTime || this.currentPlan?.deliveryTime;
  1479. if (
  1480. changeKey === 'executionStartTime' &&
  1481. deadline &&
  1482. row.executionStartTime
  1483. ) {
  1484. const d = new Date(deadline).getTime();
  1485. const v = new Date(row.executionStartTime).getTime();
  1486. if (!Number.isNaN(d) && !Number.isNaN(v) && v > d) {
  1487. this.$message.warning('时间不能大于计划交付时间');
  1488. this.$set(row, changeKey, '');
  1489. return;
  1490. }
  1491. }
  1492. if (changeKey === 'executionEndTime' && row.executionEndTime) {
  1493. const planEnd = this.currentPlan?.endTime;
  1494. const overDelivery =
  1495. !!deadline && isEndAfterPlanEnd(row.executionEndTime, deadline);
  1496. const overPlanEnd =
  1497. !!planEnd && isEndAfterPlanEnd(row.executionEndTime, planEnd);
  1498. if (overDelivery && overPlanEnd) {
  1499. this.$message.warning(
  1500. '执行结束时间晚于计划交付时间及计划结束时间,已保留填写内容,请留意核对'
  1501. );
  1502. } else if (overDelivery) {
  1503. this.$message.warning(
  1504. '执行结束时间晚于计划交付时间,已保留填写内容,请留意核对'
  1505. );
  1506. } else if (overPlanEnd) {
  1507. this.$message.warning(
  1508. '执行结束时间晚于计划结束时间,已保留填写内容,请留意核对'
  1509. );
  1510. }
  1511. }
  1512. },
  1513. isExecutionEndOverDelivery(row) {
  1514. const deadline =
  1515. this.currentPlan?.planDeliveryTime || this.currentPlan?.deliveryTime;
  1516. return (
  1517. !!deadline &&
  1518. !!row?.executionEndTime &&
  1519. isEndAfterPlanEnd(row.executionEndTime, deadline)
  1520. );
  1521. },
  1522. isExecutionEndOverPlanEnd(row) {
  1523. const planEnd = this.currentPlan?.endTime;
  1524. return (
  1525. !!planEnd &&
  1526. !!row?.executionEndTime &&
  1527. isEndAfterPlanEnd(row.executionEndTime, planEnd)
  1528. );
  1529. },
  1530. toggleDotLineFullscreen() {
  1531. this.dotLineFullscreen = !this.dotLineFullscreen;
  1532. },
  1533. getTaskLabel(item, index) {
  1534. if (item) {
  1535. return (
  1536. item.taskName ||
  1537. item.name ||
  1538. (typeof index === 'number' ? `工艺${index + 1}` : '当前工艺')
  1539. );
  1540. }
  1541. return index !== undefined ? `工艺${index + 1}` : '当前工艺';
  1542. },
  1543. getTaskIndex(row) {
  1544. return this.taskList.findIndex((item) => item === row);
  1545. },
  1546. compareTaskTime(start, end) {
  1547. if (!start || !end) return false;
  1548. const startTime = new Date(start).getTime();
  1549. const endTime = new Date(end).getTime();
  1550. return (
  1551. !Number.isNaN(startTime) &&
  1552. !Number.isNaN(endTime) &&
  1553. startTime < endTime
  1554. );
  1555. },
  1556. validateTaskSequence(row, options = {}) {
  1557. const index = this.getTaskIndex(row);
  1558. if (index < 0) {
  1559. return true;
  1560. }
  1561. const prev = this.taskList[index - 1];
  1562. const next = this.taskList[index + 1];
  1563. const resetKey = options.resetKey;
  1564. const checkPrev = !resetKey || resetKey === 'executionStartTime';
  1565. const checkNext = !resetKey || resetKey === 'executionEndTime';
  1566. if (
  1567. checkPrev &&
  1568. prev?.executionEndTime &&
  1569. row.executionStartTime &&
  1570. this.compareTaskTime(row.executionStartTime, prev.executionEndTime)
  1571. ) {
  1572. this.$message.warning(
  1573. `${this.getTaskLabel(
  1574. row,
  1575. index
  1576. )}执行开始时间不能小于上道工序${this.getTaskLabel(
  1577. prev,
  1578. index - 1
  1579. )}的执行结束时间`
  1580. );
  1581. if (resetKey) {
  1582. this.$set(row, resetKey, '');
  1583. }
  1584. return false;
  1585. }
  1586. if (
  1587. checkNext &&
  1588. next?.executionStartTime &&
  1589. row.executionEndTime &&
  1590. this.compareTaskTime(next.executionStartTime, row.executionEndTime)
  1591. ) {
  1592. this.$message.warning(
  1593. `下道工序${this.getTaskLabel(
  1594. next,
  1595. index + 1
  1596. )}的执行开始时间不能小于上道工序${this.getTaskLabel(
  1597. row,
  1598. index
  1599. )}的执行结束时间`
  1600. );
  1601. if (resetKey) {
  1602. this.$set(row, resetKey, '');
  1603. }
  1604. return false;
  1605. }
  1606. return true;
  1607. },
  1608. validateTaskRow(item, options = {}) {
  1609. const label = (t) => this.getTaskLabel(t);
  1610. const checkSequence = options.checkSequence !== false;
  1611. const execType = toSafeNumber(item.executionType);
  1612. if (execType === undefined) {
  1613. this.$message.warning(`${label(item)}请选择执行模式`);
  1614. return false;
  1615. }
  1616. if (execType === EXEC_TYPE.HOMEMADE) {
  1617. if (
  1618. !item.executionTeamId ||
  1619. !item.executionStartTime ||
  1620. !item.executionEndTime
  1621. ) {
  1622. this.$message.warning(
  1623. `${label(
  1624. item
  1625. )}执行模式为自制时,需选择执行班组并填写执行开始和结束时间`
  1626. );
  1627. return false;
  1628. }
  1629. }
  1630. if (execType === EXEC_TYPE.ENTRUST) {
  1631. if (
  1632. !item.executionFactoryId ||
  1633. !item.executionStartTime ||
  1634. !item.executionEndTime
  1635. ) {
  1636. this.$message.warning(
  1637. `${label(
  1638. item
  1639. )}执行模式为请托时,需选择工厂并填写执行开始和结束时间`
  1640. );
  1641. return false;
  1642. }
  1643. }
  1644. if (execType === EXEC_TYPE.OUTSOURCE) {
  1645. if (!item.executionStartTime || !item.executionEndTime) {
  1646. this.$message.warning(
  1647. `${label(item)}执行模式为委外时,需填写执行开始和结束时间`
  1648. );
  1649. return false;
  1650. }
  1651. }
  1652. if (isEndBeforeStart(item.executionStartTime, item.executionEndTime)) {
  1653. this.$message.warning(
  1654. `${label(item)}执行结束时间不能小于执行开始时间`
  1655. );
  1656. return false;
  1657. }
  1658. const deadline =
  1659. this.currentPlan?.planDeliveryTime || this.currentPlan?.deliveryTime;
  1660. if (deadline) {
  1661. const d = new Date(deadline).getTime();
  1662. const checkStart = (val, name) => {
  1663. if (!val) return true;
  1664. const t = new Date(val).getTime();
  1665. return Number.isNaN(d) || Number.isNaN(t) || t <= d
  1666. ? true
  1667. : (this.$message.warning(
  1668. `${label(item)}${name}不能大于计划交付时间`
  1669. ),
  1670. false);
  1671. };
  1672. if (!checkStart(item.executionStartTime, '执行开始时间'))
  1673. return false;
  1674. }
  1675. return checkSequence ? this.validateTaskSequence(item) : true;
  1676. },
  1677. validateTaskList() {
  1678. for (const item of this.taskList) {
  1679. if (!this.validateTaskRow(item)) return false;
  1680. }
  1681. return true;
  1682. },
  1683. addTaskRow(row) {
  1684. if (row) {
  1685. this.taskList.push(row);
  1686. }
  1687. },
  1688. removeTaskRow(row) {
  1689. const index = this.taskList.findIndex((item) => item === row);
  1690. if (index >= 0) {
  1691. this.taskList.splice(index, 1);
  1692. }
  1693. },
  1694. addDispatchStations({ task, list }) {
  1695. if (!this.isOrderScheduling || !task) {
  1696. return;
  1697. }
  1698. const key = this.getTaskWorkstationKey(task);
  1699. if (!key) {
  1700. this.$message.warning('当前工序缺少任务信息,无法添加工位');
  1701. return;
  1702. }
  1703. const currentList = this.workstationOptionsMap[key] || [];
  1704. const nextList = [...currentList];
  1705. const existedIds = new Set(currentList.map((item) => String(item.id)));
  1706. this.formatWorkstationOptions(list).forEach((item) => {
  1707. if (!existedIds.has(String(item.id))) {
  1708. existedIds.add(String(item.id));
  1709. nextList.push(item);
  1710. }
  1711. });
  1712. this.$set(this.workstationOptionsMap, key, nextList);
  1713. },
  1714. async handleDispatchActionSuccess(event = {}) {
  1715. if (!this.isOrderScheduling) {
  1716. return;
  1717. }
  1718. if (event.type === 'confirm') {
  1719. await this.reloadOrderSchedulingOrdersByDateRange(this.dateRange);
  1720. return;
  1721. }
  1722. await this.refreshSchedulingView();
  1723. },
  1724. buildSavePayload(isCache = 0) {
  1725. const plan = this.currentPlan;
  1726. const head = this.planRoutingPayload || {};
  1727. const detailList = this.taskList.map((row) => {
  1728. const execType = toSafeNumber(row.executionType) ?? 0;
  1729. // 只有班组排程需要把带前缀的下拉值还原为人员/工位原始 id;
  1730. // 工厂排程保持原 executionTeamId 保存方式。
  1731. const homemadeOption = this.isOrderScheduling
  1732. ? this.findHomemadeOption(row)
  1733. : null;
  1734. const detail = {
  1735. executionEndTime: row.executionEndTime || undefined,
  1736. executionStartTime: row.executionStartTime || undefined,
  1737. executionTeamId:
  1738. execType === EXEC_TYPE.HOMEMADE
  1739. ? (this.isOrderScheduling
  1740. ? homemadeOption?.rawId ||
  1741. row.rawExecutionTeamId ||
  1742. row.executionTeamId
  1743. : row.executionTeamId) || undefined
  1744. : undefined,
  1745. executionTeamLeader: row.executionTeamLeader || '',
  1746. executionTeamLeaderId: row.executionTeamLeaderId || '',
  1747. executionTeamName: row.executionTeamName || '',
  1748. executionType: execType,
  1749. planCode: row.planCode || plan?.code,
  1750. planId: row.planId ?? plan?.id,
  1751. routingId:
  1752. row.routingId ?? plan?.produceRoutingId ?? head.routingId,
  1753. routingName:
  1754. row.routingName || plan?.produceRoutingName || head.routingName,
  1755. sourceTaskId: row.sourceTaskId ?? row.taskId,
  1756. taskCode: row.taskCode,
  1757. taskId: row.taskId,
  1758. taskName: row.taskName,
  1759. taskSort: row.taskSort,
  1760. type: toSafeNumber(row.type)
  1761. };
  1762. // 数量输入框是班组排程工序配置新增字段,工厂排程不写入,
  1763. // 避免改变原工厂排程保存 payload。
  1764. if (this.isOrderScheduling) {
  1765. detail.quantity =
  1766. row.quantity !== '' &&
  1767. row.quantity !== null &&
  1768. row.quantity !== undefined
  1769. ? row.quantity
  1770. : undefined;
  1771. }
  1772. // 班组排程自制模式下,执行对象可能是人员也可能是工位;
  1773. // executionObject* 字段用于明确记录对象类型和值,委外/外协不写入。
  1774. if (this.isOrderScheduling && execType === EXEC_TYPE.HOMEMADE) {
  1775. detail.executionObjectId =
  1776. homemadeOption?.rawId ||
  1777. row.rawExecutionTeamId ||
  1778. row.executionTeamId ||
  1779. undefined;
  1780. detail.executionObjectType = row.executionObjectType || undefined;
  1781. detail.executionObjectName =
  1782. row.executionObjectName || row.executionTeamName || '';
  1783. }
  1784. if (execType === EXEC_TYPE.ENTRUST) {
  1785. detail.executionFactoryId = row.executionFactoryId || undefined;
  1786. detail.executionFactoryName = row.executionFactoryName || '';
  1787. }
  1788. if (row.id != null) detail.id = row.id;
  1789. return detail;
  1790. });
  1791. return {
  1792. detailList,
  1793. fileParam: head.fileParam ?? [],
  1794. id: head.id,
  1795. isCache,
  1796. planCode: plan?.code ?? head.planCode,
  1797. planId: plan?.id ?? head.planId,
  1798. produceVersionId: head.produceVersionId,
  1799. produceVersionName: head.produceVersionName,
  1800. releaseTime: head.releaseTime,
  1801. routingCode: head.routingCode,
  1802. routingId: head.routingId ?? plan?.produceRoutingId,
  1803. routingName: head.routingName ?? plan?.produceRoutingName,
  1804. routingVersion: head.routingVersion
  1805. };
  1806. },
  1807. // Scheduling data refresh
  1808. async handleTabChange(tabKey) {
  1809. this.activeTab = tabKey;
  1810. await this.refreshSchedulingView();
  1811. if (!this.isOrderScheduling) {
  1812. await this.reloadPlanSchedulingPlansByStatus();
  1813. }
  1814. },
  1815. async handleDateChange(val) {
  1816. this.dateRange = val;
  1817. if (this.isOrderScheduling) {
  1818. this.scheduleOrderSchedulingDateReload(val);
  1819. return;
  1820. }
  1821. await this.refreshSchedulingView();
  1822. await this.reloadPlanSchedulingPlansByStatus();
  1823. },
  1824. handleDateInput(val) {
  1825. if (!this.isOrderScheduling) {
  1826. return;
  1827. }
  1828. this.dateRange = val;
  1829. this.scheduleOrderSchedulingDateReload(val);
  1830. },
  1831. scheduleOrderSchedulingDateReload(dateRange) {
  1832. if (!Array.isArray(dateRange) || dateRange.length !== 2) {
  1833. return;
  1834. }
  1835. if (!dateRange[0] || !dateRange[1]) {
  1836. return;
  1837. }
  1838. if (this.orderDateReloadTimer) {
  1839. clearTimeout(this.orderDateReloadTimer);
  1840. }
  1841. this.orderDateReloadTimer = setTimeout(() => {
  1842. this.orderDateReloadTimer = null;
  1843. this.reloadOrderSchedulingOrdersByDateRange(dateRange);
  1844. }, 0);
  1845. },
  1846. async reloadOrderSchedulingOrdersByDateRange(dateRange) {
  1847. this.orderDetailReadonly = false;
  1848. this.orderDetailActionMode = '';
  1849. if (typeof this.orderListLoader !== 'function') {
  1850. await this.refreshSchedulingView();
  1851. return;
  1852. }
  1853. const loading = this.$loading({
  1854. lock: true,
  1855. text: '加载订单中...'
  1856. });
  1857. try {
  1858. const list = await this.orderListLoader(
  1859. dateRange,
  1860. this.getPlanTableStatusRequestWhere()
  1861. );
  1862. this.selectedWorkOrders = this.buildWorkOrderTableRows(list);
  1863. this.planDataList = this.selectedWorkOrders;
  1864. this.planTableRenderKey += 1;
  1865. const currentWorkOrderId = this.currentPlan?.workOrderId;
  1866. const matchedCurrentOrder = currentWorkOrderId
  1867. ? this.selectedWorkOrders.find(
  1868. (item) => String(item.id) === String(currentWorkOrderId)
  1869. )
  1870. : null;
  1871. if (matchedCurrentOrder) {
  1872. const currentPlan = this.resolveCurrentPlan(matchedCurrentOrder);
  1873. this.orderDetailReadonly =
  1874. this.isOrderSchedulingReadonlyRow(matchedCurrentOrder);
  1875. this.orderDetailActionMode = this.orderDetailReadonly
  1876. ? 'view'
  1877. : 'edit';
  1878. currentPlan._orderDetailReadonly = this.orderDetailReadonly;
  1879. currentPlan.orderDetailReadonly = this.orderDetailReadonly;
  1880. this.currentPlan = currentPlan;
  1881. this.selection = [matchedCurrentOrder];
  1882. this.syncTableSelection('planTable', [matchedCurrentOrder]);
  1883. await this.loadPlanDotLineDetail(currentPlan);
  1884. } else {
  1885. this.orderDetailReadonly = false;
  1886. this.orderDetailActionMode = '';
  1887. this.currentPlan = null;
  1888. this.planRoutingPayload = null;
  1889. this.taskList = [];
  1890. this.selection = [];
  1891. this.syncTableSelection('planTable', []);
  1892. }
  1893. await this.refreshSchedulingView();
  1894. } catch (e) {
  1895. this.$message.error(e.message || '获取订单数据失败');
  1896. } finally {
  1897. loading.close();
  1898. }
  1899. },
  1900. extractPlanIdsFromGanttData(data = []) {
  1901. const planIds = new Set();
  1902. (Array.isArray(data) ? data : []).forEach((item) => {
  1903. (item.resourcePeriods || []).forEach((period) => {
  1904. if (period.planId) planIds.add(period.planId);
  1905. });
  1906. (item.resourceList || []).forEach((resource) => {
  1907. if (resource.planId) planIds.add(resource.planId);
  1908. });
  1909. });
  1910. return Array.from(planIds);
  1911. },
  1912. async syncPlanTableRowsByGanttData(data = []) {
  1913. if (this.isOrderScheduling) {
  1914. return;
  1915. }
  1916. const planIds = this.extractPlanIdsFromGanttData(data);
  1917. if (!planIds.length) {
  1918. return;
  1919. }
  1920. const plans = await this.loadPlansByIds(planIds);
  1921. this.planDataList = this.buildPlanTableRows(plans);
  1922. },
  1923. async refreshSchedulingView() {
  1924. let data;
  1925. const params = {};
  1926. if (this.dateRange && this.dateRange.length === 2) {
  1927. params.startDate = this.dateRange[0];
  1928. params.endDate = this.dateRange[1];
  1929. }
  1930. // 班组排程从工单页面进入,用户选择的是工单数据;
  1931. // 甘特接口仍按计划维度查询,所以这里提取工单关联的 productionPlanId
  1932. // 作为 planIds 过滤条件。工厂排程本身就是计划入口,不需要该过滤。
  1933. if (this.isOrderScheduling) {
  1934. const planIds = Array.from(
  1935. new Set(
  1936. (this.selectedWorkOrders || [])
  1937. .map((item) => item.productionPlanId)
  1938. .filter((id) => id !== null && id !== undefined && id !== '')
  1939. )
  1940. );
  1941. if (planIds.length) {
  1942. params.planIds = planIds;
  1943. } else {
  1944. this.calendarSourceData = [];
  1945. this.tableData = [];
  1946. return;
  1947. }
  1948. }
  1949. if (this.activeTab === 'factory') {
  1950. // 工厂维度甘特:
  1951. // - 工厂排程默认进入该页签,继续使用 factorySchedulingGanttChart。
  1952. data = await factorySchedulingGanttChart(params);
  1953. await this.syncPlanTableRowsByGanttData(data);
  1954. } else if (this.isOrderScheduling) {
  1955. // 班组排程甘特按工单关联计划过滤,再使用工位/设备/人员专用接口。
  1956. // 展示结构仍交给现有甘特组件处理,保持和工厂排产一致的树形时间轴形式。
  1957. data = await workstationSchedulingGanttChart(params);
  1958. data = this.filterOrderSchedulingGanttDataByTab(data || []);
  1959. } else {
  1960. // 班组/工位维度甘特:
  1961. // 工厂排程切到该页签时保持原班组甘特逻辑;
  1962. data = await teamSchedulingGanttChart(params);
  1963. await this.syncPlanTableRowsByGanttData(data);
  1964. }
  1965. this.calendarSourceData = this.normalizeOrderSchedulingGanttData(
  1966. data || []
  1967. );
  1968. this.tableData = this.initGanttFlatRows(this.calendarSourceData);
  1969. },
  1970. getOrderSchedulingGanttWorkstationType(tabKey = this.activeTab) {
  1971. const workstationTypeMap = {
  1972. line: 1,
  1973. person: 3
  1974. };
  1975. return workstationTypeMap[tabKey];
  1976. },
  1977. hasOrderSchedulingDeviceResource(item = {}) {
  1978. return !!(item.deviceId || item.deviceCode || item.deviceName);
  1979. },
  1980. getOrderSchedulingAssigneeUsers(item = {}) {
  1981. if (Array.isArray(item.assigneeUser)) {
  1982. return item.assigneeUser;
  1983. }
  1984. if (item.assigneeUser && typeof item.assigneeUser === 'object') {
  1985. return [item.assigneeUser];
  1986. }
  1987. return [];
  1988. },
  1989. buildOrderSchedulingDeviceResource(item = {}) {
  1990. const deviceName =
  1991. item.deviceName || item.equipmentName || item.assetName || '';
  1992. const deviceCode = item.deviceCode || item.assetCode || '';
  1993. const deviceId =
  1994. this.normalizeBackendLongId(item.deviceId) ||
  1995. this.normalizeBackendLongId(item.assetId) ||
  1996. this.normalizeBackendLongId(item.extInfo?.assetId);
  1997. const resourceId =
  1998. deviceId || deviceCode || deviceName || item.resourceId;
  1999. const workstationName = item.name || item.resourceName || '';
  2000. const workstationCode = item.workstationCode || item.code || '';
  2001. return {
  2002. ...item,
  2003. resourceId: `device:${resourceId || ''}`,
  2004. resourceName: deviceName || deviceCode || workstationName,
  2005. resourceCode: deviceCode,
  2006. deviceId,
  2007. deviceCode,
  2008. deviceName,
  2009. equipmentName: deviceName || deviceCode,
  2010. workstationName,
  2011. workstationCode,
  2012. originResourceName: item.resourceName || item.name || '',
  2013. originResourceCode: item.resourceCode || item.code || '',
  2014. orderResourceTabType: 'device'
  2015. };
  2016. },
  2017. buildOrderSchedulingPersonResources(item = {}) {
  2018. const workstationName = item.name || item.resourceName || '';
  2019. const workstationCode = item.workstationCode || item.code || '';
  2020. return this.getOrderSchedulingAssigneeUsers(item)
  2021. .map((user, index) => {
  2022. const userName =
  2023. user?.userName || user?.name || user?.nickName || '';
  2024. const userId = user?.userId || user?.id || userName;
  2025. const jobNumber = user?.jobNumber || user?.code || '';
  2026. if (!userName && !userId && !jobNumber) {
  2027. return null;
  2028. }
  2029. return {
  2030. ...item,
  2031. resourceId: `person:${userId || index}-${
  2032. item.resourceId || item.taskId || item.sourceTaskId || index
  2033. }`,
  2034. resourceName: userName || jobNumber || String(userId),
  2035. resourceCode: jobNumber || String(userId || ''),
  2036. assigneeUser: [user],
  2037. assigneeUserId: userId,
  2038. assigneeUserName: userName,
  2039. assigneeJobNumber: jobNumber,
  2040. executionObjectType: 'person',
  2041. executionObjectName: userName || jobNumber || String(userId),
  2042. workstationName,
  2043. workstationCode,
  2044. originResourceName: item.resourceName || item.name || '',
  2045. originResourceCode: item.resourceCode || item.code || '',
  2046. orderResourceTabType: 'person'
  2047. };
  2048. })
  2049. .filter(Boolean);
  2050. },
  2051. filterOrderSchedulingGanttDataByTab(data = []) {
  2052. const list = Array.isArray(data) ? data : [];
  2053. if (this.activeTab === 'line') {
  2054. return list
  2055. .filter((item) => this.hasOrderSchedulingDeviceResource(item))
  2056. .map((item) => this.buildOrderSchedulingDeviceResource(item));
  2057. }
  2058. if (this.activeTab === 'person') {
  2059. return list.flatMap((item) =>
  2060. this.buildOrderSchedulingPersonResources(item)
  2061. );
  2062. }
  2063. const targetWorkstationType =
  2064. this.getOrderSchedulingGanttWorkstationType();
  2065. if (!targetWorkstationType) {
  2066. return list;
  2067. }
  2068. return list.filter(
  2069. (item) => Number(item?.workstationType) === targetWorkstationType
  2070. );
  2071. },
  2072. getOrderSchedulingResourceInfo(item = {}) {
  2073. const resourceName = item.resourceName || item.name || '';
  2074. const resourceCode = item.resourceCode || item.code || '';
  2075. const resourceType = Number(item.type);
  2076. const workstationType = Number(item.workstationType);
  2077. const deviceName =
  2078. item.deviceName || item.equipmentName || item.assetName || '';
  2079. const deviceCode = item.deviceCode || item.assetCode || '';
  2080. const personName =
  2081. item.executionObjectName || item.assigneeUserName || '';
  2082. return {
  2083. resourceName,
  2084. resourceCode,
  2085. resourceType,
  2086. workstationType,
  2087. orderResourceTabType: item.orderResourceTabType || '',
  2088. deviceId:
  2089. this.normalizeBackendLongId(item.deviceId) ||
  2090. this.normalizeBackendLongId(item.assetId) ||
  2091. this.normalizeBackendLongId(item.extInfo?.assetId) ||
  2092. '',
  2093. deviceCode,
  2094. deviceName,
  2095. assigneeUser: item.assigneeUser || [],
  2096. assigneeUserId: item.assigneeUserId || '',
  2097. assigneeUserName: item.assigneeUserName || '',
  2098. assigneeJobNumber: item.assigneeJobNumber || '',
  2099. workstationName:
  2100. item.workstationName ||
  2101. item.stationName ||
  2102. (resourceType === 1 ? resourceName : ''),
  2103. equipmentName:
  2104. item.equipmentName ||
  2105. deviceName ||
  2106. item.assetName ||
  2107. (item.orderResourceTabType === 'device' ? resourceName : ''),
  2108. executionObjectType:
  2109. item.executionObjectType || (workstationType === 3 ? 'person' : ''),
  2110. executionObjectName:
  2111. item.executionObjectName ||
  2112. personName ||
  2113. (workstationType === 3 ? resourceName : '')
  2114. };
  2115. },
  2116. normalizeOrderSchedulingPlanRef(source = {}) {
  2117. const productionOrderNumber =
  2118. source.productionOrderNumber ||
  2119. source.apsWorkOrderCode ||
  2120. source.workOrderCode ||
  2121. source.orderCode ||
  2122. '';
  2123. return {
  2124. planId: source.planId ?? source.apsWorkOrderId ?? source.workOrderId,
  2125. planCode:
  2126. source.planCode ||
  2127. source.apsWorkOrderCode ||
  2128. source.workOrderCode ||
  2129. '',
  2130. productionOrderNumber
  2131. };
  2132. },
  2133. getOrderSchedulingDisplayOrderCode(...sources) {
  2134. for (const source of sources) {
  2135. if (!source) continue;
  2136. const code =
  2137. source.productionOrderNumber ||
  2138. source.apsWorkOrderCode ||
  2139. source.workOrderCode ||
  2140. source.orderCode ||
  2141. source.planCode ||
  2142. '';
  2143. if (code) return code;
  2144. }
  2145. return '';
  2146. },
  2147. buildGanttPlanLabel(planInfo = {}, fallbackInfo = {}) {
  2148. const displayCode = this.isOrderScheduling
  2149. ? this.getOrderSchedulingDisplayOrderCode(planInfo, fallbackInfo)
  2150. : planInfo.planCode || '';
  2151. return [displayCode, planInfo.productName || fallbackInfo.productName]
  2152. .filter(Boolean)
  2153. .join(' ');
  2154. },
  2155. normalizeOrderSchedulingGanttData(data = []) {
  2156. if (!this.isOrderScheduling) {
  2157. return data;
  2158. }
  2159. return (Array.isArray(data) ? data : []).map((item) => {
  2160. const resourceInfo = this.getOrderSchedulingResourceInfo(item);
  2161. const resourceList = Array.isArray(item.resourceList)
  2162. ? item.resourceList.map((resource) => {
  2163. const planRef = this.normalizeOrderSchedulingPlanRef(resource);
  2164. return {
  2165. ...resource,
  2166. ...planRef,
  2167. productName: resource.productName || '',
  2168. workstationName:
  2169. resource.workstationName ||
  2170. resource.stationName ||
  2171. (resourceInfo.resourceType === 1
  2172. ? resourceInfo.resourceName
  2173. : ''),
  2174. equipmentName:
  2175. resource.equipmentName ||
  2176. resource.deviceName ||
  2177. resource.assetName ||
  2178. (resourceInfo.orderResourceTabType === 'device'
  2179. ? resourceInfo.resourceName
  2180. : ''),
  2181. deviceId:
  2182. this.normalizeBackendLongId(resource.deviceId) ||
  2183. this.normalizeBackendLongId(resource.assetId) ||
  2184. this.normalizeBackendLongId(resource.extInfo?.assetId) ||
  2185. resourceInfo.deviceId ||
  2186. '',
  2187. deviceCode:
  2188. resource.deviceCode || resourceInfo.deviceCode || '',
  2189. deviceName:
  2190. resource.deviceName || resourceInfo.deviceName || '',
  2191. assigneeUser:
  2192. resource.assigneeUser || resourceInfo.assigneeUser || [],
  2193. assigneeUserId:
  2194. resource.assigneeUserId ||
  2195. resourceInfo.assigneeUserId ||
  2196. '',
  2197. assigneeUserName:
  2198. resource.assigneeUserName ||
  2199. resourceInfo.assigneeUserName ||
  2200. '',
  2201. assigneeJobNumber:
  2202. resource.assigneeJobNumber ||
  2203. resourceInfo.assigneeJobNumber ||
  2204. '',
  2205. executionObjectName:
  2206. resource.executionObjectName ||
  2207. (resourceInfo.orderResourceTabType === 'person'
  2208. ? resourceInfo.resourceName
  2209. : '')
  2210. };
  2211. })
  2212. : [];
  2213. const resourcePeriods = Array.isArray(item.resourcePeriods)
  2214. ? item.resourcePeriods.map((period) => ({
  2215. ...period,
  2216. ...this.normalizeOrderSchedulingPlanRef(period)
  2217. }))
  2218. : [];
  2219. return {
  2220. ...item,
  2221. resourceCode: resourceInfo.resourceCode,
  2222. resourceName: resourceInfo.resourceName,
  2223. resourceList,
  2224. resourcePeriods,
  2225. orderResourceTabType: resourceInfo.orderResourceTabType,
  2226. deviceId: resourceInfo.deviceId,
  2227. deviceCode: resourceInfo.deviceCode,
  2228. deviceName: resourceInfo.deviceName,
  2229. assigneeUser: resourceInfo.assigneeUser,
  2230. assigneeUserId: resourceInfo.assigneeUserId,
  2231. assigneeUserName: resourceInfo.assigneeUserName,
  2232. assigneeJobNumber: resourceInfo.assigneeJobNumber,
  2233. workstationName: resourceInfo.workstationName,
  2234. equipmentName: resourceInfo.equipmentName,
  2235. executionObjectType: resourceInfo.executionObjectType,
  2236. executionObjectName: resourceInfo.executionObjectName
  2237. };
  2238. });
  2239. },
  2240. buildGanttPeriodTaskId(parentId, matchedPlanInfo, period, periodIndex) {
  2241. const periodTaskId = [
  2242. matchedPlanInfo.planId || period.planId || matchedPlanInfo.planCode,
  2243. period.apsWorkOrderId || period.workOrderId || period.planCode,
  2244. period.startTime,
  2245. period.endTime,
  2246. periodIndex
  2247. ]
  2248. .filter(
  2249. (value) => value !== '' && value !== null && value !== undefined
  2250. )
  2251. .join('-');
  2252. return `${parentId}-${periodTaskId || periodIndex}`;
  2253. },
  2254. async open(row) {
  2255. const ids = Array.isArray(row?.ids) ? row.ids : [];
  2256. const readonly = !!row?.readonly;
  2257. const mode = row?.mode === 'order' ? 'order' : 'plan';
  2258. const selectedWorkOrders = Array.isArray(row?.selectedWorkOrders)
  2259. ? row.selectedWorkOrders
  2260. : [];
  2261. const orderListLoader =
  2262. typeof row?.orderListLoader === 'function'
  2263. ? row.orderListLoader
  2264. : null;
  2265. const loading = ids.length
  2266. ? this.$loading({
  2267. lock: true,
  2268. text: mode === 'order' ? '加载订单中...' : '加载计划中...'
  2269. })
  2270. : null;
  2271. let selectedPlans = Array.isArray(row)
  2272. ? row
  2273. : Array.isArray(row?.selectedPlans)
  2274. ? row.selectedPlans
  2275. : [];
  2276. let allPlans = Array.isArray(row?.allPlans)
  2277. ? row.allPlans
  2278. : selectedPlans;
  2279. try {
  2280. if (ids.length) {
  2281. const planList = await this.loadPlansByIds(ids);
  2282. selectedPlans = planList;
  2283. allPlans = planList;
  2284. }
  2285. } finally {
  2286. loading?.close();
  2287. }
  2288. this.dialogRenderKey += 1;
  2289. this.planTableRenderKey += 1;
  2290. this.schedulingMode = mode;
  2291. this.planTableStatusTab = this.getDefaultPlanTableStatusTab(mode);
  2292. this.orderListLoader = orderListLoader;
  2293. // 弹窗复用同一个组件,但入口数据不同:
  2294. // - plan:生产计划行,使用工厂排程列 createSchedulingColumns。
  2295. // - order:工单行,使用班组排程列 createWorkOrderSchedulingColumns。
  2296. this.columns =
  2297. mode === 'order'
  2298. ? createWorkOrderSchedulingColumns()
  2299. : createSchedulingColumns();
  2300. this.selectedWorkOrders =
  2301. this.buildWorkOrderTableRows(selectedWorkOrders);
  2302. if (mode === 'order' && this.selectedWorkOrders.length) {
  2303. // 班组排程表格展示工单,但工序布点和甘特仍依赖生产计划 id;
  2304. // 因此把工单里的 productionPlan* 字段映射成 currentPlan 可识别的形态。
  2305. selectedPlans = this.selectedWorkOrders
  2306. .filter((item) => item.productionPlanId)
  2307. .map((item) => ({
  2308. ...item,
  2309. id: item.productionPlanId,
  2310. code: item.productionPlanCode,
  2311. startTime: item.planStartTime,
  2312. endTime: item.planCompleteTime,
  2313. productNum: item.formingNum,
  2314. unit: item.measuringUnit
  2315. }));
  2316. allPlans = selectedPlans;
  2317. }
  2318. this.entryReadonly = readonly;
  2319. this.orderDetailReadonly = false;
  2320. this.orderDetailActionMode = '';
  2321. this.allPlanDataList = deepClone(allPlans || []);
  2322. this.planDataList =
  2323. mode === 'order'
  2324. ? this.selectedWorkOrders
  2325. : this.buildPlanTableRows(selectedPlans, this.allPlanDataList);
  2326. this.currentPlan = null;
  2327. this.planRoutingPayload = null;
  2328. this.taskList = [];
  2329. // 每次打开弹窗都清理按工序缓存,避免上一次班组排程的工位
  2330. // 泄露到新的工单/计划中。
  2331. this.workstationOptionsMap = {};
  2332. this.workstationOptionsLoadingMap = {};
  2333. this.selection = [];
  2334. this.planPickerVisible = false;
  2335. this.planPickerSelection = [];
  2336. this.dotLineLoading = false;
  2337. this.dotLineFullscreen = false;
  2338. this.calendarSourceData = [];
  2339. this.tableData = [];
  2340. this.activeTab = mode === 'order' ? 'team' : 'factory';
  2341. const now = new Date();
  2342. this.dateRange = [
  2343. `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
  2344. 2,
  2345. '0'
  2346. )}-01`,
  2347. `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
  2348. 2,
  2349. '0'
  2350. )}-${String(
  2351. new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
  2352. ).padStart(2, '0')}`
  2353. ];
  2354. if (mode === 'order') {
  2355. // 班组排程只预加载人员选项;工位必须等工序列表出来后,
  2356. // 按每道工序 taskId 调任务派单同款接口补齐。
  2357. await this.loadWorkOrderExecutionOptions();
  2358. } else {
  2359. // 工厂排程仍使用班组主数据作为自制执行对象,不走人员/工位混合逻辑。
  2360. await this.loadTeamOptions();
  2361. }
  2362. if (mode === 'order') {
  2363. await this.reloadPlanTableByStatus();
  2364. } else {
  2365. await this.refreshSchedulingView();
  2366. await this.reloadPlanSchedulingPlansByStatus();
  2367. }
  2368. this.visible = true;
  2369. },
  2370. // Legacy operations kept for compatibility
  2371. swap(index1, index2) {
  2372. let temp1 = deepClone(this.form.scheduledPlans[index1]);
  2373. let temp2 = deepClone(this.form.scheduledPlans[index2]);
  2374. this.$set(this.form.scheduledPlans, index1, temp2);
  2375. this.$set(this.form.scheduledPlans, index2, temp1);
  2376. this.indexSort();
  2377. },
  2378. indexSort() {
  2379. this.form.scheduledPlans.forEach((item, index) => {
  2380. this.$set(this.form.scheduledPlans[index], 'serialNumber', index + 1);
  2381. });
  2382. },
  2383. remove() {
  2384. let codeS = this.selection.map((item) => item.code);
  2385. this.form.scheduledPlans = this.form.scheduledPlans.filter(
  2386. (item) => !codeS.includes(item.code)
  2387. );
  2388. this.indexSort();
  2389. },
  2390. moveUp() {
  2391. let index = this.selection[0].serialNumber - 1;
  2392. if (index > 0) {
  2393. this.swap(index, index - 1);
  2394. }
  2395. },
  2396. moveDown() {
  2397. let index = this.selection[0].serialNumber - 1;
  2398. if (index < this.form.scheduledPlans.length - 1) {
  2399. this.swap(index, index + 1);
  2400. }
  2401. },
  2402. exportList() {
  2403. const plans = this.form.scheduledPlans || [];
  2404. if (!plans.length) {
  2405. this.$message.warning('暂无可导出数据');
  2406. return;
  2407. }
  2408. const headers = [
  2409. '序号',
  2410. '计划状态',
  2411. '计划编号',
  2412. '生产订单号',
  2413. '产线名称',
  2414. '计划开始时间',
  2415. '计划结束时间',
  2416. '交期',
  2417. '计划数量',
  2418. '单位',
  2419. '优先级'
  2420. ];
  2421. const escapeCsv = (value) => {
  2422. const text =
  2423. value === null || value === undefined ? '' : String(value);
  2424. return `"${text.replace(/"/g, '""')}"`;
  2425. };
  2426. const rows = plans.map((item, index) =>
  2427. [
  2428. item.serialNumber || index + 1,
  2429. item.mesStatusName,
  2430. item.code,
  2431. item.productionOrderNumber,
  2432. item.productionLineName,
  2433. item.startTime,
  2434. item.endTime,
  2435. item.deliveryTime,
  2436. item.productNum,
  2437. item.unit,
  2438. item.priority
  2439. ]
  2440. .map((cell) => escapeCsv(cell))
  2441. .join(',')
  2442. );
  2443. const csvContent = [headers.join(','), ...rows].join('\n');
  2444. const blob = new Blob([`\uFEFF${csvContent}`], {
  2445. type: 'text/csv;charset=utf-8;'
  2446. });
  2447. const url = window.URL.createObjectURL(blob);
  2448. const link = document.createElement('a');
  2449. link.href = url;
  2450. link.download = `factory_production_scheduling_${Date.now()}.csv`;
  2451. document.body.appendChild(link);
  2452. link.click();
  2453. document.body.removeChild(link);
  2454. window.URL.revokeObjectURL(url);
  2455. },
  2456. initGanttFlatRows(data) {
  2457. if (!Array.isArray(data) || data.length === 0) {
  2458. return [];
  2459. }
  2460. const rows = [];
  2461. data.forEach((item, index) => {
  2462. const planList = Array.isArray(item.resourceList)
  2463. ? item.resourceList
  2464. : [];
  2465. const planInfo = planList[0] || {};
  2466. const taskLabel = item.taskName || item.name || '工序';
  2467. const planLabel = this.buildGanttPlanLabel(planInfo);
  2468. const resourceLabel =
  2469. planInfo.teamName ||
  2470. planInfo.productionLineName ||
  2471. item.name ||
  2472. item.taskName ||
  2473. item.resourceId ||
  2474. `资源${index + 1}`;
  2475. const teamName = planInfo.teamName || resourceLabel;
  2476. const productionLineName =
  2477. planInfo.productionLineName || resourceLabel;
  2478. const resourceName = this.isOrderScheduling
  2479. ? item.resourceName || item.name || ''
  2480. : '';
  2481. const resourceCode = this.isOrderScheduling
  2482. ? item.resourceCode || item.code || ''
  2483. : '';
  2484. const periods = Array.isArray(item.resourcePeriods)
  2485. ? item.resourcePeriods
  2486. : [];
  2487. const parentId = `gantt-${item.resourceId || 'resource'}-${
  2488. item.taskId || item.sourceTaskId || index
  2489. }`;
  2490. rows.push({
  2491. id: parentId,
  2492. code:
  2493. item.taskId || item.sourceTaskId || planInfo.planCode || parentId,
  2494. type: 2,
  2495. name: taskLabel,
  2496. text: taskLabel,
  2497. executor: planLabel || taskLabel,
  2498. laneLabel: resourceLabel,
  2499. resourceName,
  2500. resourceCode,
  2501. teamName,
  2502. productionOrderNumber: planInfo.productionOrderNumber || '',
  2503. productionLineName,
  2504. workstationName:
  2505. item.workstationName ||
  2506. item.stationName ||
  2507. planInfo.workstationName ||
  2508. planInfo.stationName ||
  2509. resourceLabel,
  2510. equipmentName:
  2511. item.equipmentName ||
  2512. item.deviceName ||
  2513. item.assetName ||
  2514. planInfo.equipmentName ||
  2515. planInfo.deviceName ||
  2516. planInfo.assetName ||
  2517. '',
  2518. deviceId:
  2519. this.normalizeBackendLongId(item.deviceId) ||
  2520. this.normalizeBackendLongId(item.assetId) ||
  2521. this.normalizeBackendLongId(planInfo.deviceId) ||
  2522. this.normalizeBackendLongId(planInfo.assetId) ||
  2523. '',
  2524. deviceCode: item.deviceCode || planInfo.deviceCode || '',
  2525. deviceName: item.deviceName || planInfo.deviceName || '',
  2526. assetName: item.assetName || planInfo.assetName || '',
  2527. assigneeUser: item.assigneeUser || planInfo.assigneeUser || [],
  2528. assigneeUserId:
  2529. item.assigneeUserId || planInfo.assigneeUserId || '',
  2530. assigneeUserName:
  2531. item.assigneeUserName || planInfo.assigneeUserName || '',
  2532. assigneeJobNumber:
  2533. item.assigneeJobNumber || planInfo.assigneeJobNumber || '',
  2534. executionObjectType: item.executionObjectType || '',
  2535. executionObjectName: item.executionObjectName || '',
  2536. render: periods.length ? 'split' : '',
  2537. open: true
  2538. });
  2539. periods.forEach((period, periodIndex) => {
  2540. const matchedPlanInfo =
  2541. planList.find(
  2542. (planItem) =>
  2543. String(planItem.planId || '') === String(period.planId || '')
  2544. ) ||
  2545. planList[periodIndex] ||
  2546. planInfo;
  2547. const childPlanLabel = this.buildGanttPlanLabel(
  2548. matchedPlanInfo,
  2549. period
  2550. );
  2551. const childDisplayOrderCode = this.isOrderScheduling
  2552. ? this.getOrderSchedulingDisplayOrderCode(matchedPlanInfo, period)
  2553. : matchedPlanInfo.planCode;
  2554. rows.push({
  2555. id: this.buildGanttPeriodTaskId(
  2556. parentId,
  2557. matchedPlanInfo,
  2558. period,
  2559. periodIndex
  2560. ),
  2561. parent: parentId,
  2562. code:
  2563. matchedPlanInfo.planCode ||
  2564. item.taskId ||
  2565. item.sourceTaskId ||
  2566. `${parentId}-${periodIndex}`,
  2567. planId: matchedPlanInfo.planId || period.planId || '',
  2568. planCode: matchedPlanInfo.planCode || '',
  2569. productionOrderNumber:
  2570. matchedPlanInfo.productionOrderNumber ||
  2571. period.productionOrderNumber ||
  2572. period.apsWorkOrderCode ||
  2573. period.workOrderCode ||
  2574. '',
  2575. productName: matchedPlanInfo.productName || '',
  2576. productCode: matchedPlanInfo.productCode || '',
  2577. routingName:
  2578. matchedPlanInfo.routingName ||
  2579. matchedPlanInfo.produceRoutingName ||
  2580. '',
  2581. batchNo: matchedPlanInfo.batchNo || '',
  2582. specification: matchedPlanInfo.specification || '',
  2583. modeType: matchedPlanInfo.modeType || '',
  2584. workstationName:
  2585. matchedPlanInfo.workstationName ||
  2586. matchedPlanInfo.stationName ||
  2587. item.workstationName ||
  2588. item.stationName ||
  2589. '',
  2590. equipmentName:
  2591. matchedPlanInfo.equipmentName ||
  2592. matchedPlanInfo.deviceName ||
  2593. matchedPlanInfo.assetName ||
  2594. item.equipmentName ||
  2595. item.deviceName ||
  2596. item.assetName ||
  2597. '',
  2598. deviceId:
  2599. this.normalizeBackendLongId(matchedPlanInfo.deviceId) ||
  2600. this.normalizeBackendLongId(matchedPlanInfo.assetId) ||
  2601. this.normalizeBackendLongId(item.deviceId) ||
  2602. this.normalizeBackendLongId(item.assetId) ||
  2603. '',
  2604. deviceCode: matchedPlanInfo.deviceCode || item.deviceCode || '',
  2605. deviceName: matchedPlanInfo.deviceName || item.deviceName || '',
  2606. assetName: matchedPlanInfo.assetName || item.assetName || '',
  2607. assigneeUser:
  2608. matchedPlanInfo.assigneeUser || item.assigneeUser || [],
  2609. assigneeUserId:
  2610. matchedPlanInfo.assigneeUserId || item.assigneeUserId || '',
  2611. assigneeUserName:
  2612. matchedPlanInfo.assigneeUserName || item.assigneeUserName || '',
  2613. assigneeJobNumber:
  2614. matchedPlanInfo.assigneeJobNumber ||
  2615. item.assigneeJobNumber ||
  2616. '',
  2617. executionObjectType: item.executionObjectType || '',
  2618. executionObjectName: item.executionObjectName || '',
  2619. type: 5,
  2620. name:
  2621. [taskLabel, childPlanLabel].filter(Boolean).join(' / ') ||
  2622. taskLabel,
  2623. text: [
  2624. taskLabel,
  2625. childDisplayOrderCode,
  2626. matchedPlanInfo.productName,
  2627. matchedPlanInfo.batchNo
  2628. ]
  2629. .filter(Boolean)
  2630. .join(' / '),
  2631. executor: childPlanLabel || taskLabel,
  2632. laneLabel: resourceLabel,
  2633. resourceName,
  2634. resourceCode,
  2635. teamName,
  2636. productionLineName,
  2637. start_date: formatDotLineDateTime(period.startTime),
  2638. end_date: formatDotLineDateTime(period.endTime)
  2639. });
  2640. });
  2641. });
  2642. return rows;
  2643. },
  2644. // 添加班组行合并
  2645. // addDuplicateCount(arr) {
  2646. // const elementCount = {}; // 用于存储元素及其出现次数
  2647. // arr.forEach((element, index) => {
  2648. // if (elementCount[element.shiftGroupCode] === undefined) {
  2649. // // 第一次出现,记录索引
  2650. // elementCount[element.shiftGroupCode] = { index, count: 1 };
  2651. // } else {
  2652. // // 不是第一次出现,增加计数
  2653. // elementCount[element.shiftGroupCode].count++;
  2654. // }
  2655. // });
  2656. // arr.forEach((item, index) => {
  2657. // if (elementCount[item.shiftGroupCode]?.index == index) {
  2658. // item.groupRowSpan = elementCount[item.shiftGroupCode].count;
  2659. // }
  2660. // });
  2661. // return arr;
  2662. // },
  2663. async handleApproveCurrentPlan() {
  2664. const row = this.currentPlan;
  2665. if (!row?.id) {
  2666. this.$message.warning('请先勾选一条计划后再审批');
  2667. return;
  2668. }
  2669. if (!row.produceRoutingName && !row.routingName) {
  2670. this.$message.error('请先选择工艺路线!');
  2671. return;
  2672. }
  2673. if (String(row.dotLineStatus) !== '1') {
  2674. this.$message.error('请先完成布点!');
  2675. return;
  2676. }
  2677. if (!this.canApproveCurrentPlan) {
  2678. this.$message.warning('当前计划不满足审批条件');
  2679. return;
  2680. }
  2681. const titleText = this.isReview
  2682. ? '是否发起流程'
  2683. : '发布工单后不可撤回,确定发布吗?';
  2684. const title = this.isReview ? '流程确认' : '发布确认';
  2685. const text = this.isReview ? '流程发布中...' : '工单发布中...';
  2686. try {
  2687. await this.$confirm(titleText, title);
  2688. } catch (e) {
  2689. return;
  2690. }
  2691. const loading = this.$loading({
  2692. lock: true,
  2693. fullscreen: true,
  2694. text
  2695. });
  2696. this.approvalLoading = true;
  2697. try {
  2698. const api = this.isReview ? releaseByApproval : release;
  2699. const data = await api([row.id]);
  2700. if (data || data === 0) {
  2701. this.$message.success('发布成功!');
  2702. } else {
  2703. this.$message.error('发布失败,请重新发布!');
  2704. }
  2705. await this.refreshSchedulingView();
  2706. await this.reloadPlanSchedulingPlansByStatus();
  2707. } catch (e) {
  2708. this.$message.error(e.message || '发布失败,请重新发布!');
  2709. } finally {
  2710. this.approvalLoading = false;
  2711. loading.close();
  2712. }
  2713. },
  2714. async submitDotLineConfig() {
  2715. if (!this.currentPlan?.id) {
  2716. this.$message.warning('请先勾选一条计划后再确定');
  2717. return;
  2718. }
  2719. if (!this.isOrderScheduling && this.isCurrentPlanReadonly) {
  2720. this.$message.warning('当前计划状态下布局数据仅支持查看');
  2721. return;
  2722. }
  2723. if (!this.taskList.length) {
  2724. this.$message.warning('当前没有可提交的工艺配置');
  2725. return;
  2726. }
  2727. if (!this.validateTaskList()) return;
  2728. const payload = this.buildSavePayload(0);
  2729. const loading = this.$loading({ lock: true, text: '保存中...' });
  2730. try {
  2731. await savePlanDotLine(payload);
  2732. await this.refreshSchedulingView();
  2733. if (!this.isOrderScheduling) {
  2734. await this.reloadPlanSchedulingPlansByStatus({
  2735. preserveCurrent: true
  2736. });
  2737. }
  2738. if (this.currentPlan?.id) {
  2739. await this.loadPlanDotLineDetail(this.currentPlan);
  2740. }
  2741. this.dotLineFullscreen = false;
  2742. this.$message.success('保存成功');
  2743. } catch (e) {
  2744. this.$message.error(e.message || '保存失败');
  2745. } finally {
  2746. loading.close();
  2747. }
  2748. },
  2749. async submitDotLineRow(row) {
  2750. if (!this.currentPlan?.id) {
  2751. this.$message.warning('请先勾选一条计划后再确定');
  2752. return;
  2753. }
  2754. if (!this.isOrderScheduling && this.isCurrentPlanReadonly) {
  2755. this.$message.warning('当前计划状态下布局数据仅支持查看');
  2756. return;
  2757. }
  2758. if (!row) {
  2759. this.$message.warning('请选择需要保存的工艺配置');
  2760. return;
  2761. }
  2762. if (!this.validateTaskRow(row, { checkSequence: false })) return;
  2763. const payload = this.buildSavePayload(this.isOrderScheduling ? 0 : 1);
  2764. const loadingText = this.isOrderScheduling ? '保存中...' : '缓存中...';
  2765. const successText = this.isOrderScheduling ? '保存成功' : '缓存成功';
  2766. const errorText = this.isOrderScheduling ? '保存失败' : '缓存失败';
  2767. const loading = this.$loading({ lock: true, text: loadingText });
  2768. try {
  2769. await savePlanDotLine(payload);
  2770. await this.refreshSchedulingView();
  2771. if (!this.isOrderScheduling) {
  2772. await this.reloadPlanSchedulingPlansByStatus({
  2773. preserveCurrent: true
  2774. });
  2775. }
  2776. if (this.currentPlan?.id) {
  2777. await this.loadPlanDotLineDetail(this.currentPlan);
  2778. }
  2779. this.$message.success(successText);
  2780. } catch (e) {
  2781. this.$message.error(e.message || errorText);
  2782. } finally {
  2783. loading.close();
  2784. }
  2785. },
  2786. // Dialog lifecycle
  2787. cancel() {
  2788. if (this.orderDateReloadTimer) {
  2789. clearTimeout(this.orderDateReloadTimer);
  2790. this.orderDateReloadTimer = null;
  2791. }
  2792. this.form = {};
  2793. this.entryReadonly = false;
  2794. this.orderDetailReadonly = false;
  2795. this.orderDetailActionMode = '';
  2796. this.currentPlan = null;
  2797. this.planRoutingPayload = null;
  2798. this.taskList = [];
  2799. this.selection = [];
  2800. this.planPickerSelection = [];
  2801. this.planPickerSelectionAll = [];
  2802. this.planPickerTimeDimensionPlanType = '';
  2803. this.planPickerWhere = createPlanPickerWhere();
  2804. this.schedulingMode = 'plan';
  2805. this.planTableStatusTab = this.getDefaultPlanTableStatusTab('plan');
  2806. this.selectedWorkOrders = [];
  2807. this.orderListLoader = null;
  2808. this.columns = createSchedulingColumns();
  2809. this.dotLineLoading = false;
  2810. this.dotLineFullscreen = false;
  2811. this.visible = false;
  2812. }
  2813. }
  2814. };
  2815. </script>
  2816. <style lang="scss" scoped>
  2817. .pane-box {
  2818. padding: 20px 0;
  2819. }
  2820. .btnList {
  2821. display: flex;
  2822. align-items: center;
  2823. gap: 8px;
  2824. margin: 10px 0 12px;
  2825. button {
  2826. margin: 0;
  2827. }
  2828. }
  2829. .scheduling-content {
  2830. position: relative;
  2831. margin-top: 6px;
  2832. width: 100%;
  2833. min-height: 0;
  2834. padding: 0;
  2835. box-sizing: border-box;
  2836. }
  2837. .form-wrapper {
  2838. position: relative;
  2839. display: flex;
  2840. flex-direction: column;
  2841. width: 100%;
  2842. height: 100%;
  2843. min-width: 0;
  2844. overflow: hidden;
  2845. border: 1px solid #d8e3ef;
  2846. border-radius: 10px;
  2847. background: linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
  2848. box-shadow: 0 10px 26px rgba(26, 39, 55, 0.08);
  2849. }
  2850. .form-wrapper::before,
  2851. .plan-dot-line-detail::before {
  2852. position: absolute;
  2853. top: 0;
  2854. right: 0;
  2855. left: 0;
  2856. height: 2px;
  2857. background: linear-gradient(90deg, #2489e8 0%, #14b8a6 60%, #7aa7ff 100%);
  2858. content: '';
  2859. pointer-events: none;
  2860. }
  2861. .plan-table-status-tabs {
  2862. flex: 0 0 42px;
  2863. height: 42px;
  2864. padding: 3px 12px 0;
  2865. box-sizing: border-box;
  2866. border-bottom: 1px solid #e5edf6;
  2867. background: linear-gradient(180deg, #f9fcff 0%, #f3f7fb 100%);
  2868. }
  2869. .plan-table-status-tabs ::v-deep {
  2870. .el-tabs__header {
  2871. margin: 0;
  2872. }
  2873. .el-tabs__nav-wrap::after {
  2874. display: none;
  2875. }
  2876. .el-tabs__item {
  2877. display: inline-flex;
  2878. align-items: center;
  2879. justify-content: center;
  2880. height: 36px;
  2881. line-height: 1;
  2882. margin-right: 8px;
  2883. padding: 0 16px;
  2884. border-radius: 7px 7px 0 0;
  2885. color: #667085;
  2886. font-size: 14px;
  2887. font-weight: 600;
  2888. transition: all 0.18s ease;
  2889. }
  2890. .el-tabs__item:not(.is-active):hover {
  2891. color: #1683d8;
  2892. background: rgba(31, 140, 235, 0.06);
  2893. }
  2894. .el-tabs__item.is-active {
  2895. color: #0f75bd;
  2896. background: #fff;
  2897. box-shadow: 0 -1px 0 #dce8f4, 1px 0 0 #e5edf6, -1px 0 0 #e5edf6;
  2898. }
  2899. .el-tabs__active-bar {
  2900. height: 2px;
  2901. border-radius: 2px 2px 0 0;
  2902. background: linear-gradient(90deg, #1f8ceb 0%, #16b8a6 100%);
  2903. }
  2904. }
  2905. .form-wrapper ::v-deep .ele-pro-table {
  2906. flex: 1 1 auto;
  2907. height: calc(100% - 42px);
  2908. min-height: 0;
  2909. overflow: hidden;
  2910. background: transparent;
  2911. }
  2912. .form-wrapper.is-order-scheduling ::v-deep .ele-pro-table,
  2913. .form-wrapper.is-plan-scheduling ::v-deep .ele-pro-table {
  2914. display: flex;
  2915. flex-direction: column;
  2916. }
  2917. .form-wrapper.is-order-scheduling ::v-deep .ele-pro-table > .el-table {
  2918. flex: 1 1 auto;
  2919. height: calc(100% - 44px) !important;
  2920. min-height: 0;
  2921. }
  2922. .form-wrapper.is-order-scheduling ::v-deep .ele-pro-table > .el-pagination {
  2923. margin-top: auto !important;
  2924. }
  2925. .form-wrapper ::v-deep .el-table {
  2926. color: #364152;
  2927. border-color: #e5edf6;
  2928. font-size: 14px;
  2929. }
  2930. .form-wrapper ::v-deep .el-table__body-wrapper {
  2931. overflow-y: auto !important;
  2932. overflow-x: auto;
  2933. padding-bottom: 1px;
  2934. box-sizing: border-box;
  2935. }
  2936. .form-wrapper ::v-deep .el-table th.el-table__cell {
  2937. background: linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
  2938. color: #1f2d3d;
  2939. font-weight: 600;
  2940. position: sticky;
  2941. top: 0;
  2942. z-index: 2;
  2943. }
  2944. .form-wrapper ::v-deep .el-table td.el-table__cell,
  2945. .form-wrapper ::v-deep .el-table th.el-table__cell {
  2946. border-bottom-color: #e9eff6;
  2947. }
  2948. .form-wrapper ::v-deep .el-table td.el-table__cell {
  2949. padding-top: 5px;
  2950. padding-bottom: 5px;
  2951. }
  2952. .form-wrapper ::v-deep .el-table__row:hover > td.el-table__cell {
  2953. background: #f5faff;
  2954. }
  2955. .form-wrapper ::v-deep .el-table__row.current-row > td.el-table__cell,
  2956. .form-wrapper
  2957. ::v-deep
  2958. .el-table__row.el-table__row--striped.current-row
  2959. > td.el-table__cell {
  2960. background: #eaf5ff;
  2961. }
  2962. .form-wrapper ::v-deep .el-link {
  2963. display: inline-flex;
  2964. align-items: center;
  2965. justify-content: center;
  2966. min-width: 42px;
  2967. height: 26px;
  2968. padding: 0 10px;
  2969. border: 1px solid #c8e0f4;
  2970. border-radius: 6px;
  2971. background: linear-gradient(180deg, #f6fbff 0%, #eaf5ff 100%);
  2972. color: #0f75bd;
  2973. font-weight: 600;
  2974. line-height: 24px;
  2975. transition: all 0.18s ease;
  2976. }
  2977. .form-wrapper ::v-deep .el-link:hover {
  2978. border-color: #8ec6f4;
  2979. background: linear-gradient(180deg, #eef8ff 0%, #dff0ff 100%);
  2980. color: #0964a3;
  2981. }
  2982. .form-wrapper ::v-deep .el-checkbox__inner {
  2983. border-color: #d8e1eb;
  2984. }
  2985. .form-wrapper ::v-deep .el-table__body-wrapper::-webkit-scrollbar,
  2986. .form-wrapper ::v-deep .el-table__fixed-body-wrapper::-webkit-scrollbar {
  2987. width: 8px;
  2988. height: 8px;
  2989. }
  2990. .form-wrapper ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb,
  2991. .form-wrapper
  2992. ::v-deep
  2993. .el-table__fixed-body-wrapper::-webkit-scrollbar-thumb {
  2994. border: 2px solid #fff;
  2995. border-radius: 999px;
  2996. background: #c9d4e2;
  2997. }
  2998. .form-wrapper ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb:hover,
  2999. .form-wrapper
  3000. ::v-deep
  3001. .el-table__fixed-body-wrapper::-webkit-scrollbar-thumb:hover {
  3002. background: #aeb9c8;
  3003. }
  3004. .form-wrapper.is-plan-scheduling ::v-deep .ele-pro-table {
  3005. display: flex;
  3006. flex-direction: column;
  3007. min-height: 0;
  3008. }
  3009. .form-wrapper.is-plan-scheduling ::v-deep .ele-pro-table > .el-table {
  3010. flex: 1 1 auto;
  3011. height: calc(100% - 44px) !important;
  3012. min-height: 0;
  3013. }
  3014. .form-wrapper.is-plan-scheduling ::v-deep .ele-pro-table > .el-pagination {
  3015. margin-top: auto !important;
  3016. }
  3017. .form-wrapper.is-plan-scheduling ::v-deep .plan-scheduling-pagination {
  3018. display: flex;
  3019. align-items: center;
  3020. justify-content: center;
  3021. flex: 0 0 44px;
  3022. height: 44px;
  3023. min-height: 44px;
  3024. padding: 0 10px;
  3025. box-sizing: border-box;
  3026. border-top: 1px solid #e5edf6;
  3027. background: linear-gradient(180deg, #ffffff 0%, #f1f6fb 100%);
  3028. box-shadow: 0 -3px 10px rgba(31, 45, 61, 0.04);
  3029. }
  3030. .form-wrapper.is-plan-scheduling
  3031. ::v-deep
  3032. .ele-pro-table
  3033. > .el-pagination
  3034. > * {
  3035. margin-top: 0 !important;
  3036. }
  3037. .form-wrapper.is-order-scheduling ::v-deep .order-plan-pagination {
  3038. display: flex;
  3039. align-items: center;
  3040. justify-content: center;
  3041. flex: 0 0 44px;
  3042. height: 44px;
  3043. min-height: 44px;
  3044. margin-top: 0 !important;
  3045. padding: 0 10px;
  3046. box-sizing: border-box;
  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. .form-wrapper.is-order-scheduling ::v-deep .order-plan-pagination > * {
  3052. margin-top: 0 !important;
  3053. }
  3054. .plan-dot-line-side {
  3055. width: 100%;
  3056. height: 100%;
  3057. overflow: hidden;
  3058. padding-left: 10px;
  3059. box-sizing: border-box;
  3060. display: flex;
  3061. flex-direction: column;
  3062. }
  3063. .plan-dot-line-side.is-fullscreen {
  3064. position: fixed;
  3065. top: 24px;
  3066. right: 24px;
  3067. bottom: 24px;
  3068. left: 24px;
  3069. z-index: 3000;
  3070. width: auto !important;
  3071. height: auto !important;
  3072. background: #fff;
  3073. border-radius: 8px;
  3074. box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  3075. padding: 20px;
  3076. }
  3077. .plan-dot-line-detail {
  3078. position: relative;
  3079. display: flex;
  3080. flex-direction: column;
  3081. height: 100%;
  3082. min-width: 0;
  3083. overflow: hidden;
  3084. border: 1px solid #d8e3ef;
  3085. border-radius: 10px;
  3086. background: linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
  3087. box-shadow: 0 10px 26px rgba(26, 39, 55, 0.08);
  3088. }
  3089. .plan-dot-line-scrollable {
  3090. flex: 1;
  3091. overflow: hidden;
  3092. padding-bottom: 14px;
  3093. box-sizing: border-box;
  3094. min-height: 0;
  3095. }
  3096. .plan-dot-line-scrollable.is-order-dispatch-scroll {
  3097. padding-bottom: 0;
  3098. }
  3099. .plan-dot-line-scrollable.is-plan-config-scroll {
  3100. display: flex;
  3101. flex-direction: column;
  3102. padding-bottom: 0;
  3103. }
  3104. .plan-dot-line-scrollable.is-plan-config-scroll
  3105. ::v-deep
  3106. .factory-task-config-panel {
  3107. flex: 1 1 auto;
  3108. min-height: 0;
  3109. display: flex;
  3110. flex-direction: column;
  3111. overflow: hidden;
  3112. }
  3113. .plan-dot-line-scrollable.is-plan-config-scroll
  3114. ::v-deep
  3115. .factory-task-config-panel
  3116. .task-config-table-wrap {
  3117. flex: 1 1 auto;
  3118. height: 100%;
  3119. min-height: 0;
  3120. }
  3121. @media (max-width: 1440px) {
  3122. .scheduling-content {
  3123. margin-top: 8px;
  3124. }
  3125. .plan-dot-line-side {
  3126. padding-left: 8px;
  3127. }
  3128. .plan-dot-line-scrollable {
  3129. padding-bottom: 12px;
  3130. }
  3131. }
  3132. @media (max-width: 1180px) {
  3133. .scheduling-content {
  3134. height: auto !important;
  3135. }
  3136. .plan-dot-line-side {
  3137. padding-left: 0;
  3138. padding-top: 10px;
  3139. min-height: 460px;
  3140. }
  3141. .form-wrapper {
  3142. min-height: 260px;
  3143. }
  3144. .plan-dot-line-scrollable {
  3145. overflow: auto;
  3146. }
  3147. }
  3148. </style>
  3149. <style lang="scss">
  3150. .scheduling-dialog.el-dialog {
  3151. width: calc(100vw - 10px) !important;
  3152. max-width: none;
  3153. height: calc(100vh - 10px);
  3154. max-height: calc(100vh - 10px);
  3155. margin-top: 5px !important;
  3156. margin-bottom: 5px !important;
  3157. border: 1px solid rgba(190, 205, 222, 0.85);
  3158. border-radius: 12px;
  3159. background: #eef4fa;
  3160. display: flex;
  3161. flex-direction: column;
  3162. overflow: hidden;
  3163. box-shadow: 0 22px 64px rgba(15, 23, 42, 0.22);
  3164. .el-dialog__header {
  3165. flex: 0 0 auto;
  3166. padding: 8px 16px;
  3167. border-bottom: 1px solid #dce7f2;
  3168. background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  3169. }
  3170. .el-dialog__title {
  3171. color: #1d2939;
  3172. font-size: 16px;
  3173. font-weight: 700;
  3174. letter-spacing: 0;
  3175. }
  3176. .el-dialog__body {
  3177. flex: 1 1 auto;
  3178. display: flex;
  3179. flex-direction: column;
  3180. min-height: 0;
  3181. padding: 6px 8px 6px;
  3182. background: radial-gradient(
  3183. circle at 12% 0,
  3184. rgba(31, 140, 235, 0.08) 0,
  3185. transparent 28%
  3186. ),
  3187. linear-gradient(90deg, rgba(31, 140, 235, 0.035) 1px, transparent 1px),
  3188. linear-gradient(180deg, rgba(22, 184, 166, 0.025) 1px, transparent 1px),
  3189. #eef4fa;
  3190. background-size: auto, 24px 24px, 24px 24px;
  3191. overflow: hidden;
  3192. }
  3193. .project-gantt {
  3194. flex: 0 0 auto;
  3195. }
  3196. .scheduling-content {
  3197. flex: 1 1 auto;
  3198. height: auto !important;
  3199. min-height: 0;
  3200. }
  3201. .el-dialog__footer {
  3202. flex: 0 0 auto;
  3203. padding: 5px 16px 6px;
  3204. border-top: 1px solid #dce7f2;
  3205. background: linear-gradient(180deg, #f9fbfd 0%, #f3f7fb 100%);
  3206. }
  3207. }
  3208. @media (max-height: 760px) {
  3209. .scheduling-dialog.el-dialog {
  3210. .el-dialog__header {
  3211. padding: 8px 14px;
  3212. }
  3213. .el-dialog__body {
  3214. padding: 6px 8px;
  3215. }
  3216. .el-dialog__footer {
  3217. padding: 4px 14px 5px;
  3218. }
  3219. }
  3220. }
  3221. @media (max-width: 1180px) {
  3222. .scheduling-dialog.el-dialog {
  3223. .el-dialog__body {
  3224. overflow: auto;
  3225. }
  3226. .scheduling-content {
  3227. flex: 0 0 auto;
  3228. min-height: 720px;
  3229. }
  3230. }
  3231. }
  3232. </style>