<template>
|
<view class="prod-reporting">
|
<PageHeader title="生产报工" />
|
|
<view class="search_form">
|
<u-form>
|
<view class="form-row">
|
<u-form-item label="客户名称" label-width="80">
|
<up-input v-model="searchForm.customerName" placeholder="请输入" clearable @change="handleQuery" />
|
</u-form-item>
|
<u-form-item label="项目名称" label-width="80">
|
<up-input v-model="searchForm.projectName" placeholder="请输入" clearable @change="handleQuery" />
|
</u-form-item>
|
</view>
|
<view class="form-row">
|
<u-form-item label="状态" label-width="80">
|
<up-input v-model="statusDisplay" placeholder="请选择状态" readonly @click="showStatusPicker = true" />
|
</u-form-item>
|
</view>
|
<view class="form-actions">
|
<u-button type="primary" size="small" @click="handleQuery">搜索</u-button>
|
</view>
|
</u-form>
|
</view>
|
|
<view class="list_container">
|
<u-loading-icon v-if="tableLoading" text="加载中..." />
|
<view v-else>
|
<view v-if="!tableData || tableData.length === 0" class="empty">暂无数据</view>
|
<view v-else class="card_list">
|
<view v-for="item in tableData" :key="item.id" class="card_item">
|
<view class="card_header">
|
<u-tag :type="statusType(item.status)" size="mini">{{ statusText(item.status) }}</u-tag>
|
<text class="card_title">{{ item.projectName }}</text>
|
</view>
|
<view class="card_body">
|
<view class="row"><text class="label">排产日期</text><text class="value">{{ item.schedulingDate }}</text></view>
|
<view class="row"><text class="label">排产人</text><text class="value">{{ item.schedulingUserName }}</text></view>
|
<view class="row"><text class="label">合同号</text><text class="value">{{ item.salesContractNo }}</text></view>
|
<view class="row"><text class="label">客户合同号</text><text class="value">{{ item.customerContractNo }}</text></view>
|
<view class="row"><text class="label">客户名称</text><text class="value">{{ item.customerName }}</text></view>
|
<view class="row"><text class="label">产品大类</text><text class="value">{{ item.productCategory }}</text></view>
|
<view class="row"><text class="label">规格型号</text><text class="value">{{ item.specificationModel }}</text></view>
|
<view class="row inline">
|
<view class="col"><text class="label">单位</text><text class="value">{{ item.unit }}</text></view>
|
<view class="col"><text class="label">排产数量</text><text class="value">{{ item.schedulingNum }}</text></view>
|
<view class="col"><text class="label">生产数量</text><text class="value">{{ item.finishedNum }}</text></view>
|
<view class="col"><text class="label">待生产数量</text><text class="value">{{ item.pendingFinishNum }}</text></view>
|
</view>
|
</view>
|
<view class="card_actions">
|
<u-button type="primary" size="small" @click="openForm('add', item)" :disabled="item.pendingFinishNum == 0">生产报工</u-button>
|
</view>
|
</view>
|
</view>
|
|
|
</view>
|
</view>
|
|
<form-dia ref="formDia" @close="handleQuery"></form-dia>
|
|
<!-- 状态选择器 -->
|
<up-action-sheet :show="showStatusPicker" :actions="statusActions" title="选择状态" @select="onStatusSelect" @close="showStatusPicker = false" />
|
</view>
|
</template>
|
|
<script setup>
|
import { onMounted, ref, reactive, toRefs, nextTick, computed } from "vue";
|
import PageHeader from '@/components/PageHeader.vue'
|
import FormDia from './components/formDia.vue'
|
import { workListPage } from "@/api/productionManagement/productionReporting.js";
|
const data = reactive({
|
searchForm: {
|
customerName: "",
|
projectName: "",
|
status: undefined,
|
},
|
});
|
const { searchForm } = toRefs(data);
|
const showStatusPicker = ref(false)
|
const statusOptions = ref([
|
{ label: '待生产', value: 1 },
|
{ label: '生产中', value: 2 },
|
{ label: '已报工', value: 3 },
|
])
|
const statusActions = computed(() => statusOptions.value.map(o => ({ name: o.label, value: o.value })))
|
const statusDisplay = ref('')
|
const tableData = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: -1,
|
size: -1,
|
});
|
const formDia = ref()
|
|
// 查询列表
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
page.current = -1;
|
page.size = -1;
|
getList();
|
};
|
const getList = () => {
|
tableLoading.value = true;
|
const params = { ...searchForm.value, ...page };
|
workListPage(params).then(res => {
|
tableLoading.value = false;
|
tableData.value = res.data.records.map(item => ({
|
...item,
|
pendingFinishNum: (Number(item.schedulingNum) || 0) - (Number(item.finishedNum) || 0)
|
}));
|
}).catch(err => {
|
tableLoading.value = false;
|
})
|
};
|
// 状态选择
|
const onStatusSelect = (item) => {
|
searchForm.value.status = item?.value
|
statusDisplay.value = item?.name || ''
|
showStatusPicker.value = false
|
handleQuery()
|
}
|
// 打开弹框
|
const openForm = (type, row) => {
|
if (!row) return
|
if ((Number(row.pendingFinishNum) || 0) === 0) {
|
uni.showToast({ title: '无需再报工', icon: 'none' })
|
return
|
}
|
nextTick(() => { formDia.value?.openDialog(type, row) })
|
};
|
|
// 状态文本/类型
|
const statusText = (s) => {
|
if (s == 3) return '已报工'
|
if (s == 1) return '待生产'
|
return '生产中'
|
}
|
const statusType = (s) => {
|
if (s == 3) return 'success'
|
if (s == 1) return 'primary'
|
return 'warning'
|
}
|
|
// 无分页
|
|
// 明细人员/日期选择
|
const openChildUserPicker = (index) => {
|
if (!expandData.value[index]?.editType) return
|
childUserPicker.value.index = index
|
childUserPicker.value.show = true
|
}
|
const onChildUserSelect = (item) => {
|
if (item && childUserPicker.value.index > -1) {
|
const row = expandData.value[childUserPicker.value.index]
|
row.schedulingUserId = item.value
|
row.schedulingUserName = item.name
|
}
|
childUserPicker.value.show = false
|
}
|
const openChildDatePicker = (index) => {
|
if (!expandData.value[index]?.editType) return
|
childDatePicker.value.index = index
|
childDatePicker.value.value = Date.now()
|
childDatePicker.value.show = true
|
}
|
const onChildDateConfirm = (e) => {
|
const d = new Date(e.value)
|
const y = d.getFullYear(); const m = String(d.getMonth()+1).padStart(2, '0'); const day = String(d.getDate()).padStart(2, '0')
|
const str = `${y}-${m}-${day}`
|
if (childDatePicker.value.index > -1) {
|
expandData.value[childDatePicker.value.index].schedulingDate = str
|
}
|
childDatePicker.value.show = false
|
}
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.prod-reporting { padding-bottom: 12px; }
|
.search_form { margin: 12px; background: #fff; border-radius: 8px; padding: 10px; }
|
.form-row { display: flex; gap: 12px; }
|
.form-actions { display: flex; justify-content: flex-end; }
|
.list_container { padding: 0 12px; }
|
.empty { text-align: center; color: #888; padding: 20px 0; }
|
.card_list { display: flex; flex-direction: column; gap: 10px; }
|
.card_item { background: #fff; border-radius: 10px; padding: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
|
.card_header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
|
.card_title { font-weight: 500; color: #333; margin-left: auto; }
|
.card_body .row { display: flex; justify-content: space-between; padding: 4px 0; }
|
.card_body .row.inline { display: flex; gap: 10px; flex-wrap: wrap; }
|
.card_body .row.inline .col { min-width: 45%; display: flex; justify-content: space-between; }
|
.label { color: #666; font-size: 12px; }
|
.value { color: #333; font-size: 12px; }
|
.card_actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
|
.ml8 { margin-left: 8px; }
|
|
</style>
|