|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="app-container">
|
|
|
3
|
+ <el-card shadow="never">
|
|
|
4
|
+ <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
|
|
|
5
|
+ <el-form-item>
|
|
|
6
|
+ <template slot="label">{{ dmT("queryAlertDate") }}</template>
|
|
|
7
|
+ <el-date-picker
|
|
|
8
|
+ v-model="queryDateRange"
|
|
|
9
|
+ type="daterange"
|
|
|
10
|
+ value-format="yyyy-MM-dd"
|
|
|
11
|
+ range-separator="-"
|
|
|
12
|
+ :start-placeholder="dmT('queryDateRangePh')"
|
|
|
13
|
+ :end-placeholder="dmT('queryDateRangeEndPh')"
|
|
|
14
|
+ clearable
|
|
|
15
|
+ style="width: 240px"
|
|
|
16
|
+ />
|
|
|
17
|
+ </el-form-item>
|
|
|
18
|
+ <el-form-item prop="dataSource">
|
|
|
19
|
+ <template slot="label">{{ dmT("queryDataSource") }}</template>
|
|
|
20
|
+ <el-select
|
|
|
21
|
+ v-model="queryParams.dataSource"
|
|
|
22
|
+ :placeholder="dmCommon('pleaseSelect')"
|
|
|
23
|
+ clearable
|
|
|
24
|
+ style="width: 180px"
|
|
|
25
|
+ >
|
|
|
26
|
+ <el-option
|
|
|
27
|
+ v-for="item in dataSourceOptions"
|
|
|
28
|
+ :key="item.value"
|
|
|
29
|
+ :label="item.label"
|
|
|
30
|
+ :value="item.value"
|
|
|
31
|
+ />
|
|
|
32
|
+ </el-select>
|
|
|
33
|
+ </el-form-item>
|
|
|
34
|
+ <el-form-item prop="subjectName">
|
|
|
35
|
+ <template slot="label">{{ dmT("querySubjectName") }}</template>
|
|
|
36
|
+ <el-input
|
|
|
37
|
+ v-model="queryParams.subjectName"
|
|
|
38
|
+ :placeholder="dmT('phSubjectName')"
|
|
|
39
|
+ clearable
|
|
|
40
|
+ style="width: 180px"
|
|
|
41
|
+ @keyup.enter.native="handleQuery"
|
|
|
42
|
+ />
|
|
|
43
|
+ </el-form-item>
|
|
|
44
|
+ <el-form-item>
|
|
|
45
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ dmCommon("search") }}</el-button>
|
|
|
46
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ dmCommon("reset") }}</el-button>
|
|
|
47
|
+ </el-form-item>
|
|
|
48
|
+ </el-form>
|
|
|
49
|
+ </el-card>
|
|
|
50
|
+
|
|
|
51
|
+ <br />
|
|
|
52
|
+
|
|
|
53
|
+ <el-card shadow="never">
|
|
|
54
|
+ <el-table v-loading="loading" :data="tableList" border>
|
|
|
55
|
+ <template slot="empty">
|
|
|
56
|
+ <span>{{ dmT("emptyList") }}</span>
|
|
|
57
|
+ </template>
|
|
|
58
|
+ <el-table-column :label="dmT('colAlertTime')" prop="alertTime" align="center" width="170" />
|
|
|
59
|
+ <el-table-column :label="dmT('colDataSource')" align="center" min-width="110">
|
|
|
60
|
+ <template slot-scope="scope">{{ dataSourceText(scope.row.dataSource) }}</template>
|
|
|
61
|
+ </el-table-column>
|
|
|
62
|
+ <el-table-column :label="dmT('colStatYear')" prop="statYear" align="center" width="90" />
|
|
|
63
|
+ <el-table-column :label="dmT('colStatMonth')" align="center" width="80">
|
|
|
64
|
+ <template slot-scope="scope">{{ formatStatMonth(scope.row.statMonth) }}</template>
|
|
|
65
|
+ </el-table-column>
|
|
|
66
|
+ <el-table-column :label="dmT('colTownName')" prop="townName" align="center" min-width="100" :show-overflow-tooltip="true" />
|
|
|
67
|
+ <el-table-column :label="dmT('colVillageName')" prop="villageName" align="center" min-width="100" :show-overflow-tooltip="true" />
|
|
|
68
|
+ <el-table-column :label="dmT('colSubjectName')" prop="subjectName" align="center" min-width="120" :show-overflow-tooltip="true" />
|
|
|
69
|
+ <el-table-column :label="dmT('colApprovedCarryingCapacity')" align="center" min-width="130">
|
|
|
70
|
+ <template slot-scope="scope">{{ formatDecimal(scope.row.approvedCarryingCapacity) }}</template>
|
|
|
71
|
+ </el-table-column>
|
|
|
72
|
+ <el-table-column :label="dmT('colYearEndStockSheepUnit')" align="center" min-width="130">
|
|
|
73
|
+ <template slot-scope="scope">{{ formatDecimal(scope.row.yearEndStockSheepUnit) }}</template>
|
|
|
74
|
+ </el-table-column>
|
|
|
75
|
+ <el-table-column :label="dmT('colAlertMessage')" prop="alertMessage" align="center" min-width="200" :show-overflow-tooltip="true" />
|
|
|
76
|
+ <el-table-column :label="dmCommon('colOp')" align="center" class-name="small-padding fixed-width" width="100" fixed="right">
|
|
|
77
|
+ <template slot-scope="scope">
|
|
|
78
|
+ <el-button
|
|
|
79
|
+ v-hasPermi="['dataModel:grassLivestockImbalanceWarning:query']"
|
|
|
80
|
+ type="text"
|
|
|
81
|
+ size="mini"
|
|
|
82
|
+ @click="handleView(scope.row)"
|
|
|
83
|
+ >{{ dmCommon("view") }}</el-button>
|
|
|
84
|
+ </template>
|
|
|
85
|
+ </el-table-column>
|
|
|
86
|
+ </el-table>
|
|
|
87
|
+ <pagination
|
|
|
88
|
+ v-show="total > 0"
|
|
|
89
|
+ :total="total"
|
|
|
90
|
+ :page.sync="queryParams.pageNum"
|
|
|
91
|
+ :limit.sync="queryParams.pageSize"
|
|
|
92
|
+ @pagination="getList"
|
|
|
93
|
+ />
|
|
|
94
|
+ </el-card>
|
|
|
95
|
+
|
|
|
96
|
+ <el-dialog :title="dmT('viewTitle')" :visible.sync="viewOpen" width="720px" append-to-body>
|
|
|
97
|
+ <el-form class="dm-view-form gliw-form" label-width="160px" size="small">
|
|
|
98
|
+ <div class="gliw-section-title">{{ dmT("sectionBasic") }}</div>
|
|
|
99
|
+ <el-form-item :label="dmT('formAlertTime')"><span>{{ viewRow.alertTime || dash }}</span></el-form-item>
|
|
|
100
|
+ <el-form-item :label="dmT('formDataSource')"><span>{{ dataSourceText(viewRow.dataSource) }}</span></el-form-item>
|
|
|
101
|
+ <el-form-item :label="dmT('formSourceKey')"><span>{{ viewRow.sourceKey || dash }}</span></el-form-item>
|
|
|
102
|
+ <el-form-item :label="dmT('formStatYear')"><span>{{ viewRow.statYear || dash }}</span></el-form-item>
|
|
|
103
|
+ <el-form-item :label="dmT('formStatMonth')"><span>{{ formatStatMonth(viewRow.statMonth) }}</span></el-form-item>
|
|
|
104
|
+ <el-form-item :label="dmT('formTown')"><span>{{ viewRow.townName || dash }}</span></el-form-item>
|
|
|
105
|
+ <el-form-item :label="dmT('formVillage')"><span>{{ viewRow.villageName || dash }}</span></el-form-item>
|
|
|
106
|
+ <el-form-item :label="dmT('formSubjectName')"><span>{{ viewRow.subjectName || dash }}</span></el-form-item>
|
|
|
107
|
+
|
|
|
108
|
+ <div class="gliw-section-title">{{ dmT("sectionBalance") }}</div>
|
|
|
109
|
+ <el-form-item :label="dmT('formApprovedCarryingCapacity')">
|
|
|
110
|
+ <span>{{ formatWithUnit(formatDecimal(viewRow.approvedCarryingCapacity), "unitSheepUnit") }}</span>
|
|
|
111
|
+ </el-form-item>
|
|
|
112
|
+ <el-form-item :label="dmT('formYearEndStockSheepUnit')">
|
|
|
113
|
+ <span>{{ formatWithUnit(formatDecimal(viewRow.yearEndStockSheepUnit), "unitSheepUnit") }}</span>
|
|
|
114
|
+ </el-form-item>
|
|
|
115
|
+ <el-form-item :label="dmT('formAlertMessage')">
|
|
|
116
|
+ <span class="gliw-message-text">{{ viewRow.alertMessage || dash }}</span>
|
|
|
117
|
+ </el-form-item>
|
|
|
118
|
+ </el-form>
|
|
|
119
|
+ <div slot="footer" class="dialog-footer">
|
|
|
120
|
+ <el-button type="primary" @click="viewOpen = false">{{ dmCommon("close") }}</el-button>
|
|
|
121
|
+ </div>
|
|
|
122
|
+ </el-dialog>
|
|
|
123
|
+ </div>
|
|
|
124
|
+</template>
|
|
|
125
|
+
|
|
|
126
|
+<script>
|
|
|
127
|
+import dataModelLocaleMixin from "@/mixins/dataModelLocaleMixin"
|
|
|
128
|
+import {
|
|
|
129
|
+ listGrassLivestockImbalanceWarning,
|
|
|
130
|
+ getGrassLivestockImbalanceWarning
|
|
|
131
|
+} from "@/api/dataModel/grassLivestockImbalanceWarning"
|
|
|
132
|
+
|
|
|
133
|
+const DATA_SOURCE_FAMILY_RANCH = "family_ranch"
|
|
|
134
|
+const DATA_SOURCE_FARMER_HOUSEHOLD = "farmer_household"
|
|
|
135
|
+const DATA_SOURCE_LARGE_LIVESTOCK_FARMER = "large_livestock_farmer"
|
|
|
136
|
+
|
|
|
137
|
+export default {
|
|
|
138
|
+ name: "GrassLivestockImbalanceWarning",
|
|
|
139
|
+ mixins: [dataModelLocaleMixin],
|
|
|
140
|
+ data() {
|
|
|
141
|
+ return {
|
|
|
142
|
+ dmNs: "grassLivestockImbalanceWarning",
|
|
|
143
|
+ loading: false,
|
|
|
144
|
+ tableList: [],
|
|
|
145
|
+ total: 0,
|
|
|
146
|
+ queryDateRange: null,
|
|
|
147
|
+ queryParams: {
|
|
|
148
|
+ pageNum: 1,
|
|
|
149
|
+ pageSize: 20,
|
|
|
150
|
+ startDate: undefined,
|
|
|
151
|
+ endDate: undefined,
|
|
|
152
|
+ dataSource: undefined,
|
|
|
153
|
+ subjectName: undefined
|
|
|
154
|
+ },
|
|
|
155
|
+ viewOpen: false,
|
|
|
156
|
+ viewRow: {}
|
|
|
157
|
+ }
|
|
|
158
|
+ },
|
|
|
159
|
+ computed: {
|
|
|
160
|
+ dash() {
|
|
|
161
|
+ return this.$t("dataModel.status.dash")
|
|
|
162
|
+ },
|
|
|
163
|
+ dataSourceOptions() {
|
|
|
164
|
+ return [
|
|
|
165
|
+ { value: DATA_SOURCE_FAMILY_RANCH, label: this.dmT("dataSourceFamilyRanch") },
|
|
|
166
|
+ { value: DATA_SOURCE_FARMER_HOUSEHOLD, label: this.dmT("dataSourceFarmerHousehold") },
|
|
|
167
|
+ { value: DATA_SOURCE_LARGE_LIVESTOCK_FARMER, label: this.dmT("dataSourceLargeLivestockFarmer") }
|
|
|
168
|
+ ]
|
|
|
169
|
+ }
|
|
|
170
|
+ },
|
|
|
171
|
+ created() {
|
|
|
172
|
+ this.getList()
|
|
|
173
|
+ },
|
|
|
174
|
+ methods: {
|
|
|
175
|
+ dataSourceText(code) {
|
|
|
176
|
+ if (!code) {
|
|
|
177
|
+ return this.dash
|
|
|
178
|
+ }
|
|
|
179
|
+ const hit = this.dataSourceOptions.find((item) => item.value === code)
|
|
|
180
|
+ return hit ? hit.label : code
|
|
|
181
|
+ },
|
|
|
182
|
+ formatStatMonth(month) {
|
|
|
183
|
+ if (month == null || month === "") {
|
|
|
184
|
+ return this.dash
|
|
|
185
|
+ }
|
|
|
186
|
+ return this.dmT("statMonthLabel", { month })
|
|
|
187
|
+ },
|
|
|
188
|
+ formatDecimal(val) {
|
|
|
189
|
+ if (val == null || val === "") {
|
|
|
190
|
+ return this.dash
|
|
|
191
|
+ }
|
|
|
192
|
+ const n = Number(val)
|
|
|
193
|
+ if (!Number.isFinite(n)) {
|
|
|
194
|
+ return this.dash
|
|
|
195
|
+ }
|
|
|
196
|
+ return String(val)
|
|
|
197
|
+ },
|
|
|
198
|
+ buildListQuery() {
|
|
|
199
|
+ const q = {
|
|
|
200
|
+ pageNum: this.queryParams.pageNum,
|
|
|
201
|
+ pageSize: this.queryParams.pageSize
|
|
|
202
|
+ }
|
|
|
203
|
+ if (this.queryParams.startDate) {
|
|
|
204
|
+ q.startDate = this.queryParams.startDate
|
|
|
205
|
+ }
|
|
|
206
|
+ if (this.queryParams.endDate) {
|
|
|
207
|
+ q.endDate = this.queryParams.endDate
|
|
|
208
|
+ }
|
|
|
209
|
+ if (this.queryParams.dataSource) {
|
|
|
210
|
+ q.dataSource = this.queryParams.dataSource
|
|
|
211
|
+ }
|
|
|
212
|
+ if (this.queryParams.subjectName) {
|
|
|
213
|
+ q.subjectName = this.queryParams.subjectName
|
|
|
214
|
+ }
|
|
|
215
|
+ return q
|
|
|
216
|
+ },
|
|
|
217
|
+ checkQueryDateRange() {
|
|
|
218
|
+ if (this.queryDateRange && this.queryDateRange.length === 2) {
|
|
|
219
|
+ const [start, end] = this.queryDateRange
|
|
|
220
|
+ if (start && end && start > end) {
|
|
|
221
|
+ this.$modal.msgWarning(this.dmT("dateRangeInvalid"))
|
|
|
222
|
+ return false
|
|
|
223
|
+ }
|
|
|
224
|
+ }
|
|
|
225
|
+ return true
|
|
|
226
|
+ },
|
|
|
227
|
+ syncDateRangeToQuery() {
|
|
|
228
|
+ if (this.queryDateRange && this.queryDateRange.length === 2) {
|
|
|
229
|
+ this.queryParams.startDate = this.queryDateRange[0]
|
|
|
230
|
+ this.queryParams.endDate = this.queryDateRange[1]
|
|
|
231
|
+ } else {
|
|
|
232
|
+ this.queryParams.startDate = undefined
|
|
|
233
|
+ this.queryParams.endDate = undefined
|
|
|
234
|
+ }
|
|
|
235
|
+ },
|
|
|
236
|
+ getList() {
|
|
|
237
|
+ if (!this.checkQueryDateRange()) {
|
|
|
238
|
+ return
|
|
|
239
|
+ }
|
|
|
240
|
+ this.syncDateRangeToQuery()
|
|
|
241
|
+ this.loading = true
|
|
|
242
|
+ listGrassLivestockImbalanceWarning(this.buildListQuery())
|
|
|
243
|
+ .then((res) => {
|
|
|
244
|
+ this.tableList = res.rows || []
|
|
|
245
|
+ this.total = res.total || 0
|
|
|
246
|
+ })
|
|
|
247
|
+ .finally(() => {
|
|
|
248
|
+ this.loading = false
|
|
|
249
|
+ })
|
|
|
250
|
+ },
|
|
|
251
|
+ handleQuery() {
|
|
|
252
|
+ this.queryParams.pageNum = 1
|
|
|
253
|
+ this.getList()
|
|
|
254
|
+ },
|
|
|
255
|
+ resetQuery() {
|
|
|
256
|
+ this.queryDateRange = null
|
|
|
257
|
+ this.queryParams = {
|
|
|
258
|
+ pageNum: 1,
|
|
|
259
|
+ pageSize: 20,
|
|
|
260
|
+ startDate: undefined,
|
|
|
261
|
+ endDate: undefined,
|
|
|
262
|
+ dataSource: undefined,
|
|
|
263
|
+ subjectName: undefined
|
|
|
264
|
+ }
|
|
|
265
|
+ this.$nextTick(() => {
|
|
|
266
|
+ if (this.$refs.queryForm) {
|
|
|
267
|
+ this.$refs.queryForm.resetFields()
|
|
|
268
|
+ }
|
|
|
269
|
+ })
|
|
|
270
|
+ this.getList()
|
|
|
271
|
+ },
|
|
|
272
|
+ handleView(row) {
|
|
|
273
|
+ getGrassLivestockImbalanceWarning(row.id).then((res) => {
|
|
|
274
|
+ this.viewRow = res.data || {}
|
|
|
275
|
+ this.viewOpen = true
|
|
|
276
|
+ })
|
|
|
277
|
+ }
|
|
|
278
|
+ }
|
|
|
279
|
+}
|
|
|
280
|
+</script>
|
|
|
281
|
+
|
|
|
282
|
+<style scoped>
|
|
|
283
|
+.gliw-section-title {
|
|
|
284
|
+ margin: 4px 0 12px;
|
|
|
285
|
+ font-weight: 600;
|
|
|
286
|
+ color: #303133;
|
|
|
287
|
+}
|
|
|
288
|
+.gliw-message-text {
|
|
|
289
|
+ white-space: pre-wrap;
|
|
|
290
|
+ word-break: break-all;
|
|
|
291
|
+}
|
|
|
292
|
+</style>
|