2024-09-20 15:13:30 +08:00

146 lines
3.3 KiB
Vue

<template>
<view>
<view class="query-card">
<!-- 产线备料清单 -->
<uni-forms style="width: 100%" ref="form">
<uni-forms-item label="日期">
<uni-datetime-picker type="date" :clear-icon="false" v-model="query.dateTime" @change="getList()" />
</uni-forms-item>
<uni-forms-item label="线别">
<uni-data-select v-model="query.lineCode" :localdata="lineOptions" @change="getList()"></uni-data-select>
</uni-forms-item>
<button type="primary" @click="getList()">查询</button>
</uni-forms>
</view>
<uni-list style="width: 100%">
<uni-list-item v-for="(item, index) in dataList" :key="index" :title="item.title" rightText="任务详情" link @click="onListItemClick(item)"></uni-list-item>
</uni-list>
<view class="bottom-box">
<button type="primary" @click="doAddTask">新建备料任务</button>
</view>
</view>
</template>
<script>
import { getLineOptions, searchTaskByLine } from '@/api/preparationTask/index.js';
import { tansParams } from '@/utils/common';
export default {
data() {
return {
// 查询条件
query: {
lineCode: '',
dateTime: this.$dayjs().format('YYYY-MM-DD')
},
value: '',
// 线别
lineOptions: [],
// 工单
dataList: [],
workOrderSelect: ''
};
},
created() {
// this.init();
},
onShow: function () {
this.init();
},
methods: {
init() {
this.getLineSelectOptions();
},
getLineSelectOptions() {
uni.showLoading();
getLineOptions()
.then((res) => {
if (res.code === 200) {
this.lineOptions = res.data.map((item) => {
return {
id: item.id,
text: `${item.name}`,
value: `${item.code}`
};
});
this.$nextTick(() => {
if (this.lineOptions.length > 0) {
this.query.lineCode = this.lineOptions[0].value;
this.getList();
}
});
}
})
.finally(() => {
uni.hideLoading();
});
},
// 获取数据
getList() {
const params = {
hadleDate: this.query.dateTime,
lineCode: this.query.lineCode
};
searchTaskByLine(params).then((res) => {
if (res.code === 200) {
this.dataList = res.data.map((item) => {
return {
id: item.id,
taskCode: item.taskCode,
title: `任务号:${item.taskCode}`,
note: ``
};
});
}
});
},
WorkOrderStatusColor(status) {
const list = ['', '未开始', '已开始', '已完成'];
const colorList = ['#fff', '#8f939c', '#2979ff', '#18bc37'];
return colorList[status * 1];
},
// 工单点击
onListItemClick(item) {
const params = {
taskCode: item.taskCode,
title: item.title
};
uni.navigateTo({
url: '/pages/materialManagement/preparationByPlan/taskDetail?' + tansParams(params)
});
},
doAddTask() {
const params = this.query;
uni.navigateTo({
url: '/pages/materialManagement/preparationByPlan/addTask/addTask?' + tansParams(params)
});
}
}
};
</script>
<style scoped>
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.query-card {
background-color: #fff;
padding: 10px;
}
.row {
background-color: #fff;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.card-box {
width: 100%;
}
</style>