| | |
| | | <template> |
| | | <win-md class="stock-edit" :title="`${setting.title}采购入库`" @close="close" :width="'800px'"> |
| | | <win-md class="stock-edit" :title="`${setting.title}采购入库`" @close="close" :width="'800px'" :loading="loading"> |
| | | <el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px"> |
| | | <div class="main-w"> |
| | | <el-row :gutter="24" class="headerHeight"> |
| | |
| | | :rules="rules.baseGoodsTemplateId" |
| | | > |
| | | <el-select |
| | | v-model="goodsItem.baseGoodsTemplateId" |
| | | v-model="goodsItem.baseGoodsTemplateId" |
| | | placeholder="请先择物品分类" |
| | | filterable |
| | | :disabled="!goodsItem.baseCategoryId" |
| | |
| | | {{ scope.row.unit }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="price" label="单价(元)" align="center"> |
| | | <el-table-column prop="priceYuan" label="单价(元)" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-form-item |
| | | label-width="0" |
| | | style="margin-bottom: 0" |
| | | :prop="`procureGoods[${goodsIndex}].models[${scope.$index}].price`" |
| | | :rules="rules.price" |
| | | :prop="`procureGoods[${goodsIndex}].models[${scope.$index}].priceYuan`" |
| | | :rules="rules.priceYuan" |
| | | > |
| | | <el-input type="number" v-model.number="scope.row.price"></el-input> |
| | | <el-input |
| | | type="number" |
| | | v-model.number="scope.row.priceYuan" |
| | | @change="priceChange($event, goodsIndex, scope.$index)" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | return callback(new Error('请选择')); |
| | | } |
| | | let temp = this.formData.procureGoods.filter((v) => v.baseGoodsTemplateId == value); |
| | | if (!temp || temp.length!=1) { |
| | | if (!temp || temp.length != 1) { |
| | | return callback(new Error('已选过此物品')); |
| | | } |
| | | callback(); |
| | |
| | | }; |
| | | // 数量校验 |
| | | var checkCounts = (rule, value, callback) => { |
| | | console.log(value) |
| | | if (!value) { |
| | | return callback(new Error('请输入')); |
| | | } |
| | |
| | | callback(); |
| | | }; |
| | | return { |
| | | loading: false, |
| | | loading: true, |
| | | buyTypeOptions: [ |
| | | { |
| | | label: '集采', |
| | |
| | | }, |
| | | modelsItem: { |
| | | baseGoodsModelsId: '', // 规格型号编号 |
| | | price: null, // 单价(采购需要,调拨不需要) |
| | | priceYuan: null, // 单价(元) |
| | | price: null, // 单价(分 采购需要,调拨不需要) |
| | | counts: null, // 操作数量 |
| | | unit: null, //单位 |
| | | }, |
| | |
| | | baseCategoryIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | baseGoodsTemplateId: [{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }], |
| | | modelsIds: [{ required: true, message: '请选择', trigger: 'change' }], |
| | | price: [{ validator: checkPrice, trigger: 'blur' }], |
| | | priceYuan: [{ validator: checkPrice, trigger: 'blur' }], |
| | | counts: [{ validator: checkCounts, trigger: 'blur' }], |
| | | }, |
| | | |
| | |
| | | title: '上传', |
| | | max: 20, // 最大大小,单位M |
| | | num: 10, // 支持上传图片个数 |
| | | accept: '.jpg,.png', // 限制格式 |
| | | tip: '', // 提示 默认:`只能上传${this.defaultSettings.num}个${this.defaultSettings.accept}文件,且不超过${this.defaultSettings.max}kb` |
| | | uploadUrl: getUploadUrl(), // 上传路径 |
| | | multiple: true, // 是否支持批量上传 |
| | |
| | | ); |
| | | this.getgoodsTemplate(item.baseCategoryId, index); |
| | | this.getgoodsModel(item.baseGoodsTemplateId, index); |
| | | item.models.forEach((child, childIndex) => { |
| | | this.$set(this.formData.procureGoods[index].models[childIndex], 'priceYuan', child.price / 100); |
| | | }); |
| | | return item; |
| | | }); |
| | | } |
| | | this.loading = false; |
| | | }, |
| | | |
| | | // 获取入库仓库列表 |
| | |
| | | this.formData.procureGoods[index].models.splice(delIndex, 1); |
| | | }, |
| | | |
| | | // 价格input监听 转为分 |
| | | priceChange(e, goodsIndex, index) { |
| | | this.formData.procureGoods[goodsIndex].models[index].price = e * 100; |
| | | }, |
| | | |
| | | // 上传 |
| | | uploadChange() { |
| | | let arr = this.$refs.uploadRef.fileList; |
| | |
| | | handleSubmit() { |
| | | this.$refs['ruleForm'].validate((valid) => { |
| | | if (valid) { |
| | | console.log('this.formData', this.formData); |
| | | this.loading = true; |
| | | if (!this.setting.id) { |
| | | procureAdd(this.formData) |
| | | .then((res) => { |
| | |
| | | this.$emit('search'); |
| | | }) |
| | | .catch((err) => { |
| | | console.log('create err', err); |
| | | this.loading = false; |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } else { |
| | |
| | | this.$emit('search'); |
| | | }) |
| | | .catch((err) => { |
| | | console.log('edit err', err); |
| | | this.loading = false; |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } |