| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <template>
- <el-dialog append-to-body :title="title" :visible.sync="innerVisible" @close="close">
- <el-row>
- <el-col :span="24">
- <el-input
- v-model="queryForm.keyword"
- clearable
- placeholder="客户名称/手机/电话"
- style="width: 30%; margin-right: 10px"
- suffix-icon="el-icon-search"
- @keyup.enter.native="fetchData" />
- <el-button icon="el-icon-search" type="primary" @click="fetchData">查询</el-button>
- <table-tool
- :columns="columns"
- :show-columns.sync="showColumns"
- style="float: right"
- table-type="selectBusinessContactTable" />
- </el-col>
- </el-row>
- <el-table ref="contactTable" v-loading="listLoading" :data="list" @selection-change="setSelectRows">
- <el-table-column align="center" type="selection" />
- <el-table-column
- v-for="(item, index) in showColumns"
- :key="index + Math.random()"
- align="center"
- :label="item.label"
- :prop="item.prop"
- show-overflow-tooltip
- :sortable="item.sortable"
- :width="item.width">
- <template #default="{ row }">
- <span v-if="item.prop === 'isDecision'">
- {{ selectDictLabel(yesNoOptions, row.isDecision) }}
- </span>
- <span v-else-if="item.prop === 'cuctGender'">
- {{ selectDictLabel(sexOptions, row.cuctGender) }}
- </span>
- <span v-else>{{ row[item.prop] }}</span>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- background
- :current-page="queryForm.pageNum"
- :layout="layout"
- :page-size="queryForm.pageSize"
- :total="total"
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange" />
- <span slot="footer">
- <el-button size="mini" type="primary" @click="save">保存</el-button>
- <el-button size="mini" @click="innerVisible = false">取消</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import businessContactApi from '@/api/proj/businessContact'
- import TableTool from '@/components/table/TableTool'
- export default {
- name: 'SelectContact',
- components: {
- TableTool,
- },
- props: {
- title: {
- type: String,
- default: '选择客户联系人',
- },
- addButton: Boolean,
- multiple: Boolean,
- // 示例{ custId: custId, custName: custName}
- defaultCustomer: {
- type: Object,
- default() {
- return {}
- },
- },
- // 示例{ busId: busId, custId: custId}
- queryParams: {
- type: Object,
- default() {
- return {}
- },
- },
- },
- data() {
- return {
- innerVisible: false,
- queryForm: {
- keyword: '',
- pageNum: 1,
- pageSize: 10,
- },
- showColumns: [],
- columns: [
- {
- label: '联系人姓名',
- width: 'auto',
- prop: 'cuctName',
- // sortable: true,
- disableCheck: true,
- },
- {
- label: '客户名称',
- width: 'auto',
- prop: 'custName',
- },
- {
- label: '手机号码',
- width: 'auto',
- prop: 'telephone',
- },
- {
- label: '微信',
- width: 'auto',
- prop: 'wechat',
- },
- {
- label: '邮箱',
- width: 'auto',
- prop: 'email',
- },
- {
- label: '职务',
- width: 'auto',
- prop: 'postion',
- },
- {
- label: '关键决策人',
- width: 'auto',
- prop: 'isDecision',
- },
- {
- label: '性别',
- width: 'auto',
- prop: 'cuctGender',
- // sortable: true,
- },
- ],
- list: [],
- listLoading: true,
- layout: 'total, sizes, prev, pager, next, jumper',
- total: 0,
- selectRows: [],
- sexOptions: [],
- yesNoOptions: [],
- }
- },
- mounted() {
- this.getDicts('sys_sex').then((response) => {
- this.sexOptions = response.data.values || []
- })
- this.getDicts('sys_yes_no').then((response) => {
- this.yesNoOptions = response.data.values || []
- })
- },
- methods: {
- open() {
- this.innerVisible = true
- this.fetchData()
- },
- close() {
- this.selectRows = []
- this.queryForm = this.$options.data().queryForm
- this.$refs.contactTable.clearSelection()
- },
- save() {
- this.innerVisible = false
- this.$emit('save', this.selectRows)
- },
- async fetchData() {
- this.listLoading = true
- let query = Object.assign(this.queryForm, this.queryParams)
- const { data } = await businessContactApi.getList(query)
- if (data) {
- this.list = data.list
- this.total = data.total
- }
- this.listLoading = false
- },
- setSelectRows(val) {
- if (!this.multiple && val.length === this.list.length && val.length > 1) {
- // 返回单条数据情况下-控制全选情况下单选第一条数据
- this.$refs.contactTable.clearSelection()
- if (this.selectRows.length === 1) {
- return
- }
- this.$refs.contactTable.toggleRowSelection(val.shift(), true)
- } else if (!this.multiple && val.length > 1) {
- // 返回单条数据情况下-控制选择当前点击数据
- this.$refs.contactTable.clearSelection()
- this.$refs.contactTable.toggleRowSelection(val.pop(), true)
- } else {
- this.selectRows = val
- }
- },
- handleSizeChange(val) {
- this.queryForm.pageSize = val
- this.fetchData()
- },
- handleCurrentChange(val) {
- this.queryForm.pageNum = val
- this.fetchData()
- },
- },
- }
- </script>
- <style scoped></style>
|