123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <div>
- <a-card size="small" :bordered="false">
- <!-- 搜索条件 -->
- <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="6" :sm="24">
- <a-form-model-item label="人员类型">
- <subarea id="businessOwnerSettings-subareaSn" ref="subarea" @change="subareaChange"></subarea>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="人员姓名">
- <a-input id="businessOwnerSettings-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入人员姓名"/>
- </a-form-item>
- </a-col>
- <a-col :md="24" :sm="24" style="margin-top: 10px;text-align:center;">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="businessOwnerSettings-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="businessOwnerSettings-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </a-card>
- <a-card size="small" :bordered="false" class="dealerZoneSearch-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <div class="table-operator">
- <a-button id="businessOwnerSettings-add" type="primary" class="button-error" @click="handleAdd">+新增</a-button>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :showPagination="false"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="link" class="button-warning" @click="handleSetCategory(record)">设置管辖范围</a-button>
- <a-button size="small" type="link" class="button-info" @click="handleEdit(record)">编辑</a-button>
- <a-button size="small" type="link" class="button-error" @click="handleDelete(record)">删除</a-button>
- </template>
- </s-table>
- </a-spin>
- </a-card>
- <!-- 新增 -->
- <addModal :openModal="openAddModal" @close="openAddModal = false"></addModal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import { subareaQueryIncludeAreaAll, subareaDeleteBySn } from '@/api/subarea'
- import subarea from '@/views/common/subarea.js'
- import addModal from './addModal'
- export default {
- name: 'BusinessOwnerSettings',
- mixins: [commonMixin],
- components: { STable, VSelect, subarea, addModal },
- data () {
- return {
- spinning: false,
- disabled: false, // 查询、重置按钮是否可操作
- tableHeight: 0,
- queryParam: {
- subareaSn: undefined,
- subareaAreaSn: undefined,
- dealerName: ''
- },
- columns: [
- { title: '创建时间', dataIndex: 'subareaName', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '人员姓名', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '人员类型', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '管辖经销商', dataIndex: 'subareaName', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '管辖品类', dataIndex: 'subareaName', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return subareaQueryIncludeAreaAll(Object.assign(parameter,this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = 0
- for (var i = 0; i < data.length; i++) {
- data[i].no = no + i + 1
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- openAddModal: false, // 编辑 弹框
- nowData: null,
- itemId: null // 当前产品id
- }
- },
- methods: {
- handleSetCategory (row) {
- this.$router.push({ name: 'categorySet', query: { sn: row.sn } })
- },
- // 新增
- handleAdd () {
- this.openAddModal = true
- },
- subareaChange(val){
- this.queryParam.subareaSn = val[0] ? val[0] : undefined
- this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
- },
- // 重置
- resetSearchForm () {
- this.queryParam = {
- subareaSn: undefined,
- subareaAreaSn: undefined,
- dealerName: ''
- }
- this.$refs.subarea.clearData()
- this.$refs.table.refresh(true)
- },
- // 删除
- handleDelete (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确定要删除吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- subareaDeleteBySn({ sn: row.subareaSn }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 编辑
- handleEdit (row) {
- this.itemId = row && row.subareaSn ? row.subareaSn : null
- this.nowData = row
- this.openModal = true
- },
- // 关闭弹框
- closeModal () {
- this.itemId = null
- this.nowData = null
- this.openModal = false
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 275
- }
- },
- watch: {
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .dealerZoneSearch-wrap{
- height: 100%;
- margin-top:6px;
- .table-operator{
- text-align:right;
- }
- }
- </style>
|