home.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. var vm = new Vue({
  2. el: '#app',
  3. data: {
  4. timer: null,
  5. title: "",
  6. statisticsTime: "",
  7. month: "",
  8. lastMonth: "",
  9. monthModuleTypeDtos: [],
  10. totals: [0, 0, 0]
  11. },
  12. mounted() {
  13. this.init()
  14. this.getModuleTypeOverviewByMark()
  15. },
  16. methods: {
  17. updateRemark(tId, modelId, year, month) {
  18. var str = $("#" + tId).val();
  19. axios
  20. .post('/Home/UpdateRemark',
  21. {
  22. Id: modelId,
  23. Remark: str,
  24. Year: parseInt(year),
  25. Month: parseInt(month)
  26. })
  27. .then(function (response) {
  28. result = response.data;
  29. if (result.code === 0) {
  30. alert("保存成功!");
  31. } else if (result.code === 1) {
  32. alert(result.message);
  33. }
  34. })
  35. .catch(function (error) {
  36. console.log(error)
  37. });
  38. },
  39. init() {
  40. let width = document.body.clientWidth - 120;
  41. let homeTop = document.querySelector("#homeTop");
  42. let homeTable1 = document.querySelector("#homeTable1");
  43. let homeTable2 = document.querySelector("#homeTable2");
  44. homeTop.style.width = width + 'px';
  45. homeTable1.style.width = width + 'px';
  46. homeTable2.style.width = width + 'px';
  47. let now = new Date();
  48. let nowYear = now.getFullYear();
  49. let nowMonth = now.getMonth() + 1;
  50. let nowDay = now.getDate();
  51. if (nowMonth >= 12) {
  52. nowYear++;
  53. }
  54. if (nowDay >= 21) {
  55. nowMonth++
  56. if (nowMonth > 12) {
  57. nowMonth = 1;
  58. }
  59. }
  60. $("#selectYear").val(nowYear);
  61. $("#selectMonth").val(nowMonth);
  62. },
  63. refresh() {
  64. this.getModuleTypeOverviewByMark()
  65. },
  66. getModuleTypeOverview() {
  67. let _this = this
  68. axios
  69. .get('/Home/GetModuleTypeOverview')
  70. .then(function (response) {
  71. _this.title = response.data.title
  72. _this.statisticsTime = response.data.statisticsTime
  73. _this.month = response.data.month
  74. _this.lastMonth = response.data.lastMonth
  75. _this.monthModuleTypeDtos = response.data.monthModuleTypeDtos
  76. })
  77. .catch(function (error) {
  78. console.log(error)
  79. });
  80. },
  81. getModuleTypeOverviewByMark() {
  82. let _this = this
  83. _this.totals[0] = 0;
  84. _this.totals[1] = 0;
  85. _this.totals[2] = 0;
  86. axios
  87. .get('/Home/GetModuleTypeOverviewByMark',
  88. {
  89. params: {
  90. mark: $('#selectMark option:selected').val(),
  91. year: $('#selectYear option:selected').val(),
  92. month: $('#selectMonth option:selected').val()
  93. }
  94. })
  95. .then(function (response) {
  96. _this.title = response.data.title
  97. _this.statisticsTime = response.data.statisticsTime
  98. _this.month = response.data.month
  99. _this.lastMonth = response.data.lastMonth
  100. _this.monthModuleTypeDtos = response.data.monthModuleTypeDtos
  101. if (_this.monthModuleTypeDtos !== undefined) {
  102. for (var i = 0; i < _this.monthModuleTypeDtos.length; i++) {
  103. _this.totals[0] += _this.monthModuleTypeDtos[i].planCapacity;
  104. _this.totals[0] += _this.monthModuleTypeDtos[i].lastModuleCapacity;
  105. _this.totals[1] += _this.monthModuleTypeDtos[i].capacity;
  106. }
  107. _this.totals[2] = _this.totals[1] - _this.totals[0];
  108. if (_this.totals[2] > 0) {
  109. _this.totals[2] = 0;
  110. }
  111. }
  112. })
  113. .catch(function (error) {
  114. console.log(error)
  115. });
  116. },
  117. jump(id, floor, line) {
  118. document.cookie = 'lineId=' + id
  119. document.cookie = 'lineName=' + floor + 'F ' + line + 'Line'
  120. document.cookie = 'action=' + 'Home'
  121. window.location.href = "/Line"
  122. },
  123. setTimer() {
  124. //if (this.timer == null) {
  125. // this.timer = setInterval(() => {
  126. // this.getProgramOfProduction()
  127. // }, 60000)
  128. //}
  129. },
  130. clearTimer() {
  131. //clearInterval(this.timer)
  132. //this.timer = null
  133. },
  134. lastMonthClick() {
  135. let year = $('#selectYear option:selected').val()
  136. let minYear = $('#selectYear option:first').val()
  137. let month = $('#selectMonth option:selected').val()
  138. month--
  139. if (month === 0) {
  140. month = 12
  141. year--
  142. if (year < minYear) {
  143. year = minYear
  144. }
  145. }
  146. $("#selectYear").val(year)
  147. $("#selectMonth").val(month)
  148. this.getModuleTypeOverviewByMark()
  149. },
  150. nextMonthClick() {
  151. let year = $('#selectYear option:selected').val()
  152. let maxYear = $('#selectYear option:last').val()
  153. let month = $('#selectMonth option:selected').val()
  154. month++
  155. if (month === 13) {
  156. month = 1
  157. year++
  158. if (year > maxYear) {
  159. year = maxYear
  160. }
  161. }
  162. $("#selectYear").val(year)
  163. $("#selectMonth").val(month)
  164. this.getModuleTypeOverviewByMark()
  165. }
  166. },
  167. filters: {
  168. dataTimeFormat: function (value) {
  169. return value.substr(11, 5)
  170. },
  171. blankSpaceFormat: function (value) {
  172. return value.replace('&nbsp;', '&nbsp;/&nbsp;')
  173. },
  174. modelSizeFormat: function (value) {
  175. let str;
  176. str = value.substr(0, 2) + "." + value(2, 1);
  177. return str;
  178. },
  179. },
  180. created: function () {
  181. this.clearTimer()
  182. this.setTimer()
  183. },
  184. destroyed: function () {
  185. this.clearTimer()
  186. }
  187. })