123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- <template>
- <view class="container">
- <!-- 搜索栏 -->
- <view class="info-row btn-panel search-bar">
- <view class="search-input">
- <input type="text" v-model="productNo" placeholder="请输入工序编号"/>
- </view>
- <view class="scan-btn" @click="scanQRCode">
- <uni-icons type="scan" size="32" color="#00aaff"></uni-icons>
- </view>
- </view>
- <!-- 按钮面板 -->
- <view class="info-row btn-panel">
- <button class="btn btn-first" @click="download">
- 下载数据
- </button>
- </view>
- <!-- 列表内容 -->
- <!-- #ifdef APP -->
- <scroll-view style="flex:1">
- <!-- #endif -->
- <view class="download-card" v-for="(item, index) in downloads" :key="index" >
- <view @click="enterItem(item.pdid)">
- <view class="info-row">
- <text class="label">工序:</text>
- <text class="value">{{ item.gxno }}</text>
- </view>
- <view class="info-row">
- <text class="label">路卡号:</text>
- <text class="value">{{ item.cardno }}</text>
- </view>
- <view class="info-row">
- <text class="label">工作令:</text>
- <text class="value">{{ item.workorder }}</text>
- </view>
- <view class="info-row">
- <text class="label">产品名称:</text>
- <text class="value">{{ item.invname }}</text>
- </view>
- <view class="info-row">
- <text class="label">图号:</text>
- <text class="value">{{ item.graphid }}</text>
- </view>
- <view class="info-row">
- <text class="label">工艺编号:</text>
- <text class="value">{{ item.processno }}</text>
- </view>
- <view class="info-row">
- <text class="label">版本号:</text>
- <text class="value">{{ item.ver }}</text>
- </view>
- <view class="info-row">
- <text class="label">最近更新时间:</text>
- <text class="value">{{ item.lastupdatetime }}</text>
- </view>
- <view class="info-row">
- <text class="label">进度:</text>
- <text class="process-value" :class="{
- 'bg-green': ( item.photoStatus + item.keyStatus + item.recordStatus) == 3,
- 'bg-yellow': ( item.photoStatus + item.keyStatus + item.recordStatus) < 3,
- 'bg-black': ( item.photoStatus + item.keyStatus + item.recordStatus) == 0
- }"> {{ (item.photoStatus + item.keyStatus + item.recordStatus) }} / 3 </text>
- </view>
- </view>
-
- <view class="info-row">
- <button class="btn btn-second" @click="upload(item)">
- 上传数据
- </button>
- </view>
- </view>
-
- <!-- #ifdef APP -->
- </scroll-view>
- <!-- #endif -->
- </view>
- </template>
- <script setup>
- import { ref, reactive } from 'vue'
- import { getTaskInfoList } from '@/api/work';
- import { downloadDataFromAPI, uploadDataToAPI } from '@/utils/qcDataProcessor.uts';
- // 产品号输入框数据
- const productNo = ref('PI02297172');
-
- const backPressOptions = reactive({
- from: 'backbutton'
- } as OnBackPressOptions)
- onBackPress((options : OnBackPressOptions) : boolean | null => {
- // 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
- // reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
- uni.reLaunch({
- url: `/pages/work/index`,
- })
- // 返回true表示拦截默认返回行为
- return true
- })
- type Task = {
- pdid : number,
- gxpk : string,
- cardno : string,
- productcode : string,
- model : string,
- workorder : string,
- invname : string,
- graphid : string,
- processno : string,
- gxno : string,
- ver : string,
- lastupdatetime : string,
- photoStatus : number,
- keyStatus : number,
- recordStatus : number,
- }
- var initDownloads = [] as Task[]
- var downloads = ref<Task[]>([]);
- const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
- // #ifdef APP-ANDROID
- getTaskInfoList(null).then((res : UTSJSONObject) => {
- let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
- if (dataList != null && dataList.length > 0) {
- dataList.forEach(item => {
- if (item != null) {
- let download = JSON.parse<Task>(item.toJSONString());
- if (download != null) {
- initDownloads.push(download)
- }
- }
- });
- }
- downloads.value = initDownloads
- })
- // #endif
- // #ifdef H5
- downloads = [{
- pdid: 1,
- workorder: "632-P-01",
- invname: "箱间段",
- productno: "1CFA1040-00#S",
- graphid: '',
- ver: '',
- cardno: "LK20230707070012",
- processno: "Pb/XXX-E11",
- updatetime: "2025-06-23",
- createtime : "2025-06-23",
- totalRecord : 3,
- statusRecordCount : 3,
- uploadflag: 1,
- status: 3
- }, {
- pdid: 2,
- workorder: "712-SY-10-6",
- invname: "级间架",
- productno: "1XA1020-00A",
- graphid: '',
- ver: '',
- cardno: "LK20250215003",
- processno: "Pb/XXX-E11",
- createtime : "2025-06-23",
- updatetime: "2025-08-25",
- totalRecord : 4,
- statusRecordCount : 2,
- uploadflag: 1,
- status: 2
- }, {
- pdid: 3,
- workorder: "712-SY-10-6",
- invname: "级间架",
- productno: "1XA1020-00A",
- graphid: '',
- ver: '',
- cardno: "LK20250215003",
- processno: "Pb/XXX-E11",
- createtime : "2025-06-23",
- updatetime: "2025-08-25",
- totalRecord : 4,
- statusRecordCount : 0,
- uploadflag: 1,
- status: 1
- }] as Download[];
- // #endif
- const download = async (e : any) => {
- console.log("开始下载...")
- // 调用数据处理工具中的方法下载数据
- if(productNo.value == null || productNo.value == '') {
- uni.showToast({
- title: '请先扫描或者输入工序编号',
- icon: 'error'
- });
- return
- }
-
- await downloadDataFromAPI(productNo.value, () => {
- // 回调函数中执行刷新,确保数据都保存好,进度条跑完
- uni.reLaunch({ url: '/pages/work/download/DownloadList' })
- }).then((res) => {
- // 移除这里的刷新逻辑,避免过早刷新
- })
- }
-
- const upload = async (e : Task) => {
- if((e.photoStatus + e.keyStatus + e.recordStatus ) != 3) {
- uni.showToast({
- title: '当前任务还未完成!',
- icon: 'error'
- });
- return
- }
- console.log("开始上传...")
- uploadDataToAPI(e.gxpk, () => {
- // 回调函数中执行刷新,确保数据都保存好,进度条跑完
- uni.reLaunch({ url: '/pages/work/download/DownloadList' })
- }).then((res) => {
- // 移除这里的刷新逻辑,避免过早刷新
- // 处理断点续传
- })
- }
-
- const enterItem = (id : number) => {
- uni.navigateTo({
- url: `/pages/work/download/DownloadDetail?id=${id}`
- });
- }
-
- // 扫描二维码功能
- const scanQRCode = () => {
- uni.scanCode({
- success: (res) => {
- // 扫描成功,将结果填充到输入框
- productNo.value = res.result;
- console.log('扫描结果:', res.result);
- },
- fail: (err) => {
- console.error('扫描失败:', err);
- uni.showToast({
- title: '扫描失败,请重试',
- icon: 'error'
- });
- }
- });
- }
- defineExpose({
- backPressOptions
- })
- </script>
- <style scope>
- .container {
- padding: 24rpx;
- background-color: #f0f4f8;
- flex: 1;
- display: flex;
- flex-direction: column;
- font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
- /* #ifndef APP-ANDROID */
- min-height: 100vh;
- /* #endif */
- height: 120rpx;
- }
- .search-bar {
- background-color: #ffffff;
- border-radius: 10rpx;
- box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
- }
- /* 搜索输入框:占满容器剩余空间,放在按钮左侧 */
- .search-input {
- /* 清除默认输入框样式 */
- border: none;
- background: transparent;
- width: 70%;
- margin-left: 10rpx;
- }
- /* 扫描按钮:放在输入框右侧,距离最右10rpx */
- .scan-btn {
- justify-content: center;
- align-items: center; /* 新增:按钮内部图标垂直居中 */
- /* 关键:右侧10rpx边距,实现"距离最右10rpx" */
- margin-left: auto; /* 自动推到flex容器最右侧 */
- margin-right: 10rpx; /* 与容器右边缘保持10rpx间距 */
- }
- .download-card {
- background: #ffffff;
- border-radius: 20rpx;
- padding: 24rpx 32rpx;
- box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
- display: flex;
- flex-direction: column;
- margin-bottom: 20rpx;
- margin-top: 40rpx;
- margin-left: 20rpx;
- margin-right: 20rpx;
- }
- .download-card .view {
- margin-bottom: 16rpx;
- }
- /* 信息行 */
- .info-row {
- display: flex;
- flex-direction: row;
- font-size: 28rpx;
- color: #33475b;
- align-items: center;
- }
- .info-row>.label {
- margin-left: 10rpx;
- }
- .info-row>.value {
- margin-left: 10rpx;
- }
- .btn-panel {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-left: 5rpx;
- margin-right: 5rpx;
- }
- .label {
- font-weight: bold;
- color: #102a43;
- min-width: 100rpx;
- }
- .value {
- flex: 1;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .btn {
- align-self: flex-end;
- background-color: #00aaff;
- color: #fff;
- border: none;
- border-radius: 32rpx;
- padding: 2rpx 30rpx;
- font-size: 24rpx;
- font-weight: bold;
- /* #ifndef APP-ANDROID */
- transition: background-color 0.3s ease;
- /* #endif */
- margin-top: 30rpx;
- }
- .process-value {
- width: 120rpx;
- min-width: 100rpx;
- text-align: center;
- border-radius: 10rpx;
- }
- .bg-green {
- background-color: seagreen;
- }
- .bg-yellow {
- background-color: yellow;
- }
- .bg-black {
- background-color: #102a43;
- }
- .btn-first {
- margin-left: 5rpx;
- }
- .btn-second {
- margin-right: 5rpx;
- margin-left: auto;
- }
-
- </style>
|