Browse Source

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

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

271
src/pages/pointPutawayJob/index.vue

@ -97,7 +97,7 @@
</view> </view>
</template> </template>
<script> <script setup>
import { import {
getJimuPutawayJobDetail, getJimuPutawayJobDetail,
queryInspectionFreeFlag queryInspectionFreeFlag
@ -113,75 +113,70 @@ 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 {
data: {
sublist: []
},
newHtmlContent: '', //html
newHtmlContent1: '', //html
isLoadFinish: false,
ids: '',
tabIndex: 1,
data1: '',
currentPage: 1,
pageSize: 3,
showTableSubList: [],
showTableInspectDTOList: [],
currentPage1: 1,
pageSize1: 20,
number: '',
isHaveOn: false, //
// isHaveInspect:false,//
}
},
methods: { const data = ref({
// sublist: []
printImage() { })
const newHtmlContent = ref('')
const newHtmlContent1 = ref('')
const isLoadFinish = ref(false)
const ids = ref('')
const tabIndex = ref(1)
const data1 = ref('')
const currentPage = ref(1)
const pageSize = ref(3)
const showTableSubList = ref([])
const showTableInspectDTOList = ref([])
const currentPage1 = ref(1)
const pageSize1 = ref(20)
const number = ref('')
const isHaveOn = ref(false)
const comMessage = ref(null)
const printImage = () => {
// #ifdef APP // #ifdef APP
if (this.tabIndex == 1) { if (tabIndex.value === 1) {
testModule.doHTMLPrint(this.newHtmlContent1) testModule.doHTMLPrint(newHtmlContent1.value)
} else { } else {
testModule.doHTMLPrint(this.newHtmlContent) testModule.doHTMLPrint(newHtmlContent.value)
} }
// #endif // #endif
}, }
// html
readFile(path, callback) { const readFile = (path, callback) => {
// #ifdef APP // #ifdef APP
plus.io.resolveLocalFileSystemURL(path, function (entry) { plus.io.resolveLocalFileSystemURL(path, function (entry) {
entry.file(function (file) { entry.file(function (file) {
var reader = new plus.io.FileReader(); const reader = new plus.io.FileReader()
reader.onloadend = function (e) { reader.onloadend = function (e) {
callback(e.target.result); callback(e.target.result)
}; }
reader.readAsText(file); reader.readAsText(file)
}, function (e) { }, function (e) {
console.log("读取文件失败:" + e.message); console.log('读取文件失败:' + e.message)
}); })
}, function (e) { }, function (e) {
console.log("获取图片资源失败:" + e.message); console.log('获取图片资源失败:' + e.message)
}); })
// #endif // #endif
}, }
formatDate(val) {
const formatDate = (val) => {
return dateFormat(val) return dateFormat(val)
}, }
// html
getPointPutawayJobHtml() { const getPointPutawayJobHtml = () => {
this.$nextTick(async () => { nextTick(async () => {
let str = '' let str = ''
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.readFile(htmlFileUrl, (htmlContent) => { readFile(htmlFileUrl, (htmlContent) => {
this.newHtmlContent = htmlContent newHtmlContent.value = htmlContent
this.data.sublist.forEach(item => { data.value.sublist.forEach(item => {
str += `<div class="box" style="page-break-before:always;" ><br /> str += `<div class="box" style="page-break-before:always;" ><br />
<div class="top"> <div class="top">
<div class="mb-kw"> <div class="mb-kw">
@ -205,20 +200,19 @@ export default {
</div> </div>
` `
}) })
this.newHtmlContent = this.newHtmlContent.replace( newHtmlContent.value = newHtmlContent.value.replace('mainBody', str)
"mainBody", str); // })
});
// #endif // #endif
}) })
}, }
// html
getPurchaseReceiptJobHtml() { const getPurchaseReceiptJobHtml = () => {
this.$nextTick(async () => { nextTick(async () => {
let str = '' let str = ''
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.readFile(htmlFileUrl1, (htmlContent) => { readFile(htmlFileUrl1, (htmlContent) => {
this.newHtmlContent1 = htmlContent newHtmlContent1.value = htmlContent
this.data1.inspectDTOList.forEach(item => { data1.value.inspectDTOList.forEach(item => {
let str1 = ` let str1 = `
<div class="box" style="page-break-before:always;"><br /> <div class="box" style="page-break-before:always;"><br />
<div class="relative" > <div class="relative" >
@ -226,7 +220,7 @@ export default {
<div class="left"> <div class="left">
<div class="left-item"> <div class="left-item">
<div class="label">发货单号</div> <div class="label">发货单号</div>
<div>${this.data1.asnNumber}</div> <div>${data1.value.asnNumber}</div>
</div> </div>
<div class="left-item"> <div class="left-item">
<div class="label">物料代码</div> <div class="label">物料代码</div>
@ -253,7 +247,7 @@ export default {
<div>${item.sampleQty}</div> <div>${item.sampleQty}</div>
</div> </div>
` `
let str2 = `` let str2 = ''
if (item.haveInspectionRequest === '0') { if (item.haveInspectionRequest === '0') {
str2 = ` str2 = `
<div class="left-item"> <div class="left-item">
@ -277,122 +271,101 @@ export default {
` `
str += str1 + str2 + str3 str += str1 + str2 + str3
}) })
this.newHtmlContent1 = this.newHtmlContent1.replace( newHtmlContent1.value = newHtmlContent1.value.replace('mainBody', str)
"mainBody", str); // })
});
// #endif // #endif
}) })
}, }
getTableSubList() {
if (this.data.sublist.length > this.pageSize) { const getTableSubList = () => {
const array = this.data.sublist.slice( if (data.value.sublist.length > pageSize.value) {
(this.currentPage - 1) * this.pageSize, const array = data.value.sublist.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value)
this.currentPage * this.pageSize
)
if (array.length > 0) { if (array.length > 0) {
this.showTableSubList = [...this.showTableSubList, ...array] showTableSubList.value = [...showTableSubList.value, ...array]
this.currentPage += 1 currentPage.value += 1
} }
} else { } else {
this.showTableSubList = this.data.sublist showTableSubList.value = data.value.sublist
} }
}, }
getTableInspectDTOList() {
if (this.data1.inspectDTOList.length > this.pageSize1) { const getTableInspectDTOList = () => {
const array = this.data1.inspectDTOList.slice( if (data1.value.inspectDTOList.length > pageSize1.value) {
(this.currentPage1 - 1) * this.pageSize1, const array = data1.value.inspectDTOList.slice((currentPage1.value - 1) * pageSize1.value, currentPage1.value * pageSize1.value)
this.currentPage1 * this.pageSize1
)
if (array.length > 0) { if (array.length > 0) {
this.showTableInspectDTOList = [...this.showTableInspectDTOList, ...array] showTableInspectDTOList.value = [...showTableInspectDTOList.value, ...array]
this.currentPage1 += 1 currentPage1.value += 1
} }
} else { } else {
this.showTableInspectDTOList = this.data1.inspectDTOList showTableInspectDTOList.value = data1.value.inspectDTOList
}
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
}
});
},
},
watch: {
isLoadFinish: {
handler(newVal, oldVal) {
if (newVal == true) {
// html
} }
}, }
immediate: true
const showMessage = (message) => {
comMessage.value.showMessage(message, res => {
if (res) {
} }
}, })
}
onLoad(option) { onLoad((option) => {
if (option.data) { if (option.data) {
this.data = JSON.parse(decodeURIComponent(option.data)); data.value = JSON.parse(decodeURIComponent(option.data))
this.isHaveOn = true isHaveOn.value = true
} }
if (option.number) { if (option.number) {
this.number = option.number; number.value = option.number
} }
}, })
async onShow() {
// onShow(async () => {
if (this.data.ids) { if (ids.value) {
await getJimuPutawayJobDetail({ await getJimuPutawayJobDetail({ masterIds: ids.value }).then(res => {
masterIds: this.data.ids data.value.sublist = res.data
}).then(res => { getTableSubList()
this.data.sublist = res.data
this.getTableSubList()
}) })
} }
if (this.data.ids && !this.number) { if (ids.value && !number.value) {
this.tabIndex = 2 tabIndex.value = 2
} }
//
if (this.number) { if (number.value) {
await queryInspectionFreeFlag({ await queryInspectionFreeFlag({ number: number.value }).then(async res1 => {
number: this.number data1.value = res1.data
}).then(async res1 => { data1.value.inspectDTOList = data1.value.inspectDTOList.filter(item => item.sampleQty > 0)
this.data1 = res1.data if (data1.value && data1.value.inspectDTOList && data1.value.inspectDTOList.length === 0 && ids.value) {
this.data1.inspectDTOList = this.data1.inspectDTOList.filter(item => item.sampleQty > tabIndex.value = 2
0)
if (this.data1 && this.data1.inspectDTOList && this.data1.inspectDTOList.length == 0 && this.data.ids) {
this.tabIndex = 2
} }
this.getTableInspectDTOList() getTableInspectDTOList()
}) }).catch(error => {
.catch(error => { comMessage.value.showMessage(error, res => {
this.$refs.comMessage.showMessage(error, res => {
if (res) { if (res) {
} }
}); })
}) })
} }
getPointPutawayJobHtml()
this.getPointPutawayJobHtml() getPurchaseReceiptJobHtml()
this.getPurchaseReceiptJobHtml() })
},
onReachBottom() { onReachBottom(() => {
if (this.tabIndex == 1) { if (tabIndex.value === 1) {
if (this.showTableInspectDTOList != this.data1.inspectDTOList.length) { if (showTableInspectDTOList.value.length !== data1.value.inspectDTOList.length) {
this.getTableInspectDTOList() getTableInspectDTOList()
} }
} else { } else {
if (this.showTableSubList.length != this.data.sublist.length) { if (showTableSubList.value.length !== data.value.sublist.length) {
this.getTableSubList() getTableSubList()
} }
} }
})
watch(isLoadFinish, (newVal, oldVal) => {
if (newVal === true) {
} }
} }, { immediate: true })
</script> </script>
<style lang="scss"> <style lang="scss">

Loading…
Cancel
Save