<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"
|
@tableRowClick="tableRowClick"
|
>
|
<template slot="tableButton">
|
<el-table-column label="操作" width="120">
|
<template slot-scope="scope">
|
<el-button
|
v-if="scope.row.status === 0"
|
@click="enableClick(scope.row, '启用')"
|
type="text"
|
size="small"
|
>启用</el-button
|
>
|
<el-button v-else @click="enableClick(scope.row, '停用')" type="text" size="small">停用</el-button>
|
<el-button @click="modifyClick(scope.row)" 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>
|
<div class="bottom">
|
<div class="product-search">
|
<div style="margin-left: 10px">可提供的产品</div>
|
<div style="margin-left: 20px">
|
<el-button type="primary" size="mini">创建采购单</el-button>
|
</div>
|
<SearchCommonView
|
class="search"
|
ref="searchCommonView"
|
:search-options="searchProductOptions"
|
@searchClick="searchProductClick"
|
@resetClick="resetProductClick"
|
/>
|
<div class="add-view">
|
<el-button type="primary" size="mini" @click="addNewProductClick">添加新产品</el-button>
|
</div>
|
</div>
|
<template>
|
<TableCommonView
|
ref="tableListProduct"
|
:table-list="productTableList"
|
@selCommonClick="selCommonClick"
|
@getSelectArray="getSelectArray"
|
>
|
<template slot="tableButton">
|
<el-table-column label="操作" width="170">
|
<template slot-scope="scope">
|
<el-button @click="raleteClick(scope.row)" type="text" size="small">相关供应商</el-button>
|
<el-button @click="editClick(scope.row)" type="text" size="small">修改</el-button>
|
<el-button @click="delClick(scope.row)" type="text" size="small">删除</el-button>
|
</template>
|
</el-table-column>
|
</template>
|
</TableCommonView>
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="productPagerOptions" v-on="pagerEvents" />
|
</div>
|
</template>
|
</div>
|
<!-- 新建/编辑销售线索 -->
|
<AddSupplier v-if="editConfig.visible" :add-common-config="editConfig" />
|
<!-- 详情 -->
|
<DetailSupplier v-if="commonDetail.visible" :common-detail="commonDetail" />
|
<!-- 相关供应商 -->
|
<RaleteSupplierList v-if="raleteSupplierConfig.visible" :common-config="raleteSupplierConfig" />
|
<!-- 添加新产品 -->
|
<AddNewProduct v-if="newProductConfig.visible" :add-common-config="newProductConfig" />
|
</div>
|
</template>
|
|
<script>
|
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
|
import { getSupplierList, changeSupplierStatus } from "@/api/supplierManage/supplier"
|
import DetailSupplier from "@/views/supplierManage/supplier/DetailSupplier"
|
import AddSupplier from "@/views/supplierManage/supplier/AddSupplier"
|
import RaleteSupplierList from "@/views/supplierManage/supplier/RaleteSupplierList"
|
import AddNewProduct from "@/views/supplierManage/supplier/AddNewProduct"
|
import { getProductList, deleteProduct } from "@/api/productManage/product"
|
|
export default {
|
name: "SupplierManage",
|
props: {},
|
components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct },
|
mixins: [pageMixin],
|
computed: {},
|
data() {
|
return {
|
tableList: {}, // 供应商列表
|
productTableList: {}, // 产品列表
|
selValueList: [],
|
searchOptions: [],
|
searchProductOptions: [], // 产品查询
|
commonDetail: {
|
visible: false,
|
infomation: {}
|
},
|
editConfig: {
|
visible: false,
|
title: "新建",
|
infomation: {}
|
},
|
raleteSupplierConfig: {
|
visible: false,
|
infomation: {}
|
},
|
newProductConfig: {
|
visible: false,
|
title: "添加",
|
infomation: {}
|
},
|
productPagerOptions: {
|
currPage: 1,
|
pageSize: 10,
|
totalCount: 0
|
},
|
supplierId: 0
|
}
|
},
|
created() {
|
this.setTable()
|
this.setProductTable()
|
this.getData()
|
},
|
methods: {
|
setTable() {
|
this.tableList = {
|
tableInfomation: [],
|
selectIndex: true,
|
ref: "tableListRef",
|
tableColumn: [
|
{ label: "供应商编号", prop: "number", min: 190, isCommonClick: true },
|
{ label: "供应商名称", prop: "name", min: 130 },
|
{ label: "供应商类型", prop: "supplierType", min: 130 },
|
{ label: "所属行业", prop: "industry", min: 130 },
|
{ label: "联系人", prop: "contact", min: 130 },
|
{ label: "联系电话", prop: "phone", min: 130 },
|
{ label: "状态", prop: "status_name", min: 130 },
|
{ label: "创建时间", prop: "member_name", min: 130 }
|
]
|
}
|
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 })
|
}
|
},
|
setProductTable() {
|
this.productTableList = {
|
tableInfomation: [],
|
selectBox: true,
|
selectIndex: true,
|
tableColumn: [
|
{ label: "产品编码", prop: "number", min: 190 },
|
{ label: "产品名称", prop: "name", min: 130 },
|
{ label: "产品规格", prop: "specifications", min: 130 },
|
{ label: "单位", prop: "unit", min: 130 },
|
{ label: "采购价格", prop: "purchasePrice", min: 130 },
|
{ label: "供货时长(天)", prop: "deliveryTime", min: 130 },
|
{ label: "物流时长(天)", prop: "shippingDuration", min: 130 }
|
]
|
}
|
this.searchProductOptions = []
|
for (let i = 0; i < this.productTableList.tableColumn.length; i++) {
|
const label = this.productTableList.tableColumn[i].label
|
const value = this.productTableList.tableColumn[i].prop
|
this.searchProductOptions.push({ value: value, label: label })
|
}
|
},
|
// 请求数据
|
async getData(val, content) {
|
this.getSupplierList(val, content)
|
},
|
// 供应商列表
|
async getSupplierList(val, content) {
|
await getSupplierList({
|
[val]: content,
|
page: this.pagerOptions.currPage,
|
pageSize: this.pagerOptions.pageSize
|
}).then((res) => {
|
console.log(res.data)
|
if (res.data.code === 200) {
|
const list = res.data.data.list.map((item) => {
|
return {
|
...item,
|
status_name: item.status === 0 ? "未启用" : "启用"
|
}
|
})
|
this.tableList.tableInfomation = list || []
|
this.pagerOptions.totalCount = res.data.data.total
|
if (list && list.length > 0) {
|
this.supplierId = this.tableList.tableInfomation[0].ID
|
} else {
|
this.supplierId = 0
|
}
|
this.getProductList()
|
}
|
})
|
},
|
// 产品列表
|
async getProductList(val, content) {
|
console.log(val, content)
|
await getProductList({
|
[val]: content,
|
supplierId: this.supplierId,
|
page: this.productPagerOptions.currPage,
|
pageSize: this.productPagerOptions.pageSize
|
}).then((res) => {
|
console.log(res.data)
|
const list = res.data.data.list.map((item) => {
|
return {
|
...item
|
}
|
})
|
this.productTableList.tableInfomation = list || []
|
this.productPagerOptions.totalCount = res.data.data.total
|
})
|
},
|
// 搜索供应商
|
searchClick(val, content) {
|
console.log(val, content)
|
this.getSupplierList(val.value, content)
|
},
|
resetClick() {
|
this.getSupplierList()
|
},
|
// 搜索产品
|
searchProductClick(val, content) {
|
console.log(val, content)
|
this.getProductList(val.value, content)
|
},
|
resetProductClick() {
|
this.getProductList()
|
},
|
// 新建供应商
|
addBtnClick() {
|
this.editConfig.visible = true
|
this.editConfig.title = "新建"
|
},
|
// 启用供应商
|
async enableClick(row, value) {
|
let status = value === "启用" ? 1 : 0
|
await changeSupplierStatus({
|
id: row.ID,
|
status: status
|
}).then((res) => {
|
if (res.code === 200) {
|
this.$message.success("状态修改成功")
|
this.getData()
|
}
|
})
|
},
|
// 修改供应商
|
modifyClick(row) {
|
console.log(row)
|
this.editConfig.visible = true
|
this.editConfig.title = "修改"
|
this.editConfig.infomation = { ...row }
|
},
|
// 相关供应商
|
raleteClick(row) {
|
console.log(row)
|
this.raleteSupplierConfig.visible = true
|
this.raleteSupplierConfig.infomation = { ...row }
|
},
|
// 添加新产品
|
addNewProductClick() {
|
this.newProductConfig.visible = true
|
this.newProductConfig.title = "添加"
|
},
|
// 修改产品
|
editClick(row) {
|
console.log(row)
|
this.newProductConfig.visible = true
|
// this.newProductConfig.title = "修改"
|
},
|
// 删除
|
delClick(row) {
|
this.$confirm("是否确认删除?", "警告", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
console.log("dddd")
|
deleteProduct({ id: row.ID }).then((response) => {
|
if (response.code === 200) {
|
this.$message.success("删除成功")
|
this.getProductList()
|
} else {
|
this.$message.warning("删除失败")
|
}
|
})
|
})
|
.catch(() => {})
|
},
|
getSelectArray(val) {
|
console.log(val)
|
this.selValueList = []
|
const list = val.map((item) => {
|
return item.id
|
})
|
this.selValueList = list
|
},
|
tableRowClick(row) {
|
console.log(row)
|
this.supplierId = row.ID
|
this.getProductList()
|
},
|
// 详情
|
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;
|
}
|
}
|
}
|
.bottom {
|
.product-search {
|
display: flex;
|
align-items: center;
|
.search {
|
margin-left: auto;
|
}
|
.add-view {
|
margin-left: 20px;
|
margin-right: 20px;
|
}
|
}
|
.btn-pager {
|
display: flex;
|
.page {
|
margin-left: auto;
|
}
|
}
|
}
|
}
|
</style>
|