123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- var vm = new Vue({
- el: '#app',
- data: {
- timer: null,
- title: "",
- statisticsTime: "",
- month: "",
- lastMonth: "",
- monthModuleTypeDtos: [],
- totals: [0, 0, 0]
- },
- mounted() {
- this.init()
- this.getModuleTypeOverviewByMark()
- },
- methods: {
- updateRemark(tId, modelId, year, month) {
- var str = $("#" + tId).val();
- axios
- .post('/Home/UpdateRemark',
- {
- Id: modelId,
- Remark: str,
- Year: parseInt(year),
- Month: parseInt(month)
- })
- .then(function (response) {
- result = response.data;
- if (result.code === 0) {
- alert("保存成功!");
- } else if (result.code === 1) {
- alert(result.message);
- }
- })
- .catch(function (error) {
- console.log(error)
- });
- },
- init() {
- let width = document.body.clientWidth - 120;
- let homeTop = document.querySelector("#homeTop");
- let homeTable1 = document.querySelector("#homeTable1");
- let homeTable2 = document.querySelector("#homeTable2");
- homeTop.style.width = width + 'px';
- homeTable1.style.width = width + 'px';
- homeTable2.style.width = width + 'px';
- let now = new Date();
- let nowYear = now.getFullYear();
- let nowMonth = now.getMonth() + 1;
- let nowDay = now.getDate();
- if (nowMonth >= 12) {
- nowYear++;
- }
- if (nowDay >= 21) {
- nowMonth++
- if (nowMonth > 12) {
- nowMonth = 1;
- }
- }
- $("#selectYear").val(nowYear);
- $("#selectMonth").val(nowMonth);
- },
- refresh() {
- this.getModuleTypeOverviewByMark()
- },
- getModuleTypeOverview() {
- let _this = this
- axios
- .get('/Home/GetModuleTypeOverview')
- .then(function (response) {
- _this.title = response.data.title
- _this.statisticsTime = response.data.statisticsTime
- _this.month = response.data.month
- _this.lastMonth = response.data.lastMonth
- _this.monthModuleTypeDtos = response.data.monthModuleTypeDtos
- })
- .catch(function (error) {
- console.log(error)
- });
- },
- getModuleTypeOverviewByMark() {
- let _this = this
- _this.totals[0] = 0;
- _this.totals[1] = 0;
- _this.totals[2] = 0;
- axios
- .get('/Home/GetModuleTypeOverviewByMark',
- {
- params: {
- mark: $('#selectMark option:selected').val(),
- year: $('#selectYear option:selected').val(),
- month: $('#selectMonth option:selected').val()
- }
- })
- .then(function (response) {
- _this.title = response.data.title
- _this.statisticsTime = response.data.statisticsTime
- _this.month = response.data.month
- _this.lastMonth = response.data.lastMonth
- _this.monthModuleTypeDtos = response.data.monthModuleTypeDtos
- if (_this.monthModuleTypeDtos !== undefined) {
- for (var i = 0; i < _this.monthModuleTypeDtos.length; i++) {
- _this.totals[0] += _this.monthModuleTypeDtos[i].planCapacity;
- _this.totals[0] += _this.monthModuleTypeDtos[i].lastModuleCapacity;
- _this.totals[1] += _this.monthModuleTypeDtos[i].capacity;
- }
- _this.totals[2] = _this.totals[1] - _this.totals[0];
- if (_this.totals[2] > 0) {
- _this.totals[2] = 0;
- }
- }
- })
- .catch(function (error) {
- console.log(error)
- });
- },
- jump(id, floor, line) {
- document.cookie = 'lineId=' + id
- document.cookie = 'lineName=' + floor + 'F ' + line + 'Line'
- document.cookie = 'action=' + 'Home'
- window.location.href = "/Line"
- },
- setTimer() {
- //if (this.timer == null) {
- // this.timer = setInterval(() => {
- // this.getProgramOfProduction()
- // }, 60000)
- //}
- },
- clearTimer() {
- //clearInterval(this.timer)
- //this.timer = null
- },
- lastMonthClick() {
- let year = $('#selectYear option:selected').val()
- let minYear = $('#selectYear option:first').val()
- let month = $('#selectMonth option:selected').val()
- month--
- if (month === 0) {
- month = 12
- year--
- if (year < minYear) {
- year = minYear
- }
- }
- $("#selectYear").val(year)
- $("#selectMonth").val(month)
- this.getModuleTypeOverviewByMark()
- },
- nextMonthClick() {
- let year = $('#selectYear option:selected').val()
- let maxYear = $('#selectYear option:last').val()
- let month = $('#selectMonth option:selected').val()
- month++
- if (month === 13) {
- month = 1
- year++
- if (year > maxYear) {
- year = maxYear
- }
- }
- $("#selectYear").val(year)
- $("#selectMonth").val(month)
- this.getModuleTypeOverviewByMark()
- }
- },
- filters: {
- dataTimeFormat: function (value) {
- return value.substr(11, 5)
- },
- blankSpaceFormat: function (value) {
- return value.replace(' ', ' / ')
- },
- modelSizeFormat: function (value) {
- let str;
- str = value.substr(0, 2) + "." + value(2, 1);
- return str;
- },
- },
- created: function () {
- this.clearTimer()
- this.setTimer()
- },
- destroyed: function () {
- this.clearTimer()
- }
- })
|