|
1 | 1 | <template> |
2 | | - |
3 | | - <div class="vol-table" |
4 | | - :class="[cellOverflowHidden?'vol-cell-overflow-hidden':'']"> |
| 2 | + <div |
| 3 | + class="vol-table" |
| 4 | + :class="[cellOverflowHidden ? 'vol-cell-overflow-hidden' : '']" |
| 5 | + > |
5 | 6 | <div class="col-header"> |
6 | | - <div class="col-cell" |
7 | | - :style="getStyle(column)" |
8 | | - v-for="(column,index) in filterColumns()" |
9 | | - :key="index"> |
10 | | - {{column.title}} |
| 7 | + <div |
| 8 | + class="col-cell" |
| 9 | + :style="getStyle(column)" |
| 10 | + v-for="(column, index) in filterColumns()" |
| 11 | + :key="index" |
| 12 | + > |
| 13 | + {{ column.title }} |
11 | 14 | </div> |
12 | 15 | </div> |
13 | | - <PullRefreshList :immediate-check="false" |
14 | | - :default-load="true" |
15 | | - :getUrl="getUrl" |
16 | | - :height="bodyHeight" |
17 | | - httpType="post" |
18 | | - ref="PRL" |
19 | | - :index="'1'"> |
| 16 | + <PullRefreshList |
| 17 | + :immediate-check="false" |
| 18 | + :default-load="true" |
| 19 | + :getUrl="getUrl" |
| 20 | + :height="bodyHeight" |
| 21 | + httpType="post" |
| 22 | + :loadDataAfter="loadDataAfter" |
| 23 | + ref="PRL" |
| 24 | + :index="'1'" |
| 25 | + > |
20 | 26 | <template slot-scope="scope"> |
21 | 27 | <div class="col-body"> |
22 | | - <div class="col-rows" |
23 | | - v-for="(row,index) in scope.list" |
24 | | - :key="index" |
25 | | - @click="rowClick(row,index)"> |
26 | | - <div class="col-cell" |
27 | | - :style="getStyle(column)" |
28 | | - v-for="(column) in fields" |
29 | | - :key="column.field"> |
30 | | - <div v-if="column.type=='img'"> |
31 | | - <img class="tb-cell-img" |
32 | | - v-for="(imgItem,imgIndex) in getImgs(row[column.field])" |
33 | | - :src="imgItem" |
34 | | - :key="imgIndex" /> |
| 28 | + <div |
| 29 | + class="col-rows" |
| 30 | + v-for="(row, index) in scope.list" |
| 31 | + :key="index" |
| 32 | + @click="rowClick(row, index)" |
| 33 | + > |
| 34 | + <div |
| 35 | + class="col-cell" |
| 36 | + :style="getStyle(column)" |
| 37 | + v-for="column in fields" |
| 38 | + :key="column.field" |
| 39 | + > |
| 40 | + <div v-if="column.type == 'img'"> |
| 41 | + <img |
| 42 | + class="tb-cell-img" |
| 43 | + v-for="(imgItem, imgIndex) in getImgs(row[column.field])" |
| 44 | + :src="imgItem" |
| 45 | + :key="imgIndex" |
| 46 | + /> |
35 | 47 | </div> |
36 | | - <div v-else-if="column.formatter" |
37 | | - v-html="column.formatter(row[column.field],row,column)"></div> |
38 | | - <template v-else-if="column.bind"> {{converDicValue( row[column.field],column)}}</template> |
39 | | - <template v-else> {{ row[column.field]}}</template> |
| 48 | + <div |
| 49 | + v-else-if="column.formatter" |
| 50 | + v-html="column.formatter(row[column.field], row, column)" |
| 51 | + ></div> |
| 52 | + <template v-else-if="column.bind"> |
| 53 | + {{ converDicValue(row[column.field], column) }}</template |
| 54 | + > |
| 55 | + <template v-else> {{ row[column.field] }}</template> |
40 | 56 | </div> |
41 | 57 | </div> |
42 | 58 | </div> |
43 | 59 | </template> |
44 | 60 | </PullRefreshList> |
45 | 61 | </div> |
46 | | - |
47 | 62 | </template> |
48 | 63 | <script> |
49 | 64 | import PullRefreshList from "@/components/PullRefreshList.vue"; |
50 | 65 | export default { |
51 | 66 | components: { |
52 | | - PullRefreshList |
| 67 | + PullRefreshList, |
53 | 68 | }, |
54 | 69 | props: { |
55 | | - cellOverflowHidden: {//单元格超出是否隐藏 |
| 70 | + cellOverflowHidden: { |
| 71 | + //单元格超出是否隐藏 |
56 | 72 | type: Boolean, |
57 | | - defalut: false |
| 73 | + defalut: false, |
58 | 74 | }, |
59 | 75 | height: { |
60 | 76 | type: Number, |
61 | | - default: 0 |
| 77 | + default: 0, |
62 | 78 | }, |
63 | | - queryParams: { //查询的参数 |
| 79 | + queryParams: { |
| 80 | + //查询的参数 |
64 | 81 | type: Function, |
65 | 82 | default: () => { |
66 | | - return [] |
67 | | - } |
| 83 | + return []; |
| 84 | + }, |
68 | 85 | }, |
69 | 86 | url: { |
70 | | - type: String, default: "" |
| 87 | + type: String, |
| 88 | + default: "", |
71 | 89 | }, |
72 | 90 | rowClick: { |
73 | 91 | type: Function, |
74 | 92 | default: () => { |
75 | | - return "" |
76 | | - } |
| 93 | + return ""; |
| 94 | + }, |
77 | 95 | }, |
78 | 96 | columns: { |
79 | 97 | type: Array, |
80 | 98 | default: () => { |
81 | 99 | return []; |
82 | | - } |
83 | | - } |
| 100 | + }, |
| 101 | + }, |
84 | 102 | }, |
85 | | - data () { |
| 103 | + data() { |
86 | 104 | return { |
87 | 105 | bodyHeigth: 0, |
88 | 106 | fields: [], |
89 | 107 | keySource: {}, |
90 | | - imgFields: [],//图片字段 |
91 | | - list: [] |
92 | | - } |
| 108 | + imgFields: [], //图片字段 |
| 109 | + list: [], |
| 110 | + }; |
93 | 111 | }, |
94 | 112 | methods: { |
95 | | - getCellStyle (column) { |
| 113 | + getCellStyle(column) { |
96 | 114 | if (column.type == "img") { |
97 | | - return { "line-height": "40px" } |
| 115 | + return { "line-height": "40px" }; |
98 | 116 | } |
99 | 117 | return ""; |
100 | 118 | }, |
101 | | - getImgs (imgs) { |
| 119 | + getImgs(imgs) { |
102 | 120 | if (!imgs) return []; |
103 | | - var _imgs = imgs.split(','); |
104 | | - return _imgs.filter(x => { return x }).map(m => { |
105 | | - if (m.substr(0, 4) == "http") { |
106 | | - return m; |
107 | | - } |
108 | | - return this.http.ipAddress + m; |
109 | | - }) |
| 121 | + var _imgs = imgs.split(","); |
| 122 | + return _imgs |
| 123 | + .filter((x) => { |
| 124 | + return x; |
| 125 | + }) |
| 126 | + .map((m) => { |
| 127 | + if (m.substr(0, 4) == "http") { |
| 128 | + return m; |
| 129 | + } |
| 130 | + return this.http.ipAddress + m; |
| 131 | + }); |
110 | 132 | }, |
111 | | - reload () { |
| 133 | + reload() { |
112 | 134 | this.$refs.PRL.refresh(); |
113 | 135 | }, |
114 | | - filterColumns () { |
115 | | - return this.columns.filter(x => { |
116 | | - return !x.hidden |
117 | | - }) |
| 136 | + filterColumns() { |
| 137 | + return this.columns.filter((x) => { |
| 138 | + return !x.hidden; |
| 139 | + }); |
118 | 140 | }, |
119 | | - getStyle (column) { |
| 141 | + getStyle(column) { |
120 | 142 | if (column.width) { |
121 | | - return 'width:' + column.width + 'px' |
| 143 | + return "width:" + column.width + "px"; |
122 | 144 | } |
123 | | - return 'flex: 1' |
| 145 | + return "flex: 1"; |
124 | 146 | }, |
125 | | - isEmpty (val) { |
126 | | -
|
127 | | - return val === "" || val === null || val === undefined |
128 | | -
|
129 | | - }, converDicValue (val, column) { |
| 147 | + isEmpty(val) { |
| 148 | + return val === "" || val === null || val === undefined; |
| 149 | + }, |
| 150 | + converDicValue(val, column) { |
130 | 151 | if (this.isEmpty(val)) return ""; |
131 | 152 | if (column.bind.type == "selectList") { |
132 | 153 | var _values = []; |
133 | 154 | var _array = (val + "").split(","); |
134 | 155 | for (let index = 0; index < _array.length; index++) { |
135 | 156 | if (!this.isEmpty(_array[index])) { |
136 | | - _values.push(this.getDicValue(_array[index], column)) |
| 157 | + _values.push(this.getDicValue(_array[index], column)); |
137 | 158 | } |
138 | 159 | } |
139 | | - return _values.join(',') |
| 160 | + return _values.join(","); |
140 | 161 | } |
141 | 162 | return this.getDicValue(val, column); |
142 | 163 | }, |
143 | | - getDicValue (val, column) { |
144 | | - var kv = column.bind.data.find(x => { return x.key + "" === val + "" }); |
| 164 | + getDicValue(val, column) { |
| 165 | + var kv = column.bind.data.find((x) => { |
| 166 | + return x.key + "" === val + ""; |
| 167 | + }); |
145 | 168 | return kv ? kv.value : val; |
146 | 169 | }, |
147 | | - getUrl () { |
| 170 | + getUrl() { |
148 | 171 | var params = {}; |
149 | 172 | params.wheres = this.queryParams(); |
150 | | - return { url: this.url, params: { wheres: JSON.stringify(params.wheres) } } |
151 | | - } |
| 173 | + return { |
| 174 | + url: this.url, |
| 175 | + params: { wheres: JSON.stringify(params.wheres) }, |
| 176 | + }; |
| 177 | + }, |
| 178 | + loadDataAfter(rows) { |
| 179 | + this.$emit("loadTableAfter", rows); |
| 180 | + }, |
152 | 181 | }, |
153 | | - created () { |
| 182 | + created() { |
154 | 183 | if (!this.height) { |
155 | 184 | this.bodyHeight = document.body.clientHeight - 92; |
156 | 185 | } else { |
157 | 186 | this.bodyHeight = this.height; |
158 | 187 | } |
159 | | - var keys = [] |
160 | | - this.columns.forEach(x => { |
| 188 | + var keys = []; |
| 189 | + this.columns.forEach((x) => { |
161 | 190 | if (!x.hidden) { |
162 | 191 | this.fields.push(x); |
163 | 192 | if (x.bind && x.bind.key) { |
164 | 193 | if (!x.bind.data) { |
165 | | - x.bind.data = [] |
| 194 | + x.bind.data = []; |
166 | 195 | } |
167 | 196 | if (!x.bind.data.length) { |
168 | | - keys.push(x.bind.key) |
| 197 | + keys.push(x.bind.key); |
169 | 198 | } |
170 | 199 | this.keySource[x.bind.key] = x.bind.data; |
171 | 200 | } |
172 | 201 | } |
173 | | - }) |
| 202 | + }); |
174 | 203 | if (keys.length) { |
175 | 204 | this.http |
176 | 205 | .post("/api/Sys_Dictionary/GetVueDictionary", keys) |
177 | 206 | .then((dic) => { |
178 | 207 | dic.forEach((x) => { |
179 | | - x.data.forEach(x => { |
| 208 | + x.data.forEach((x) => { |
180 | 209 | x.key = x.key + ""; |
181 | | - }) |
182 | | - this.keySource[x.dicNo].push(...x.data) |
| 210 | + }); |
| 211 | + this.keySource[x.dicNo].push(...x.data); |
183 | 212 | }); |
184 | 213 | }); |
185 | 214 | } |
186 | 215 |
|
187 | | - this.http.post("/api/Sys_Log/getPageData", {}, true).then(x => { |
188 | | - //this.$emit("loadTableAfter", x.rows); |
189 | | -
|
| 216 | + this.http.post("/api/Sys_Log/getPageData", {}, true).then((x) => { |
| 217 | + this.loadDataAfter(x.rows); |
190 | 218 | this.list = x.rows; |
191 | | - }) |
192 | | - } |
193 | | -} |
| 219 | + }); |
| 220 | + }, |
| 221 | +}; |
194 | 222 | </script> |
195 | 223 | <style lang="less" scoped> |
196 | 224 | .col-header { |
|
0 commit comments