| | |
| | | <template> |
| | | <win-md :title="`${setting.title}预警设置`" @close="close" :width="'800px'"> |
| | | <win-md :title="`${setting.title}预警设置`" @close="close" :width="'800px'" :loading="loading"> |
| | | <el-form ref="ruleForm" :model="formData" :rules="rules" class="demo-ruleForm" label-width="100px"> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="入库仓库" prop="baseWarehouseId"> |
| | | <el-form-item label="预警仓库" prop="baseWarehouseId"> |
| | | <el-select |
| | | v-model="formData.baseWarehouseId" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | :disabled="type == 'edit'" |
| | | v-model="formData.baseWarehouseId" |
| | | placeholder="请选择预警仓库" |
| | | style="width: 100%" |
| | | :disabled="type == 'edit'" |
| | | > |
| | | <el-option v-for="item in warehouses" :key="item.id" :label="item.warehouseName" :value="item.id" /> |
| | | <el-option v-for="item in warehouses" :key="item.id" :label="item.warehouseName" :value="item.id"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="物品分类" prop="baseCategoryIds"> |
| | | <el-form-item label="物品分类" prop="baseCategoryId"> |
| | | <el-cascader |
| | | v-model="formData.baseCategoryIds" |
| | | :options="categoryOptions" |
| | | :props="{ value: 'id' }" |
| | | @change="categoryChange" |
| | | style="width: 100%" |
| | | :disabled="type == 'edit'" |
| | | v-model="formData.baseCategoryId" |
| | | :options="categoryOptions" |
| | | :props="{ value: 'id',emitPath: false }" |
| | | :show-all-levels="false" |
| | | filterable |
| | | clearable |
| | | @change="categoryChange" |
| | | style="width: 100%" |
| | | :disabled="type == 'edit'" |
| | | ></el-cascader> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="物品名称" prop="baseGoodsTemplateId"> |
| | | <el-select |
| | | :value="formData.baseGoodsTemplateId" |
| | | placeholder="请先择物品分类" |
| | | filterable |
| | | :disabled="!formData.baseCategoryId || type == 'edit'" |
| | | @change="goodsTemplateChange" |
| | | style="width: 100%" |
| | | :value="formData.baseGoodsTemplateId" |
| | | :placeholder="formData.baseCategoryId?'请选择物品':'请先选择物品分类'" |
| | | filterable |
| | | clearable |
| | | :disabled="!formData.baseCategoryId || type == 'edit'" |
| | | @change="goodsTemplateChange" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in goodsTemplatelOptions" |
| | | :key="item.id" |
| | | :label="item.goodsName" |
| | | :value="item.id" |
| | | v-for="item in goodsTemplatelOptions" |
| | | :key="item.id" |
| | | :label="item.goodsName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="规格型号" prop="modelsIds"> |
| | | <el-select |
| | | v-model="formData.modelsIds" |
| | | multiple |
| | | :disabled="!formData.baseGoodsTemplateId || type == 'edit'" |
| | | placeholder="请先择物品名称" |
| | | @change="modelChange" |
| | | @remove-tag="modelRemoveTag" |
| | | style="width: 100%" |
| | | v-model="formData.modelsIds" |
| | | multiple |
| | | clearable |
| | | :disabled="!formData.baseGoodsTemplateId || type == 'edit'" |
| | | :placeholder="formData.baseCategoryId?'请选择规格型号':'请先选择物品名称'" |
| | | @change="modelChange" |
| | | @remove-tag="modelRemoveTag" |
| | | @clear="modelRemoveTag(-1)" |
| | | style="width: 100%" |
| | | > |
| | | <el-option v-for="item in modelsOptions" :key="item.id" :label="item.modelName" :value="item.id" /> |
| | | <el-option v-for="item in modelsOptions" :key="item.id" :label="item.modelName" :value="item.id"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-table-column prop="lowerLimit" label="保底库存" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-form-item |
| | | v-if="scope.row.lowerLimit || scope.row.upperLimit" |
| | | label-width="0" |
| | | :prop="`models[${scope.$index}].lowerLimit`" |
| | | :rules="rules.lowerLimit" |
| | | v-if="scope.row.lowerLimit || scope.row.upperLimit" |
| | | label-width="0" |
| | | :prop="`models[${scope.$index}].lowerLimit`" |
| | | :rules="rules.lowerLimit" |
| | | > |
| | | <el-input v-model.number="scope.row.lowerLimit"></el-input> |
| | | </el-form-item> |
| | |
| | | <el-table-column prop="upperLimit" label="封顶库存" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-form-item |
| | | v-if="scope.row.lowerLimit || scope.row.upperLimit" |
| | | label-width="0" |
| | | :prop="`models[${scope.$index}].upperLimit`" |
| | | :rules="rules.upperLimit" |
| | | v-if="scope.row.lowerLimit || scope.row.upperLimit" |
| | | label-width="0" |
| | | :prop="`models[${scope.$index}].upperLimit`" |
| | | :rules="rules.upperLimit" |
| | | > |
| | | <el-input v-model.number="scope.row.upperLimit"></el-input> |
| | | </el-form-item> |
| | |
| | | </el-table> |
| | | </el-form> |
| | | <div slot="footer" align="center" class="dialog-footer"> |
| | | <my-button name="取消" site="form" @click="close" /> |
| | | <my-button name="保存" site="form" @click="save" /> |
| | | <my-button name="取消" site="form" @click="close"/> |
| | | <my-button name="保存" site="form" @click="save"/> |
| | | </div> |
| | | </win-md> |
| | | </template> |
| | |
| | | import {findParentIds} from '@/utils/index'; |
| | | |
| | | export default { |
| | | components: { winMd, myButton }, |
| | | components: {winMd, myButton}, |
| | | props: { |
| | | setting: { |
| | | type: Object, |
| | | default: () => {}, |
| | | default: () => { |
| | | }, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | loading: true, |
| | | type: '', |
| | | warehouses: [], // 入库仓库列表 |
| | | agencyOptions: [], // 调拨机构 |
| | |
| | | models: [], |
| | | }, |
| | | rules: { |
| | | baseCategoryIds: [{ required: true, message: '请选择', trigger: 'blur' }], |
| | | baseGoodsTemplateId: [{ required: true, message: '请选择', trigger: 'blur' }], |
| | | modelsIds: [{ required: true, message: '请选择', trigger: 'blur' }], |
| | | baseWarehouseId: [{required: true, message: '请选择预警仓库', trigger: 'change'}], |
| | | baseCategoryId: [{required: true, message: '请选择物品分类', trigger: 'change'}], |
| | | baseGoodsTemplateId: [{required: true, message: '请选择物品', trigger: 'change'}], |
| | | modelsIds: [{required: true, message: '请选择规格型号', trigger: 'change'}], |
| | | lowerLimit: [ |
| | | { required: true, message: '请输入', trigger: 'blur' }, |
| | | { type: 'number', message: '请输入数字值', trigger: 'blur' }, |
| | | {required: true, message: '请输入', trigger: 'blur'}, |
| | | {type: 'number', message: '请输入数字值', trigger: 'blur'}, |
| | | ], |
| | | upperLimit: [ |
| | | { required: true, message: '请输入', trigger: 'blur' }, |
| | | { type: 'number', message: '请输入数字值', trigger: 'blur' }, |
| | | {required: true, message: '请输入', trigger: 'blur'}, |
| | | {type: 'number', message: '请输入数字值', trigger: 'blur'}, |
| | | ], |
| | | }, |
| | | }; |
| | |
| | | }, |
| | | methods: { |
| | | async init() { |
| | | await this.getWarehouseList(); |
| | | await this.getCategoryTree(); |
| | | if (this.setting.id) { |
| | | this.type = 'edit'; |
| | | const detail = await warningConfigGetById({ id: this.setting.id }); |
| | | await this.getCategoryTree(); |
| | | const detail = await warningConfigGetById({id: this.setting.id}); |
| | | this.formData = Object.assign({}, detail); |
| | | // 分类反显 |
| | | let res = await queryGoodsModelInfo({ baseGoodsModelsId: this.formData.baseGoodsModelsId }); |
| | | let res = await queryGoodsModelInfo({baseGoodsModelsId: this.formData.baseGoodsModelsId}); |
| | | this.formData.baseCategoryId = res[0].categoryId; |
| | | this.formData.baseCategoryIds = findParentIds(this.categoryOptions, this.formData.baseCategoryId); |
| | | // 物品名称反显 |
| | |
| | | this.getgoodsModel(this.formData.baseGoodsTemplateId); |
| | | this.formData.modelsIds = [this.formData.baseGoodsModelsId]; |
| | | this.getWarehouseList(); |
| | | } else { |
| | | this.getWarehouseList(); |
| | | this.getCategoryTree(); |
| | | } |
| | | this.loading = false |
| | | }, |
| | | // 获取入库仓库列表 |
| | | getWarehouseList() { |
| | | selectTenantWarehouse({ agencyId: this.userInfo.tenantId }) |
| | | .then((res) => { |
| | | this.warehouses = res; |
| | | if (this.warehouses.length && !this.formData.baseWarehouseId) { |
| | | // 默认选中第一个仓库 |
| | | this.formData.baseWarehouseId = this.warehouses[0].id; |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log('err', err); |
| | | }); |
| | | selectTenantWarehouse({agencyId: this.userInfo.tenantId}) |
| | | .then((res) => { |
| | | this.warehouses = res; |
| | | if (this.warehouses.length && !this.formData.baseWarehouseId) { |
| | | // 默认选中第一个仓库 |
| | | this.formData.baseWarehouseId = this.warehouses[0].id; |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log('err', err); |
| | | }); |
| | | }, |
| | | |
| | | getCategoryTree() { |
| | |
| | | |
| | | // 获取物品名称列表 |
| | | getgoodsTemplate(id) { |
| | | goodsTemplate({ categoryId: id || '', agencyId: this.userInfo.tenantId }).then((res) => { |
| | | goodsTemplate({categoryId: id || '', agencyId: this.userInfo.tenantId}).then((res) => { |
| | | this.goodsTemplatelOptions = res; |
| | | }); |
| | | }, |
| | | |
| | | // 规格型号 |
| | | getgoodsModel(id) { |
| | | goodsModel({ goodsTemplatesId: id || '' }).then((res) => { |
| | | goodsModel({goodsTemplatesId: id || ''}).then((res) => { |
| | | this.modelsOptions = res; |
| | | }); |
| | | }, |
| | |
| | | |
| | | // 物品分类选择 |
| | | categoryChange(e) { |
| | | if (!e) return; |
| | | this.goodsTemplatelOptions = []; |
| | | this.modelsOptions = []; |
| | | this.formData.baseGoodsTemplateId = ''; |
| | | this.formData.modelsIds = []; |
| | | this.formData.models = []; |
| | | |
| | | this.formData.baseCategoryId = e[e.length - 1]; |
| | | // 根据选中分类请求物品名称列表 |
| | | this.getgoodsTemplate(this.formData.baseCategoryId); |
| | | this.getgoodsTemplate(e); |
| | | }, |
| | | |
| | | // 物品名称列表选择 |
| | | goodsTemplateChange(e) { |
| | | this.formData.modelsIds = []; |
| | | this.formData.models = []; |
| | | |
| | | this.formData.baseGoodsTemplateId = e; |
| | | // 根据选中物品名称id获取规格型号列表 |
| | | this.getgoodsModel(e); |
| | |
| | | let str = JSON.stringify(arr); |
| | | e.forEach((item, index) => { |
| | | if (str && !str.includes(item)) { |
| | | arr.push({ baseGoodsModelsId: item, lowerLimit: null, upperLimit: null }); |
| | | arr.push({baseGoodsModelsId: item, lowerLimit: null, upperLimit: null}); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 规格型号移除 |
| | | modelRemoveTag(e) { |
| | | if (e === -1) { |
| | | this.formData.models = [] |
| | | return |
| | | } |
| | | let delIndex = this.formData.models.findIndex((v) => v.baseGoodsModelsId == e); |
| | | this.formData.models.splice(delIndex, 1); |
| | | }, |
| | | |
| | | getEditInfo(id) {}, |
| | | getEditInfo(id) { |
| | | }, |
| | | close() { |
| | | this.$emit('close'); |
| | | }, |
| | | save() { |
| | | this.$refs.ruleForm.validate((valid) => { |
| | | if (valid) { |
| | | if (this.loading) return |
| | | this.loading = true; |
| | | if (this.setting.id) { |
| | | // 编辑接口 |
| | | const params = { |
| | |
| | | upperLimit: this.formData.upperLimit, |
| | | }; |
| | | warningConfigUpd(params).then((res) => { |
| | | this.loading = false; |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }).catch((err) => { |
| | | this.loading = false; |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } else { |
| | | const params = { |
| | |
| | | modelConfigStr: JSON.stringify(this.formData.models), |
| | | }; |
| | | warningConfigAdd(params).then((res) => { |
| | | this.loading = false; |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }).catch((err) => { |
| | | this.loading = false; |
| | | this.$message.error('保存失败'); |
| | | }); |
| | | } |
| | | } else { |