index.vue 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  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: 50px;">
  7. <div class="JKWTree-tree" style="height: 70vh;">
  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%" :data="tableData" row-key="ID" highlight-current-row
  30. border show-overflow-tooltip :row-style="{ height: '20px' }"
  31. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  32. :header-cell-style="{ padding: '0px' }" @row-click="handleSelectChange"
  33. @row-dblclick="doubleClick">
  34. <!-- 循环渲染表格列 -->
  35. <el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop"
  36. :label="column.label" :width="column.width" sortable />
  37. </el-table>
  38. <!-- 分页 -->
  39. <div class="gva-pagination">
  40. <el-pagination v-model:current-page="page" v-model:page-size="limit"
  41. layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 30, 50, 100]"
  42. :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  43. </div>
  44. </div>
  45. <!-- 弹出框 -->
  46. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type" destroy-on-close
  47. width="1200px">
  48. <el-form ref="elFormRef" :model="detailData" inline label-position="right" :rules="rule"
  49. id="detail-form" label-width="70px">
  50. <el-row :gutter="24">
  51. <el-col :span="5">
  52. <el-form-item label="日期">
  53. <el-input type="date" max="9999-12-31" v-model="detailData.qczl_rq" @keydown="ent1($event)" @focus="rqHandleFocus()"
  54. style="width: 130px;" />
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="5">
  58. <el-form-item label="工单编号">
  59. <el-input v-model="detailData.qczl_gdbh" style="width: 120px;" @keydown="ent1($event)"
  60. @blur="handleGdbhEnter" placeholder="Enter回车" />
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="5">
  64. <el-form-item label="拼印主工单" label-width="90px">
  65. <el-input v-model="detailData.qczl_Pygd" style="width: 120px;" @keydown="ent1($event)" />
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="9">
  69. <el-form-item label="产品名称">
  70. <el-input v-model="detailData.Gd_cpmc" style="width: 300px;" readonly />
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. <el-row :gutter="24">
  75. <el-col :span="5">
  76. <el-form-item label="印件号">
  77. <el-input v-model="detailData.qczl_yjno" style="width: 60px;" readonly/>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="10">
  81. <el-form-item label="印件名称" >
  82. <el-input v-model="detailData.yj_yjmc" style="width: 385px;" readonly/>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="5">
  86. <el-form-item label="废品总数">
  87. <el-input v-model="detailData.qczl_fp" @keydown="ent1($event)" style="width: 100px;" />
  88. </el-form-item>
  89. </el-col>
  90. </el-row>
  91. <el-row :gutter="24">
  92. <el-col :span="5">
  93. <el-form-item label="工序">
  94. <el-input v-model="detailData.qczl_gxmc" style="width: 150px;"
  95. @blur="getgxsubmit" @keydown="ent1($event)" />
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="5">
  99. <el-form-item label="工序号">
  100. <el-input v-model="detailData.qczl_gxh" @keydown="ent1($event)" style="width: 120px;" />
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="5">
  104. <el-form-item label="总流程号" label-width="90px">
  105. <el-input v-model="detailData.total_liucheng" @keydown="ent1($event)" style="width: 120px;" />
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row :gutter="24">
  110. <el-col :span="15">
  111. <el-form-item label="流程单号">
  112. <el-input v-model="detailData.qczl_num" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  113. <el-input v-model="detailData.qczl_NumDesc1" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  114. <el-input v-model="detailData.qczl_NumDesc2" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  115. <el-input v-model="detailData.qczl_NumDesc3" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  116. <el-input v-model="detailData.qczl_NumDesc4" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  117. <el-input v-model="detailData.qczl_NumDesc5" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  118. <el-input v-model="detailData.qczl_NumDesc6" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  119. <el-input v-model="detailData.qczl_NumDesc7" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  120. <el-input v-model="detailData.qczl_NumDesc8" @keydown="ent1($event)" style="width: 60px; margin-right: 5px;" />
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="9">
  124. <el-form-item label="备注">
  125. <el-input v-model="detailData.qczl_NumDesc" @keydown="ent1($event)" style="width: 300px;" />
  126. </el-form-item>
  127. </el-col>
  128. </el-row>
  129. <el-scrollbar height="400px">
  130. <el-table :data="detailData.table" border tooltip-effect="dark"
  131. :row-style="{ height: '20px' }" :cell-style="{ padding: '0px' }"
  132. :header-row-style="{ height: '20px' }" :header-cell-style="{ padding: '0px' }">
  133. <el-table-column label="废品类别" width="200">
  134. <template #default="{ row, $index }">
  135. <el-input v-model="row.fp_lb" @keydown="ent1($event)" @blur="handleFplbEnter($index, row)" />
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="数量" width="100">
  139. <template #default="{ row, $index }">
  140. <el-input v-model="row.fp_sl" @keydown="ent1($event)" @blur="handleFpslEnter($index, row)" />
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="工序及责任机长" >
  144. <template #default="{ row }">
  145. <el-input v-model="row.fp_gxmc" @keydown="ent1($event)" readonly/>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="" width="100">
  149. <template #default="{ row }">
  150. <el-input v-model="row.fp_bz" @keydown="ent1($event)" readonly/>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="" width="100">
  154. <template #default="{ row }">
  155. <el-input v-model="row.fp_bh" @keydown="ent1($event)" 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_name" @keydown="ent1($event)" readonly/>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </el-scrollbar>
  165. </el-form>
  166. <template #footer>
  167. <div class="dialog-footer">
  168. <el-button @click="closeDialog">取 消</el-button>
  169. <el-button type="primary" @click="enterDialog">确 定
  170. </el-button>
  171. </div>
  172. </template>
  173. </el-dialog>
  174. <!-- 废品类别弹出选项框 -->
  175. <el-dialog v-model="dialogSelectVisible1" id="tableFplb" @keydown="ent($event)" @opened="focusFirstNode">
  176. <el-form>
  177. <div>
  178. <el-form-item label="废品类别 :" class="mab" prop="keyOrder"></el-form-item>
  179. <div style="border:1px solid #eee; width:100%; height: 400px; overflow-y: auto">
  180. <el-tree :data="selecTreeData" ref="table_fplb"
  181. :props="{ children: 'children',label: 'label'}"
  182. node-key="id" @node-click="handleFplbClick">
  183. </el-tree>
  184. </div>
  185. </div>
  186. </el-form>
  187. </el-dialog>
  188. <!-- 弹出选项框 数量 -->
  189. <el-dialog v-model="dialogSelectVisible2" title="选择" destroy-on-close width="800px"
  190. @keydown="selectSL($event)">
  191. <el-table tooltip-effect="dark" :data="selectData" row-key="ID" highlight-current-row border
  192. style="width:100%" @row-dblclick="handleSelectClick" ref="table2">
  193. <el-table-column v-for=" column in selectColumns " :key="column.prop" :prop="column.prop"
  194. :label="column.label" :width="column.width" />
  195. </el-table>
  196. </el-dialog>
  197. <!--流程单查询【弹窗】-->
  198. <el-dialog v-model="gd_lcdlist" title="工单工序生产进程" style="width: 100%;height: 100%;margin: 0px;padding: 0px;">
  199. <div style="width: 100%;height: 100%;">
  200. <el-button type="" @click="gd_lcdCancel">退出</el-button>
  201. </div>
  202. <div style="width: 100%; height: 100%; display: flex; align-items: center;">
  203. <el-form-item label="工单编号" style="margin-right: 20px; padding: 0;">
  204. <el-input v-model="gd_lcdformData['gdbh']" @keyup.enter="gd_lcdProductValue"/>
  205. </el-form-item>
  206. <el-form-item label="" style="margin-right: 5px; padding: 0;">
  207. <el-input v-model="gd_lcdformData['code']" disabled/>
  208. </el-form-item>
  209. <el-form-item label="" style="margin-right: 5px; padding: 0;">
  210. <el-input v-model="gd_lcdformData['name']" disabled style="width: 500px"/>
  211. </el-form-item>
  212. </div>
  213. <div style="width: 100%; height: 70vh; display: flex;">
  214. <layout>
  215. <layout-sider :resize-directions="['right']" :width="240" style="margin-right: 10px;height: 70vh;">
  216. <div class="JKWTree-tree">
  217. <el-tree :data="lcd_treeData" @node-click="lcd_handleNodeClick" default-expand-all></el-tree>
  218. </div>
  219. </layout-sider>
  220. <layout-main>
  221. <!-- 这里放右侧的内容 -->
  222. <el-space wrap>
  223. <!-- 右侧内容 -->
  224. <template v-for="item in processList.total_process">
  225. <el-button disabled :type="! processList.process.includes(item) ? 'danger' : 'info'" plain style="width: 50px">{{ item }}</el-button>
  226. </template>
  227. </el-space>
  228. </layout-main>
  229. </layout>
  230. </div>
  231. </el-dialog>
  232. <!-- 弹出选项框 工单 -->
  233. <el-dialog v-model="dialogSelectVisible" title="选择" destroy-on-close width="1000px"
  234. @keydown="selectGX($event)">
  235. <el-table tooltip-effect="dark" :data="selectData_gd" row-key="ID" highlight-current-row="true"
  236. border style="width:100%" @row-dblclick="handleSelectClick_gd" ref="table_gd">
  237. <el-table-column prop="Gd_cpmc" label="工单名称" width="430" />
  238. <el-table-column prop="yj_Yjno" label="印件号" width="100" />
  239. <el-table-column prop="yj_yjmc" label="印件名称" width="430" />
  240. </el-table>
  241. </el-dialog>
  242. <!-- 弹出选项框 工序 -->
  243. <el-dialog v-model="dialogSelectVisible_gx" title="选择" destroy-on-close width="600px"
  244. @keydown="select_gx($event)">
  245. <el-table tooltip-effect="dark" :data="selectData_gx" row-key="ID" highlight-current-row="true"
  246. border style="width:100%" @row-dblclick="handleSelectClick_gx" ref="table_gx">
  247. <el-table-column prop="gxh" label="工序号" width="100" />
  248. <el-table-column prop="gxmc" label="工序名称" width="460" />
  249. </el-table>
  250. </el-dialog>
  251. <!-- 废品日统计 -->
  252. <Meirihejiantongji v-if="dialogMrhjtj" v-model="dialogMrhjtj" />
  253. <!-- 工单质检废品统计 -->
  254. <Gongdanzhijianfeipintongji v-if="dialogGdzjfptj" v-model="dialogGdzjfptj" :val="value1" />
  255. <!-- 测试图表 -->
  256. <Shebeizhuangtai v-if="dialogSbyxgl" v-model="dialogSbyxgl"
  257. title="【01.30 08:30】【JY01#--海德堡对开八色平版胶印机(JY08-01)】【2311116-->钻石(荷花)盒包装纸】【01--胶印】" />
  258. </el-main>
  259. </el-container>
  260. </el-container>
  261. </div>
  262. </template>
  263. <script setup>
  264. import {
  265. createCompany,
  266. deleteCompany,
  267. deleteCompanyByIds,
  268. updateCompany,
  269. findCompany,
  270. getCompanyList
  271. } from '@/api/company'
  272. // 全量引入格式化工具 请按需保留
  273. import {
  274. ElMessage,
  275. ElMessageBox,
  276. } from 'element-plus'
  277. import {
  278. Search,
  279. Refresh,
  280. Download
  281. } from '@element-plus/icons-vue'
  282. import {ref,reactive,nextTick} from 'vue'
  283. import {getOrderProcessLeft,getOrderProcessRight} from "@/api/yunyin/yunying";
  284. import {
  285. getSide,
  286. getTable,
  287. getOneWorkOrder,
  288. getOrderInfo,
  289. getGxAndLeader,
  290. getYjInfo,
  291. getWastInfo,
  292. updateData,
  293. add,
  294. del
  295. } from '@/api/mes_api_gty/workOrderVerification'
  296. import Meirihejiantongji from '@/view/performance/09-workOrderVerification/componets/meirihejiantongji.vue'
  297. import Gongdanzhijianfeipintongji from '@/view/performance/09-workOrderVerification/componets/gongdanzhijianfeipintongji.vue'
  298. import Shebeizhuangtai from '@/view/performance/09-workOrderVerification/componets/shebeizhuangtai.vue'
  299. import Liuchengdanchaxun from '@/view/performance/09-workOrderVerification/componets/liuchengdanchaxun.vue'
  300. import {
  301. Layout,
  302. LayoutContent,
  303. LayoutHeader,
  304. LayoutSider
  305. } from '@arco-design/web-vue'
  306. import {
  307. useUserStore
  308. } from '@/pinia/modules/user'
  309. const userStore = useUserStore()
  310. const sys_id = '[' + userStore.userInfo.userName + '/' + userStore.userInfo.nickName + ']'
  311. defineOptions({
  312. name: '06PackingDocuments'
  313. })
  314. // 侧边栏数据请求
  315. const treeData = reactive([])
  316. const getSideData = async () => {
  317. const response = await getSide()
  318. if (response.code === 0) {
  319. const transformedData = response.data.map(item => ({
  320. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  321. children: item.sys.map(sysItem => ({
  322. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  323. params: {
  324. date: item.date.replace(/\./g, '-'),
  325. sys_id: sysItem.sys_id,
  326. },
  327. })),
  328. }))
  329. treeData.splice(0, treeData.length, ...transformedData)
  330. }
  331. }
  332. getSideData()
  333. // 验证规则
  334. const rule = reactive({})
  335. const elFormRef = ref()
  336. const elSearchFormRef = ref()
  337. // =========== 表格控制部分 ===========
  338. const tableColumns = [
  339. {label: '工单编号', prop: 'qczl_gdbh', width: '120'},
  340. {label: '印件号', prop: 'qczl_yjno', width: '100'},
  341. {label: '印件名称', prop: 'Gd_cpmc', width: '400'},
  342. {label: '日期', prop: 'qczl_rq', width: '100'},
  343. {label: '流程单号', prop: 'qczl_num', width: '120'},
  344. {label: '流程单备注', prop: 'qczl_NumDesc', width: '120'},
  345. {label: '总废品', prop: 'qczl_fp', width: '100'},
  346. {label: '废品1', prop: 'sl_lb1', width: '250'},
  347. {label: '废品2', prop: 'sl_lb2', width: '250'},
  348. {label: '废品3', prop: 'sl_lb3', width: '250'},
  349. {label: '废品4', prop: 'sl_lb4', width: '250'},
  350. {label: '废品5', prop: 'sl_lb5', width: '250'},
  351. {label: '废品6', prop: 'sl_lb6', width: '250'},
  352. {label: '废品7', prop: 'sl_lb7', width: '250'},
  353. {label: '废品8', prop: 'sl_lb8', width: '250'},
  354. {label: '废品9', prop: 'sl_lb9', width: '250'},
  355. {label: '废品10', prop: 'sl_lb10', width: '250'},
  356. {label: '废品11', prop: 'sl_lb11', width: '250'},
  357. {label: '废品12', prop: 'sl_lb12', width: '250'},
  358. {label: '废品13', prop: 'sl_lb13', width: '250'},
  359. {label: '废品14', prop: 'sl_lb14', width: '250'},
  360. {label: '废品15', prop: 'sl_lb15', width: '250'},
  361. {label: '废品16', prop: 'sl_lb16', width: '250'},
  362. {label: '废品17', prop: 'sl_lb17', width: '250'},
  363. {label: '创建用户', prop: 'sys_id', width: '200'},
  364. ]
  365. const tableData = reactive([])
  366. const total = ref(0)
  367. const page = ref(1)
  368. const limit = ref(10)
  369. const searchInfo = ref('')
  370. const params = {
  371. date: '',
  372. sys_id: '',
  373. order: '',
  374. page: page.value.toString(),
  375. limit: limit.value.toString(),
  376. }
  377. // 获取工序
  378. const getgxsubmit = () => {
  379. if(!detailData.qczl_gdbh || !detailData.qczl_yjno){
  380. return
  381. }
  382. GetJtbh()
  383. }
  384. const GetJtbh = async () => {
  385. const { qczl_gdbh, qczl_yjno } = detailData
  386. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  387. if (response.code === 0) {
  388. const data = response.data
  389. if (data) {
  390. detailData.total_liucheng = data.max_num
  391. const tableData = data.gx_data.map(item => ({
  392. gxh: item.Gy0_gxh,
  393. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  394. // addGxmc: item.Add_gxmc
  395. }))
  396. selectData_gx.splice(0, selectData_gx.length, ...tableData)
  397. setCurrent_gx(selectData_gx[0])
  398. dialogSelectVisible_gx.value = true
  399. }
  400. }
  401. }
  402. const dialogSelectVisible_gx = ref(false)
  403. const selectData_gx = reactive([])
  404. const handleSelectClick_gx = (row, column, event) => {
  405. const { gxh, gxmc } = row
  406. detailData.qczl_gxmc = gxh + '-' + gxmc
  407. detailData.qczl_gxh = gxh
  408. dialogSelectVisible_gx.value = false
  409. }
  410. const currentIndex_gx = ref(0);
  411. const current_gx = ref(0);
  412. const select_gx = (event) => {
  413. if (event.keyCode === 40) { // 向下箭头
  414. if (currentIndex_gx.value < selectData_gx.length - 1) {
  415. currentIndex_gx.value++;
  416. setCurrent_gx(selectData_gx[currentIndex_gx.value]);
  417. } else {
  418. currentIndex_gx.value = 0;
  419. setCurrent_gx(selectData_gx[currentIndex_gx.value]); // 到达最后一行时回到第一行
  420. }
  421. } else if (event.keyCode === 38) { // 向上箭头
  422. if (currentIndex_gx.value > 0) {
  423. currentIndex_gx.value--;
  424. setCurrent_gx(selectData_gx[currentIndex_gx.value]);
  425. } else {
  426. currentIndex_gx.value = selectData_gx.length - 1;
  427. setCurrent_gx(selectData_gx[currentIndex_gx.value]); // 到达第一行时回到最后一行
  428. }
  429. } else if (event.keyCode === 13) { // 回车键
  430. dialogSelectVisible_gx.value = false;
  431. }
  432. }
  433. const table_gx = ref()
  434. const setCurrent_gx = (row) => {
  435. setTimeout(() => {
  436. table_gx.value?.setCurrentRow(row)
  437. const { gxh, gxmc } = row
  438. detailData.qczl_gxmc = gxh + '-' + gxmc
  439. detailData.qczl_gxh = gxh
  440. })
  441. }
  442. // 批量删除控制标记
  443. const deleteVisible = ref(false)
  444. const multipleSelection = ref([])
  445. const getTableData = async () => {
  446. const response = await getTable(params)
  447. if (response.code === 0) {
  448. total.value = response.data.total
  449. // Object.assign(tableData, response.data.rows)
  450. tableData.splice(0, tableData.length, ...response.data.rows)
  451. }
  452. }
  453. // 左侧树结构点击
  454. const handleNodeClick = (node, check) => {
  455. if (node.params) {
  456. params.date = node.params.date
  457. params.sys_id = node.params.sys_id
  458. page.value = 1
  459. handleCurrentChange()
  460. }
  461. }
  462. // =========== 流程单查询 ===========
  463. const gd_lcdlist = ref(false);
  464. const gd_lcdformData = reactive({
  465. gdbh: '',
  466. code: '',
  467. name: '',
  468. });
  469. // 流程单查询按钮
  470. const processList = ref([]);
  471. const gdlcdcxconlick = async () => {
  472. if(currentRow.gdbh === '' || currentRow.gdbh === null || currentRow.gdbh === undefined){
  473. ElMessage({type: 'warning',message: '请选择具体的工单,在进行操作'})
  474. return false;
  475. }else{
  476. gd_lcdformData['gdbh'] = currentRow.gdbh;
  477. _getOrderProcessLeft_list();
  478. gd_lcdlist.value = true;
  479. processList.value = []
  480. }
  481. }
  482. //流程单查询回车
  483. const gd_lcdProductValue = async () => {
  484. if(gd_lcdformData['gdbh'] == '' || gd_lcdformData['gdbh'] === null){
  485. ElMessage({type: 'warning',message: '工单编号为空'})
  486. return false;
  487. }
  488. _getOrderProcessLeft_list();
  489. }
  490. const lcd_treeData = ref([]);
  491. const _getOrderProcessLeft_list = async () => {
  492. const order = gd_lcdformData['gdbh'];
  493. try {
  494. //5.1流程单查询-工单工序生产进程菜单栏
  495. const getOrderProcessLeft_list = await getOrderProcessLeft({ order:order});
  496. console.log(getOrderProcessLeft_list)
  497. if(getOrderProcessLeft_list.data.Gd_info === null || getOrderProcessLeft_list.data.Gd_info === ''){
  498. ElMessage({type: 'warning',message: '未查询到具体工单信息'})
  499. lcd_treeData.value = [];
  500. return false;
  501. }
  502. gd_lcdformData['code'] = getOrderProcessLeft_list.data.Gd_info['code'];
  503. gd_lcdformData['name'] = getOrderProcessLeft_list.data.Gd_info['name'];
  504. lcd_treeData.value = [{
  505. label: order + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
  506. // label: getOrderProcessLeft_list.data.Gd_info['code'] + '-' + getOrderProcessLeft_list.data.Gd_info['name'],
  507. value: undefined,
  508. children: []
  509. }]
  510. const newData = [];
  511. for (let key in getOrderProcessLeft_list.data.Gy_info) {
  512. let temp = getOrderProcessLeft_list.data.Gy_info[key];
  513. let concatenatedValue = `${temp.Gy0_yjno}-${temp.Gy0_gxh} ---> ${temp.Gy0_gxmc}`;
  514. newData.push({ label: concatenatedValue,value: temp.Gy0_gxh });
  515. }
  516. lcd_treeData.value[0].children = newData;
  517. //5.2流程单查询-获取工单工序生产进程右侧【接口】【进入页面默认显示第一个数据】
  518. const getOrderProcessRight_list = await getOrderProcessRight({order: order, gxNo:newData[0].value});
  519. processList.value = getOrderProcessRight_list.data
  520. } catch (error) {
  521. console.error(error);
  522. }
  523. };
  524. //点击左侧获取工序显示右侧数据
  525. const lcd_handleNodeClick = async (node) => {
  526. if (node.value === undefined || node.value === null){
  527. return false;
  528. }
  529. const order = gd_lcdformData['gdbh'];
  530. //5.2流程单查询-获取工单工序生产进程右侧【接口】
  531. const getOrderProcessRight_list = await getOrderProcessRight({order:order, gxNo:node.value});
  532. processList.value = getOrderProcessRight_list.data
  533. };
  534. // 流程单查询退出
  535. const gd_lcdCancel = async () => {
  536. gd_lcdlist.value = false;
  537. }
  538. // 搜索
  539. function handleSearch() {
  540. params.sys_id = ''
  541. params.date = ''
  542. params.order = searchInfo.value
  543. page.value = 1
  544. handleCurrentChange()
  545. }
  546. // 分页
  547. const handleSizeChange = () => {
  548. params.limit = limit.value.toString()
  549. getTableData()
  550. }
  551. // 页面跳转
  552. const handleCurrentChange = () => {
  553. params.page = page.value.toString()
  554. getTableData()
  555. }
  556. // ============== 详情页面 ==============
  557. const detailData = reactive({})
  558. // const selectData = reactive([])
  559. const selectColumns = [{
  560. label: '',
  561. prop: 'sczl_gxmc',
  562. width: '500'
  563. },
  564. {
  565. label: '',
  566. prop: 'sczl_jtbh',
  567. width: '100'
  568. },
  569. {
  570. label: '',
  571. prop: 'sczl_bzdh',
  572. width: '100'
  573. },
  574. {
  575. label: '',
  576. prop: 'name',
  577. width: '100'
  578. },
  579. ]
  580. // 行为控制标记(弹窗内部需要增还是改)
  581. const type = ref('')
  582. // 弹窗控制标记
  583. const dialogFormVisible = ref(false)
  584. const dialogSelectVisible1 = ref(false)
  585. const dialogSelectVisible2 = ref(false)
  586. let selectIndex = 0
  587. const getDetailData = async (id) => {
  588. try {
  589. const res = await getOneWorkOrder({ UniqId: id })
  590. if (res.code === 0) {
  591. const obj = res.data
  592. // 裁剪返回数据的前后空格
  593. for (const key in obj) {
  594. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  595. obj[key] = obj[key].trim()
  596. }
  597. }
  598. // 修改日期格式
  599. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  600. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  601. }
  602. Object.assign(detailData, obj)
  603. const table = []
  604. // 循环13行数据
  605. for (let i = 1; i <= 13; i++) {
  606. table.push({
  607. fp_lb: detailData[`fp_lb${i}`] || '',
  608. fp_sl: detailData[`fp_sl${i}`] || '',
  609. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  610. fp_bz: detailData[`fp_bz${i}`] || '',
  611. fp_bh: detailData[`fp_bh${i}`] || '',
  612. fp_name: detailData[`fp_name${i}`] || '',
  613. })
  614. // 从原对象中删除这些属性
  615. delete detailData[`fp_lb${i}`]
  616. delete detailData[`fp_sl${i}`]
  617. delete detailData[`fp_gxmc${i}`]
  618. delete detailData[`fp_bz${i}`]
  619. delete detailData[`fp_bh${i}`]
  620. delete detailData[`fp_name${i}`]
  621. }
  622. detailData.table = table
  623. getOrderInfo({ order: detailData.qczl_gdbh }).then(resposne => {
  624. if (resposne.code === 0) {
  625. //循环resposne.data当子项yj_Yjno的值等于obj中的qczl_yjno的值时设置detailData.Gd_cpmc的值为res.data[i].Gd_cpmc
  626. for (let i = 0; i < resposne.data.length; i++) {
  627. if (resposne.data[i].yj_Yjno == detailData.qczl_yjno) {
  628. detailData.yj_yjmc = resposne.data[i].yj_yjmc
  629. detailData.Gd_cpmc = resposne.data[i].Gd_cpmc
  630. }
  631. }
  632. showDialog()
  633. }
  634. })
  635. }
  636. } catch (e) {
  637. console.log(e)
  638. }
  639. }
  640. //日期获得焦点事件
  641. const rqHandleFocus = () => {
  642. if (detailData.qczl_rq == undefined || detailData.qczl_rq == '') {
  643. detailData.qczl_rq = new Date().toISOString().split('T')[0]
  644. }
  645. }
  646. // 工单编号回车
  647. const handleGdbhEnter = async () => {
  648. if (detailData.qczl_gdbh != undefined) {
  649. const res = await getOrderInfo({
  650. order: detailData.qczl_gdbh
  651. })
  652. if (res.code === 0) {
  653. if (res.data.length == 0) {
  654. ElMessage({
  655. type: 'error',
  656. message: '查无此编号的工单,请仔细检查后重新输入'
  657. })
  658. //设置输入框的值为空
  659. detailData.Gd_cpmc = ''
  660. detailData.qczl_yjno = ''
  661. detailData.yj_yjmc = ''
  662. } else if (res.data.length == 1) {
  663. detailData.Gd_cpmc = res.data[0]['Gd_cpmc']
  664. detailData.qczl_yjno = res.data[0]['yj_Yjno']
  665. detailData.yj_yjmc = res.data[0]['yj_yjmc']
  666. } else if (res.data.length > 1) {
  667. selectData_gd.splice(0, selectData_gd.length, ...res.data)
  668. setGXCurrent(selectData_gd[0])
  669. dialogSelectVisible.value = true
  670. }
  671. }
  672. } else {
  673. detailData.Gd_cpmc = ''
  674. detailData.qczl_yjno = ''
  675. detailData.yj_yjmc = ''
  676. }
  677. }
  678. const dialogSelectVisible = ref(false)
  679. const selectData_gd = reactive([])
  680. // 处理选择框
  681. const handleSelectClick_gd = (row, column, event) => {
  682. detailData.Gd_cpmc = row.Gd_cpmc
  683. detailData.qczl_yjno = row.yj_Yjno
  684. detailData.yj_yjmc = row.yj_yjmc
  685. dialogSelectVisible.value = false
  686. }
  687. const currentIndex = ref(0);
  688. const GXCurrent = ref(0);
  689. const selectGX = (event) => {
  690. if (event.keyCode === 40) { // 向下箭头
  691. if (currentIndex.value < selectData_gd.length - 1) {
  692. currentIndex.value++;
  693. setGXCurrent(selectData_gd[currentIndex.value]);
  694. } else {
  695. currentIndex.value = 0;
  696. setGXCurrent(selectData_gd[currentIndex.value]); // 到达最后一行时回到第一行
  697. }
  698. } else if (event.keyCode === 38) { // 向上箭头
  699. if (currentIndex.value > 0) {
  700. currentIndex.value--;
  701. setGXCurrent(selectData_gd[currentIndex.value]);
  702. } else {
  703. currentIndex.value = selectData_gd.length - 1;
  704. setGXCurrent(selectData_gd[currentIndex.value]); // 到达第一行时回到最后一行
  705. }
  706. } else if (event.keyCode === 13) { // 回车键
  707. dialogSelectVisible.value = false;
  708. }
  709. }
  710. const table_gd = ref()
  711. const setGXCurrent = (row) => {
  712. setTimeout(() => {
  713. table_gd.value?.setCurrentRow(row)
  714. detailData.Gd_cpmc = row.Gd_cpmc
  715. detailData.qczl_yjno = row.yj_Yjno
  716. detailData.yj_yjmc = row.yj_yjmc
  717. })
  718. }
  719. const selecTreeData = ref([])
  720. const table_fplb = ref()
  721. // 废品类别回车
  722. const handleFplbEnter = async(index, row) => {
  723. //上个弹窗还未关闭或者值为空
  724. if(dialogSelectVisible2.value || !row.fp_lb){
  725. return
  726. }
  727. let flag = true
  728. //查询废品类别
  729. const res = await getWastInfo()
  730. if (res.code == 0) {
  731. const obj = res.data
  732. const children = []
  733. let i = 0
  734. for (const subCategory in obj.废品分类) {
  735. if (flag && Object.prototype.hasOwnProperty.call(obj.废品分类, subCategory)) {
  736. let j = 0
  737. const subChildren = []
  738. obj.废品分类[subCategory].map(item => {
  739. if(item==row.fp_lb){
  740. flag = false
  741. return
  742. }
  743. subChildren.push({
  744. id: i+'-'+j,
  745. label: item,
  746. children: []
  747. })
  748. j++
  749. })
  750. children.push({
  751. id: i,
  752. label: subCategory,
  753. children: subChildren
  754. })
  755. i++
  756. }
  757. }
  758. if(!flag){
  759. return
  760. }
  761. //渲染数据
  762. selecTreeData.value = children
  763. selectIndex = index
  764. dialogSelectVisible1.value = true
  765. // nextTick(() => {
  766. // // 手动设置选中节点,如果默认选中不生效,可以使用此方法
  767. // if (table_fplb.value) {
  768. // const tree = table_fplb.value?.$el; // 访问组件实例的 $el
  769. // if (tree) {
  770. // const node = tree.querySelector('[data-key="0"]');
  771. // if (node) {
  772. // node.scrollIntoView();
  773. // node.focus(); // 尝试聚焦
  774. // console.log(document.activeElement === node); // 输出检查
  775. // }
  776. // }
  777. // }
  778. // });
  779. }
  780. }
  781. const handleFplbClick = (node, check) => {
  782. console.log(node, check)
  783. if (node.children && node.children.length > 0) {
  784. console.log(11);
  785. } else {
  786. detailData.table[selectIndex].fp_lb = node.label
  787. dialogSelectVisible1.value = false
  788. }
  789. }
  790. let selectData = [] // 将const改为let
  791. const handleFpslEnter = async (index, row) => {
  792. selectIndex = index
  793. if(dialogSelectVisible1.value){
  794. return
  795. }
  796. if (row.fp_sl == '0' || row.fp_sl == '') {
  797. detailData.table[index].fp_gxmc = ''
  798. detailData.table[index].fp_bz = ''
  799. detailData.table[index].fp_bh = ''
  800. detailData.table[index].fp_name = ''
  801. return
  802. }
  803. //计算总数
  804. let total = 0;
  805. detailData.table.forEach((item, index) => {
  806. if(item.fp_sl != 0 || item.fp_sl != ''){
  807. total += parseInt(item.fp_sl);
  808. }
  809. });
  810. detailData.qczl_fp = total
  811. const params = {
  812. type: row.fp_lb,
  813. order: detailData.qczl_gdbh,
  814. yjno: detailData.qczl_yjno,
  815. }
  816. let res
  817. try {
  818. res = await getGxAndLeader(params)
  819. if (res.code !== 0) {
  820. return
  821. }
  822. } catch (e) {
  823. console.log(e)
  824. return
  825. }
  826. // 解译乱码并填充到selectData
  827. const decodedData = res.data.map(item => {
  828. return {
  829. sczl_gxmc: decodeEntities(item.sczl_gxmc), // 解译乱码函数
  830. sczl_bzdh: item.sczl_bzdh,
  831. sczl_jtbbh: item.sczl_jtbh,
  832. sczl_bh1: item.sczl_bh1,
  833. name: item.name.trim() // 去除姓名两端的空格
  834. }
  835. })
  836. selectData = decodedData // 对selectData进行赋值
  837. setCurrent(selectData[0])
  838. dialogSelectVisible2.value = true
  839. }
  840. // 解译HTML实体编码的函数
  841. function decodeEntities(encodedString) {
  842. const textArea = document.createElement('textarea')
  843. textArea.innerHTML = encodedString
  844. return textArea.value
  845. }
  846. // 双击表格操作
  847. function doubleClick(row, column, event) {
  848. type.value = '查改'
  849. getDetailData(row.UniqId)
  850. }
  851. // 处理选择框回车操作
  852. const handleSelectClick = (row, column, event) => {
  853. const {
  854. sczl_gxmc,
  855. sczl_bzdh,
  856. sczl_bh1,
  857. name
  858. } = row
  859. const index = selectIndex
  860. console.log(index);
  861. detailData.table[index].fp_gxmc = sczl_gxmc
  862. detailData.table[index].fp_bz = sczl_bzdh
  863. detailData.table[index].fp_bh = sczl_bh1
  864. detailData.table[index].fp_name = name
  865. dialogSelectVisible2.value = false
  866. }
  867. const table2 = ref()
  868. const setCurrent = (row) => {
  869. setTimeout(() => {
  870. table2.value?.setCurrentRow(row)
  871. // SelectClick(row)
  872. // console.log(row)
  873. // console.log(table)
  874. const {
  875. sczl_gxmc,
  876. sczl_bzdh,
  877. sczl_bh1,
  878. name
  879. } = row
  880. const index = selectIndex
  881. detailData.table[index].fp_gxmc = sczl_gxmc
  882. detailData.table[index].fp_bz = sczl_bzdh
  883. detailData.table[index].fp_bh = sczl_bh1
  884. detailData.table[index].fp_name = name
  885. })
  886. }
  887. const SLIndex = ref(0);
  888. const JYCurrent = ref(0);
  889. const selectSL = (event) => {
  890. if (event.keyCode === 40) { // 向下箭头
  891. if (SLIndex.value < selectData.length - 1) {
  892. SLIndex.value++;
  893. setCurrent(selectData[SLIndex.value]);
  894. } else {
  895. SLIndex.value = 0;
  896. setCurrent(selectData[SLIndex.value]); // 到达最后一行时回到第一行
  897. }
  898. } else if (event.keyCode === 38) { // 向上箭头
  899. if (SLIndex.value > 0) {
  900. SLIndex.value--;
  901. setCurrent(selectData[SLIndex.value]);
  902. } else {
  903. SLIndex.value = selectData.length - 1;
  904. setCurrent(selectData[SLIndex.value]); // 到达第一行时回到最后一行
  905. }
  906. } else if (event.keyCode === 13) { // 回车键
  907. dialogSelectVisible2.value = false
  908. }
  909. }
  910. // 弹窗确定
  911. const enterDialog = async () => {
  912. if (type.value === '查改') {
  913. updateDetailData()
  914. } else if (type.value === '新增') {
  915. addDetailData()
  916. }
  917. }
  918. const addDetailData = async () => {
  919. const formatDate = (date) => {
  920. const year = date.getFullYear();
  921. const month = String(date.getMonth() + 1).padStart(2, '0');
  922. const day = String(date.getDate()).padStart(2, '0');
  923. return `${year}-${month}-${day}`;
  924. };
  925. const restoredData = {
  926. UniqId: detailData.UniqId,
  927. qczl_gdbh: detailData.qczl_gdbh,
  928. qczl_yjno: detailData.qczl_yjno,
  929. qczl_gxh: detailData.qczl_gxh,
  930. qczl_gxmc: detailData.qczl_gxmc,
  931. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  932. qczl_fp: detailData.qczl_fp,
  933. qczl_num: detailData.qczl_num,
  934. qczl_NumDesc: detailData.qczl_NumDesc,
  935. qczl_NumDesc1: detailData.qczl_NumDesc1,
  936. qczl_NumDesc2: detailData.qczl_NumDesc2,
  937. qczl_NumDesc3: detailData.qczl_NumDesc3,
  938. qczl_NumDesc4: detailData.qczl_NumDesc4,
  939. qczl_NumDesc5: detailData.qczl_NumDesc5,
  940. qczl_NumDesc6: detailData.qczl_NumDesc6,
  941. qczl_NumDesc7: detailData.qczl_NumDesc7,
  942. qczl_NumDesc8: detailData.qczl_NumDesc8,
  943. sys_id: sys_id
  944. };
  945. detailData.table.forEach((item, index) => {
  946. const num = index + 1;
  947. restoredData[`fp_lb${num}`] = item.fp_lb;
  948. restoredData[`fp_sl${num}`] = item.fp_sl;
  949. restoredData[`fp_bh${num}`] = item.fp_bh;
  950. restoredData[`fp_bz${num}`] = item.fp_bz;
  951. restoredData[`fp_gxmc${num}`] = item.fp_gxmc;
  952. });
  953. console.log(restoredData);
  954. const res = await add(restoredData)
  955. console.log(res)
  956. if (res.code === 0) {
  957. ElMessage({
  958. type: 'success',
  959. message: '新增成功',
  960. })
  961. //刷新
  962. if (params.date != '') {
  963. getTableData()
  964. }
  965. getSideData()
  966. dialogFormVisible.value = false
  967. }
  968. };
  969. // 修改
  970. const updateDetailData = async () => {
  971. const formatDate = (date) => {
  972. const year = date.getFullYear();
  973. const month = String(date.getMonth() + 1).padStart(2, '0');
  974. const day = String(date.getDate()).padStart(2, '0');
  975. return `${year}-${month}-${day}`;
  976. };
  977. const restoredData = {
  978. UniqId: detailData.UniqId,
  979. qczl_gdbh: detailData.qczl_gdbh,
  980. qczl_yjno: detailData.qczl_yjno,
  981. qczl_gxh: detailData.qczl_gxh,
  982. qczl_gxmc: detailData.qczl_gxmc,
  983. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  984. qczl_fp: detailData.qczl_fp,
  985. qczl_num: detailData.qczl_num,
  986. qczl_NumDesc: detailData.qczl_NumDesc,
  987. qczl_NumDesc1: detailData.qczl_NumDesc1,
  988. qczl_NumDesc2: detailData.qczl_NumDesc2,
  989. qczl_NumDesc3: detailData.qczl_NumDesc3,
  990. qczl_NumDesc4: detailData.qczl_NumDesc4,
  991. qczl_NumDesc5: detailData.qczl_NumDesc5,
  992. qczl_NumDesc6: detailData.qczl_NumDesc6,
  993. qczl_NumDesc7: detailData.qczl_NumDesc7,
  994. qczl_NumDesc8: detailData.qczl_NumDesc8,
  995. }
  996. detailData.table.forEach((item, index) => {
  997. const num = index + 1
  998. restoredData[`fp_lb${num}`] = item.fp_lb
  999. restoredData[`fp_sl${num}`] = item.fp_sl
  1000. restoredData[`fp_bh${num}`] = item.fp_bh
  1001. restoredData[`fp_bz${num}`] = item.fp_bz
  1002. restoredData[`fp_gxmc${num}`] = item.fp_gxmc
  1003. })
  1004. const res = await updateData(restoredData)
  1005. if (res.code === 0) {
  1006. ElMessage({
  1007. type: 'success',
  1008. message: res.msg,
  1009. })
  1010. dialogFormVisible.value = false
  1011. }
  1012. }
  1013. // 多选
  1014. const handleSelectionChange = (val) => {
  1015. multipleSelection.value = val
  1016. }
  1017. // 多选删除
  1018. const onDelete = async () => {
  1019. const ids = []
  1020. if (multipleSelection.value.length === 0) {
  1021. ElMessage({
  1022. type: 'warning',
  1023. message: '请选择要删除的数据'
  1024. })
  1025. return
  1026. }
  1027. multipleSelection.value &&
  1028. multipleSelection.value.map(item => {
  1029. ids.push(item.ID)
  1030. })
  1031. const res = await deleteCompanyByIds({
  1032. ids
  1033. })
  1034. if (res.code === 0) {
  1035. ElMessage({
  1036. type: 'success',
  1037. message: '删除成功'
  1038. })
  1039. if (tableData.value.length === ids.length && page.value > 1) {
  1040. page.value--
  1041. }
  1042. deleteVisible.value = false
  1043. getTableData()
  1044. }
  1045. }
  1046. // 更新行
  1047. const updateCompanyFunc = async (row) => {
  1048. const res = await findCompany({
  1049. ID: row.ID
  1050. })
  1051. type.value = 'update'
  1052. if (res.code === 0) {
  1053. formData.value = res.data.recompany
  1054. // dialogFormVisible.value = true
  1055. showDialog()
  1056. }
  1057. }
  1058. // 关闭弹窗
  1059. const closeDialog = () => {
  1060. dialogFormVisible.value = false
  1061. }
  1062. // 导出excel
  1063. function exportExcel() {
  1064. console.log('导出到excel')
  1065. // dialogSbyxgl.value = true
  1066. }
  1067. const dialogMrhjtj = ref(false)
  1068. const dialogGdzjfptj = ref(false)
  1069. const dialogSbyxgl = ref(false)
  1070. const dialoglcdcx = ref(false)
  1071. const value1 = ref('')
  1072. const table = ref(null)
  1073. const showGdzjfptj = () => {
  1074. value1.value = currentRow.gdbh
  1075. dialogGdzjfptj.value = true
  1076. }
  1077. const currentRow = ref()
  1078. const handleSelectChange = (row, column, event) => {
  1079. currentRow.value = row.UniqId
  1080. currentRow.gdbh = row.qczl_gdbh
  1081. console.log(currentRow.gdbh)
  1082. }
  1083. // 新增数据
  1084. const handleShowAdd = async () => {
  1085. type.value = '新增'
  1086. if (currentRow.value == undefined) {
  1087. // 循环13行数据
  1088. const table = []
  1089. for (let i = 1; i <= 13; i++) {
  1090. table.push({
  1091. fp_lb: '',
  1092. fp_sl: '',
  1093. fp_gxmc: '',
  1094. fp_bz: '',
  1095. fp_bh: '',
  1096. fp_name: '',
  1097. })
  1098. }
  1099. detailData.table = table
  1100. dialogFormVisible.value = true
  1101. } else {
  1102. getOneWorkOrder({ UniqId: currentRow.value }).then(res => {
  1103. if (res.code === 0) {
  1104. const obj = res.data
  1105. // 裁剪返回数据的前后空格
  1106. for (const key in obj) {
  1107. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  1108. obj[key] = obj[key].trim()
  1109. }
  1110. }
  1111. // 修改日期格式
  1112. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  1113. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  1114. }
  1115. obj['qczl_num'] = '0'
  1116. obj['qczl_NumDesc1'] = '0'
  1117. obj['qczl_NumDesc2'] = '0'
  1118. obj['qczl_NumDesc3'] = '0'
  1119. obj['qczl_NumDesc4'] = '0'
  1120. obj['qczl_NumDesc5'] = '0'
  1121. obj['qczl_NumDesc6'] = '0'
  1122. obj['qczl_NumDesc7'] = '0'
  1123. obj['qczl_NumDesc8'] = '0'
  1124. obj['qczl_fp'] = ''
  1125. Object.assign(detailData, obj)
  1126. const table = []
  1127. // 循环13行数据
  1128. for (let i = 1; i <= 13; i++) {
  1129. table.push({
  1130. fp_lb: detailData[`fp_lb${i}`] || '',
  1131. fp_sl: 0,
  1132. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  1133. fp_bz: detailData[`fp_bz${i}`] || '',
  1134. fp_bh: detailData[`fp_bh${i}`] || '',
  1135. fp_name: detailData[`fp_name${i}`] || '',
  1136. })
  1137. // 从原对象中删除这些属性
  1138. delete detailData[`fp_lb${i}`]
  1139. delete detailData[`fp_sl${i}`]
  1140. delete detailData[`fp_gxmc${i}`]
  1141. delete detailData[`fp_bz${i}`]
  1142. delete detailData[`fp_bh${i}`]
  1143. delete detailData[`fp_name${i}`]
  1144. }
  1145. detailData.table = table
  1146. getOrderInfo({ order: detailData.qczl_gdbh }).then(resposne => {
  1147. if (resposne.code === 0) {
  1148. //循环resposne.data当子项yj_Yjno的值等于obj中的qczl_yjno的值时设置detailData.Gd_cpmc的值为res.data[i].Gd_cpmc
  1149. for (let i = 0; i < resposne.data.length; i++) {
  1150. if (resposne.data[i].yj_Yjno == detailData.qczl_yjno) {
  1151. detailData.yj_yjmc = resposne.data[i].yj_yjmc
  1152. detailData.Gd_cpmc = resposne.data[i].Gd_cpmc
  1153. }
  1154. }
  1155. showDialog()
  1156. }
  1157. })
  1158. }
  1159. })
  1160. }
  1161. // type.value='add'
  1162. // Object.assign(detailData);
  1163. // dialogFormVisible.value = true
  1164. }
  1165. // 开启弹窗
  1166. const showDialog = () => {
  1167. dialogFormVisible.value = true
  1168. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  1169. // setTimeout(() => {
  1170. // formElements = document.getElementById('detail-form').elements
  1171. // formElements[0].focus()
  1172. // }, 0)
  1173. }
  1174. //
  1175. const ent = (event) => {
  1176. if(document.activeElement.id=='tableFplb'){
  1177. if (table_fplb.value) {
  1178. const tree = table_fplb.value?.$el; // 访问组件实例的 $el
  1179. if (tree) {
  1180. const node = tree.querySelector('[data-key="0"]');
  1181. if (node) {
  1182. node.scrollIntoView();
  1183. node.focus(); // 尝试聚焦}
  1184. }
  1185. }
  1186. }
  1187. }
  1188. }
  1189. const ent1 = (event) => {
  1190. const inputs = document.getElementsByTagName('input');
  1191. const currentIndex = Array.from(inputs).indexOf(event.target);
  1192. if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
  1193. let nextIndex = currentIndex + 1;
  1194. while (nextIndex < inputs.length) {
  1195. if (inputs[nextIndex].disabled) {
  1196. console.log("当前输入框为disabled,跳过");
  1197. nextIndex++; // 跳过disabled的输入框
  1198. continue;
  1199. }
  1200. if (!inputs[nextIndex].readOnly) {
  1201. nextTick(() => {
  1202. inputs[nextIndex].focus();
  1203. inputs[nextIndex].select();
  1204. });
  1205. break;
  1206. }
  1207. nextIndex++;
  1208. }
  1209. }
  1210. else if (event.keyCode === 38) { // 向上箭头
  1211. for (let i = currentIndex - 1; i >= 0; i--) {
  1212. if (!inputs[i].readOnly) {
  1213. nextTick(()=>{
  1214. inputs[i].focus();
  1215. inputs[i].select();
  1216. })
  1217. break;
  1218. }
  1219. }
  1220. } else if (event.keyCode === 8) { // 删除箭头
  1221. if (event.target.selectionStart === 0) {
  1222. for (let i = currentIndex - 1; i >= 0; i--) {
  1223. if (!inputs[i].readOnly) {
  1224. nextTick(()=>{
  1225. inputs[i].focus();
  1226. inputs[i].setSelectionRange(0, 0);
  1227. })
  1228. break;
  1229. }
  1230. }
  1231. }
  1232. } else if (event.keyCode === 37) { // 向左箭头
  1233. if (event.target.selectionStart === 0) {
  1234. for (let i = currentIndex - 1; i >= 0; i--) {
  1235. if (!inputs[i].readOnly) {
  1236. nextTick(()=>{
  1237. inputs[i].focus();
  1238. inputs[i].select();
  1239. })
  1240. break;
  1241. }
  1242. }
  1243. }
  1244. } else if (event.keyCode === 39) { // 向右箭头
  1245. if (event.target.selectionStart === event.target.value.length) {
  1246. for (let i = currentIndex + 1; i < inputs.length; i++) {
  1247. if (!inputs[i].readOnly) {
  1248. nextTick(()=>{
  1249. inputs[i].focus();
  1250. inputs[i].select();
  1251. })
  1252. break;
  1253. }
  1254. }
  1255. }
  1256. }
  1257. }
  1258. // let formElements
  1259. // const moveFocus = (event) => {
  1260. // const index = Array.from(formElements).indexOf(event.target)
  1261. // const key = event.key
  1262. // event.preventDefault()
  1263. // switch (index) {
  1264. // case 0:
  1265. // if (key === 'ArrowDown') {
  1266. // formElements[1].focus()
  1267. // formElements[1].select();
  1268. // } else if (key === 'ArrowUp') {
  1269. // formElements[formElements.length - 1].focus()
  1270. // } else if (key === 'Enter') {
  1271. // formElements[1].focus()
  1272. // formElements[1].select();
  1273. // }
  1274. // break
  1275. // case formElements.length - 1 :
  1276. // if (key === 'ArrowDown') {
  1277. // formElements[0].focus()
  1278. // formElements[0].select();
  1279. // } else if (key === 'ArrowUp') {
  1280. // formElements[index - 1].focus()
  1281. // } else if (key === 'Enter') {
  1282. // formElements[0].focus()
  1283. // formElements[0].select();
  1284. // }
  1285. // break
  1286. // default:
  1287. // if (key === 'ArrowDown') {
  1288. // formElements[index + 1].focus()
  1289. // formElements[index + 1].select();
  1290. // } else if (key === 'ArrowUp') {
  1291. // formElements[index - 1].focus()
  1292. // formElements[index + 1].select();
  1293. // } else if (key === 'Enter') {
  1294. // formElements[index + 1].focus()
  1295. // formElements[index + 1].select();
  1296. // }
  1297. // break
  1298. // }
  1299. // }
  1300. // 删除
  1301. const handleDelete = () => {
  1302. if (currentRow.value == undefined) {
  1303. ElMessage({
  1304. type: 'warning',
  1305. message: '未选中记录',
  1306. })
  1307. return
  1308. }
  1309. ElMessageBox.confirm(
  1310. `确认删除这条数据么?`,
  1311. '警告', {
  1312. confirmButtonText: '确认',
  1313. cancelButtonText: '取消',
  1314. type: 'warning',
  1315. }
  1316. ).then(() => {
  1317. del({'UniqId': currentRow.value}).then(res => {
  1318. if (res.code === 0) {
  1319. ElMessage({
  1320. type: 'success',
  1321. message: '删除成功',
  1322. })
  1323. currentRow.value = undefined
  1324. getSideData()
  1325. getTableData()
  1326. }
  1327. })
  1328. }).catch(() => {
  1329. ElMessage({
  1330. type: 'info',
  1331. message: '取消删除',
  1332. })
  1333. })
  1334. }
  1335. </script>
  1336. <style scoped>
  1337. .JKWTree-container {
  1338. display: flex;
  1339. }
  1340. .JKWTree-tree {
  1341. width: 100%;
  1342. background-color: #fff;
  1343. padding: 10px;
  1344. margin-right: 20px;
  1345. }
  1346. .JKWTree-tree h3 {
  1347. font-size: 15px;
  1348. font-weight: 700;
  1349. margin: 10px 0;
  1350. }
  1351. .JKWTree-content {
  1352. flex: 1;
  1353. }
  1354. .bt {
  1355. margin-left: 2px !important;
  1356. padding: 3px !important;
  1357. font-size: 12px;
  1358. }
  1359. /* 选中某行时的背景色 */
  1360. :deep(.el-table__body tr.current-row)>td {
  1361. background: #ff80ff !important;
  1362. }
  1363. .mab {
  1364. margin-bottom: 5px;
  1365. }
  1366. </style>