This commit is contained in:
bb_pan 2025-06-06 13:15:28 +08:00
parent 8923fca4f3
commit 1ba8b6eb90
4 changed files with 114 additions and 27 deletions

View File

@ -55,6 +55,13 @@
@blur="checkPhone"
></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="备注" name="remark">
<uni-easyinput
v-model="formData.remark"
placeholder="请输入内容"
maxlength="200"
></uni-easyinput>
</uni-forms-item>
<uni-section title="工器具退料" type="line"></uni-section>
<eselect
v-model="equipmentId"
@ -112,7 +119,9 @@
>
删除
</button>
<button class="uni-button" size="mini" type="primary" @click="">出库</button>
<!-- <button class="uni-button" size="mini" type="primary" @click="submit(1, item)">
出库
</button> -->
</uni-td>
</uni-tr>
</uni-table>
@ -122,7 +131,7 @@
</template>
<script setup>
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app'
import { ref, reactive } from 'vue'
import eselect from '@/components/tree-select/eselect.vue'
import {
@ -147,6 +156,7 @@ const formData = reactive({
agreementId: undefined,
remark: undefined,
isBack: 1,
remark: '',
})
const agreementId = ref('')
const equipmentId = ref()
@ -172,7 +182,7 @@ const getDetailsById = async () => {
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) {
if (res.data && res.data.backApplyDetailsList && res.data.backApplyDetailsList.length > 0) {
tableData.value = res.data.backApplyDetailsList.map((item) => {
return {
...item,
@ -435,16 +445,18 @@ const submit = (isBack) => {
title: '提交中...',
})
try {
let res = null
if (!opts.value.isEdit) {
const res = await backTask(params)
console.log('🚀 ~ .then ~ res:', res)
uni.hideLoading()
back()
console.log('🚀 ~ .then ~ 新增:')
res = await backTask(params)
} else {
const res = await editBackTask(params)
uni.hideLoading()
back()
console.log('🚀 ~ .then ~ 编辑:')
res = await editBackTask(params)
}
console.log('🚀 ~ .then ~ res:', res)
tableData.value = []
uni.hideLoading()
back()
} catch (error) {
console.log('🚀 ~ .then ~ error:', error)
uni.hideLoading()
@ -504,6 +516,22 @@ onShow(() => {
})
console.log('🚀 ~ onShow ~ tableData.value:', tableData.value)
})
onBackPress((opt) => {
console.log('🚀 ~ onBackPress ~ opt:', opt)
if (opt.from == 'backbutton') {
if (tableData.value.length > 0) {
//
uni.showToast({
title: '当前有未提交数据, 请暂存或提交',
icon: 'none',
duration: 1000,
})
return true
}
} else {
return false
}
})
</script>
<style lang="scss" scoped>

View File

@ -167,7 +167,7 @@ const getList = async () => {
]
return {
...item,
options: item.taskStatus == 4 ? [] : options, // 4
options: item.taskStatus == 2 ? [] : options, // 4
}
})
console.log('🚀 ~ getList ~ tableList.value:', tableList.value)

View File

@ -48,6 +48,27 @@
<text>{{ isSelectNum }} / {{ codeDeviceList.length }} 条已选</text>
</checkbox-group>
</uni-forms-item>
<uni-forms-item label="" name="">
<div
style="display: flex; align-items: center; flex-wrap: wrap"
>
<div
v-for="(item, index) in codeDeviceList"
style="margin: 0 5px"
v-show="item.checked"
>
<span
>{{ item.maCode }}
<uni-icons
type="close"
size="18"
color="red"
@click="handleItemChecked(item)"
></uni-icons
></span>
</div>
</div>
</uni-forms-item>
<!--
<uni-forms-item
@ -243,14 +264,15 @@ const getCodeList = async () => {
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
}
})
// queryParamsTemp.value.maCodeList codeDeviceList.value
codeDeviceList.value = [
...new Map(
[...codeDeviceList.value, ...queryParamsTemp.value.maCodeList].map((item) => [
item.maId,
item,
]),
).values(),
]
//
allChecked.value = codeDeviceList.value.every((e) => e.checked)
console.log('🚀 ~ getCodeList ~ allChecked.value:', allChecked.value)
@ -302,21 +324,34 @@ const getCodeDetailData = async (id, publishTask, typeId) => {
//
const getCodeDeviceListData = async () => {
console.log('🚀 ~ getCodeDeviceListData ~ queryCodeParams.value:', queryCodeParams.value)
const res = await getCodeDeviceListAPI(queryCodeParams.value)
console.log('🚀 ~ getCodeDeviceListData ~ res:', res)
codeDeviceList.value.push(...res.data)
if (codeDeviceList.value.length > 0) {
codeDeviceList.value = codeDeviceList.value.map((e) => {
return { ...e, checked: false, outType: 0, checked: false }
try {
uni.showLoading({
title: '加载中...',
mask: true,
})
const res = await getCodeDeviceListAPI(queryCodeParams.value)
console.log('🚀 ~ getCodeDeviceListData ~ res:', res)
codeDeviceList.value.push(...res.data)
if (codeDeviceList.value.length > 0) {
codeDeviceList.value = codeDeviceList.value.map((e) => {
return { ...e, checked: false, outType: 0, checked: false }
})
}
total.value = res.total
setTimeout(() => {
uni.hideLoading()
}, 500)
} catch (error) {
console.log('🚀 ~ getCodeDeviceListData ~ error:', error)
uni.hideLoading()
}
total.value = res.total
}
//
const onCodeSearch = () => {
queryCodeParams.value.pageNum = 1
codeDeviceList.value = []
allChecked.value = false
getCodeDeviceListData()
}

View File

@ -55,6 +55,13 @@
@blur="checkPhone"
></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="备注" name="remark">
<uni-easyinput
v-model="formData.remark"
placeholder="请输入内容"
maxlength="200"
></uni-easyinput>
</uni-forms-item>
<uni-section title="领用工具器" type="line" />
<eselect
v-model="equipmentId"
@ -145,7 +152,7 @@
</template>
<script setup>
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app'
import { ref, reactive } from 'vue'
import eselect from '@/components/tree-select/eselect.vue'
import {
@ -169,6 +176,7 @@ const formData = reactive({
leasePerson: '',
phone: '',
isOut: 1,
remark: '',
})
const equipmentId = ref()
const teamRange = ref([]) //
@ -569,6 +577,22 @@ onShow(() => {
})
console.log('🚀 ~ onShow ~ tableData.value:', tableData.value)
})
onBackPress((opt) => {
console.log('🚀 ~ onBackPress ~ opt:', opt)
if (opt.from == 'backbutton') {
if (tableData.value.length > 0) {
//
uni.showToast({
title: '当前有未提交数据, 请暂存或提交',
icon: 'none',
duration: 1000,
})
return true
}
} else {
return false
}
})
</script>
<style lang="scss" scoped>