<template>
|
<div class="rightContent">
|
<div class="top">
|
<div class="supplier-search">
|
<SearchCommonView
|
ref="searchCommonView"
|
:search-options="searchOptions"
|
@searchClick="searchClick"
|
@resetClick="resetClick"
|
/>
|
<div class="add-view">
|
<el-button type="primary" size="mini" @click="addBtnClick">新建</el-button>
|
</div>
|
</div>
|
<template>
|
<TableCommonView ref="tableListRef" :table-list="tableList" @selCommonClick="selCommonClick">
|
<template slot="tableButton">
|
<el-table-column label="操作" width="120">
|
<template slot-scope="scope">
|
<el-button @click="handleClick(scope.row)" type="text" size="small">编辑</el-button>
|
<el-button @click="delClick(scope.row.id)" type="text" size="small">删除</el-button>
|
</template>
|
</el-table-column>
|
</template>
|
</TableCommonView>
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
|
</div>
|
</template>
|
</div>
|
<!-- 新建/编辑产品 -->
|
<AddProduct v-if="editConfig.visible" :add-common-config="editConfig" />
|
<!-- 详情 -->
|
<DetailProduct v-if="commonDetail.visible" :common-detail="commonDetail" />
|
</div>
|
</template>
|
|
<script>
|
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
|
import { getProductList, deleteProduct } from "@/api/productManage/product"
|
import DetailProduct from "@/views/productManage/product/DetailProduct"
|
import AddProduct from "@/views/productManage/product/AddProduct"
|
|
export default {
|
name: "PruductManage",
|
props: {},
|
components: { DetailProduct, AddProduct },
|
mixins: [pageMixin],
|
computed: {},
|
data() {
|
return {
|
tableList: {},
|
searchOptions: [],
|
commonDetail: {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
},
|
editConfig: {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
}
|
}
|
},
|
created() {
|
this.setTable()
|
this.getData()
|
},
|
methods: {
|
setTable() {
|
this.tableList = {
|
tableInfomation: [],
|
selectIndex: true,
|
tableColumn: [
|
{ label: "产品编码", prop: "number", min: 190, isCommonClick: true },
|
{ label: "产品名称", prop: "name", min: 130 },
|
{ label: "供应商", prop: "id", min: 130 },
|
{ label: "产品类别", prop: "productType", min: 130 },
|
{ label: "规格", prop: "sales_resources", min: 130 },
|
{ label: "型号", prop: "province", min: 130 },
|
{ label: "单位", prop: "unit", min: 60 },
|
{ label: "价格", prop: "contact_phone1", min: 130 },
|
{ label: "最低库存", prop: "desc", min: 80 },
|
{ label: "最高库存", prop: "member_name", min: 80 }
|
]
|
}
|
this.searchOptions = []
|
for (let i = 0; i < this.tableList.tableColumn.length; i++) {
|
const label = this.tableList.tableColumn[i].label
|
const value = this.tableList.tableColumn[i].prop
|
this.searchOptions.push({ value: value, label: label })
|
}
|
},
|
// 请求数据
|
async getData(val, content) {
|
await getProductList({
|
val,
|
content,
|
page: this.pagerOptions.currPage,
|
pageSize: this.pagerOptions.pageSize
|
}).then((res) => {
|
if (res.data.code === 200) {
|
const list = res.data.data.list.map((item) => {
|
return {
|
...item
|
}
|
})
|
this.tableList.tableInfomation = list || []
|
this.pagerOptions.totalCount = res.data.data.total
|
}
|
})
|
},
|
// 搜索
|
searchClick(val, content) {
|
console.log(val, content)
|
this.getData(val, content)
|
},
|
resetClick() {
|
this.getData()
|
},
|
// 新建
|
addBtnClick() {
|
this.editConfig.visible = true
|
this.editConfig.title = "新建"
|
},
|
// 编辑
|
handleClick(row) {
|
console.log(row)
|
this.editConfig.visible = true
|
this.editConfig.title = "编辑"
|
this.editConfig.infomation = { ...row }
|
},
|
// 删除
|
delClick(val) {
|
this.$confirm("是否确认删除?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
deleteProduct({ id: val }).then((response) => {
|
if (response.code === 200) {
|
this.$message.success("删除成功")
|
this.getData()
|
} else {
|
this.$message.warning("删除失败")
|
}
|
})
|
})
|
.catch(() => {})
|
},
|
// 详情
|
selCommonClick(row) {
|
console.log(row)
|
this.commonDetail.visible = true
|
this.commonDetail.infomation = { ...row }
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.rightContent {
|
.top {
|
margin-bottom: 20px;
|
.supplier-search {
|
display: flex;
|
align-items: center;
|
.add-view {
|
margin-left: auto;
|
margin-right: 20px;
|
}
|
}
|
.btn-pager {
|
display: flex;
|
.page {
|
margin-left: auto;
|
}
|
}
|
}
|
}
|
</style>
|