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
<template>
  <el-popover placement="bottom" width="200" trigger="manual" v-model="visible" @show="showPopover">
    <el-select
      v-if="tableType === '企业性质' || tableType === '项目属性' ||tableType === '提交' || tableType === '审批' || tableType === '合同类型'"
      v-model="value"
      filterable
      placeholder="请选择"
      style='width: 100%;'
      @change='getSelect'>
      <el-option
        v-for="(optionItem, index) in optionsList"
        :key="index"
        :label="optionItem"
        :value="optionItem"/>
    </el-select>
    <el-cascader
      v-if="tableType === '行业细分'"
      ref="salesCas"
      :show-all-levels="false"
      placeholder="请选择行业细分"
      :options="optionsList"
      :props="{
        children: 'children',
        label: 'Name',
        value: 'Name'
      }"
      v-model="casVal"
      style="width: 100%;"
      @change='getCas'/>
      <el-select
        v-if="tableType === '商机类型'"
        v-model="busType"
        filterable
        placeholder="请选择"
        style='width: 100%;'
        @change='getSelect'>
        <el-option
          v-for="(optionItem, index) in optionsList"
          :key="index"
          :label="optionItem"
          :value="optionItem"/>
      </el-select>
    <!--<el-input
      placeholder="请输入内容"
      v-model="value"
      clearable
      @keyup.enter.native="confirm"
      ref="sInput"
    >
    </el-input>-->
    <div class='filterBtn'>
      <el-button size="mini" @click="resetData">取消</el-button>
      <el-button type="primary" size="mini" @click="confirm" style="margin-top:5px">确认</el-button>
    </div>
    <div slot="reference" style="margin-left:8px" @click.stop="popClick" v-clickoutside="closeOver" v-show="show">
      <img class="table-filter" src='../../../assets/img/tablefilter.png'/>
    </div>
  </el-popover>
</template>
 
<script>
import { GetIndustryListChildrenData } from '@/api/common'
import Lockr from 'lockr'
export default {
  name: 'CRMTableFilter',
  data () {
    return {
      value: '',
      casVal: '',
      busType: '',
      visible: false,
      iconColor: false,
      optionsList: []
    }
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    tableType: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: ''
    },
    defaultValue: {
      type: String,
      default: ''
    },
    options: {
      type: Array,
      default: function () {
        return []
      }
    },
    defaultProps: {
      type: Object,
      default: function () {
        return {
          label: 'label',
          value: 'value'
        }
      }
    }
  },
  watch: {
    defaultValue (newVal, oldVal) {
      const self = this
      self.value = newVal
    }
 
  },
  mounted () {
    this.getList()
    Lockr.set('comType', '')
    Lockr.set('casType', '')
  },
  methods: {
    showPopover () {
      this.$nextTick(() => {
        // this.$refs.sInput.focus()
      })
    },
    getSelect () {
      console.log(this.value)
      Lockr.set('comType', this.value)
    },
    getCas () {
      Lockr.set('casType', this.casVal[1])
    },
    getList () {
      if (this.tableType === '企业性质') {
        this.optionsList = ['国企', '外企', '民营', '其他']
      } else if (this.tableType === '行业细分') {
        this.getIndustryList()
      } else if (this.tableType === '项目属性') {
        this.optionsList = ['普通项目', 'LC协作', 'ACAD项目', 'ACAD重点客户', 'AEC项目', 'AEC倍增计划', 'MFG项目', 'MNE项目', '企业信息特例', '特别案例', '区域重点客户', '知识产权代理']
      } else if (this.tableType === '商机类型') {
        this.optionsList = ['Other', 'LC', 'ACAD', 'AEC', 'MFG', 'MNE']
      } else if (this.tableType === '提交') {
        this.optionsList = ['待提交', '已提交']
      } else if (this.tableType === '审批') {
        this.optionsList = ['审批中', '通过', '驳回']
      } else if (this.tableType === '合同类型') {
        this.optionsList = ['合同章', '公章']
      }
    },
    getIndustryList () {
      GetIndustryListChildrenData().then(res => {
        if (res.data.ErrorCode === 200) {
          let list = res.data.Result
          let array = this.addLabel(list)
          console.log(array)
          this.optionsList = array
        } else {
          return []
        }
      })
    },
    addLabel (arr) {
      for (let k in arr) {
        arr[k].Name = arr[k].CategoryName || '无类名'
        if (arr[k].IndustryData && arr[k].IndustryData.length < 1) {
          // 当后台返回的children为空时,页面会留空白,把空白部分去掉
          arr[k].children = undefined
        } else {
          arr[k].children = []
          for (let i in arr[k].IndustryData) {
            arr[k].children.push({Name: arr[k].IndustryData[i]})
          }
        }
      }
      return arr
    },
    resetData () {
      this.value = ''
      this.casVal = ''
      this.visible = false
      this.iconColor = false
      Lockr.set('comType', '')
      Lockr.set('casType', '')
      this.$emit('queryList')
    },
    closeOver () {
      this.visible = false
    },
    popClick (e) {
      // e.stopPropagation()
      this.visible = !this.visible
    },
    confirm () {
      this.visible = false
      this.iconColor = true
      if (this.value || this.casVal) {
        this.$emit('queryList', { value: this.value, busType: this.busType, casVal: this.casVal[1], tableType: this.tableType })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.table-filter{
  width: 20px; /*no*/
  height: 20px; /*no*/
  margin-top: 1px;
}
.filterBtn{
  float: right;
  margin-top:12px;
  .el-button{
    width: 40px;
    height: 20px;
    font-size: 12px;
    line-height: 7px;
    padding: 2px;
  }
}
</style>