<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()"
|
:disabled="item.flag==='Y'" 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="确认提交" :disabled="centerContent.length===centerSelected.length">
|
</u-button>
|
|
</view>
|
|
<scan-code></scan-code>
|
</view>
|
</template>
|
|
<script>
|
import {
|
AppAnDonCallSave,
|
AppAnDonCallScanSearch,
|
AppAnDonCallItemSearch,
|
} 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.getAppDeviceAnDengCallScanSearch(content)
|
})
|
},
|
onPullDownRefresh() {
|
setTimeout(() => {
|
this.init(() => {
|
uni.stopPullDownRefresh();
|
})
|
}, 1000);
|
},
|
data() {
|
return {
|
|
topContent: [], //头部数据
|
centerContent: [], //选择呼叫类型
|
scanContent: '', //扫描扫出来的值
|
radioValue: '', //单选框的值
|
|
centerSelected: [], //点击头部切换时 已选中的开关
|
|
isDisabledSubmitButton: false, //提交按钮是否处于加载中
|
}
|
},
|
created() {
|
|
},
|
mounted() {
|
this.init()
|
// this.getAppDeviceAnDengCallScanSearch('LD001');
|
|
},
|
methods: {
|
init() {
|
uni.stopPullDownRefresh();
|
},
|
// 扫码 工位 的扫码框点击
|
topScanClick() {
|
let that = this;
|
uni.scanCode({
|
onlyFromCamera: true,
|
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.getAppDeviceAnDengCallScanSearch(that.scanContent);
|
}
|
},
|
complete: function(res) {},
|
fail: function(res) {
|
|
}
|
|
});
|
},
|
// 获取扫描工位
|
async getAppDeviceAnDengCallScanSearch(val) {
|
const res = await AppAnDonCallScanSearch(this.global.formatData({
|
eqpcode: val
|
}))
|
if (res.code === '200') {
|
this.topContent.unshift(res.data[0])
|
this.radioValue = this.topContent[0].code
|
|
this.$forceUpdate()
|
this.getAppDeviceAnDengCallItemSearch(this.radioValue)
|
}
|
},
|
async getAppDeviceAnDengCallItemSearch(val) {
|
const data = {
|
eqpcode: val,
|
wkshpcode: this.topContent.find(i => i.code === val).wksp_code
|
}
|
|
const res = await AppAnDonCallItemSearch(this.global.formatData(data))
|
if (res.code === '200') {
|
this.centerContent = res.data
|
this.centerSelected = []
|
this.centerContent.forEach(r => {
|
r.isTrue = r.flag === 'Y'
|
if (r.flag === 'Y') {
|
this.centerSelected.push(r.code)
|
}
|
})
|
this.$forceUpdate()
|
}
|
},
|
// 单选按钮点击
|
groupChange(val) {
|
this.radioValue = val
|
this.$forceUpdate()
|
this.getAppDeviceAnDengCallItemSearch(val)
|
},
|
// 开关按钮点击
|
switchChange(val) {
|
this.centerContent.find(i => i.code === val).isTrue != this.centerContent.find(i => i.code === val).isTrue
|
this.$forceUpdate()
|
},
|
// 确认提交按钮
|
async submit() {
|
if (this.centerContent.filter(i => i.isTrue === true).length === this.centerSelected.length) {
|
return uni.$u.toast('提交失败!未对该设备选择新的呼叫类型')
|
}
|
|
this.isDisabledSubmitButton = true
|
let data = []
|
this.centerContent.forEach(i => {
|
if (i.isTrue && !this.centerSelected.includes(i.code)) {
|
i.flag = i.isTrue ? 'Y' : 'N'
|
data.push(i)
|
}
|
})
|
|
const data1 = {
|
eqpcode: this.topContent.find(i => i.code === this.radioValue).code,
|
wkshpcode: this.topContent.find(i => i.code === this.radioValue).wksp_code
|
}
|
|
|
AppAnDonCallSave(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>
|