This commit is contained in:
2023-10-08 15:58:29 +08:00
parent b4ffb20ba8
commit 51f101ea4e
77 changed files with 1378 additions and 947 deletions

View File

@@ -19,17 +19,18 @@
:rules="dataRule"
label-width="100px"
@keyup.enter.native="dataFormSubmit()">
<el-form-item label="产品" prop="productId">
<el-form-item label="产品" prop="productInfo">
<el-select
v-model="dataForm.productId"
v-model="dataForm.productInfo"
style="width: 100%"
@change="setProduct"
filterable
value-key="id"
placeholder="请选择产品">
<el-option
v-for="item in productArr"
:key="item.id"
:label="item.goodSpecificationName"
:value="item.id" />
:value="item" />
</el-select>
</el-form-item>
</el-form>
@@ -42,7 +43,6 @@
</template>
<script>
import { createWarehouseStorehouseGoodsSpecification } from '@/api/asrs/warehouseStorehouseGoodsSpecification';
import { getGoodSpecificationPage } from '@/api/asrs/goodSpecification';
export default {
@@ -56,52 +56,52 @@ export default {
return {
visible: false,
dataForm: {
id: 0,
productId: '',
value: '',
index: -1,
productInfo: '',
},
productArr: [],
dataRule: {
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
productId: [
{ required: true, message: '产品不能为空', trigger: 'blur' },
],
},
};
},
methods: {
init(id) {
this.dataForm.id = id || '';
init(index) {
if (index >= 0) {
this.dataForm.index = index;
}
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
const params = {
pageSize: 100,
pageNo: 1,
warehouseId: this.warehouseId,
};
getGoodSpecificationPage(params).then((response) => {
this.productArr = response.data.list;
});
});
},
setProduct(val) {
let data = this.productArr.find((item) => {
return (item.id === val);
});
const { id, ...newData } = data;
this.dataForm.value = newData;
this.dataForm.value.goodSpecificationId = id;
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
// 添加的提交
createWarehouseStorehouseGoodsSpecification({
...this.dataForm.value,
warehouseStorehouseId: this.warehouseId,
}).then((response) => {
this.$modal.msgSuccess('添加成功');
this.dataForm.productInfo.goodSpecificationId =
this.dataForm.productInfo.id;
// 修改的提交
if (this.dataForm.index >= 0) {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
this.$emit('refreshDataList', this.dataForm);
return;
}
// 添加的提交
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshDataList', this.dataForm);
}
});
},