steel_inboundStatistics.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. //入库统计
  2. <template>
  3. <div class="steel_inboundStatistics">
  4. <div class="sache">
  5. <span class="text">入库时间:</span>
  6. <el-date-picker
  7. v-model="startTime"
  8. type="datetime"
  9. placeholder="选择日期"
  10. >
  11. </el-date-picker>
  12. <span class="text1">至</span>
  13. <el-date-picker v-model="endTime" type="datetime" placeholder="选择日期">
  14. </el-date-picker>
  15. <el-select v-model="region" placeholder="请选择班次" style="width: auto;">
  16. <el-option label="不选择班次" value="0"></el-option>
  17. <el-option label="早班" value="1"></el-option>
  18. <el-option label="中班" value="2"></el-option>
  19. <el-option label="晚班" value="3"></el-option>
  20. </el-select>
  21. <el-button type="primary" class="btn" @click="onclick">
  22. <i class="el-icon-search"></i>查询
  23. </el-button>
  24. <el-col :span="3" v-html="'\u2003'" />
  25. <span class="text">生产总件数</span>
  26. <el-input
  27. placeholder="请输入内容"
  28. v-model="input3"
  29. :disabled="true"
  30. class="inputs"
  31. style="width:10%"
  32. >
  33. </el-input>
  34. <span class="text">生产总重量</span>
  35. <el-input
  36. placeholder="请输入内容"
  37. v-model="input4"
  38. :disabled="true"
  39. style="width:10%"
  40. >
  41. </el-input>
  42. </div>
  43. <div class="table">
  44. <dilTable v-bind.sync="options" @func="func" :rowClassName="rowClassName">
  45. </dilTable>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { sjTime } from "@/utils/sharedJsFile";
  51. import { getCookie } from "@/utils/util.js";
  52. export default {
  53. data() {
  54. return {
  55. rowClassName({ row, rowIndex }) {
  56. if (rowIndex === 0) {
  57. return "success-row";
  58. }
  59. return "";
  60. },
  61. input1: "",
  62. input2: "",
  63. input3: "",
  64. input4: "",
  65. input5: "",
  66. inputText: "",
  67. startTime: null,
  68. endTime: null,
  69. region: "0",
  70. options: {
  71. // first请求数据的地址
  72. requestUrl:
  73. "/api/v1/wms/getWmsInboundResultStatistics?apiId=445&warehouseId=" + 3
  74. // selectionType: "select",
  75. // mapList: [],
  76. }
  77. };
  78. },
  79. created() {
  80. console.log(this.options.data);
  81. },
  82. methods: {
  83. func(res) {
  84. // console.log(res.list[0])
  85. // this.input1 = this.input1 + e.furnaceNumber1,
  86. let num1 = 0;
  87. let num2 = 0;
  88. res.list.forEach(e => {
  89. console.log(e);
  90. console.log(e.count);
  91. console.log(e.weight);
  92. num1 = num1 + e.count;
  93. num2 = num2 + e.weight;
  94. });
  95. this.input3 = num1;
  96. this.input4 = (num2 / 1000).toFixed(3);
  97. // this.input1 = res.list[0].furnaceNumber1,
  98. // this.input2 = res.list[0].materialName,
  99. // this.input3 = res.list[0].count,
  100. // this.input4 = res.list[0].weight,
  101. // this.input5 = res.list[0].onetime
  102. },
  103. // inboundDetails(scope){
  104. // this.$router.push("/inboundDetails/" + scope.row.inboundId)
  105. // },
  106. // 获取当前月份的最后一天
  107. getdaysinmonth(year, month) {
  108. month = parseInt(month, 10) + 1;
  109. let days = 0;
  110. month = month - 1;
  111. console.log("othermonth" + month);
  112. console.log("otheryear" + year);
  113. // 根据月份获取对应的天数
  114. if (month == 2) {
  115. days = year % 4 == 0 ? 29 : 28;
  116. } else if (
  117. month == 1 ||
  118. month == 3 ||
  119. month == 5 ||
  120. month == 7 ||
  121. month == 8 ||
  122. month == 10 ||
  123. month == 12
  124. ) {
  125. days = 31;
  126. } else {
  127. days = 30;
  128. }
  129. console.log("otherdays" + days);
  130. return days;
  131. },
  132. onclick() {
  133. let startTime = null;
  134. let endTime = null;
  135. // 判断用户有没有班次,有班次则提供默认时间
  136. if (this.region != null) {
  137. let date = null;
  138. let date2 = null;
  139. let year = null;
  140. let month = null;
  141. let day = null;
  142. let year2 = null;
  143. let month2 = null;
  144. let day2 = null;
  145. // 判断当前日期输入框中是否选择了时间,并且开始日期和结束日期是否是同一天
  146. if (this.startTime != null) {
  147. date = this.startTime;
  148. // 判断当前开始时间是标准时间还是字符串时间
  149. year = date.getFullYear(); // 年
  150. month = date.getMonth() + 1; // 月
  151. day = date.getDate(); // 日
  152. }
  153. if (this.endTime != null) {
  154. date2 = this.endTime;
  155. year2 = date2.getFullYear(); // 年
  156. month2 = date2.getMonth() + 1; // 月
  157. day2 = date2.getDate(); // 日 // 日
  158. }
  159. if (this.startTime == null && this.endTime == null) {
  160. // 获取当前的日期时间
  161. date = new Date();
  162. year = date.getFullYear(); // 年
  163. month = date.getMonth() + 1; // 月
  164. day = date.getDate(); // 日
  165. }
  166. // 判断开始日期和结束日期是否是同一天
  167. if (
  168. !(year == year2 && month == month2 && day == day2) &&
  169. (this.startTime != null || this.endTime != null) &&
  170. this.region == null
  171. ) {
  172. // 当不是同一天的时候,直接弹窗警告
  173. this.startTime = null;
  174. this.endTime = null;
  175. this.$message.warning("开始日期和结束日期不是同一天");
  176. }
  177. // 判断当前用户选择的具体班次
  178. if (this.region == 0) {
  179. this.startTime = year + "-" + month + "-" + day + " " + "00:00:00";
  180. // 将结束时间加一
  181. day = parseInt(day) + 1;
  182. this.endTime = year + "-" + month + "-" + day + " " + "00:00:00";
  183. } else if (this.region == 1) {
  184. this.startTime = year + "-" + month + "-" + day + " " + "07:30:00";
  185. this.endTime = year + "-" + month + "-" + day + " " + "15:30:00";
  186. } else if (this.region == 2) {
  187. this.startTime = year + "-" + month + "-" + day + " " + "15:30:00";
  188. this.endTime = year + "-" + month + "-" + day + " " + "23:30:00";
  189. } else if (this.region == 3) {
  190. this.endTime = year + "-" + month + "-" + day + " " + "07:30:00";
  191. // 判断开始日期和结束日期是否跨月份了
  192. if (month != month2) {
  193. month = parseInt(month) - 1;
  194. // 获取前一个月份的最后一天
  195. day = this.$options.methods.getdaysinmonth(year, month);
  196. } else {
  197. // 将开始时间减一
  198. day = parseInt(day) - 1;
  199. }
  200. this.startTime = year + "-" + month + "-" + day + " " + "23:30:00";
  201. }
  202. this.startTime = new Date(this.startTime);
  203. this.endTime = new Date(this.endTime);
  204. console.log(this.startTime + "开始时间");
  205. console.log(this.endTime + "结束时间");
  206. // 将拼接好的日期转换为时间戳
  207. startTime = Date.parse(this.startTime);
  208. endTime = Date.parse(this.endTime);
  209. console.log(startTime + "开始时间2");
  210. console.log(endTime + "结束时间2");
  211. } else {
  212. if (this.startTime) {
  213. startTime = sjTime(this.startTime);
  214. }
  215. if (this.endTime) {
  216. endTime = sjTime(this.endTime);
  217. }
  218. }
  219. if (startTime && endTime) {
  220. if (startTime < endTime) {
  221. // if(getCookie("orgCode") == "dagangadmin" || getCookie("orgCode") == "zidonghuabu"){
  222. this.options.requestUrl =
  223. "/api/v1/wms/getWmsInboundResultStatistics?apiId=445&warehouseId=" +
  224. 3 +
  225. "&startTime=" +
  226. startTime +
  227. "&endTime=" +
  228. endTime +
  229. "&i=" +
  230. new Date();
  231. // }else if(getCookie("orgCode") == "wuliuchuyunzhongxin"){
  232. // this.options.requestUrl = "/api/v1/wms/getWmsInboundResultStatistics?apiId=445&warehouseId="+3+"&orderType=13&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
  233. // }else{
  234. // this.options.requestUrl = '/api/v1/wms/getWmsInboundResultStatistics?apiId=445&warehouseId="+3+"&userId=' + getCookie("orgCode") +"&startTime=" + startTime + "&endTime=" + endTime + "&i=" +new Date();
  235. // }
  236. } else {
  237. this.startTime = null;
  238. this.endTime = null;
  239. this.$message.warning("开始时间要比结束时间早");
  240. }
  241. }
  242. },
  243. selectionChange(selection) {
  244. this.options.mapList = selection;
  245. }
  246. }
  247. };
  248. </script>
  249. <style lang="scss" scoped>
  250. .steel_inboundStatistics {
  251. margin-top: 30px;
  252. margin-left: 20px;
  253. .sache {
  254. display: flex;
  255. margin-bottom: 10px;
  256. padding-right: 10px;
  257. .text {
  258. text-align: left;
  259. line-height: 40px;
  260. width: 70px;
  261. }
  262. .text1 {
  263. text-align: left;
  264. line-height: 40px;
  265. }
  266. .el-date-editor {
  267. margin-right: 5px;
  268. margin-left: 5px;
  269. }
  270. .btn {
  271. margin-left: 10px;
  272. }
  273. .el-select {
  274. width: 100%;
  275. .el-input__inner {
  276. width: 150px;
  277. }
  278. }
  279. }
  280. }
  281. </style>