<template>
|
<view>
|
<page-nav title="安灯响应"></page-nav>
|
|
<u-notify ref="uNotify"></u-notify>
|
|
|
<view v-show="topContent.length===0">
|
<div class="sacnBody">
|
<div class="scanImg" @click="topScanClick"></div>
|
<div class="scanText">扫描工位</div>
|
</div>
|
</view>
|
|
<view v-show="topContent.length!==0">
|
<view class="mainContent">
|
<view>
|
|
<u-gap height="10" bgColor="#eff0f1"></u-gap>
|
<view class="head">
|
<view class="head_block">
|
<view class="head_left">
|
<view class="head_bar"></view>
|
<view class="head_title">
|
扫描工位
|
</view>
|
</view>
|
|
<view class="marginRight20">
|
<u-icon name="scan" @click="topScanClick" color="red" size="28"></u-icon>
|
</view>
|
</view>
|
|
<view class="marginTop20 marginLeft20 marginRight20" style="max-height:470rpx;overflow: auto;">
|
<u-radio-group v-model="radioValue" class="flex_column">
|
<view class="marginBottom20 flex_between" @click="groupChange(item.code)"
|
v-for="item in topContent" :key="item.code">
|
<view style="display: flex;">
|
<view class="flex_column titleFont">
|
<view>工位编码:</view>
|
<view>工位名称:</view>
|
<view>生产车间:</view>
|
</view>
|
<view class="flex_column contentFont">
|
<view>{{item.code}}</view>
|
<view>{{item.name}}</view>
|
<view>{{item.wksp_name}}</view>
|
</view>
|
</view>
|
<u-radio size='20' :key="item.code" :name="item.code"
|
@change="groupChange(item.code)" activeColor="red"></u-radio>
|
</view>
|
</u-radio-group>
|
</view>
|
|
</view>
|
|
<u-gap height="10" bgColor="#eff0f1"></u-gap>
|
<view class="head">
|
<view class="head_block">
|
<view class="head_left">
|
<view class="head_bar"></view>
|
<view class="head_title">
|
选择呼叫类型
|
</view>
|
</view>
|
</view>
|
|
<view class="marginTop20 marginBottom20">
|
|
<view class="flex_column" style="margin: 10rpx;" v-for="item in centerContent"
|
:key="item.code">
|
<div style="display: flex;justify-content: space-between">
|
<div class="marginLeft20 contentFont">{{item.name}}</div>
|
<u-switch class="marginRight20" activeColor="red" :key="item.code+Math.random()"
|
v-model="item.isTrue" size="20" @change='switchChange(item.code)'></u-switch>
|
</div>
|
</view>
|
</view>
|
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<u-button size="large" type="primary" @click="submit" :loading="isDisabledSubmitButton"
|
loadingText="正在提交,请稍等..." text="确认提交">
|
</u-button>
|
|
</view>
|
|
<scan-code></scan-code>
|
</view>
|
</template>
|
|
<script>
|
import {
|
AppAnDonLampResponseScanSearch,
|
AppAnDonLampResponseSave,
|
} from '../../config/api.js'
|
import scanCode from '@/components/scan-code/scan-code.vue'
|
export default {
|
components: {
|
scanCode
|
},
|
onLoad(option) {
|
const _this = this
|
uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
|
uni.$on('scancodedate', function(content) {
|
console.log("扫描到的内容为:", content)
|
_this.getAppAnDonLampResponseScanSearch(content)
|
})
|
},
|
onPullDownRefresh() {
|
setTimeout(() => {
|
this.init(() => {
|
uni.stopPullDownRefresh();
|
})
|
}, 1000);
|
},
|
data() {
|
return {
|
topContent: [], //扫描工位
|
centerContent: [], //选择呼叫类型
|
scanContent: '', //扫描扫出来的值
|
radioValue: '', //单选框的值
|
|
isDisabledSubmitButton: false,
|
|
|
}
|
},
|
created() {
|
|
},
|
mounted() {
|
this.init()
|
this.getAppAnDonLampResponseScanSearch('LD001');
|
},
|
methods: {
|
init() {
|
uni.stopPullDownRefresh();
|
},
|
// 扫码 工位 的扫码框点击
|
topScanClick() {
|
let that = this;
|
uni.scanCode({
|
onlyFromCamera: true,
|
// scanType: ['barCode', 'qrCode'],
|
scanType: ['qrCode'],
|
success: function(res) {
|
that.scanContent = res.result;
|
let flag = false
|
that.topContent.forEach(item => {
|
if (item.code === res.result) {
|
flag = true
|
}
|
})
|
if (flag) {
|
that.$u.toast('此条码已扫描,已在列表中!')
|
} else {
|
//处理扫码事件
|
that.getAppAnDonLampResponseScanSearch(that.scanContent);
|
}
|
},
|
complete: function(res) {},
|
fail: function(res) {
|
|
}
|
|
});
|
},
|
// 获取扫描工位
|
async getAppAnDonLampResponseScanSearch(val) {
|
const res = await AppAnDonLampResponseScanSearch(this.global.formatData({
|
eqpcode: val
|
}))
|
if (res.code === '200') {
|
this.handleApiData(res.data)
|
}
|
},
|
|
//处理扫描之后调用接口返回回来的数据
|
handleApiData(val) {
|
let children = []
|
|
val.forEach(i => {
|
children.push({
|
code: i.typecode,
|
name: i.typename,
|
isTrue: false
|
})
|
})
|
|
this.topContent.unshift({
|
code: val[0].eqp_code,
|
name: val[0].eqp_name,
|
wksp_code: val[0].wksp_code,
|
wksp_name: val[0].wksp_name,
|
children
|
})
|
|
this.radioValue = this.topContent[0].code
|
|
this.centerContent = this.topContent[this.topContent.findIndex(i => i.code === this.radioValue)].children
|
|
|
|
this.$forceUpdate()
|
},
|
|
// 单选按钮点击
|
groupChange(val) {
|
this.centerContent = []
|
this.radioValue = val
|
this.centerContent = this.topContent[this.topContent.findIndex(i => i.code === this.radioValue)].children
|
|
this.$forceUpdate()
|
},
|
// 开关按钮点击
|
switchChange(val) {
|
this.centerContent.find(i => i.code === val).isTrue != this.centerContent.find(i => i.code === val).isTrue
|
this.$forceUpdate()
|
},
|
// 确认提交按钮
|
async submit() {
|
|
let data = []
|
data = this.topContent.filter(i => i.code === this.radioValue)[0].children.filter(i => i.isTrue ===
|
true)
|
this.isDisabledSubmitButton = true
|
|
|
const data1 = {
|
eqpcode: this.topContent.find(i => i.code === this.radioValue).code,
|
wkshpcode: this.topContent.find(i => i.code === this.radioValue).wksp_code
|
}
|
|
AppAnDonLampResponseSave(this.global.formatData(data1), data).then(
|
res => {
|
if (res.code === '200') {
|
uni.$u.toast('提交成功!')
|
this.isDisabledSubmitButton = false
|
this.topContent = this.topContent.filter(i => i.code !== this.radioValue)
|
if (this.topContent.length > 0) {
|
this.groupChange(this.topContent[0].code)
|
}
|
|
}
|
|
})
|
},
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import url('@/style/global.css');
|
|
::v-deep .uicon-arrow-left>span {
|
display: block;
|
}
|
</style>
|