123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- <template>
- <view class="uni-column container">
- <view class="scroll-container">
- <view v-for="(item, index) in listData" :key="index" class="list-item">
- <view class="title-container">
- <view class="title uni-row">
- <view class="uni-row">
- <text class="label">批次号:</text>
- <text class="label code"> {{ item['lotCode'] }}</text>
- </view>
- <view style="color: #1684fc; margin-right: 0;" @click="handleOpenLonInfo">
- <text>批次详情</text>
- </view>
- </view>
- <view class="uni-row">
- <view class="right-info uni-row"> <text class="label">工时</text>
- <text class="label time">{{ item['taskTime'] }}</text>
- <!-- <text class="label time">{{ item['taskTime'] }}h</text> -->
- </view>
- <view class="right-info uni-row" style="margin-left: 50rpx;"> <text class="label">合格数</text>
- <text class="label number ">{{ item['qualifiedNum'] }}</text>
- </view>
- </view>
- </view>
- <view class="item-info uni-row">
- <text class="label">产品描述</text>
- <text class="label right">{{ curPlan['productDescription'] }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">操作者</text>
- <text class="label right">{{ item['nickName'] }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">开始时间</text>
- <text class="label right">{{ item['startTime'] ? item['startTime'] : '-' }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">结束时间</text>
- <text class="label right">{{ item['endTime'] ? item['endTime'] : '-'}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">废品数</text>
- <text class="label right">{{ item['rejectSum'] ? item['rejectSum'] : 0 }}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">投入数</text>
- <text
- class="label right">{{store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store.dayworkInfo['processQualifiedNum']}}</text>
- </view>
- <view class="item-info uni-row">
- <text class="label">设备</text>
- <text class="label right">{{ item['equipmentDetailCode']}}</text>
- </view>
- <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 1 : false"
- class="status-btn uni-row ">
- <button class="finished-turnover-tag" size="mini"
- @click.stop="handleShowEndWorkDialog(item)">结束报工</button>
- </view>
- <view v-if="item['userId'] == userInfo['userId'] ? item['status'] == 0 : false"
- class="status-btn uni-row ">
- <button class="start-turnover-tag" size="mini" type="primary"
- @click.stop="handleStartProcessing(item)">开始报工</button>
- </view>
- </view>
- </view>
- <view class="top">
- <button class="top-btn" @click="HandleSeleteInviteUser(listData)"><text class="label">邀请报工</text></button>
- </view>
- <view class="bottom uni-row">
- <button class="bottom-btn left-btn" @click="HandleChangevehicle"><text class="label">更换载具</text></button>
- <button v-if="flag" class="bottom-btn right-btn" type="primary" @click="handleStartProcessing(null)"><text
- class="label">开始加工</text></button>
- </view>
- <dialog-end-work ref="endWorkDialog" @resflushItem='resflushItem' />
- <dialog-selectEquipment ref='selectEquipment'
- @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectEquipment>
- <dialog-selectInviteUser ref="inviteUser"
- @handleAddDayWorkItem='handleAddDayWorkItem'></dialog-selectInviteUser>
- </view>
- <dialog-lotInfo ref="lotInfo"></dialog-lotInfo>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad,
- onReady,
- onUnload,
- onShow
- } from '@dcloudio/uni-app'
- import {
- getDayWorkItemList,
- saveDayWorkItemBatch,
- updateDayWorkItem
- } from "@/api/business/dayWorkItem.js"
- import {
- store
- } from '@/store/index.js'
- import {
- timestampToTime,
- toHHmmss
- } from '@/utils/common.js'
- import {
- checkBizDayworkCarriers
- } from '@/api/business/dayWork.js'
- import {
- isCurProcessFinish
- } from '@/api/business/dayWorkItem.js'
- import {
- getEquipmentByUidAndDid
- } from '@/api/resourceGroup/resourceGroupDetail.js'
- const listData = ref([]) // 回显
- const curPlan = ref({}) // 接收生产计划单信息
- const dayWorkInfo = ref({}) // 接收daywork信息
- const equipmentList = ref([]) // 设备列表
- const endWorkDialog = ref(null) // 组件
- const selectEquipment = ref(null) // 组件
- const inviteUser = ref(null) // 组件
- const dayWorkItem = ref({}) // 添加传输对象
- const reqParam = ref([]) // 请求参数
- const userInfo = ref(null) // 登录员工信息
- const flag = ref(true) // 控制底部开始加工按钮功能
- const lotInfo = ref(null) // 详情弹窗
- const hasEquipment = ref(true) // 判断资源组是否有设备
- onLoad(() => {
- curPlan.value = store.planDetails;
- dayWorkInfo.value = store.dayworkInfo;
- console.log(dayWorkInfo.value)
- init();
- })
- // onUnload(() => {
- // uni.$off('dayworkItemUpdate', reflush)
- // })
- onShow(() => {
- uni.$on('dayworkItemUpdate', reflush)
- })
- function init() {
- console.log(store.dayworkInfo.processSequence)
- userInfo.value = store.userInfo;
- uni.showLoading({
- title: '加载中'
- });
- getDayWorkItemList({
- dayworkId: dayWorkInfo.value.id,
- // processId: store.dayworkInfo.currentProcess.id,
- type: '非周转中item'
- }).then(res => {
- if (res.code == 200) {
- listData.value = res.rows || [];
- console.log(listData.value)
- // 时间戳转工时
- for (var i = 0; i < listData.value.length; i++) {
- let timeStamp = listData.value[i].workingHours;
- listData.value[i].taskTime = toHHmmss(timeStamp);
- }
- flag.value = !listData.value.some(item => item.status == 0);
- uni.hideLoading();
- } else {
- uni.showToast({
- icon: "error",
- title: res.message,
- duration: 1000
- })
- uni.hideLoading();
- }
- })
- getEquipmentByUidAndDid(store.planDetails.id,store.curDeptDetails.deptId).then(equipmentRes => {
- if (equipmentRes.code == 200) {
- hasEquipment.value = equipmentRes.rows.length > 0 ? true : false;
- }
- })
- }
- function reflush() {
- init();
- }
- function resflushItem() {
- reflush();
- }
- function handleOpenLonInfo() {
- lotInfo.value.open();
- }
- function handleShowEndWorkDialog(data) {
- checkBizDayworkCarriers({
- id: store.dayworkInfo.id
- }).then(res => {
- if (res.code == 200) {
- // 调用子组件中的方法
- endWorkDialog.value.open(data, listData)
- } else {
- uni.showToast({
- icon: "none",
- title: res.msg + ",请绑定",
- duration: 2000
- })
- uni.navigateTo({
- url: "/pages/changeBox/index"
- })
- }
- })
- }
- function HandleSeleteInviteUser(data) {
- if (store.dayworkInfo.status == 4) {
- uni.showToast({
- icon: 'none',
- title: '当前批次已完成'
- })
- } else if (store.dayworkInfo.status == 2 || store.dayworkInfo.status == 3) {
- uni.showToast({
- icon: 'none',
- title: '当前工序已完成'
- })
- } else if (!hasEquipment.value) {
- uni.showToast({
- icon: 'none',
- title: '当前无可用设备',
- })
- } else {
- inviteUser.value.open(data);
- }
- }
- function HandleChangevehicle() {
- if (store.dayworkInfo.status == 4) {
- uni.showToast({
- icon: 'none',
- title: '该工序已完成'
- })
- } else {
- uni.navigateTo({
- url: "/pages/changeBox/index"
- })
- }
- }
- function getEquipment(data) {
- console.log(data);
- equipmentList.value = data;
- }
- function handleStartProcessing(item) {
- // 先判断默认的一条是否开始加工
- // if (!item && listData.value.some(item => item.status == 0)) {
- // uni.showToast({
- // icon: 'none',
- // title: '请先开始默认的报工记录再进行报工',
- // duration: 2000
- // })
- // }else{
- // 查询当前工序是否完成再判断是否进行报工
- isCurProcessFinish({
- dayworkId: store.dayworkInfo.id,
- processId: listData.value[0].processId
- }).then(res => {
- if (store.dayworkInfo.status == 4) {
- uni.showToast({
- icon: 'none',
- title: '当前批次已完成'
- })
- } else if (res.data) {
- uni.showToast({
- icon: 'none',
- title: '该工序已完成,不能继续报工'
- })
- } else if (!hasEquipment.value) {
- uni.showToast({
- icon: 'none',
- title: '当前无可用设备',
- })
- } else {
- selectEquipment.value.open(item);
- }
- })
- // }
- }
- /**
- * 新批次默认item去报工(执行方法)
- * @param {Object} item
- */
- function handleStartFirstItem(item) {
- let reqParam = item;
- reqParam.status = 1;
- reqParam.startTime = timestampToTime(new Date());
- updateDayWorkItem(reqParam).then(res => {
- if (res.code === 200) {
- uni.showToast({
- icon: "success",
- title: "报工成功",
- duration: 2000
- })
- init();
- } else {
- uni.showToast({
- icon: "none",
- title: "报工失败,请联系管理员",
- duration: 2000
- })
- }
- })
- }
- function handleAddDayWorkItem(data) {
- console.log(data)
- if (data.dayworkId) { // data里面任意一对象除了设备相关的字段存在,直接给reqParam赋值
- reqParam.value = {
- ...data,
- productionPlanId: curPlan.value.productionPlanId,
- productionPlanDetailId: curPlan.value.id,
- technologicalProcessId: curPlan.value.technologicalProcessId,
- prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
- .dayworkInfo['processQualifiedNum'],
- deptId: store.curDeptDetails.deptId,
- deptName: store.curDeptDetails.deptName
- }
- } else {
- // equipmentList.value = data;
- dayWorkItem.value = {
- dayworkId: dayWorkInfo.value.id,
- lotId: dayWorkInfo.value.lotId,
- productionPlanId: curPlan.value.productionPlanId,
- productionPlanDetailId: curPlan.value.id,
- technologicalProcessId: curPlan.value.technologicalProcessId,
- prodNum: store.dayworkInfo['processQualifiedNum'] == 0 ? store.dayworkInfo['oneLotQuantity'] : store
- .dayworkInfo['processQualifiedNum'],
- status: 1,
- startTime: timestampToTime(new Date()),
- deptId: store.curDeptDetails.deptId,
- deptName: store.curDeptDetails.deptName,
- ...data
- }
- reqParam.value = dayWorkItem.value;
- }
- console.log(reqParam.value)
- saveDayWorkItemBatch(reqParam.value).then(res => {
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '操作成功',
- duration: 2000
- });
- reqParam.value = [];
- reflush();
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败',
- duration: 2000
- });
- }
- })
- }
- </script>
- <style lang="scss">
- .container {
- height: calc(100% - 232rpx);
- background-color: #f5f5f5;
- overflow: auto;
- }
- .scroll-container {
- position: relative;
- top: 16rpx;
- // right: 0;
- // bottom: 144rpx;
- // left: 0;
- }
- .selected {
- border: 1px solid #1684fc;
- }
- .list-item {
- background-color: #fff;
- position: relative;
- padding: 16rpx;
- padding-bottom: 24rpx;
- margin: 0 24rpx;
- margin-bottom: 24rpx;
- border-radius: 8rpx;
- .title-container {
- margin: 8rpx 0;
- width: 100%;
- .title {
- height: 48rpx;
- justify-content: space-between;
- align-items: center;
- flex: 7;
- .label {
- // font-size: 32rpx;
- font-weight: bold;
- }
- .code {
- margin-left: 8rpx;
- }
- }
- }
- .item-info {
- margin-bottom: 8rpx;
- .label {
- font-size: 28rpx;
- width: 152rpx;
- color: #808080;
- &.right {
- flex: 1;
- color: #000000;
- }
- }
- }
- .right-info {
- // justify-content: flex-end;
- // width:45%;
- // margin-top: 5rpx;
- .label {
- font-size: 28rpx;
- }
- .time {
- margin-left: 8rpx;
- color: #1684fc;
- }
- .number {
- margin-left: 8rpx;
- color: #1684fc;
- }
- }
- }
- .top {
- position: fixed;
- bottom: 132rpx;
- right: 0;
- left: 0;
- height: 80rpx;
- padding: 0 24rpx;
- align-items: center;
- justify-content: center;
- background-color: #FFFFFF;
- .top-btn {
- font-size: 28rpx;
- color: #FFFFFF;
- background-color: #1684fc;
- width: 100%;
- }
- }
- .bottom {
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- height: 100rpx;
- padding: 16rpx 24rpx;
- align-items: center;
- background-color: #FFFFFF;
- justify-content: space-between;
- .bottom-btn {
- flex: 1;
- font-size: 28rpx;
- color: #FFFFFF;
- &.left-btn {
- background-color: rgba(0, 226, 166, 1);
- }
- &.right-btn {
- margin-left: 24rpx;
- }
- }
- }
- .status-btn {
- width: 100%;
- justify-content: flex-end;
- .finished-turnover-tag {
- margin: unset;
- border-radius: 8rpx;
- background-color: rgb(255, 85, 85);
- font-size: 28rpx;
- color: #FFFFFF;
- }
- .start-turnover-tag {
- margin: unset;
- border-radius: 8rpx;
- font-size: 28rpx;
- color: #FFFFFF;
- }
- }
- </style>
|