| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <view class="content-box">
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
- color="#000" @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode">
- </uni-nav-bar>
- <view class="list_box">
- <u-list @scrolltolower="scrolltolower">
- <view class="card_box">
- <workOrderBom :item='objData' v-if='objData' @handleScan='handleScan'></workOrderBom>
- <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList'></deviceBom>
- <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList'>
- </modelBom>
- <jobBom :item='objData'></jobBom>
- <byProductBom v-if='objData.productRecycleList.length != 0 ' :list='objData.productRecycleList'>
- </byProductBom>
- <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :wordItem='objData'
- @handleScan='handleScan' @handleDel='handleDel'>
- </turnoverBom>
-
- <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
- @handleScan='handleScan' @handleDel='handleDel'></aridRegion>
- <view class="operate_box rx-sc">
- <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
- </view>
- </view>
- </u-list>
- </view>
- <view class="bottom-wrapper">
- <view class="btn_box" @click="save">一键报工</view>
- </view>
- </view>
- </template>
- <script>
- import {
- getByIdReport,
- getByCodeReport
- } from '@/api/pda/jobBooking.js'
- import {
- scanLedger
- } from '@/api/pda/workOrder.js'
- import workOrderBom from '../../feeding/components/workOrderBom.vue'
- import deviceBom from '../../feeding/components/deviceBom.vue'
- import modelBom from '../../feeding/components/modelBom.vue'
- import jobBom from '../components/jobBom.vue'
- import byProductBom from '../components/byProductBom'
- import turnoverBom from '../components/turnoverBom.vue'
- import aridRegion from '../components/aridRegion.vue'
- export default {
- components: {
- workOrderBom,
- deviceBom,
- modelBom,
- jobBom,
- byProductBom,
- turnoverBom,
- aridRegion
- },
- data() {
- return {
- title: '',
- objData: {
- equipmentList: [],
- modelList: [],
- turnover: [],
- productRecycleList: [],
- aridRegionList: []
- },
-
- id: null,
- taskId: null,
- }
- },
- onLoad(options) {
- this.title = options.taskName ? options.taskName + '-报工' : '报工'
- this.id = options.id
- this.taskId = options.taskId
- this.getList()
- },
- onShow() {
- uni.$off("setSelectList");
- uni.$on("setSelectList", (selectList, id) => {
- let turnover = []
- let aridRegionList = []
- selectList.forEach(f => {
- if (f.rootCategoryLevelId == 7) { // 周转车
- turnover = turnover.concat(f)
- }
- })
- selectList.forEach(f => {
- if (f.rootCategoryLevelId == 11) { // 干燥区
- aridRegionList = aridRegionList.concat(f)
- }
- })
- this.$set(this.objData, 'turnover', turnover)
- this.$set(this.objData, 'aridRegionList', aridRegionList)
- this.$forceUpdate()
- });
- },
- methods: {
- // 相机扫码
- HandlScanCode() {
- // CX-EQ-YLSJL-008 设备
- // M001 M002 模具
- // 周转车 w0300000003140004
- this.scanItAllData('M002')
- return false
- let _this = this
- uni.scanCode({
- success: function(res) {
- _this.scanItAllData(res.result)
- }
- })
- },
- scanItAllData(result) {
- scanLedger(result).then(res => {
- if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
- if (this.objData.equipmentList.length == 0) {
- this.objData.equipmentList = res
- this.$forceUpdate()
- } else {
- if (this.objData.equipmentList[0].instanceId != res[0].instanceId) {
- uni.showToast({
- title: '设备不匹配',
- icon: 'none'
- })
- } else {
- uni.showToast({
- title: '设备匹配成功',
- icon: 'none'
- })
- }
- }
- }
- if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
- if (this.objData.modelList.length == 0) {
- this.objData.modelList = res
- this.$forceUpdate()
- } else {
- if (this.objData.modelList[0].instanceId != res[0].instanceId) {
- uni.showToast({
- title: '模具不匹配',
- icon: 'none'
- })
- } else {
- uni.showToast({
- title: '设备匹配成功',
- icon: 'none'
- })
- }
- }
- } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
- let isFals = this.objData.turnover.some(m => m.code == result)
- if (isFals) {
- uni.showToast({
- title: '周转车已存在',
- icon: 'none'
- })
- return false
- }
- this.objData.turnover.push(res[0])
- this.$forceUpdate()
- }
- })
- },
- handleDel(idx, type) {
- if (type == 'turnover') {
- this.objData.turnover.splice(idx, 1)
- this.$forceUpdate()
- }
- if (type == 'aridRegion') {
- this.objData.aridRegionList.splice(idx, 1)
- this.$forceUpdate()
- }
- },
- handleScan(id, type) {
- let _this = this
- uni.scanCode({
- success: function(res) {
- _this.scanData(res.result, type, id)
- }
- })
- },
- scanData(result, type, id) {
- if (type == 'wordOrder') {
- getByCodeReport(result, this.taskId).then(res => {
- this.objData = res
- if (!this.objData.hasOwnProperty('turnover')) {
- this.objData['turnover'] = []
- }
- if (!this.objData.hasOwnProperty('aridRegionList')) {
- this.objData['aridRegionList'] = []
- }
- })
- } else if (type == 'turnover') {
- let isFals = this.objData.turnover.some(m => m.code == result)
- if (isFals) {
- uni.showToast({
- title: '周转车已存在',
- icon: 'none'
- })
- return false
- }
- getByCodeReport(result, this.taskId).then(res => {
- this.objData.turnover[id] = res
- })
- }
- },
- getList() {
- getByIdReport(this.id, this.taskId).then(res => {
- this.objData = res
- if (!this.objData.hasOwnProperty('turnover')) {
- this.objData['turnover'] = []
- }
- if (!this.objData.hasOwnProperty('aridRegionList')) {
- this.objData['aridRegionList'] = []
- }
- console.log(this.objData)
- })
- },
- scrolltolower() {},
- handAdd() {
- const storageKey = Date.now() + "";
- uni.setStorageSync(storageKey, this.objData || {});
- uni.navigateTo({
- url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job`
- })
- },
- save() {
- if(this.objData.aridRegionList.length > 0) {
- if(!this.objData.aridRegionList[0].occupationTime) {
- uni.showToast({
- title: '请输入干燥时间',
- icon: 'none'
- })
- return false
- }
- }
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content-box {
- height: 100vh;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- }
- .list_box {
- flex: 1;
- overflow: hidden;
- padding: 4rpx 0;
- .u-list {
- height: 100% !important;
- }
- .card_box {
- padding: 16rpx 24rpx;
- }
- }
- .bottom-wrapper {
- .btn_box {
- width: 750rpx;
- height: 88rpx;
- line-height: 88rpx;
- background: $theme-color;
- text-align: center;
- font-size: 36rpx;
- font-style: normal;
- font-weight: 400;
- color: #fff;
- }
- }
- .operate_box {
- padding: 10rpx 160rpx;
- /deep/ .u-button {
- width: 160rpx;
- }
- }
- </style>
|