| | |
| | | <template> |
| | | <view> |
| | | <ProductCard /> |
| | | <view class="pt-2"> |
| | | <ProductCard |
| | | :data="cardData" |
| | | :map="{ |
| | | deviceModel: 'deviceModel', |
| | | model: 'model', |
| | | systemNo: 'systemNo', |
| | | totalAmount: 'totalAmount', |
| | | amount: 'amount', |
| | | unAmount: 'unAmount', |
| | | poleModel: 'poleModel', |
| | | contractNo: 'contractNo', |
| | | }" |
| | | /> |
| | | <view class="mx-3"> |
| | | <wd-grid class="rounded-lg" clickable> |
| | | <wd-grid-item |
| | | icon="computer" |
| | | link-type="navigateTo" |
| | | url="/pages/production/wire/report/wire" |
| | | text="报工" |
| | | /> |
| | | <wd-grid-item |
| | | <wd-grid-item icon="computer" @click="handleReportClick" text="报工" /> |
| | | <!-- <wd-grid-item |
| | | icon="chart" |
| | | text="自检" |
| | | link-type="navigateTo" |
| | | url="/pages/production/wire/selfInspect/index" |
| | | /> |
| | | /> --> |
| | | <wd-grid-item |
| | | icon="tips" |
| | | link-type="navigateTo" |
| | | url="/pages/production/wire/backman/index" |
| | | :url="`/pages/production/wire/backman/index?id=${paramsId}`" |
| | | text="杂工" |
| | | /> |
| | | <wd-grid-item |
| | | <!-- <wd-grid-item |
| | | icon="wallet" |
| | | link-type="navigateTo" |
| | | url="/pages/production/wire/receive/index" |
| | | text="材料领用" |
| | | /> |
| | | /> --> |
| | | </wd-grid> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { onLoad } from "@dcloudio/uni-app"; |
| | | import ProductCard from "@/components/product_card/index.vue"; |
| | | import WireApi from "@/api/product/wire"; |
| | | import { getPrepareId, setPrepareId, clearPrepareId } from "@/utils/cache"; |
| | | import HomeApi from "@/api/home"; |
| | | |
| | | const paramsId = ref(); |
| | | const cardData = reactive({ |
| | | deviceModel: undefined, |
| | | model: undefined, |
| | | systemNo: undefined, |
| | | totalAmount: undefined, |
| | | amount: undefined, |
| | | unAmount: undefined, |
| | | oneLength: undefined, |
| | | poleModel: undefined, |
| | | contractNo: undefined, |
| | | type: "拉丝", |
| | | }); |
| | | const detailData = ref<any>({}); |
| | | |
| | | const getDetailData = async (id: string) => { |
| | | const { data } = await WireApi.getWireDetailById({ |
| | | id: id, |
| | | }); |
| | | detailData.value = data; |
| | | cardData.deviceModel = data.deviceModel; |
| | | cardData.model = data.model; |
| | | cardData.systemNo = data.systemNo; |
| | | cardData.totalAmount = data.totalAmount; |
| | | cardData.amount = data.amount; |
| | | cardData.unAmount = data.unAmount; |
| | | cardData.oneLength = data.oneLength; |
| | | cardData.poleModel = data.poleModel; |
| | | cardData.contractNo = data.contractNo; |
| | | cardData.type = data.type || "拉丝"; |
| | | }; |
| | | |
| | | // 获取并缓存生产准备ID |
| | | const initPrepareId = async () => { |
| | | try { |
| | | const { data } = await HomeApi.getIndex(); |
| | | if (data && data.prepareId) { |
| | | setPrepareId(data.prepareId); |
| | | } else { |
| | | // 如果没有 prepareId,清空缓存 |
| | | clearPrepareId(); |
| | | } |
| | | } catch (error) { |
| | | console.error("获取生产准备ID失败:", error); |
| | | // 获取失败时也清空缓存 |
| | | clearPrepareId(); |
| | | } |
| | | }; |
| | | |
| | | // 处理报工点击 |
| | | const handleReportClick = async () => { |
| | | // 先请求验证变更接口 |
| | | try { |
| | | const { code } = await WireApi.verifyChanges({ projectId: detailData.value.projectId }); |
| | | if (code !== 200) { |
| | | return; |
| | | } |
| | | } catch (error) { |
| | | console.error("验证变更失败:", error); |
| | | return; |
| | | } |
| | | |
| | | const prepareId = getPrepareId(); |
| | | console.log("拉丝表格报工检查 - prepareId值:", prepareId); |
| | | |
| | | // 如果prepareId为空或未定义,说明生产准备未完成 |
| | | if (!prepareId) { |
| | | console.log("拉丝表格报工阻止 - 生产准备未完成"); |
| | | uni.showModal({ |
| | | title: "提示", |
| | | content: "请在电脑端完成生产准备确认,再进行报工操作", |
| | | showCancel: false, |
| | | confirmText: "确定", |
| | | success: () => { |
| | | // 用户点击确定后,不做任何操作 |
| | | }, |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 如果有 prepareId,正常跳转 |
| | | uni.navigateTo({ |
| | | url: `/pages/production/wire/report/wire?id=${paramsId.value}&model=${cardData.model}&oneLength=${cardData.oneLength}`, |
| | | }); |
| | | }; |
| | | |
| | | onLoad(async (options: any) => { |
| | | paramsId.value = options.id; |
| | | await getDetailData(options.id); |
| | | // 获取并缓存生产准备ID |
| | | await initPrepareId(); |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped></style> |