This commit is contained in:
bb_pan 2025-06-05 18:31:35 +08:00
parent cfdd8545e9
commit 30175452a6
5 changed files with 546 additions and 360 deletions

View File

@ -1,11 +1,5 @@
<template>
<uni-nav-bar
dark
:fixed="true"
shadow
background-color="#4AA4EA"
status-bar
:title="title"
<uni-nav-bar dark :fixed="true" shadow background-color="#4AA4EA" status-bar :title="title"
><template v-slot:left>
<view style="font-size: 18px; display: flex; align-items: center" @click="back">
<!-- 图标 -->
@ -14,123 +8,131 @@
<text>返回</text>
</view>
</template>
</uni-nav-bar>
<div class="content">
<uni-section title="任务信息" type="line"></uni-section>
<uni-forms ref="form" :rules="rules" :model="formData" label-width="80px">
<uni-forms-item label="退料班组" required name="teamId">
<uni-data-select
v-model="formData.teamId"
:localdata="teamRange"
filterable
:disabled="opts.isEdit"
@change="changeTeamd"
></uni-data-select>
</uni-forms-item>
<uni-forms-item label="工程名称" required name="projectId">
<eselect
style="width: 100%; height: 90rpx"
v-model="formData.projectId"
ref="treeSelect"
:options="prodRange"
:disabled="opts.isEdit"
@change="changeProd"
@clear="
<template v-slot:right>
<view style="font-size: 18px; display: flex; align-items: center" @click="submit(0)">
<!-- 文本 -->
<text>暂存</text>
</view>
</template>
</uni-nav-bar>
<div class="content">
<uni-section title="任务信息" type="line"></uni-section>
<uni-forms ref="form" :rules="rules" :model="formData" label-width="80px">
<uni-forms-item label="退料班组" required name="teamId">
<uni-data-select
v-model="formData.teamId"
:localdata="teamRange"
filterable
:disabled="opts.isEdit"
@change="changeTeamd"
></uni-data-select>
</uni-forms-item>
<uni-forms-item label="工程名称" required name="projectId">
<eselect
v-if="!opts.isEdit"
style="width: 100%; height: 45rpx"
v-model="formData.projectId"
ref="treeSelect"
:options="prodRange"
:disabled="opts.isEdit"
@change="changeProd"
@clear="
() => {
formData.projectId = ''
}
"
></eselect>
</uni-forms-item>
<uni-forms-item label="退料人员" required name="backPerson">
<uni-easyinput v-model="formData.backPerson" placeholder="请输入内容"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="联系电话" required name="phone">
<uni-easyinput
v-model="formData.phone"
placeholder="请输入内容"
maxlength="11"
@blur="checkPhone"
></uni-easyinput>
</uni-forms-item>
<uni-section title="工器具退料" type="line"></uni-section>
<eselect
v-model="equipmentId"
style="width: 100%; height: 90rpx; margin: 10px 0"
ref="treeSelect"
:options="equipmentList"
@change="changeEquipment"
></eselect>
</uni-forms>
></eselect>
<uni-easyinput v-else v-model="formData.proName" disabled></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="退料人员" required name="backPerson">
<uni-easyinput v-model="formData.backPerson" placeholder="请输入内容"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="联系电话" name="phone">
<uni-easyinput
v-model="formData.phone"
placeholder="请输入内容"
maxlength="11"
@blur="checkPhone"
></uni-easyinput>
</uni-forms-item>
<uni-section title="工器具退料" type="line"></uni-section>
<eselect
v-model="equipmentId"
style="width: 100%; height: 90rpx; margin: 10px 0"
ref="treeSelect"
:options="equipmentList"
:disabled="!formData.teamId || !formData.projectId"
@change="changeEquipment"
></eselect>
</uni-forms>
<uni-table ref="table" border stripe emptyText="暂无更多数据">
<uni-tr>
<uni-th width="60" align="center">序号</uni-th>
<uni-th width="140" align="center">类型名称</uni-th>
<uni-th width="140" align="center">规格型号</uni-th>
<uni-th width="80" align="center">在用数</uni-th>
<uni-th width="120" align="center">退料数</uni-th>
<uni-th width="120" align="center">损坏价值判定</uni-th>
<uni-th width="90" align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in tableData" :key="index">
<uni-td align="center">{{ index + 1 }}</uni-td>
<uni-td align="center">{{ item.maTypeName }}</uni-td>
<uni-td align="center">
<view class="name">{{ item.typeName }}</view>
</uni-td>
<uni-td align="center">{{ item.num }}</uni-td>
<uni-td align="center"
><uni-easyinput
v-model="item.preNum"
placeholder="请输入内容"
type="number"
@blur="checkPerNum(item)"
></uni-easyinput
></uni-td>
<uni-td align="center"
><uni-easyinput
v-model="item.apDetection"
placeholder="请输入内容"
></uni-easyinput
></uni-td>
<uni-td align="center">
<view>
<button
class="uni-button"
size="mini"
type="warn"
@click="
() => {
tableData.splice(index, 1)
}
"
>
删除
</button>
</view>
</uni-td>
</uni-tr>
</uni-table>
<uni-table ref="table" border stripe emptyText="暂无更多数据">
<uni-tr>
<uni-th width="60" align="center">序号</uni-th>
<uni-th width="140" align="center">类型名称</uni-th>
<uni-th width="140" align="center">规格型号</uni-th>
<uni-th width="80" align="center">在用数</uni-th>
<uni-th width="120" align="center">退料数</uni-th>
<uni-th width="120" align="center">损坏价值判定</uni-th>
<uni-th width="90" align="center">操作</uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in tableData" :key="index">
<uni-td align="center">{{ index + 1 }}</uni-td>
<uni-td align="center">{{ item.maTypeName }}</uni-td>
<uni-td align="center">
<view class="name">{{ item.typeName }}</view>
</uni-td>
<uni-td align="center">{{ item.num }}</uni-td>
<uni-td align="center">
<uni-easyinput
v-if="item.manageType == 1"
v-model="item.preNum"
placeholder="请输入数量"
type="number"
@blur="checkPerNum(item)"
></uni-easyinput>
<!-- 编码 -->
<span v-else style="color: #409eff" @click="getCode(item)">{{
item.maCodeList.length == 0 ? '选择编码' : item.maCodeList.length
}}</span>
</uni-td>
<uni-td align="center"
><uni-easyinput v-model="item.apDetection" placeholder="请输入内容"></uni-easyinput
></uni-td>
<uni-td align="center">
<button
class="uni-button"
size="mini"
type="warn"
@click="
() => {
tableData.splice(index, 1)
}
"
>
删除
</button>
<button class="uni-button" size="mini" type="primary" @click="">出库</button>
</uni-td>
</uni-tr>
</uni-table>
<button style="width: 100%; margin: 50px 0" size="mini" type="primary" @click="submit">
确定
</button>
</div>
<button style="width: 100%; margin: 50px 0" type="primary" @click="submit(1)"> </button>
</div>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { ref, reactive } from 'vue'
import eselect from '@/components/tree-select/eselect.vue'
import {
getBmTeamList,
getProjectList,
getTypeTreeList,
backTask,
editLeaseTask,
getAgreementInfoById,
detailsLeaseTask
getBmTeamList,
getProjectList,
getTypeTreeList,
backTask,
editBackTask,
getAgreementInfoById,
detailsBackTask,
} from '@/services/back.js'
import { getUseTypeTree } from '../../services/back'
@ -138,12 +140,13 @@ const title = ref('工器具退料申请')
const opts = ref({})
const form = ref()
const formData = reactive({
teamId: undefined,
projectId: '',
backPerson: '',
phone: '',
agreementId: undefined,
remark: undefined
teamId: undefined,
projectId: '',
backPerson: '',
phone: '',
agreementId: undefined,
remark: undefined,
isBack: 1,
})
const agreementId = ref('')
const equipmentId = ref()
@ -151,289 +154,366 @@ const teamRange = ref([]) // 班组
const prodRange = ref([]) //
const equipmentList = ref([]) //
const rules = {
teamId: {
rules: [{ required: true, errorMessage: '请选择班组' }],
},
projectId: {
rules: [{ required: true, errorMessage: '请选择工程' }],
},
backPerson: {
rules: [{ required: true, errorMessage: '请填写退料人' }],
},
phone: {
rules: [{ required: true, errorMessage: '请填写联系电话' }],
},
teamId: {
rules: [{ required: true, errorMessage: '请选择班组' }],
},
projectId: {
rules: [{ required: true, errorMessage: '请选择工程' }],
},
backPerson: {
rules: [{ required: true, errorMessage: '请填写退料人' }],
},
}
const tableData = ref([])
//
const getDetailsById = async () => {
try {
const res = await detailsLeaseTask(opts.value.id)
console.log('🚀 ~ getDetailsById ~ res:', res)
tableData.value = res.data.leaseApplyDetailsList
Object.assign(formData, res.data.leaseApplyInfo)
} catch (error) {
console.log('🚀 ~ getDetailsById ~ error:', error)
try {
const res = await detailsBackTask(opts.value.id)
console.log('🚀 ~ getDetailsById ~ res:', res)
res.data.backApplyInfo.projectId = res.data.backApplyInfo.proId
if (res.data && res.data.backApplyDetailsList.length > 0) {
tableData.value = res.data.backApplyDetailsList.map((item) => {
return {
...item,
maTypeName: item.materialName, //
}
})
}
Object.assign(formData, res.data.backApplyInfo)
console.log('🚀 ~ getDetailsById ~ formData:', formData)
getAgreement()
} catch (error) {
console.log('🚀 ~ getDetailsById ~ error:', error)
}
}
//
const getTeamList = async () => {
try {
const res = await getBmTeamList({ isAll: 0 })
// teamRange.value = res.data
if (res.data.length > 0) {
teamRange.value = res.data.map((item) => {
return {
...item,
value: item.id,
text: item.teamName,
}
})
try {
const res = await getBmTeamList({ isAll: 0 })
// teamRange.value = res.data
if (res.data.length > 0) {
teamRange.value = res.data.map((item) => {
return {
...item,
value: item.id,
text: item.teamName,
}
} catch (error) {
console.log('🚀 ~ getTeamList ~ error:', error)
})
}
} catch (error) {
console.log('🚀 ~ getTeamList ~ error:', error)
}
}
//
const getProjectListApi = async () => {
try {
const res = await getProjectList()
prodRange.value = res.data
} catch (error) {
console.log('🚀 ~ getProjectListApi ~ error:', error)
}
console.log('🚀 ~ 工程')
try {
const res = await getProjectList()
prodRange.value = res.data
} catch (error) {
console.log('🚀 ~ getProjectListApi ~ error:', error)
}
}
//
const getAgreement = () => {
console.log(formData.teamId,formData.projectId)
let obj = {
teamId: formData.teamId,
projectId: formData.projectId,
}
getAgreementInfoById(obj)
.then((res) => {
console.log(res)
if (res.code == 200) {
agreementId.value = res.data.agreementId
formData.agreementId = res.data.agreementId
getEquipmentList()
} else {
agreementId.value = ''
formData.agreementId=''
}
})
.catch((error) => {
formData.agreementId=''
console.log(error)
})
console.log(formData.teamId, formData.projectId)
let obj = {
teamId: formData.teamId,
projectId: formData.projectId,
}
getAgreementInfoById(obj)
.then((res) => {
console.log(res)
if (res.code == 200) {
agreementId.value = res.data.agreementId
formData.agreementId = res.data.agreementId
getEquipmentList()
} else {
agreementId.value = ''
formData.agreementId = ''
}
})
.catch((error) => {
formData.agreementId = ''
console.log(error)
})
}
//
const getEquipmentList = async () => {
try {
let obj = {
agreementId: agreementId.value,
}
const res = await getUseTypeTree(obj)
// machineList.value = res.data
if (res.data.length > 0) {
equipmentList.value = formatEquipmentTree(res.data)
console.log('🚀 ~ getEquipmentList ~ machineList.value:', equipmentList.value)
}
} catch (error) {
console.log('🚀 ~ getMachineListApi ~ error:', error)
try {
let obj = {
agreementId: agreementId.value,
}
const res = await getUseTypeTree(obj)
// machineList.value = res.data
if (res.data.length > 0) {
equipmentList.value = formatEquipmentTree(res.data)
console.log('🚀 ~ getEquipmentList ~ machineList.value:', equipmentList.value)
}
} catch (error) {
console.log('🚀 ~ getMachineListApi ~ error:', error)
}
}
function formatEquipmentTree(list) {
return list.map((item) => {
const newItem = {
...item,
id: item.typeId,
name: item.typeName,
}
if (item.children && item.children.length > 0) {
newItem.children = formatEquipmentTree(item.children)
}
return newItem
})
return list.map((item) => {
const newItem = {
...item,
id: item.typeId,
name: item.typeName,
}
if (item.children && item.children.length > 0) {
newItem.children = formatEquipmentTree(item.children)
}
return newItem
})
}
//
const checkPhone = (rule, value, callback) => {
if (!formData.phone) {
uni.showToast({
icon: 'none',
title: '请输入电话号码',
})
return false
}
if (!/^1[3-9][0-9]{9}$/.test(formData.phone)) {
uni.showToast({
icon: 'none',
title: '请输入正确的电话号码',
})
//
formData.phone = ''
return false
}
return true
if (!formData.phone) {
uni.showToast({
icon: 'none',
title: '请输入电话号码',
})
return false
}
if (!/^1[3-9][0-9]{9}$/.test(formData.phone)) {
uni.showToast({
icon: 'none',
title: '请输入正确的电话号码',
})
//
formData.phone = ''
return false
}
return true
}
//
const checkPerNum = (item) => {
// 1
if (!/^[1-9]\d*$/.test(item.preNum)) {
uni.showToast({
icon: 'none',
title: '请输入正确的数量',
})
// 1
item.preNum = 1
return false
}
// 1
if (!/^[1-9]\d*$/.test(item.preNum)) {
uni.showToast({
icon: 'none',
title: '请输入正确的数量',
})
// 1
item.preNum = 1
return false
}
}
//
const changeTeamd = (e) => {
console.log('🚀 ~ changeTeamd ~ e:', e)
formData.teamId = e
if (formData.teamId && formData.teamId.length > 0) {
getAgreement()
}
console.log('🚀 ~ changeTeamd ~ e:', e)
formData.teamId = e
if (formData.teamId && formData.teamId.length > 0) {
getAgreement()
}
}
//
const changeProd = (e) => {
console.log('🚀 ~ changeProd ~ e:', e)
formData.projectId = e.id
if (formData.projectId && formData.projectId.length > 0) {
getAgreement()
}
console.log('🚀 ~ changeProd ~ e:', e)
formData.projectId = e.id
if (formData.projectId && formData.projectId.length > 0) {
getAgreement()
}
}
//
const changeEquipment = (e) => {
console.log('🚀 ~ changeEquipment ~ e:', e)
if (e.manageType !== '1') {
//
uni.showToast({
icon: 'none',
title: '请选择数量设备',
})
return
}
// equipmentList.value id typeName
const equipment = findEquipmentById(equipmentList.value, e.parentId)
tableData.value.push({
...JSON.parse(JSON.stringify(e)),
maTypeName: equipment.typeName,
preNum: 1,
console.log('🚀 ~ changeEquipment ~ e:', e)
if (tableData.value.some((item) => item.typeId === e.typeId)) {
uni.showToast({
icon: 'none',
title: '该型号已添加',
})
setTimeout(() => {
equipmentId.value = ''
}, 300)
return
}
// if (e.manageType !== '1') {
// //
// uni.showToast({
// icon: 'none',
// title: '',
// })
// return
// }
// equipmentList.value id typeName
const equipment = findEquipmentById(equipmentList.value, e.parentId)
tableData.value.push({
...JSON.parse(JSON.stringify(e)),
maTypeName: equipment.typeName,
preNum: e.manageType == '1' ? 1 : 0, // 退1
maCodeList: [],
})
setTimeout(() => {
equipmentId.value = ''
}, 300)
}
// id
function findEquipmentById(list, id) {
for (const item of list) {
if (item.id === id) {
return item
}
if (item.children && item.children.length > 0) {
const found = findEquipmentById(item.children, id)
if (found) return found
}
for (const item of list) {
if (item.id === id) {
return item
}
return null
if (item.children && item.children.length > 0) {
const found = findEquipmentById(item.children, id)
if (found) return found
}
}
return null
}
const submit = () => {
console.log('🚀 ~ submit ~ submit:', formData)
//
form.value
.validate()
.then(async (valid) => {
console.log('🚀 ~ form.value.validate.then ~ valid:', valid)
if (tableData.value.length === 0) {
await uni.showToast({
title: '请添加退料数据',
icon: 'none',
duration: 1000,
})
return
}
// tableData.value preNum 0, 0
for (let i = 0; i < tableData.value.length; i++) {
console.log('🚀 ~ .then ~ tableData.value[i].preNum:', tableData.value[i].preNum)
if (tableData.value[i].preNum < 1) {
await uni.showToast({
title: `${i + 1}行退料数量不能为0`,
icon: 'none',
duration: 1000,
})
return
} else if (tableData.value[i].preNum > tableData.value[i].num) {
await uni.showToast({
title: `${i + 1}行退料数量不能大于在用数量`,
icon: 'none',
duration: 1000,
})
return
}
}
const params = {
backApplyDetailsList: tableData.value,
backApplyInfo: formData,
}
console.log('🚀 ~ .then ~ params:', params)
try {
if (!opts.value.isEdit) {
const res = await backTask(params)
console.log('🚀 ~ .then ~ res:', res)
back()
} else {
const res = await editLeaseTask(params)
back()
}
} catch (error) {
console.log('🚀 ~ .then ~ error:', error)
}
})
.catch((err) => {
console.log('🚀 ~ form.value.validate.catch ~ err:', err)
})
//
const getCode = (item) => {
console.log('🚀 ~ getCode ~ item:', item)
if (item.maCodeList.length > 0) {
item.maCodeList.forEach((code) => {
code.checked = true
})
}
item.isEdit = opts.value.isEdit
item.isBack = true
item.teamId = formData.teamId
item.projectId = formData.projectId
uni.navigateTo({
url: '/pages/toolsLease/codeOut?params=' + JSON.stringify(item),
})
}
const back = () => {
uni.navigateBack({
delta: 1,
const submit = (isBack) => {
console.log('🚀 ~ submit ~ submit:', formData)
//
form.value
.validate()
.then(async (valid) => {
formData.isBack = isBack
console.log('🚀 ~ form.value.validate.then ~ valid:', valid)
if (tableData.value.length === 0) {
await uni.showToast({
title: '请添加退料数据',
icon: 'none',
duration: 1000,
})
return
}
// tableData.value preNum 0, 0
for (let i = 0; i < tableData.value.length; i++) {
console.log('🚀 ~ .then ~ tableData.value[i].preNum:', tableData.value[i].preNum)
if (tableData.value[i].preNum < 1) {
await uni.showToast({
title: `${i + 1}行退料数量不能为0`,
icon: 'none',
duration: 1000,
})
return
} else if (tableData.value[i].preNum > tableData.value[i].num) {
await uni.showToast({
title: `${i + 1}行退料数量不能大于在用数量`,
icon: 'none',
duration: 1000,
})
return
}
}
const res = await uni.showModal({
title: '提示',
content: '是否确认提交?',
confirmText: '确定',
cancelText: '取消',
})
console.log('🚀 ~ .then ~ res:', res)
if (!res.confirm) return
tableData.value.forEach((item) => {
item.outNum = item.preNum
})
const params = {
backApplyDetailsList: tableData.value,
backApplyInfo: formData,
}
console.log('🚀 ~ .then ~ params:', params)
uni.showLoading({
title: '提交中...',
})
try {
if (!opts.value.isEdit) {
const res = await backTask(params)
console.log('🚀 ~ .then ~ res:', res)
uni.hideLoading()
back()
} else {
const res = await editBackTask(params)
uni.hideLoading()
back()
}
} catch (error) {
console.log('🚀 ~ .then ~ error:', error)
uni.hideLoading()
}
})
.catch((err) => {
console.log('🚀 ~ form.value.validate.catch ~ err:', err)
})
}
const rightClick = () => {
console.log(2)
uni.navigateTo({ url: `/pages/back/backCodeAdd` })
const back = () => {
if (tableData.value.length > 0) {
uni
.showModal({
title: '提示',
content: '当前有未提交的数据,是否暂存?',
confirmText: '确定',
cancelText: '取消',
})
.then((res) => {
if (res.confirm) {
submit(0)
} else {
uni.navigateBack({
delta: 1,
})
}
})
} else {
uni.navigateBack({
delta: 1,
})
}
}
onLoad((opt) => {
console.log('onLoad', opt)
opts.value = opt.params ? JSON.parse(opt.params) : {}
title.value = opts.value.isEdit ? '编辑工器具退料' : '新增工器具退料'
getTeamList()
getProjectListApi()
// getEquipmentList()
if (opts.value.isEdit) {
getDetailsById()
console.log('onLoad', opt)
opts.value = opt.params ? JSON.parse(opt.params) : {}
title.value = opts.value.isEdit ? '编辑工器具退料' : '新增工器具退料'
getTeamList()
getProjectListApi()
// getEquipmentList()
if (opts.value.isEdit) {
getDetailsById()
}
})
onShow(() => {
console.log('onShow')
//
uni.$on('maCodeList', (data) => {
console.log('🚀 ~ onShow ~ data:', data)
const item = tableData.value.find((item) => item.typeId == data[0].typeId)
console.log('🚀 ~ onShow ~ item:', item)
if (item) {
item.maCodeList = data
item.preNum = data.length
}
})
console.log('🚀 ~ onShow ~ tableData.value:', tableData.value)
})
</script>
<style lang="scss" scoped>
.content {
padding: 10px;
background-color: #fafafa;
padding: 10px;
background-color: #fafafa;
}
.col {
display: flex;
align-items: center;
margin-bottom: 15px;
display: flex;
align-items: center;
margin-bottom: 15px;
}
</style>

View File

@ -48,12 +48,12 @@
<scroll-view scroll-y @scrolltolower="onScrollTolower" class="scroll-container">
<uni-swipe-action class="swipe-action">
<uni-swipe-action-item
:right-options="current == 0 ? options : []"
v-for="(item, index) in tableList"
:right-options="item.options"
:key="index"
@click="(e) => onClickSwipe(e, item)"
>
<div class="list" @click="handleItem(item)">
<div class="list">
<div style="margin-right: 8px">{{ index + 1 }}.</div>
<div class="item">
<div>申请时间: {{ item.createTime }}</div>
@ -116,7 +116,7 @@ const tableList = ref([])
const total = ref(0)
const options = ref([
{
text: '提交',
text: '2f8cf0',
style: {
backgroundColor: '#2f8cf0',
},
@ -159,7 +159,17 @@ const getList = async () => {
const res = await getBackListAPI(params)
console.log('🚀 ~ getList ~ res:', res)
if (res.code == 200) {
tableList.value = res.data.rows
tableList.value = res.data.rows.map((item, index) => {
let options = [
// { text: '', style: { backgroundColor: '#c6bf3b' } },
{ text: '编辑', style: { backgroundColor: '#2f8cf0' } },
{ text: '删除', style: { backgroundColor: '#ff4949' } },
]
return {
...item,
options: item.taskStatus == 4 ? [] : options, // 4
}
})
console.log('🚀 ~ getList ~ tableList.value:', tableList.value)
total.value = res.data.total
}
@ -198,7 +208,7 @@ const onScrollTolower = () => {
const onClickSwipe = async (e, item) => {
console.log('🚀 ~ onClickSwipe ~ e:', e, item)
try {
if (e.index == 0) {
if (e.content.text == '提交') {
//
const params = JSON.stringify({
id: item.id,
@ -220,7 +230,18 @@ const onClickSwipe = async (e, item) => {
icon: 'error',
})
}
} else {
} else if (e.content.text == '编辑') {
//
console.log('🚀 ~ 编辑 ~ item:', item)
const params = JSON.stringify({
id: item.id,
taskId: item.taskId,
isEdit: true,
})
uni.navigateTo({
url: `/pages/toolsBack/toolsAddBack?params=${params}`,
})
} else if (e.content.text == '删除') {
//
await deleteItem(item)
}

View File

@ -1,6 +1,6 @@
<template>
<!-- 编码出库-->
<uni-nav-bar dark :fixed="true" shadow background-color="#4AA4EA" status-bar title="编码出库"
<uni-nav-bar dark :fixed="true" shadow background-color="#4AA4EA" status-bar title="编码"
><template v-slot:left>
<view style="font-size: 18px; display: flex; align-items: center" @click="back">
<!-- 图标 -->
@ -63,7 +63,7 @@
</view>
</view>
<view class="table-list-item">
<view class="table-list-item" v-if="!queryParamsTemp.isBack">
<uni-row :gutter="24" class="flex">
<uni-col :span="6">出库方式</uni-col>
<!--
@ -131,7 +131,7 @@
<uni-row :gutter="24">
<uni-col :span="6">设备状态</uni-col>
<uni-col :span="16">
<view class="cont">{{ item.statusName }}</view>
<view class="cont">{{ item.statusName || item.maStatusName }}</view>
</uni-col>
</uni-row>
<uni-row :gutter="24">
@ -161,7 +161,7 @@ import {
getCodeScanAPI,
} from '@/services/picking/outbound.js'
import { getBoxBindByCode } from '@/services/standard.js'
import { getInfoByQrcode, getOutNum, detailsLeaseTask } from '@/services/back.js'
import { getInfoByQrcode, getOutNum, getMachineByIdApi } from '@/services/back.js'
import { debounce } from 'lodash-es'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
// const query = defineProps() //
@ -212,18 +212,53 @@ onLoad((opt) => {
console.log('xxxxxxxx', queryParamsTemp.value)
queryCodeParams.value.typeId = queryParamsTemp.value.typeId
queryParams.value = { ...queryParamsTemp.value }
codeDeviceList.value = queryParamsTemp.value.maCodeList || [] //
if (queryParamsTemp.value.maCodeList && queryParamsTemp.value.maCodeList.length > 0) {
allChecked.value = queryParamsTemp.value.maCodeList.every((e) => e.checked)
if (queryParamsTemp.value.isBack) {
getCodeList() //
} else {
codeDeviceList.value = queryParamsTemp.value.maCodeList || [] //
if (queryParamsTemp.value.maCodeList && queryParamsTemp.value.maCodeList.length > 0) {
allChecked.value = queryParamsTemp.value.maCodeList.every((e) => e.checked)
}
}
// getDetailsById()
// console.log('🚀 ~ onLoad ~ queryParams.value:', queryParams.value)
})
onShow(() => {
// getDetailsById()
// getCodeDetailData(queryParams.value.id, queryParams.value.publishTask, queryParams.value.typeId) //
})
const getCodeList = async () => {
const params = {
teamId: queryParamsTemp.value.teamId,
proId: queryParamsTemp.value.projectId,
typeId: queryParamsTemp.value.typeId,
}
try {
const res = await getMachineByIdApi(params)
console.log('🚀 ~ getCodeList ~ res:', res)
if (res.code === 200 && res.data && res.data.length > 0) {
codeDeviceList.value = res.data.map((item) => {
return {
...item,
checked: false, //
materialModel: item.typeName,
}
})
// queryParamsTemp.value.maCodeList checked= true
queryParamsTemp.value.maCodeList.forEach((e) => {
const index = codeDeviceList.value.findIndex((item) => item.maId === e.maId)
console.log('🚀 ~ queryParamsTemp.value.maCodeList.forEach ~ index:', index)
if (index !== -1) {
codeDeviceList.value[index].checked = true
}
})
//
allChecked.value = codeDeviceList.value.every((e) => e.checked)
console.log('🚀 ~ getCodeList ~ allChecked.value:', allChecked.value)
}
} catch (error) {
console.log('🚀 ~ getCodeList ~ error:', error)
}
}
//
const getDetailsById = async () => {
try {

View File

@ -505,10 +505,35 @@ const submit = (isOut) => {
})
}
// const back = () => {
// uni.navigateBack({
// delta: 1,
// })
// }
const back = () => {
uni.navigateBack({
delta: 1,
})
if (tableData.value.length > 0) {
uni
.showModal({
title: '提示',
content: '当前有未提交的数据,是否暂存?',
confirmText: '确定',
cancelText: '取消',
})
.then((res) => {
if (res.confirm) {
submit(0)
} else {
uni.navigateBack({
delta: 1,
})
}
})
} else {
uni.navigateBack({
delta: 1,
})
}
}
onLoad((opt) => {

View File

@ -231,6 +231,13 @@ export const detailsLeaseTask = (data) => {
// data:data,
})
}
// 退料详情
export const detailsBackTask = (data) => {
return http({
method: 'get',
url: `/material/back_apply_info/${data}`,
})
}
// 直转申请下拉选
export const getParentType = (data) => {
@ -331,6 +338,15 @@ export const backTask = (data) => {
})
}
// 退料申请-编辑
export const editBackTask = (data) => {
return http({
method: 'POST',
url: '/material/back_apply_info/edit',
data: data,
})
}
// 退料提交
export const backSubmit = (data) => {
return http({
@ -384,3 +400,12 @@ export const getAgreementInfoByIdApi = (data) => {
data,
})
}
// 获取编码详情
export const getMachineByIdApi = (data) => {
return http({
method: 'GET',
url: '/material/back_apply_info/getMachineById',
data,
})
}