123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <template>
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="8" :sm="24" v-if="pageType=='dealerPromotion'">
- <a-form-model-item label="地区">
- <AreaList id="viewDealers-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
- </a-form-model-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-item label="经销商名称/别名">
- <a-input id="chooseDealer-nameLike" v-model.trim="queryParam.nameLike" allowClear placeholder="请输入经销商名称/别名"/>
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-item label="商户类型">
- <dealerType id="chooseDealer-dealerType" changeOnSelect v-model="dealerType" @change="getDealerType" allowClear></dealertype>
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-model-item label="商户级别" prop="dealerLevel">
- <v-select code="DEALER_LEVEL" id="ucModal-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择商户级别"></v-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="8" :sm="24" v-if="pageType!='viewDealers'">
- <a-form-item label="所在区域/分区">
- <subarea id="chooseDealer-subarea" ref="subarea" @change="subareaChange"></subarea>
- </a-form-item>
- </a-col>
- <div v-else>
- <a-col :md="8" :sm="24">
- <a-form-item label="审核状态">
- <v-select code="AUDIT_STATE" id="viewDealers-auditState" v-model="queryParam.auditState" allowClear placeholder="请选择审核状态"></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-model-item label="地区">
- <AreaList id="viewDealers-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
- </a-form-model-item>
- </a-col>
- </div>
- <a-col :md="pageType!='viewDealers'?8:6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="searchForm(true)" :disabled="disabled" id="chooseDealer-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chooseDealer-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- <!-- 列表 -->
- <div style="margin-bottom: 10px">
- <a-button id="chooseDealer-batchAdd" type="primary" ghost :loading="loading" @click="handleBatchAudit">批量添加</a-button>
- <span style="margin-left: 5px">
- <template v-if="selectCount"> {{ `已选 ${selectCount} 项` }} </template>
- </span>
- </div>
- </div>
- <a-table
- style="height: 320px;"
- :scroll="{ y: 230 }"
- :bordered="true"
- :pagination="pagination"
- :row-key="record => record.dealerSn"
- :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
- :columns="columns"
- :data-source="dealerList"
- @change="handlePage"
- >
- <template slot="addressInfo" slot-scope="text, record">
- {{ record.provinceName }}{{ '-'+ record.cityName }}{{ '-'+ record.districtName }}
- </template>
- </a-table>
- </a-spin>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import AreaList from '@/views/common/areaList.js'
- import subarea from '@/views/common/subarea.js'
- import dealerType from '@/views/common/dealerType.js'
- import { dealerQueryList, getDealerListInfo } from '@/api/dealer'
- export default {
- name: 'ChooseDealer',
- mixins: [commonMixin],
- components: { STable, VSelect, subarea, AreaList, dealerType },
- props: {
- pageType: { // 添加or编辑
- type: String,
- default: ''
- },
- itemSn: { // 单据sn
- type: String,
- default: ''
- }
- },
- data () {
- return {
- spinning: false,
- dealerType: [], // 商户类型默认值
- queryParam: { // 查询条件
- nameLike: '', // 商户名称
- dealerType1: undefined, // 商户类型1
- dealerType2: undefined, // 商户类型2
- dealerLevel: null, // 商户等级
- subareaArea: {
- subareaSn: undefined, // 区域
- subareaAreaSn: undefined // 分区
- },
- auditState: undefined, // 审核状态
- provinceSn: undefined, // 省
- citySn: undefined, // 市
- districtSn: undefined // 区
- },
- pagination: {
- pageSize: 20, // 每页数
- showSizeChanger: true, // 是否显示页码输入框
- pageSizeOptions: ['20', '50', '100', '200', '500'] // 可选页码
- },
- pageFlag: false, // 经销商加载完成是否
- chooseInfo: [], // 已选商户
- selectedRowKeys: [], // 已选商户key
- dealerList: [], // 商户列表
- tableHeight: 0, // 表格高度
- disabled: false, // 查询、重置按钮是否可操作
- loading: false // 批量添加loading
- }
- },
- computed: {
- // 已选商户数量
- selectCount () {
- return this.selectedRowKeys && this.selectedRowKeys.length
- },
- // 列
- columns () {
- const arr = [
- { title: '经销商名称', dataIndex: 'dealerName', width: '25%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '商户别名', dataIndex: 'dealerAlias', align: 'left', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '商户类型', dataIndex: 'dealerTypeName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '所在区域', dataIndex: 'subareaArea.subareaName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '所在分区', dataIndex: 'subareaArea.subareaAreaName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }
- ]
- // 如果时经销商促销活动
- if (this.pageType === 'dealerPromotion') {
- arr.unshift({ title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '30%', align: 'center', ellipsis: true })
- }
- return arr
- }
- },
- methods: {
- // 全选
- onSelectChange (selectedRowKeys) {
- this.selectedRowKeys = selectedRowKeys
- },
- // 表格页码变化
- handlePage (pagination, filters, sorter) {
- const pager = { ...this.pagination }
- pager.pageNo = pagination.pageSize != pager.pageSize ? 1 : pagination.current
- pager.pageSize = pagination.pageSize
- pager.current = pager.pageNo
- this.pagination = pager
- this.loadData()
- },
- // 查询列表
- loadData () {
- this.spinning = true
- const params = { pageSize: 20, pageNo: 1, ...this.pagination }
- this.queryParam.notDealerSn = this.itemSn ? this.itemSn : undefined
- dealerQueryList(Object.assign(params, this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const pagination = { ...this.pagination }
- pagination.total = data.count
- const no = 0
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- if (data.list[i].dealerTypeName1) {
- data.list[i].dealerTypeName = data.list[i].dealerTypeName1 + '>' + data.list[i].dealerTypeName2
- }
- }
- this.dealerList = data.list
- this.pagination = pagination
- // 是否已选
- if (this.chooseInfo.length > 0 && !this.pageFlag) {
- this.pageFlag = true
- this.selectedRowKeys = this.chooseInfo
- }
- }
- this.spinning = false
- })
- },
- // 表格选中项
- rowSelectionFun (obj) {
- this.rowSelectionInfo = obj || null
- },
- // 地区选择
- areaChange (val) {
- this.queryParam.provinceSn = val[0] ? val[0] : ''
- this.queryParam.citySn = val[1] ? val[1] : ''
- this.queryParam.districtSn = val[2] ? val[2] : ''
- },
- // 查询
- searchForm () {
- this.loadData()
- this.spinning = false
- },
- // 分区选择
- subareaChange (val) {
- this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
- this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
- },
- // 商户类型选项
- getDealerType (v, o) {
- this.queryParam.dealerType1 = v[0]
- this.queryParam.dealerType2 = v[1]
- },
- // 重置列表
- resetSearchForm () {
- this.dealerType = []
- this.queryParam = {
- nameLike: '',
- dealerType1: undefined, // 商户类型
- dealerType2: undefined, // 商户类型
- dealerLevel: null,
- subareaArea: {
- subareaSn: undefined, // 区域
- subareaAreaSn: undefined // 分区
- },
- auditState: undefined,
- provinceSn: undefined,
- citySn: undefined,
- districtSn: undefined
- }
- if (this.pageType != 'viewDealers') {
- this.$refs.subarea.clearData()
- if (this.pageType == 'dealerPromotion') {
- this.$refs.areaList.clearData()
- }
- } else {
- this.$refs.areaList.clearData()
- }
- this.pagination.pageNo = 1
- this.pagination.current = 1
- this.loadData()
- this.pageFlag = false
- },
- // 批量添加
- async handleBatchAudit () {
- const _this = this
- if (_this.selectedRowKeys && _this.selectedRowKeys.length < 1) {
- _this.$message.warning('请在列表勾选后再进行批量操作!')
- return
- }
- const dealerInfoList = await getDealerListInfo({ dealerSnList: _this.selectedRowKeys })
- this.spinning = false
- this.$emit('plAdd', dealerInfoList.data)
- },
- // 绑定关系
- handleAdd (row) {
- if (row.subareaArea) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '当前经销商已被其他区域分区绑定,确定要更新绑定关系吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- _this.$emit('add', row)
- }
- })
- } else {
- this.spinning = true
- this.$emit('add', row)
- }
- },
- // 页面初始化
- pageInit (data) {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- this.selectedRowKeys = []
- this.chooseInfo = data || []
- this.resetSearchForm()
- },
- // 设置表格高度
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 285
- }
- },
- watch: {
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- }
- }
- </script>
|