chukubaogong.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <div>
  3. <layout>
  4. <!-- <layout-header> -->
  5. <div class="gva-table-box">
  6. <h1 style="margin: 0%;margin-bottom: 6px;">出库报工</h1>
  7. <el-row :gutter="24" style="margin-bottom: 6px;">
  8. <el-input v-model="add_searchInfo" placeholder="请扫描子订单编号"
  9. @keyup.enter="add_onSubmit"
  10. id="searchInput"
  11. style="width: 220px;height: 50px;margin-left: 10px;">
  12. </el-input>
  13. <el-button type="primary" icon="search" @click="add_onSubmit" style="height: 50px;font-size: 20px;">查询</el-button>
  14. <el-button type="primary" icon="" @click="Restore_onSubmit" style="height: 50px;font-size: 20px;">恢复未出库</el-button>
  15. <el-button type="primary" icon="" @click="add_Dialog" style="height: 50px;font-size: 20px;">确认出库</el-button>
  16. </el-row>
  17. </div>
  18. <!-- </layout-header> -->
  19. <layout>
  20. <layout-content >
  21. <div class="gva-table-box">
  22. <el-table ref="multipleTable" style="width: 100%;height: 64vh" tooltip-effect="dark"
  23. :row-style="{ height: '40px' }" :header-cell-style="{ padding: '0px' }"
  24. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  25. :data="add_tableData" border row-key="ID" size="small"
  26. :cell-class-name="tableDataCellClass"
  27. highlight-current-row="true" @row-dblclick="add_updateCompanyFunc"
  28. @row-click="add_tableRowClick" :show-overflow-tooltip="true"
  29. @selection-change="handleSelectionChange">
  30. <!-- <el-table-column type="selection" width="80" /> -->
  31. <el-table-column sortable align="left" label="订单编号" prop="订单编号" width="120" />
  32. <el-table-column sortable align="left" label="订单子编号" prop="子订单编号" width="140"/>
  33. <el-table-column sortable align="left" label="生产款号" prop="款号" width="220"/>
  34. <el-table-column sortable align="left" label="款式" prop="款式" width="100"/>
  35. <el-table-column sortable align="left" label="色系名称" prop="颜色" width="150"/>
  36. <el-table-column sortable align="left" label="是否出库" prop="是否出库" width="120"/>
  37. <el-table-column sortable align="left" label="出库时间" prop="ck_rq" width="120"/>
  38. </el-table>
  39. <div class="dialog-footer" style="text-align: left;margin-right: 60px;">
  40. </div>
  41. </div>
  42. </layout-content>
  43. </layout>
  44. </layout>
  45. </div>
  46. </template>
  47. <script setup>
  48. // 全量引入格式化工具 请按需保留
  49. import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
  50. import {ref, reactive} from 'vue'
  51. import {getSpotList,getSpotTab} from '@/api/mes/job'
  52. import {ElMessage} from "element-plus";
  53. // import { get } from 'scriptjs';
  54. defineOptions({name: 'Company'})
  55. import { useUserStore } from '@/pinia/modules/user'
  56. //获取用户登录信息
  57. const userStore = useUserStore()
  58. const _username = ref('')
  59. _username.value = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
  60. //全局调用获取当前日期
  61. const today = new Date();
  62. const year = today.getFullYear();
  63. const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要补零
  64. const day = String(today.getDate()).padStart(2, '0');
  65. const hours = String(today.getHours()).padStart(2, '0');
  66. const minutes = String(today.getMinutes()).padStart(2, '0');
  67. const seconds = String(today.getSeconds()).padStart(2, '0');
  68. const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  69. const currentDates = `${year}-${month}-${day}`;
  70. //自动聚焦光标input
  71. const getMachineMacdata = async () => {
  72. setTimeout(() => {
  73. const inputElement = document.getElementById('searchInput');
  74. if (inputElement) {
  75. inputElement.focus();
  76. }
  77. }, 100); // 延迟100毫秒
  78. }
  79. getMachineMacdata();
  80. //全局调用参数
  81. const add_searchInfo = ref('')//搜索
  82. const add_tableData = reactive([])//表格
  83. const _orderid = ref('')//订单子编号
  84. const searcs = ref('')//默认记录扫描两次出库
  85. //表格行点击
  86. const add_tableRowClick = async (row)=>{
  87. // add_searchInfo.value = row.子订单编号
  88. console.log(row)
  89. _orderid.value = row.子订单编号
  90. }
  91. //点击【查询】按钮
  92. const add_onSubmit = async ()=>{
  93. //自动聚焦光标input
  94. getMachineMacdata();
  95. if(add_searchInfo.value === ''){
  96. const WorkListdata = [];
  97. searcs.value = '';
  98. add_tableData.splice(0,add_tableData.length,...WorkListdata);
  99. ElMessage({type: 'warning',message: '请扫描子订单编号' })
  100. }else{
  101. if (add_searchInfo.value.includes('-')) {//子订单编号
  102. if(searcs.value == ''){ //第一次扫码 查询数据
  103. console.log("查询子订单编号数据")
  104. const getSpotLists = await getSpotList({order:add_searchInfo.value,code:'出库'});//出库报工修改
  105. add_tableData.splice(0,add_tableData.length,...getSpotLists.data.data);
  106. add_searchInfo.value = ''
  107. searcs.value = 1;
  108. return;
  109. }
  110. if(searcs.value == 1){//第二次扫码,如果两次相同代表可以出库
  111. if(add_tableData[0]['子订单编号'] === add_searchInfo.value){
  112. console.log("出库")
  113. add_Dialogs();//调用出库按钮
  114. searcs.value = '';
  115. }else{
  116. ElMessage({type: 'warning',message: '两次扫码不一致,请重新扫描子订单出库' })
  117. searcs.value = '';
  118. const WorkListdata = [];
  119. add_tableData.splice(0,add_tableData.length,...WorkListdata);
  120. add_searchInfo.value = ''
  121. }
  122. }
  123. } else {//订单编号
  124. console.log("查询订单编号数据")
  125. const WorkListdata = [];
  126. searcs.value = '';
  127. const getSpotLists = await getSpotList({order:add_searchInfo.value,code:'出库'});
  128. add_tableData.splice(0,add_tableData.length,...getSpotLists.data.data);
  129. add_searchInfo.value = ''
  130. }
  131. }
  132. };
  133. //确认出库按钮
  134. const add_Dialog = async () => {
  135. // console.log("确认出库按钮")
  136. let params = {}
  137. if(_orderid.value === ''){
  138. params.order_id = add_tableData[0]['子订单编号'];
  139. }else{
  140. params.order_id = _orderid.value;
  141. }
  142. params.code = '出库';
  143. params.sys_id = _username.value;
  144. const ck_gettab = await getSpotTab(params);// 发起出库请求
  145. if (ck_gettab.code === 0) {// 出库成功后的处理
  146. searcs.value = '';
  147. ElMessage({ type: 'success', message: '出库成功'});
  148. const getSpotLists = await getSpotList({order:params.order_id,code: '出库'});// 获取并更新表格数据
  149. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  150. add_searchInfo.value = ''
  151. }else {
  152. searcs.value = '';
  153. const getSpotLists = await getSpotList({order: params.order_id, code: '出库'}); // 出库失败,重新获取数据
  154. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  155. }
  156. }
  157. //确认出库按钮
  158. const add_Dialogs = async () => {
  159. if(add_tableData[0]['子订单编号'] === add_searchInfo.value){
  160. let params = {
  161. order_id: add_searchInfo.value,
  162. code: '出库',
  163. sys_id: _username.value,
  164. };
  165. console.log(params)
  166. const ck_gettab = await getSpotTab(params);// 发起出库请求
  167. if (ck_gettab.code === 0) {// 出库成功后的处理
  168. searcs.value = '';
  169. ElMessage({ type: 'success', message: '出库成功' });
  170. const getSpotLists = await getSpotList({ order: add_searchInfo.value, code: '出库' });// 获取并更新表格数据
  171. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  172. add_searchInfo.value = ''
  173. }else {
  174. searcs.value = '';
  175. const getSpotLists = await getSpotList({ order: add_searchInfo.value, code: '出库' }); // 出库失败,重新获取数据
  176. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  177. }
  178. }else{
  179. ElMessage({type: 'warning',message: '两次扫码不一致,请重新扫描子订单出库' })
  180. searcs.value = '';
  181. const WorkListdata = [];
  182. add_tableData.splice(0,add_tableData.length,...WorkListdata);
  183. add_searchInfo.value = ''
  184. }
  185. return false;
  186. //下面代码代表多条出库
  187. if (add_tableData.length > 1) {
  188. searcs.value = '';
  189. ElMessage({ type: 'warning', message: '出库出现多条数据'});
  190. return;
  191. }
  192. const orderData = add_tableData[0];
  193. if (add_tableData[0]['子订单编号'] !== add_searchInfo.value) {
  194. const WorkListdata = [];
  195. searcs.value = '';
  196. const getSpotLists = await getSpotList({order:add_searchInfo.value,code:'出库'});
  197. add_tableData.splice(0,add_tableData.length,...getSpotLists.data.data);
  198. return;
  199. }
  200. let params = {
  201. order_id: orderData['子订单编号'],
  202. code: '出库',
  203. sys_id: _username.value,
  204. };
  205. try {
  206. // 发起出库请求
  207. const ck_gettab = await getSpotTab(params);
  208. if (ck_gettab.code === 0) {
  209. // 出库成功后的处理
  210. add_searchInfo.value = '';
  211. searcs.value = '';
  212. ElMessage({ type: 'success', message: '出库成功' });
  213. // 获取并更新表格数据
  214. const getSpotLists = await getSpotList({ order: orderData['子订单编号'], code: '出库' });
  215. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  216. } else {
  217. searcs.value = '';
  218. // 出库失败,重新获取数据
  219. const getSpotLists = await getSpotList({ order: add_searchInfo.value, code: '出库' });
  220. add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.data);
  221. }
  222. } catch (error) {
  223. console.error("出库请求失败", error);
  224. ElMessage({ type: 'error', message: '出库请求失败,请稍后重试' });
  225. }
  226. };
  227. //恢复未出库按钮
  228. const Restore_onSubmit = async ()=>{
  229. if(_orderid.value === '' || _orderid.value === null){
  230. ElMessage({type: 'warning',message: '请点击选择恢复的子订单' })
  231. }else{
  232. let params = {}
  233. params.order_id = _orderid.value;
  234. params.code_ck_rq = currentDates;
  235. params.code = '恢复';
  236. params.sys_id = _username.value;
  237. const ck_gettab = await getSpotTab(params);
  238. if (ck_gettab.code === 0) {
  239. searcs.value = '';
  240. add_searchInfo.value = ''
  241. ElMessage({type: 'success',message: '恢复成功'});
  242. const getSpotLists = await getSpotList({order:_orderid.value,code:'出库'});
  243. add_tableData.splice(0,add_tableData.length,...getSpotLists.data.data);
  244. }
  245. }
  246. //自动聚焦光标input
  247. getMachineMacdata();
  248. }
  249. //复选框选择
  250. const ckSelection = ref('')
  251. const handleSelectionChange = (selection, type) => {
  252. const ids = selection.map(item => {
  253. return item.子订单编号
  254. })
  255. ckSelection.value = ids.join(',')
  256. console.log(ckSelection.value)
  257. }
  258. // =========== 分页 ===========
  259. // 分页相关的响应式变量
  260. const page = ref(1)
  261. const total = ref(0)
  262. const pageSize = ref(10)
  263. // 分页
  264. const handleCurrentChange = (val) => {
  265. page.value = val;
  266. _getStaffList();
  267. };
  268. // 修改页面容量 点击多少条/页
  269. const handleSizeChange = (val) => {
  270. page.value = 10;//默认显示
  271. pageSize.value = val;
  272. _getStaffList();
  273. };
  274. //根据出库状态文字颜色
  275. const tableDataCellClass = ({row, column, rowIndex, columnIndex}) =>{
  276. if(row['是否出库'] === '已出库'){
  277. return 'status-plan-usage-low';
  278. }
  279. if(row['是否出库'] === '未出库'){
  280. return 'statusy-plan-usage-low';
  281. }
  282. }
  283. </script>
  284. <style scoped>
  285. /* 根据出库状态文字颜色 */
  286. :deep(.status-plan-usage-low div) {
  287. color: #8c939d !important;
  288. }
  289. :deep(.statusy-plan-usage-low div) {
  290. color: blue !important;
  291. }
  292. .form-container {
  293. display: flex;
  294. flex-wrap: wrap;
  295. }
  296. .form-column {
  297. /*flex: 1;*/
  298. margin-right: 15px; /* 调整列之间的间距 */
  299. }
  300. /* 左侧输入框宽度调整 */
  301. .form-column .el-form-item .el-input {
  302. width: 150px; /* 调整左侧输入框的宽度 */
  303. }
  304. /* 媒体查询,根据需要调整断点 */
  305. @media screen and (max-width: 768px) {
  306. .form-column {
  307. flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
  308. margin-right: 0;
  309. }
  310. }
  311. .JKWTree-container {
  312. display: flex;
  313. }
  314. .JKWTree-tree {
  315. /*width: 300px;*/
  316. background-color: #fff;
  317. padding: 10px;
  318. margin-right: 20px;
  319. }
  320. .JKWTree-tree h3 {
  321. font-size: 15px;
  322. font-weight: 700;
  323. margin: 10px 0;
  324. }
  325. .JKWTree-content {
  326. flex: 1;
  327. }
  328. /* 表格复选框大小调整 */
  329. :deep(.el-checkbox.el-checkbox--small .el-checkbox__inner) {
  330. width: 45px; /* 复选框宽度 */
  331. height: 23px; /* 复选框高度 */
  332. }
  333. :deep(.el-checkbox.el-checkbox--small.is-checked .el-checkbox__inner::after) {
  334. transform: scale(1.2) rotate(45deg); /* 调整选中后的对勾大小 */
  335. top: 5%; /* 调整对勾位置 */
  336. left: 40%; /* 调整对勾位置 */
  337. width: 5px; /* 调整对勾宽度 */
  338. height: 9px; /* 调整对勾高度 */
  339. }
  340. /* 选中某行时的背景色 */
  341. :deep(.el-table__body tr.current-row) > td {
  342. background: #ff80ff !important;
  343. }
  344. </style>
  345. <style scoped>
  346. :deep(.el-table td .cell) {
  347. line-height: 20px !important;
  348. }
  349. :deep(.el-tabs__header){
  350. margin-bottom: 0;
  351. }
  352. .search{
  353. margin-left: 0px !important;
  354. margin-right: 10px !important;
  355. }
  356. .bt{
  357. margin-left: 2px !important;
  358. padding: 3px !important;
  359. font-size: 12px;
  360. }
  361. .el-tabs__header{
  362. margin: 0px !important;
  363. }
  364. .gva-table-box{
  365. padding: 0px !important;
  366. margin-left: 5px !important;
  367. }
  368. .mab{
  369. margin-bottom: 5px;
  370. }
  371. /* 搜索样式 */
  372. ::v-deep .el-input__wrapper #searchInput {
  373. font-size: 16px;
  374. }
  375. </style>