提交 ca537cc2 authored 作者: 刘旭's avatar 刘旭

优化

上级 9d3f1cb6
<template> <template>
<div class="app-container"> <div class="app-container">
<el-drawer v-model="editDrawer" size="100%" @before-close="handleCancel">
<el-card class="box-card"> <el-card class="box-card">
<h3>商品介绍</h3> <h3>商品介绍</h3>
<el-form ref="goodsRef" :rules="rules" :model="goods" label-width="150px"> <el-form ref="goodsRef" :rules="rules" :model="goods" label-width="150px">
...@@ -46,8 +47,8 @@ ...@@ -46,8 +47,8 @@
<el-form-item label="宣传画廊"> <el-form-item label="宣传画廊">
<el-upload :action="uploadPath" :limit="5" :headers="headers" :on-exceed="uploadOverrun" <el-upload :action="uploadPath" :limit="5" :headers="headers" :on-exceed="uploadOverrun"
:on-success="handleGalleryUrl" :on-remove="handleRemove" multiple accept=".jpg,.jpeg,.png,.gif" :on-success="handleGalleryUrl" :on-remove="handleRemove" multiple
list-type="picture-card"> accept=".jpg,.jpeg,.png,.gif" list-type="picture-card">
<el-icon class="avatar-uploader-icon"> <el-icon class="avatar-uploader-icon">
<Plus /> <Plus />
</el-icon> </el-icon>
...@@ -63,12 +64,14 @@ ...@@ -63,12 +64,14 @@
{{ tag }} {{ tag }}
</el-tag> </el-tag>
<el-input v-if="newKeywordVisible" ref="newKeywordInput" v-model="newKeyword" <el-input v-if="newKeywordVisible" ref="newKeywordInput" v-model="newKeyword"
class="input-new-keyword" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm" /> class="input-new-keyword" @keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm" />
<el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button> <el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button>
</el-form-item> </el-form-item>
<el-form-item label="商品配件"> <el-form-item label="商品配件">
<el-select v-model="goods.parts" multiple collapse-tags collapse-tags-tooltip style="width: 240px"> <el-select v-model="goodsParts" multiple collapse-tags collapse-tags-tooltip
style="width: 240px">
<el-option v-for="item in partsList" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in partsList" :key="item.id" :label="item.name" :value="item.id" />
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -166,59 +169,6 @@ ...@@ -166,59 +169,6 @@
</el-dialog> </el-dialog>
</el-card> </el-card>
<!-- <el-card class="box-card">
<h3>商品库存</h3>
<el-table :data="products">
<el-table-column property="value" label="货品规格">
<template #default="scope">
<el-tag v-for="tag in scope.row.specifications" :key="tag">
{{ tag }}
</el-tag>
</template>
</el-table-column>
<el-table-column property="price" width="100" label="货品售价" />
<el-table-column property="number" width="100" label="货品数量" />
<el-table-column property="url" width="100" label="货品图片">
<template #default="scope">
<img v-if="scope.row.url" :src="scope.row.url" width="40" />
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width">
<template #default="scope">
<el-button type="primary" size="small" @click="handleProductShow(scope.row)">设置</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog v-model="productVisiable" title="添加货品">
<el-form ref="productRef" :model="productForm" status-icon label-position="left" label-width="100px"
style="width: 400px; margin-left: 50px">
<el-form-item label="货品规格列" prop="specifications">
<el-tag v-for="tag in productForm.specifications" :key="tag">
{{ tag }}
</el-tag>
</el-form-item>
<el-form-item label="货品售价" prop="price">
<el-input v-model="productForm.price" />
</el-form-item>
<el-form-item label="货品数量" prop="number">
<el-input v-model="productForm.number" />
</el-form-item>
<el-form-item label="货品图片" prop="url">
<el-upload :action="uploadPath" :show-file-list="false" :headers="headers"
:on-success="uploadProductUrl" class="avatar-uploader" accept=".jpg,.jpeg,.png,.gif">
<img v-if="productForm.url" :src="productForm.url" class="avatar" />
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-form>
<template #footer class="dialog-footer">
<el-button @click="productVisiable = false">取消</el-button>
<el-button type="primary" @click="handleProductEdit">确定</el-button>
</template>
</el-dialog>
</el-card> -->
<el-card class="box-card"> <el-card class="box-card">
<h3>商品参数</h3> <h3>商品参数</h3>
<el-button type="primary" @click="handleAttributeShow">添加</el-button> <el-button type="primary" @click="handleAttributeShow">添加</el-button>
...@@ -227,14 +177,15 @@ ...@@ -227,14 +177,15 @@
<el-table-column property="value" label="商品参数值" /> <el-table-column property="value" label="商品参数值" />
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-button type="danger" size="small" @click="handleAttributeDelete(scope.row)">删除</el-button> <el-button type="danger" size="small" @click="handleAttributeDelete(scope.row)">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog v-model="attributeVisiable" title="添加商品参数"> <el-dialog v-model="attributeVisiable" title="添加商品参数">
<el-form ref="attributeRef" :model="attributeForm" status-icon label-position="left" label-width="100px" <el-form ref="attributeRef" :model="attributeForm" status-icon label-position="left"
style="width: 400px; margin-left: 50px"> label-width="100px" style="width: 400px; margin-left: 50px">
<el-form-item label="商品参数名称" prop="attribute"> <el-form-item label="商品参数名称" prop="attribute">
<el-input v-model="attributeForm.attribute" /> <el-input v-model="attributeForm.attribute" />
</el-form-item> </el-form-item>
...@@ -249,15 +200,16 @@ ...@@ -249,15 +200,16 @@
</el-dialog> </el-dialog>
</el-card> </el-card>
<div class="op-container"> <template #footer>
<el-button @click="handleCancel">取消</el-button> <el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleEdit">更新商品</el-button> <el-button type="primary" @click="handleEdit">更新商品</el-button>
</div> </template>
</el-drawer>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, nextTick } from "vue"; import { ref, computed } from "vue";
import { detailGoods, editGoods, listCatAndBrand } from "@/services/api/commodityManage/list"; import { detailGoods, editGoods, listCatAndBrand } from "@/services/api/commodityManage/list";
import { uploadPath } from "@/services/api/storage"; import { uploadPath } from "@/services/api/storage";
import { ElMessageBox, ElMessage, ElNotification } from "element-plus"; import { ElMessageBox, ElMessage, ElNotification } from "element-plus";
...@@ -266,6 +218,7 @@ import router from '@/router' ...@@ -266,6 +218,7 @@ import router from '@/router'
import { listGoods } from "@/services/api/commodityManage/list"; import { listGoods } from "@/services/api/commodityManage/list";
let route: any = router let route: any = router
let editDrawer = ref(false)
let newKeywordVisible = ref(false); let newKeywordVisible = ref(false);
let newPartsVisible = ref(false); let newPartsVisible = ref(false);
let newKeyword = ref(""); let newKeyword = ref("");
...@@ -290,9 +243,9 @@ let goods = ref({ ...@@ -290,9 +243,9 @@ let goods = ref({
brief: "", brief: "",
detail: '<p>你好啊!!</p>', detail: '<p>你好啊!!</p>',
categoryId: undefined, categoryId: undefined,
keywords: undefined, keywords: undefined
parts: undefined
} as any); } as any);
let goodsParts = ref()
let specVisiable = ref(false); let specVisiable = ref(false);
let specForm = ref({ specification: "", value: "", picUrl: "" } as any); let specForm = ref({ specification: "", value: "", picUrl: "" } as any);
let multipleSpec = ref(false); let multipleSpec = ref(false);
...@@ -305,7 +258,6 @@ let productForm = ref({ ...@@ -305,7 +258,6 @@ let productForm = ref({
number: 0, number: 0,
url: "", url: "",
}); });
let goodsId = ref(route.options.history.location.split('=')[1])
let products = ref([ let products = ref([
{ id: 0, specifications: ["标准"], price: 0.0, number: 0, url: "" }, { id: 0, specifications: ["标准"], price: 0.0, number: 0, url: "" },
]); ]);
...@@ -335,13 +287,9 @@ let initList = () => { ...@@ -335,13 +287,9 @@ let initList = () => {
}) })
} }
initList() initList()
let init = () => {
// if (route.options.history.location.split('=').length > 1) {
// var goodsId = route.options.history.location.split('=')[1]
// }
// else return
detailGoods(goodsId.value).then((res) => { let init = (id: number) => {
detailGoods(id).then((res) => {
goods.value = res.data.goods; goods.value = res.data.goods;
console.log(goods.value); console.log(goods.value);
...@@ -374,7 +322,6 @@ let init = () => { ...@@ -374,7 +322,6 @@ let init = () => {
brandList.value = res.data.brandList; brandList.value = res.data.brandList;
}); });
} }
init()
let htmlChange = (value: any) => goods.value.detail = value let htmlChange = (value: any) => goods.value.detail = value
...@@ -622,6 +569,11 @@ let handleAttributeDelete = (row: any) => { ...@@ -622,6 +569,11 @@ let handleAttributeDelete = (row: any) => {
const index = attributes.value.indexOf(row); const index = attributes.value.indexOf(row);
attributes.value.splice(index, 1); attributes.value.splice(index, 1);
} }
defineExpose({
editDrawer,
init
})
</script> </script>
<style> <style>
......
...@@ -114,6 +114,8 @@ ...@@ -114,6 +114,8 @@
<litemall-page :page-data="listQuery" :total="total" @size-change="sizeChange" <litemall-page :page-data="listQuery" :total="total" @size-change="sizeChange"
@current-change="currentChange" /> @current-change="currentChange" />
</div> </div>
<shelves ref="shelvesRef" @initShelves="getList"/>
<edit ref="editRef" :editId="editId" @initShelves="getList"/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
...@@ -123,10 +125,15 @@ import { listGoods, deleteGoods } from "@/services/api/commodityManage/list"; ...@@ -123,10 +125,15 @@ import { listGoods, deleteGoods } from "@/services/api/commodityManage/list";
// import { thumbnail, toPreview } from "@/utils/index"; // import { thumbnail, toPreview } from "@/utils/index";
import router from '@/router'; import router from '@/router';
import LitemallPage from "@/components/pagination/litemallPage.vue"; import LitemallPage from "@/components/pagination/litemallPage.vue";
import shelves from './shelves.vue'
import edit from './edit.vue'
let list = ref([]); let list = ref([]);
let total = ref(0); let total = ref(0);
let listLoading = ref(true); let listLoading = ref(true);
let shelvesRef = ref();
let editRef = ref();
let editId = ref();
let listQuery = ref({ let listQuery = ref({
page: 1, page: 1,
limit: 10, limit: 10,
...@@ -170,12 +177,12 @@ let handleFilter = () => { ...@@ -170,12 +177,12 @@ let handleFilter = () => {
getList(); getList();
}; };
let handleCreate = () => { let handleCreate = () => {
console.log('跳转'); shelvesRef.value.shelvesDrawer = true
// router.push({ path: "/commodity/shelves" });
router.push({ path: "/commodity/shelves" });
}; };
let handleUpdate = (row: any) => { let handleUpdate = (row: any) => {
router.push({ path: "/commodity/edit", query: { id: row.id } }); editRef.value.init(row.id)
editRef.value.editDrawer = true
}; };
let showDetail = (detail: any) => { let showDetail = (detail: any) => {
goodsDetail = detail; goodsDetail = detail;
......
...@@ -89,7 +89,7 @@ export default ({ command, mode }) => { ...@@ -89,7 +89,7 @@ export default ({ command, mode }) => {
// '/foo': '', // '/foo': '',
// 选项写法 // 选项写法
"/admin": { "/admin": {
target: "http://192.168.0.23/", target: "http://192.168.0.9:8089/",
// rewrite: (path) => path.replace(/^\/api/, '') // rewrite: (path) => path.replace(/^\/api/, '')
}, },
// 正则表达式写法 // 正则表达式写法
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论