|
@@ -13,13 +13,15 @@
|
|
<div style="display:flex;align-items: center;padding:10px 0;">
|
|
<div style="display:flex;align-items: center;padding:10px 0;">
|
|
<div style="font-size:14px;"><span style="color:red;">*</span>供应商名称:</div>
|
|
<div style="font-size:14px;"><span style="color:red;">*</span>供应商名称:</div>
|
|
<div style="flex-grow: 1;">
|
|
<div style="flex-grow: 1;">
|
|
- <supplier style="width:50%" v-model="queryParam.supplierSn" placeholder="请输入供应商名称搜索"></supplier>
|
|
|
|
|
|
+ <supplier style="width:50%" v-model="supplierSn" @change="getChoosed" placeholder="请输入供应商名称搜索"></supplier>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div style="padding:10px 0;border-bottom: 1px solid #eee;">
|
|
|
|
- <span style="font-size:14px;">选择产品</span>
|
|
|
|
- <span style="font-weight: bold;">(已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length }}个)</span>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div style="padding:10px 0;border-bottom: 1px solid #eee;">
|
|
|
|
+ <span style="font-size:14px;">选择产品</span>
|
|
|
|
+ <span style="font-weight: bold;" v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length">
|
|
|
|
+ (已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length||0 }}个)
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
<div style="padding:15px 0 0;">
|
|
<div style="padding:15px 0 0;">
|
|
<!-- 搜索条件 -->
|
|
<!-- 搜索条件 -->
|
|
<div class="table-page-search-wrapper">
|
|
<div class="table-page-search-wrapper">
|
|
@@ -39,7 +41,7 @@
|
|
</a-form-model-item>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
</a-col>
|
|
<a-col :md="6" :sm="24">
|
|
<a-col :md="6" :sm="24">
|
|
- <a-form-model-item label="产品品牌" :prop="type=='dealership'?'productBrandSn':''">
|
|
|
|
|
|
+ <a-form-model-item label="产品品牌">
|
|
<a-select
|
|
<a-select
|
|
placeholder="请选择产品品牌"
|
|
placeholder="请选择产品品牌"
|
|
id="chooseProducts-productBrandSn"
|
|
id="chooseProducts-productBrandSn"
|
|
@@ -53,7 +55,7 @@
|
|
</a-form-model-item>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
</a-col>
|
|
<a-col :md="6" :sm="24">
|
|
<a-col :md="6" :sm="24">
|
|
- <a-form-model-item label="产品分类" :prop="type=='dealership'?'productType':''">
|
|
|
|
|
|
+ <a-form-model-item label="产品分类">
|
|
<a-cascader
|
|
<a-cascader
|
|
@change="changeProductType"
|
|
@change="changeProductType"
|
|
change-on-select
|
|
change-on-select
|
|
@@ -80,7 +82,7 @@
|
|
size="small"
|
|
size="small"
|
|
:rowKey="(record) => record.productSn"
|
|
:rowKey="(record) => record.productSn"
|
|
rowKeyName="productSn"
|
|
rowKeyName="productSn"
|
|
- :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: (this.type == 'supplier') && (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.indexOf(record.productSn) > -1) }}) }"
|
|
|
|
|
|
+ :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseData && this.chooseData.indexOf(record.productSn) > -1 }}) }"
|
|
@rowSelection="rowSelectionFun"
|
|
@rowSelection="rowSelectionFun"
|
|
:columns="columns"
|
|
:columns="columns"
|
|
:data="loadData"
|
|
:data="loadData"
|
|
@@ -115,7 +117,8 @@ import { productBrandQuery } from '@/api/productBrand'
|
|
import { productTypeQuery, productTypeQueryAll } from '@/api/productType'
|
|
import { productTypeQuery, productTypeQueryAll } from '@/api/productType'
|
|
import supplier from '@/views/common/supplier.js'
|
|
import supplier from '@/views/common/supplier.js'
|
|
import { dealerScopeValidProduct } from '@/api/dealerScope'
|
|
import { dealerScopeValidProduct } from '@/api/dealerScope'
|
|
-import { productPricedList, productPricingList } from '@/api/product'
|
|
|
|
|
|
+import { addProduct, supplierProductSnList } from '@/api/supplier'
|
|
|
|
+import { productPricingList } from '@/api/product'
|
|
export default {
|
|
export default {
|
|
name: 'ChooseProductsModal',
|
|
name: 'ChooseProductsModal',
|
|
components: { STable, supplier },
|
|
components: { STable, supplier },
|
|
@@ -124,15 +127,9 @@ export default {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false
|
|
default: false
|
|
},
|
|
},
|
|
- chooseData: {
|
|
|
|
- type: Array,
|
|
|
|
- default: () => {
|
|
|
|
- return []
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
type: { // 类型,经销权设置dealership, 供应商添加产品supplier
|
|
type: { // 类型,经销权设置dealership, 供应商添加产品supplier
|
|
type: String,
|
|
type: String,
|
|
- default: ''
|
|
|
|
|
|
+ default: 'supplier'
|
|
},
|
|
},
|
|
dealerSn: {
|
|
dealerSn: {
|
|
type: String || Number,
|
|
type: String || Number,
|
|
@@ -147,6 +144,7 @@ export default {
|
|
labelCol: { span: 4 },
|
|
labelCol: { span: 4 },
|
|
wrapperCol: { span: 20 }
|
|
wrapperCol: { span: 20 }
|
|
},
|
|
},
|
|
|
|
+ supplierSn: undefined, // 供应商sn
|
|
queryParam: { // 查询条件
|
|
queryParam: { // 查询条件
|
|
code: '', // 产品编码
|
|
code: '', // 产品编码
|
|
productBrandSn: undefined, // 产品品牌
|
|
productBrandSn: undefined, // 产品品牌
|
|
@@ -159,6 +157,7 @@ export default {
|
|
productBrandSn: [ { required: true, message: '请选择产品品牌', trigger: 'change' } ],
|
|
productBrandSn: [ { required: true, message: '请选择产品品牌', trigger: 'change' } ],
|
|
productType: [ { required: true, message: '请选择产品分类', trigger: 'change' } ]
|
|
productType: [ { required: true, message: '请选择产品分类', trigger: 'change' } ]
|
|
},
|
|
},
|
|
|
|
+ chooseData: [], // 已选产品
|
|
disabled: false, // 查询、重置按钮是否可操作
|
|
disabled: false, // 查询、重置按钮是否可操作
|
|
loading: false, // 表格加载中
|
|
loading: false, // 表格加载中
|
|
columns: [
|
|
columns: [
|
|
@@ -170,15 +169,8 @@ export default {
|
|
loadData: parameter => {
|
|
loadData: parameter => {
|
|
this.disabled = true
|
|
this.disabled = true
|
|
this.spinning = true
|
|
this.spinning = true
|
|
- let url = productPricedList // 获取定过价的产品
|
|
|
|
- if (this.type == 'supplier') { // 供应商增加产品
|
|
|
|
- url = productPricingList // 获取定价产品
|
|
|
|
- }
|
|
|
|
const params = Object.assign(parameter, this.queryParam)
|
|
const params = Object.assign(parameter, this.queryParam)
|
|
- if (this.type != 'supplier' && this.type != 'dealership') { // 促销
|
|
|
|
- params.onlineFalg = 1
|
|
|
|
- }
|
|
|
|
- return url(params).then(res => {
|
|
|
|
|
|
+ return productPricingList(params).then(res => {
|
|
let data
|
|
let data
|
|
if (res.status == 200) {
|
|
if (res.status == 200) {
|
|
data = res.data
|
|
data = res.data
|
|
@@ -202,49 +194,26 @@ export default {
|
|
rowSelectionFun (obj) {
|
|
rowSelectionFun (obj) {
|
|
this.rowSelectionInfo = obj || null
|
|
this.rowSelectionInfo = obj || null
|
|
},
|
|
},
|
|
|
|
+ // 查询所有已选sn
|
|
|
|
+ getChoosed () {
|
|
|
|
+ this.spinning = true
|
|
|
|
+ supplierProductSnList({ sn: this.supplierSn }).then(res => {
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ this.chooseData = res.data // 包含先前所选产品
|
|
|
|
+ this.handleSearch()
|
|
|
|
+ }
|
|
|
|
+ this.spinning = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 查询
|
|
// 查询
|
|
handleSearch () {
|
|
handleSearch () {
|
|
const _this = this
|
|
const _this = this
|
|
_this.$refs.ruleForm.validate(valid => {
|
|
_this.$refs.ruleForm.validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- if (_this.type == 'dealership') { // 设置经销权时选择产品
|
|
|
|
- // 校验产品是否被包含在品牌分类中
|
|
|
|
- const params = []
|
|
|
|
- if (_this.queryParam.productBrandSn) {
|
|
|
|
- params.push({
|
|
|
|
- dealerSn: _this.dealerSn,
|
|
|
|
- goodsType: 'BRAND',
|
|
|
|
- goodsSn: _this.queryParam.productBrandSn
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (_this.queryParam.productTypeSn1) {
|
|
|
|
- params.push({
|
|
|
|
- dealerSn: _this.dealerSn,
|
|
|
|
- goodsType: 'CATEGORY',
|
|
|
|
- goodsSn: _this.queryParam.productTypeSn1
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (_this.queryParam.productTypeSn2) {
|
|
|
|
- params.push({
|
|
|
|
- dealerSn: _this.dealerSn,
|
|
|
|
- goodsType: 'CATEGORY',
|
|
|
|
- goodsSn: _this.queryParam.productTypeSn2
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (_this.queryParam.productTypeSn3) {
|
|
|
|
- params.push({
|
|
|
|
- dealerSn: _this.dealerSn,
|
|
|
|
- goodsType: 'CATEGORY',
|
|
|
|
- goodsSn: _this.queryParam.productTypeSn3
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- dealerScopeValidProduct(params).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- _this.$refs.table.refresh(true)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (this.supplierSn) {
|
|
_this.$refs.table.refresh(true)
|
|
_this.$refs.table.refresh(true)
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.warning('请先选择供应商!')
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return false
|
|
return false
|
|
@@ -268,22 +237,39 @@ export default {
|
|
// 保存
|
|
// 保存
|
|
handleSave () {
|
|
handleSave () {
|
|
const _this = this
|
|
const _this = this
|
|
|
|
+ if (!this.supplierSn) {
|
|
|
|
+ this.$message.warning('请先选择供应商!')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
|
|
if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
|
|
- this.$message.warning('请在列表勾选后再进行操作!')
|
|
|
|
|
|
+ this.$message.warning('请选择产品!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if (this.type == 'supplier') { // 供应商增加产品
|
|
|
|
- const arr = []
|
|
|
|
- this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.map(item => {
|
|
|
|
- if (_this.chooseData.indexOf(item) == -1) {
|
|
|
|
- arr.push(item)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- this.$emit('ok', arr)
|
|
|
|
|
|
+ const arr = []
|
|
|
|
+ this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.map(item => {
|
|
|
|
+ if (_this.chooseData.indexOf(item) == -1) {
|
|
|
|
+ arr.push(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (arr.length) {
|
|
|
|
+ this.addProduct(arr)
|
|
} else {
|
|
} else {
|
|
- this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
|
|
|
|
|
|
+ this.$message.warning('请选择产品!')
|
|
}
|
|
}
|
|
- this.isShow = false
|
|
|
|
|
|
+ },
|
|
|
|
+ // 添加产品 数据处理
|
|
|
|
+ addProduct (arr) {
|
|
|
|
+ this.spinning = true
|
|
|
|
+ addProduct({
|
|
|
|
+ supplierSn: this.supplierSn,
|
|
|
|
+ productSnList: arr
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ this.$emit('ok')
|
|
|
|
+ this.isShow = false
|
|
|
|
+ }
|
|
|
|
+ this.spinning = false
|
|
|
|
+ })
|
|
},
|
|
},
|
|
// 产品分类 change
|
|
// 产品分类 change
|
|
changeProductType (val, opt) {
|
|
changeProductType (val, opt) {
|
|
@@ -308,23 +294,13 @@ export default {
|
|
},
|
|
},
|
|
// 产品分类 列表
|
|
// 产品分类 列表
|
|
getProductType () {
|
|
getProductType () {
|
|
- if (this.type != 'supplier' && this.type != 'dealership') { // 促销
|
|
|
|
- productTypeQueryAll({}).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- this.productTypeList = res.data
|
|
|
|
- } else {
|
|
|
|
- this.productTypeList = []
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- productTypeQuery({}).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- this.productTypeList = res.data
|
|
|
|
- } else {
|
|
|
|
- this.productTypeList = []
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ productTypeQuery({}).then(res => {
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ this.productTypeList = res.data
|
|
|
|
+ } else {
|
|
|
|
+ this.productTypeList = []
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
@@ -337,24 +313,10 @@ export default {
|
|
if (!newValue) {
|
|
if (!newValue) {
|
|
this.$emit('close')
|
|
this.$emit('close')
|
|
this.$refs.table.clearTable()
|
|
this.$refs.table.clearTable()
|
|
|
|
+ this.chooseData = []
|
|
|
|
+ this.supplierSn = undefined
|
|
this.resetData()
|
|
this.resetData()
|
|
} else {
|
|
} else {
|
|
- const _this = this
|
|
|
|
- let selectedRows = []
|
|
|
|
- let selectedRowKeys = []
|
|
|
|
- if (this.type == 'supplier') { // 供应商增加产品
|
|
|
|
- selectedRows = []
|
|
|
|
- selectedRowKeys = this.chooseData
|
|
|
|
- } else {
|
|
|
|
- selectedRows = this.chooseData
|
|
|
|
- selectedRowKeys = []
|
|
|
|
- this.chooseData.map(item => {
|
|
|
|
- selectedRowKeys.push(item.goodsSn)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
|
- _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
|
|
|
|
- })
|
|
|
|
if (this.productBrandList.length == 0) {
|
|
if (this.productBrandList.length == 0) {
|
|
this.getProductBrand()
|
|
this.getProductBrand()
|
|
}
|
|
}
|