Blame view

admin-web-master/src/components/change/cl.vue 8.29 KB
9d8bcb26   wesley88   2
1
2
  <template>
    <div class="policy-selector">
a182f238   wesley88   1
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
      <div class="policy-selector-content">
        <div style="border: 1px solid #E5E5E5;padding: 1px" id="huodong">
          <div
            style="padding: 10px 13px;font-size: 14px;border-bottom: 1px solid #E5E5E5;display: flex;justify-content: space-between;">
            <div style="line-height:200%">选择策略</div>
            <div style="display: flex">
              <el-input placeholder="请输入" suffix-icon="el-icon-search" style="margin-right:15px;width: 40%;"
                v-model="pageindex.policyName">
              </el-input>
              <el-button @click="onSearch" style="background-color: #3F9B6A;color: #fff">查询
              </el-button>
              <el-button @click="resetting" class="buttonHover"
                style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">重置
              </el-button>
            </div>
          </div>
          <div style="padding: 15px;">
            <div style="padding: 0px 20px 0px 0px;max-height:40vh;overflow-y: auto;">
ad921312   wesley88   1
21
22
              <el-table ref="multipleTable" :data="celueData" tooltip-effect="dark"
                @selection-change="handleSelectionChange"
a182f238   wesley88   1
23
24
25
26
27
                :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}">
                <el-table-column label="选择" type="selection" width="55">
                </el-table-column>
                <el-table-column label="策略名称" prop="policyName" show-overflow-tooltip></el-table-column>
                <el-table-column label="适用资源" prop="applicableResources" show-overflow-tooltip></el-table-column>
0e7a57c2   杨鑫   '最新'
28
29
30
31
32
                <el-table-column label="租金价格(/M²)" prop="rentalPrice" show-overflow-tooltip>
  				  <template slot-scope="scope">
  				    {{scope.row.rentalPrice}}/M²
  				  </template>
  			  </el-table-column>
a182f238   wesley88   1
33
                <el-table-column label="付款周期" prop="leaseTerm" show-overflow-tooltip></el-table-column>
523cfe19   wesley88   1
34
                <!-- <el-table-column label="付款日" prop="payDay" show-overflow-tooltip></el-table-column> -->
a182f238   wesley88   1
35
36
37
38
39
40
41
              </el-table>
            </div>
          </div>
        </div>
      </div>
      <div style="display: flex;justify-content: space-between;margin: 20px 0;" class="bom">
        <div style="font-size: 14px;">共 <span style="color: #3F9B6A;">{{total}}</span> 项数据</div>
ad921312   wesley88   1
42
43
44
        <el-pagination :current-page="pageindex.pageNumber+1" :page-sizes="[5,10, 20, 50, 100]"
          :page-size="pageindex.pageSize" background small layout="prev, pager, next" :total="total"
          @size-change="handleSizeChange" @current-change="handleCurrentChange">
a182f238   wesley88   1
45
        </el-pagination>
9d8bcb26   wesley88   2
46
47
48
      </div>
      <div class="policy-selector-footer" style="display: flex; justify-content: flex-end; align-items: center;">
        <el-button @click="confirm" style="background-color: #3F9B6A;color: #fff;">确定</el-button>
a182f238   wesley88   1
49
50
        <el-button @click="cancel" class="buttonHover"
          style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">取消</el-button>
9d8bcb26   wesley88   2
51
52
53
54
55
      </div>
    </div>
  </template>
  
  <script>
ad921312   wesley88   1
56
57
58
      import {
      cereResourceStrategylist
    } from '@/api/newly.js'
9d8bcb26   wesley88   2
59
60
61
    import {
      ceGetAll
    } from '@/api/sam.js'
ad921312   wesley88   1
62
  
a182f238   wesley88   1
63
64
65
66
67
    export default {
      name: 'PolicySelector',
      data() {
        return {
          total: 0,
9d8bcb26   wesley88   2
68
          pageindex: {
9b392fc6   wesley88   1
69
            isTemplate: "1",
a182f238   wesley88   1
70
71
72
            pageNumber: 0,
            pageSize: 5,
            policyName: ''
9d8bcb26   wesley88   2
73
          },
a182f238   wesley88   1
74
          selectedRows: [],
ad921312   wesley88   1
75
76
77
78
79
80
81
          celueData: [],
          changelist: [],
          yelist: [
  
          ], //页码处理数据
          isone:false,
          datalist:[]
a182f238   wesley88   1
82
        };
9d8bcb26   wesley88   2
83
      },
ad921312   wesley88   1
84
85
86
87
88
89
90
91
92
93
94
      async created() {
  
        await this.getAll()
        this.intdatalist()
      },
      props: {
        resourcesId: {
          type: String,
          default: function () {
            return ''
          }
e75fe4fe   wesley88   2
95
96
97
98
99
100
101
        },
        type: {
          type: String,
          default: function () {
            return ''
          }
        },
9d8bcb26   wesley88   2
102
      },
a182f238   wesley88   1
103
      methods: {
ad921312   wesley88   1
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
        async intdatalist() {
          let c1 = {
            pageNumber: 0,
            pageSize: 10,
            resourcesId: this.resourcesId
          }
          await cereResourceStrategylist(c1).then(res => {
            console.error(res)
            if (!Array.isArray(res.data)) {
              this.datalist = [];
              return;
            }
            this.datalist = res.data
          })
          let listfy = []
          const celue = await ceGetAll({
            pageNumber: 0,
            pageSize: 100
          })
          const total = celue.data.totalElements > 0 ? Math.ceil(celue.data.totalElements / this.pageindex.pageSize) : 0
          for (let index = 0; index < total; index++) {
            const element = {
              num: index,
              list: []
            }
            for (let i = 0; i < this.pageindex.pageSize; i++) {
              if ((index * (this.pageindex.pageSize)) + i < celue.data.totalElements) {
                const element1 = celue.data.content[(index * (this.pageindex.pageSize)) + i];
                var iscz = this.datalist.findIndex(item => item.id === element1.id)
                if (iscz == -1) { //说明arr中不存在id为objid的对象
                } else {
                  element.list.push(element1)
                }
              }
  
            }
  
            listfy.push(element)
          }
          console.log(listfy)
          this.yelist = listfy
          if (this.yelist.length > 0) {
            this.setchange()
          }
  
        },
        toggleSelection(rows) {
          // console.error(rows)
          for (let index = 0; index < rows.length; index++) {
            const element = rows[index];
            this.changelist.push(element)
          }
        },
        setchange() {
          // console.error('改变已选中')
          // console.error(this.yelist[this.pageindex.pageNumber])
          for (let index = 0; index < this.yelist[this.pageindex.pageNumber].list.length; index++) {
            const element = this.yelist[this.pageindex.pageNumber].list[index];
            // console.error(element)
            for (let i = 0; i < this.celueData.length; i++) {
              const element1 = this.celueData[i];
              if (element.id == element1.id) {
                // console.error(element1.id)
                this.$refs.multipleTable.toggleRowSelection(element1);
              }
            }
          }
          this.isone =  true
        },
a182f238   wesley88   1
173
        async getAll() {
e75fe4fe   wesley88   2
174
          const celue = await ceGetAll({...this.pageindex,applicableResources:this.type})
a182f238   wesley88   1
175
176
          this.celueData = celue.data.content
          this.total = celue.data.totalElements
ad921312   wesley88   1
177
  
a182f238   wesley88   1
178
        },
ad921312   wesley88   1
179
180
181
182
183
184
185
        async handleCurrentChange(val) {
          this.isone = false
          this.pageindex.pageNumber = val - 1
          await this.getAll()
          this.$nextTick(() => {
            this.setchange()
          })
a182f238   wesley88   1
186
187
188
189
190
191
192
193
194
        },
        handleSizeChange(val) {
          this.pageindex.pageSize = val
        },
        onSearch() {
          this.pageindex.pageNumber = 0
          this.getAll()
        },
        resetting() {
ad921312   wesley88   1
195
          this.pageindex = {
a182f238   wesley88   1
196
197
198
199
200
201
202
203
            pageNumber: 0,
            pageSize: 5,
            policyName: ''
          }
          this.getAll()
        },
        handleSelectionChange(selection) {
          this.selectedRows = selection;
ad921312   wesley88   1
204
205
206
207
208
209
210
          // console.error('改变')
          // console.error(this.selectedRows)
          if(this.isone) {
            // console.error('--------')
            this.yelist[this.pageindex.pageNumber].list = JSON.parse(JSON.stringify(this.selectedRows))
          }
          
a182f238   wesley88   1
211
212
        },
        confirm() {
ad921312   wesley88   1
213
214
215
216
217
218
219
220
221
222
223
          var list = []
          for (let i = 0; i < this.yelist.length; i++) {
            let item = this.yelist[i]
            if(item.list) {
              for (let index = 0; index < item.list.length; index++) {
                const element = item.list[index];
                list.push(element)
              }
            }
          }
          this.$emit('minSev',list);
a182f238   wesley88   1
224
225
226
227
        },
        cancel() {
          this.$emit('mingClose');
        }
9d8bcb26   wesley88   2
228
      }
a182f238   wesley88   1
229
    };
9d8bcb26   wesley88   2
230
231
232
  </script>
  
  <style scoped>
a182f238   wesley88   1
233
234
    .policy-selector {
      padding: 20px;
c3bca151   wesley88   1
235
      /* padding: 20px;
a182f238   wesley88   1
236
237
      width: 100%;
      margin: 0 auto;
c3bca151   wesley88   1
238
      border: 1px solid #ddd; */
a182f238   wesley88   1
239
240
241
      /* border-radius: 4px; */
      /* box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); */
    }
9d8bcb26   wesley88   2
242
  
a182f238   wesley88   1
243
244
245
246
    .policy-selector-header {
      text-align: left;
      margin-bottom: 20px;
    }
9d8bcb26   wesley88   2
247
  
a182f238   wesley88   1
248
249
250
251
252
    .policy-selector-header h3 {
      margin: 0;
      font-size: 18px;
      color: #303133;
    }
9d8bcb26   wesley88   2
253
  
a182f238   wesley88   1
254
255
256
    .policy-selector-content {
      margin-bottom: 20px;
    }
9d8bcb26   wesley88   2
257
  
a182f238   wesley88   1
258
259
260
261
262
    .policy-selector-footer {
      display: flex;
      justify-content: flex-end;
      align-items: center;
    }
c3bca151   wesley88   1
263
264
265
    ::v-deep .el-dialog__body {
      padding: 0 0 !important;
    }
a182f238   wesley88   1
266
  </style>