| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625 |
- <!--
- * @Author: wanglj 471442253@qq.com
- * @Date: 2022-12-15 15:38:21
- * @LastEditors: niezch@dashoo.cn
- * @La
- * @Description: file content
- * @FilePath: \opms_frontend\src\views\customer\openSea.vue
- -->
- <template>
- <div class="open-sea-container">
- <vab-query-form>
- <vab-query-form-top-panel>
- <el-form :inline="true" :model="queryForm" @submit.native.prevent>
- <!-- <el-form-item>
- <el-input v-model="queryForm.custCode" placeholder="客户编码" />
- </el-form-item> -->
- <el-form-item>
- <el-input
- v-model="queryForm.custName"
- clearable
- placeholder="客户名称"
- @keyup.enter.native="handleSearch" />
- </el-form-item>
- <!-- <el-form-item>
- <el-input
- v-model="queryForm.custProvince"
- clearable
- placeholder="所在省"
- @keyup.enter.native="handleSearch" />
- </el-form-item> -->
- <el-form-item>
- <el-select v-model="queryForm.province" clearable placeholder="所在省" value-key="id">
- <el-option v-for="item in provinceOptions" :key="item.id" :label="item.distName" :value="item" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <!-- <el-input v-model="queryForm.custCity" clearable placeholder="所在市" @keyup.enter.native="handleSearch" /> -->
- <el-select v-model="queryForm.custCity" clearable placeholder="所在市" value-key="id">
- <el-option
- v-for="item in queryForm.province ? queryForm.province.children : []"
- :key="item.id"
- clearable
- :label="item.distName"
- :value="item.distName" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select
- v-model="queryForm.custIndustry"
- clearable
- placeholder="客户类型"
- style="width: 100%"
- @keyup.enter.native="handleSearch">
- <el-option v-for="item in industryOptions" :key="item.key" :label="item.value" :value="item.key" />
- </el-select>
- </el-form-item>
- <!-- <el-form-item>
- <el-select v-model="queryForm.custLevel" placeholder="客户级别" style="width: 100%">
- <el-option v-for="item in levelOptions" :key="item.value" :label="item.value" :value="item.value" />
- </el-select>
- </el-form-item> -->
- <el-form-item>
- <!-- <el-date-picker
- v-model="queryForm.followUpDate"
- end-placeholder="跟进结束时间"
- placeholder="时间范围"
- start-placeholder="跟进开始时间"
- style="width: 100%"
- type="daterange"
- value-format="yyyy-MM-dd"
- @keyup.enter.native="fetchData" /> -->
- <el-date-picker
- v-model="queryForm.followUpDate"
- end-placeholder="跟进结束时间"
- range-separator="至"
- start-placeholder="跟进开始时间"
- style="width: 100%"
- type="daterange"
- value-format="yyyy-MM-dd" />
- </el-form-item>
- <el-form-item>
- <el-button icon="el-icon-plus" type="primary" @click="handleSearch">查询</el-button>
- <el-button icon="el-icon-refresh-right" @click="reset">重置</el-button>
- </el-form-item>
- </el-form>
- </vab-query-form-top-panel>
- <vab-query-form-left-panel :span="12">
- <el-button v-permissions="['cust:open:add']" icon="el-icon-plus" type="primary" @click="$refs.edit.init()">
- 新建
- </el-button>
- <el-button v-permissions="['cust:open:allocate']" icon="el-icon-plus" type="primary" @click="handleAllocate">
- 分配
- </el-button>
- <el-button v-permissions="['cust:open:receive']" icon="el-icon-plus" type="primary" @click="handleReceive">
- 领取
- </el-button>
- <el-button
- v-permissions="['cust:open:import']"
- icon="el-icon-download"
- type="primary"
- @click="downloadTemplate">
- 下载模板
- </el-button>
- <el-upload
- ref="uploadRef"
- v-permissions="['cust:open:import']"
- :accept="fileSettings.types"
- action="#"
- :before-upload="
- (file) => {
- return beforeUpload(file)
- }
- "
- :file-list="fileList"
- :http-request="uploadRequest"
- :show-file-list="false"
- style="margin: 0 10px 10px 0 !important">
- <el-button icon="el-icon-upload2" :loading="importLoading" type="primary">导入</el-button>
- </el-upload>
- </vab-query-form-left-panel>
- <vab-query-form-right-panel :span="12">
- <!-- <el-button icon="el-icon-download" @click="exportData" />-->
- <table-tool :columns="columns" :show-columns.sync="showColumns" table-type="openSeaCustomerTable" />
- </vab-query-form-right-panel>
- </vab-query-form>
- <el-table
- ref="table"
- v-loading="listLoading"
- border
- :data="list"
- :height="$baseTableHeight(2)"
- @selection-change="setSelectRows">
- <el-table-column align="center" show-overflow-tooltip type="selection" />
- <el-table-column
- v-for="(item, index) in showColumns"
- :key="index"
- align="center"
- :label="item.label"
- :min-width="item.width"
- :prop="item.prop"
- show-overflow-tooltip
- :sortable="item.sortable">
- <template #default="{ row }">
- <el-button v-if="item.prop === 'custName'" class="link-button" type="text" @click="handleDetail(row)">
- {{ row.custName }}
- </el-button>
- <span v-else-if="item.prop === 'custStatus'">
- {{ row.custStatus == 10 ? '正常' : '异常' }}
- </span>
- <span v-else-if="item.prop === 'custIndustry'">
- {{ selectDictLabel(industryOptions, row.custIndustry) }}
- </span>
- <span v-else-if="item.prop === 'followUpDate'">
- {{ parseTime(row.followUpDate, '{y}-{m}-{d}') }}
- </span>
- <span v-else-if="item.prop === 'createdTime'">
- {{ parseTime(row.createdTime, '{y}-{m}-{d}') }}
- </span>
- <span v-else>{{ row[item.prop] }}</span>
- </template>
- </el-table-column>
- <!-- <el-table-column
- align="center"
- label="客户编码"
- min-width="120px"
- prop="custCode" />
- <el-table-column
- align="center"
- label="客户名称"
- min-width="120px"
- prop="custName">
- <template slot-scope="scope">
- <el-button
- style="font-size: 14px"
- type="text"
- @click="handleDetail(scope.row)">
- {{ scope.row.custName }}
- </el-button>
- </template>
- </el-table-column>
- <el-table-column align="center" label="助记名" prop="abbrName" />
- <el-table-column align="center" label="所在地区" prop="custLocation" />
- <el-table-column align="center" label="客户类型" prop="custIndustry" />
- <el-table-column align="center" label="客户级别" prop="custLevel" />
- <el-table-column align="center" label="客户状态" prop="custStatus">
- <template slot-scope="scope">
- {{ scope.row.custStatus == 10 ? '正常' : '异常' }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="最后跟进时间"
- min-width="140px"
- prop="followUpDate" />
- <el-table-column align="center" label="创建人" prop="createdName" />
- <el-table-column
- align="center"
- label="创建时间"
- min-width="140px"
- prop="createdTime" /> -->
- <el-table-column align="center" fixed="right" label="操作" width="90px">
- <template slot-scope="scope">
- <el-button v-permissions="['cust:open:edit']" type="text" @click="handleEdit(scope.row)">编辑</el-button>
- <el-button v-permissions="['cust:open:delete']" type="text" @click="handleDelete(scope.row)">删除</el-button>
- </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" />
- <!-- 新增编辑客户弹窗 -->
- <Edit ref="edit" @createContact="createContact" @customerSave="customerSave" />
- <!-- 新建联系人弹窗 -->
- <Contact ref="contact" />
- <!-- 分配客户 -->
- <Allocate ref="allocate" @refresh="fetchData" />
- <!-- 领取客户 -->
- <Pick ref="pick" @refresh="fetchData" />
- </div>
- </template>
- <script>
- import to from 'await-to-js'
- import api from '@/api/customer'
- import Contact from './components/Contact'
- import Edit from './components/Edit'
- import Allocate from './components/Allocate'
- import Pick from './components/Pick'
- import TableTool from '@/components/table/TableTool'
- import downloadFileByByte from '@/utils/base64ToFile'
- import axios from 'axios'
- import asyncUploadFile from '@/utils/uploadajax'
- export default {
- name: 'OpenSeaCustomer',
- components: {
- Contact,
- Edit,
- Allocate,
- Pick,
- TableTool,
- },
- data() {
- return {
- listLoading: false,
- layout: 'total, sizes, prev, pager, next, jumper',
- list: [],
- total: 0,
- queryForm: {
- pageNum: 1,
- pageSize: 10,
- custCode: '', // 客户编码
- custName: '', //客户名称
- custIndustry: '', // 客户类型 ()
- custLevel: '', //客户级别
- followUpDate: [], //最后跟进时间
- isPublic: true,
- custProvince: '',
- province: {},
- custCity: '',
- },
- selectRows: [],
- industryOptions: [], //客户类型
- levelOptions: [], //客户级别
- provinceOptions: [],
- provinceDetail: [],
- sellOptions: [],
- // 自定义列表
- showColumns: [],
- columns: [
- {
- label: '客户编码',
- width: '120px',
- prop: 'custCode',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '客户名称',
- width: '200px',
- prop: 'custName',
- sortable: false,
- disableCheck: true,
- },
- {
- label: '助记名',
- width: '120px',
- prop: 'abbrName',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '所在省',
- width: '120px',
- prop: 'custProvince',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '所在市',
- width: '100px',
- prop: 'custCity',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '客户类型',
- width: '100px',
- prop: 'custIndustry',
- sortable: false,
- disableCheck: false,
- },
- // {
- // label: '客户级别',
- // width: 'auto',
- // prop: 'custLevel',
- // sortable: false,
- // disableCheck: false,
- // },
- // {
- // label: '客户状态',
- // width: '100px',
- // prop: 'custStatus',
- // sortable: false,
- // disableCheck: false,
- // },
- {
- label: '最后跟进时间',
- width: '100px',
- prop: 'followUpDate',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '最后跟进人',
- width: '100px',
- prop: 'followUpMan',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '创建人',
- width: '100px',
- prop: 'createdName',
- sortable: false,
- disableCheck: false,
- },
- {
- label: '创建时间',
- width: '100px',
- prop: 'createdTime',
- sortable: false,
- disableCheck: false,
- },
- ],
- fileList: [],
- fileSettings: {
- // 文件配置信息
- fileSize: 52428800,
- fileTypes: '.xlsx',
- pictureSize: 52428800,
- types: '.xlsx',
- },
- importLoading: false,
- }
- },
- watch: {
- showColumns: function () {
- this.$nextTick(() => this.$refs.table.doLayout())
- },
- },
- activated() {
- this.fetchData()
- },
- mounted() {
- this.fetchData()
- this.getOptions()
- },
- methods: {
- getOptions() {
- Promise.all([api.getProvinceDetail(), this.getDicts('cust_level'), this.getDicts('cust_idy')])
- .then(([province, level, industry, sell]) => {
- this.provinceOptions = province.data.list || []
- this.levelOptions = level.data.values || []
- this.industryOptions = industry.data.values || []
- this.sellOptions = sell.data.list || []
- })
- .catch((err) => console.log(err))
- },
- async fetchData() {
- this.listLoading = true
- const params = { ...this.queryForm }
- if (!params.followUpDate) params.followUpDate = null
- if (this.queryForm.followUpDate && this.queryForm.followUpDate.length === 2) {
- params.beginTime = this.queryForm.followUpDate[0]
- params.endTime = this.queryForm.followUpDate[1]
- }
- params.custProvince = params.province.distName ? params.province.distName : ''
- const [err, res] = await to(api.getPublicList(params))
- if (err) return (this.listLoading = false)
- this.list = res.data.list || []
- this.total = res.data.total
- this.listLoading = false
- this.$nextTick(() => this.$refs.table.doLayout())
- },
- handleSearch() {
- this.queryForm.pageNum = 1
- this.fetchData()
- },
- exportData() {
- this.queryForm.isPublic = true
- let exportFrom = JSON.parse(JSON.stringify(this.queryForm))
- exportFrom.columns = this.showColumns.map((item) => item.label)
- api
- .deriveList(exportFrom)
- .then((res) => {
- if (res.data.list.content) {
- downloadFileByByte(res.data.list.content, '公海客户数据.xlsx')
- }
- })
- .catch((err) => {
- console.error(err)
- })
- },
- reset() {
- this.queryForm = {
- pageNum: 1,
- pageSize: 10,
- custCode: '', // 客户编码
- custName: '', //客户名称
- custIndustry: '', // 客户类型 ()
- custLevel: '', //客户级别
- followUpDate: [], //最后跟进时间
- isPublic: true,
- custProvince: '',
- custCity: '',
- province: {},
- }
- this.fetchData()
- },
- handleSizeChange(val) {
- this.queryForm.pageSize = val
- this.fetchData()
- },
- handleCurrentChange(val) {
- this.queryForm.pageNum = val
- this.fetchData()
- },
- setSelectRows(val) {
- this.selectRows = val
- },
- // 客户编辑
- async handleEdit(row) {
- this.$refs.edit.init([row.id])
- },
- // 客户详情
- handleDetail(row) {
- this.$router.push({
- path: '/customer/detail',
- query: {
- id: row.id,
- },
- })
- },
- // 客户删除
- handleDelete(row) {
- this.$confirm('确认删除?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(async () => {
- const [err, res] = await to(api.deleteCustomer({ Ids: [row.id] }))
- if (err) return
- if (res.code == 200) {
- this.$message({
- type: 'success',
- message: '删除成功!',
- })
- this.fetchData()
- }
- })
- .catch(() => {})
- },
- // 联系人弹窗
- createContact(res) {
- this.$refs.contact.contactForm.custId = res.id
- this.$refs.contact.contactForm.custName = res.name
- this.$refs.contact.contactVisible = true
- },
- customerSave() {
- this.fetchData()
- },
- handleClose(form) {
- this.$refs[form].resetFields()
- },
- // 分配
- handleAllocate() {
- if (!this.selectRows.length) return this.$message.warning('请选择客户')
- const arr = this.selectRows.map((item) => item.id)
- this.$refs.allocate.ids = arr
- this.$refs.allocate.visible = true
- },
- // 领取
- handleReceive() {
- if (!this.selectRows.length) return this.$message.warning('请选择客户')
- const arr = this.selectRows.map((item) => item.id)
- this.$refs.pick.ids = arr
- this.$refs.pick.visible = true
- // this.$confirm('确认领取客户?', '提示', {
- // confirmButtonText: '确定',
- // cancelButtonText: '取消',
- // type: 'warning',
- // })
- // .then(async () => {
- // const [err, res] = await to(
- // api.receiveCustomer({
- // ids: arr,
- // salesId: this.$store.state.user.id,
- // salesName: this.$store.state.user.nickName,
- // receive: '1',
- // })
- // )
- // if (err) return
- // if (res.code == 200) {
- // this.$message({
- // type: 'success',
- // message: '领取成功!',
- // })
- // this.fetchData()
- // }
- // })
- // .catch((err) => console.log(err))
- },
- beforeUpload(file) {
- let flag1 = file.size < this.fileSettings.fileSize
- if (!flag1) {
- this.$message.warning('文件过大,请重新选择!')
- return false
- }
- let flag2 = this.fileSettings.fileTypes.split(',').includes('.' + file.name.split('.').pop())
- if (!flag2) {
- this.$message.warning('文件类型不符合,请重新选择!')
- return false
- }
- return true
- },
- uploadRequest(option) {
- this.importLoading = true
- let _this = this
- let url = process.env.VUE_APP_UPLOAD_WEED
- axios
- .post(url)
- .then((res) => {
- if (res.data && res.data.fid && res.data.fid !== '') {
- option.action = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
- let fileUrl = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}` // 资料存储url
- asyncUploadFile(option).then(async () => {
- console.log('fileUrl', fileUrl)
- const params = {
- excelUrl: fileUrl,
- }
- const [err, res] = await to(api.import(params))
- if (err) {
- this.importLoading = false
- return
- }
- if (res.code == 200) {
- this.importLoading = false
- _this.fetchData()
- _this.$message({
- type: 'success',
- message: '操作成功',
- })
- }
- })
- } else {
- this.importLoading = false
- _this.$message({
- type: 'warning',
- message: '未上传成功!请刷新界面重新上传!',
- })
- }
- })
- .catch(function () {
- this.importLoading = false
- _this.$message({
- type: 'warning',
- message: '未上传成功!请重新上传!',
- })
- })
- },
- downloadTemplate() {
- api
- .excelTemplate({})
- .then((res) => {
- if (res.code == 200) {
- downloadFileByByte(res.data, '客户导入模板.xlsx')
- }
- })
- .catch((err) => {
- console.error(err)
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- $base: '.open-sea';
- .link-button {
- font-size: 14px;
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- </style>
|