baozhuangbaogong.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <div>
  3. <layout>
  4. <layout-content >
  5. <!-- <el-main> -->
  6. <div class="gva-table-box">
  7. <h1 id="title" style="margin: 0%;margin-bottom: 10px;">包装报工</h1>
  8. <el-row :gutter="24" style="margin-bottom: 0px;">
  9. <el-input v-model="add_searchInfo" placeholder="请扫描子订单编号" @keyup.enter="add_onSubmit" id="searchInput"
  10. style="width: 280px;height: 50px;margin-left: 10px;"></el-input>
  11. <el-button type="primary" icon="search" @click="add_onSubmit" style="height: 50px;width: 60px;">查询</el-button>
  12. <el-form-item label="机台号:" prop="jitaihao" class="mab" style="font-size: 30px;margin: 10px;" label-width="116px">
  13. <el-input v-model="add_formData['机台号']" readonly style="width: 100px; height: 40px;" id="jitaihao" />
  14. </el-form-item>
  15. <el-form-item label="工序:" prop="gongxu" class="mab" style="font-size: 30px; margin: 10px;" label-width="81px">
  16. <el-input v-model="add_formData['工序']" readonly style="width: 100px; height: 40px;" id="gongxu" />
  17. </el-form-item>
  18. <el-form-item label="组别:" prop="zubie" class="mab" style="font-size: 30px; margin: 10px;" label-width="81px">
  19. <el-input v-model="add_formData['组别']" readonly style="width: 140px; height: 40px;" id="zubie" />
  20. </el-form-item>
  21. <el-form-item label="人员:" prop="renyuan" class="mab" style="font-size: 30px; margin: 10px;" label-width="81px">
  22. <el-input v-model="add_formData['人员']" readonly style="width: 110px; height: 40px;" id="renyuan" />
  23. </el-form-item>
  24. </el-row>
  25. <el-row :gutter="24">
  26. <el-form-item label="尺码:" prop="chima" class="mab" style="font-size: 30px;margin: 10px;" label-width="90">
  27. <el-input v-model="add_formData['尺码']" readonly style="width: 110px;height: 40px;" id="chima" />
  28. </el-form-item>
  29. <el-form-item label="数量:" prop="shuliang" class="mab" style="font-size: 30px;margin: 10px;" label-width="90">
  30. <el-input v-model="add_formData['数量']" readonly style="width: 110px;height: 40px;" id="shuliang" />
  31. </el-form-item>
  32. <el-form-item label="上报数量:" prop="sbsl" class="mab" style="font-size: 30px;margin: 10px;" label-width="150">
  33. <el-input v-model="add_formData['上报数量']" @input="baogongslpd" style="width: 110px;height: 40px;" id="sbsl" />
  34. </el-form-item>
  35. <el-form-item label="是否尾包:" prop="joinDate" style="font-size: 30px; margin: 10px;" label-width="150">
  36. <!-- 假设 activeButtonValue 是从后端或某个方法获取的,这里直接硬编码为 0 或 1 -->
  37. <div :class="{'info-button': activeButtonValue === '1', 'default-button': activeButtonValue !== '1'}"
  38. style="margin-top:-20px; margin-right:15px; height: 50px; width: 70px;
  39. display: flex; justify-content: center; align-items: center; cursor: not-allowed; border: 1px solid #ccc;
  40. border-radius: 4px; color: #000000; font-size: 24px;"
  41. :style="{ backgroundColor: activeButtonValue === '1' ? '#ff0000' : '#808080' }">是</div>
  42. <div :class="{'info-button': activeButtonValue === '0', 'default-button': activeButtonValue !== '0'}"
  43. style="margin-top:-20px; height: 50px; width: 70px;
  44. display: flex; justify-content: center; align-items: center; cursor: not-allowed; border: 1px solid #ccc;
  45. border-radius: 4px; color: #000000; font-size: 24px;"
  46. :style="{ backgroundColor: activeButtonValue === '0' ? '#ff0000' : '#808080' }">否</div>
  47. </el-form-item>
  48. </el-row>
  49. <el-row :gutter="24" style="margin-bottom: 15px;margin-left: 0px;">
  50. <div @contextmenu.prevent>
  51. <el-table ref="multipleTableRef" style="width: 100%;height: 53vh"
  52. :row-style="{ height: '50px' }" :header-cell-style="{ padding: '5px', fontSize: '20px' }"
  53. :cell-style="{ padding: '10px', fontSize: '20px' }" :header-row-style="{ height: '20px' }"
  54. :data="add_tableData" border row-key="ID" size="small"
  55. highlight-current-row="true" tooltip-effect="dark"
  56. @row-dblclick="add_updateCompanyFunc" @row-click="add_tableRowClick" @row-contextmenu="handleRightClick"
  57. :show-overflow-tooltip="true" @selection-change="add_xpSelectionChange">
  58. <el-table-column type="selection" width="70" />
  59. <el-table-column sortable align="left" label="订单编号" prop="订单编号" width="140"/>
  60. <el-table-column sortable align="left" label="订单子编号" prop="子订单编号" width="140"/>
  61. <el-table-column sortable align="left" label="生产款号" prop="款号" width="140"/>
  62. <el-table-column sortable align="left" label="款式" prop="款式" width="140"/>
  63. <el-table-column sortable align="left" label="色系名称" prop="颜色" width="140"/>
  64. <el-table-column sortable align="left" label="尺码" prop="尺码" width="140"/>
  65. <el-table-column sortable align="left" label="数量" prop="数量" width="140"/>
  66. <el-table-column sortable align="left" label="是否尾包" prop="尾包" width="140"/>
  67. <el-table-column sortable align="left" label="组别" prop="组别" width="140"/>
  68. </el-table>
  69. </div>
  70. </el-row>
  71. <div class="dialog-footer" style="text-align: left;margin-right: 60px;">
  72. <el-button type="primary" @click="add_Dialog" id="add_Dialog" :disabled="add_Dialogonclick === false" style="width: 110px;height: 60px;font-size: 20px;">确认</el-button>
  73. </div>
  74. </div>
  75. <!-- </el-main> -->
  76. </layout-content>
  77. </layout>
  78. </div>
  79. </template>
  80. <script>
  81. export default {
  82. methods: {
  83. handleKeyDown(event, prevId, currentId, nextId) {
  84. const currentElement = document.getElementById(currentId);
  85. const isEmpty = currentElement.value === '';
  86. const atStart = currentElement.selectionStart === 0;
  87. const atEnd = currentElement.selectionStart === currentElement.value.length;
  88. switch (event.keyCode) {
  89. case 13: // Enter
  90. case 40: // 向下箭头
  91. if (nextId) {
  92. document.getElementById(nextId).focus();
  93. }
  94. break;
  95. case 38: // 向上箭头
  96. if (prevId) {
  97. document.getElementById(prevId).focus();
  98. }
  99. break;
  100. case 8: // 删除键
  101. if (prevId && (isEmpty || atStart)) {
  102. document.getElementById(prevId).focus();
  103. }
  104. break;
  105. case 37: // 向左箭头
  106. if (prevId && atStart) {
  107. document.getElementById(prevId).focus();
  108. }
  109. break;
  110. case 39: // 向右箭头
  111. if (nextId && atEnd) {
  112. document.getElementById(nextId).focus();
  113. }
  114. break;
  115. default:
  116. break;
  117. }
  118. },
  119. },
  120. };
  121. </script>
  122. <script setup>
  123. // 全量引入格式化工具 请按需保留
  124. import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
  125. import {hiprint} from "vue-plugin-hiprint";
  126. import {ref, reactive,nextTick,watch, setBlockTracking } from 'vue'
  127. import {getSpotList,search,getMachineMac,getTab} from '@/api/mes/job'
  128. import {ElMessage} from "element-plus";
  129. import { get } from 'scriptjs';
  130. defineOptions({name: 'Company'})
  131. // =========== 全局获取当前日期 ===========
  132. // currentDate 年月日 时分秒
  133. // currentDates 年月日
  134. const today = new Date();
  135. const year = today.getFullYear();
  136. const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要补零
  137. const day = String(today.getDate()).padStart(2, '0');
  138. const hours = String(today.getHours()).padStart(2, '0');
  139. const minutes = String(today.getMinutes()).padStart(2, '0');
  140. const seconds = String(today.getSeconds()).padStart(2, '0');
  141. const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  142. const currentDates = `${year}-${month}-${day}`;
  143. //全局调用
  144. const _Machine = '68-ED-A4-26-5F-38'
  145. const _code = '包装'
  146. const _gx = '7'
  147. const _gxmc = "包装"
  148. //物理地址获取机台编号
  149. const getMachineMacdata = async () => {
  150. try {
  151. const data = await getMachineMac({sys_sbID:_Machine,code:_code});
  152. add_formData['机台号'] = data.data['机台号']
  153. add_formData['工序'] = data.data['生产工序']
  154. add_formData['组别'] = data.data['组别']
  155. add_formData['人员'] = data.data['组长']
  156. setTimeout(() => {
  157. const inputElement = document.getElementById('searchInput');
  158. if (inputElement) {
  159. inputElement.focus();
  160. }
  161. }, 100); // 延迟100毫秒
  162. } catch (error) {
  163. console.error(error)
  164. }
  165. }
  166. getMachineMacdata();
  167. const UniqId = ref('')
  168. //搜索
  169. const add_searchInfo = ref('')
  170. //表格
  171. const add_tableData = reactive([]);
  172. //尾包选中值
  173. const activeButtonValue = ref('')
  174. //代表扫描两次自动保存
  175. const searcs = ref('')
  176. const _order = ref('')
  177. //查询询钮
  178. const add_onSubmit = async ()=>{
  179. if(add_searchInfo.value === '' || add_searchInfo.value === undefined){
  180. const WorkListdata = [];
  181. add_tableData.splice(0,add_tableData.length,...WorkListdata);
  182. ElMessage({type: 'warning',message: '请扫描小票二维码' })
  183. }else{
  184. if(searcs.value === ''){
  185. _order.value = add_searchInfo.value;
  186. const sys_sbID = add_formData['机台号']
  187. //获取下面报工历史记录
  188. const getSpotLists = await getSpotList({order:add_searchInfo.value,code:_code,sys_sbID:sys_sbID});
  189. activeButtonValue.value = getSpotLists.data.result.wb
  190. UniqId.value = getSpotLists.data.result.UniqId
  191. add_formData['数量'] = getSpotLists.data.result.sl
  192. add_formData['尺码'] = getSpotLists.data.result.cm
  193. add_tableData.splice(0,add_tableData.length,...getSpotLists.data.records);
  194. searcs.value = 1;
  195. add_searchInfo.value = ''
  196. setTimeout(() => {
  197. const inputElement = document.getElementById('sbsl');
  198. if (inputElement) {
  199. inputElement.focus();
  200. }
  201. }, 100); // 延迟100毫秒
  202. }else{
  203. add_Dialog();
  204. }
  205. }
  206. }
  207. const AttendanceVisible=ref(false)
  208. //清空对象的属性值
  209. const gd_clearFormData = () => {
  210. Object.keys(add_formData).forEach(key => {
  211. add_formData[key] = '';
  212. });
  213. };
  214. const add_formData = reactive({
  215. 机台号: '',
  216. 工序: '',
  217. 组别: '',
  218. 人员: '',
  219. 尺码: '',
  220. 数量: '',
  221. 上报数量:'',
  222. 是否订单尾包: '',
  223. });
  224. const add_Dialogonclick = ref(false)
  225. function baogongslpd() {
  226. // 将字符串转换为数字
  227. const reportedQuantity = parseInt(add_formData['上报数量'], 10) || 0; // 使用10作为基数表示十进制,如果转换失败则返回0
  228. const totalQuantity = parseInt(add_formData['数量'], 10) || 0; // 同样处理
  229. if (reportedQuantity > totalQuantity) {
  230. ElMessage({ type: 'warning', message: '上报数量不能大于数量' });
  231. add_Dialogonclick.value = false;
  232. } else {
  233. add_Dialogonclick.value = true;
  234. }
  235. }
  236. const currentSlValue=ref('')
  237. //后道确认按钮
  238. const add_Dialog = async ()=>{
  239. if(_order.value === ''){
  240. ElMessage({type: 'warning',message: '请重新扫描小票二维码'})
  241. }else{
  242. console.log(_order.value.split(',')[0])
  243. let params ={}
  244. params.code = _code
  245. params.order = _order.value.split(',')[0].split('-')[0]
  246. params.order_id = _order.value.split(',')[0]
  247. params.gx = _gx
  248. params.gxmc = _gxmc
  249. params.cm = _order.value.split(',')[3]
  250. params.sl = _order.value.split(',')[4]
  251. params.sczl_jtbh = add_formData['机台号']
  252. params.sczl_bh = add_formData['组别']
  253. params.wb = _order.value.split(',')[5]
  254. params.sys_id = add_formData['人员']
  255. params.UniqId = UniqId.value
  256. params.num = add_formData['上报数量']
  257. console.log(params)
  258. // return false;
  259. const cf_gettab = await search(params); // 调用search函数
  260. if (cf_gettab.code === 0) {
  261. const firstPart = add_searchInfo.value.split(',')[0];
  262. const lsjltable = await getTab({order_id:firstPart,sczl_jtbh:add_formData['机台号']});
  263. console.log(lsjltable)
  264. add_tableData.splice(0,add_tableData.length,...lsjltable.data.records);
  265. add_searchInfo.value = '';
  266. setTimeout(() => {
  267. const inputElement = document.getElementById('searchInput');
  268. if (inputElement) {
  269. inputElement.focus();
  270. }
  271. }, 100); // 延迟100毫秒
  272. searcs.value = '';
  273. add_formData['尺码']=''
  274. add_formData['数量']=''
  275. add_formData['上报数量']=''
  276. ElMessage({type: 'success', message: '报工成功'});
  277. }
  278. }
  279. }
  280. //单机
  281. const add_tableRowClick = async (row) => {
  282. roww.value = row
  283. }
  284. //双击
  285. const add_updateCompanyFunc = async (row) => {
  286. }
  287. //右键
  288. const handleRightClick = async (row) => {
  289. }
  290. //复选框
  291. const add_xpSelectionChange = async (selection) => {
  292. console.log(selection.length)
  293. selectedRows.value = selection;
  294. if (selection.length === 0) {
  295. ElMessage({type: 'warning', message: '请勾选打印的数据' });
  296. return false;
  297. }else if(selection.length>0){
  298. allPrintData.value = selection.map((row) => {
  299. let weibao = row['是否尾包'] === '是' ? 1 : 0;
  300. const ewm = `${row['订单子编号']},01,${row['尺码']},${row['数量']},${weibao}`;
  301. return {
  302. emm: ewm,
  303. zddbh: row['子订单编号'],
  304. kh: row['款号'],
  305. pm: row['款式'],
  306. ys: row['颜色'],
  307. cm: row['尺码'],
  308. sl: row['数量'],
  309. zb: row['组别'],
  310. dyrq: currentDates,
  311. wb: row['尾包']
  312. };
  313. });
  314. }else{
  315. allPrintData.value = [];
  316. }
  317. console.log(allPrintData.value)
  318. }
  319. // =========== 删除按钮 ===========
  320. //记录复选框的值
  321. const bgSelection = ref(null)
  322. const baogong_del = () => {
  323. if(bgSelection.value === null || bgSelection.value === ''){
  324. ElMessage({type: 'warning',message: '请选择删除的数据' })
  325. }else{
  326. console.log(bgSelection.value)
  327. }
  328. }
  329. // 保存当前选中的行数据
  330. const table_selectrows = ref([]);
  331. // 表格复选框选中变化时触发
  332. const table_SelectionChange = (val) => {
  333. table_selectrows.value = val; // 将选中的行数据保存到 table_selectrows
  334. }
  335. // =========== 分页 ===========
  336. // 分页相关的响应式变量
  337. const page = ref(1)
  338. const total = ref(0)
  339. const pageSize = ref(10)
  340. // 分页
  341. const handleCurrentChange = (val) => {
  342. page.value = val;
  343. _getStaffList();
  344. };
  345. // 修改页面容量 点击多少条/页
  346. const handleSizeChange = (val) => {
  347. page.value = 10;//默认显示
  348. pageSize.value = val;
  349. _getStaffList();
  350. };
  351. </script>
  352. <style scoped>
  353. .form-container {
  354. display: flex;
  355. flex-wrap: wrap;
  356. }
  357. .form-column {
  358. /*flex: 1;*/
  359. margin-right: 15px; /* 调整列之间的间距 */
  360. }
  361. /* 左侧输入框宽度调整 */
  362. .form-column .el-form-item .el-input {
  363. width: 150px; /* 调整左侧输入框的宽度 */
  364. }
  365. /* 媒体查询,根据需要调整断点 */
  366. @media screen and (max-width: 768px) {
  367. .form-column {
  368. flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
  369. margin-right: 0;
  370. }
  371. }
  372. /* 表格复选框大小调整 */
  373. :deep(.el-checkbox.el-checkbox--small .el-checkbox__inner) {
  374. width: 30px; /* 复选框宽度 */
  375. height: 20px; /* 复选框高度 */
  376. }
  377. :deep(.el-checkbox.el-checkbox--small.is-checked .el-checkbox__inner::after) {
  378. transform: scale(1.2) rotate(45deg); /* 调整选中后的对勾大小 */
  379. top: 5%; /* 调整对勾位置 */
  380. left: 40%; /* 调整对勾位置 */
  381. width: 5px; /* 调整对勾宽度 */
  382. height: 9px; /* 调整对勾高度 */
  383. }
  384. /*:deep(.el-table td .cell) {*/
  385. /* line-height: 30px !important;*/
  386. /*}*/
  387. .JKWTree-container {
  388. display: flex;
  389. }
  390. .JKWTree-tree {
  391. /*width: 300px;*/
  392. background-color: #fff;
  393. padding: 10px;
  394. margin-right: 20px;
  395. }
  396. .JKWTree-tree h3 {
  397. font-size: 15px;
  398. font-weight: 700;
  399. margin: 10px 0;
  400. }
  401. .JKWTree-content {
  402. flex: 1;
  403. }
  404. /* 图片上传 */
  405. .upload-box {
  406. width: 200px;
  407. height: 200px;
  408. border: 2px dashed #e2e2e2;
  409. display: flex;
  410. justify-content: center;
  411. align-items: center;
  412. position: relative;
  413. cursor: pointer;
  414. }
  415. .uploaded-image {
  416. width: 100%;
  417. height: 100%;
  418. object-fit: cover;
  419. }
  420. .upload-icon {
  421. font-size: 40px;
  422. color: #c0c4cc;
  423. }
  424. .file-input {
  425. display: none;
  426. }
  427. .el-table .warning-row {
  428. background: oldlace;
  429. }
  430. /* 选中某行时的背景色 */
  431. :deep(.el-table__body tr.current-row) > td {
  432. background: #ff80ff !important;
  433. }
  434. </style>
  435. <style scoped>
  436. :deep(.el-table td .cell) {
  437. line-height: 20px !important;
  438. }
  439. :deep(.el-tabs__header){
  440. margin-bottom: 0;
  441. }
  442. .search{
  443. margin-left: 0px !important;
  444. margin-right: 10px !important;
  445. }
  446. .bt{
  447. margin-left: 2px !important;
  448. padding: 3px !important;
  449. font-size: 12px;
  450. }
  451. .el-tabs__header{
  452. margin: 0px !important;
  453. }
  454. .gva-table-box{
  455. padding: 0px !important;
  456. }
  457. .mab{
  458. margin-bottom: 5px;
  459. }
  460. /* 点击按钮改变颜色 */
  461. .active-button {
  462. background-color: #ff0000;
  463. }
  464. .default-button {
  465. background-color: #808080;
  466. }
  467. /* 搜索样式 */
  468. ::v-deep .el-input__wrapper #searchInput {
  469. font-size: 16px;
  470. }
  471. ::v-deep .el-input__wrapper #jitaihao {
  472. font-size: 18px;
  473. }
  474. ::v-deep .el-input__wrapper #gongxu {
  475. font-size: 18px;
  476. }
  477. ::v-deep .el-input__wrapper #zubie {
  478. font-size: 18px;
  479. }
  480. ::v-deep .el-input__wrapper #renyuan {
  481. font-size: 18px;
  482. }
  483. ::v-deep .el-input__wrapper #shuliang {
  484. font-size: 18px;
  485. color: red;
  486. }
  487. ::v-deep .el-input__wrapper #chima {
  488. font-size: 18px;
  489. }
  490. ::v-deep .el-input__wrapper #sbsl {
  491. font-size: 18px;
  492. color: red;
  493. }
  494. </style>