zjf
2023-02-24 2126cd24b8a0174ac0597340917c0a4595f72254
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<template>
  <div class='customer'>
    <c-r-m-list-head
        ref="listHead"
        title="商机管理"
        main-title="客户管理" />
 
    <c-r-m-table-head
      ref="crmTableHead"
      :crm-type="crmType"
      :fieldList='fieldList'
      @exportFile="exportFile"
      @importFile='importFile'
      @filter="handleFilter"
      @handle="handleHandle"
      @on-handle="listHeadHandle"
      @scene="handleScene"
      @queryList='queryList'/>
 
    <el-card class="el-card">
      <el-table
        v-loading="loading"
        id="crm-table"
        :data="list"
        :height="tableHeight"
        :cell-style="cellStyle"
        class="n-table--border"
        border
        highlight-current-row
        style="width: 100%; z-index: 0;"
        @row-click="handleRowClick"
        @sort-change="sortChange"
        @header-dragend="handleHeaderDragend"
        @selection-change="handleSelectionChange">
        <el-table-column
          show-overflow-tooltip
          type="selection"
          :selectable="selectable"
          align="center"
          width="55"/>
        <el-table-column
          v-for="(item, index) in fieldList"
          :key="index"
          :fixed="index==0"
          :prop="item.field"
          :label="item.value"
          :width="item.width"
          :formatter="fieldFormatter"
          sortable="custom"
          show-overflow-tooltip>
          <template
            slot="header"
            slot-scope="scope">
            <div class="table-head-name">
              {{ scope.column.label }}
              <c-r-m-table-filter
                :show="scope.column.label==='项目属性'||scope.column.label==='提交'||scope.column.label==='审批'"
                :tableType="scope.column.label"
                @queryList="queryList">
                </c-r-m-table-filter>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="BusinessStatusString" label="上报状态">
          <template
            slot="header"
            slot-scope="scope">
            <div class="table-head-name">{{ scope.column.label }}</div>
          </template>
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" :content="scope.row.BusinessStatusReason?scope.row.BusinessStatusReason:scope.row.BusinessStatusString" placement="top">
              <span >{{scope.row.BusinessStatusString}}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column
          prop="operation"
          width="150">
          <template
            slot="header"
            slot-scope="scope">
            <div class="table-head-name">操作</div>
          </template>
          <template slot-scope="scope">
          <el-button type="text" size="small" :disabled="!scope.row.IsCanEdit"  @click='editList(scope.row)'>编辑 |</el-button>
          <el-button type="text" size="small" :disabled="!scope.row.IsCanDelete"  @click='deleteSingleModule(scope.row.Id)'>删除 |</el-button>
          <el-button type="text" size="small"  @click='goFollow(scope.row.Id)'>跟进</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="p-contianer" v-show='total>0'>
        <el-pagination
          :current-page="currentPage"
          :page-sizes="pageSizes"
          :page-size.sync="pageSize"
          :total="total"
          class="p-bar"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
 
    </el-card>
 
    <!-- 编辑页面 -->
    <c-r-m-create-view
      v-if="isCreate"
      :action="{type: 'update', id: editData.Id, data: editData}"
      :crm-type="crmType"
      @save-success="listHeadHandle"
      @hiden-view="hiddenView"/>
    <c-r-m-import
      :show="showCRMImport"
      :crm-type="crmType"
      @close="showCRMImport=false"
      @queryList='queryList'/>
    <c-r-m-export
      :show="showCRMExport"
      :crm-type="crmType"
      :search="search"
      :filter-obj="filterObj"
      :head-obj="headObj"
      :is-seas="false"
      :export-params="exportParams"
      @close="showCRMExport=false"
      @queryList='queryList'/>
    <!-- 相关详情页面 -->
    <c-r-m-all-detail
      :key='timer'
      :visible.sync="showDview"
      :crm-type="rowType"
      :id="rowID"
      :isFollow="isFollow"
      class="d-view"
      @handle="handleHandle"/>
    <fields-set
      :crm-type="crmType"
      :dialog-visible.sync="showFieldSet"
      @set-success="setSave"/>
  </div>
</template>
 
<script>
import table from '../mixins/table'
import CRMCreateView from '../components/CRMCreateView'
import CRMImport from '../components/CRMImport'
import CRMExport from '../components/CRMExport'
import CRMAllDetail from '@/views/clients/components/CRMAllDetail'
import CRMTableFilter from '../components/CRMTableFilter'
import { DeleteSalesChance } from '@/api/customermanagement/business'
 
export default {
  /** 客户管理 的 商机列表 */
  name: 'BusinessIndex',
  components: {
    CRMAllDetail,
    CRMCreateView,
    CRMImport,
    CRMExport,
    CRMTableFilter
  },
  filters: {
  },
  mixins: [table],
  computed: {
  },
  data () {
    return {
      timer: '',
      choosedScene: '2',
      fieldList: [{ field: 'ChanceNumber', value: '编号' },
        { field: 'ChanceName', value: '商机名称', width: '150' },
        { field: 'CustomerName', value: '客户名称', width: '150' },
        { field: 'ContacterName', value: '联系人' },
        { field: 'ProjectProperty', value: '项目属性' },
        { field: 'ChanceRequestTypeString', value: '商机类型' },
        { field: 'SalesChanceStage', value: '销售阶段' },
        { field: 'UploadStatusName', value: '提交' },
        { field: 'ReportStatusName', value: '审批' },
        { field: 'TrackStatus', value: '报备' },
        // { field: 'BusinessStatusString', value: '上报状态' },
        { field: 'SubmitTimeString', value: '上报时间' },
        { field: 'InvalidTimeString', value: '过期时间' },
        { field: 'ExpectedDate', value: '预期成交日期' },
        { field: 'ExpectedAmount', value: '商机金额/元' },
        { field: 'CreateUserName', value: '创建人' },
        { field: 'OwerName', value: '销售负责人' }
      ],
      isDialogVisible: false, // 是创建
      isCreate: false,
      // 导入
      showCRMImport: false,
      // 导出
      showCRMExport: false,
      // 导出选中参数
      exportParams: {},
      crmType: 'business',
      loading: false,
      addLoading: false,
      popSearch: '',
      isFollow: false
    }
  },
  mounted () {
  },
  methods: {
    hiddenView () {
      this.isCreate = false
      this.getList()
    },
    // 选择文件
    selectFile () {
      document.getElementById('importInputFile').click()
    },
    // 获取左边padding
    getPaddingLeft (item, index) {
      if (item.showblock && item.showblock === true) {
        return '25px'
      }
      return item.styleIndex % 2 === 0 ? '0' : '25px'
    },
    // 获取右边padding
    getPaddingRight (item, index) {
      if (item.showblock && item.showblock === true) {
        return '0'
      }
 
      return item.styleIndex % 2 === 0 ? '25px' : '0'
    },
    /** 通过回调控制style */
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      if (
        column.property === 'ChanceName' ||
        column.property === 'CustomerName'
      ) {
        return { color: '#4D88FF', cursor: 'pointer' }
      } else if (column.property === 'ReportStatusName') {
        if (row[column.property] === '审批中') {
          return { color: '#FF8800' }
        } else if (row[column.property] === '通过') {
          return { color: '#2DB300' }
        } else if (row[column.property] === '驳回') {
          return { color: '#FF4D4D' }
        } else {
          return { color: '#333' }
        }
      } else if (column.property === 'TrackStatus') {
        if (row[column.property]) {
          if (row['IsAutoPassed'] === true) {
            return { color: '#2DB300' }
          } else {
            return { color: '#FF4D4D' }
          }
        } else {
          return { color: '#333' }
        }
      } else if (column.property === 'BusinessStatusString') {
        if (row[column.property] === '待上报') {
          return { color: '#FF8800' }
        } else if (row[column.property] === '已上报') {
          return { color: '#2DB300' }
        } else if (row[column.property] === '已拒绝') {
          return { color: '#FF4D4D' }
        } else {
          return { color: '#333' }
        }
      } else {
        return ''
      }
    },
    selectable (row, index) {
      if (row.IsCanDelete) {
        return true
      } else {
        return false
      }
    },
    goFollow (id) {
      this.rowID = id
      this.isFollow = true
      this.rowType = 'business'
      this.showDview = true
      this.timer = new Date().getTime()
      this.$forceUpdate()
    },
    deleteSingleModule (id) {
      this.$confirm('确定删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          DeleteSalesChance([{'Id': id}]).then(res => {
            if (res.data.ErrorCode === 200) {
              this.$message.success(res.data.Message)
              this.getList()
            } else {
              this.$message.error(res.data.Message)
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    exportFile () {
      this.showCRMExport = true
    },
    importFile () {
      this.showCRMImport = true
    },
    queryList (data) {
      this.headObj = data
      this.getList(data)
    },
    /** 筛选操作 */
    handleFilter (data) {
      console.log(data)
      this.filterObj = data
      var offsetHei = document.documentElement.clientHeight
      var removeHeight = Object.keys(this.filterObj).length > 0 ? 310 : 240
      this.tableHeight = offsetHei - removeHeight
      this.currentPage = 1
      this.getList()
    }
 
  }
}
</script>
 
<style lang="scss" scoped>
@import '../styles/table.scss';
#importInputFile {
  display: none;
}
.customer{
  // .xr-btn--orange{
  //   background-color: #ff6a00;
  //   border-color: #ff6a00;
  // }
  .customerName{
    cursor:pointer;
    // color: #ff6a00
  }
}
.container {
  position: relative;
}
 
.header {
  height: 40px;
  padding: 0 10px;
  flex-shrink: 0;
  .name {
    font-size: 13px;
    padding: 0 10px;
    color: #333;
  }
  .detail {
    font-size: 12px;
    padding: 0 10px;
    color: #aaaaaa;
    border-left: 1px solid #aaaaaa;
  }
  .close {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    right: 10px;
    padding: 10px;
  }
}
.content{
  .cropper-box{
    display:flex;
    flex-direction: row;
    align-items: center;
    padding: 0 20px;
    .searchTitle{
      font-size: 14px;
      width: 124px;
      color: #333;
    }
    .searchInput{
      margin-right: 20px;
    }
  }
}
.p-contianer .p-bar{
  margin: 5px 0 0 14px;
}
</style>
<style lang="scss">
.customer{
  /deep/.el-input .el-input-group__append{
    // background-color: #ff7d00;
    // border-color: #ff7d00;
    // color: #fff;
  }
}
/* 新建和编辑 */
.new-dialog-title {
  padding-left: 10px;
  margin-bottom: 3px;
  border-left: 2px solid #4D88FF;
}
.new-busDialog-form {
  height: 47vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
}
.new-busDialog-form /deep/ .el-form-item {
  // width: 50%;
  margin: 0;
  padding-bottom: 10px;
}
.new-busDialog-form /deep/ .el-form-item .el-form-item__label {
  line-height: normal;
  font-size: 13px;
  color: #333333;
  position: relative;
  padding-bottom: 8px;
}
.new-busDialog-form /deep/ .crm-create-item.el-form-item .el-form-item__content {
  width: 70%;
}
.new-busDialog-form /deep/ .crm-create-block-item.el-form-item .el-form-item__content {
  width: 90%;
}
.new-busDialog-form /deep/ .crm-create-block-item.el-form-item .el-form-item__label{
  width: 10% !important;
}
.doubleSelect{
  display: flex;
  flex-direction: row;
  width: 100%;
  .leftSelect{
    margin-right: 10px;
  }
}
.radioList{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  .el-radio{
    flex: 0 0 40%;
    line-height: 24px;
    .el-radio__label{
      color: #666;
      font-size: 16px;
      margin-bottom: 12px;
    }
  }
}
.crm-create-item {
  flex: 0 0 45%;
  flex-shrink: 0;
  // overflow: hidden;
  padding-bottom: 10px;
}
 
// 占用一整行
.crm-create-block-item {
  flex: 0 0 100%;
  flex-shrink: 0;
  padding-bottom: 10px;
}
.nav-dialog-div {
  margin-bottom: 20px;
}
.nav-dialog-div /deep/ .el-input {
  width: auto;
}
.el-table /deep/ .el-button+.el-button{
  margin-left: 3px;
}
</style>