index.vue 46 KB

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