index.vue 9.04 KB
<template>
	<div class="NCC-common-layout">
		<div class="NCC-common-layout-center">
			<el-row class="NCC-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="名称">
							<el-select v-model="query.customerId" placeholder="名称" clearable >
								<el-option v-for="(item, index) in customerIdOptions" :key="index" :label="item.Name" :value="item.Id"  />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="跟进时间">
							<el-date-picker v-model="query.trackTime" type="datetimerange" value-format="timestamp" format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始日期" end-placeholder="结束日期">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="跟进人">
							<userSelect v-model="query.creater" placeholder="请选择跟进人" />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="NCC-common-layout-main NCC-flex-main">
				<div class="NCC-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
					</div>
					<div class="NCC-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false" @click="reset()" />
						</el-tooltip>
						<screenfull isContainer />
					</div>
				</div>
                <NCC-table v-loading="listLoading" :data="list">
					<el-table-column label="线索/客户" prop="typeId" align="center"  width="140">
                        <template slot-scope="scope">
                            <el-tag type="success" v-if="scope.row.typeId==1">客户</el-tag>
                            <el-tag type="info" v-else>线索</el-tag>
                        </template>
					</el-table-column>
					<el-table-column label="名称" prop="customerId" align="left">
							<template slot-scope="scope">{{ scope.row.customerId | dynamicText(customerIdOptions) }}</template>
					</el-table-column>
                    <el-table-column prop="trackTime" label="跟进时间" align="center"  width="140">
                        <template slot-scope="scope" algin="center" >
                          <p class="text-success">{{scope.row.trackTime | toDate("yyyy-MM-dd HH:mm") }}</p>
                        </template>
                    </el-table-column>
					<el-table-column label="跟进阶段" prop="trackStage" align="center"  width="140">
							<template slot-scope="scope">{{ scope.row.trackStage | dynamicText(trackStageOptions) }}</template>
					</el-table-column>
                    <el-table-column prop="creater" label="跟进人" align="center" width="120" />
                    <el-table-column prop="createTime" label="创建时间" align="center"  width="140">
                        <template slot-scope="scope" algin="center" >
                          <p class="text-grey">{{scope.row.createTime | toDate("yyyy-MM-dd HH:mm") }}</p>
                        </template>
                    </el-table-column>
					<el-table-column label="操作" fixed="right" width="140">
							<template slot-scope="scope">
							<el-button type="text" @click="addOrUpdateHandle(scope.row.id)" >编辑</el-button>
							<el-button type="text" @click="handleDel(scope.row.id)" class="NCC-table-delBtn" >删除</el-button>
                            <el-button type="text" @click="toDetailHandle(scope.row.id)"  v-has="'btn_detail'">
								详细
							</el-button>
						</template>
					</el-table-column>
				</NCC-table>
                <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
            </div>
        </div>
		<NCC-Form v-if="formVisible" ref="NCCForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
        <Detail v-show="offerVisible" ref="Detail" @detailRefresh="detailRefresh" />
	</div>
</template>
<script>
    import request from '@/utils/request'
    import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
    import NCCForm from './Form'
    import Detail from './Detail'
    import ExportBox from './ExportBox'
    import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
        components: { NCCForm, ExportBox,Detail},
        data() {
            return {
                showAll: false,
				query: {
                    customerId:undefined,
                    trackTime:undefined,
                    creater:undefined,
				},
                list: [],
                listLoading: true,
                multipleSelection: [], total: 0,
                listQuery: {
                    currentPage: 1,
                    pageSize: 20,
					sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                offerVisible:false,
                columnList: [
                    { prop: 'typeId', label: '线索/客户' },
                    { prop: 'customerId', label: '名称' },
                    { prop: 'trackTime', label: '跟进时间' },
                    { prop: 'trackStage', label: '跟进阶段' },
                    { prop: 'creater', label: '跟进人' },
                    { prop: 'createTime', label: '创建时间' },
				],
				typeIdOptions:[{"fullName":"客户","id":"1"},{"fullName":"线索","id":"0"}],
				customerIdOptions : [],
				trackStageOptions : [],
			}
        },
		computed: {},
		created() {
			this.initData()
			this.getcustomerIdOptions();
			this.gettrackStageOptions();
		},
		methods: {
			getcustomerIdOptions(){
				previewDataInterface('195029830188664069').then(res => {
					this.customerIdOptions = res.data
				});
			},
			gettrackStageOptions(){
				getDictionaryDataSelector('208067702508487941').then(res => {
					this.trackStageOptions = res.data.list
				});
			},
			initData() {
                this.listLoading = true;
                let _query = {
                    ...this.listQuery,
                    ...this.query
                };
                let query = {}
                for (let key in _query) {
                    if (Array.isArray(_query[key])) {
                        query[key] = _query[key].join()
                    } else {
                        query[key] = _query[key]
                    }
                }
                request({
                    url: `/api/SubDev/ZyOaCustomerTrack`,
                    method: 'GET',
                    data: query
                }).then(res => {
                    this.list = res.data.list
                    this.total = res.data.pagination.total
                    this.listLoading = false
                })
            },
			handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/SubDev/ZyOaCustomerTrack/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
			addOrUpdateHandle(id, isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.NCCForm.init(id, isDetail)
                })
            },
             toDetailHandle(id) {
                 this.offerVisible = true
                 this.$nextTick(() => {
                 this.$refs.Detail.init(id)
                })
            },
			search() {
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "createTime",
                }
                this.initData()
            },
             detailRefresh(isrRefresh) {
                this.offerVisible = false
                if (isrRefresh) this.reset()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
                    currentPage: 1,
                    pageSize: 20,
                    sort: "desc",
                    sidx: "createTime",
                }
                this.initData()
            }
		}
    }
</script>