haoxuan
2023-10-10 b169e0fe3ecad3713880626bd6152c58d8ed4222
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
<template>
  <div class="edit-selClient-box">
    <el-dialog
      :title="'销售机会'"
      :visible.sync="editConfig.editVisible"
      :width="dialogWidth"
      :before-close="handleClose"
      :append-to-body="true"
      :close-on-click-modal="false"
    >
      <div class="bg-view">
        <div class="query-bg">
          <SearchCommonView
            ref="searchCommonView"
            :search-options="searchOptions"
            @searchClick="searchClick"
            @resetClick="resetClick"
          />
          <div class="btn">
            <!-- <el-button type="primary" size="mini" disabled>设置字段</el-button>
            <el-button type="primary" size="mini" disabled>快速创建</el-button> -->
          </div>
        </div>
        <TableCommonView
          ref="tableListRef"
          v-loading="loading"
          :table-list="tableList"
          :select-box="false"
          @selCommonClick="selNameClick"
          @selTableCol="selTableCol"
        >
        </TableCommonView>
        <div slot="footer" class="dialog-footer">
          <!-- <div class="remark">说明:支持多字段模糊查询,仅显示符合条件的前5条数据</div> -->
          <div class="btn-pager">
            <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { getSaleChanceList } from "@/api/sales/salesOpportunity"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
export default {
  name: "EditSelChanceDialog",
  mixins: [pageMixin],
  props: {
    editCommonConfig: {
      type: Object,
      default: () => {
        return {
          editVisible: false,
          title: "",
          infomation: {}
        }
      }
    }
  },
  components: {},
  computed: {},
  data() {
    return {
      dialogWidth: "50%",
      editConfig: this.editCommonConfig,
      queryInput: "",
      select: "1",
      tableList: [],
      searchSelOptions: [],
      loading: false,
      search_map: {},
      tableColumn: [
        { label: "销售机会编号", prop: "number" }, // 销售机会编号
        { label: "机会名称", prop: "name", isCommonClick: true, default: true }, // 机会名称
        { label: "销售阶段", prop: "sale_stage_name" }, // 销售阶段
        { label: "销售负责人", prop: "member_name" }, // 销售负责人
        { label: "预计成交日期", prop: "expected_time" } // 预计成交日期
      ],
      showCol: ["销售机会编号", "机会名称", "销售阶段", "销售负责人", "预计成交日期"]
    }
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        selectIndex: true,
        tableInfomation: [],
        allcol: [],
        showcol: this.showCol,
        tableColumn: this.setColumnVisible(this.showCol)
      }
      this.tableList.allcol = this.tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
        const value = this.tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    setColumnVisible(showCol) {
      return this.tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
        }
      })
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
    },
    handleClose() {
      this.editConfig.editVisible = false
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getSaleChanceList({
        search_map: this.search_map,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          console.log(res)
          if (res.code === 200) {
            if (res.data.list && res.data.list.length > 0) {
              const list = res.data.list.map((item) => {
                return {
                  ...item,
                  member_name: item.member.username,
                  sale_stage_name: item.sale_stage.name
                }
              })
              this.tableList.tableInfomation = list || []
              this.pagerOptions.totalCount = res.data.count
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    selNameClick(row) {
      this.editConfig.editVisible = false
      console.log(row)
      this.$emit("selClient", row, "chance")
    },
    // 搜索
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      this.getData()
    },
    resetClick() {
      this.search_map = {}
      this.getData()
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.bg-view {
  margin: 10px;
  .query-bg {
    margin-left: -20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .el-input {
      width: 310px;
      .el-select {
        width: 100px;
      }
    }
    .btn {
      float: right;
    }
  }
}
.sel-name {
  color: $color-primary;
  cursor: pointer;
}
.dialog-footer {
  height: 50px;
  line-height: 50px;
  color: red;
  .btn-pager {
    display: flex;
    margin-top: 0px;
    .page {
      margin-left: auto;
    }
  }
}
::v-deep {
  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }
}
</style>