logListCommon.vue 18.2 KB
Newer Older
1 2 3 4 5
<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-form size="small" :inline="true" label-width="100px">
6
          <div class="search-z">
zs嵩's avatar
6  
zs嵩 committed
7
            <el-form-item :label="$t('联系人')" prop="contactName">
8 9
              <el-input v-model.trim="followForm.contactName" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
10
            <el-form-item :label="$t('联系方式')" prop="contactPhone">
11 12
              <el-input v-model.trim="followForm.contactPhone" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
13
            <el-form-item :label="$t('跟进类型')">
14 15
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE" v-model="followForm.followType" @input="handleQuery"></dict-selector>
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
16
            <el-form-item :label="$t('销售阶段')">
17 18
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_SALE_STAGE" v-model="followForm.saleStage" @input="handleQuery"></dict-selector>
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
19
            <el-form-item :label="$t('编号')" prop="number" v-show="showSearch">
20 21
              <el-input v-model.trim="followForm.number" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
22
            <el-form-item :label="$t('报价单号')" prop="offerNumber" v-show="showSearch">
23 24 25
              <el-input v-model.trim="followForm.offerNumber" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>

zs嵩's avatar
6  
zs嵩 committed
26
            <el-form-item :label="$t('客户经理')" prop="followUserIds" v-show="showSearch">
27 28
              <user-selector v-model="followForm.followUserIds" multiple clearable @input="handleQuery" />
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
29
            <el-form-item :label="$t('关联跟进记录')" prop="parentNumber" v-show="showSearch">
30 31
              <el-input v-model.trim="followForm.parentNumber" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
32

zs嵩's avatar
6  
zs嵩 committed
33
            <el-form-item :label="$t('跟进方式')" v-show="showSearch">
34 35
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD" v-model="followForm.followMethod" @input="handleQuery"></dict-selector>
            </el-form-item>
36

37
            <!-- <el-form-item :label="$t('跟进结果')">
38 39 40
              <el-select clearable v-model="followForm.resultType" :placeholder="$t('请选择')" size="small" @change="handleQuery">
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_RESULT_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
              </el-select>
41
            </el-form-item> -->
zs嵩's avatar
6  
zs嵩 committed
42
            <el-form-item :label="$t('跟进状态')" v-show="showSearch">
43 44 45 46
              <el-select clearable v-model="followForm.status" :placeholder="$t('请选择')" size="small" @change="handleQuery">
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
              </el-select>
            </el-form-item>
zhengyi's avatar
zhengyi committed
47
            <el-form-item :label="$t('客户来源')" v-show="showSearch">
zhengyi's avatar
zhengyi committed
48
              <el-select filterable multiple clearable v-model="followForm.customerSourceList" :placeholder="$t('请选择')" size="small" @change="handleQuery">
zhengyi's avatar
zhengyi committed
49 50 51
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_SOURCE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
              </el-select>
            </el-form-item>
52 53
          </div>
          <div class="search-time">
zs嵩's avatar
6  
zs嵩 committed
54
            <el-form-item :label="$t('创建时间')" v-show="showSearch">
55 56
              <el-date-picker v-model="followFormTmp.createTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
57
            <el-form-item :label="$t('跟进时间')" v-show="showSearch">
58 59
              <el-date-picker v-model="followFormTmp.followTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
zs嵩's avatar
6  
zs嵩 committed
60
            <el-form-item :label="$t('下次跟进时间')" v-show="showSearch">
61 62
              <el-date-picker v-model="followFormTmp.nextTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
zhengyi's avatar
zhengyi committed
63 64 65
            <el-form-item :label="$t('客户创建时间')" v-show="showSearch">
              <el-date-picker v-model="followFormTmp.customerCreateTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
66 67
            <el-form-item style="padding-left: 20px; width: auto">
              <div class="flex-c-c">
68
                <el-button type="primary" icon="el-icon-search" @click="getDataSpaceCustomerFollowupList">{{ $t("搜索") }} </el-button>
69 70 71 72
                <el-button type="primary" @click="reset">{{ $t("重置") }} </el-button>
              </div>
            </el-form-item>
          </div>
73 74
        </el-form>
      </div>
75 76 77 78 79 80 81 82 83 84 85 86 87 88

      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button :disabled="selectCustomerFollowList.length === 0" type="primary" @click="updateStatus = true" v-hasPermi="['ecw:customer:followup:batch-update-status']">{{ $t("修改状态") }}</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="success" @click="handleAdd" v-hasPermi="['ecw:customer:follow-create']">{{ $t("新增") }} </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="warning" @click="handleExport" v-hasPermi="['ecw:customer:follow-export']">
            {{ $t("导出") }}
          </el-button>
        </el-col>
zs嵩's avatar
6  
zs嵩 committed
89
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getDataSpaceCustomerFollowupList"></right-toolbar>
90
      </el-row>
91
      <el-table ref="multipleTable" border :data="customerFollowList" v-loading="loading" @selection-change="handleSelectionChange" style="width: 100%" id="dataTable" :height="autoHeight">
92
        <el-table-column type="selection" width="55" fixed></el-table-column>
zhengyi's avatar
zhengyi committed
93
        <el-table-column prop="customerNumber" :label="$t('客户编号')" width="120" fixed>
94
          <template slot-scope="scope">
zhengyi's avatar
zhengyi committed
95
            <a href="javascript:void(0)" @click="handleCustomerViewLink(scope.row)" class="link-type">{{ scope.row.customerNumber }}</a>
96 97
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
98 99 100 101 102 103
        <el-table-column prop="customerName" :label="$t('客户名称')" width="120" fixed/>
        <el-table-column prop="contactName" :label="$t('联系人')" width="120"/>
        <el-table-column prop="contactPhone" :label="$t('联系方式')" width="120"/>
        <el-table-column prop="saleStage" :label="$t('销售阶段')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_SALE_STAGE, cellValue)" width="120"/>
        <el-table-column prop="followType" :label="$t('跟进类型')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE, cellValue)" width="120"/>
        <el-table-column prop="offerNumber" :label="$t('报价单号')" width="120">
104 105 106 107
          <template slot-scope="{ row }">
            <el-link type="primary" @click.native="$router.push('/offer/detail?offerId=' + row.offerId)" v-if="row.offerNumber">{{ row.offerNumber }}</el-link>
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
108
        <el-table-column prop="followTime" :label="$t('跟进时间')" :formatter="(row, column, cellValue) => parseTime(cellValue)" width="120"></el-table-column>
109 110
        <el-table-column prop="purpose" :label="$t('目的')" width="240"/>
        <el-table-column prop="feedback" :label="$t('跟进情况')" width="240"/>
zhengyi's avatar
zhengyi committed
111
        <el-table-column :label="$t('下次跟进时间')" align="center" width="120">
112 113 114 115
          <template slot-scope="scope">
            {{ parseTime(scope.row.nextTime) }}
          </template>
        </el-table-column>
116 117 118 119 120 121
        <el-table-column prop="nextPlan" :label="$t('下次计划')" align="center" width="240"/>
        <el-table-column :label="$t('关联跟进记录')" align="center" prop="parentNumber" width="120">
          <template slot-scope="scope">
            <a href="javascript:void(0)" @click="handleCustomerFollowLink(scope.row.parentVO)" class="link-type">{{ scope.row.parentNumber }}</a>
          </template>
        </el-table-column>
122 123 124 125 126
        <el-table-column :label="$t('跟进状态')" align="center">
          <template slot-scope="scope">
            {{ getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS, scope.row.status) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
127 128 129 130 131 132 133 134 135 136 137
        <el-table-column prop="number" :label="$t('跟进编号')" align="center" width="120">
          <template slot-scope="scope">
            <a href="javascript:void(0)" @click="handleCustomerFollowLink(scope.row)" class="link-type">{{ scope.row.number }}</a>
          </template>
        </el-table-column>
        <el-table-column prop="followMethod" :label="$t('跟进方式')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD, cellValue)" width="120" />

        <el-table-column prop="followUserName" :label="$t('客户经理')" width="120" />
        <el-table-column prop="customerSource" :label="$t('客户来源')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_SOURCE, cellValue)" width="120"/>
        <el-table-column :label="$t('客户创建时间')" align="center" width="120">
          <template slot-scope="scope">
zhengyi's avatar
zhengyi committed
138
            {{ parseTime(scope.row.customerCreateTime) }}
zhengyi's avatar
zhengyi committed
139 140
          </template>
        </el-table-column>
141
        <el-table-column prop="creatorName" :label="$t('创建人')" align="center" width="120"/>
zhengyi's avatar
zhengyi committed
142
        <el-table-column :label="$t('创建时间')" align="center" width="120">
143 144 145 146
          <template slot-scope="scope">
            {{ parseTime(scope.row.createTime) }}
          </template>
        </el-table-column>
147
        <el-table-column prop="updaterName" :label="$t('最后更新人')" align="center" width="120"/>
zhengyi's avatar
zhengyi committed
148
        <el-table-column :label="$t('最后更新时间')" align="center" width="120">
149 150 151 152
          <template slot-scope="scope">
            {{ parseTime(scope.row.updateTime) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
153
        <el-table-column width="200" :label="$t('操作')" align="center" fixed="right" class-name="small-padding fixed-width">
154 155 156
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" v-if="!scope.row.status" @click="handleCustomerFollow(scope.row)" v-hasPermi="['ecw:customer:follow-update']">{{ $t("编辑") }} </el-button>
            <el-button size="mini" type="text" icon="el-icon-collection" @click="handleCustomerFollow(scope.row, true)" v-has-permi="['ecw:customer:follow-add-plan']">{{ $t("增加计划") }} </el-button>
zhengyi's avatar
zhengyi committed
157
            <el-button size="mini" type="text" icon="el-icon-edit"  @click="handleCustomerFollowLink(scope.row)" v-hasPermi="['ecw:customer:follow-update']">{{ $t("查看") }} </el-button>
158 159 160
          </template>
        </el-table-column>
      </el-table>
161
      <pagination :total="customerFollowTotal" :page.sync="followForm.pageNo" :limit.sync="followForm.pageSize" @pagination="getDataSpaceCustomerFollowupList" />
162
    </el-card>
zs嵩's avatar
zs嵩 committed
163
    <customer-follow ref="customerFollow" @close="customerFollowVisible = false" @handleCustomerFollowAdd="handleCustomerFollowAdd" @refresh="handleQuery" v-if="customerFollowVisible" :customer-id="customerId" :customerService="customerService" :customerNumber="customerNumber" />
zs嵩's avatar
zs嵩 committed
164
    <customer-follow-update-status :show.sync="updateStatus" :followup-ids.sync="selectCustomerFollowList" @refresh="handleQuery"></customer-follow-update-status>
165 166 167 168
  </div>
</template>

<script>
169
import { getCustomerFollowupList, getDataSpaceCustomerFollowupList, exportDataSpaceCustomerFollowup } from "@/api/ecw/customerFollow"
170
import { getDictDatas, DICT_TYPE, getDictDatas2 } from "@/utils/dict"
171 172
import CustomerFollow from "@/views/ecw/customer/components/customerFollow"
import UserSelector from "@/components/UserSelector"
zs嵩's avatar
zs嵩 committed
173
import customerFollowUpdateStatus from "@/views/ecw/customer/components/customerFollowUpdateStatus.vue"
174 175
export default {
  name: "logListCommon",
zs嵩's avatar
zs嵩 committed
176
  components: { customerFollowUpdateStatus, UserSelector, CustomerFollow },
177
  props: ["customerId", "offerId", "customerService", "customerNumber"],
178 179
  data() {
    return {
180 181 182 183 184
      // 遮罩层
      loading: true,
      getDictDatas,
      getDictDatas2,
      DICT_TYPE,
185 186
      // 显示搜索条件
      showSearch: false,
187
      updateStatus: false,
188 189 190
      customerFollowVisible: false,
      customerFollowTotal: 0,
      customerFollowList: [],
191
      selectCustomerFollowList: [],
192 193 194 195 196
      followForm: {
        pageNo: 1,
        pageSize: 10
      },
      followFormTmp: {
197
        createTime: ["", ""],
198
        followTime: ["", ""],
zhengyi's avatar
zhengyi committed
199 200
        nextTime: ["", ""],
        customerCreateTime: ["", ""]
201
      },
202
      autoHeight: null
203 204 205 206 207
    }
  },
  created() {
    this.handleQuery()
  },
208 209 210 211 212
  updated() {
    this.$nextTick(() => {
      this.$refs.multipleTable.doLayout()
    })
  },
213
  computed: {
214 215 216 217 218 219 220 221
    // selectAuthorityFn() {
    //   return (val) => {
    //     let t = val.split(":")
    //     t[t.length - 1] = this.authorityFn + t[t.length - 1]
    //     console.log(t.join(":"))
    //     return t.join(":")
    //   }
    // },
222 223 224 225 226 227
    isMobile() {
      const userAgent = navigator.userAgent || navigator.vendor || window.opera;
      // 匹配常见的移动设备标识
      const mobileIdentifiers = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone'];
      return mobileIdentifiers.some(identifier => userAgent.includes(identifier));
    },
228 229 230 231 232 233 234 235
    isChinese() {
      return this.$i18n.locale === "zh_CN"
    },
    customerId_offerId() {
      return `${this.customerId}_${this.offerId}`
    }
  },
  watch: {
honghy's avatar
honghy committed
236
    showSearch() {
honghy's avatar
honghy committed
237 238 239
      this.$nextTick(() => {
        this.getHeight()
      })
honghy's avatar
honghy committed
240
    },
241 242
    selectCustomerFollowList(val) {
      if (val.length === 0) {
243
        this.getDataSpaceCustomerFollowupList()
244 245 246
        this.$refs.multipleTable.clearSelection()
      }
    },
247 248 249 250 251
    customerId_offerId() {
      this.handleQuery()
    }
  },
  methods: {
252 253 254
    handleSelectionChange(val) {
      this.selectCustomerFollowList = val.map((i) => i.id)
    },
255 256 257 258 259
    handleCustomerFollowAdd(row) {
      this.customerFollowVisible = false
      setTimeout(() => {
        this.customerFollowVisible = true
        this.$nextTick((_) => {
1483922988@qq.com's avatar
1483922988@qq.com committed
260
          this.$refs["customerFollow"].handleUpdate(row, true)
261 262 263 264 265 266 267 268 269
        })
      }, 100)
    },
    handleCustomerFollow(row, flag) {
      this.customerFollowVisible = true
      this.$nextTick((_) => {
        this.$refs["customerFollow"].handleUpdate(row, flag)
      })
    },
1483922988@qq.com's avatar
1483922988@qq.com committed
270 271 272 273 274 275 276
    handleAdd() {
      this.customerFollowVisible = true
      this.$nextTick(() => {
        this.$refs["customerFollow"].handleAdd()
      })
    },

277 278 279 280 281 282
    handleCustomerFollowLink(row) {
      this.customerFollowVisible = true
      this.$nextTick((_) => {
        this.$refs["customerFollow"].handleView(row)
      })
    },
283 284 285
    handleCustomerViewLink(row) {
      this.$router.push(`/customer/query/${row.customerId}`)
    },
286 287 288 289
    formatQuery() {
      let obj = {}
      obj.customerId = this.customerId || null
      obj.offerId = this.offerId || null
290 291
      obj.beginCreateTime = this.followFormTmp.createTime[0]
      obj.endCreateTime = this.followFormTmp.createTime[1]
292 293
      obj.beginFollowTime = this.followFormTmp.followTime[0]
      obj.endFollowTime = this.followFormTmp.followTime[1]
294 295
      obj.beginNextTime = this.followFormTmp.nextTime[0]
      obj.endNextTime = this.followFormTmp.nextTime[1]
zhengyi's avatar
zhengyi committed
296 297
      obj.beginCustomerCreateTime = this.followFormTmp.customerCreateTime[0]
      obj.endCustomerCreateTime = this.followFormTmp.customerCreateTime[1]
298 299 300
      return obj
    },
    handleQuery() {
332784038@qq.com's avatar
6  
332784038@qq.com committed
301 302
      console.log(this.followForm)

303 304 305
      this.followForm.pageNo = 1
      this.customerFollowTotal = 0
      this.customerFollowList = []
306
      this.getDataSpaceCustomerFollowupList()
307 308 309 310 311
    },
    /** 跟进记录导出按钮操作 */
    handleExport() {
      // 执行导出
      this.$modal.confirm(this.$t("是否确认导出客户跟进记录数据项?")).then(() => {
312
        exportDataSpaceCustomerFollowup({
313 314
          ...this.followForm,
          ...this.formatQuery(),
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
315 316
          pageNo: null,
          pageSize: null
317 318 319 320 321
        }).then((r) => {
          this.$message.success(this.$t("已加入导出队列,请稍后在下载日志中下载"))
        })
      })
    },
322
    getDataSpaceCustomerFollowupList() {
323
      this.loading = true
324
      getDataSpaceCustomerFollowupList({
325 326 327 328 329
        ...this.followForm,
        ...this.formatQuery()
      }).then((r) => {
        this.customerFollowList = r.data.list
        this.customerFollowTotal = r.data.total
330
        this.loading = false
331
        this.getHeight()
332
      })
332784038@qq.com's avatar
6  
332784038@qq.com committed
333 334
    },
    reset() {
335
      this.followFormTmp.createTime = ["", ""]
336
      this.followFormTmp.followTime = ["", ""]
332784038@qq.com's avatar
6  
332784038@qq.com committed
337
      this.followFormTmp.nextTime = ["", ""]
zhengyi's avatar
zhengyi committed
338
      this.followFormTmp.customerCreateTime = ["", ""]
332784038@qq.com's avatar
6  
332784038@qq.com committed
339 340 341 342
      this.followForm = {
        pageNo: 1,
        pageSize: 10
      }
343
      this.getDataSpaceCustomerFollowupList()
344 345 346
    },
    //表格高度自适应
    getHeight() {
347 348 349 350 351 352 353 354 355 356 357 358
      if(!this.isMobile) {
        this.$refs.multipleTable.doLayout()
        let getHeightFromBottom = (element, variableHeight) => {
          const elementRect = element.getBoundingClientRect().top;
          const windowHeight = document.documentElement.clientHeight;
          const elementHeightFromBottom = windowHeight - elementRect;
          const result = elementHeightFromBottom - variableHeight;
          return result;
        }
        const element = document.getElementById('dataTable');
        const variableHeight = 70; // 给定的变量高度 一般留于分页器高度
        this.autoHeight =getHeightFromBottom(element, variableHeight);
359 360
      }
    },
361 362 363
  }
}
</script>