chukubaogong.vue 13 KB

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