|
|
@@ -0,0 +1,844 @@
|
|
|
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 prop="statYear">
|
|
|
6
|
+ <template slot="label">{{ dmT("queryStatYear") }}</template>
|
|
|
7
|
+ <el-select v-model="queryParams.statYear" :placeholder="dmCommon('pleaseSelect')" clearable style="width: 120px">
|
|
|
8
|
+ <el-option v-for="y in yearOptions" :key="y" :label="String(y)" :value="y" />
|
|
|
9
|
+ </el-select>
|
|
|
10
|
+ </el-form-item>
|
|
|
11
|
+ <el-form-item prop="statMonth">
|
|
|
12
|
+ <template slot="label">{{ dmT("queryStatMonth") }}</template>
|
|
|
13
|
+ <el-select v-model="queryParams.statMonth" :placeholder="dmCommon('pleaseSelect')" clearable style="width: 120px">
|
|
|
14
|
+ <el-option v-for="m in monthOptions" :key="'q-' + m" :label="formatStatMonth(m)" :value="m" />
|
|
|
15
|
+ </el-select>
|
|
|
16
|
+ </el-form-item>
|
|
|
17
|
+ <el-form-item prop="townDeptId">
|
|
|
18
|
+ <template slot="label">{{ dmT("queryTown") }}</template>
|
|
|
19
|
+ <el-select v-model="queryParams.townDeptId" :placeholder="dmCommon('pleaseSelect')" clearable filterable style="width: 180px">
|
|
|
20
|
+ <el-option v-for="item in townOptions" :key="item.deptId" :label="item.deptName" :value="item.deptId" />
|
|
|
21
|
+ </el-select>
|
|
|
22
|
+ </el-form-item>
|
|
|
23
|
+ <el-form-item prop="villageDeptId">
|
|
|
24
|
+ <template slot="label">{{ dmT("queryVillage") }}</template>
|
|
|
25
|
+ <el-select
|
|
|
26
|
+ v-model="queryParams.villageDeptId"
|
|
|
27
|
+ :placeholder="dmT('phVillageSearch')"
|
|
|
28
|
+ clearable
|
|
|
29
|
+ filterable
|
|
|
30
|
+ style="width: 220px"
|
|
|
31
|
+ >
|
|
|
32
|
+ <el-option
|
|
|
33
|
+ v-for="item in villageOptions"
|
|
|
34
|
+ :key="'q-v-' + item.deptId"
|
|
|
35
|
+ :label="item.label"
|
|
|
36
|
+ :value="item.deptId"
|
|
|
37
|
+ />
|
|
|
38
|
+ </el-select>
|
|
|
39
|
+ </el-form-item>
|
|
|
40
|
+ <el-form-item>
|
|
|
41
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ dmCommon("search") }}</el-button>
|
|
|
42
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ dmCommon("reset") }}</el-button>
|
|
|
43
|
+ <el-button
|
|
|
44
|
+ v-hasPermi="['dataModel:livestockOwnershipHousehold:add']"
|
|
|
45
|
+ type="primary"
|
|
|
46
|
+ plain
|
|
|
47
|
+ icon="el-icon-plus"
|
|
|
48
|
+ size="mini"
|
|
|
49
|
+ @click="handleAdd"
|
|
|
50
|
+ >{{ dmCommon("add") }}</el-button>
|
|
|
51
|
+ <el-button
|
|
|
52
|
+ v-hasPermi="['dataModel:livestockOwnershipHousehold:import']"
|
|
|
53
|
+ type="info"
|
|
|
54
|
+ plain
|
|
|
55
|
+ icon="el-icon-upload2"
|
|
|
56
|
+ size="mini"
|
|
|
57
|
+ @click="handleImportOpen"
|
|
|
58
|
+ >{{ dmT("btnImport") }}</el-button>
|
|
|
59
|
+ <el-button
|
|
|
60
|
+ v-hasPermi="['dataModel:livestockOwnershipHousehold:export']"
|
|
|
61
|
+ type="warning"
|
|
|
62
|
+ plain
|
|
|
63
|
+ icon="el-icon-download"
|
|
|
64
|
+ size="mini"
|
|
|
65
|
+ @click="handleExportOpen"
|
|
|
66
|
+ >{{ dmCommon("export") }}</el-button>
|
|
|
67
|
+ </el-form-item>
|
|
|
68
|
+ </el-form>
|
|
|
69
|
+ </el-card>
|
|
|
70
|
+
|
|
|
71
|
+ <br />
|
|
|
72
|
+
|
|
|
73
|
+ <el-card shadow="never">
|
|
|
74
|
+ <el-table v-loading="loading" :data="tableList" border>
|
|
|
75
|
+ <template slot="empty">
|
|
|
76
|
+ <span>{{ dmT("emptyList") }}</span>
|
|
|
77
|
+ </template>
|
|
|
78
|
+ <el-table-column :label="dmT('colStatYear')" prop="statYear" align="center" width="90" fixed />
|
|
|
79
|
+ <el-table-column :label="dmT('colStatMonth')" align="center" width="80" fixed>
|
|
|
80
|
+ <template slot-scope="scope">{{ formatStatMonth(scope.row.statMonth) }}</template>
|
|
|
81
|
+ </el-table-column>
|
|
|
82
|
+ <el-table-column :label="dmT('colTownName')" prop="townName" align="center" min-width="100" :show-overflow-tooltip="true" />
|
|
|
83
|
+ <el-table-column :label="dmT('colVillageName')" prop="villageName" align="center" min-width="100" :show-overflow-tooltip="true" />
|
|
|
84
|
+ <el-table-column :label="dmT('colWithHousehold')" align="center" width="100">
|
|
|
85
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withLivestockHouseholdCount) }}</template>
|
|
|
86
|
+ </el-table-column>
|
|
|
87
|
+ <el-table-column :label="dmT('colWithPopulation')" align="center" width="100">
|
|
|
88
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withLivestockPopulationCount) }}</template>
|
|
|
89
|
+ </el-table-column>
|
|
|
90
|
+ <el-table-column :label="dmT('colWithLabor')" align="center" width="100">
|
|
|
91
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withLivestockLaborCount) }}</template>
|
|
|
92
|
+ </el-table-column>
|
|
|
93
|
+ <el-table-column :label="dmT('colWithAnimal')" align="center" width="110">
|
|
|
94
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withLivestockAnimalCount) }}</template>
|
|
|
95
|
+ </el-table-column>
|
|
|
96
|
+ <el-table-column :label="dmT('colWithoutHousehold')" align="center" width="100">
|
|
|
97
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withoutLivestockHouseholdCount) }}</template>
|
|
|
98
|
+ </el-table-column>
|
|
|
99
|
+ <el-table-column :label="dmT('colWithoutPopulation')" align="center" width="100">
|
|
|
100
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withoutLivestockPopulationCount) }}</template>
|
|
|
101
|
+ </el-table-column>
|
|
|
102
|
+ <el-table-column :label="dmT('colWithoutLabor')" align="center" width="100">
|
|
|
103
|
+ <template slot-scope="scope">{{ formatCount(scope.row.withoutLivestockLaborCount) }}</template>
|
|
|
104
|
+ </el-table-column>
|
|
|
105
|
+ <el-table-column :label="dmCommon('colOp')" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
|
|
|
106
|
+ <template slot-scope="scope">
|
|
|
107
|
+ <el-button v-hasPermi="['dataModel:livestockOwnershipHousehold:query']" type="text" size="mini" @click="handleView(scope.row)">{{ dmCommon("view") }}</el-button>
|
|
|
108
|
+ <el-button v-hasPermi="['dataModel:livestockOwnershipHousehold:edit']" type="text" size="mini" @click="handleEdit(scope.row)">{{ dmCommon("edit") }}</el-button>
|
|
|
109
|
+ <el-button v-hasPermi="['dataModel:livestockOwnershipHousehold:remove']" type="text" size="mini" @click="handleDelete(scope.row)">{{ dmCommon("delete") }}</el-button>
|
|
|
110
|
+ </template>
|
|
|
111
|
+ </el-table-column>
|
|
|
112
|
+ </el-table>
|
|
|
113
|
+ <pagination
|
|
|
114
|
+ v-show="total > 0"
|
|
|
115
|
+ :total="total"
|
|
|
116
|
+ :page.sync="queryParams.pageNum"
|
|
|
117
|
+ :limit.sync="queryParams.pageSize"
|
|
|
118
|
+ @pagination="getList"
|
|
|
119
|
+ />
|
|
|
120
|
+ </el-card>
|
|
|
121
|
+
|
|
|
122
|
+ <el-dialog :title="dialogTitle" :visible.sync="open" width="680px" append-to-body @close="cancel">
|
|
|
123
|
+ <el-form :key="formKey" ref="form" :model="form" class="loh-form" label-width="120px" size="small">
|
|
|
124
|
+ <div class="loh-section-title">{{ dmT("sectionBasic") }}</div>
|
|
|
125
|
+ <el-form-item prop="statYear" :rules="formRules.statYear">
|
|
|
126
|
+ <template slot="label">{{ dmT("formStatYear") }}</template>
|
|
|
127
|
+ <el-select v-model="form.statYear" :placeholder="dmCommon('pleaseSelect')" style="width: 100%">
|
|
|
128
|
+ <el-option v-for="y in yearOptions" :key="'f-' + y" :label="String(y)" :value="y" />
|
|
|
129
|
+ </el-select>
|
|
|
130
|
+ </el-form-item>
|
|
|
131
|
+ <el-form-item prop="statMonth" :rules="formRules.statMonth">
|
|
|
132
|
+ <template slot="label">{{ dmT("formStatMonth") }}</template>
|
|
|
133
|
+ <el-select v-model="form.statMonth" :placeholder="dmCommon('pleaseSelect')" style="width: 100%">
|
|
|
134
|
+ <el-option v-for="m in monthOptions" :key="'fm-' + m" :label="formatStatMonth(m)" :value="m" />
|
|
|
135
|
+ </el-select>
|
|
|
136
|
+ </el-form-item>
|
|
|
137
|
+ <el-form-item prop="villageDeptId" :rules="formRules.villageDeptId">
|
|
|
138
|
+ <template slot="label">{{ dmT("formVillage") }}</template>
|
|
|
139
|
+ <el-select
|
|
|
140
|
+ v-model="form.villageDeptId"
|
|
|
141
|
+ :placeholder="dmT('phVillageSearch')"
|
|
|
142
|
+ filterable
|
|
|
143
|
+ clearable
|
|
|
144
|
+ style="width: 100%"
|
|
|
145
|
+ >
|
|
|
146
|
+ <el-option
|
|
|
147
|
+ v-for="item in villageOptions"
|
|
|
148
|
+ :key="'f-v-' + item.deptId"
|
|
|
149
|
+ :label="item.label"
|
|
|
150
|
+ :value="item.deptId"
|
|
|
151
|
+ />
|
|
|
152
|
+ </el-select>
|
|
|
153
|
+ </el-form-item>
|
|
|
154
|
+
|
|
|
155
|
+ <div class="loh-section-title">{{ dmT("sectionWith") }}</div>
|
|
|
156
|
+ <el-form-item prop="withLivestockHouseholdCount" :rules="formRules.count">
|
|
|
157
|
+ <template slot="label">{{ dmT("formHouseholdCount") }}</template>
|
|
|
158
|
+ <div class="dm-input-with-unit">
|
|
|
159
|
+ <el-input-number v-model="form.withLivestockHouseholdCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
160
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitHousehold") }}</span>
|
|
|
161
|
+ </div>
|
|
|
162
|
+ </el-form-item>
|
|
|
163
|
+ <el-form-item prop="withLivestockPopulationCount" :rules="formRules.count">
|
|
|
164
|
+ <template slot="label">{{ dmT("formPopulationCount") }}</template>
|
|
|
165
|
+ <div class="dm-input-with-unit">
|
|
|
166
|
+ <el-input-number v-model="form.withLivestockPopulationCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
167
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitPerson") }}</span>
|
|
|
168
|
+ </div>
|
|
|
169
|
+ </el-form-item>
|
|
|
170
|
+ <el-form-item prop="withLivestockLaborCount" :rules="formRules.count">
|
|
|
171
|
+ <template slot="label">{{ dmT("formLaborCount") }}</template>
|
|
|
172
|
+ <div class="dm-input-with-unit">
|
|
|
173
|
+ <el-input-number v-model="form.withLivestockLaborCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
174
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitPerson") }}</span>
|
|
|
175
|
+ </div>
|
|
|
176
|
+ </el-form-item>
|
|
|
177
|
+ <el-form-item prop="withLivestockAnimalCount" :rules="formRules.count">
|
|
|
178
|
+ <template slot="label">{{ dmT("formAnimalCount") }}</template>
|
|
|
179
|
+ <div class="dm-input-with-unit">
|
|
|
180
|
+ <el-input-number v-model="form.withLivestockAnimalCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
181
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitHeadPiece") }}</span>
|
|
|
182
|
+ </div>
|
|
|
183
|
+ </el-form-item>
|
|
|
184
|
+
|
|
|
185
|
+ <div class="loh-section-title">{{ dmT("sectionWithout") }}</div>
|
|
|
186
|
+ <el-form-item prop="withoutLivestockHouseholdCount" :rules="formRules.count">
|
|
|
187
|
+ <template slot="label">{{ dmT("formHouseholdCount") }}</template>
|
|
|
188
|
+ <div class="dm-input-with-unit">
|
|
|
189
|
+ <el-input-number v-model="form.withoutLivestockHouseholdCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
190
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitHousehold") }}</span>
|
|
|
191
|
+ </div>
|
|
|
192
|
+ </el-form-item>
|
|
|
193
|
+ <el-form-item prop="withoutLivestockPopulationCount" :rules="formRules.count">
|
|
|
194
|
+ <template slot="label">{{ dmT("formPopulationCount") }}</template>
|
|
|
195
|
+ <div class="dm-input-with-unit">
|
|
|
196
|
+ <el-input-number v-model="form.withoutLivestockPopulationCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
197
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitPerson") }}</span>
|
|
|
198
|
+ </div>
|
|
|
199
|
+ </el-form-item>
|
|
|
200
|
+ <el-form-item prop="withoutLivestockLaborCount" :rules="formRules.count">
|
|
|
201
|
+ <template slot="label">{{ dmT("formLaborCount") }}</template>
|
|
|
202
|
+ <div class="dm-input-with-unit">
|
|
|
203
|
+ <el-input-number v-model="form.withoutLivestockLaborCount" :min="0" :precision="0" controls-position="right" class="dm-input-with-unit__input" />
|
|
|
204
|
+ <span class="dm-input-with-unit__suffix">{{ dmT("unitPerson") }}</span>
|
|
|
205
|
+ </div>
|
|
|
206
|
+ </el-form-item>
|
|
|
207
|
+
|
|
|
208
|
+ <el-form-item prop="remark" :rules="formRules.remark">
|
|
|
209
|
+ <template slot="label">{{ dmT("formRemark") }}</template>
|
|
|
210
|
+ <el-input v-model="form.remark" type="textarea" :rows="2" :placeholder="dmT('phRemark')" maxlength="500" show-word-limit />
|
|
|
211
|
+ </el-form-item>
|
|
|
212
|
+ </el-form>
|
|
|
213
|
+ <div slot="footer" class="dialog-footer">
|
|
|
214
|
+ <el-button type="primary" @click="submitForm">{{ dmCommon("ok") }}</el-button>
|
|
|
215
|
+ <el-button @click="cancel">{{ dmCommon("cancel") }}</el-button>
|
|
|
216
|
+ </div>
|
|
|
217
|
+ </el-dialog>
|
|
|
218
|
+
|
|
|
219
|
+ <el-dialog :title="dmCommon('viewTitle')" :visible.sync="viewOpen" width="680px" append-to-body>
|
|
|
220
|
+ <el-form class="dm-view-form loh-form" label-width="120px" size="small">
|
|
|
221
|
+ <div class="loh-section-title">{{ dmT("sectionBasic") }}</div>
|
|
|
222
|
+ <el-form-item :label="dmT('formStatYear')"><span>{{ viewRow.statYear || dash }}</span></el-form-item>
|
|
|
223
|
+ <el-form-item :label="dmT('formStatMonth')"><span>{{ formatStatMonth(viewRow.statMonth) }}</span></el-form-item>
|
|
|
224
|
+ <el-form-item :label="dmT('formTown')"><span>{{ viewRow.townName || dash }}</span></el-form-item>
|
|
|
225
|
+ <el-form-item :label="dmT('formVillage')"><span>{{ viewRow.villageName || dash }}</span></el-form-item>
|
|
|
226
|
+
|
|
|
227
|
+ <div class="loh-section-title">{{ dmT("sectionWith") }}</div>
|
|
|
228
|
+ <el-form-item :label="dmT('formHouseholdCount')">
|
|
|
229
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withLivestockHouseholdCount), "unitHousehold") }}</span>
|
|
|
230
|
+ </el-form-item>
|
|
|
231
|
+ <el-form-item :label="dmT('formPopulationCount')">
|
|
|
232
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withLivestockPopulationCount), "unitPerson") }}</span>
|
|
|
233
|
+ </el-form-item>
|
|
|
234
|
+ <el-form-item :label="dmT('formLaborCount')">
|
|
|
235
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withLivestockLaborCount), "unitPerson") }}</span>
|
|
|
236
|
+ </el-form-item>
|
|
|
237
|
+ <el-form-item :label="dmT('formAnimalCount')">
|
|
|
238
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withLivestockAnimalCount), "unitHeadPiece") }}</span>
|
|
|
239
|
+ </el-form-item>
|
|
|
240
|
+
|
|
|
241
|
+ <div class="loh-section-title">{{ dmT("sectionWithout") }}</div>
|
|
|
242
|
+ <el-form-item :label="dmT('formHouseholdCount')">
|
|
|
243
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withoutLivestockHouseholdCount), "unitHousehold") }}</span>
|
|
|
244
|
+ </el-form-item>
|
|
|
245
|
+ <el-form-item :label="dmT('formPopulationCount')">
|
|
|
246
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withoutLivestockPopulationCount), "unitPerson") }}</span>
|
|
|
247
|
+ </el-form-item>
|
|
|
248
|
+ <el-form-item :label="dmT('formLaborCount')">
|
|
|
249
|
+ <span>{{ formatWithUnit(formatCount(viewRow.withoutLivestockLaborCount), "unitPerson") }}</span>
|
|
|
250
|
+ </el-form-item>
|
|
|
251
|
+
|
|
|
252
|
+ <el-form-item :label="dmT('formRemark')">
|
|
|
253
|
+ <span class="loh-view-text">{{ viewRow.remark || dash }}</span>
|
|
|
254
|
+ </el-form-item>
|
|
|
255
|
+ </el-form>
|
|
|
256
|
+ <div slot="footer" class="dialog-footer">
|
|
|
257
|
+ <el-button v-hasPermi="['dataModel:livestockOwnershipHousehold:edit']" type="primary" @click="handleEditFromView">{{ dmCommon("edit") }}</el-button>
|
|
|
258
|
+ <el-button @click="viewOpen = false">{{ dmCommon("close") }}</el-button>
|
|
|
259
|
+ </div>
|
|
|
260
|
+ </el-dialog>
|
|
|
261
|
+
|
|
|
262
|
+ <el-dialog :title="dmT('importTitle')" :visible.sync="importOpen" width="480px" append-to-body @close="resetImport">
|
|
|
263
|
+ <el-form ref="importFormRef" :model="importForm" label-width="100px" size="small">
|
|
|
264
|
+ <el-form-item prop="statYear" :rules="importRules.statYear">
|
|
|
265
|
+ <template slot="label">{{ dmT("importStatYear") }}</template>
|
|
|
266
|
+ <el-select v-model="importForm.statYear" :placeholder="dmT('importStatYearPh')" style="width: 100%">
|
|
|
267
|
+ <el-option v-for="y in yearOptions" :key="'iy-' + y" :label="String(y)" :value="y" />
|
|
|
268
|
+ </el-select>
|
|
|
269
|
+ </el-form-item>
|
|
|
270
|
+ <el-form-item prop="statMonth" :rules="importRules.statMonth">
|
|
|
271
|
+ <template slot="label">{{ dmT("importStatMonth") }}</template>
|
|
|
272
|
+ <el-select v-model="importForm.statMonth" :placeholder="dmT('importStatMonthPh')" style="width: 100%">
|
|
|
273
|
+ <el-option v-for="m in monthOptions" :key="'im-' + m" :label="formatStatMonth(m)" :value="m" />
|
|
|
274
|
+ </el-select>
|
|
|
275
|
+ </el-form-item>
|
|
|
276
|
+ <p class="loh-import-tip">{{ dmT("importTip") }}</p>
|
|
|
277
|
+ <el-upload ref="importUpload" drag :limit="1" accept=".xlsx,.xls" :auto-upload="false" action="#">
|
|
|
278
|
+ <i class="el-icon-upload" />
|
|
|
279
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
280
|
+ <div slot="tip" class="el-upload__tip">
|
|
|
281
|
+ <el-link type="primary" :underline="false" @click="handleDownloadTemplate">{{ dmT("btnDownloadTemplate") }}</el-link>
|
|
|
282
|
+ </div>
|
|
|
283
|
+ </el-upload>
|
|
|
284
|
+ </el-form>
|
|
|
285
|
+ <div slot="footer" class="dialog-footer">
|
|
|
286
|
+ <el-button type="primary" :loading="importing" @click="handleImportSubmit">{{ dmCommon("ok") }}</el-button>
|
|
|
287
|
+ <el-button @click="importOpen = false">{{ dmCommon("cancel") }}</el-button>
|
|
|
288
|
+ </div>
|
|
|
289
|
+ </el-dialog>
|
|
|
290
|
+
|
|
|
291
|
+ <el-dialog :title="dmT('exportTitle')" :visible.sync="exportOpen" width="480px" append-to-body @close="resetExport">
|
|
|
292
|
+ <el-form ref="exportFormRef" :model="exportForm" label-width="100px" size="small">
|
|
|
293
|
+ <el-form-item prop="statYear" :rules="exportRules.statYear">
|
|
|
294
|
+ <template slot="label">{{ dmT("exportStatYear") }}</template>
|
|
|
295
|
+ <el-select v-model="exportForm.statYear" :placeholder="dmT('exportStatYearPh')" style="width: 100%">
|
|
|
296
|
+ <el-option v-for="y in yearOptions" :key="'ey-' + y" :label="String(y)" :value="y" />
|
|
|
297
|
+ </el-select>
|
|
|
298
|
+ </el-form-item>
|
|
|
299
|
+ <el-form-item prop="statMonth" :rules="exportRules.statMonth">
|
|
|
300
|
+ <template slot="label">{{ dmT("exportStatMonth") }}</template>
|
|
|
301
|
+ <el-select v-model="exportForm.statMonth" :placeholder="dmT('exportStatMonthPh')" style="width: 100%">
|
|
|
302
|
+ <el-option v-for="m in monthOptions" :key="'em-' + m" :label="formatStatMonth(m)" :value="m" />
|
|
|
303
|
+ </el-select>
|
|
|
304
|
+ </el-form-item>
|
|
|
305
|
+ <el-form-item>
|
|
|
306
|
+ <template slot="label">{{ dmT("exportTown") }}</template>
|
|
|
307
|
+ <el-select
|
|
|
308
|
+ v-model="exportForm.townDeptId"
|
|
|
309
|
+ :placeholder="dmT('exportTownPh')"
|
|
|
310
|
+ clearable
|
|
|
311
|
+ filterable
|
|
|
312
|
+ style="width: 100%"
|
|
|
313
|
+ >
|
|
|
314
|
+ <el-option v-for="item in townOptions" :key="'et-' + item.deptId" :label="item.deptName" :value="item.deptId" />
|
|
|
315
|
+ </el-select>
|
|
|
316
|
+ </el-form-item>
|
|
|
317
|
+ </el-form>
|
|
|
318
|
+ <div slot="footer" class="dialog-footer">
|
|
|
319
|
+ <el-button type="primary" :loading="exporting" @click="handleExportSubmit">{{ dmCommon("ok") }}</el-button>
|
|
|
320
|
+ <el-button @click="exportOpen = false">{{ dmCommon("cancel") }}</el-button>
|
|
|
321
|
+ </div>
|
|
|
322
|
+ </el-dialog>
|
|
|
323
|
+ </div>
|
|
|
324
|
+</template>
|
|
|
325
|
+
|
|
|
326
|
+<script>
|
|
|
327
|
+import dataModelLocaleMixin from "@/mixins/dataModelLocaleMixin"
|
|
|
328
|
+import {
|
|
|
329
|
+ listLivestockOwnershipHousehold,
|
|
|
330
|
+ getLivestockOwnershipHousehold,
|
|
|
331
|
+ addLivestockOwnershipHousehold,
|
|
|
332
|
+ updateLivestockOwnershipHousehold,
|
|
|
333
|
+ delLivestockOwnershipHousehold,
|
|
|
334
|
+ listLivestockOwnershipHouseholdYearOptions,
|
|
|
335
|
+ listLivestockOwnershipHouseholdMonthOptions,
|
|
|
336
|
+ listLivestockOwnershipHouseholdTownOptions,
|
|
|
337
|
+ listLivestockOwnershipHouseholdVillageTree,
|
|
|
338
|
+ importLivestockOwnershipHousehold,
|
|
|
339
|
+ downloadLivestockOwnershipHouseholdTemplate,
|
|
|
340
|
+ exportLivestockOwnershipHousehold
|
|
|
341
|
+} from "@/api/dataModel/livestockOwnershipHousehold"
|
|
|
342
|
+import { blobValidate } from "@/utils/ruoyi"
|
|
|
343
|
+import { saveAs } from "file-saver"
|
|
|
344
|
+
|
|
|
345
|
+const COUNT_PROPS = [
|
|
|
346
|
+ "withLivestockHouseholdCount",
|
|
|
347
|
+ "withLivestockPopulationCount",
|
|
|
348
|
+ "withLivestockLaborCount",
|
|
|
349
|
+ "withLivestockAnimalCount",
|
|
|
350
|
+ "withoutLivestockHouseholdCount",
|
|
|
351
|
+ "withoutLivestockPopulationCount",
|
|
|
352
|
+ "withoutLivestockLaborCount"
|
|
|
353
|
+]
|
|
|
354
|
+
|
|
|
355
|
+function getCurrentYearMonth() {
|
|
|
356
|
+ const now = new Date()
|
|
|
357
|
+ return { statYear: now.getFullYear(), statMonth: now.getMonth() + 1 }
|
|
|
358
|
+}
|
|
|
359
|
+
|
|
|
360
|
+function createEmptyForm() {
|
|
|
361
|
+ const form = {
|
|
|
362
|
+ id: undefined,
|
|
|
363
|
+ statYear: undefined,
|
|
|
364
|
+ statMonth: undefined,
|
|
|
365
|
+ villageDeptId: undefined,
|
|
|
366
|
+ remark: undefined
|
|
|
367
|
+ }
|
|
|
368
|
+ COUNT_PROPS.forEach((prop) => {
|
|
|
369
|
+ form[prop] = undefined
|
|
|
370
|
+ })
|
|
|
371
|
+ return form
|
|
|
372
|
+}
|
|
|
373
|
+
|
|
|
374
|
+function normalizeForm(data) {
|
|
|
375
|
+ const row = Object.assign(createEmptyForm(), data || {})
|
|
|
376
|
+ COUNT_PROPS.forEach((prop) => {
|
|
|
377
|
+ const val = row[prop]
|
|
|
378
|
+ row[prop] = val == null || val === "" ? undefined : Number(val)
|
|
|
379
|
+ })
|
|
|
380
|
+ return row
|
|
|
381
|
+}
|
|
|
382
|
+
|
|
|
383
|
+function flattenVillageOptions(tree) {
|
|
|
384
|
+ const list = []
|
|
|
385
|
+ ;(tree || []).forEach((county) => {
|
|
|
386
|
+ ;(county.children || []).forEach((town) => {
|
|
|
387
|
+ ;(town.children || []).forEach((village) => {
|
|
|
388
|
+ if (village == null || village.id == null) {
|
|
|
389
|
+ return
|
|
|
390
|
+ }
|
|
|
391
|
+ const townName = town.label || ""
|
|
|
392
|
+ const villageName = village.label || ""
|
|
|
393
|
+ list.push({
|
|
|
394
|
+ deptId: village.id,
|
|
|
395
|
+ label: townName ? `${townName} / ${villageName}` : villageName
|
|
|
396
|
+ })
|
|
|
397
|
+ })
|
|
|
398
|
+ })
|
|
|
399
|
+ })
|
|
|
400
|
+ return list
|
|
|
401
|
+}
|
|
|
402
|
+
|
|
|
403
|
+export default {
|
|
|
404
|
+ name: "LivestockOwnershipHousehold",
|
|
|
405
|
+ mixins: [dataModelLocaleMixin],
|
|
|
406
|
+ data() {
|
|
|
407
|
+ return {
|
|
|
408
|
+ dmNs: "livestockOwnershipHousehold",
|
|
|
409
|
+ loading: false,
|
|
|
410
|
+ importing: false,
|
|
|
411
|
+ exporting: false,
|
|
|
412
|
+ open: false,
|
|
|
413
|
+ viewOpen: false,
|
|
|
414
|
+ importOpen: false,
|
|
|
415
|
+ exportOpen: false,
|
|
|
416
|
+ dialogEdit: false,
|
|
|
417
|
+ formKey: 0,
|
|
|
418
|
+ total: 0,
|
|
|
419
|
+ tableList: [],
|
|
|
420
|
+ yearOptions: [],
|
|
|
421
|
+ monthOptions: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
|
|
422
|
+ townOptions: [],
|
|
|
423
|
+ villageOptions: [],
|
|
|
424
|
+ viewRow: {},
|
|
|
425
|
+ importForm: { statYear: undefined, statMonth: undefined },
|
|
|
426
|
+ exportForm: { statYear: undefined, statMonth: undefined, townDeptId: undefined },
|
|
|
427
|
+ queryParams: {
|
|
|
428
|
+ pageNum: 1,
|
|
|
429
|
+ pageSize: 20,
|
|
|
430
|
+ statYear: undefined,
|
|
|
431
|
+ statMonth: undefined,
|
|
|
432
|
+ townDeptId: undefined,
|
|
|
433
|
+ villageDeptId: undefined
|
|
|
434
|
+ },
|
|
|
435
|
+ form: createEmptyForm()
|
|
|
436
|
+ }
|
|
|
437
|
+ },
|
|
|
438
|
+ computed: {
|
|
|
439
|
+ dash() {
|
|
|
440
|
+ return this.$t("dataModel.status.dash")
|
|
|
441
|
+ },
|
|
|
442
|
+ dialogTitle() {
|
|
|
443
|
+ return this.dialogEdit ? this.dmT("dialogEdit") : this.dmT("dialogAdd")
|
|
|
444
|
+ },
|
|
|
445
|
+ formRules() {
|
|
|
446
|
+ return {
|
|
|
447
|
+ statYear: [{ required: true, message: this.dmT("ruleStatYearRequired"), trigger: "change" }],
|
|
|
448
|
+ statMonth: [
|
|
|
449
|
+ { required: true, message: this.dmT("ruleStatMonthRequired"), trigger: "change" },
|
|
|
450
|
+ { validator: this.validateFormStatMonth, trigger: "change" }
|
|
|
451
|
+ ],
|
|
|
452
|
+ villageDeptId: [{ required: true, message: this.dmT("ruleVillageRequired"), trigger: "change" }],
|
|
|
453
|
+ count: [{ validator: this.validateOptionalCount, trigger: "change" }],
|
|
|
454
|
+ remark: [{ max: 500, message: this.dmCommon("ruleLen500"), trigger: "blur" }]
|
|
|
455
|
+ }
|
|
|
456
|
+ },
|
|
|
457
|
+ importRules() {
|
|
|
458
|
+ return {
|
|
|
459
|
+ statYear: [{ required: true, message: this.dmT("ruleStatYearRequired"), trigger: "change" }],
|
|
|
460
|
+ statMonth: [
|
|
|
461
|
+ { required: true, message: this.dmT("ruleStatMonthRequired"), trigger: "change" },
|
|
|
462
|
+ { validator: this.validateImportStatMonth, trigger: "change" }
|
|
|
463
|
+ ]
|
|
|
464
|
+ }
|
|
|
465
|
+ },
|
|
|
466
|
+ exportRules() {
|
|
|
467
|
+ return {
|
|
|
468
|
+ statYear: [{ required: true, message: this.dmT("exportStatYearRequired"), trigger: "change" }],
|
|
|
469
|
+ statMonth: [
|
|
|
470
|
+ { required: true, message: this.dmT("exportStatMonthRequired"), trigger: "change" },
|
|
|
471
|
+ { validator: this.validateExportStatMonth, trigger: "change" }
|
|
|
472
|
+ ]
|
|
|
473
|
+ }
|
|
|
474
|
+ }
|
|
|
475
|
+ },
|
|
|
476
|
+ created() {
|
|
|
477
|
+ this.loadOptions()
|
|
|
478
|
+ this.getList()
|
|
|
479
|
+ },
|
|
|
480
|
+ methods: {
|
|
|
481
|
+ loadOptions() {
|
|
|
482
|
+ listLivestockOwnershipHouseholdYearOptions().then((res) => {
|
|
|
483
|
+ this.yearOptions = Array.isArray(res.data) ? res.data : []
|
|
|
484
|
+ })
|
|
|
485
|
+ listLivestockOwnershipHouseholdMonthOptions().then((res) => {
|
|
|
486
|
+ if (Array.isArray(res.data) && res.data.length) {
|
|
|
487
|
+ this.monthOptions = res.data
|
|
|
488
|
+ }
|
|
|
489
|
+ })
|
|
|
490
|
+ listLivestockOwnershipHouseholdTownOptions().then((res) => {
|
|
|
491
|
+ this.townOptions = Array.isArray(res.data) ? res.data : []
|
|
|
492
|
+ })
|
|
|
493
|
+ this.loadVillageTree()
|
|
|
494
|
+ },
|
|
|
495
|
+ loadVillageTree() {
|
|
|
496
|
+ return listLivestockOwnershipHouseholdVillageTree()
|
|
|
497
|
+ .then((res) => {
|
|
|
498
|
+ const raw = res && res.data !== undefined ? res.data : res
|
|
|
499
|
+ this.villageOptions = flattenVillageOptions(Array.isArray(raw) ? raw : [])
|
|
|
500
|
+ if (!this.villageOptions.length) {
|
|
|
501
|
+ this.$modal.msgWarning(this.dmT("villageTreeEmpty"))
|
|
|
502
|
+ }
|
|
|
503
|
+ })
|
|
|
504
|
+ .catch(() => {
|
|
|
505
|
+ this.villageOptions = []
|
|
|
506
|
+ })
|
|
|
507
|
+ },
|
|
|
508
|
+ formatStatMonth(month) {
|
|
|
509
|
+ if (month == null || month === "") {
|
|
|
510
|
+ return this.dash
|
|
|
511
|
+ }
|
|
|
512
|
+ return this.dmT("statMonthLabel", { month })
|
|
|
513
|
+ },
|
|
|
514
|
+ formatCount(val) {
|
|
|
515
|
+ return val == null || val === "" ? this.dash : val
|
|
|
516
|
+ },
|
|
|
517
|
+ isFutureStatPeriod(statYear, statMonth) {
|
|
|
518
|
+ if (statYear == null || statMonth == null) {
|
|
|
519
|
+ return false
|
|
|
520
|
+ }
|
|
|
521
|
+ const now = new Date()
|
|
|
522
|
+ const y = now.getFullYear()
|
|
|
523
|
+ const m = now.getMonth() + 1
|
|
|
524
|
+ return statYear > y || (statYear === y && statMonth > m)
|
|
|
525
|
+ },
|
|
|
526
|
+ validateFormStatMonth(rule, value, callback) {
|
|
|
527
|
+ if (this.isFutureStatPeriod(this.form.statYear, value)) {
|
|
|
528
|
+ callback(new Error(this.dmT("ruleStatMonthFuture")))
|
|
|
529
|
+ return
|
|
|
530
|
+ }
|
|
|
531
|
+ callback()
|
|
|
532
|
+ },
|
|
|
533
|
+ validateImportStatMonth(rule, value, callback) {
|
|
|
534
|
+ if (this.isFutureStatPeriod(this.importForm.statYear, value)) {
|
|
|
535
|
+ callback(new Error(this.dmT("ruleStatMonthFuture")))
|
|
|
536
|
+ return
|
|
|
537
|
+ }
|
|
|
538
|
+ callback()
|
|
|
539
|
+ },
|
|
|
540
|
+ validateExportStatMonth(rule, value, callback) {
|
|
|
541
|
+ if (this.isFutureStatPeriod(this.exportForm.statYear, value)) {
|
|
|
542
|
+ callback(new Error(this.dmT("ruleStatMonthFuture")))
|
|
|
543
|
+ return
|
|
|
544
|
+ }
|
|
|
545
|
+ callback()
|
|
|
546
|
+ },
|
|
|
547
|
+ validateOptionalCount(rule, value, callback) {
|
|
|
548
|
+ if (value == null || value === "") {
|
|
|
549
|
+ callback()
|
|
|
550
|
+ return
|
|
|
551
|
+ }
|
|
|
552
|
+ if (typeof value !== "number" || Number.isNaN(value) || value < 0 || !Number.isInteger(value)) {
|
|
|
553
|
+ callback(new Error(this.dmT("ruleCountNonNegative")))
|
|
|
554
|
+ return
|
|
|
555
|
+ }
|
|
|
556
|
+ callback()
|
|
|
557
|
+ },
|
|
|
558
|
+ buildListQuery() {
|
|
|
559
|
+ const q = {
|
|
|
560
|
+ pageNum: this.queryParams.pageNum,
|
|
|
561
|
+ pageSize: this.queryParams.pageSize
|
|
|
562
|
+ }
|
|
|
563
|
+ if (this.queryParams.statYear != null) {
|
|
|
564
|
+ q.statYear = this.queryParams.statYear
|
|
|
565
|
+ }
|
|
|
566
|
+ if (this.queryParams.statMonth != null) {
|
|
|
567
|
+ q.statMonth = this.queryParams.statMonth
|
|
|
568
|
+ }
|
|
|
569
|
+ if (this.queryParams.townDeptId != null) {
|
|
|
570
|
+ q.townDeptId = this.queryParams.townDeptId
|
|
|
571
|
+ }
|
|
|
572
|
+ if (this.queryParams.villageDeptId != null) {
|
|
|
573
|
+ q.villageDeptId = this.queryParams.villageDeptId
|
|
|
574
|
+ }
|
|
|
575
|
+ return q
|
|
|
576
|
+ },
|
|
|
577
|
+ getList() {
|
|
|
578
|
+ this.loading = true
|
|
|
579
|
+ listLivestockOwnershipHousehold(this.buildListQuery())
|
|
|
580
|
+ .then((res) => {
|
|
|
581
|
+ this.tableList = res.rows || []
|
|
|
582
|
+ this.total = res.total || 0
|
|
|
583
|
+ })
|
|
|
584
|
+ .finally(() => {
|
|
|
585
|
+ this.loading = false
|
|
|
586
|
+ })
|
|
|
587
|
+ },
|
|
|
588
|
+ handleQuery() {
|
|
|
589
|
+ this.queryParams.pageNum = 1
|
|
|
590
|
+ this.getList()
|
|
|
591
|
+ },
|
|
|
592
|
+ resetQuery() {
|
|
|
593
|
+ this.queryParams = {
|
|
|
594
|
+ pageNum: 1,
|
|
|
595
|
+ pageSize: 20,
|
|
|
596
|
+ statYear: undefined,
|
|
|
597
|
+ statMonth: undefined,
|
|
|
598
|
+ townDeptId: undefined,
|
|
|
599
|
+ villageDeptId: undefined
|
|
|
600
|
+ }
|
|
|
601
|
+ this.getList()
|
|
|
602
|
+ },
|
|
|
603
|
+ handleAdd() {
|
|
|
604
|
+ this.dialogEdit = false
|
|
|
605
|
+ this.formKey += 1
|
|
|
606
|
+ this.form = createEmptyForm()
|
|
|
607
|
+ const ym = getCurrentYearMonth()
|
|
|
608
|
+ this.form.statYear = ym.statYear
|
|
|
609
|
+ this.form.statMonth = ym.statMonth
|
|
|
610
|
+ this.open = true
|
|
|
611
|
+ this.$nextTick(() => {
|
|
|
612
|
+ if (this.$refs.form) {
|
|
|
613
|
+ this.$refs.form.clearValidate()
|
|
|
614
|
+ }
|
|
|
615
|
+ })
|
|
|
616
|
+ },
|
|
|
617
|
+ handleEdit(row) {
|
|
|
618
|
+ getLivestockOwnershipHousehold(row.id).then((res) => {
|
|
|
619
|
+ this.dialogEdit = true
|
|
|
620
|
+ this.formKey += 1
|
|
|
621
|
+ this.form = normalizeForm(res.data)
|
|
|
622
|
+ this.open = true
|
|
|
623
|
+ this.viewOpen = false
|
|
|
624
|
+ this.$nextTick(() => {
|
|
|
625
|
+ if (this.$refs.form) {
|
|
|
626
|
+ this.$refs.form.clearValidate()
|
|
|
627
|
+ }
|
|
|
628
|
+ })
|
|
|
629
|
+ })
|
|
|
630
|
+ },
|
|
|
631
|
+ handleView(row) {
|
|
|
632
|
+ getLivestockOwnershipHousehold(row.id).then((res) => {
|
|
|
633
|
+ this.viewRow = res.data || {}
|
|
|
634
|
+ this.viewOpen = true
|
|
|
635
|
+ })
|
|
|
636
|
+ },
|
|
|
637
|
+ handleEditFromView() {
|
|
|
638
|
+ if (!this.viewRow || this.viewRow.id == null) {
|
|
|
639
|
+ return
|
|
|
640
|
+ }
|
|
|
641
|
+ this.handleEdit(this.viewRow)
|
|
|
642
|
+ },
|
|
|
643
|
+ handleDelete(row) {
|
|
|
644
|
+ this.$modal
|
|
|
645
|
+ .confirm(this.dmT("confirmDelete"))
|
|
|
646
|
+ .then(() => delLivestockOwnershipHousehold(row.id))
|
|
|
647
|
+ .then(() => {
|
|
|
648
|
+ this.$modal.msgSuccess(this.dmCommon("msgDelOk"))
|
|
|
649
|
+ this.getList()
|
|
|
650
|
+ })
|
|
|
651
|
+ .catch(() => {})
|
|
|
652
|
+ },
|
|
|
653
|
+ normalizeCount(val) {
|
|
|
654
|
+ return val == null || val === "" ? null : val
|
|
|
655
|
+ },
|
|
|
656
|
+ buildSubmitPayload() {
|
|
|
657
|
+ const payload = {
|
|
|
658
|
+ id: this.form.id,
|
|
|
659
|
+ statYear: this.form.statYear,
|
|
|
660
|
+ statMonth: this.form.statMonth,
|
|
|
661
|
+ villageDeptId: this.form.villageDeptId,
|
|
|
662
|
+ remark: this.form.remark
|
|
|
663
|
+ }
|
|
|
664
|
+ COUNT_PROPS.forEach((prop) => {
|
|
|
665
|
+ payload[prop] = this.normalizeCount(this.form[prop])
|
|
|
666
|
+ })
|
|
|
667
|
+ return payload
|
|
|
668
|
+ },
|
|
|
669
|
+ submitForm() {
|
|
|
670
|
+ this.$refs.form.validate((valid) => {
|
|
|
671
|
+ if (!valid) {
|
|
|
672
|
+ return
|
|
|
673
|
+ }
|
|
|
674
|
+ const payload = this.buildSubmitPayload()
|
|
|
675
|
+ if (this.dialogEdit) {
|
|
|
676
|
+ updateLivestockOwnershipHousehold(payload).then(() => {
|
|
|
677
|
+ this.$modal.msgSuccess(this.dmCommon("msgEditOk"))
|
|
|
678
|
+ this.open = false
|
|
|
679
|
+ this.getList()
|
|
|
680
|
+ })
|
|
|
681
|
+ } else {
|
|
|
682
|
+ addLivestockOwnershipHousehold(payload).then(() => {
|
|
|
683
|
+ this.$modal.msgSuccess(this.dmCommon("msgAddOk"))
|
|
|
684
|
+ this.open = false
|
|
|
685
|
+ this.getList()
|
|
|
686
|
+ })
|
|
|
687
|
+ }
|
|
|
688
|
+ })
|
|
|
689
|
+ },
|
|
|
690
|
+ cancel() {
|
|
|
691
|
+ this.open = false
|
|
|
692
|
+ this.form = createEmptyForm()
|
|
|
693
|
+ },
|
|
|
694
|
+ handleImportOpen() {
|
|
|
695
|
+ const ym = getCurrentYearMonth()
|
|
|
696
|
+ this.importForm = {
|
|
|
697
|
+ statYear: this.queryParams.statYear != null ? this.queryParams.statYear : ym.statYear,
|
|
|
698
|
+ statMonth: this.queryParams.statMonth != null ? this.queryParams.statMonth : ym.statMonth
|
|
|
699
|
+ }
|
|
|
700
|
+ this.importOpen = true
|
|
|
701
|
+ this.$nextTick(() => {
|
|
|
702
|
+ if (this.$refs.importFormRef) {
|
|
|
703
|
+ this.$refs.importFormRef.clearValidate()
|
|
|
704
|
+ }
|
|
|
705
|
+ if (this.$refs.importUpload) {
|
|
|
706
|
+ this.$refs.importUpload.clearFiles()
|
|
|
707
|
+ }
|
|
|
708
|
+ })
|
|
|
709
|
+ },
|
|
|
710
|
+ resetImport() {
|
|
|
711
|
+ this.importForm = { statYear: undefined, statMonth: undefined }
|
|
|
712
|
+ if (this.$refs.importUpload) {
|
|
|
713
|
+ this.$refs.importUpload.clearFiles()
|
|
|
714
|
+ }
|
|
|
715
|
+ },
|
|
|
716
|
+ handleDownloadTemplate() {
|
|
|
717
|
+ downloadLivestockOwnershipHouseholdTemplate().then(async (data) => {
|
|
|
718
|
+ const isBlob = blobValidate(data)
|
|
|
719
|
+ if (isBlob) {
|
|
|
720
|
+ saveAs(data, `livestock_ownership_household_import_template_${new Date().getTime()}.xlsx`)
|
|
|
721
|
+ } else {
|
|
|
722
|
+ this.$modal.msgError(this.dmT("exportFail"))
|
|
|
723
|
+ }
|
|
|
724
|
+ })
|
|
|
725
|
+ },
|
|
|
726
|
+ handleImportSubmit() {
|
|
|
727
|
+ this.$refs.importFormRef.validate((valid) => {
|
|
|
728
|
+ if (!valid) {
|
|
|
729
|
+ return
|
|
|
730
|
+ }
|
|
|
731
|
+ const files = this.$refs.importUpload ? this.$refs.importUpload.uploadFiles : []
|
|
|
732
|
+ if (!files || !files.length) {
|
|
|
733
|
+ this.$modal.msgError(this.dmCommon("pleaseSelect"))
|
|
|
734
|
+ return
|
|
|
735
|
+ }
|
|
|
736
|
+ const raw = files[0].raw
|
|
|
737
|
+ this.importing = true
|
|
|
738
|
+ this.$modal.loading(this.dmT("importLoading"))
|
|
|
739
|
+ importLivestockOwnershipHousehold(raw, this.importForm.statYear, this.importForm.statMonth)
|
|
|
740
|
+ .then((res) => {
|
|
|
741
|
+ const data = res.data || {}
|
|
|
742
|
+ const msg = this.dmT("importSummary", {
|
|
|
743
|
+ insert: data.insertCount != null ? data.insertCount : 0,
|
|
|
744
|
+ update: data.updateCount != null ? data.updateCount : 0,
|
|
|
745
|
+ fail: data.failCount != null ? data.failCount : 0
|
|
|
746
|
+ })
|
|
|
747
|
+ this.$modal.msgSuccess(msg)
|
|
|
748
|
+ if (data.warnMessages && data.warnMessages.length) {
|
|
|
749
|
+ this.$alert(data.warnMessages.join("<br/>"), this.dmT("importWarnTitle"), { dangerouslyUseHTMLString: true })
|
|
|
750
|
+ }
|
|
|
751
|
+ if (data.failMessages && data.failMessages.length) {
|
|
|
752
|
+ this.$alert(data.failMessages.join("<br/>"), this.dmT("importFailTitle"), { dangerouslyUseHTMLString: true })
|
|
|
753
|
+ }
|
|
|
754
|
+ this.importOpen = false
|
|
|
755
|
+ this.getList()
|
|
|
756
|
+ })
|
|
|
757
|
+ .finally(() => {
|
|
|
758
|
+ this.importing = false
|
|
|
759
|
+ this.$modal.closeLoading()
|
|
|
760
|
+ })
|
|
|
761
|
+ })
|
|
|
762
|
+ },
|
|
|
763
|
+ handleExportOpen() {
|
|
|
764
|
+ const ym = getCurrentYearMonth()
|
|
|
765
|
+ this.exportForm = {
|
|
|
766
|
+ statYear: this.queryParams.statYear != null ? this.queryParams.statYear : ym.statYear,
|
|
|
767
|
+ statMonth: this.queryParams.statMonth != null ? this.queryParams.statMonth : ym.statMonth,
|
|
|
768
|
+ townDeptId: this.queryParams.townDeptId
|
|
|
769
|
+ }
|
|
|
770
|
+ this.exportOpen = true
|
|
|
771
|
+ this.$nextTick(() => {
|
|
|
772
|
+ if (this.$refs.exportFormRef) {
|
|
|
773
|
+ this.$refs.exportFormRef.clearValidate()
|
|
|
774
|
+ }
|
|
|
775
|
+ })
|
|
|
776
|
+ },
|
|
|
777
|
+ resetExport() {
|
|
|
778
|
+ this.exportForm = { statYear: undefined, statMonth: undefined, townDeptId: undefined }
|
|
|
779
|
+ },
|
|
|
780
|
+ handleExportSubmit() {
|
|
|
781
|
+ this.$refs.exportFormRef.validate((valid) => {
|
|
|
782
|
+ if (!valid) {
|
|
|
783
|
+ return
|
|
|
784
|
+ }
|
|
|
785
|
+ this.exporting = true
|
|
|
786
|
+ const filename = `${this.exportForm.statYear}年${this.exportForm.statMonth}月有无畜户数据.xlsx`
|
|
|
787
|
+ this.$modal.loading(this.dmT("exportLoading"))
|
|
|
788
|
+ exportLivestockOwnershipHousehold(this.exportForm.statYear, this.exportForm.statMonth, this.exportForm.townDeptId)
|
|
|
789
|
+ .then(async (data) => {
|
|
|
790
|
+ const isBlob = blobValidate(data)
|
|
|
791
|
+ if (isBlob) {
|
|
|
792
|
+ saveAs(
|
|
|
793
|
+ data,
|
|
|
794
|
+ filename
|
|
|
795
|
+ )
|
|
|
796
|
+ this.exportOpen = false
|
|
|
797
|
+ } else {
|
|
|
798
|
+ this.$modal.msgError(this.dmT("exportFail"))
|
|
|
799
|
+ }
|
|
|
800
|
+ })
|
|
|
801
|
+ .finally(() => {
|
|
|
802
|
+ this.exporting = false
|
|
|
803
|
+ this.$modal.closeLoading()
|
|
|
804
|
+ })
|
|
|
805
|
+ })
|
|
|
806
|
+ }
|
|
|
807
|
+ }
|
|
|
808
|
+}
|
|
|
809
|
+</script>
|
|
|
810
|
+
|
|
|
811
|
+<style scoped>
|
|
|
812
|
+.loh-section-title {
|
|
|
813
|
+ margin: 4px 0 12px;
|
|
|
814
|
+ font-weight: 600;
|
|
|
815
|
+ color: #303133;
|
|
|
816
|
+}
|
|
|
817
|
+.loh-import-tip {
|
|
|
818
|
+ margin: 0 0 12px;
|
|
|
819
|
+ color: #909399;
|
|
|
820
|
+ font-size: 12px;
|
|
|
821
|
+ line-height: 1.5;
|
|
|
822
|
+}
|
|
|
823
|
+.loh-view-text {
|
|
|
824
|
+ white-space: pre-wrap;
|
|
|
825
|
+ word-break: break-all;
|
|
|
826
|
+}
|
|
|
827
|
+.dm-input-with-unit {
|
|
|
828
|
+ display: flex;
|
|
|
829
|
+ align-items: center;
|
|
|
830
|
+ width: 100%;
|
|
|
831
|
+}
|
|
|
832
|
+.dm-input-with-unit__input {
|
|
|
833
|
+ flex: 1;
|
|
|
834
|
+ width: 100%;
|
|
|
835
|
+}
|
|
|
836
|
+.dm-input-with-unit__suffix {
|
|
|
837
|
+ margin-left: 8px;
|
|
|
838
|
+ color: #909399;
|
|
|
839
|
+ white-space: nowrap;
|
|
|
840
|
+}
|
|
|
841
|
+.dm-input-with-unit >>> .el-input-number {
|
|
|
842
|
+ width: 100%;
|
|
|
843
|
+}
|
|
|
844
|
+</style>
|