This commit is contained in:
曹辉 2023-01-29 10:45:59 +08:00
parent 3900b1dfea
commit 0f302aae64
3 changed files with 88 additions and 34 deletions

View File

@ -190,6 +190,7 @@
:visible.sync="open" :visible.sync="open"
width="1200px" width="1200px"
append-to-body append-to-body
:before-close="cancel"
> >
<el-form <el-form
ref="form" ref="form"
@ -234,7 +235,18 @@
> >
</el-form-item> </el-form-item>
<el-form-item label="商品分类名称" prop="goodsCategoryId"> <el-form-item label="商品分类名称" prop="goodsCategoryId">
<el-select <!-- v-model="form.parentIdList" -->
<el-cascader
:props="treeOption"
@change="change"
style="width: 210px"
:show-all-levels="false"
:clearable="true"
ref="cascader"
:placeholder="form.goodsCategoryName ? form.goodsCategoryName : ''"
>
</el-cascader>
<!-- <el-select
style="width: 210px" style="width: 210px"
v-model="form.goodsCategoryId" v-model="form.goodsCategoryId"
clearable clearable
@ -247,7 +259,7 @@
:value="item.id" :value="item.id"
> >
</el-option> </el-option>
</el-select> </el-select> -->
</el-form-item> </el-form-item>
<el-form-item label="商品用途" prop="goodsPurpose"> <el-form-item label="商品用途" prop="goodsPurpose">
<el-select <el-select
@ -489,5 +501,8 @@ export default indexjs;
overflow: hidden; overflow: hidden;
font-size: 14px; font-size: 14px;
} }
::v-deep .el-cascader .el-input input::-webkit-input-placeholder {
color: black;
}
</style> </style>

View File

@ -9,9 +9,13 @@ import {
editGoodsWhetherShelf, editGoodsWhetherShelf,
stationList, stationList,
} from "@/api/system/OperateGoodsInfo"; } from "@/api/system/OperateGoodsInfo";
import {
getStationCategoryList,
} from "@/api/system/goodsCategory";
import editor from "@/components/Editor"; import editor from "@/components/Editor";
import stationAcatar from "../stationAvatar/index.vue"; import stationAcatar from "../stationAvatar/index.vue";
import baseurl from "@/api/baseurl.js"; import baseurl from "@/api/baseurl.js";
let id = 0;
export default { export default {
components: { stationAcatar, editor }, components: { stationAcatar, editor },
@ -36,7 +40,6 @@ export default {
// 总条数 // 总条数
total: 0, total: 0,
total2: 0, total2: 0,
// 商品基本信息表格数据 // 商品基本信息表格数据
goodsInfoList: [], goodsInfoList: [],
// 护理站列表 // 护理站列表
@ -131,19 +134,38 @@ export default {
], ],
}, },
homestation: null, homestation: null,
treeOption: {
lazy: true,
checkStrictly: true, // 是否可选择任意一级
lazyLoad(node, resolve) {
const id = (node.level === 0) ? 0 : node.data.id;
setTimeout(() => {
getStationCategoryList(id).then(res => { // 接口请求
res.data.forEach(e => {
e.value = e.id
e.label = e.goodsCategoryName
})
resolve(res.data.map(item => {
return {
...item
}
}))
});
}, 1000);
},
},
ruleForm: [],
}; };
}, },
created() { created() {
this.getList(); this.getList();
this.goodsCategoryinfo(); // this.goodsCategoryinfo();
}, },
methods: { methods: {
imgs(item) { imgs(item) {
this.imgsurl.pictureUrlList.push(item); this.imgsurl.pictureUrlList.push(item);
// console.log(this.imgsurl)
}, },
upwhetherShelf(row) { upwhetherShelf(row) {
console.log(row);
if (row.whetherShelf == false) { if (row.whetherShelf == false) {
var obj = { var obj = {
id: row.goodsInfoId, id: row.goodsInfoId,
@ -156,7 +178,6 @@ export default {
}; };
} }
editGoodsWhetherShelf(obj).then((res) => { editGoodsWhetherShelf(obj).then((res) => {
console.log(obj);
if (obj.whetherShelf == 0) { if (obj.whetherShelf == 0) {
this.$modal.msgSuccess("已修改上架状态为未上架"); this.$modal.msgSuccess("已修改上架状态为未上架");
} else { } else {
@ -199,7 +220,6 @@ export default {
}, },
// 删除 // 删除
delgoodAttributeDetail(item) { delgoodAttributeDetail(item) {
console.log(item);
if (item.ids && !item.attributeDetailsId) { if (item.ids && !item.attributeDetailsId) {
if (this.goodDetailsLists.length == 1) { if (this.goodDetailsLists.length == 1) {
this.$message.error("最后一条不可删除"); this.$message.error("最后一条不可删除");
@ -217,19 +237,15 @@ export default {
); );
} }
} }
console.log(this.goodDetailsLists);
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
console.log(this.form);
var obj = { pictureUrlList: [] }; var obj = { pictureUrlList: [] };
if (this.imgone != this.form.goodsPictureUrl) { if (this.imgone != this.form.goodsPictureUrl) {
obj.pictureUrlList.push(this.form.goodsPictureUrl); obj.pictureUrlList.push(this.form.goodsPictureUrl);
} }
if (obj.pictureUrlList.length > 0) { if (obj.pictureUrlList.length > 0) {
updatePicture(obj).then((res) => { updatePicture(obj).then((res) => {});
console.log(res);
});
} }
if (this.imgsurl.pictureUrlList.length > 0) { if (this.imgsurl.pictureUrlList.length > 0) {
updatePicture(this.imgsurl).then((res) => {}); updatePicture(this.imgsurl).then((res) => {});
@ -247,6 +263,11 @@ export default {
attributeDetailsSort: null, attributeDetailsSort: null,
}, ], }, ],
}, ]; }, ];
// 清空选中的节点
this.$refs.cascader.$refs.panel.clearCheckedNodes();
// 设置为空可以让节点不高亮显示
this.$refs.cascader.$refs.panel.activePath = [];
}, },
//页面所属护理站 //页面所属护理站
ParamsStation(item) { ParamsStation(item) {
@ -335,7 +356,6 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
console.log(selection);
this.ids = selection.map((item) => item.goodsInfoId); this.ids = selection.map((item) => item.goodsInfoId);
this.single = selection.length !== 1; this.single = selection.length !== 1;
this.multiple = !selection.length; this.multiple = !selection.length;
@ -366,23 +386,25 @@ export default {
if (this.StationName == null) { if (this.StationName == null) {
this.StationName = "请选择所属护理站"; this.StationName = "请选择所属护理站";
} }
console.log(this.StationName);
getGoodsInfo(id).then((response) => { getGoodsInfo(id).then((response) => {
// response.data[0].parentIdList = response.data[0].parentIdList[0].split(',')
this.form = response.data[0]; this.form = response.data[0];
this.imgone = this.form.goodsPictureUrl; this.imgone = this.form.goodsPictureUrl;
if (response.data[0].goodAttributeDetailsLists) { if (response.data[0].goodAttributeDetailsLists) {
this.goodDetailsLists = response.data[0].goodAttributeDetailsLists; this.goodDetailsLists = response.data[0].goodAttributeDetailsLists;
} }
// console.log(this.form.parentIdList)
// this.form.goodsCategoryId = this.form.goodsCategoryName
// this.form.value = this.form.goodsCategoryId
// this.form.label = this.form.goodsCategoryName
this.open = true; this.open = true;
this.title = "修改商品基本信息"; this.title = "修改商品基本信息";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
console.log(this.form)
this.form.goodAttributeDetailsLists = []; this.form.goodAttributeDetailsLists = [];
this.form.goodDetailsLists = this.goodDetailsLists; this.form.goodDetailsLists = this.goodDetailsLists;
console.log(this.form);
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
if (this.form.goodsInfoId != null) { if (this.form.goodsInfoId != null) {
@ -401,9 +423,7 @@ export default {
} }
this.imgsurl = { pictureUrlList: [] }; this.imgsurl = { pictureUrlList: [] };
if (obj.pictureUrlList.length > 0) { if (obj.pictureUrlList.length > 0) {
updatePicture(obj).then((res) => { updatePicture(obj).then((res) => {});
console.log(res);
});
} }
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
@ -416,7 +436,6 @@ export default {
}) })
// this.nurseStationId=this.form.nurseStationId // this.nurseStationId=this.form.nurseStationId
addGoodsInfo(this.form).then((response) => { addGoodsInfo(this.form).then((response) => {
console.log(this.form);
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.StationName = "请选择所属护理站"; this.StationName = "请选择所属护理站";
this.open = false; this.open = false;
@ -428,7 +447,6 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
console.log("row :>> ", row);
this.$confirm("是否确认删除订单信息的数据项?", "提示", { this.$confirm("是否确认删除订单信息的数据项?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
@ -439,9 +457,7 @@ export default {
var obj = { pictureUrlList: [] }; var obj = { pictureUrlList: [] };
obj.pictureUrlList.push(row.goodsPictureUrl); obj.pictureUrlList.push(row.goodsPictureUrl);
if (obj.pictureUrlList.length > 0) { if (obj.pictureUrlList.length > 0) {
updatePicture(obj).then((res) => { updatePicture(obj).then((res) => {});
console.log(res);
});
} }
this.$message.success("删除成功"); this.$message.success("删除成功");
this.getList(); this.getList();
@ -450,11 +466,9 @@ export default {
.catch(() => {}); .catch(() => {});
}, },
imgUrl(imgUrl) { imgUrl(imgUrl) {
console.log(imgUrl);
this.form.goodsPictureUrl = imgUrl; this.form.goodsPictureUrl = imgUrl;
}, },
attributePitureUrl(imgUrl) { attributePitureUrl(imgUrl) {
console.log(imgUrl);
// this.form.attributePitureUrl = imgUrl; // this.form.attributePitureUrl = imgUrl;
}, },
attributePitureitem(item) { attributePitureitem(item) {
@ -475,11 +489,17 @@ export default {
}, },
//商品分类 //商品分类
goodsCategoryinfo() { goodsCategoryinfo() {
goodsCategory().then((res) => { getStationCategoryList(0).then((res) => {
console.log(this.form); res.data.forEach(e => {
this.goodsCategorylist = res.rows; e.value = e.id
e.label = e.goodsCategoryName
})
this.goodsCategorylist = res.data;
}); });
}, },
change(e) {
this.form.goodsCategoryId = e[e.length - 1]
},
//护理站 //护理站
info() { info() {
stationList(this.getListByUserquery).then((res) => { stationList(this.getListByUserquery).then((res) => {

View File

@ -185,6 +185,8 @@
<!-- 添加或修改商品分类信息对话框 --> <!-- 添加或修改商品分类信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-cascader :props="props"></el-cascader>
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item <el-form-item
label="父级分类名称" label="父级分类名称"
@ -192,12 +194,12 @@
:required="true" :required="true"
v-if="form.parentId" v-if="form.parentId"
> >
<el-input <!-- <el-input
v-model="form.parentName" v-model="form.parentName"
placeholder="请输入商品分类名称" placeholder="请输入父级分类名称"
maxlength="10" maxlength="10"
disabled disabled
/> /> -->
</el-form-item> </el-form-item>
<el-form-item label="商品分类名称" prop="goodsCategoryName"> <el-form-item label="商品分类名称" prop="goodsCategoryName">
<el-input <el-input
@ -257,11 +259,28 @@ import {
} from "@/api/system/goodsCategory"; } from "@/api/system/goodsCategory";
import stationAcatar from "../stationAvatar/index.vue"; import stationAcatar from "../stationAvatar/index.vue";
import baseurl from "@/api/baseurl"; import baseurl from "@/api/baseurl";
let id = 0;
export default { export default {
name: "GoodsCategory", name: "GoodsCategory",
components: { stationAcatar }, components: { stationAcatar },
data() { data() {
return { return {
props: {
lazy: true,
lazyLoad(node, resolve) {
console.log(node)
const { level } = node;
setTimeout(() => {
const nodes = Array.from({ length: level + 1 }).map((item) => ({
value: ++id,
label: `选项${id}`,
leaf: level >= 2,
}));
// resolve
resolve(nodes);
}, 1000);
},
},
imgone: "", imgone: "",
baseurl: "", baseurl: "",
// //
@ -328,7 +347,7 @@ export default {
created() { created() {
this.baseurl = baseurl; this.baseurl = baseurl;
// this.getList(); this.getList();
this.info(); this.info();
}, },
methods: { methods: {