| | |
| | | <template> |
| | | <win-md class="stock-edit" :title="`${setting.title}出库出库`" @close="close" :width="'800px'"> |
| | | <el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px"> |
| | | <win-md class="stock-edit" :title="`${setting.title}出库`" @close="close" :width="'800px'"> |
| | | <el-form v-loading="loading" class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px"> |
| | | <div class="main-w"> |
| | | <el-row :gutter="24" class="headerHeight"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="出库仓库" prop="warehouseId"> |
| | | <el-select v-model="formData.warehouseId" placeholder="请选择" style="width: 100%"> |
| | | <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.warehouseName" :value="item.id" /> |
| | | <el-select v-model="formData.warehouseId" placeholder="请选择" clearable style="width: 100%"> |
| | | <el-option |
| | | v-for="item in warehouseOptions" |
| | | :key="item.id" |
| | | :label="item.warehouseName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-date-picker |
| | | v-model="formData.dealTime" |
| | | type="datetime" |
| | | clearable |
| | | value="yyyy-MM-dd HH:mm:ss" |
| | | value-format="yyyyMMddHHmmss" |
| | | placeholder="请选择日期" |
| | |
| | | </el-row> |
| | | <el-row :gutter="24" class="headerHeight"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="出库手续" prop="procureDoc"> |
| | | <el-form-item label="出库手续" prop="doc"> |
| | | <upload ref="uploadRef" :settings="uploadSettings" @on-change="uploadChange"></upload> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item |
| | | label="物品分类" |
| | | :prop="`goods[${goodsIndex}].baseCategoryIds`" |
| | | :prop="`goods.${goodsIndex}.baseCategoryId`" |
| | | :rules="{ |
| | | required: true, |
| | | message: '请选择', |
| | |
| | | }" |
| | | > |
| | | <el-cascader |
| | | v-model="goodsItem.baseCategoryIds" |
| | | v-model="goodsItem.baseCategoryId" |
| | | :options="categoryOptions" |
| | | :props="{ value: 'id' }" |
| | | placeholder="请选择物品分类" |
| | | :props="{ value: 'id',emitPath: false }" |
| | | :show-all-levels="false" |
| | | filterable |
| | | clearable |
| | | @change="categoryChange($event, goodsIndex)" |
| | | style="width: 100%" |
| | | ></el-cascader> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item |
| | | label="物品名称" |
| | | :prop="`goods[${goodsIndex}].baseGoodsTemplateId`" |
| | | :prop="`goods.${goodsIndex}.baseGoodsTemplateId`" |
| | | :rules="rules.baseGoodsTemplateId" |
| | | > |
| | | <el-select |
| | | v-model="goodsItem.baseGoodsTemplateId" |
| | | placeholder="请先择物品分类" |
| | | :placeholder="goodsItem.baseCategoryId?'请选择物品':'请先选择物品分类'" |
| | | filterable |
| | | clearable |
| | | :disabled="!goodsItem.baseCategoryId" |
| | | style="width: 100%" |
| | | @change="goodsTemplateChange($event, goodsIndex)" |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item |
| | | label="规格型号" |
| | | :prop="`goods[${goodsIndex}].modelsIds`" |
| | | :prop="`goods.${goodsIndex}.modelsIds`" |
| | | :rules="{ |
| | | required: true, |
| | | message: '请选择', |
| | | message: '请选择规格型号', |
| | | trigger: 'change', |
| | | }" |
| | | > |
| | | <el-select |
| | | v-model="goodsItem.modelsIds" |
| | | multiple |
| | | placeholder="请先择物品名称" |
| | | :disabled="!goodsItem.baseCategoryId" |
| | | clearable |
| | | :placeholder="goodsItem.baseGoodsTemplateId?'请选择规格型号':'请先选择物品名称'" |
| | | :disabled="!goodsItem.baseGoodsTemplateId" |
| | | @change="modelChange($event, goodsIndex)" |
| | | @remove-tag="modelRemoveTag($event, goodsIndex)" |
| | | @clear="modelRemoveTag(-1, goodsIndex)" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="price" label="现有库存" align="center"> |
| | | <template slot-scope="scope">{{ }} |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.worehouseCount }} |
| | | </template> |
| | | </el-table-column> |
| | |
| | | <template slot-scope="scope"> |
| | | <el-form-item |
| | | label-width="0" |
| | | style="margin-bottom: 0" |
| | | :prop="`goods[${goodsIndex}].models[${scope.$index}].counts`" |
| | | :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-input |
| | | type="number" |
| | | v-model="scope.row.counts" |
| | | @change="countsChange($event, goodsIndex, scope.$index)" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | </el-form> |
| | | <div slot="footer" align="center" class="dialog-footer"> |
| | | <my-button name="取消" site="form" @click="close" /> |
| | | <my-button name="保存" site="form" @click="handleSubmit" /> |
| | | <el-button name="保存" type="primary" size="medium" :loading="btnloading" @click="handleSubmit">保存</el-button> |
| | | </div> |
| | | </win-md> |
| | | </template> |
| | | <script> |
| | | import { |
| | | goodsTemplate, |
| | | goodsModel, |
| | | selectTenantWarehouse, |
| | | } from '@/api/baseSetting/finsystenant'; |
| | | import { |
| | | outputAdd, |
| | | outputSelectNumber |
| | | } from '@/api/stock/accessStock'; |
| | | import { getTree } from '@/api/foudation/classification'; |
| | | import {goodsModel, goodsTemplate, selectTenantWarehouse, warehouseSelectNumber,} from '@/api/baseSetting/finsystenant'; |
| | | import {outputAdd} from '@/api/stock/accessStock'; |
| | | import {getTree} from '@/api/foudation/classification'; |
| | | import MyButton from '@/components/myButton/myButton'; |
| | | import winMd from '@/components/win/win-md'; |
| | | import upload from '@/components/upload/index'; |
| | | import { getUploadUrl } from '@/utils/base'; |
| | | import {mapGetters} from 'vuex' |
| | | import {getUploadUrl} from '@/utils/base'; |
| | | import {mapGetters} from 'vuex'; |
| | | import * as DateFormatter from "@/utils/DateFormatter"; |
| | | |
| | | export default { |
| | | components: { MyButton, winMd, upload }, |
| | |
| | | return callback(new Error('请选择')); |
| | | } |
| | | let temp = this.formData.goods.filter((v) => v.baseGoodsTemplateId == value); |
| | | if (!temp || temp.length!=1) { |
| | | if (!temp || temp.length != 1) { |
| | | return callback(new Error('已选过此物品')); |
| | | } |
| | | callback(); |
| | | }; |
| | | return { |
| | | loading: false, |
| | | loading: true, |
| | | btnloading: false, |
| | | warehouseOptions: [], // 出库仓库列表 |
| | | categoryOptions: [], // 物品分类列表 |
| | | modelList: [], //型号列表 |
| | | formData: { |
| | | warehouseId: '', // 出库仓库id |
| | | dealTime: '', // 出库时间 |
| | | procureDoc: '', |
| | | dealTime: DateFormatter.formatDate(new Date(), 'yyyyMMddhhmmss'), // 出库时间 |
| | | doc: '', |
| | | goods: [], |
| | | }, |
| | | goodsItem: { |
| | |
| | | worehouseCount: 0, |
| | | counts: null, // 操作数量 |
| | | unit: null, //单位 |
| | | totalAmount: 0, //单位 |
| | | }, |
| | | rules: { |
| | | warehouseId: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | dealTime: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | buyType: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | |
| | | baseCategoryIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | baseGoodsTemplateId: [{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }], |
| | | modelsIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }], |
| | | dealTime: [{ required: true, message: '请选择时间', trigger: 'change' }], |
| | | doc: [{required: true, message: '请上传审批手续', trigger: 'change'}], |
| | | baseCategoryId: [{ required: true, message: '请选择物品分类', trigger: 'change' }], |
| | | baseGoodsTemplateId: [{ required: true, message: '请选择物品', trigger: 'change' },{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }], |
| | | modelsIds: [{ required: true, message: '请选择规格型号', trigger: 'change' }], |
| | | counts: [{ required: true, message: '请输入', trigger: 'change' }], |
| | | }, |
| | | |
| | |
| | | title: '上传', |
| | | max: 20, // 最大大小,单位M |
| | | num: 10, // 支持上传图片个数 |
| | | accept: '.jpg,.png', // 限制格式 |
| | | tip: '', // 提示 默认:`只能上传${this.defaultSettings.num}个${this.defaultSettings.accept}文件,且不超过${this.defaultSettings.max}kb` |
| | | uploadUrl: getUploadUrl(), // 上传路径 |
| | | multiple: true, // 是否支持批量上传 |
| | |
| | | }, |
| | | }; |
| | | }, |
| | | computed:{ |
| | | ...mapGetters(['userInfo']) |
| | | computed: { |
| | | ...mapGetters(['userInfo']), |
| | | }, |
| | | created() { |
| | | this.init(); |
| | | }, |
| | | methods: { |
| | | async init() { |
| | | this.getWarehouseList(); |
| | | this.getgoodsTemplate(); |
| | | this.getgoodsModel(); |
| | | await this.getWarehouseList(); |
| | | await this.getgoodsTemplate(); |
| | | await this.getgoodsModel(); |
| | | // 获取物品分类列表 |
| | | const treeRes = await getTree(); |
| | | this.categoryOptions = this.removeEmptyChildren(treeRes); |
| | | this.loading = false |
| | | }, |
| | | |
| | | // 获取出库仓库列表 |
| | | getWarehouseList() { |
| | | selectTenantWarehouse({agencyId:this.userInfo.tenantId}) |
| | | async getWarehouseList() { |
| | | await selectTenantWarehouse({ agencyId: this.userInfo.tenantId }) |
| | | .then((res) => { |
| | | this.warehouseOptions = res |
| | | if(res.length) { |
| | | this.warehouseOptions = res; |
| | | if (res.length) { |
| | | this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem))); |
| | | } |
| | | if (this.warehouseOptions.length && !this.formData.warehouseId) { |
| | |
| | | }, |
| | | |
| | | // 获取物品名称列表 |
| | | getgoodsTemplate(id, index) { |
| | | goodsTemplate({ categoryId: id || '' }).then((res) => { |
| | | async getgoodsTemplate(id, index) { |
| | | await goodsTemplate({ agencyId: this.userInfo.tenantId, categoryId: id || '' }).then((res) => { |
| | | if (index || index == 0) { |
| | | this.$set(this.formData.goods[index], 'goodsOptions', res); |
| | | } else { |
| | |
| | | }, |
| | | |
| | | // 规格型号 |
| | | getgoodsModel(id, index) { |
| | | goodsModel({ goodsTemplatesId: id || '' }).then((res) => { |
| | | async getgoodsModel(id, index) { |
| | | await goodsModel({ goodsTemplatesId: id || '' }).then((res) => { |
| | | if (index || index == 0) { |
| | | this.$set(this.formData.goods[index], 'modelsOptions', res); |
| | | } else { |
| | |
| | | this.formData.goods[index].modelsOptions = []; |
| | | this.formData.goods[index].modelsIds = []; |
| | | this.formData.goods[index].models = []; |
| | | |
| | | this.formData.goods[index].baseCategoryId = e[e.length - 1]; |
| | | // 根据选中分类请求物品名称列表 |
| | | this.getgoodsTemplate(e[e.length - 1], index); |
| | | this.getgoodsTemplate(e, index); |
| | | }, |
| | | |
| | | // 物品名称列表选择 |
| | |
| | | async modelChange(e, index) { |
| | | let arr = [...this.formData.goods[index].models]; |
| | | let str = JSON.stringify(arr); |
| | | for(let item of e) { |
| | | for (let item of e) { |
| | | if (str.indexOf(item) == -1) { |
| | | let temp = this.goodsModelAll.find((v) => v.id == item); |
| | | // 获取库存 |
| | | let num = await outputSelectNumber({warehouseId:this.formData.warehouseId,baseGoodsModelsId:item}) |
| | | arr.push({ ...this.modelsItem, baseGoodsModelsId: item, unit: temp.unit,worehouseCount: num}); |
| | | let num = await warehouseSelectNumber({ |
| | | warehouseId: this.formData.warehouseId, |
| | | baseGoodsModelsId: item, |
| | | warehouseType: 0, |
| | | states: 1, |
| | | buyType: null, |
| | | }); |
| | | arr.push({ ...this.modelsItem, baseGoodsModelsId: item, unit: temp.unit, worehouseCount: num }); |
| | | } |
| | | } |
| | | this.formData.goods[index].models = arr; |
| | |
| | | |
| | | // 规格型号移除 |
| | | modelRemoveTag(e, index) { |
| | | if(e===-1){ |
| | | this.formData.goods[index].models = [] |
| | | return |
| | | } |
| | | let arr = this.formData.goods[index].models; |
| | | let delIndex = arr.findIndex((v) => v.baseGoodsModelsId == e); |
| | | this.formData.goods[index].models.splice(delIndex, 1); |
| | |
| | | |
| | | // 上传 |
| | | uploadChange() { |
| | | let arr = this.$refs.uploadRef.fileList |
| | | this.formData.procureDoc = JSON.stringify(arr) |
| | | let arr = this.$refs.uploadRef.fileList; |
| | | this.formData.doc = JSON.stringify(arr); |
| | | }, |
| | | |
| | | // 点击新增物品 |
| | |
| | | }, |
| | | |
| | | // 出库数量校验 |
| | | countsChange(e, goodsIndex,index) { |
| | | const curItem = this.formData.goods[goodsIndex].models[index] |
| | | const worehouseCount = curItem.worehouseCount |
| | | 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 |
| | | curItem.counts = null; |
| | | } |
| | | if (e > worehouseCount) { |
| | | this.$message.warning('数额超过现有库存'); |
| | | curItem.counts = worehouseCount > 0 ? worehouseCount : null |
| | | curItem.counts = worehouseCount > 0 ? worehouseCount : null; |
| | | } |
| | | }, |
| | | |
| | |
| | | handleSubmit() { |
| | | this.$refs['ruleForm'].validate((valid) => { |
| | | if (valid) { |
| | | if (this.loading) return |
| | | this.loading = true; |
| | | this.btnloading = true; |
| | | console.log('this.formData', this.formData); |
| | | outputAdd(this.formData) |
| | | .then((res) => { |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }) |
| | | .catch((err) => { |
| | | console.log('edit err', err); |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | outputAdd(this.formData) |
| | | .then((res) => { |
| | | this.$message.success('保存成功!'); |
| | | this.btnloading = false; |
| | | this.loading = false; |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }) |
| | | .catch((err) => { |
| | | console.log('edit err', err); |
| | | this.btnloading = false; |
| | | this.loading = false; |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } else { |
| | | this.$message.error('校验未通过,请检查。'); |
| | | this.btnloading = false; |
| | | } |
| | | }); |
| | | }, |