You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
6.7 KiB
JavaScript

// pages/production/production.js
import {
request
} from '../../utils/request'
const app = getApp()
Page({
data: {
options1Row: [],
options1: [],
selectedIndex1: 13,
options2Row: [],
options2: [],
selectedIndex2: null,
options3Row: [],
options3: [],
selectedIndex3: null,
options4Row: [],
options4: [],
selectedIndex4: null,
open: false,
selectForm: {
pageNum: 1,
pageSize: 10,
processId: 18
},
list: [],
total:0
},
toggle() {
this.setData({
open: !this.data.open
})
},
onSearch() {
let data = this.data.selectForm
Object.keys(data).forEach(key => {
if (!data[key]) delete data[key]
})
data.pageNum = 1
request({
url: '/mes/prodReport/planCompletionRateReport',
method: 'get',
data: data
}).then(e => {
this.setData({
list: e.rows.map(v => {
return {
...v,
completionRate: parseFloat(v.completionRate)
}
}),
total:e.total
})
})
},
onChange(e) {
this.setData({
selectedIndex1: e.detail.value
})
let id = this.data.options1Row.find(v => v.label === this.data.options1[e.detail.value])?.value || ''
this.setData({
selectedIndex2: null,
'selectForm.processId': id
})
this.setData({
'selectForm.machineId': null
})
request({
url: '/mes/prodBaseMachineInfo/getProdBaseMachineInfoList',
method: 'get',
data: {
processId: id
}
}).then(e => {
this.setData({
options2Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.machineId,
label: v.machineName,
}
}),
options2: e.data.map(v => v.machineName),
})
})
},
onChange1(e) {
this.setData({
selectedIndex2: e.detail.value
})
let id = this.data.options2Row.find(v => v.label === this.data.options2[e.detail.value])?.value || ''
this.setData({
'selectForm.machineId': id
})
},
onChange2(e) {
this.setData({
selectedIndex3: e.detail.value
})
let id = this.data.options3Row.find(v => v.label === this.data.options3[e.detail.value])?.value || ''
this.setData({
'selectForm.shiftId': id
})
},
onChange3(e) {
this.setData({
selectedIndex4: e.detail.value
})
let id = this.data.options4Row.find(v => v.label === this.data.options4[e.detail.value])?.value || ''
this.setData({
'selectForm.classTeamId': id
})
},
onChange4(e) {
this.setData({
'selectForm.planCode': e.detail.value
})
},
onChange5(e) {
this.setData({
'selectForm.materialName': e.detail.value
})
},
reset() {
this.setData({
selectForm: {
pageNum: 1,
pageSize: 10,
processId: 18
},
selectedIndex1: 13,
selectedIndex2: null,
selectedIndex3: null,
selectedIndex4: null,
})
request({
url: '/mes/prodBaseMachineInfo/getProdBaseMachineInfoList',
method: 'get',
data: {
processId: 18
}
}).then(e => {
this.setData({
options2Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.machineId,
label: v.machineName,
}
}),
options2: e.data.map(v => v.machineName),
})
})
},
onStartChange(e) {
this.setData({
'selectForm.beginDate': e.detail.value
})
},
onEndChange(e) {
this.setData({
'selectForm.endDate': e.detail.value
})
},
/**
* 生命周期函数--监听页面显示
*/
async onShow() {
const tabBar = this.getTabBar?.()
if (tabBar) {
tabBar.setData({
nowPage: getCurrentPages().at(-1)?.route
})
}
await request({
url: '/auth/login',
method: 'post',
headers: {
isToken: false,
isEncrypt: true,
repeatSubmit: false
},
data: {
username: 'admin',
password: 'admin123',
clientId: '428a8310cd442757ae699df5d894f051',
grantType: 'password',
rememberMe: false,
tenantId: "000000",
}
}).then(e => {
app.globalData.token = e.data.access_token
})
request({
url: '/mes/baseProcessInfo/getProcessInfoList',
method: 'get',
}).then(e => {
this.setData({
options1Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.processId,
label: v.processName,
}
}),
options1: e.data.map(v => v.processName),
})
})
request({
url: '/mes/prodBaseMachineInfo/getProdBaseMachineInfoList',
method: 'get',
data: {
processId: 18
}
}).then(e => {
this.setData({
options2Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.machineId,
label: v.machineName,
}
}),
options2: e.data.map(v => v.machineName),
})
})
request({
url: '/mes/baseShiftInfo/getBaseShiftInfoList',
method: 'get',
}).then(e => {
this.setData({
options3Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.shiftId,
label: v.shiftName,
}
}),
options3: e.data.map(v => v.shiftName),
})
})
request({
url: '/mes/baseClassTeamInfo/getBaseClassTeamInfoList',
method: 'get',
}).then(e => {
this.setData({
options4Row: JSON.parse(JSON.stringify(e.data)).map(v => {
return {
value: v.classTeamId,
label: v.teamName,
}
}),
options4: e.data.map(v => v.teamName),
})
})
},
onReachBottom() {
if(this.data.selectForm.pageNum * this.data.selectForm.pageSize < this.data.total){
let data = this.data.selectForm
Object.keys(data).forEach(key => {
if (!data[key]) delete data[key]
})
data.pageNum += 1
request({
url: '/mes/prodReport/planCompletionRateReport',
method: 'get',
data: data
}).then(e => {
this.setData({
list: [...this.data.list, ...e.rows.map(v => {
return {
...v,
completionRate: parseFloat(v.completionRate)
}
})]
})
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})