|
@@ -8,109 +8,95 @@
|
|
|
v-model="isShow"
|
|
|
@cancle="isShow=false"
|
|
|
:width="900">
|
|
|
- <div class="products-con">
|
|
|
- <div>
|
|
|
- <!-- 搜索条件 -->
|
|
|
- <div class="table-page-search-wrapper">
|
|
|
- <a-form-model
|
|
|
- ref="ruleForm"
|
|
|
- class="form-model-con"
|
|
|
- layout="inline"
|
|
|
- :model="queryParam"
|
|
|
- :rules="rules"
|
|
|
- @keyup.enter.native="getProductList(1)"
|
|
|
- :label-col="formItemLayout.labelCol"
|
|
|
- :wrapper-col="formItemLayout.wrapperCol">
|
|
|
- <a-row :gutter="15">
|
|
|
- <a-col :md="6" :sm="24">
|
|
|
- <a-form-model-item label="产品编码" prop="code">
|
|
|
- <a-input id="chooseProducts-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- <a-col :md="6" :sm="24">
|
|
|
- <a-form-model-item label="产品品牌" :prop="type=='dealership'?'productBrandSn':''">
|
|
|
- <a-select
|
|
|
- placeholder="请选择产品品牌"
|
|
|
- id="chooseProducts-productBrandSn"
|
|
|
- allowClear
|
|
|
- v-model="queryParam.productBrandSn"
|
|
|
- :showSearch="true"
|
|
|
- option-filter-prop="children"
|
|
|
- :filter-option="filterOption">
|
|
|
- <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- <a-col :md="6" :sm="24">
|
|
|
- <a-form-model-item label="产品分类" :prop="type=='dealership'?'productType':''">
|
|
|
- <a-cascader
|
|
|
- @change="changeProductType"
|
|
|
- change-on-select
|
|
|
- v-model="queryParam.productType"
|
|
|
- expand-trigger="hover"
|
|
|
- :options="productTypeList"
|
|
|
- :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
|
|
|
- id="chooseProducts-productType"
|
|
|
- placeholder="请选择产品分类"
|
|
|
- allowClear />
|
|
|
- </a-form-model-item>
|
|
|
- </a-col>
|
|
|
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
|
|
|
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chooseProducts-refresh">查询</a-button>
|
|
|
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chooseProducts-reset">重置</a-button>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- </a-form-model></a-form>
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <div class="products-con">
|
|
|
+ <div>
|
|
|
+ <!-- 搜索条件 -->
|
|
|
+ <div class="table-page-search-wrapper">
|
|
|
+ <a-form-model
|
|
|
+ ref="ruleForm"
|
|
|
+ class="form-model-con"
|
|
|
+ layout="inline"
|
|
|
+ :model="queryParam"
|
|
|
+ :rules="rules"
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ :label-col="formItemLayout.labelCol"
|
|
|
+ :wrapper-col="formItemLayout.wrapperCol">
|
|
|
+ <a-row :gutter="15">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品编码" prop="code">
|
|
|
+ <a-input id="chooseProducts-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品品牌" :prop="type=='dealership'?'productBrandSn':''">
|
|
|
+ <a-select
|
|
|
+ placeholder="请选择产品品牌"
|
|
|
+ id="chooseProducts-productBrandSn"
|
|
|
+ allowClear
|
|
|
+ v-model="queryParam.productBrandSn"
|
|
|
+ :showSearch="true"
|
|
|
+ option-filter-prop="children"
|
|
|
+ :filter-option="filterOption">
|
|
|
+ <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品分类" :prop="type=='dealership'?'productType':''">
|
|
|
+ <a-cascader
|
|
|
+ @change="changeProductType"
|
|
|
+ change-on-select
|
|
|
+ v-model="queryParam.productType"
|
|
|
+ expand-trigger="hover"
|
|
|
+ :options="productTypeList"
|
|
|
+ :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
|
|
|
+ id="chooseProducts-productType"
|
|
|
+ placeholder="请选择产品分类"
|
|
|
+ allowClear />
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
|
|
|
+ <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chooseProducts-refresh">查询</a-button>
|
|
|
+ <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chooseProducts-reset">重置</a-button>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form-model></a-form>
|
|
|
+ </div>
|
|
|
+ <p style="font-weight: bold;">当前已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length }}个</p>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <s-table
|
|
|
+ class="sTable"
|
|
|
+ ref="table"
|
|
|
+ size="small"
|
|
|
+ :rowKey="(record) => record.productSn"
|
|
|
+ rowKeyName="productSn"
|
|
|
+ :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: (this.type == 'supplier') && (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.indexOf(record.productSn) > -1) }}) }"
|
|
|
+ @rowSelection="rowSelectionFun"
|
|
|
+ :columns="columns"
|
|
|
+ :data="loadData"
|
|
|
+ :defaultLoadData="false"
|
|
|
+ bordered>
|
|
|
+ </s-table>
|
|
|
+ </div>
|
|
|
+ <!-- 按钮 -->
|
|
|
+ <div class="btn-con">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ id="chooseProducts-save"
|
|
|
+ size="large"
|
|
|
+ class="button-primary"
|
|
|
+ @click="handleSave"
|
|
|
+ style="padding: 0 60px;">保存</a-button>
|
|
|
+ <a-button
|
|
|
+ id="chooseProducts-cancel"
|
|
|
+ size="large"
|
|
|
+ class="button-cancel"
|
|
|
+ @click="isShow=false"
|
|
|
+ style="padding: 0 60px;margin-left: 15px;">取消</a-button>
|
|
|
</div>
|
|
|
- <p style="font-weight: bold;">当前已选:{{ selectedRowKeys.length }}个</p>
|
|
|
- <!-- 列表 -->
|
|
|
- <a-table
|
|
|
- class="sTable"
|
|
|
- ref="table"
|
|
|
- size="small"
|
|
|
- :rowKey="(record) => record.productSn"
|
|
|
- :row-selection="{
|
|
|
- selectedRowKeys: selectedRowKeys,
|
|
|
- onChange: onChange,
|
|
|
- onSelect: onSelectChange,
|
|
|
- onSelectAll: onSelectAllChange,
|
|
|
- getCheckboxProps:record =>({props: {
|
|
|
- disabled: (this.type == 'supplier') && (this.selectedRowKeys.indexOf(record.productSn) > -1)
|
|
|
- }})
|
|
|
- }"
|
|
|
- :data-source="loadData"
|
|
|
- :columns="columns"
|
|
|
- :pagination="false"
|
|
|
- :loading="loading"
|
|
|
- :scroll="{ y: 450 }"
|
|
|
- bordered>
|
|
|
- </a-table>
|
|
|
- <!-- 分页 -->
|
|
|
- <tablePagination
|
|
|
- ref="tablePagination"
|
|
|
- :total="paginationProps.total"
|
|
|
- :current="paginationProps.current"
|
|
|
- :pageSize="paginationProps.pageSize"
|
|
|
- @changePageSize="changePageSize"
|
|
|
- @changePage="changePage" />
|
|
|
- </div>
|
|
|
- <!-- 按钮 -->
|
|
|
- <div class="btn-con">
|
|
|
- <a-button
|
|
|
- type="primary"
|
|
|
- id="chooseProducts-save"
|
|
|
- size="large"
|
|
|
- class="button-primary"
|
|
|
- @click="handleSave"
|
|
|
- style="padding: 0 60px;">保存</a-button>
|
|
|
- <a-button
|
|
|
- id="chooseProducts-cancel"
|
|
|
- size="large"
|
|
|
- class="button-cancel"
|
|
|
- @click="isShow=false"
|
|
|
- style="padding: 0 60px;margin-left: 15px;">取消</a-button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </a-spin>
|
|
|
</a-modal>
|
|
|
</template>
|
|
|
|
|
@@ -146,6 +132,7 @@ export default {
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
+ spinning: false,
|
|
|
isShow: this.openModal, // 是否打开弹框
|
|
|
formItemLayout: {
|
|
|
labelCol: { span: 4 },
|
|
@@ -170,19 +157,42 @@ export default {
|
|
|
{ title: '产品编码', dataIndex: 'code', align: 'center' },
|
|
|
{ title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } }
|
|
|
],
|
|
|
- loadData: [],
|
|
|
- paginationProps: {
|
|
|
- total: 0, // 分页总条数
|
|
|
- current: 1,
|
|
|
- pageSize: 20
|
|
|
+ // 加载数据方法 必须为 Promise 对象
|
|
|
+ loadData: parameter => {
|
|
|
+ this.disabled = true
|
|
|
+ this.spinning = true
|
|
|
+ let url = productPricedList // 获取定过价的产品
|
|
|
+ if (this.type == 'supplier') { // 供应商增加产品
|
|
|
+ url = productPricingList // 获取定价产品
|
|
|
+ }
|
|
|
+ const params = Object.assign(parameter, this.queryParam)
|
|
|
+ if (this.type != 'supplier' && this.type != 'dealership') { // 促销
|
|
|
+ params.onlineFalg = 1
|
|
|
+ }
|
|
|
+ return url(params).then(res => {
|
|
|
+ let data
|
|
|
+ if (res.status == 200) {
|
|
|
+ data = res.data
|
|
|
+ const no = (data.pageNo - 1) * data.pageSize
|
|
|
+ for (var i = 0; i < data.list.length; i++) {
|
|
|
+ data.list[i].no = no + i + 1
|
|
|
+ }
|
|
|
+ this.disabled = false
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ return data
|
|
|
+ })
|
|
|
},
|
|
|
productBrandList: [], // 品牌下拉数据
|
|
|
productTypeList: [], // 分类下拉数据
|
|
|
- selectedRowKeys: [],
|
|
|
- selectedRows: []
|
|
|
+ rowSelectionInfo: null
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 表格选中项
|
|
|
+ rowSelectionFun (obj) {
|
|
|
+ this.rowSelectionInfo = obj || null
|
|
|
+ },
|
|
|
// 查询
|
|
|
handleSearch () {
|
|
|
const _this = this
|
|
@@ -221,11 +231,11 @@ export default {
|
|
|
}
|
|
|
dealerScopeValidProduct(params).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
- _this.getProductList(1)
|
|
|
+ _this.$refs.table.refresh(true)
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- _this.getProductList(1)
|
|
|
+ _this.$refs.table.refresh(true)
|
|
|
}
|
|
|
} else {
|
|
|
return false
|
|
@@ -240,116 +250,32 @@ export default {
|
|
|
this.queryParam.productTypeSn2 = ''
|
|
|
this.queryParam.productTypeSn3 = ''
|
|
|
this.queryParam.productType = []
|
|
|
- this.paginationProps.total = 0
|
|
|
- this.paginationProps.current = 1
|
|
|
- this.paginationProps.pageSize = 20
|
|
|
},
|
|
|
// 重置
|
|
|
resetSearchForm () {
|
|
|
this.resetData()
|
|
|
- this.loadData = []
|
|
|
- this.disabled = false
|
|
|
+ this.$refs.table.clearTable()
|
|
|
},
|
|
|
// 保存
|
|
|
handleSave () {
|
|
|
const _this = this
|
|
|
- if (this.selectedRowKeys.length < 1) {
|
|
|
+ if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
|
|
|
this.$message.warning('请在列表勾选后再进行操作!')
|
|
|
return
|
|
|
}
|
|
|
if (this.type == 'supplier') { // 供应商增加产品
|
|
|
const arr = []
|
|
|
- this.selectedRowKeys.map(item => {
|
|
|
+ this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.map(item => {
|
|
|
if (_this.chooseData.indexOf(item) == -1) {
|
|
|
arr.push(item)
|
|
|
}
|
|
|
})
|
|
|
this.$emit('ok', arr)
|
|
|
} else {
|
|
|
- this.$emit('ok', this.selectedRows)
|
|
|
+ this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
|
|
|
}
|
|
|
this.isShow = false
|
|
|
},
|
|
|
- onChange (selectedRowKeys, selectedRows) {
|
|
|
- this.selectedRowKeys = selectedRowKeys
|
|
|
- },
|
|
|
- onSelectChange (record, selected, selectedRows, nativeEvent) {
|
|
|
- if (this.type != 'supplier') { // 供应商增加产品
|
|
|
- if (selected) { // 选择
|
|
|
- this.selectedRows.push(record)
|
|
|
- } else { // 取消
|
|
|
- this.selectedRows = selectedRows
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 本页全选/取消全选
|
|
|
- onSelectAllChange (selected, selectedRows, changeRows) {
|
|
|
- const _this = this
|
|
|
- if (this.type != 'supplier') { // 供应商增加产品
|
|
|
- if (selected) { // 选择
|
|
|
- this.selectedRows = [...this.selectedRows, ...changeRows]
|
|
|
- } else { // 取消
|
|
|
- const arrId = []
|
|
|
- this.selectedRows.map((item, index) => {
|
|
|
- this.selectedRows.map((subItem, ind) => {
|
|
|
- if (item.productSn == subItem.productSn) {
|
|
|
- arrId.push(index)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- arrId.map((item, index) => {
|
|
|
- _this.selectedRows = _this.selectedRows.slice(item, item + 1)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 产品列表
|
|
|
- getProductList (pageNo) {
|
|
|
- this.paginationProps.current = pageNo || this.paginationProps.current
|
|
|
- this.disabled = true
|
|
|
- const params = {
|
|
|
- pageNo: this.paginationProps.current,
|
|
|
- pageSize: this.paginationProps.pageSize
|
|
|
- }
|
|
|
- this.loading = true
|
|
|
- let url = productPricedList // 获取定过价的产品
|
|
|
- if (this.type == 'supplier') { // 供应商增加产品
|
|
|
- url = productPricingList // 获取定价产品
|
|
|
- }
|
|
|
- if (this.type != 'supplier' && this.type != 'dealership') { // 促销
|
|
|
- params.onlineFalg = 1
|
|
|
- }
|
|
|
- url(Object.assign(params, this.queryParam)).then(res => {
|
|
|
- this.loading = false
|
|
|
- if (res.status == 200) {
|
|
|
- const data = res.data
|
|
|
- this.paginationProps.total = Number(res.data.count) || 0
|
|
|
- this.paginationProps.current = data.pageNo
|
|
|
- const no = (data.pageNo - 1) * data.pageSize
|
|
|
- for (var i = 0; i < data.list.length; i++) {
|
|
|
- data.list[i].no = no + i + 1
|
|
|
- }
|
|
|
- this.loadData = data.list
|
|
|
- this.disabled = false
|
|
|
- } else {
|
|
|
- this.paginationProps.total = 0
|
|
|
- this.paginationProps.current = 1
|
|
|
- this.paginationProps.pageSize = 20
|
|
|
- this.loadData = []
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 已选产品 分页 一页多少条change
|
|
|
- changePageSize (current, pageSize) {
|
|
|
- this.paginationProps.current = current
|
|
|
- this.paginationProps.pageSize = pageSize
|
|
|
- this.getProductList()
|
|
|
- },
|
|
|
- // 已选产品 分页 页码change
|
|
|
- changePage (current) {
|
|
|
- this.paginationProps.current = current
|
|
|
- this.getProductList()
|
|
|
- },
|
|
|
// 产品分类 change
|
|
|
changeProductType (val, opt) {
|
|
|
this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
|
|
@@ -401,20 +327,25 @@ export default {
|
|
|
isShow (newValue, oldValue) {
|
|
|
if (!newValue) {
|
|
|
this.$emit('close')
|
|
|
- this.loadData = []
|
|
|
- this.disabled = false
|
|
|
+ this.$refs.table.clearTable()
|
|
|
this.resetData()
|
|
|
} else {
|
|
|
+ const _this = this
|
|
|
+ let selectedRows = []
|
|
|
+ let selectedRowKeys = []
|
|
|
if (this.type == 'supplier') { // 供应商增加产品
|
|
|
- this.selectedRows = []
|
|
|
- this.selectedRowKeys = this.chooseData
|
|
|
+ selectedRows = []
|
|
|
+ selectedRowKeys = this.chooseData
|
|
|
} else {
|
|
|
- this.selectedRows = this.chooseData
|
|
|
- this.selectedRowKeys = []
|
|
|
+ selectedRows = this.chooseData
|
|
|
+ selectedRowKeys = []
|
|
|
this.chooseData.map(item => {
|
|
|
- this.selectedRowKeys.push(item.goodsSn)
|
|
|
+ selectedRowKeys.push(item.goodsSn)
|
|
|
})
|
|
|
}
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
|
|
|
+ })
|
|
|
if (this.productBrandList.length == 0) {
|
|
|
this.getProductBrand()
|
|
|
}
|