dev
This commit is contained in:
parent
970f012d69
commit
f984aeb49e
|
|
@ -414,12 +414,20 @@ const removeTableRow = (row: any) => {
|
|||
table_list.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
const init = () => {
|
||||
const init = (orderInfo: any,goodList: any) => {
|
||||
isShow.value = true
|
||||
getSupplierList()
|
||||
getManagerUserList()
|
||||
getUserInfo()
|
||||
|
||||
if (orderInfo){
|
||||
inventory_order_data.value = orderInfo
|
||||
}
|
||||
if (goodList){
|
||||
table_list.value = goodList
|
||||
}
|
||||
getTotalPrice()
|
||||
|
||||
}
|
||||
const managerUserList: any = ref([])
|
||||
const getManagerUserList = () => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<Mask :width="400" :height="240" :is-show="isShow" @close="isShow=false" :show-footer="true" title="选择模板范围">
|
||||
<Mask :width="400" :height="240" :is-show="isShow" @close="close" :show-footer="true" title="选择模板范围">
|
||||
<template #default>
|
||||
<div class="select">
|
||||
<el-form style="height: 100%">
|
||||
|
|
@ -13,12 +13,14 @@
|
|||
</template>
|
||||
<template #footer>
|
||||
<div class="bottom">
|
||||
<div class="default-btn" @click="isShow=false">上传数据</div>
|
||||
<input ref="fileInput" type="file" @change="handleFileChange" style="display: none"/>
|
||||
<div class="default-btn" @click="selectFile" style="margin-left: 24px">上传数据</div>
|
||||
<div class="default-btn" @click="toExcel" style="margin-left: 24px">下载模板</div>
|
||||
<div class="default-btn" @click="isShow=false" style="margin-left: 24px">取消</div>
|
||||
<div class="default-btn" @click="close" style="margin-left: 24px">取消</div>
|
||||
</div>
|
||||
</template>
|
||||
</Mask>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
@ -26,9 +28,13 @@ import Mask from "@/components/common/Mask.vue";
|
|||
import {defineModel, onMounted, ref} from "vue";
|
||||
import {post} from "@/utils/request.ts";
|
||||
import {loadConfig} from "@/utils/config.ts";
|
||||
import {Plus} from "@element-plus/icons-vue";
|
||||
import axios from "axios";
|
||||
|
||||
const isShow = defineModel()
|
||||
const props = {multiple: true}
|
||||
const baseUrl = ref("")
|
||||
const file = ref([])
|
||||
|
||||
interface CateOption {
|
||||
value: string;
|
||||
|
|
@ -44,18 +50,18 @@ const typeList = {
|
|||
}
|
||||
const cateIds = ref<number[]>([]);
|
||||
const allCateList = ref<CateOption[]>([]);
|
||||
const toExcel=()=>{
|
||||
let cateIdsVal=cateIds.value
|
||||
let cateIdList=[]
|
||||
for(let i=0;i<cateIdsVal.length;i++){
|
||||
let item:any=cateIdsVal[i];
|
||||
if(item.length>1){
|
||||
const toExcel = () => {
|
||||
let cateIdsVal = cateIds.value
|
||||
let cateIdList = []
|
||||
for (let i = 0; i < cateIdsVal.length; i++) {
|
||||
let item: any = cateIdsVal[i];
|
||||
if (item.length > 1) {
|
||||
cateIdList.push(item[1])
|
||||
}
|
||||
}
|
||||
post("inventory/order/toExcel",{cateIdList:cateIdList}).then((token:any)=>{
|
||||
post("inventory/order/toExcel", {cateIdList: cateIdList}).then((token: any) => {
|
||||
loadConfig().then((res: any) => {
|
||||
window.open(res.base_url+"file/download/"+token)
|
||||
window.open(res.base_url + "file/download/" + token)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
@ -91,9 +97,54 @@ const uploadCateIds = () => {
|
|||
})
|
||||
console.log(ids)
|
||||
}
|
||||
const fromExcel = () => {
|
||||
}
|
||||
onMounted(() => {
|
||||
getAllCate()
|
||||
loadConfig().then((res: any) => {
|
||||
baseUrl.value = res.base_url
|
||||
})
|
||||
})
|
||||
const selectedFile = ref(null);
|
||||
|
||||
const handleFileChange = (event: any) => {
|
||||
selectedFile.value = event.target.files[0];
|
||||
uploadFile();
|
||||
};
|
||||
|
||||
const fileInput = ref<HTMLInputElement | null>(null); // 声明或已通过 ref 获取
|
||||
|
||||
const selectFile = () => {
|
||||
if (fileInput.value) {
|
||||
fileInput.value.click(); // 触发文件选择框弹出
|
||||
}
|
||||
};
|
||||
const emit = defineEmits(['initAddOrderData'])
|
||||
const uploadFile = async () => {
|
||||
if (!selectedFile.value) {
|
||||
alert('请先选择一个文件');
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', selectedFile.value);
|
||||
|
||||
try {
|
||||
const response = await axios.post(baseUrl.value + 'file/uploadToTemp', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
let excelData = await post("inventory/order/fromExcel", {token: response.data})
|
||||
close()
|
||||
emit('initAddOrderData',excelData)
|
||||
} catch (error) {
|
||||
console.error('上传失败:', error);
|
||||
}
|
||||
};
|
||||
const close = () => {
|
||||
isShow.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@
|
|||
</div>
|
||||
<AddOrder ref="addOrderRef" @close="closeAddOrder"/>
|
||||
<EditOrder ref="editOrderRef" @close="closeEditOrder" @updateOrderDetail="init"/>
|
||||
<UpLoad v-model="show"></UpLoad>
|
||||
<UpLoad v-model="show" @initAddOrderData =initAddOrderData></UpLoad>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ onMounted(() => {
|
|||
const addOrderRef = ref<any>('')
|
||||
const openAdd = () => {
|
||||
nextTick(() => {
|
||||
addOrderRef.value.init()
|
||||
addOrderRef.value.init(null)
|
||||
})
|
||||
}
|
||||
const editOrderRef = ref<any>('')
|
||||
|
|
@ -249,6 +249,36 @@ const show = ref(false)
|
|||
const openUpload= ()=>{
|
||||
show.value=true
|
||||
}
|
||||
|
||||
const initAddOrderData = (initData:any)=>{
|
||||
const data = {
|
||||
invoiceCode:initData.tag.invoice_code,
|
||||
shippingCode:initData.tag.shipping_code,
|
||||
remark:initData.tag.remark,
|
||||
purchaseDate: initData.tag.purchase_date,
|
||||
}
|
||||
let goodsList = []
|
||||
for (let i=0;i<initData.list.length;i++){
|
||||
let item = initData.list[i]
|
||||
let goodsInfo = {
|
||||
productionBatchCode:item.info.production_batch_code,
|
||||
wholeNumber:item.info.whole_number,
|
||||
productionDate:item.info.production_date,
|
||||
expiryDate:item.info.expiry_date,
|
||||
purchaseUnitPrice:item.info.purchase_unit_price,
|
||||
goodId:item.id,
|
||||
name:item.goods.name,
|
||||
packagingUnit:item.goods.packagingUnit,
|
||||
unitPrice:item.goods.unitPrice,
|
||||
}
|
||||
goodsList.push(goodsInfo)
|
||||
}
|
||||
|
||||
|
||||
nextTick(()=>{
|
||||
addOrderRef.value?.init(data,goodsList)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
@use "@/assets/scss/base.scss";
|
||||
|
|
|
|||
Loading…
Reference in New Issue