Browse Source

pages/pointPutawayJob 文件迁移Vue2升级Vue3 8/2-10/25

hella_vue3
王志国 3 weeks ago
parent
commit
55af9befa2
  1. 499
      src/pages/pointPutawayJob/index.vue

499
src/pages/pointPutawayJob/index.vue

@ -97,7 +97,7 @@
</view> </view>
</template> </template>
<script> <script setup>
import { import {
getJimuPutawayJobDetail, getJimuPutawayJobDetail,
queryInspectionFreeFlag queryInspectionFreeFlag
@ -113,286 +113,259 @@ import {
pathToBase64 pathToBase64
} from "../../api/img-to-base64.js" //js } from "../../api/img-to-base64.js" //js
// #ifdef APP // #ifdef APP
var testModule = uni.requireNativePlugin("TestModule") let testModule = uni.requireNativePlugin("TestModule")
// #endif // #endif
export default { import { ref, nextTick, watch} from 'vue'
name: 'pointPutawayJob', import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
data() {
return { const data = ref({
data: { sublist: []
sublist: [] })
}, const newHtmlContent = ref('')
newHtmlContent: '', //html const newHtmlContent1 = ref('')
newHtmlContent1: '', //html const isLoadFinish = ref(false)
isLoadFinish: false, const ids = ref('')
ids: '', const tabIndex = ref(1)
tabIndex: 1, const data1 = ref('')
data1: '', const currentPage = ref(1)
currentPage: 1, const pageSize = ref(3)
pageSize: 3, const showTableSubList = ref([])
showTableSubList: [], const showTableInspectDTOList = ref([])
showTableInspectDTOList: [], const currentPage1 = ref(1)
const pageSize1 = ref(20)
currentPage1: 1, const number = ref('')
pageSize1: 20, const isHaveOn = ref(false)
number: '', const comMessage = ref(null)
isHaveOn: false, //
// isHaveInspect:false,// const printImage = () => {
} // #ifdef APP
}, if (tabIndex.value === 1) {
testModule.doHTMLPrint(newHtmlContent1.value)
methods: { } else {
// testModule.doHTMLPrint(newHtmlContent.value)
printImage() { }
// #ifdef APP // #endif
if (this.tabIndex == 1) { }
testModule.doHTMLPrint(this.newHtmlContent1)
} else { const readFile = (path, callback) => {
testModule.doHTMLPrint(this.newHtmlContent) // #ifdef APP
plus.io.resolveLocalFileSystemURL(path, function (entry) {
entry.file(function (file) {
const reader = new plus.io.FileReader()
reader.onloadend = function (e) {
callback(e.target.result)
} }
// #endif reader.readAsText(file)
}, }, function (e) {
// html console.log('读取文件失败:' + e.message)
readFile(path, callback) { })
// #ifdef APP }, function (e) {
plus.io.resolveLocalFileSystemURL(path, function (entry) { console.log('获取图片资源失败:' + e.message)
entry.file(function (file) { })
var reader = new plus.io.FileReader(); // #endif
reader.onloadend = function (e) { }
callback(e.target.result);
}; const formatDate = (val) => {
reader.readAsText(file); return dateFormat(val)
}, function (e) { }
console.log("读取文件失败:" + e.message);
}); const getPointPutawayJobHtml = () => {
}, function (e) { nextTick(async () => {
console.log("获取图片资源失败:" + e.message); let str = ''
}); // #ifdef APP-PLUS
// #endif readFile(htmlFileUrl, (htmlContent) => {
}, newHtmlContent.value = htmlContent
formatDate(val) { data.value.sublist.forEach(item => {
return dateFormat(val) str += `<div class="box" style="page-break-before:always;" ><br />
}, <div class="top">
// html <div class="mb-kw">
getPointPutawayJobHtml() { 目标库位<div>${item.toLocationCode}</div>
this.$nextTick(async () => { </div>
let str = '' <div class="mb-bo">
// #ifdef APP-PLUS <div class="mb-left">
this.readFile(htmlFileUrl, (htmlContent) => { <div class="mb-text">
this.newHtmlContent = htmlContent 物料号<div>${item.itemCode}asjkdhfksjahfkljashfklsdh</div>
this.data.sublist.forEach(item => { </div>
str += `<div class="box" style="page-break-before:always;" ><br /> <div class="mb-text">
<div class="top"> 托包装号<div>${item.packingNumber}</div>
<div class="mb-kw"> </div>
目标库位<div>${item.toLocationCode}</div> </div>
</div> <div class="mb-right">
<div class="mb-bo"> <div class="mb-text">
<div class="mb-left"> 数量<div>${item.qty}${item.uom}</div>
<div class="mb-text"> </div>
物料号<div>${item.itemCode}asjkdhfksjahfkljashfklsdh</div> </div>
</div> </div>
<div class="mb-text"> </div>
托包装号<div>${item.packingNumber}</div> `
</div>
</div>
<div class="mb-right">
<div class="mb-text">
数量<div>${item.qty}${item.uom}</div>
</div>
</div>
</div>
</div>
`
})
this.newHtmlContent = this.newHtmlContent.replace(
"mainBody", str); //
});
// #endif
})
},
// html
getPurchaseReceiptJobHtml() {
this.$nextTick(async () => {
let str = ''
// #ifdef APP-PLUS
this.readFile(htmlFileUrl1, (htmlContent) => {
this.newHtmlContent1 = htmlContent
this.data1.inspectDTOList.forEach(item => {
let str1 = `
<div class="box" style="page-break-before:always;"><br />
<div class="relative" >
<div class="q">Q</div>
<div class="left">
<div class="left-item">
<div class="label">发货单号</div>
<div>${this.data1.asnNumber}</div>
</div>
<div class="left-item">
<div class="label">物料代码</div>
<div>${item.itemCode}</div>
</div>
<div class="left-item">
<div class="label">物料名称</div>
<div>${item.itemName}</div>
</div>
<div class="left-item">
<div class="label">供应商</div>
<div>${item.supplierCode}</div>
</div>
<div class="left-item">
<div class="label">供应商批次</div>
<div>${item.supplierBatch}</div>
</div>
<div class="left-item">
<div class="label">到货数量</div>
<div>${item.quantityQty}</div>
</div>
<div class="left-item">
<div class="label">抽检数量</div>
<div>${item.sampleQty}</div>
</div>
`
let str2 = ``
if (item.haveInspectionRequest === '0') {
str2 = `
<div class="left-item">
<div style="color:#ff0000;font-weight: bold;font-size: 15px;">未生成检验申请</div>
</div>`
} else if (item.haveInspectionRequest === '2') {
str2 = `
<div class="left-item">
<div style="color:#ffab01;font-weight: bold;font-size: 15px;">没有检验方案</div>
</div>`
} else if (item.haveInspectionRequest === '3') {
str2 = `
<div class="left-item">
<div style="color:#258eff;font-weight: bold;font-size: 15px;">检验阶段不存在</div>
</div>`
}
let str3 = `
</div>
</div>
</div>
`
str += str1 + str2 + str3
})
this.newHtmlContent1 = this.newHtmlContent1.replace(
"mainBody", str); //
});
// #endif
}) })
}, newHtmlContent.value = newHtmlContent.value.replace('mainBody', str)
getTableSubList() { })
if (this.data.sublist.length > this.pageSize) { // #endif
const array = this.data.sublist.slice( })
(this.currentPage - 1) * this.pageSize, }
this.currentPage * this.pageSize
)
if (array.length > 0) {
this.showTableSubList = [...this.showTableSubList, ...array]
this.currentPage += 1
}
} else {
this.showTableSubList = this.data.sublist
}
},
getTableInspectDTOList() {
if (this.data1.inspectDTOList.length > this.pageSize1) {
const array = this.data1.inspectDTOList.slice(
(this.currentPage1 - 1) * this.pageSize1,
this.currentPage1 * this.pageSize1
)
if (array.length > 0) {
this.showTableInspectDTOList = [...this.showTableInspectDTOList, ...array]
this.currentPage1 += 1
}
} else {
this.showTableInspectDTOList = this.data1.inspectDTOList
}
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
const getPurchaseReceiptJobHtml = () => {
nextTick(async () => {
let str = ''
// #ifdef APP-PLUS
readFile(htmlFileUrl1, (htmlContent) => {
newHtmlContent1.value = htmlContent
data1.value.inspectDTOList.forEach(item => {
let str1 = `
<div class="box" style="page-break-before:always;"><br />
<div class="relative" >
<div class="q">Q</div>
<div class="left">
<div class="left-item">
<div class="label">发货单号</div>
<div>${data1.value.asnNumber}</div>
</div>
<div class="left-item">
<div class="label">物料代码</div>
<div>${item.itemCode}</div>
</div>
<div class="left-item">
<div class="label">物料名称</div>
<div>${item.itemName}</div>
</div>
<div class="left-item">
<div class="label">供应商</div>
<div>${item.supplierCode}</div>
</div>
<div class="left-item">
<div class="label">供应商批次</div>
<div>${item.supplierBatch}</div>
</div>
<div class="left-item">
<div class="label">到货数量</div>
<div>${item.quantityQty}</div>
</div>
<div class="left-item">
<div class="label">抽检数量</div>
<div>${item.sampleQty}</div>
</div>
`
let str2 = ''
if (item.haveInspectionRequest === '0') {
str2 = `
<div class="left-item">
<div style="color:#ff0000;font-weight: bold;font-size: 15px;">未生成检验申请</div>
</div>`
} else if (item.haveInspectionRequest === '2') {
str2 = `
<div class="left-item">
<div style="color:#ffab01;font-weight: bold;font-size: 15px;">没有检验方案</div>
</div>`
} else if (item.haveInspectionRequest === '3') {
str2 = `
<div class="left-item">
<div style="color:#258eff;font-weight: bold;font-size: 15px;">检验阶段不存在</div>
</div>`
} }
}); let str3 = `
}, </div>
}, </div>
watch: { </div>
isLoadFinish: { `
handler(newVal, oldVal) { str += str1 + str2 + str3
if (newVal == true) { })
// html newHtmlContent1.value = newHtmlContent1.value.replace('mainBody', str)
} })
}, // #endif
immediate: true })
}
const getTableSubList = () => {
if (data.value.sublist.length > pageSize.value) {
const array = data.value.sublist.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value)
if (array.length > 0) {
showTableSubList.value = [...showTableSubList.value, ...array]
currentPage.value += 1
} }
}, } else {
showTableSubList.value = data.value.sublist
}
}
onLoad(option) { const getTableInspectDTOList = () => {
if (option.data) { if (data1.value.inspectDTOList.length > pageSize1.value) {
this.data = JSON.parse(decodeURIComponent(option.data)); const array = data1.value.inspectDTOList.slice((currentPage1.value - 1) * pageSize1.value, currentPage1.value * pageSize1.value)
this.isHaveOn = true if (array.length > 0) {
} showTableInspectDTOList.value = [...showTableInspectDTOList.value, ...array]
if (option.number) { currentPage1.value += 1
this.number = option.number;
}
},
async onShow() {
//
if (this.data.ids) {
await getJimuPutawayJobDetail({
masterIds: this.data.ids
}).then(res => {
this.data.sublist = res.data
this.getTableSubList()
})
} }
} else {
showTableInspectDTOList.value = data1.value.inspectDTOList
}
}
if (this.data.ids && !this.number) { const showMessage = (message) => {
this.tabIndex = 2 comMessage.value.showMessage(message, res => {
if (res) {
} }
// })
if (this.number) { }
await queryInspectionFreeFlag({
number: this.number
}).then(async res1 => {
this.data1 = res1.data
this.data1.inspectDTOList = this.data1.inspectDTOList.filter(item => item.sampleQty >
0)
if (this.data1 && this.data1.inspectDTOList && this.data1.inspectDTOList.length == 0 && this.data.ids) {
this.tabIndex = 2
}
this.getTableInspectDTOList()
})
.catch(error => {
this.$refs.comMessage.showMessage(error, res => {
if (res) {
} onLoad((option) => {
}); if (option.data) {
}) data.value = JSON.parse(decodeURIComponent(option.data))
} isHaveOn.value = true
}
if (option.number) {
number.value = option.number
}
})
onShow(async () => {
if (ids.value) {
await getJimuPutawayJobDetail({ masterIds: ids.value }).then(res => {
data.value.sublist = res.data
getTableSubList()
})
}
this.getPointPutawayJobHtml() if (ids.value && !number.value) {
this.getPurchaseReceiptJobHtml() tabIndex.value = 2
}, }
onReachBottom() {
if (this.tabIndex == 1) { if (number.value) {
if (this.showTableInspectDTOList != this.data1.inspectDTOList.length) { await queryInspectionFreeFlag({ number: number.value }).then(async res1 => {
this.getTableInspectDTOList() data1.value = res1.data
} data1.value.inspectDTOList = data1.value.inspectDTOList.filter(item => item.sampleQty > 0)
} else { if (data1.value && data1.value.inspectDTOList && data1.value.inspectDTOList.length === 0 && ids.value) {
if (this.showTableSubList.length != this.data.sublist.length) { tabIndex.value = 2
this.getTableSubList()
} }
getTableInspectDTOList()
}).catch(error => {
comMessage.value.showMessage(error, res => {
if (res) {
}
})
})
}
getPointPutawayJobHtml()
getPurchaseReceiptJobHtml()
})
onReachBottom(() => {
if (tabIndex.value === 1) {
if (showTableInspectDTOList.value.length !== data1.value.inspectDTOList.length) {
getTableInspectDTOList()
} }
} else {
if (showTableSubList.value.length !== data.value.sublist.length) {
getTableSubList()
}
}
})
watch(isLoadFinish, (newVal, oldVal) => {
if (newVal === true) {
} }
} }, { immediate: true })
</script> </script>
<style lang="scss"> <style lang="scss">

Loading…
Cancel
Save