yangfeng
2023-08-18 96fdf32bd5612b6c16dcbcc8352a9f54adcc8e7e
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
<template>
  <div class="collectionPlan">
    <div v-if="isDetail" class="detail-top">
      <DetailListCommonBtn :query-class-options="queryClassOptions" />
      <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
    </div>
    <div v-else class="top">
      <SearchCommonView
        ref="searchCommonView"
        :query-class-options="queryClassOptions"
        :search-options="searchOptions"
        :search-sel="searchSel"
        @searchClick="searchClick"
        @resetClick="resetClick"
      />
      <div class="btn-pager">
        <PublicFunctionBtnView :statistics="true" :operates-list="operatesList" @batchDelete="delClick" />
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    <TableCommonView
      ref="tableListRef"
      v-loading="loading"
      :table-list="tableList"
      :select-box="!isDetail"
      @getSelectArray="getSelectArray"
    >
      <!-- <template slot="tableButton">
        <el-table-column label="操作" width="60" fixed="right">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </template> -->
    </TableCommonView>
    <!-- 新建/编辑 -->
    <AddCollectionPlan v-if="editConfig.visible" :edit-common-config="editConfig" />
  </div>
</template>
 
<script>
import { getCollectionPlanList } from "@/api/common/payment"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import AddCollectionPlan from "@/views/other/payment/collectionPlan/AddCollectionPlan"
 
export default {
  name: "CollectionPlan",
  props: {
    isDetail: {
      type: Boolean,
      default: false
    },
    addConfig: {
      type: Object,
      default: () => {
        return {}
      }
    },
    sourceType: {
      type: Number,
      default: 1
    }
  },
  mixins: [pageMixin],
  components: { AddCollectionPlan },
  computed: {},
  data() {
    return {
      tableList: {},
      loading: false,
      activeName: "second",
      queryClassValue: "1",
      queryClassOptions: [
        { value: "1", label: "全部" },
        { value: "2", label: "今日联系" },
        { value: "3", label: "本周联系" },
        { value: "4", label: "本月联系" }
      ],
      searchOptions: [],
      operatesList: [
        { id: "1", name: "共享" },
        { id: "2", name: "批量编辑" },
        { id: "3", name: "导出" },
        { id: "4", name: "下载全部附件" },
        { id: "5", name: "更改创建人" },
        { id: "6", name: "树结构设置" },
        { id: "7", name: "审批设置" },
        { id: "8", name: "回访预设列宽" }
      ],
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      saleChanceName: "",
      contactsDeail: {
        visible: false,
        infomation: {}
      },
      clientDeail: {
        visible: false,
        infomation: {}
      },
      selValueList: [],
      searchSel: {
        value: "topic",
        label: ""
      },
      search_map: {},
      serviceContractId: 0
    }
  },
  created() {
    this.setTable()
    console.log(this.addConfig)
    if (!this.isDetail) {
      this.serviceContractId = 0
    } else {
      this.serviceContractId = this.addConfig.id
    }
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [],
        tableColumn: [
          { label: "收款计划编号", prop: "number" },
          { label: "客户名称", prop: "client_name" },
          { label: "期次", prop: "term" },
          { label: "计划收款日期", prop: "collectionDate" },
          { label: "金额", prop: "amount" },
          { label: "已收金额", prop: "amountReceived" },
          { label: "应收金额", prop: "amountReceivable" },
          { label: "负责人", prop: "member_name" }
        ]
      }
      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 })
      }
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getCollectionPlanList({
        serviceContractId: this.serviceContractId
      })
        .then((res) => {
          if (res.data.code === 200) {
            if (res.data.data.data && res.data.data.data.length > 0) {
              const list = res.data.data.data.map((item) => {
                return {
                  ...item
                }
              })
              this.tableList.tableInfomation = list || []
              this.pagerOptions.totalCount = res.data.data.count
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    // 搜索
    searchClick(val, content) {
      this.serviceContractId = content
      // this.keywordType = val.label
      this.getData()
    },
    resetClick() {
      this.serviceContractId = ""
      // this.keywordType = ""
      this.getData()
    },
    getSelectArray(val) {
      console.log(val)
      this.selValueList = []
      const list = val.map((item) => {
        return item.id
      })
      this.selValueList = list
    },
    // 新建
    addBtnClick() {
      if (this.tableList.tableInfomation && this.tableList.tableInfomation.length > 0) {
        this.$confirm("该订单已创建收款计划", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {})
          .catch(() => {})
      } else {
        this.editConfig.visible = true
        this.editConfig.title = "新建"
        this.editConfig.sourceType = this.sourceType
        this.editConfig.infomation = { ...this.addConfig }
      }
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.collectionPlan {
  .top {
    margin-bottom: 20px;
    .btn-pager {
      display: flex;
      .page {
        margin-left: auto;
      }
    }
  }
  .detail-top {
    display: flex;
    .page {
      margin-left: auto;
    }
  }
}
</style>