index.vue 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <!-- <el-scrollbar max-height="75vh"> -->
  6. <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px">
  7. <div class="JKWTree-tree" style="height: 70vh;width:100vh" >
  8. <h3>工单核验单维护</h3>
  9. <el-tree :data="treeData" highlight-current @node-click="handleNodeClick"/>
  10. </div>
  11. </layout-sider>
  12. <!-- </el-scrollbar> -->
  13. <el-container>
  14. <el-main>
  15. <div class="gva-table-box">
  16. <!-- 按钮区域 -->
  17. <el-form>
  18. <el-form-item>
  19. <el-input v-model="searchInfo" placeholder="请输入工单编号" style="width: 180px;"/>
  20. <el-button type="primary" :icon="Search" class="bt" @click="handleSearch"></el-button>
  21. <el-button type="primary" class="bt" icon="plus" @click="handleShowAdd">新增</el-button>
  22. <el-button type="primary" icon="copy-document" class="bt"@click="dialogMrhjtj = true">每日核检统计</el-button>
  23. <el-button type="primary" icon="copy-document" class="bt" @click="showGdzjfptj">工单质检废品统计</el-button>
  24. <el-button type="primary" icon="edit" @click="gdlcdcxconlick" class="bt" title="流程单查询">流程单查询</el-button>
  25. <el-button type="primary" icon="delete" class="bt" @click="handleDelete">删除</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <!-- 数据展示 -->
  29. <el-table ref="table" style="width: 100%;height: 62vh;" :data="tableData" row-key="ID"
  30. @row-click="handleSelectChange"
  31. highlight-current-row="true"
  32. border
  33. :row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }"
  34. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  35. :show-overflow-tooltip="true"
  36. @row-dblclick="doubleClick">
  37. <!-- 循环渲染表格列 -->
  38. <el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop"
  39. :label="column.label" :width="column.width" />
  40. </el-table>
  41. <!-- 分页 -->
  42. <div class="gva-pagination">
  43. <el-pagination v-model:current-page="page" v-model:page-size="limit"
  44. layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 30, 50, 100]"
  45. :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  46. </div>
  47. </div>
  48. <!-- 弹出框 -->
  49. <!-- <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type" destroy-on-close
  50. width="1200px" style="margin-top: 0%;height: 100%;;"> -->
  51. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type" destroy-on-close
  52. width="1200px" style="margin-top: 2%;height: 80%;">
  53. <el-form ref="elFormRef" :model="detailData" inline label-position="right" :rules="rule"
  54. id="detail-form" label-width="70px">
  55. <el-row :gutter="24">
  56. <el-col :span="5">
  57. <el-form-item label="日期">
  58. <el-input type="date" max="9999-12-31" v-model="detailData.qczl_rq" id = '日期' @keydown="ent1($event)" @focus="rqHandleFocus()"
  59. style="width: 150px;" />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="5">
  63. <el-form-item label="工单编号">
  64. <el-input v-model="detailData.qczl_gdbh" style="width: 120px;" @keydown="ent1($event)"
  65. @blur="handleGdbhEnter" placeholder="Enter回车" />
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="5">
  69. <el-form-item label="拼印主工单" label-width="90px">
  70. <el-input v-model="detailData.qczl_Pygd" style="width: 120px;" @keydown="ent1($event)" />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="9">
  74. <el-form-item label="产品名称">
  75. <el-input v-model="detailData.Gd_cpmc" style="width: 300px;" disabled />
  76. </el-form-item>
  77. </el-col>
  78. </el-row>
  79. <el-row :gutter="24">
  80. <el-col :span="5">
  81. <el-form-item label="印件号">
  82. <el-input v-model="detailData.qczl_yjno" style="width: 150px;" disabled/>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="10">
  86. <el-form-item label="印件名称" >
  87. <el-input v-model="detailData.yj_yjmc" style="width: 385px;" disabled/>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="5">
  91. <el-form-item label="废品总数">
  92. <el-input v-model="detailData.qczl_fp" @keydown="ent1($event)" style="width: 100px;" />
  93. </el-form-item>
  94. </el-col>
  95. </el-row>
  96. <el-row :gutter="24">
  97. <el-col :span="5">
  98. <el-form-item label="工序">
  99. <el-input v-model="detailData.qczl_gxmc" style="width: 150px;"
  100. @keydown="ent1($event,index,row,'工序')" />
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="5">
  104. <el-form-item label="工序号">
  105. <el-input v-model="detailData.qczl_gxh" @keydown="ent1($event)" id="工序号" style="width: 120px;" />
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="5">
  109. <el-form-item label="总流程号" label-width="90px">
  110. <el-input v-model="detailData.total_liucheng" @keydown="ent1($event)" style="width: 120px;" />
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. <el-row :gutter="24">
  115. <el-col :span="15">
  116. <el-form-item label="流程单号">
  117. <el-input v-model="detailData.qczl_num" id='qczl_num' @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  118. <el-input v-model="detailData.qczl_NumDesc1" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  119. <el-input v-model="detailData.qczl_NumDesc2" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  120. <el-input v-model="detailData.qczl_NumDesc3" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  121. <el-input v-model="detailData.qczl_NumDesc4" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  122. <el-input v-model="detailData.qczl_NumDesc5" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  123. <el-input v-model="detailData.qczl_NumDesc6" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  124. <el-input v-model="detailData.qczl_NumDesc7" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  125. <el-input v-model="detailData.qczl_NumDesc8" @keydown="ent1($event,index,row,'流程单号')" style="width: 60px; margin-right: 5px;" />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="9">
  129. <el-form-item label="备注">
  130. <el-input v-model="detailData.qczl_NumDesc" @keydown="ent1($event)" style="width: 300px;" />
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. <el-scrollbar height="400px">
  135. <el-table :data="detailData.table" border tooltip-effect="dark"
  136. :row-style="{ height: '20px' }" :cell-style="{ padding: '0px' }"
  137. :header-row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }">
  138. <el-table-column label="废品类别" width="200">
  139. <template #default="{ row, $index }">
  140. <el-input v-model="row.fp_lb" @keydown="ent1($event,$index,row,'废品类别')" />
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="数量" width="100">
  144. <template #default="{ row, $index }">
  145. <el-input v-model="row.fp_sl" @keydown="ent1($event,$index,row,'数量')" @input="countEnter($index, row)"/>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="工序及责任机长" >
  149. <template #default="{ row, $index }">
  150. <el-input v-model="row.fp_gxmc" @keydown="ent1($event,$index,row,'工序及责任机长')"/>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="" width="100">
  154. <template #default="{ row }">
  155. <el-input v-model="row.fp_bz" @keydown="ent1($event,$index,row,'')" readonly/>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="" width="100">
  159. <template #default="{ row }">
  160. <el-input v-model="row.fp_bh" @keydown="ent1($event,$index,row,'')" readonly/>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="" width="100">
  164. <template #default="{ row }">
  165. <el-input v-model="row.fp_name" @keydown="ent1($event,$index,row,'')" readonly/>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </el-scrollbar>
  170. </el-form>
  171. <template #footer>
  172. <div class="dialog-footer">
  173. <el-button @click="closeDialog">取 消</el-button>
  174. <el-button type="primary" @click="enterDialog">确 定
  175. </el-button>
  176. </div>
  177. </template>
  178. </el-dialog>
  179. <!-- 废品类别弹出 -->
  180. <el-dialog v-model="dialogSelectVisible1" id="tableFplb" @keydown="ent($event)" style="margin-top: 5%;" >
  181. <el-form>
  182. <el-form-item label="废品类别" class="mab" prop="keyOrder"></el-form-item>
  183. <div style="border:1px solid #eee; width:100%; height: 600px; overflow-y: auto;">
  184. <el-tree :data="selecTreeData" ref="table_fplb"
  185. @keydown="handleTreeKeydown"
  186. :props="{ children: 'children',label: 'label'}"
  187. node-key="id" @node-click="handleFplbClick">
  188. </el-tree>
  189. </div>
  190. </el-form>
  191. </el-dialog>
  192. <!-- 弹出选项框 数量 -->
  193. <el-dialog v-model="dialogSelectVisible2" title="数量选择" destroy-on-close width="900px" style="margin-top: 3%;" @keydown="selectSL($event)">
  194. <el-table tooltip-effect="dark" :data="selectData" row-key="ID" highlight-current-row border style="width:100%" @row-dblclick="handleSelectClick" ref="table2">
  195. <el-table-column v-for="column in selectColumns" :key="column.prop" :prop="column.prop" :label="column.label" :width="column.width" />
  196. </el-table>
  197. </el-dialog>
  198. <!--流程单查询【弹窗】-->
  199. <el-dialog v-model="gd_lcdlist" title="工单工序生产进程" style="width: 100%;height: 100%;margin: 0px;padding: 0px;">
  200. <div style="width: 100%;height: 100%;">
  201. <el-button type="" @click="gd_lcdCancel">退出</el-button>
  202. </div>
  203. <div style="width: 100%; height: 100%; display: flex; align-items: center;">
  204. <el-form-item label="工单编号" style="margin-right: 20px; padding: 0;">
  205. <el-input v-model="gd_lcdformData['gdbh']" @keyup.enter="gd_lcdProductValue"/>
  206. </el-form-item>
  207. <el-form-item label="印件号" style="margin-right: 20px; padding: 0;">
  208. <el-input v-model="gd_lcdformData['yjno']" @keyup.enter="gd_lcdProductValue"/>
  209. </el-form-item>
  210. <el-form-item label="" style="margin-right: 5px; padding: 0;">
  211. <el-input v-model="gd_lcdformData['code']" disabled/>
  212. </el-form-item>
  213. <el-form-item label="" style="margin-right: 5px; padding: 0;">
  214. <el-input v-model="gd_lcdformData['name']" disabled style="width: 500px"/>
  215. </el-form-item>
  216. </div>
  217. <div style="width: 100%; height: 70vh; display: flex;">
  218. <layout>
  219. <layout-sider :resize-directions="['right']" :width="240" style="margin-right: 10px;height: 70vh;">
  220. <div class="JKWTree-tree">
  221. <el-tree :data="lcd_treeData" @node-click="lcd_handleNodeClick" default-expand-all></el-tree>
  222. </div>
  223. </layout-sider>
  224. <layout-main>
  225. <!-- 这里放右侧的内容 -->
  226. <div style="display: flex; align-items: center;margin-left: 20px;">
  227. <el-tag type="success" style="width: 55px; height: 40px; margin-right: 10px;"><h2>流程号</h2></el-tag>
  228. <h2 style="margin: 0 20px 0 0;">绿格子图标表示“已完成”</h2>
  229. <el-tag type="danger" style="width: 55px; height: 40px; margin-right: 10px;"><h2>流程号</h2></el-tag>
  230. <h2 style="margin: 0;">红格子图标表示“未完成”</h2>
  231. </div>
  232. <br>
  233. <el-space wrap style="margin-left: 20px;">
  234. <!-- 右侧内容 -->
  235. <template v-for="item in processList.total_process">
  236. <el-button class="custom-button" disabled :type="! processList.process.includes(item) ? 'danger' : 'info'" plain style="width: 50px;">{{ item }}</el-button>
  237. <!-- <el-button disabled :type="! processList.process.includes(item) ? 'danger' : 'info'" plain style="width: 50px">{{ item }}</el-button> -->
  238. </template>
  239. </el-space>
  240. </layout-main>
  241. </layout>
  242. </div>
  243. </el-dialog>
  244. <!-- 弹出选项框 工单 -->
  245. <el-dialog v-model="dialogSelectVisible" title="选择" destroy-on-close width="1000px"
  246. @keydown="selectGX($event)">
  247. <el-table tooltip-effect="dark" :data="selectData_gd" row-key="ID" highlight-current-row="true"
  248. border style="width:100%" @row-dblclick="handleSelectClick_gd" ref="table_gd">
  249. <el-table-column prop="Gd_cpmc" label="工单名称" width="430" />
  250. <el-table-column prop="yj_Yjno" label="印件号" width="100" />
  251. <el-table-column prop="yj_yjmc" label="印件名称" width="430" />
  252. </el-table>
  253. </el-dialog>
  254. <!-- 弹出选项框 工序 -->
  255. <el-dialog v-model="dialogSelectVisible_gx" title="工序选择" destroy-on-close width="600px"
  256. @keydown="select_gx($event)">
  257. <el-table tooltip-effect="dark" :data="selectData_gx" row-key="ID" highlight-current-row="true"
  258. border style="width:100%" @row-dblclick="handleSelectClick_gx" ref="table_gx">
  259. <el-table-column prop="gxh" label="工序号" width="100" />
  260. <el-table-column prop="gxmc" label="工序名称" width="460" />
  261. </el-table>
  262. </el-dialog>
  263. <el-dialog v-model="dialogbutton" title="是否确认"
  264. @keydown="handleKeydown ($event)"
  265. destroy-on-close width="300px" style="height: 140px; margin-top: 20%;">
  266. <br>
  267. <span slot="footer" class="dialog-footer" style="display: flex; justify-content: space-between; align-items: center; padding: 0 20px;">
  268. <el-button @click="dialogbutton = false">取消</el-button>
  269. <el-button type="primary" @click="enterDialog">确 定
  270. </el-button>
  271. </span>
  272. </el-dialog>
  273. <!-- 废品日统计 -->
  274. <Meirihejiantongji v-if="dialogMrhjtj" v-model="dialogMrhjtj" />
  275. <!-- 工单质检废品统计 -->
  276. <Gongdanzhijianfeipintongji v-if="dialogGdzjfptj" v-model="dialogGdzjfptj" :val="value1" />
  277. <!-- 测试图表 -->
  278. <Shebeizhuangtai v-if="dialogSbyxgl" v-model="dialogSbyxgl"
  279. title="【01.30 08:30】【JY01#--海德堡对开八色平版胶印机(JY08-01)】【2311116-->钻石(荷花)盒包装纸】【01--胶印】" />
  280. </el-main>
  281. </el-container>
  282. </el-container>
  283. </div>
  284. </template>
  285. <script setup>
  286. // 全量引入格式化工具 请按需保留
  287. import {createCompany,deleteCompany,deleteCompanyByIds,updateCompany,findCompany,getCompanyList} from '@/api/company'
  288. import {ElMessage,ElMessageBox,} from 'element-plus'
  289. import {Search,Refresh,Download} from '@element-plus/icons-vue'
  290. import {ref,reactive,nextTick} from 'vue'
  291. import {getOrderProcessLeft,getOrderProcessRight} from "@/api/yunyin/yunying";
  292. import {getSide,getTable,getOneWorkOrder,getOrderInfo,getGxAndLeader,getYjInfo,getWastInfo,updateData,add,del} from '@/api/mes_api_gty/workOrderVerification'
  293. import Meirihejiantongji from '@/view/performance/09-workOrderVerification/componets/meirihejiantongji.vue'
  294. import Gongdanzhijianfeipintongji from '@/view/performance/09-workOrderVerification/componets/gongdanzhijianfeipintongji.vue'
  295. import Shebeizhuangtai from '@/view/performance/09-workOrderVerification/componets/shebeizhuangtai.vue'
  296. import {Layout,LayoutContent,LayoutHeader,LayoutSider} from '@arco-design/web-vue'
  297. import {useUserStore} from '@/pinia/modules/user'
  298. const userStore = useUserStore()
  299. const sys_id = '[' + userStore.userInfo.userName + '/' + userStore.userInfo.nickName + ']'
  300. defineOptions({name: '06PackingDocuments'})
  301. // 侧边栏数据请求
  302. const treeData = reactive([])
  303. const getSideData = async () => {
  304. const response = await getSide()
  305. if (response.code === 0) {
  306. const transformedData = response.data.map(item => ({
  307. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  308. children: item.sys.map(sysItem => ({
  309. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  310. params: {
  311. date: item.date.replace(/\./g, '-'),
  312. sys_id: sysItem.sys_id,
  313. },
  314. })),
  315. }))
  316. treeData.splice(0, treeData.length, ...transformedData)
  317. }
  318. }
  319. getSideData()
  320. // 验证规则
  321. const rule = reactive({})
  322. const elFormRef = ref()
  323. const elSearchFormRef = ref()
  324. // =========== 表格控制部分 ===========
  325. const tableColumns = [
  326. {label: '工单编号', prop: 'qczl_gdbh', width: '100'},
  327. {label: '印件号', prop: 'qczl_yjno', width: '70'},
  328. {label: '印件名称', prop: 'Gd_cpmc', width: '400'},
  329. {label: '日期', prop: 'qczl_rq', width: '100'},
  330. {label: '流程单号', prop: 'qczl_num', width: '100'},
  331. {label: '流程单备注', prop: 'qczl_NumDesc', width: '120'},
  332. {label: '总废品', prop: 'qczl_fp', width: '100'},
  333. {label: '废品1', prop: 'sl_lb1', width: '250'},
  334. {label: '废品2', prop: 'sl_lb2', width: '250'},
  335. {label: '废品3', prop: 'sl_lb3', width: '250'},
  336. {label: '废品4', prop: 'sl_lb4', width: '250'},
  337. {label: '废品5', prop: 'sl_lb5', width: '250'},
  338. {label: '废品6', prop: 'sl_lb6', width: '250'},
  339. {label: '废品7', prop: 'sl_lb7', width: '250'},
  340. {label: '废品8', prop: 'sl_lb8', width: '250'},
  341. {label: '废品9', prop: 'sl_lb9', width: '250'},
  342. {label: '废品10', prop: 'sl_lb10', width: '250'},
  343. {label: '废品11', prop: 'sl_lb11', width: '250'},
  344. {label: '废品12', prop: 'sl_lb12', width: '250'},
  345. {label: '废品13', prop: 'sl_lb13', width: '250'},
  346. {label: '废品14', prop: 'sl_lb14', width: '250'},
  347. {label: '废品15', prop: 'sl_lb15', width: '250'},
  348. {label: '废品16', prop: 'sl_lb16', width: '250'},
  349. {label: '废品17', prop: 'sl_lb17', width: '250'},
  350. {label: '创建用户', prop: 'sys_id', width: '160'},
  351. ]
  352. const tableData = reactive([])
  353. const total = ref(0)
  354. const page = ref(1)
  355. const limit = ref(10)
  356. const searchInfo = ref('')
  357. const params = {
  358. date: '',
  359. sys_id: '',
  360. order: '',
  361. page: page.value.toString(),
  362. limit: limit.value.toString(),
  363. }
  364. // 工序弹窗选择控制
  365. const dialogSelectVisible_gx = ref(false)
  366. const selectData_gx = reactive([])
  367. const handleSelectClick_gx = (row, column, event) => {
  368. const { gxh, gxmc } = row
  369. detailData.qczl_gxmc = gxh + '-' + gxmc
  370. detailData.qczl_gxh = gxh
  371. dialogSelectVisible_gx.value = false
  372. }
  373. const currentIndex_gx = ref(0);
  374. const current_gx = ref(0);
  375. const select_gx = (event) => {
  376. if (event.keyCode === 40) { // 向下箭头
  377. if (currentIndex_gx.value < selectData_gx.length - 1) {
  378. currentIndex_gx.value++;
  379. setCurrent_gx(selectData_gx[currentIndex_gx.value]);
  380. } else {
  381. currentIndex_gx.value = 0;
  382. setCurrent_gx(selectData_gx[currentIndex_gx.value]); // 到达最后一行时回到第一行
  383. }
  384. } else if (event.keyCode === 38) { // 向上箭头
  385. if (currentIndex_gx.value > 0) {
  386. currentIndex_gx.value--;
  387. setCurrent_gx(selectData_gx[currentIndex_gx.value]);
  388. } else {
  389. currentIndex_gx.value = selectData_gx.length - 1;
  390. setCurrent_gx(selectData_gx[currentIndex_gx.value]); // 到达第一行时回到最后一行
  391. }
  392. } else if (event.keyCode === 13) { // 回车键
  393. dialogSelectVisible_gx.value = false;
  394. setTimeout(() => {
  395. const inputElement = document.getElementById('工序号');
  396. if (inputElement) {
  397. inputElement.focus();
  398. }
  399. }, 100);
  400. // 获取工序
  401. const getgxsubmit = () => {
  402. if(!detailData.qczl_gdbh || !detailData.qczl_yjno){
  403. return
  404. }
  405. GetJtbh()
  406. }
  407. const GetJtbh = async () => {
  408. const { qczl_gdbh, qczl_yjno } = detailData
  409. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  410. if (response.code === 0) {
  411. const data = response.data
  412. if (data) {
  413. detailData.total_liucheng = data.max_num
  414. const tableData = data.gx_data.map(item => ({
  415. gxh: item.Gy0_gxh,
  416. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  417. // addGxmc: item.Add_gxmc
  418. }))
  419. selectData_gx.splice(0, selectData_gx.length, ...tableData)
  420. setCurrent_gx(selectData_gx[0])
  421. dialogSelectVisible_gx.value = true
  422. }
  423. }
  424. }
  425. }
  426. }
  427. const table_gx = ref()
  428. const setCurrent_gx = (row) => {
  429. setTimeout(() => {
  430. table_gx.value?.setCurrentRow(row)
  431. const { gxh, gxmc } = row
  432. detailData.qczl_gxmc = gxh + '-' + gxmc
  433. detailData.qczl_gxh = gxh
  434. })
  435. }
  436. // 批量删除控制标记
  437. const deleteVisible = ref(false)
  438. const multipleSelection = ref([])
  439. const getTableData = async () => {
  440. const response = await getTable(params)
  441. if (response.code === 0) {
  442. total.value = response.data.total
  443. // Object.assign(tableData, response.data.rows)
  444. tableData.splice(0, tableData.length, ...response.data.rows)
  445. }
  446. }
  447. // 左侧树结构点击
  448. const handleNodeClick = (node, check) => {
  449. if (node.params) {
  450. params.date = node.params.date
  451. params.sys_id = node.params.sys_id
  452. page.value = 1
  453. handleCurrentChange()
  454. }
  455. }
  456. // =========== 流程单查询 ===========
  457. const gd_lcdlist = ref(false);
  458. const gd_lcdformData = reactive({
  459. gdbh: '',
  460. code: '',
  461. name: '',
  462. });
  463. // 流程单查询按钮
  464. const processList = ref([]);
  465. const gdlcdcxconlick = async () => {
  466. // console.log(lcdyjno.value)
  467. if(currentRow.gdbh === '' || currentRow.gdbh === null || currentRow.gdbh === undefined){
  468. ElMessage({type: 'warning',message: '请选择具体的工单,在进行操作'})
  469. return false;
  470. }else{
  471. gd_lcdformData['gdbh'] = currentRow.gdbh;
  472. gd_lcdformData['yjno'] = lcdyjno.value
  473. _getOrderProcessLeft_list();
  474. gd_lcdlist.value = true;
  475. processList.value = []
  476. }
  477. }
  478. //流程单查询回车
  479. const gd_lcdProductValue = async () => {
  480. if(gd_lcdformData['gdbh'] == '' || gd_lcdformData['gdbh'] === null){
  481. ElMessage({type: 'warning',message: '工单编号为空'})
  482. return false;
  483. }
  484. _getOrderProcessLeft_list();
  485. }
  486. const lcd_treeData = ref([]);
  487. const _getOrderProcessLeft_list = async () => {
  488. const order = gd_lcdformData['gdbh'];
  489. const yjno = gd_lcdformData['yjno']
  490. try {
  491. //5.1流程单查询-工单工序生产进程菜单栏
  492. const getOrderProcessLeft_list = await getOrderProcessLeft({ order:order,yjno:yjno});
  493. console.log(getOrderProcessLeft_list)
  494. if(getOrderProcessLeft_list.data.Gd_info === null || getOrderProcessLeft_list.data.Gd_info === ''){
  495. ElMessage({type: 'warning',message: '未查询到具体工单信息'})
  496. lcd_treeData.value = [];
  497. return false;
  498. }
  499. gd_lcdformData['code'] = getOrderProcessLeft_list.data.Gd_info['code'];
  500. gd_lcdformData['name'] = getOrderProcessLeft_list.data.Gd_info['name'];
  501. lcd_treeData.value = [{
  502. label: order + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
  503. // label: getOrderProcessLeft_list.data.Gd_info['code'] + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
  504. value: undefined,
  505. children: []
  506. }]
  507. const newData = [];
  508. for (let key in getOrderProcessLeft_list.data.Gy_info) {
  509. let temp = getOrderProcessLeft_list.data.Gy_info[key];
  510. let concatenatedValue = `${temp.Gy0_yjno}-${temp.Gy0_gxh} ---> ${temp.Gy0_gxmc}`;
  511. newData.push({ label: concatenatedValue,value: temp.Gy0_gxh });
  512. }
  513. lcd_treeData.value[0].children = newData;
  514. //5.2流程单查询-获取工单工序生产进程右侧【接口】【进入页面默认显示第一个数据】
  515. const getOrderProcessRight_list = await getOrderProcessRight({order: order, gxNo:newData[0].value,yjno:yjno});
  516. processList.value = getOrderProcessRight_list.data
  517. } catch (error) {
  518. console.error(error);
  519. }
  520. };
  521. //点击左侧获取工序显示右侧数据
  522. const lcd_handleNodeClick = async (node) => {
  523. if (node.value === undefined || node.value === null){
  524. return false;
  525. }
  526. const order = gd_lcdformData['gdbh'];
  527. const yjno = gd_lcdformData['yjno'];
  528. //5.2流程单查询-获取工单工序生产进程右侧【接口】
  529. const getOrderProcessRight_list = await getOrderProcessRight({order:order, gxNo:node.value,yjno:yjno});
  530. processList.value = getOrderProcessRight_list.data
  531. };
  532. // 流程单查询退出
  533. const gd_lcdCancel = async () => {
  534. gd_lcdlist.value = false;
  535. }
  536. // 搜索
  537. function handleSearch() {
  538. params.sys_id = ''
  539. params.date = ''
  540. params.order = searchInfo.value
  541. page.value = 1
  542. handleCurrentChange()
  543. }
  544. // 分页
  545. const handleSizeChange = () => {
  546. params.limit = limit.value.toString()
  547. getTableData()
  548. }
  549. // 页面跳转
  550. const handleCurrentChange = () => {
  551. params.page = page.value.toString()
  552. getTableData()
  553. }
  554. const detailData = reactive({})
  555. // ============== 详情页面 ==============
  556. const selectColumns = [{
  557. label: '',
  558. prop: 'sczl_gxmc',
  559. width: '500'
  560. },
  561. {
  562. label: '',
  563. prop: 'sczl_bzdh',
  564. width: '100'
  565. },
  566. {
  567. label: '',
  568. prop: 'sczl_bh1',
  569. width: '100'
  570. },
  571. {
  572. label: '',
  573. prop: 'name',
  574. width: '150'
  575. },
  576. ]
  577. // 行为控制标记(弹窗内部需要增还是改)
  578. const type = ref('')
  579. // 弹窗控制标记
  580. const dialogFormVisible = ref(false)
  581. const dialogSelectVisible2 = ref(false)
  582. const getDetailData = async (id) => {
  583. try {
  584. const res = await getOneWorkOrder({ UniqId: id })
  585. if (res.code === 0) {
  586. const obj = res.data
  587. // 裁剪返回数据的前后空格
  588. for (const key in obj) {
  589. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  590. obj[key] = obj[key].trim()
  591. }
  592. }
  593. // 修改日期格式
  594. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  595. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  596. }
  597. Object.assign(detailData, obj)
  598. const table = []
  599. // 循环13行数据
  600. for (let i = 1; i <= 13; i++) {
  601. table.push({
  602. fp_lb: detailData[`fp_lb${i}`] || '',
  603. fp_sl: detailData[`fp_sl${i}`] || '',
  604. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  605. fp_bz: detailData[`fp_bz${i}`] || '',
  606. fp_bh: detailData[`fp_bh${i}`] || '',
  607. fp_name: detailData[`fp_name${i}`] || '',
  608. })
  609. // 从原对象中删除这些属性
  610. delete detailData[`fp_lb${i}`]
  611. delete detailData[`fp_sl${i}`]
  612. delete detailData[`fp_gxmc${i}`]
  613. delete detailData[`fp_bz${i}`]
  614. delete detailData[`fp_bh${i}`]
  615. delete detailData[`fp_name${i}`]
  616. }
  617. detailData.table = table
  618. getOrderInfo({ order: detailData.qczl_gdbh }).then(resposne => {
  619. if (resposne.code === 0) {
  620. //循环resposne.data当子项yj_Yjno的值等于obj中的qczl_yjno的值时设置detailData.Gd_cpmc的值为res.data[i].Gd_cpmc
  621. for (let i = 0; i < resposne.data.length; i++) {
  622. if (resposne.data[i].yj_Yjno == detailData.qczl_yjno) {
  623. detailData.yj_yjmc = resposne.data[i].yj_yjmc
  624. detailData.Gd_cpmc = resposne.data[i].Gd_cpmc
  625. }
  626. }
  627. showDialog()
  628. }
  629. })
  630. }
  631. } catch (e) {
  632. console.log(e)
  633. }
  634. }
  635. //日期获得焦点事件
  636. const rqHandleFocus = () => {
  637. if (detailData.qczl_rq == undefined || detailData.qczl_rq == '') {
  638. detailData.qczl_rq = new Date().toISOString().split('T')[0]
  639. }
  640. }
  641. // 工单编号回车
  642. const handleGdbhEnter = async () => {
  643. if (detailData.qczl_gdbh != undefined) {
  644. const res = await getOrderInfo({
  645. order: detailData.qczl_gdbh
  646. })
  647. if (res.code === 0) {
  648. if (res.data.length == 0) {
  649. ElMessage({
  650. type: 'error',
  651. message: '查无此编号的工单,请仔细检查后重新输入'
  652. })
  653. //设置输入框的值为空
  654. detailData.Gd_cpmc = ''
  655. detailData.qczl_yjno = ''
  656. detailData.yj_yjmc = ''
  657. } else if (res.data.length == 1) {
  658. detailData.Gd_cpmc = res.data[0]['Gd_cpmc']
  659. detailData.qczl_yjno = res.data[0]['yj_Yjno']
  660. detailData.yj_yjmc = res.data[0]['yj_yjmc']
  661. } else if (res.data.length > 1) {
  662. selectData_gd.splice(0, selectData_gd.length, ...res.data)
  663. setGXCurrent(selectData_gd[0])
  664. dialogSelectVisible.value = true
  665. }
  666. }
  667. } else {
  668. detailData.Gd_cpmc = ''
  669. detailData.qczl_yjno = ''
  670. detailData.yj_yjmc = ''
  671. }
  672. }
  673. const dialogSelectVisible = ref(false)
  674. const selectData_gd = reactive([])
  675. // 处理选择框
  676. const handleSelectClick_gd = (row, column, event) => {
  677. detailData.Gd_cpmc = row.Gd_cpmc
  678. detailData.qczl_yjno = row.yj_Yjno
  679. detailData.yj_yjmc = row.yj_yjmc
  680. dialogSelectVisible.value = false
  681. }
  682. const currentIndex = ref(0);
  683. const GXCurrent = ref(0);
  684. const selectGX = (event) => {
  685. if (event.keyCode === 40) { // 向下箭头
  686. if (currentIndex.value < selectData_gd.length - 1) {
  687. currentIndex.value++;
  688. setGXCurrent(selectData_gd[currentIndex.value]);
  689. } else {
  690. currentIndex.value = 0;
  691. setGXCurrent(selectData_gd[currentIndex.value]); // 到达最后一行时回到第一行
  692. }
  693. } else if (event.keyCode === 38) { // 向上箭头
  694. if (currentIndex.value > 0) {
  695. currentIndex.value--;
  696. setGXCurrent(selectData_gd[currentIndex.value]);
  697. } else {
  698. currentIndex.value = selectData_gd.length - 1;
  699. setGXCurrent(selectData_gd[currentIndex.value]); // 到达第一行时回到最后一行
  700. }
  701. } else if (event.keyCode === 13) { // 回车键
  702. dialogSelectVisible.value = false;
  703. }
  704. }
  705. const table_gd = ref()
  706. const setGXCurrent = (row) => {
  707. setTimeout(() => {
  708. table_gd.value?.setCurrentRow(row)
  709. detailData.Gd_cpmc = row.Gd_cpmc
  710. detailData.qczl_yjno = row.yj_Yjno
  711. detailData.yj_yjmc = row.yj_yjmc
  712. })
  713. }
  714. // 解译HTML实体编码的函数
  715. function decodeEntities(encodedString) {
  716. const textArea = document.createElement('textarea')
  717. textArea.innerHTML = encodedString
  718. return textArea.value
  719. }
  720. // 双击表格操作
  721. function doubleClick(row, column, event) {
  722. type.value = '修改工单核验单维护'
  723. getDetailData(row.UniqId)
  724. }
  725. // 处理选择框回车操作
  726. const handleSelectClick = (row, column, event) => {
  727. const {
  728. sczl_gxmc,
  729. sczl_bzdh,
  730. sczl_bh1,
  731. name
  732. } = row
  733. const index = selectIndex
  734. console.log("index",index);
  735. detailData.table[index].fp_gxmc = sczl_gxmc
  736. detailData.table[index].fp_bz = sczl_bzdh
  737. detailData.table[index].fp_bh = sczl_bh1
  738. detailData.table[index].fp_name = name
  739. dialogSelectVisible2.value = false
  740. }
  741. const table2 = ref()
  742. const setCurrent = (row, rowIndex) => {
  743. setTimeout(() => {
  744. table2.value?.setCurrentRow(row);
  745. detailData.table[rowIndex].fp_gxmc = row.sczl_gxmc;
  746. detailData.table[rowIndex].fp_bz = row.sczl_bzdh;
  747. detailData.table[rowIndex].fp_bh = row.sczl_bh1;
  748. detailData.table[rowIndex].fp_name = row.name;
  749. });
  750. };
  751. const countEnter = async (index, row) => {
  752. // 计算总数
  753. let total = 0;
  754. detailData.table.forEach((item) => {
  755. if (item.fp_sl != 0 && item.fp_sl != '') {
  756. total += parseInt(item.fp_sl);
  757. }
  758. });
  759. detailData.qczl_fp = total;
  760. }
  761. // 数量回车事件
  762. let selectData = []; // 初始化为数组
  763. // const handleFpslEnter = async (event, index, row, title) => {
  764. // // 保存当前行索引
  765. // selectIndex.value = index;
  766. // // 如果数量为 0,则清空对应字段并直接返回
  767. // if (row.fp_sl === 0 || row.fp_sl === '0' || row.fp_sl === '') {
  768. // detailData.table[index].fp_gxmc = '';
  769. // detailData.table[index].fp_bz = '';
  770. // detailData.table[index].fp_bh = '';
  771. // detailData.table[index].fp_name = '';
  772. // return;
  773. // }
  774. // // 调用接口获取数据
  775. // const params = {
  776. // type: row.fp_lb,
  777. // order: detailData.qczl_gdbh,
  778. // yjno: detailData.qczl_yjno,
  779. // };
  780. // let res;
  781. // try {
  782. // res = await getGxAndLeader(params);
  783. // console.log("接口返回结果", res);
  784. // if (res.code !== 0) {
  785. // return;
  786. // }
  787. // } catch (e) {
  788. // console.log(e);
  789. // return;
  790. // }
  791. // // 解析返回的数据
  792. // const decodedData = res.data.map(item => ({
  793. // sczl_gxmc: decodeEntities(item.sczl_gxmc),
  794. // sczl_bzdh: item.sczl_bzdh,
  795. // sczl_jtbbh: item.sczl_jtbh,
  796. // sczl_bh1: item.sczl_bh1,
  797. // name: item.name.trim(),
  798. // }));
  799. // // 如果数据为空,直接返回
  800. // if (decodedData.length === 0) {
  801. // console.log("接口返回数据为空");
  802. // return;
  803. // }
  804. // // 初始化选中数据
  805. // selectData = decodedData;
  806. // SLIndex.value = 0; // 初始化索引为第一个
  807. // setCurrent(selectData[0]); // 设置当前选中为第一个
  808. // dialogSelectVisible2.value = true; // 显示弹窗
  809. // };
  810. // 选择逻辑
  811. const SLIndex = ref(0); // 初始化索引为 0
  812. const selectSL = (event) => {
  813. console.log("键盘事件触发", event.keyCode);
  814. if (event.keyCode === 40) { // 向下箭头
  815. if (SLIndex.value < selectData.length - 1) {
  816. SLIndex.value++;
  817. setCurrent(selectData[SLIndex.value]);
  818. } else {
  819. SLIndex.value = 0;
  820. setCurrent(selectData[SLIndex.value]);
  821. }
  822. } else if (event.keyCode === 38) { // 向上箭头
  823. if (SLIndex.value > 0) {
  824. SLIndex.value--;
  825. setCurrent(selectData[SLIndex.value]);
  826. } else {
  827. SLIndex.value = selectData.length - 1;
  828. setCurrent(selectData[SLIndex.value]);
  829. }
  830. } else if (event.keyCode === 13) { // 回车键
  831. console.log("回车键触发");
  832. // 如果未通过上下箭头选择,则默认选中第一个
  833. if (SLIndex.value === null || SLIndex.value === undefined || selectData.length === 0) {
  834. SLIndex.value = 0; // 默认选中第一个
  835. }
  836. // 获取当前选中的数据
  837. const selectedRow = selectData[SLIndex.value];
  838. if (!selectedRow) {
  839. console.log("选中数据为空");
  840. return;
  841. }
  842. console.log("关闭弹窗,选中数据为:", selectedRow);
  843. console.log("selectIndex.value:", selectIndex.value);
  844. // 确保 selectIndex.value 是有效的当前行索引
  845. if (selectIndex.value !== null) {
  846. detailData.table[selectIndex.value].fp_gxmc = selectedRow.sczl_gxmc;
  847. detailData.table[selectIndex.value].fp_bz = selectedRow.sczl_bzdh;
  848. detailData.table[selectIndex.value].fp_bh = selectedRow.sczl_bh1;
  849. detailData.table[selectIndex.value].fp_name = selectedRow.name;
  850. }
  851. // 关闭弹窗
  852. dialogSelectVisible2.value = false;
  853. }
  854. };
  855. // 弹窗确定
  856. const enterDialog = async () => {
  857. console.log(type.value)
  858. if (type.value === '修改工单核验单维护') {
  859. updateDetailData()
  860. } else if (type.value === '新增工单核验单维护') {
  861. addDetailData()
  862. }
  863. }
  864. const addDetailData = async () => {
  865. const formatDate = (date) => {
  866. const year = date.getFullYear();
  867. const month = String(date.getMonth() + 1).padStart(2, '0');
  868. const day = String(date.getDate()).padStart(2, '0');
  869. return `${year}-${month}-${day}`;
  870. };
  871. const restoredData = {
  872. UniqId: detailData.UniqId,
  873. qczl_gdbh: detailData.qczl_gdbh,
  874. qczl_yjno: detailData.qczl_yjno,
  875. qczl_gxh: detailData.qczl_gxh,
  876. qczl_gxmc: detailData.qczl_gxmc,
  877. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  878. qczl_fp: detailData.qczl_fp,
  879. qczl_num: detailData.qczl_num,
  880. qczl_NumDesc: detailData.qczl_NumDesc,
  881. qczl_NumDesc1: detailData.qczl_NumDesc1,
  882. qczl_NumDesc2: detailData.qczl_NumDesc2,
  883. qczl_NumDesc3: detailData.qczl_NumDesc3,
  884. qczl_NumDesc4: detailData.qczl_NumDesc4,
  885. qczl_NumDesc5: detailData.qczl_NumDesc5,
  886. qczl_NumDesc6: detailData.qczl_NumDesc6,
  887. qczl_NumDesc7: detailData.qczl_NumDesc7,
  888. qczl_NumDesc8: detailData.qczl_NumDesc8,
  889. sys_id: sys_id
  890. };
  891. detailData.table.forEach((item, index) => {
  892. const num = index + 1;
  893. restoredData[`fp_lb${num}`] = item.fp_lb;
  894. restoredData[`fp_sl${num}`] = item.fp_sl;
  895. restoredData[`fp_bh${num}`] = item.fp_bh;
  896. restoredData[`fp_bz${num}`] = item.fp_bz;
  897. restoredData[`fp_gxmc${num}`] = item.fp_gxmc;
  898. });
  899. console.log(restoredData);
  900. setTimeout(() => {
  901. const inputElement = document.getElementById('qczl_num');
  902. if (inputElement) {
  903. inputElement.focus();
  904. }
  905. }, 100);
  906. dialogbutton.value = false;
  907. // return;
  908. const res = await add(restoredData)
  909. console.log(res)
  910. if (res.code === 0) {
  911. ElMessage({type: 'success',message: '新增成功',})
  912. //刷新
  913. if (params.date != '') {
  914. getTableData()
  915. }
  916. getSideData()
  917. detailData.table.forEach((item, index) => {
  918. item.fp_sl = 0;
  919. });
  920. // dialogFormVisible.value = false
  921. }
  922. detailData.qczl_fp = 0
  923. };
  924. // 修改
  925. const updateDetailData = async () => {
  926. // console.log("确认")
  927. const formatDate = (date) => {
  928. const year = date.getFullYear();
  929. const month = String(date.getMonth() + 1).padStart(2, '0');
  930. const day = String(date.getDate()).padStart(2, '0');
  931. return `${year}-${month}-${day}`;
  932. };
  933. const restoredData = {
  934. UniqId: detailData.UniqId,
  935. qczl_gdbh: detailData.qczl_gdbh,
  936. qczl_yjno: detailData.qczl_yjno,
  937. qczl_gxh: detailData.qczl_gxh,
  938. qczl_gxmc: detailData.qczl_gxmc,
  939. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  940. qczl_fp: detailData.qczl_fp,
  941. qczl_num: detailData.qczl_num,
  942. qczl_NumDesc: detailData.qczl_NumDesc,
  943. qczl_NumDesc1: detailData.qczl_NumDesc1,
  944. qczl_NumDesc2: detailData.qczl_NumDesc2,
  945. qczl_NumDesc3: detailData.qczl_NumDesc3,
  946. qczl_NumDesc4: detailData.qczl_NumDesc4,
  947. qczl_NumDesc5: detailData.qczl_NumDesc5,
  948. qczl_NumDesc6: detailData.qczl_NumDesc6,
  949. qczl_NumDesc7: detailData.qczl_NumDesc7,
  950. qczl_NumDesc8: detailData.qczl_NumDesc8,
  951. }
  952. detailData.table.forEach((item, index) => {
  953. const num = index + 1
  954. restoredData[`fp_lb${num}`] = item.fp_lb
  955. restoredData[`fp_sl${num}`] = item.fp_sl
  956. restoredData[`fp_bh${num}`] = item.fp_bh
  957. restoredData[`fp_bz${num}`] = item.fp_bz
  958. restoredData[`fp_gxmc${num}`] = item.fp_gxmc
  959. })
  960. const res = await updateData(restoredData)
  961. if (res.code === 0) {
  962. ElMessage({
  963. type: 'success',
  964. message: res.msg,
  965. })
  966. dialogFormVisible.value = false
  967. }
  968. }
  969. // 多选
  970. const handleSelectionChange = (val) => {
  971. multipleSelection.value = val
  972. }
  973. // 多选删除
  974. const onDelete = async () => {
  975. const ids = []
  976. if (multipleSelection.value.length === 0) {
  977. ElMessage({
  978. type: 'warning',
  979. message: '请选择要删除的数据'
  980. })
  981. return
  982. }
  983. multipleSelection.value &&
  984. multipleSelection.value.map(item => {
  985. ids.push(item.ID)
  986. })
  987. const res = await deleteCompanyByIds({
  988. ids
  989. })
  990. if (res.code === 0) {
  991. ElMessage({
  992. type: 'success',
  993. message: '删除成功'
  994. })
  995. if (tableData.value.length === ids.length && page.value > 1) {
  996. page.value--
  997. }
  998. deleteVisible.value = false
  999. getTableData()
  1000. }
  1001. }
  1002. // 更新行
  1003. const updateCompanyFunc = async (row) => {
  1004. const res = await findCompany({
  1005. ID: row.ID
  1006. })
  1007. type.value = 'update'
  1008. if (res.code === 0) {
  1009. formData.value = res.data.recompany
  1010. // dialogFormVisible.value = true
  1011. showDialog()
  1012. }
  1013. }
  1014. // 关闭弹窗
  1015. const closeDialog = () => {
  1016. dialogFormVisible.value = false
  1017. }
  1018. // 导出excel
  1019. function exportExcel() {
  1020. console.log('导出到excel')
  1021. }
  1022. const dialogMrhjtj = ref(false)
  1023. const dialogGdzjfptj = ref(false)
  1024. const dialogSbyxgl = ref(false)
  1025. const dialoglcdcx = ref(false)
  1026. const value1 = ref('')
  1027. const table = ref(null)
  1028. const showGdzjfptj = () => {
  1029. value1.value = currentRow.gdbh
  1030. dialogGdzjfptj.value = true
  1031. }
  1032. const currentRow = ref()
  1033. const lcdyjno = ref()
  1034. const handleSelectChange = (row, column, event) => {
  1035. currentRow.value = row.UniqId
  1036. currentRow.gdbh = row.qczl_gdbh
  1037. lcdyjno.value = row.qczl_yjno
  1038. }
  1039. //新增工单核验单维护
  1040. const handleShowAdd = async () => {
  1041. type.value = '新增工单核验单维护'
  1042. dialogFormVisible.value = true
  1043. setTimeout(() => {
  1044. const inputElement = document.getElementById('日期');
  1045. if (inputElement) {
  1046. inputElement.focus();
  1047. }
  1048. }, 100);
  1049. if (currentRow.value == undefined) {
  1050. // 循环13行数据
  1051. const table = []
  1052. for (let i = 1; i <= 13; i++) {
  1053. table.push({
  1054. fp_lb: '',
  1055. fp_sl: '',
  1056. fp_gxmc: '',
  1057. fp_bz: '',
  1058. fp_bh: '',
  1059. fp_name: '',
  1060. })
  1061. }
  1062. detailData.table = table
  1063. dialogFormVisible.value = true
  1064. } else {
  1065. getOneWorkOrder({ UniqId: currentRow.value }).then(res => {
  1066. if (res.code === 0) {
  1067. const obj = res.data
  1068. // 裁剪返回数据的前后空格
  1069. for (const key in obj) {
  1070. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  1071. obj[key] = obj[key].trim()
  1072. }
  1073. }
  1074. // 修改日期格式
  1075. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  1076. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  1077. }
  1078. obj['qczl_num'] = '0'
  1079. obj['qczl_NumDesc1'] = '0'
  1080. obj['qczl_NumDesc2'] = '0'
  1081. obj['qczl_NumDesc3'] = '0'
  1082. obj['qczl_NumDesc4'] = '0'
  1083. obj['qczl_NumDesc5'] = '0'
  1084. obj['qczl_NumDesc6'] = '0'
  1085. obj['qczl_NumDesc7'] = '0'
  1086. obj['qczl_NumDesc8'] = '0'
  1087. obj['qczl_fp'] = ''
  1088. Object.assign(detailData, obj)
  1089. const table = []
  1090. // 循环13行数据
  1091. for (let i = 1; i <= 13; i++) {
  1092. table.push({
  1093. fp_lb: detailData[`fp_lb${i}`] || '',
  1094. fp_sl: 0,
  1095. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  1096. fp_bz: detailData[`fp_bz${i}`] || '',
  1097. fp_bh: detailData[`fp_bh${i}`] || '',
  1098. fp_name: detailData[`fp_name${i}`] || '',
  1099. })
  1100. // 从原对象中删除这些属性
  1101. delete detailData[`fp_lb${i}`]
  1102. delete detailData[`fp_sl${i}`]
  1103. delete detailData[`fp_gxmc${i}`]
  1104. delete detailData[`fp_bz${i}`]
  1105. delete detailData[`fp_bh${i}`]
  1106. delete detailData[`fp_name${i}`]
  1107. }
  1108. detailData.table = table
  1109. getOrderInfo({ order: detailData.qczl_gdbh }).then(resposne => {
  1110. if (resposne.code === 0) {
  1111. //循环resposne.data当子项yj_Yjno的值等于obj中的qczl_yjno的值时设置detailData.Gd_cpmc的值为res.data[i].Gd_cpmc
  1112. for (let i = 0; i < resposne.data.length; i++) {
  1113. if (resposne.data[i].yj_Yjno == detailData.qczl_yjno) {
  1114. detailData.yj_yjmc = resposne.data[i].yj_yjmc
  1115. detailData.Gd_cpmc = resposne.data[i].Gd_cpmc
  1116. }
  1117. }
  1118. showDialog()
  1119. }
  1120. })
  1121. }
  1122. })
  1123. }
  1124. }
  1125. // 开启弹窗
  1126. const showDialog = () => {
  1127. dialogFormVisible.value = true
  1128. }
  1129. const dialogSelectVisible1 = ref(false); // 控制对话框显示
  1130. const selecTreeData = ref([]); // 树形数据
  1131. const table_fplb = ref(null); // el-tree 的 ref
  1132. const defaultExpandedKey = ref(null); // 默认展开的节点 key
  1133. const selectIndex = ref(0); // 当前选中的索引
  1134. // 异步加载废品类别的回车事件
  1135. const handleFplbEnter = async (event, index, row, title) => {
  1136. // 更新当前选中的索引
  1137. selectIndex.value = index;
  1138. if (dialogSelectVisible1.value || !row.fp_lb?.trim()) {
  1139. console.log("废品类别为空或弹窗已打开");
  1140. return;
  1141. }
  1142. try {
  1143. const res = await getWastInfo();
  1144. if (res.code === 0 && res.data && res.data.废品分类) {
  1145. const categories = res.data.废品分类;
  1146. if (typeof categories !== 'object') {
  1147. console.error("废品分类数据格式错误,预期为对象格式", categories);
  1148. return;
  1149. }
  1150. const hasMatch = checkMatchInTree(processTreeData(categories, ''), row.fp_lb.trim());
  1151. if (hasMatch) {
  1152. return;
  1153. }
  1154. const treeData = processTreeData(categories, row.fp_lb.trim());
  1155. selecTreeData.value = treeData;
  1156. dialogSelectVisible1.value = true;
  1157. nextTick(() => {
  1158. if (treeData.length > 0) {
  1159. defaultExpandedKey.value = treeData[0].id;
  1160. const firstNode = treeData[0];
  1161. if (table_fplb.value) {
  1162. table_fplb.value.setCurrentKey(firstNode.id);
  1163. handleFplbClick(firstNode, true);
  1164. }
  1165. }
  1166. });
  1167. }
  1168. } catch (error) {
  1169. console.error("获取废品分类数据时出错:", error);
  1170. }
  1171. };
  1172. // 递归检查树形数据是否存在匹配项
  1173. const checkMatchInTree = (tree, targetLabel) => {
  1174. if (!tree || !targetLabel) return false;
  1175. for (const node of tree) {
  1176. if (node.label === targetLabel) {
  1177. return true; // 找到匹配项
  1178. }
  1179. if (node.children && node.children.length > 0) {
  1180. const foundInChildren = checkMatchInTree(node.children, targetLabel);
  1181. if (foundInChildren) {
  1182. return true;
  1183. }
  1184. }
  1185. }
  1186. return false; // 未找到匹配项
  1187. };
  1188. // 处理数据构建树形结构(支持模糊筛选)
  1189. const processTreeData = (categories, prefix) => {
  1190. const result = [];
  1191. if (!categories || typeof categories !== 'object') {
  1192. console.error("processTreeData:废品分类数据格式不正确", categories);
  1193. return result;
  1194. }
  1195. // 处理分类数据
  1196. const isPrefixValid = prefix && /^[a-zA-Z]+$/.test(prefix);
  1197. const upperPrefix = isPrefixValid ? prefix.toUpperCase() : null;
  1198. for (const categoryKey in categories) {
  1199. if (Object.prototype.hasOwnProperty.call(categories, categoryKey)) {
  1200. const items = categories[categoryKey];
  1201. const categoryNode = {
  1202. id: categoryKey,
  1203. label: categoryKey,
  1204. children: [],
  1205. };
  1206. for (const [index, item] of items.entries()) {
  1207. if (!upperPrefix || item.toUpperCase().includes(upperPrefix)) {
  1208. categoryNode.children.push({
  1209. id: `${categoryKey}-${index}`,
  1210. label: item,
  1211. children: [],
  1212. });
  1213. }
  1214. }
  1215. if (categoryNode.children.length > 0) {
  1216. result.push(categoryNode);
  1217. }
  1218. }
  1219. }
  1220. return result; // 确保返回的总是数组
  1221. };
  1222. // 废品类别分类点击事件
  1223. const handleFplbClick = (node) => {
  1224. const tree = table_fplb.value; // 获取树实例
  1225. if (!tree) {
  1226. console.error("树实例未加载");
  1227. return;
  1228. }
  1229. // 清除上一次的选中状态
  1230. clearPreviousSelection(tree);
  1231. // 遍历所有节点,收起所有节点
  1232. Object.keys(tree.store.nodesMap).forEach((key) => {
  1233. tree.store.nodesMap[key].expanded = false; // 收起所有节点
  1234. });
  1235. };
  1236. // 废品类别分类键盘事件
  1237. const handleTreeKeydown = (event) => {
  1238. const tree = table_fplb.value; // 获取树实例
  1239. if (!tree) {
  1240. console.error("树组件未加载");
  1241. return;
  1242. }
  1243. const focusedElement = document.activeElement;
  1244. const focusedNodeId = focusedElement?.getAttribute("data-key"); // 获取 DOM 的 data-key 属性
  1245. if (event.keyCode === 13 && focusedNodeId) { // 判断是否是回车键
  1246. tree.setCurrentKey(focusedNodeId); // 设置当前节点为选中
  1247. tree.$nextTick(() => {
  1248. const currentNode = tree.getCurrentNode(); // 获取当前选中的节点
  1249. if (!currentNode) {
  1250. console.warn("没有选中的节点");
  1251. return;
  1252. }
  1253. // 清除上一次的选中状态
  1254. clearPreviousSelection(tree);
  1255. // 收起所有其他节点
  1256. Object.keys(tree.store.nodesMap).forEach((key) => {
  1257. tree.store.nodesMap[key].expanded = false; // 收起所有节点
  1258. });
  1259. // 展开当前节点
  1260. tree.store.nodesMap[currentNode.id].expanded = true;
  1261. // 如果当前节点有子节点,选中第一个子节点
  1262. if (currentNode.children && currentNode.children.length > 0) {
  1263. const firstChild = currentNode.children[0];
  1264. if (firstChild) {
  1265. const firstChildKey = firstChild.id.toString();
  1266. tree.setCurrentKey(firstChildKey); // 设置第一个子节点为选中
  1267. setTimeout(() => {
  1268. const firstChildDom = tree.$el.querySelector(`[data-key="${firstChildKey}"]`);
  1269. if (firstChildDom) {
  1270. firstChildDom.focus();
  1271. firstChildDom.scrollIntoView({ block: "nearest" });
  1272. }
  1273. });
  1274. }
  1275. } else {
  1276. console.log("当前子节点:", currentNode.label);
  1277. detailData.table[selectIndex.value].fp_lb = currentNode.label; // 更新数据
  1278. dialogSelectVisible1.value = false; // 关闭对话框
  1279. }
  1280. });
  1281. } else if (event.keyCode === 38 || event.keyCode === 40) { // 上下箭头键
  1282. const currentNode = tree.getCurrentNode();
  1283. if (currentNode) {
  1284. const currentNodeDom = tree.$el.querySelector(`[data-key="${currentNode.id}"]`);
  1285. if (currentNodeDom) {
  1286. currentNodeDom.focus();
  1287. }
  1288. }
  1289. }
  1290. };
  1291. // 工序弹出框键盘事件
  1292. const ent = (event) => {
  1293. if (document.activeElement.id === "tableFplb") {
  1294. if (table_fplb.value) {
  1295. const tree = table_fplb.value?.$el;
  1296. console.log(111, tree);
  1297. if (tree) {
  1298. const node = tree.querySelector("[data-key]");
  1299. console.log(222, node);
  1300. if (event.keyCode === 13) {
  1301. dialogSelectVisible1.value = false;
  1302. }
  1303. if (node) {
  1304. node.scrollIntoView({ block: "nearest" }); // 确保节点可见
  1305. node.focus(); // 确保焦点正确
  1306. }
  1307. }
  1308. }
  1309. }
  1310. };
  1311. // 清除之前的选中状态
  1312. const clearPreviousSelection = (tree) => {
  1313. const selectedNodes = tree.getCheckedNodes();
  1314. selectedNodes.forEach(node => {
  1315. tree.setChecked(node, false);
  1316. });
  1317. tree.setCurrentKey(null);
  1318. };
  1319. //键盘事件监听逻辑确认
  1320. const handleKeydown = (event) => {
  1321. if (dialogbutton.value && event.key === "Enter") {
  1322. ElMessage({
  1323. type: 'warning',
  1324. message: '正在保存数据中'
  1325. })
  1326. enterDialog(); // 调用确认按钮逻辑
  1327. }
  1328. };
  1329. // 获取工序
  1330. const getgxsubmit = () => {
  1331. console.log("获取工序")
  1332. if(!detailData.qczl_gdbh || !detailData.qczl_yjno){
  1333. return
  1334. }
  1335. GetJtbh()
  1336. }
  1337. const GetJtbh = async () => {
  1338. const { qczl_gdbh, qczl_yjno } = detailData
  1339. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  1340. if (response.code === 0) {
  1341. const data = response.data
  1342. console.log(data)
  1343. if (data) {
  1344. detailData.total_liucheng = data.max_num
  1345. const tableData = data.gx_data.map(item => ({
  1346. gxh: item.Gy0_gxh,
  1347. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  1348. // addGxmc: item.Add_gxmc
  1349. }))
  1350. selectData_gx.splice(0, selectData_gx.length, ...tableData)
  1351. setCurrent_gx(selectData_gx[0])
  1352. dialogSelectVisible_gx.value = true
  1353. }
  1354. }
  1355. }
  1356. let isProcessing = false; // 标志位
  1357. let lastFpSl = null; // 记录上一次输入的数量
  1358. const dialogbutton = ref(false); // 控制对话框显示
  1359. let enterCount = 0; // 记录回车键按下的次数
  1360. //新增回车事件
  1361. const ent1 = async(event,index,row,title) => {
  1362. const inputs = document.getElementsByTagName('input');
  1363. const currentIndex = Array.from(inputs).indexOf(event.target);
  1364. if (event.keyCode === 13 && title === '工序') {
  1365. getgxsubmit()
  1366. }else if (event.keyCode === 13 && title === '流程单号') {
  1367. // 获取所有相关的输入框值
  1368. const allValues = [
  1369. detailData.qczl_num,
  1370. detailData.qczl_NumDesc1,
  1371. detailData.qczl_NumDesc2,
  1372. detailData.qczl_NumDesc3,
  1373. detailData.qczl_NumDesc4,
  1374. detailData.qczl_NumDesc5,
  1375. detailData.qczl_NumDesc6,
  1376. detailData.qczl_NumDesc7,
  1377. detailData.qczl_NumDesc8,
  1378. ];
  1379. // 获取当前输入框的值
  1380. const currentValue = event.target.value;
  1381. // 如果当前值为 0,不进行校验,直接跳转到下一个输入框
  1382. if (currentValue === "0") {
  1383. console.log("输入值为 0,无需校验");
  1384. // 跳转到下一个输入框
  1385. let nextIndex = currentIndex + 1;
  1386. let foundNext = false; // 标记是否找到下一个可用输入框
  1387. while (nextIndex < inputs.length) {
  1388. if (inputs[nextIndex].disabled) {
  1389. console.log("当前输入框为 disabled,跳过");
  1390. nextIndex++; // 跳过 disabled 的输入框
  1391. continue;
  1392. }
  1393. if (!inputs[nextIndex].readOnly) {
  1394. nextTick(() => {
  1395. inputs[nextIndex].focus();
  1396. inputs[nextIndex].select();
  1397. });
  1398. foundNext = true; // 找到下一个可用输入框
  1399. break;
  1400. }
  1401. nextIndex++;
  1402. }
  1403. if (!foundNext) {
  1404. console.log("没有更多可用的输入框");
  1405. }
  1406. return;
  1407. }
  1408. // 检查是否有重复的值
  1409. const isDuplicate = allValues.filter((val) => val === currentValue).length > 1;
  1410. if (isDuplicate) {
  1411. // 如果有重复值,提示用户并清空当前输入框
  1412. event.target.value = 0;
  1413. ElMessage({
  1414. type: 'error',
  1415. message: '输入的值已存在,请重新输入'
  1416. });
  1417. } else {
  1418. console.log('输入值无重复');
  1419. // 跳转到下一个输入框
  1420. let nextIndex = currentIndex + 1;
  1421. let foundNext = false; // 标记是否找到下一个可用输入框
  1422. while (nextIndex < inputs.length) {
  1423. if (inputs[nextIndex].disabled) {
  1424. console.log("当前输入框为 disabled,跳过");
  1425. nextIndex++; // 跳过 disabled 的输入框
  1426. continue;
  1427. }
  1428. if (!inputs[nextIndex].readOnly) {
  1429. nextTick(() => {
  1430. inputs[nextIndex].focus();
  1431. inputs[nextIndex].select();
  1432. });
  1433. foundNext = true; // 找到下一个可用输入框
  1434. break;
  1435. }
  1436. nextIndex++;
  1437. }
  1438. if (!foundNext) {
  1439. console.log("没有更多可用的输入框");
  1440. }
  1441. }
  1442. }else if (event.keyCode === 13 && title === '废品类别') {
  1443. handleFplbEnter(event,index,row,title)
  1444. let nextIndex = currentIndex + 1;
  1445. let foundNext = false; // 标记是否找到下一个可用的输入框
  1446. while (nextIndex < inputs.length) {
  1447. if (inputs[nextIndex].disabled) {
  1448. console.log("当前输入框为disabled,跳过");
  1449. nextIndex++; // 跳过disabled的输入框
  1450. continue;
  1451. }
  1452. if (!inputs[nextIndex].readOnly) {
  1453. nextTick(() => {
  1454. inputs[nextIndex].focus();
  1455. inputs[nextIndex].select();
  1456. });
  1457. foundNext = true; // 找到下一个可用输入框
  1458. break;
  1459. }
  1460. nextIndex++;
  1461. }
  1462. }else if (event.keyCode === 13 && title === '数量') {
  1463. // 去掉数量前导的0
  1464. if (typeof row.fp_sl === 'string') {
  1465. row.fp_sl = row.fp_sl.replace(/^0+(?=\d)/, '');
  1466. }
  1467. // 判断数量是否为 0 或为空
  1468. if (row.fp_sl === '0' || row.fp_sl === '' || row.fp_sl === 0) {
  1469. console.log("数量为 0,清空对应字段");
  1470. ['fp_gxmc', 'fp_bz', 'fp_bh', 'fp_name'].forEach(field => {
  1471. detailData.table[index][field] = '';
  1472. });
  1473. }
  1474. // 焦点跳转逻辑
  1475. let nextIndex = currentIndex + 1;
  1476. let foundNext = false;
  1477. while (nextIndex < inputs.length) {
  1478. const nextInput = inputs[nextIndex];
  1479. if (!nextInput.disabled && !nextInput.readOnly) {
  1480. nextInput.focus();
  1481. nextInput.select();
  1482. foundNext = true;
  1483. console.log(`焦点已跳转到输入框索引: ${nextIndex}`);
  1484. break;
  1485. }
  1486. nextIndex++;
  1487. }
  1488. if (!foundNext) {
  1489. console.log("未找到下一个可用的输入框");
  1490. enterCount++; // 增加回车键按下的次数
  1491. if (enterCount === 2) {
  1492. dialogbutton.value = true; // 第二次按下回车键时弹出弹窗
  1493. enterCount = 0; // 重置计数器
  1494. }
  1495. }
  1496. isProcessing = false; // 标志位重置,允许下一次回车处理
  1497. }else
  1498. if (event.keyCode === 13 && title === '工序及责任机长') {
  1499. console.log('工序及责任机长');
  1500. console.log('row', row['fp_gxmc']);
  1501. // 判断工序字段是否为空
  1502. if (!row.fp_gxmc || row.fp_gxmc.trim() === '') {
  1503. console.log('工序及责任机长为空,跳转到下一个输入框');
  1504. let nextIndex = currentIndex + 1;
  1505. let foundNext = false;
  1506. // 找下一个可用输入框
  1507. while (nextIndex < inputs.length) {
  1508. if (!inputs[nextIndex].disabled && !inputs[nextIndex].readOnly) {
  1509. nextTick(() => {
  1510. inputs[nextIndex].focus();
  1511. inputs[nextIndex].select();
  1512. });
  1513. foundNext = true;
  1514. break;
  1515. }
  1516. nextIndex++;
  1517. }
  1518. // 如果找不到下一个输入框,触发弹窗逻辑
  1519. if (!foundNext) {
  1520. console.log('未找到下一个可用的输入框');
  1521. dialogbutton.value = true;
  1522. handleKeydown();
  1523. }
  1524. return; // 提前返回
  1525. }
  1526. // 如果数量为 0,清空字段并返回
  1527. if (row.fp_sl === 0 || row.fp_sl === '0' || row.fp_sl === '') {
  1528. detailData.table[index].fp_gxmc = '';
  1529. detailData.table[index].fp_bz = '';
  1530. detailData.table[index].fp_bh = '';
  1531. detailData.table[index].fp_name = '';
  1532. return;
  1533. }
  1534. // 保存当前行索引
  1535. selectIndex.value = index;
  1536. // 调用接口获取数据
  1537. const params = {
  1538. type: row.fp_lb,
  1539. order: detailData.qczl_gdbh,
  1540. yjno: detailData.qczl_yjno,
  1541. };
  1542. let res;
  1543. try {
  1544. res = await getGxAndLeader(params);
  1545. console.log('接口返回结果', res);
  1546. if (res.code !== 0) {
  1547. return; // 如果接口报错,直接返回
  1548. }
  1549. } catch (e) {
  1550. console.log('接口调用异常:', e);
  1551. return;
  1552. }
  1553. // 解析接口返回数据
  1554. const decodedData = res.data.map(item => ({
  1555. sczl_gxmc: item.sczl_gxmc,
  1556. sczl_bzdh: item.sczl_bzdh,
  1557. sczl_jtbbh: item.sczl_jtbh,
  1558. sczl_bh1: item.sczl_bh1,
  1559. name: item.name ? item.name.trim() : '', // 防止 name 为 null
  1560. }));
  1561. // 如果接口返回数据为空,直接返回
  1562. if (decodedData.length === 0) {
  1563. console.log('接口返回数据为空');
  1564. return;
  1565. }
  1566. console.log('row:', row);
  1567. // 匹配接口返回数据中的 sczl_gxmc 和 name
  1568. const matchedItem = decodedData.find(item => {
  1569. // console.log('正在匹配:', item.sczl_gxmc, '与', row.fp_gxmc);
  1570. // return item.name === row.fp_name;
  1571. console.log('正在匹配工序名称:', `: ${item.sczl_gxmc} 与 ${row.fp_gxmc}`);
  1572. console.log('正在匹配名字:', `名字: ${item.name} 与 ${row.fp_name}`);
  1573. // 运行匹配不成功继续匹配,成功代表匹配成功
  1574. return item.sczl_gxmc === row.fp_gxmc && item.name === row.fp_name;
  1575. });
  1576. console.log('匹配到的项:', matchedItem);
  1577. if (matchedItem) {
  1578. // 如果找到匹配的数据,更新当前行
  1579. console.log('匹配成功,数据正确,不需要弹窗');
  1580. detailData.table[index].fp_bz = matchedItem.sczl_bzdh;
  1581. detailData.table[index].fp_bh = matchedItem.sczl_bh1;
  1582. detailData.table[index].fp_name = matchedItem.name;
  1583. // 跳转到下一个输入框
  1584. let nextIndex = currentIndex + 1;
  1585. let foundNext = false;
  1586. while (nextIndex < inputs.length) {
  1587. if (!inputs[nextIndex].disabled && !inputs[nextIndex].readOnly) {
  1588. nextTick(() => {
  1589. inputs[nextIndex].focus();
  1590. inputs[nextIndex].select();
  1591. });
  1592. foundNext = true;
  1593. break;
  1594. }
  1595. nextIndex++;
  1596. }
  1597. if (!foundNext) {
  1598. console.log('未找到下一个可用的输入框');
  1599. dialogbutton.value = true;
  1600. handleKeydown();
  1601. }
  1602. } else {
  1603. // 如果未找到匹配的数据,弹窗选择
  1604. console.log('匹配失败,需要弹窗');
  1605. selectData = decodedData;
  1606. SLIndex.value = 0; // 初始化索引为第一个
  1607. setCurrent(selectData[0]); // 设置当前选中为第一个
  1608. dialogSelectVisible2.value = true; // 显示弹窗
  1609. }
  1610. }
  1611. else if (event.keyCode === 13 || event.keyCode === 40 && title === '') {
  1612. console.log('其他')
  1613. let nextIndex = currentIndex + 1;
  1614. let foundNext = false; // 标记是否找到下一个可用的输入框
  1615. while (nextIndex < inputs.length) {
  1616. if (inputs[nextIndex].disabled) {
  1617. nextIndex++; // 跳过disabled的输入框
  1618. continue;
  1619. }
  1620. if (!inputs[nextIndex].readOnly) {
  1621. nextTick(() => {
  1622. inputs[nextIndex].focus();
  1623. inputs[nextIndex].select();
  1624. });
  1625. foundNext = true; // 找到下一个可用输入框
  1626. break;
  1627. }
  1628. nextIndex++;
  1629. }
  1630. // 如果没有找到下一个可用输入框,提示用户
  1631. if (!foundNext) {
  1632. console.log("已经是最后一个输入框");
  1633. }
  1634. }
  1635. else if (event.keyCode === 38) { // 向上箭头
  1636. for (let i = currentIndex - 1; i >= 0; i--) {
  1637. if (!inputs[i].readOnly) {
  1638. nextTick(()=>{
  1639. inputs[i].focus();
  1640. inputs[i].select();
  1641. })
  1642. break;
  1643. }
  1644. }
  1645. } else if (event.keyCode === 37) { // 向左箭头
  1646. if (event.target.selectionStart === 0) {
  1647. for (let i = currentIndex - 1; i >= 0; i--) {
  1648. if (!inputs[i].readOnly) {
  1649. nextTick(()=>{
  1650. inputs[i].focus();
  1651. inputs[i].select();
  1652. })
  1653. break;
  1654. }
  1655. }
  1656. }
  1657. } else if (event.keyCode === 39) { // 向右箭头
  1658. if (event.target.selectionStart === event.target.value.length) {
  1659. for (let i = currentIndex + 1; i < inputs.length; i++) {
  1660. if (!inputs[i].readOnly) {
  1661. nextTick(()=>{
  1662. inputs[i].focus();
  1663. inputs[i].select();
  1664. })
  1665. break;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. }
  1671. //删除按钮
  1672. const handleDelete = () => {
  1673. if (currentRow.value == undefined) {
  1674. ElMessage({type: 'warning',message: '未选中记录',})
  1675. return
  1676. }
  1677. ElMessageBox.confirm(`确认删除这条数据么?`,'警告', {
  1678. confirmButtonText: '确认',
  1679. cancelButtonText: '取消',
  1680. type: 'warning',
  1681. }
  1682. ).then(() => {
  1683. del({'UniqId': currentRow.value}).then(res => {
  1684. if (res.code === 0) {
  1685. ElMessage({
  1686. type: 'success',
  1687. message: '删除成功',
  1688. })
  1689. currentRow.value = undefined
  1690. getSideData()
  1691. getTableData()
  1692. }
  1693. })
  1694. }).catch(() => {
  1695. ElMessage({
  1696. type: 'info',
  1697. message: '取消删除',
  1698. })
  1699. })
  1700. }
  1701. </script>
  1702. <style>
  1703. .JKWTree-container {
  1704. display: flex;
  1705. }
  1706. .JKWTree-tree {
  1707. width: 300px;
  1708. background-color: #fff;
  1709. padding: 10px;
  1710. margin-right: 20px;
  1711. }
  1712. .JKWTree-tree h3 {
  1713. font-size: 15px;
  1714. font-weight: 700;
  1715. margin: 10px 0;
  1716. }
  1717. .JKWTree-content {
  1718. flex: 1;
  1719. }
  1720. /* 选中某行时的背景色*/
  1721. .el-table__body tr.current-row > td {
  1722. background: #ff80ff !important;
  1723. /* 背景颜色 */
  1724. }
  1725. </style>
  1726. <style scoped>
  1727. :deep(.el-table td .cell) {
  1728. line-height: 20px !important;
  1729. }
  1730. :deep(.el-tabs__header) {
  1731. margin-bottom: 0;
  1732. }
  1733. .search {
  1734. margin-left: 0px !important;
  1735. margin-right: 10px !important;
  1736. }
  1737. .bt {
  1738. margin-left: 2px !important;
  1739. padding: 3px !important;
  1740. font-size: 12px;
  1741. }
  1742. .el-tabs__header {
  1743. margin: 0px !important;
  1744. }
  1745. .gva-table-box {
  1746. padding: 0px !important;
  1747. }
  1748. .mab {
  1749. margin-bottom: 5px;
  1750. }
  1751. :deep(.plan-usage-low div) {
  1752. color: blue !important;
  1753. font-size: 16px;
  1754. font-weight: bold;
  1755. }
  1756. /* 工序产量核查高亮 */
  1757. :deep(.lan-plan-usage-lows div) {
  1758. color: blue !important;
  1759. font-weight: bold;
  1760. }
  1761. /* tree组件背景高亮 */
  1762. :deep(.el-tree-node:focus > .el-tree-node__content){
  1763. background: #ff80ff !important;
  1764. }
  1765. /*!* 流程单查询按钮颜色控制未完成*/
  1766. :deep(.custom-button.el-button--info) {
  1767. background-color: palegreen !important;
  1768. color: #155724;
  1769. font-size: 20px;
  1770. border-color: #c3e6cb;
  1771. }
  1772. /* 已完成 */
  1773. :deep(.custom-button.el-button--danger) {
  1774. background-color: rgb(236, 135, 135) !important;
  1775. color: #721c24;
  1776. font-size: 20px;
  1777. border-color: #f5c6cb;
  1778. }
  1779. </style>