| | |
| | | <template> |
| | | <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"> |
| | | <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"> |
| | |
| | | plain |
| | | size="mini" |
| | | @click="removeGoods(goodsIndex)" |
| | | >移除</el-button |
| | | >移除 |
| | | </el-button |
| | | > |
| | | <el-button |
| | | v-if="formData.procureGoods.length - 1 == goodsIndex" |
| | |
| | | plain |
| | | size="mini" |
| | | @click="addGoods" |
| | | >新增物品</el-button |
| | | >新增物品 |
| | | </el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | props: { |
| | | setting: { |
| | | type: Object, |
| | | default: () => {}, |
| | | default: () => { |
| | | }, |
| | | }, |
| | | }, |
| | | data() { |
| | |
| | | }, |
| | | methods: { |
| | | async init() { |
| | | this.getWarehouseList(); |
| | | this.getgoodsTemplate(); |
| | | this.getgoodsModel(); |
| | | await this.getWarehouseList(); |
| | | |
| | | // 获取物品分类列表 |
| | | const treeRes = await getTree(); |
| | | this.categoryOptions = this.removeEmptyChildren(treeRes); |
| | |
| | | } |
| | | this.$set(this.formData, 'buyType', this.formData.buyType.toString()); |
| | | this.formData.procureTime = this.formData.procureTime.toString(); |
| | | this.formData.procureGoods.map((item, index) => { |
| | | this.formData.procureGoods.map(async (item, index) => { |
| | | // 根据子集ID拼接物品分类列表 |
| | | item.baseCategoryIds = findParentIds(this.categoryOptions, item.baseCategoryId); |
| | | this.$set( |
| | |
| | | 'modelsIds', |
| | | item.models.map((v) => v.baseGoodsModelsId), |
| | | ); |
| | | this.getgoodsTemplate(item.baseCategoryId, index); |
| | | this.getgoodsModel(item.baseGoodsTemplateId, index); |
| | | item.models.forEach((child, childIndex) => { |
| | | await this.getgoodsTemplate(item.baseCategoryId, index); |
| | | await this.getgoodsModel(item.baseGoodsTemplateId, index); |
| | | await item.models.forEach((child, childIndex) => { |
| | | this.$set(this.formData.procureGoods[index].models[childIndex], 'priceYuan', child.price / 100); |
| | | }); |
| | | return item; |
| | | }); |
| | | } else { |
| | | await this.getgoodsTemplate(); |
| | | await this.getgoodsModel(); |
| | | } |
| | | this.loading = false; |
| | | }, |
| | | |
| | | // 获取入库仓库列表 |
| | | getWarehouseList() { |
| | | selectTenantWarehouse({ agencyId: this.userInfo.tenantId }) |
| | | async getWarehouseList() { |
| | | await selectTenantWarehouse({agencyId: this.userInfo.tenantId}) |
| | | .then((res) => { |
| | | this.warehouses = res; |
| | | if (!this.setting.id && res.length) { |
| | |
| | | }, |
| | | |
| | | // 获取物品名称列表 |
| | | getgoodsTemplate(id, index) { |
| | | goodsTemplate({ categoryId: id || '' }).then((res) => { |
| | | async getgoodsTemplate(id, index) { |
| | | await goodsTemplate({categoryId: id || ''}).then((res) => { |
| | | if (index || index == 0) { |
| | | this.$set(this.formData.procureGoods[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.procureGoods[index], 'modelsOptions', res); |
| | | } else { |
| | |
| | | handleSubmit() { |
| | | this.$refs['ruleForm'].validate((valid) => { |
| | | if (valid) { |
| | | if (this.loading) return |
| | | this.loading = true; |
| | | if (!this.setting.id) { |
| | | procureAdd(this.formData) |