| | |
| | | <el-form-item |
| | | label="物品名称" |
| | | :prop="`goods[${goodsIndex}].baseGoodsTemplateId`" |
| | | :rules="{ |
| | | required: true, |
| | | message: '请选择', |
| | | trigger: 'change', |
| | | }" |
| | | :rules="rules.baseGoodsTemplateId" |
| | | > |
| | | <el-select |
| | | v-model="goodsItem.baseGoodsTemplateId" |
| | |
| | | </el-table-column> |
| | | <el-table-column prop="counts" label="出库数量" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-form-item |
| | | label-width="0" |
| | | style="margin-bottom: 0" |
| | | :prop="`goods[${goodsIndex}].models[${scope.$index}].counts`" |
| | | :rules="rules.counts" |
| | | > |
| | | <el-input |
| | | type="number" |
| | | v-model="scope.row.counts" |
| | | @change="countsChange($event, goodsIndex,scope.$index)" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | import winMd from '@/components/win/win-md'; |
| | | import upload from '@/components/upload/index'; |
| | | import { getUploadUrl } from '@/utils/base'; |
| | | |
| | | import SettingIplatform from '../../../../../public/static/config'; |
| | | import {mapGetters} from 'vuex' |
| | | |
| | | export default { |
| | | components: { MyButton, winMd, upload }, |
| | |
| | | }, |
| | | }, |
| | | data() { |
| | | // 自定义校验 |
| | | // 物品重复校验 |
| | | var checkGoodsTemplateId = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error('请选择')); |
| | | } |
| | | let temp = this.formData.goods.filter((v) => v.baseGoodsTemplateId == value); |
| | | if (!temp || temp.length!=1) { |
| | | return callback(new Error('已选过此物品')); |
| | | } |
| | | callback(); |
| | | }; |
| | | return { |
| | | loading: false, |
| | | warehouseOptions: [], // 出库仓库列表 |
| | |
| | | modelsItem: { |
| | | baseGoodsModelsId: '', // 规格型号编号 |
| | | worehouseCount: 0, |
| | | counts: 0, // 操作数量 |
| | | counts: null, // 操作数量 |
| | | unit: null, //单位 |
| | | }, |
| | | rules: { |
| | |
| | | dealTime: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | buyType: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | |
| | | procureDoc: [{ required: true, message: '请上传', trigger: 'change' }], |
| | | baseCategoryIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | baseGoodsTemplateId: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | baseGoodsTemplateId: [{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }], |
| | | modelsIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | counts: [{ required: true, message: '请输入', trigger: 'change' }], |
| | | }, |
| | | |
| | | uploadSettings: { |
| | |
| | | }, |
| | | }; |
| | | }, |
| | | computed:{ |
| | | ...mapGetters(['userInfo']) |
| | | }, |
| | | created() { |
| | | this.init(); |
| | | }, |
| | |
| | | // 获取物品分类列表 |
| | | const treeRes = await getTree(); |
| | | this.categoryOptions = this.removeEmptyChildren(treeRes); |
| | | this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem))); |
| | | }, |
| | | |
| | | // 获取出库仓库列表 |
| | | getWarehouseList() { |
| | | selectTenantWarehouse() |
| | | selectTenantWarehouse({agencyId:this.userInfo.tenantId}) |
| | | .then((res) => { |
| | | this.warehouseOptions = res; |
| | | this.warehouseOptions = res |
| | | if(res.length) { |
| | | this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem))); |
| | | } |
| | | if (this.warehouseOptions.length && !this.formData.warehouseId) { |
| | | // 默认选中第一个仓库 |
| | | this.formData.warehouseId = this.warehouseOptions[0].id; |
| | |
| | | this.getgoodsTemplate(e[e.length - 1], index); |
| | | }, |
| | | |
| | | // 物品名称列表 |
| | | // 物品名称列表选择 |
| | | goodsTemplateChange(e, index) { |
| | | this.formData.goods[index].modelsOptions = []; |
| | | this.formData.goods[index].modelsIds = []; |
| | |
| | | countsChange(e, goodsIndex,index) { |
| | | const curItem = this.formData.goods[goodsIndex].models[index] |
| | | const worehouseCount = curItem.worehouseCount |
| | | if (e == 0) { |
| | | this.$message.warning('数额不能为0'); |
| | | curItem.counts = null |
| | | } |
| | | if (e > worehouseCount) { |
| | | this.$message.warning('数额超过现有库存'); |
| | | curItem.counts = worehouseCount |
| | | curItem.counts = worehouseCount > 0 ? worehouseCount : null |
| | | } |
| | | }, |
| | | |
| | |
| | | goods: [], |
| | | }; |
| | | this.$emit('close'); |
| | | }, |
| | | |
| | | // 通过子集id查到所以相关父级id并返回数组 |
| | | findParentIds(dataSource, nodeId) { |
| | | const parentIds = []; // 用于存储所有父节点ID的数组 |
| | | |
| | | // 定义一个递归函数,用于遍历整棵树并查找子节点的所有父节点 |
| | | function traverse(node, nodeId) { |
| | | if (node.id === nodeId) { |
| | | // 如果当前节点的ID等于子节点的ID,则表示已经找到了子节点,可以开始向上查找父节点 |
| | | return true; // 返回true表示已经找到了子节点 |
| | | } |
| | | |
| | | if (node.children) { |
| | | // 如果当前节点有子节点,则继续遍历子节点 |
| | | for (const childNode of node.children) { |
| | | if (traverse(childNode, nodeId)) { |
| | | // 如果在子节点中找到了子节点的父节点,则将当前节点的ID添加到父节点ID数组中,并返回true表示已经找到了子节点 |
| | | parentIds.push(node.id); |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; // 如果当前节点不是子节点的父节点,则返回false |
| | | } |
| | | |
| | | // 从根节点开始遍历整棵树,并调用递归函数查找子节点的所有父节点 |
| | | for (const node of dataSource) { |
| | | if (traverse(node, nodeId)) { |
| | | // 如果在当前节点的子树中找到了子节点的父节点,则直接退出循环 |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return parentIds; // 返回所有父节点ID的数组 |
| | | }, |
| | | }, |
| | | }; |