Blame view

admin-web-master/src/components/change/cl.vue 8.42 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>
2210df30   wesley88   1
28
29
30
31
32
33
                <el-table-column label="租金价格(元/m²)" prop="rentalPrice" show-overflow-tooltip>
                  <template slot-scope="scope" >
                    <span v-if="scope.row.rentalPrice!=''">{{scope.row.rentalPrice}}元/m²</span>
                    <span v-else>无</span>
                  </template>
                </el-table-column>
a182f238   wesley88   1
34
                <el-table-column label="付款周期" prop="leaseTerm" show-overflow-tooltip></el-table-column>
523cfe19   wesley88   1
35
                <!-- <el-table-column label="付款日" prop="payDay" show-overflow-tooltip></el-table-column> -->
a182f238   wesley88   1
36
37
38
39
40
41
42
              </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
43
44
45
        <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
46
        </el-pagination>
9d8bcb26   wesley88   2
47
48
49
      </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
50
51
        <el-button @click="cancel" class="buttonHover"
          style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">取消</el-button>
9d8bcb26   wesley88   2
52
53
54
55
56
      </div>
    </div>
  </template>
  
  <script>
ad921312   wesley88   1
57
58
59
      import {
      cereResourceStrategylist
    } from '@/api/newly.js'
9d8bcb26   wesley88   2
60
61
62
    import {
      ceGetAll
    } from '@/api/sam.js'
ad921312   wesley88   1
63
  
a182f238   wesley88   1
64
65
66
67
68
    export default {
      name: 'PolicySelector',
      data() {
        return {
          total: 0,
9d8bcb26   wesley88   2
69
          pageindex: {
9b392fc6   wesley88   1
70
            isTemplate: "1",
a182f238   wesley88   1
71
72
73
            pageNumber: 0,
            pageSize: 5,
            policyName: ''
9d8bcb26   wesley88   2
74
          },
a182f238   wesley88   1
75
          selectedRows: [],
ad921312   wesley88   1
76
77
78
79
80
81
82
          celueData: [],
          changelist: [],
          yelist: [
  
          ], //页码处理数据
          isone:false,
          datalist:[]
a182f238   wesley88   1
83
        };
9d8bcb26   wesley88   2
84
      },
ad921312   wesley88   1
85
86
87
88
89
90
91
92
93
94
95
      async created() {
  
        await this.getAll()
        this.intdatalist()
      },
      props: {
        resourcesId: {
          type: String,
          default: function () {
            return ''
          }
e75fe4fe   wesley88   2
96
97
98
99
100
101
102
        },
        type: {
          type: String,
          default: function () {
            return ''
          }
        },
9d8bcb26   wesley88   2
103
      },
a182f238   wesley88   1
104
      methods: {
ad921312   wesley88   1
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
        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
174
        async getAll() {
e75fe4fe   wesley88   2
175
          const celue = await ceGetAll({...this.pageindex,applicableResources:this.type})
a182f238   wesley88   1
176
177
          this.celueData = celue.data.content
          this.total = celue.data.totalElements
ad921312   wesley88   1
178
  
a182f238   wesley88   1
179
        },
ad921312   wesley88   1
180
181
182
183
184
185
186
        async handleCurrentChange(val) {
          this.isone = false
          this.pageindex.pageNumber = val - 1
          await this.getAll()
          this.$nextTick(() => {
            this.setchange()
          })
a182f238   wesley88   1
187
188
189
190
191
192
193
194
195
        },
        handleSizeChange(val) {
          this.pageindex.pageSize = val
        },
        onSearch() {
          this.pageindex.pageNumber = 0
          this.getAll()
        },
        resetting() {
ad921312   wesley88   1
196
          this.pageindex = {
a182f238   wesley88   1
197
198
199
200
201
202
203
204
            pageNumber: 0,
            pageSize: 5,
            policyName: ''
          }
          this.getAll()
        },
        handleSelectionChange(selection) {
          this.selectedRows = selection;
ad921312   wesley88   1
205
206
207
208
209
210
211
          // 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
212
213
        },
        confirm() {
ad921312   wesley88   1
214
215
216
217
218
219
220
221
222
223
224
          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
225
226
227
228
        },
        cancel() {
          this.$emit('mingClose');
        }
9d8bcb26   wesley88   2
229
      }
a182f238   wesley88   1
230
    };
9d8bcb26   wesley88   2
231
232
233
  </script>
  
  <style scoped>
a182f238   wesley88   1
234
235
    .policy-selector {
      padding: 20px;
c3bca151   wesley88   1
236
      /* padding: 20px;
a182f238   wesley88   1
237
238
      width: 100%;
      margin: 0 auto;
c3bca151   wesley88   1
239
      border: 1px solid #ddd; */
a182f238   wesley88   1
240
241
242
      /* border-radius: 4px; */
      /* box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); */
    }
9d8bcb26   wesley88   2
243
  
a182f238   wesley88   1
244
245
246
247
    .policy-selector-header {
      text-align: left;
      margin-bottom: 20px;
    }
9d8bcb26   wesley88   2
248
  
a182f238   wesley88   1
249
250
251
252
253
    .policy-selector-header h3 {
      margin: 0;
      font-size: 18px;
      color: #303133;
    }
9d8bcb26   wesley88   2
254
  
a182f238   wesley88   1
255
256
257
    .policy-selector-content {
      margin-bottom: 20px;
    }
9d8bcb26   wesley88   2
258
  
a182f238   wesley88   1
259
260
261
262
263
    .policy-selector-footer {
      display: flex;
      justify-content: flex-end;
      align-items: center;
    }
c3bca151   wesley88   1
264
265
266
    ::v-deep .el-dialog__body {
      padding: 0 0 !important;
    }
a182f238   wesley88   1
267
  </style>