index.vue 46 KB

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