| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="录入人:" prop="entryPerson"> |
| | | <el-select v-model="form.entryPerson" placeholder="请选择" clearable> |
| | | <el-select v-model="form.entryPerson" placeholder="请选择" clearable @change="changs"> |
| | | <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId"/> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | type="date" |
| | | placeholder="请选择" |
| | | clearable |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="产品大类:" prop="productCategory"> |
| | | <el-select v-model="productForm.productCategory" placeholder="请选择" clearable> |
| | | <!-- <el-select v-model="productForm.productCategory" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | </el-select> |
| | | </el-select> --> |
| | | <el-tree-select |
| | | v-model="productForm.productCategory" |
| | | placeholder="请选择" clearable |
| | | check-strictly |
| | | @change="getModels" |
| | | :data="productOptions" |
| | | :render-after-expand="false" |
| | | style="width: 100%" |
| | | /> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="规格型号:" prop="specificationModel"> |
| | | <el-select v-model="productForm.specificationModel" placeholder="请选择" clearable> |
| | | <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> |
| | | <el-form-item label="规格型号:" prop="productModelId"> |
| | | <el-select v-model="productForm.productModelId" placeholder="请选择" clearable @change="getProductModel"> |
| | | <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | import { ref } from 'vue' |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import {ElMessageBox } from "element-plus"; |
| | | import useUserStore from '@/store/modules/user' |
| | | import {userListNoPage} from "@/api/system/user.js"; |
| | | import { |
| | | ledgerList, |
| | |
| | | addOrUpdateSalesLedger, |
| | | getSalesLedgerWithProducts, delLedger, addOrUpdateSalesLedgerProduct, delProduct, delLedgerFile |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | import {modelList, productTreeList} from "@/api/basicData/product.js"; |
| | | const userStore = useUserStore() |
| | | const { proxy } = getCurrentInstance() |
| | | const tableData = ref([]) |
| | | const productData = ref([]) |
| | |
| | | const productSelectedRows = ref([]) |
| | | const userList = ref([]) |
| | | const customerOption = ref([]) |
| | | const productOptions = ref([]) |
| | | const modelOptions = ref([]) |
| | | const tableLoading = ref(false) |
| | | const page = reactive({ |
| | | current: 1, |
| | |
| | | tableLoading.value = false |
| | | }) |
| | | } |
| | | // 获取产品大类tree数据 |
| | | const getProductOptions = () => { |
| | | productTreeList().then(res => { |
| | | productOptions.value = convertIdToValue(res) |
| | | }) |
| | | } |
| | | // 获取tree子数据 |
| | | const getModels =(value) => { |
| | | productForm.value.productCategory = findNodeById(productOptions.value, value) |
| | | modelList({id: value}).then(res => { |
| | | modelOptions.value = res |
| | | }) |
| | | } |
| | | const getProductModel =(value) => { |
| | | const index = modelOptions.value.findIndex(item => item.id === value); |
| | | if (index !== -1) { |
| | | productForm.value.specificationModel = modelOptions.value[index].model; |
| | | } else { |
| | | productForm.value.specificationModel = null; |
| | | } |
| | | } |
| | | const findNodeById = (nodes, productId) => { |
| | | for (let i = 0; i < nodes.length; i++) { |
| | | if (nodes[i].value === productId) { |
| | | return nodes[i].label; // 找到节点,返回该节点 |
| | | } |
| | | if (nodes[i].children && nodes[i].children.length > 0) { |
| | | const foundNode = findNodeById(nodes[i].children, productId); |
| | | if (foundNode) { |
| | | return foundNode.label; // 在子节点中找到,返回该节点 |
| | | } |
| | | } |
| | | } |
| | | return null; // 没有找到节点,返回null |
| | | }; |
| | | function convertIdToValue(data) { |
| | | return data.map(item => { |
| | | const { id, children, ...rest } = item; |
| | | const newItem = { |
| | | ...rest, |
| | | value: id // 将 id 改为 value |
| | | }; |
| | | if (children && children.length > 0) { |
| | | newItem.children = convertIdToValue(children); |
| | | } |
| | | |
| | | return newItem; |
| | | }); |
| | | } |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection |
| | |
| | | return sums; |
| | | } |
| | | // 打开弹框 |
| | | const openForm = (type, row) => { |
| | | const openForm = async (type, row) => { |
| | | operationType.value = type |
| | | form.value = {} |
| | | productData.value = [] |
| | | userListNoPage().then(res => { |
| | | userList.value = res.data |
| | | }) |
| | | let userLists = await userListNoPage() |
| | | userList.value = userLists.data |
| | | customerList().then(res => { |
| | | customerOption.value = res |
| | | }) |
| | |
| | | fileList.value = form.value.salesLedgerFiles |
| | | }) |
| | | } |
| | | let userAll = await userStore.getInfo() |
| | | userList.value.forEach(element => { |
| | | if(userAll.user.nickName === element.nickName && userAll.user.userName === element.userName) { |
| | | form.value.entryPerson = userAll.user.userId // 设置默认业务员为当前用户 |
| | | } |
| | | }); |
| | | form.value.entryDate = getCurrentDate() // 设置默认录入日期为当前日期 |
| | | dialogFormVisible.value = true |
| | | } |
| | | function changs(val){ |
| | | console.log(val); |
| | | } |
| | | // 上传前校检 |
| | | function handleBeforeUpload(file) { |
| | |
| | | productForm.value = {...row} |
| | | } |
| | | productFormVisible.value = true |
| | | getProductOptions() |
| | | } |
| | | // 提交产品表单 |
| | | const submitProduct = () => { |
| | |
| | | proxy.$modal.msg("已取消") |
| | | }) |
| | | } |
| | | // 获取当前日期并格式化为 YYYY-MM-DD |
| | | function getCurrentDate() { |
| | | const today = new Date(); |
| | | const year = today.getFullYear(); |
| | | const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始 |
| | | const day = String(today.getDate()).padStart(2, '0'); |
| | | return `${year}-${month}-${day}`; |
| | | } |
| | | const mathNum = (val) => { |
| | | productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(val, productForm.value.taxRate) |
| | | } |
| | | getList() |
| | | </script> |
| | | |