2024-09-18 17:39:43 +08:00

147 lines
3.2 KiB
Vue

<template>
<!-- 备料 -->
<view class="content">
<view class="row">
<uni-forms style="width: 100%" ref="form">
<uni-forms-item label="日期">
<uni-datetime-picker type="date" :clear-icon="false" v-model="dateTime" @change="dateChange" />
</uni-forms-item>
<uni-forms-item label="线别">
<uni-data-select v-model="routeCode" :localdata="routeOptions" @change="routeSelectChange"></uni-data-select>
</uni-forms-item>
</uni-forms>
</view>
<uni-list style="width: 100%">
<uni-list-item
v-for="(item, index) in workOrderList"
:key="index"
:title="item.title"
:note="item.note"
rightText="配料任务"
link
@click="onListItemClick(item)"
></uni-list-item>
</uni-list>
</view>
</template>
<script>
import { getLineOptions, getWorkOrderList } from '@/api/preparationTask/index.js';
import { tansParams } from '@/utils/common';
export default {
data() {
return {
dateTime: this.$dayjs().format('YYYY-MM-DD'),
value: '',
// 线别
routeOptions: [],
routeCode: '',
// 工单
workOrderList: [],
workOrderSelect: ''
};
},
created() {
this.init();
},
onShow:function(){
this.$nextTick(() => {
this.handlerGetWorkOrderList();
});
},
methods: {
init() {
this.getLineSelectOptions();
},
getLineSelectOptions() {
uni.showLoading();
getLineOptions()
.then((res) => {
if (res.code === 200) {
this.routeOptions = res.data.map((item) => {
return {
id: item.id,
text: `${item.name}`,
value: `${item.code}`
};
});
this.$nextTick(() => {
if (this.routeOptions.length > 0) {
this.routeCode = this.routeOptions[0].value;
this.handlerGetWorkOrderList();
}
});
}
})
.finally(() => {
uni.hideLoading();
});
},
// 日期改变
dateChange() {
this.handlerGetWorkOrderList();
},
// 线别修改
routeSelectChange() {
this.handlerGetWorkOrderList();
},
// 获取工单
handlerGetWorkOrderList() {
const params = {
HandleDate: this.dateTime,
route_code: this.routeCode
};
getWorkOrderList(params).then((res) => {
if (res.code === 200) {
this.workOrderList = res.data.map((item) => {
return {
id: item.id,
workOrder: item.workorder,
title: `工单号:${item.workorder}`,
note: `零件号:${item.productionCode} \n描述:${item.productionName ?? ''}\n规格:${item.specification ?? ''}`
};
});
}
});
},
WorkOrderStatusColor(status) {
const list = ['', '未开始', '已开始', '已完成'];
const colorList = ['#fff', '#8f939c', '#2979ff', '#18bc37'];
return colorList[status * 1];
},
// 工单点击
onListItemClick(item) {
const params = {
workOrder: item.workOrder,
title: item.title,
note: item.note
};
uni.navigateTo({
url: '/pages/materialManagement/materialPreparation/batching?' + tansParams(params)
});
}
}
};
</script>
<style scoped>
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.row {
background-color: #fff;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.card-box {
width: 100%;
}
</style>