From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- pages/product/produce/workstationList/index.vue | 795 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 795 insertions(+), 0 deletions(-) diff --git a/pages/product/produce/workstationList/index.vue b/pages/product/produce/workstationList/index.vue new file mode 100644 index 0000000..ce47ae6 --- /dev/null +++ b/pages/product/produce/workstationList/index.vue @@ -0,0 +1,795 @@ +<template> + <view class="page"> + <view class="workstation-index-bg" /> + <u-navbar title="鏈哄彴绠$悊" :background="background" :border-bottom="false" :title-bold="true" title-color="#000" + back-icon-color="#000" /> + + <view class="wrap"> + <view> + <uni-notice-bar class="content-notice" background-color="#A3E0C8" color="#007145" single + v-if="submitNotice" :text="submitNotice"></uni-notice-bar> + <uni-notice-bar class="content-notice" color="#D53F3F" single v-if="unsubmitNotice" + :text="unsubmitNotice"></uni-notice-bar> + </view> + <view class="content"> + <view class="content-header"> + <view class="content-header-left"> + <view class="content-header-icon-one"></view> + <view class="content-header-title">缂栧彿锛�</view> + <text>{{dutyRecordInfo.dutyNo}}</text> + </view> + <view class="content-header-right"> + <view class="clear-icon" @click="clear()"></view> + <view class="edit-icon" @click="edit()"></view> + </view> + </view> + <view class="content-body"> + <view class="content-body-title"> + 鐝鐧昏 + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 鏈� 鍙帮細 + </view> + <view class="content-body-item-right" @click="toWorkstation()"> + ( {{ workstationInfo.workCenter }} ) {{workstationInfo.workstationName}} + <u-icon name="arrow-right" color="#687792" size="28" @click="toWorkstation" + style="padding-left: 10rpx;"></u-icon> + </view> + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 鐝� 娆★細 + </view> + <view class="content-body-item-right"> + <uni-data-select class="_select" v-model="dutyRecordInfo.shiftId" :localdata="shiftList" + :border="false" :disabled="editState" @change="selectShiftChanged"></uni-data-select> + </view> + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 鐝� 缁勶細 + </view> + <view class="content-body-item-right"> + <uni-data-select class="_select" v-model="dutyRecordInfo.crewId" :localdata="crewList" + :border="false" :disabled="editState"></uni-data-select> + </view> + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 鐝鏃ユ湡锛� + </view> + <view class="content-body-item-right"> + <uni-datetime-picker type="date" :clear-icon="false" + v-model="dutyRecordInfo.dutyDate" :disabled="editState" @change="dutyDateChange" /> + </view> + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 寮�濮嬫椂闂达細 + </view> + <view class="content-body-item-right"> + <uni-datetime-picker type="datetime" v-model="dutyRecordInfo.startTime" + :disabled="editState" /> + </view> + </view> + + <view class="content-body-item param-extra"> + <view class="content-body-item-left"> + 缁撴潫鏃堕棿锛� + </view> + <view class="content-body-item-right"> + <uni-datetime-picker class="_time-picker" type="datetime" v-model="dutyRecordInfo.endTime" + :disabled="editState" /> + </view> + </view> + </view> + <view class="content-footer"> + <view class="footer-button"> + <wu-button :custom-style="customStyleOne" size="normal" text="鎻愪氦" + @click="submitDutyRecord"></wu-button> + </view> + <view class="footer-button"> + <wu-button :custom-style="customStyleTwo" size="normal" text="淇濆瓨" + @click="saveDutyRecord"></wu-button> + </view> + </view> + </view> + <view class="bottom"> + <view class="bottom-btn"> + <wu-button :custom-style="customStyleFive" shape="circle" :hairline="true" size="small" + @click="deleteDutyRecord" :plain="true"> + <image src="/static/custom/operationTask/red-delete-icon.png" + style="width: 30rpx; height: 30rpx; margin-right: 5rpx;"></image> + 鍒犻櫎 + </wu-button> + </view> + <view class="bottom-btn"> + <wu-button :custom-style="customStyleThree" shape="circle" :hairline="true" size="small" + @click="toDutyRecordHistory" :plain="true"> + <image src="/static/custom/operationTask/workstation/icon_history.png" + style="width: 30rpx; height: 30rpx; margin-right: 5rpx;"></image> + 鍘嗗彶 + </wu-button> + </view> + <view class="bottom-btn"> + <wu-button :custom-style="customStyleFour" shape="circle" :hairline="true" size="small" + @click="toUnSubmitDutyRecord" :plain="true"> + <image src="/static/custom/operationTask/workstation/icon_batch_submit.png" + style="width: 30rpx; height: 30rpx; margin-right: 5rpx;"></image> + 鎵归噺鎻愪氦 + </wu-button> + </view> + <view class="bottom-btn"> + <wu-button :custom-style="customStyleFour" shape="circle" :hairline="true" size="small" + @click="toBatchSaveDutyRecord" :plain="true"> + <image src="/static/custom/operationTask/workstation/icon_batch_save.png" + style="width: 30rpx; height: 30rpx; margin-right: 5rpx;"></image> + 鎵归噺淇濆瓨 + </wu-button> + </view> + </view> + </view> + </view> +</template> +<script> + import content_bg from '@/static/custom/product/productBg.png' + import { + dateFormat + } from "@/utils/date.js"; + export default { + components: {}, + data() { + return { + background: { + backgroundImage: `url(${content_bg})`, + backgroundAttachment: 'fixed', + backgroundSize: '100% auto', + backgroundRepeat: 'no-repeat', + }, + dutyRecordInfo: { + crewId: null, + dutyDate: null, + dutyNo: null, + dutyTime: null, + endTime: null, + id: null, + isLimitUpd: true, + isSubmit: null, + operationType: null, + shiftId: null, + startTime: null, + isConfirm: null, + workstationId: null + }, + updateDutyForm: { + dutyNo: null, + crewId: null, + dutyDate: null, + startTime: null, + endTime: null, + dutyTime: null, + shiftId: null, + id: null, + isSubmit: null + }, + status: false, + editState: true, + shiftList: [], + crewList: [], + shifts: [], + submitNotice: "", + unsubmitNotice: "", + workstationInfo: { + workstationId: null, + workstationNo: null, + workstationName: null, + workCenter: null, + dutyRecordId: null + } + } + }, + computed: { + customStyleOne() { + return { + color: '#FFFFFF', + background: '#214DED', + width: '140rpx' + } + }, + customStyleTwo() { + return { + color: '#000000', + // background: '#214DED', + width: '150rpx' + } + }, + customStyleThree() { + return { + color: '#214DED', + // background: 'rgba(250, 252, 255, 0.36);', + width: '150rpx', + border: "1px solid #214DED" + } + }, + customStyleFour() { + return { + color: '#214DED', + // background: 'rgba(250, 252, 255, 0.36);', + width: '190rpx', + border: "1px solid #214DED" + } + }, + customStyleFive() { + return { + color: 'red', + width: '140rpx', + border: "1px solid red" + } + } + }, + onLoad(option) { + this.getShiftList(); + this.getCrewList(); + + if (option && option.id !== "null") { + this.getWorkstationList(option.id); + } + }, + onShow() { + + }, + methods: { + toWorkstation() { + uni.navigateTo({ + url: '/pages/product/produce/workstationList/workstationList' + }) + }, + toDutyRecordHistory() { + uni.navigateTo({ + url: './dutyRecordHistory?id=' + this.workstationInfo.workstationId + }) + }, + toUnSubmitDutyRecord() { + uni.navigateTo({ + url: './unSubmitDutyRecord?workCenter=' + this.workstationInfo.workCenter + }) + }, + toBatchSaveDutyRecord() { + const validResult = this.validDutyForm() + if (validResult.result) { + if (this.dutyRecordInfo.id) { + this.$u.toast('璇ョ彮娆″凡瀛樺湪锛屼笉鍙繘琛屾壒閲忎繚瀛樻搷浣�') + } else { + let params = this.dutyRecordInfo; + this.$set(params, 'workCenter', this.workstationInfo.workCenter) + + uni.navigateTo({ + url: './dutyRecordWorkstation?params=' + encodeURIComponent(JSON.stringify(params)) + }) + } + } else { + uni.showModal({ + title: '鎻愮ず', + content: validResult.msg, + showCancel: false, + success: function() {} + }); + } + }, + setWorkstation(workstation) { + this.workstationInfo.workstationId = workstation.id; + this.workstationInfo.workstationNo = workstation.workstationNo; + this.workstationInfo.workstationName = workstation.name; + this.workstationInfo.workCenter = workstation.workCenter; + this.workstationInfo.dutyRecordId = workstation.dutyRecordId; + // 瀛樺叆缂撳瓨 + uni.setStorage({ + key: 'workstation', + data: JSON.stringify(workstation), + success: function() {} + }); + + this.clear(); + this.getDutyRecordByWorkstationId(workstation.id); + }, + getShiftList() { + this.$u.api.operationTask.getShiftList({}).then(res => { + res.data.forEach((el) => { + const shift = { + text: el.name, + value: el.id + }; + this.shiftList.push(shift); + this.shifts = res.data; + }); + }); + }, + getCrewList() { + this.$u.api.operationTask.getCrewList({}).then(res => { + res.data.forEach((el) => { + const crew = { + text: el.crewName, + value: el.id + }; + this.crewList.push(crew); + }); + }); + }, + getDutyRecordByWorkstationId(workstationId) { + this.$u.api.outputRegister.getDutyRecordByWorkstationId({ + id: workstationId + }).then(res => { + if (res.data) { + this.dutyRecordInfo = res.data; + this.workstationInfo.dutyRecordId = this.dutyRecordInfo.id; + if (this.dutyRecordInfo.isConfirm) { + this.status = true; + } else { + this.status = false; + } + this.noticeShow(); + } + }); + }, + saveDutyRecord() { + this.dutyRecordInfo.workstationId = this.workstationInfo.workstationId; + const validResult = this.validDutyForm(); + if (validResult.result) { + if (this.dutyRecordInfo.id) { + if (!this.status) { + this.updateDutyForm.dutyNo = this.dutyRecordInfo.dutyNo + this.updateDutyForm.crewId = this.dutyRecordInfo.crewId + this.updateDutyForm.dutyDate = this.dutyRecordInfo.dutyDate + this.updateDutyForm.startTime = this.dutyRecordInfo.startTime + this.updateDutyForm.endTime = this.dutyRecordInfo.endTime + this.updateDutyForm.dutyTime = this.dutyRecordInfo.dutyTime + this.updateDutyForm.shiftId = this.dutyRecordInfo.shiftId + this.updateDutyForm.id = this.dutyRecordInfo.id + this.updateDutyForm.isSubmit = this.dutyRecordInfo.isSubmit + + this.$set(this.updateDutyForm, 'operationType', '缂栬緫'); + this.$set(this.updateDutyForm, 'isLimitUpd', true); + + this.updDutyRecord(); + } else { + uni.showModal({ + title: '鎻愮ず', + content: '璇ョ彮娆″凡纭锛屼笉鍙慨鏀�', + showCancel: false, + success: function() {} + }); + return; + } + } else { + this.dutyRecordInfo.isSubmit = false; + this.addDutyRecord(); + } + } else { + uni.showModal({ + title: '鎻愮ず', + content: validResult.msg, + showCancel: false, + success: function() {} + }); + return; + } + }, + addDutyRecord() { + this.$u.api.operationTask.addDutyRecord(this.dutyRecordInfo).then(res => { + if (res.code == 0) { + this.dutyRecordInfo = res.data; + this.status = false; + this.editState = true; + this.updWorkstation(); + + uni.showModal({ + title: '鎻愮ず', + content: '淇濆瓨鎴愬姛', + showCancel: false, + success: function() {} + }) + } else { + uni.showModal({ + title: '鎻愮ず', + content: res.msg, + showCancel: false, + success: function() {} + }) + } + }); + }, + updDutyRecord() { + this.$u.api.operationTask.updDutyRecord(this.updateDutyForm).then(res => { + if (res.code == 0) { + this.editState = true; + this.dutyRecordInfo = res.data; + uni.showModal({ + title: '鎻愮ず', + content: '淇敼鎴愬姛', + showCancel: false, + success: function() {} + }) + } else { + uni.showModal({ + title: '鎻愮ず', + content: res.msg, + showCancel: false, + success: function() { + + } + }) + } + }); + }, + submitDutyRecord() { + if (!this.dutyRecordInfo.id) { + uni.showModal({ + title: '鎻愮ず', + content: '璇烽�夋嫨鐝鎻愪氦', + showCancel: false, + success: function() {} + }); + return; + } + + const params = { + id: this.dutyRecordInfo.id, + isLimitUpd: true, + isSubmit: true, + operationType: '鎻愪氦' + } + + this.$u.api.operationTask.updDutyRecord(params).then(res => { + if (res.code == 0) { + this.dutyRecordInfo = res.data; + this.noticeShow(); + uni.showModal({ + title: '鎻愮ず', + content: '鎻愪氦鎴愬姛', + showCancel: false, + success: function() {} + }) + } else { + uni.showModal({ + title: '鎻愮ず', + content: res.msg, + showCancel: false, + success: function() { + + } + }) + } + }); + }, + // 宸ヤ綔绔欑粦瀹氱彮娆� + updWorkstation() { + const params = { + id: this.workstationInfo.workstationId, + dutyRecordId: this.dutyRecordInfo.id + }; + this.$u.api.operationTask.updWorkstation(params); + }, + getWorkstationList(workstationId) { + this.$u.api.operationTask.getWorkstationList({ + id: workstationId + }).then(res => { + if (res.code == 0) { + const workstation = res.data[0]; + this.workstationInfo.workstationId = workstation.id; + this.workstationInfo.workstationNo = workstation.workstationNo; + this.workstationInfo.workstationName = workstation.name; + this.workstationInfo.workCenter = workstation.workCenter; + + this.getDutyRecordByWorkstationId(workstation.id); + } + }); + }, + selectShiftChanged(shiftId) { + const shift = this.shifts.find((item) => item.id === shiftId) + let date = new Date() + if (this.dutyRecordInfo.dutyDate) { + date = this.dutyRecordInfo.dutyDate + } else { + this.dutyRecordInfo.dutyDate = dateFormat(date) + } + this.autoValue(shift, date) + }, + selectDutyDate(dutyDate) { + const shift = this.shifts.find( + (item) => item.id === this.dutyRecordInfo.shiftId + ) + if (shift) { + this.autoValue(shift, dutyDate) + } + }, + deleteDutyRecord() { + if (this.dutyRecordInfo.isSubmit) { + this.$u.toast('璇ョ彮娆″凡鎻愪氦锛佷笉鍙垹闄わ紒'); + return; + } + let that = this + uni.showModal({ + title: '鎻愮ず', + content: '鏄惁纭鍒犻櫎鐝璁板綍缂栧彿涓猴細' + this.dutyRecordInfo.dutyNo, + success: function(res) { + if (res.confirm) { + that.$u.api.operationTask.delDutyRecord({ + id: that.dutyRecordInfo.id + }).then(res => { + if (res.code == 0) { + that.clear(); + } + }); + } else if (res.cancel) { + return; + } + } + }); + }, + autoValue(shift, date) { + const a = [ + 'sunday', + 'monday', + 'tuesday', + 'wensday', + 'thursday', + 'friday', + 'saturday' + ] + const day = a[new Date().getDay()] + const hours = day + 'Hours' + const workHours = day + 'WorkHours' + const start = shift[`${hours}`].split('-')[0] + const end = shift[`${hours}`].split('-')[1] + this.dutyRecordInfo.startTime = + this.dutyRecordInfo.dutyDate.split(' ')[0] + ' ' + start + ':00' + // 澶滅彮杩欑鎯呭喌缁撴潫鏃堕棿瑕佽绠楀埌涓嬩竴澶� + if (start < end) { + this.dutyRecordInfo.endTime = + this.dutyRecordInfo.dutyDate.split(' ')[0] + ' ' + end + ':00' + } else { + const nextDay = dateFormat( + new Date(new Date().setDate(new Date(date).getDate() + 1)) + ) + this.dutyRecordInfo.endTime = nextDay.split(' ')[0] + ' ' + end + ':00' + } + this.dutyRecordInfo.dutyTime = shift[`${workHours}`] + }, + dutyDateChange(e) { + this.dutyRecordInfo.dutyDate = e + ' 00:00:00'; + this.selectDutyDate(); + }, + validDutyForm() { + if (!this.dutyRecordInfo.dutyDate) { + return { + result: false, + msg: '鐝鏃ユ湡涓嶈兘涓虹┖' + } + } + if (!this.dutyRecordInfo.startTime) { + return { + result: false, + msg: '寮�濮嬫椂闂翠笉鑳戒负绌�' + } + } + if (!this.dutyRecordInfo.endTime) { + return { + result: false, + msg: '缁撴潫鏃堕棿涓嶈兘涓虹┖' + } + } + if (!this.dutyRecordInfo.dutyTime) { + return { + result: false, + msg: '鐝鏃堕棿涓嶈兘涓虹┖' + } + } + if (!this.dutyRecordInfo.shiftId) { + return { + result: false, + msg: '鐝涓嶈兘涓虹┖' + } + } + if (!this.dutyRecordInfo.workstationId) { + return { + result: false, + msg: '宸ヤ綔绔欎笉鑳戒负绌�' + } + } + return { + result: true, + msg: '' + } + }, + noticeShow() { + if (this.dutyRecordInfo.isSubmit) { + this.submitNotice = "璇ョ彮娆″凡鎻愪氦!"; + this.unsubmitNotice = ""; + } else { + this.unsubmitNotice = "璇ョ彮娆℃湭鎻愪氦!"; + this.submitNotice = ""; + } + }, + clear() { + Object.keys(this.dutyRecordInfo).forEach(key => { + this.dutyRecordInfo[key] = null; + }); + if (this.workstationInfo.workstationId) { + this.dutyRecordInfo.workstationId = this.workstationInfo.workstationId; + } + this.submitNotice = ""; + this.unsubmitNotice = ""; + }, + edit() { + this.editState = !this.editState; + } + }, + } +</script> +<style lang="scss" scoped> + .workstation-index-bg { + background-color: #F6F9FF; + background-image: url('~@/static/custom/product/productBg.png'); + // background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0)); + padding: 0 20rpx; + background-attachment: fixed; + background-size: 100% auto; + background-repeat: no-repeat; + position: fixed; + top: 0; + bottom: 0; + width: 100%; + z-index: -1; + } + + .slot-box { + /* #ifndef APP-NVUE */ + display: flex; + /* #endif */ + flex-direction: row; + align-items: center; + } + + .slot-text { + flex: 1; + font-size: 30rpx; + margin-right: 10px; + } + + .content-notice { + height: 45rpx; + text-align: center; + margin: 0; + } + + .content { + font-size: 12px; + background-color: rgba(250, 252, 255, 0.36); + box-sizing: border-box; + border-radius: 10rpx; + margin: 0rpx 0rpx 24rpx; + padding: 10rpx 20rpx; + box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(127, 127, 127, 0.1) !important; + position: relative; + + .content-header { + height: 90rpx; + display: flex; + align-items: center; + justify-content: space-between; + + .content-header-left { + display: flex; + align-items: center; + margin-left: 10rpx; + + .content-header-icon-one { + background-image: url('~@/static/custom/materialReturn/label-icon-1.png'); + background-size: 100% auto; + background-repeat: no-repeat; + height: 32rpx; + width: 32rpx; + } + + .content-header-title { + margin-left: 11rpx; + font-size: 32rpx; + font-weight: bold; + color: #333333; + } + + text { + font-size: 32rpx; + } + } + + .content-header-right { + display: flex; + + .edit-icon { + background-image: url('~@/static/custom/operationTask/edit-icon.png'); + background-size: 100% auto; + background-repeat: no-repeat; + height: 32rpx; + width: 32rpx; + margin-right: 35rpx; + } + + .clear-icon { + background-image: url('~@/static/custom/operationTask/workstation/icon_clear.png'); + background-size: 100% auto; + background-repeat: no-repeat; + height: 32rpx; + width: 32rpx; + margin-right: 35rpx; + } + } + } + + .content-body { + margin-top: 20rpx; + + .content-body-title { + margin-left: 30rpx; + font-size: 38rpx; + font-weight: bold; + } + + .content-body-item { + height: 100rpx; + border: 1px solid #ADC8E4; + line-height: 100rpx; + display: flex; + justify-content: space-between; + border: none; + margin: 20rpx 30rpx 0rpx 30rpx; + font-size: 32rpx; + + .content-body-item-left {} + + .content-body-item-right { + + + + + ._select { + padding-top: 10rpx; + width: 300rpx; + border: none; + text-align: right; + } + } + } + + .param-extra { + border-bottom: 1px solid #D5D5D5; + } + } + + .content-footer { + margin: 30rpx ; + display: flex; + justify-content: flex-end; + + .footer-button { + margin-right: 35rpx; + } + } + } + + .bottom { + height: 100rpx; + display: flex; + justify-content: space-between; + + .bottom-btn { + margin: 10rpx 10rpx; + } + } +</style> \ No newline at end of file -- Gitblit v1.9.3