steel_inboundReal.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //真实入库作业
  2. <template>
  3. <div class="steel_inbound_real">
  4. <div class="sache">
  5. <span class="text">入库时间:</span>
  6. <el-date-picker v-model="startTime" type="datetime" placeholder="选择日期">
  7. </el-date-picker>
  8. <span class="text">至</span>
  9. <el-date-picker v-model="endTime" type="datetime" placeholder="选择日期">
  10. </el-date-picker>
  11. <el-select v-model="region" placeholder="请选择班次" style="width: auto;">
  12. <el-option label="不选择班次" value="0"></el-option>
  13. <el-option label="早班" value="1"></el-option>
  14. <el-option label="中班" value="2"></el-option>
  15. <el-option label="晚班" value="3"></el-option>
  16. </el-select>
  17. <el-button type="primary" class="btn" @click="onclick">
  18. <i class="el-icon-search"></i>查询
  19. </el-button>
  20. </div>
  21. <div class="table">
  22. <dilTable v-bind.sync="options" @selection-change="selectionChange" ref="table">
  23. </dilTable>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { sjTime } from "@/utils/sharedJsFile";
  29. import { getCookie } from '@/utils/util.js';
  30. export default {
  31. data(){
  32. return{
  33. inputText:"",
  34. startTime: null,
  35. endTime: null,
  36. region: "0",
  37. options:{
  38. // first请求数据的地址
  39. requestUrl: "/api/v1/wms/getWmsInboundResults?apiId=371&warehouseId="+3,
  40. // selectionType: "select",
  41. // mapList: [],
  42. },
  43. }
  44. },
  45. methods:{
  46. // inboundDetails(scope){
  47. // this.$router.push("/inboundDetails/" + scope.row.inboundId)
  48. // },
  49. // 获取当前月份的最后一天
  50. getdaysinmonth(year,month){
  51. month = parseInt(month,10)+1;
  52. let days = 0;
  53. month = month -1;
  54. console.log("othermonth"+month)
  55. console.log("otheryear"+year);
  56. // 根据月份获取对应的天数
  57. if(month == 2){
  58. days = year % 4 == 0?29:28;
  59. }else if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12){
  60. days = 31;
  61. }else{
  62. days = 30;
  63. }
  64. console.log("otherdays"+days)
  65. return days;
  66. },
  67. onclick(){
  68. console.log("nihaohhh")
  69. let startTime = null;
  70. let endTime = null;
  71. // 判断用户有没有班次,有班次则提供默认时间
  72. if(this.region!=null){
  73. let date =null;
  74. let date2 =null;
  75. let year = null;
  76. let month =null;
  77. let day = null;
  78. let year2 = null;
  79. let month2 =null;
  80. let day2 = null;
  81. // 判断当前日期输入框中是否选择了时间,并且开始日期和结束日期是否是同一天
  82. if(this.startTime!=null){
  83. date = this.startTime;
  84. // 判断当前开始时间是标准时间还是字符串时间
  85. year = date.getFullYear(); // 年
  86. month = date.getMonth() + 1; // 月
  87. day = date.getDate(); // 日
  88. }
  89. if(this.endTime!=null){
  90. date2 = this.endTime;
  91. year2 = date2.getFullYear(); // 年
  92. month2 = date2.getMonth() + 1; // 月
  93. day2 = date2.getDate(); // 日 // 日
  94. }
  95. if(this.startTime==null&&this.endTime==null){
  96. // 获取当前的日期时间
  97. date = new Date();
  98. year = date.getFullYear(); // 年
  99. month = date.getMonth() + 1; // 月
  100. day = date.getDate(); // 日
  101. }
  102. // 判断开始日期和结束日期是否是同一天
  103. if(!(year==year2&&month==month2&&day==day2)&&(this.startTime!=null||this.endTime!=null)&&this.region==null){
  104. // 当不是同一天的时候,直接弹窗警告
  105. this.startTime = null;
  106. this.endTime = null;
  107. this.$message.warning("开始日期和结束日期不是同一天");
  108. }
  109. // 判断当前用户选择的具体班次
  110. if(this.region == 0){
  111. this.startTime = year+"-"+month+"-"+day+" "+"00:00:00";
  112. // 将结束时间加一
  113. day =parseInt(day) + 1;
  114. this.endTime = year+"-"+month+"-"+day+" "+"00:00:00";
  115. }else if(this.region == 1){
  116. this.startTime = year+"-"+month+"-"+day+" "+"07:30:00";
  117. this.endTime = year+"-"+month+"-"+day+" "+"15:30:00";
  118. }else if(this.region == 2){
  119. this.startTime = year+"-"+month+"-"+day+" "+"15:30:00";
  120. this.endTime = year+"-"+month+"-"+day+" "+"23:30:00";
  121. }else if(this.region == 3){
  122. this.endTime = year+"-"+month+"-"+day+" "+"07:30:00";
  123. // 判断开始日期和结束日期是否跨月份了
  124. if(month!=month2){
  125. month = parseInt(month)-1
  126. // 获取前一个月份的最后一天
  127. day = this.$options.methods.getdaysinmonth(year,month)
  128. }else{
  129. // 将开始时间减一
  130. day =parseInt(day)-1;
  131. }
  132. this.startTime = year+"-"+month+"-"+day+" "+"23:30:00";
  133. }
  134. this.startTime = new Date(this.startTime)
  135. this.endTime = new Date(this.endTime)
  136. console.log(this.startTime+"开始时间")
  137. console.log(this.endTime+"结束时间")
  138. // 将拼接好的日期转换为时间戳
  139. startTime = Date.parse(this.startTime)
  140. endTime = Date.parse(this.endTime)
  141. console.log(startTime+"开始时间2")
  142. console.log(endTime+"结束时间2")
  143. }else{
  144. if (this.startTime) {
  145. startTime = sjTime(this.startTime);
  146. }
  147. if (this.endTime) {
  148. endTime = sjTime(this.endTime);
  149. }
  150. }
  151. // console.log(startTime)
  152. // console.log(endTime)
  153. if (startTime && endTime) {
  154. if (startTime < endTime) {
  155. // if(getCookie("orgCode") == "dagangadmin" || getCookie("orgCode") == "zidonghuabu"){
  156. this.options.requestUrl = "/api/v1/wms/getWmsInboundResults?apiId=371&warehouseId="+3+"&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
  157. // }else if(getCookie("orgCode") == "wuliuchuyunzhongxin"){
  158. // this.options.requestUrl = "/api/v1/wms/getWmsInboundResults?apiId=371&orderType=13&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
  159. // }else{
  160. // this.options.requestUrl = '/api/v1/wms/getWmsInboundResults?apiId=371&userId=' + getCookie("orgCode") +"&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
  161. // }
  162. } else {
  163. this.startTime = null;
  164. this.endTime = null;
  165. this.$message.warning("开始时间要比结束时间早");
  166. }
  167. }
  168. },
  169. selectionChange(selection) {
  170. this.options.mapList = selection;
  171. },
  172. onreserved(){
  173. console.log("fahaahahahaha")
  174. if (this.options.mapList.length == 0) {
  175. this.$message({
  176. type: "warning",
  177. message: "请先选择入库单!",
  178. });
  179. } else {
  180. this.$confirm("是否预留", "提示", {
  181. confirmButtonText: "确定",
  182. cancelButtonText: "取消",
  183. type: "warning",
  184. center: true,
  185. })
  186. .then(() => {
  187. //初始化maplist
  188. var mapList = [];
  189. this.options.mapList.forEach((item, i) => {
  190. //初始化mapItem
  191. var mapItem = {
  192. //入库实绩表id
  193. inboundId: 0,
  194. // 给一个标记定义其为入库变为预留
  195. status: 0,
  196. };
  197. mapItem.inboundId = item.inboundId;
  198. mapList.push(mapItem);
  199. });
  200. this.$message({
  201. type: "success",
  202. message: "预留成功!",
  203. });
  204. console.log(mapList)
  205. this.axios.post("/api/v1/wms/changeReserved", mapList).then((res) => {
  206. console.log("res.data"+res.data)
  207. if (res.data >= 1) {
  208. //改变查询条件
  209.       this.$refs.table.setDataRequestQuery({
  210. });  
  211. this.$router.go(0);
  212. }
  213. });
  214. console.log("fdagfaahh")
  215. })
  216. .catch(() => {
  217. this.$message({
  218. type: "info",
  219. message: "取消上传!",
  220. });
  221. });
  222. }
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .steel_inbound_real{
  229. margin-top: 40px;
  230. margin-left: 20px;
  231. .sache{
  232. display: flex;
  233. margin-bottom: 10px;
  234. padding-right: 10px;
  235. .text {
  236. text-align: left;
  237. line-height: 40px;
  238. }
  239. .el-date-editor {
  240. margin-right: 5px;
  241. margin-left: 5px;
  242. }
  243. .btn {
  244. margin-left: 10px;
  245. }
  246. .el-select {
  247. width: 100%;
  248. .el-input__inner {
  249. width: 150px;
  250. }
  251. }
  252. }
  253. }
  254. </style>