This commit is contained in:
2025-11-24 11:02:42 +08:00
parent ca41f4f528
commit 765f48bd03
12 changed files with 441 additions and 221 deletions

View File

@@ -24,12 +24,6 @@
<uni-data-select v-model="index" :localdata="options" placeholder="" @change="selectChange"></uni-data-select>
</view>
</view>
<view class="zd-row">
<button class="zd-col-6 button-primary ftsize1" @tap="toScanAdd">{{$t('button.scan-add')}}</button>
<button class="zd-col-5 button-primary ftsize1" @tap="toAdd">{{$t('button.add-row')}}</button>
<button class="zd-col-5 button-primary ftsize1" @tap="toDel">{{$t('button.del-row')}}</button>
<button class="zd-col-6 button-primary ftsize1" @tap="toCopy">{{$t('button.copy-row')}}</button>
</view>
</view>
<view class="zd_wrapper grid-wraper">
<view class="slide_new">
@@ -65,8 +59,10 @@
</view>
</view>
<view class="zd-row submit-bar">
<!-- <button class="zd-col-22 button-primary" :class="{'button-info': !val1 || !dataList.length || !index}" :disabled="disabled" @tap="_blanking">确认下料</button> -->
<button class="zd-col-22 button-primary" :class="{'button-info': !val1 || !dataList.length || !index}" :disabled="disabled" @tap="_blanking">{{$t('button.confirm-down-material')}}</button>
<!-- <button class="zd-col-22 button-primary" :class="{'button-info': !val1 || !dataList.length || !index}" :disabled="disabled" @tap="_productBlanking">{{$t('button.confirm-down-material')}}</button> -->
<button class="zd-col-7 button-primary" :class="{'button-info': !val1 || !index || !dataList.length}" :disabled="disabled" @tap="handleConfirm('1')">{{$t('button.scxl')}}</button>
<button class="zd-col-8 button-default" :class="{'button-info': !val1 || !index || !dataList.length}" :disabled="disabled" @tap="handleConfirm('2')">{{$t('button.zjps')}}</button>
<button class="zd-col-8 button-default" :class="{'button-info': !val1 || !index || !dataList.length}" :disabled="disabled" @tap="handleConfirm('3')">{{$t('button.zjxl')}}</button>
</view>
</view>
</template>
@@ -75,7 +71,7 @@
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import { confirmAction } from '@/utils/utils.js'
import {getNextRegions, selectMaterials, blanking} from '@/utils/getData4.js'
import {getNextRegionsByPoint, selectMaterials, productBlanking} from '@/utils/getData4.js'
export default {
components: {
NavBar,
@@ -98,26 +94,26 @@
this.title = options.title
},
onShow() {
if (this.$store.getters.publicObj !== '') {
this.currentData = this.$store.getters.publicObj
this.pkId = ''
this.dataList.map((item) => {
if (this.pkObj.mid === item.mid) {
item.material_name = this.currentData.material_name
item.material_code = this.currentData.material_code
item.measure_unit_id = this.currentData.measure_unit_id
}
})
this.$store.dispatch('setPublicObj', '')
}
// if (this.$store.getters.publicObj !== '') {
// this.currentData = this.$store.getters.publicObj
// this.pkId = ''
// this.dataList.map((item) => {
// if (this.pkObj.mid === item.mid) {
// item.material_name = this.currentData.material_name
// item.material_code = this.currentData.material_code
// item.measure_unit_id = this.currentData.measure_unit_id
// }
// })
// this.$store.dispatch('setPublicObj', '')
// }
},
created () {
this._getNextRegions()
this._getNextRegionsByPoint()
},
methods: {
async _getNextRegions () {
async _getNextRegionsByPoint () {
try {
let res = await getNextRegions()
let res = await getNextRegionsByPoint(this.val1)
if (res) {
this.options = res.data
} else {
@@ -127,6 +123,22 @@
this.options = []
}
},
async _selectMaterials () {
let res = await selectMaterials(this.val1)
this.dataList = res.data
// this.totalCount = res.totalElements
// if (res.totalElements > 0) {
// const dataMap = res.data
// this.dataList = this.reload ? dataMap : this.dataList.concat(dataMap)
// this.reload = false
// } else {
// this.dataList = []
// }
// if (this.totalCount == this.dataList.length) {
// this.reload = false
// this.status = 'noMore'
// }
},
selectChange (e) {
this.index = e
},
@@ -157,96 +169,6 @@
url: '/pages/ftdlDTY/mater-list0?title=查询物料'
})
},
toScanAdd () {
uni.scanCode({
success: (res) => {
// console.log('扫码成功:', res.result);
if (res.result.includes(';')) {
const parts = res.result.split(';')
if (parts.length !== 5) {
uni.showToast({
title: '二维码格式不正确,请扫描符合格式的二维码',
icon: 'none'
})
return
}
let currObj = {
mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
container_code: parts[0],
material_code: parts[1],
material_name: parts[2],
qty: parts[3],
measure_unit_id: parts[4],
}
// 检查是否已存在相同卷号
const exists = this.dataList.some(item => item.container_code === currObj.container_code)
if (exists) {
uni.showToast({
title: '已存在',
icon: 'none'
})
return
}
this.dataList.push(currObj)
} else {
let currObj = {
mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
container_code: res.result,
material_code: '',
material_name: '',
qty: '',
measure_unit_id: ''
}
// 检查是否已存在相同卷号
const exists = this.dataList.some(item => item.container_code === currObj.container_code)
if (exists) {
uni.showToast({
title: '已存在',
icon: 'none'
})
return
}
this.dataList.push(currObj)
}
},
fail: (err) => {
console.log('扫码失败:', err)
// uni.showToast({
// title: err + '扫码失败',
// icon: 'none'
// })
}
})
},
toAdd () {
let currObj = {
mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
container_code: '',
material_code: '编码',
material_name: '名称',
qty: '1',
measure_unit_id: '单位'
}
this.dataList.push(currObj)
},
toDel () {
if (!this.pkId) {
return
}
this.dataList = this.dataList.filter(item => item.mid !== this.pkObj.mid)
},
toCopy () {
if (!this.pkId) {
return
}
// let original = this.dataList.find(item => item.mid === this.pkObj.mid)
const copy = JSON.parse(JSON.stringify(this.pkObj))
// 更新mid为新生成的唯一值
copy.mid = 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9)
// 添加到原数组
this.dataList.push(copy)
this.pkId = ''
},
clearUp () {
this.val1 = ''
this.index = ''
@@ -256,19 +178,19 @@
this.currentData = {}
this.disabled = false
},
async handleConfirm() {
async handleConfirm(type) {
if (!this.val1 || !this.dataList.length || !this.index) {
return
}
const isConfirmed = await confirmAction("确认操作", "确定要执行此操作吗?")
if (isConfirmed) {
this._blanking()
this._productBlanking(type)
}
},
async _blanking () {
async _productBlanking (type) {
this.disabled = true
try {
let res = await blanking(this.val1, this.dataList, this.index)
let res = await productBlanking(this.val1, this.dataList, this.index, type)
uni.showToast({
title: res.message,
icon: 'none'