|
|
@@ -0,0 +1,687 @@
|
|
|
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="townDeptId">
|
|
|
12
|
+ <template slot="label">{{ dmT("queryTown") }}</template>
|
|
|
13
|
+ <el-select v-model="queryParams.townDeptId" :placeholder="dmCommon('pleaseSelect')" clearable filterable style="width: 180px">
|
|
|
14
|
+ <el-option v-for="item in townOptions" :key="item.deptId" :label="item.deptName" :value="item.deptId" />
|
|
|
15
|
+ </el-select>
|
|
|
16
|
+ </el-form-item>
|
|
|
17
|
+ <el-form-item>
|
|
|
18
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ dmCommon("search") }}</el-button>
|
|
|
19
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ dmCommon("reset") }}</el-button>
|
|
|
20
|
+ <el-button
|
|
|
21
|
+ v-hasPermi="['dataModel:yakHerdInventory:add']"
|
|
|
22
|
+ type="primary"
|
|
|
23
|
+ plain
|
|
|
24
|
+ icon="el-icon-plus"
|
|
|
25
|
+ size="mini"
|
|
|
26
|
+ @click="handleAdd"
|
|
|
27
|
+ >{{ dmCommon("add") }}</el-button>
|
|
|
28
|
+ <el-button
|
|
|
29
|
+ v-hasPermi="['dataModel:yakHerdInventory:import']"
|
|
|
30
|
+ type="info"
|
|
|
31
|
+ plain
|
|
|
32
|
+ icon="el-icon-upload2"
|
|
|
33
|
+ size="mini"
|
|
|
34
|
+ @click="handleImportOpen"
|
|
|
35
|
+ >{{ dmT("btnImport") }}</el-button>
|
|
|
36
|
+ <el-button
|
|
|
37
|
+ v-hasPermi="['dataModel:yakHerdInventory:export']"
|
|
|
38
|
+ type="warning"
|
|
|
39
|
+ plain
|
|
|
40
|
+ icon="el-icon-download"
|
|
|
41
|
+ size="mini"
|
|
|
42
|
+ @click="handleExportOpen"
|
|
|
43
|
+ >{{ dmCommon("export") }}</el-button>
|
|
|
44
|
+ </el-form-item>
|
|
|
45
|
+ </el-form>
|
|
|
46
|
+ </el-card>
|
|
|
47
|
+
|
|
|
48
|
+ <br />
|
|
|
49
|
+
|
|
|
50
|
+ <el-card shadow="never">
|
|
|
51
|
+ <el-table v-loading="loading" :data="tableList" border>
|
|
|
52
|
+ <template slot="empty">
|
|
|
53
|
+ <span>{{ dmT("emptyList") }}</span>
|
|
|
54
|
+ </template>
|
|
|
55
|
+ <el-table-column :label="dmT('colStatYear')" prop="statYear" align="center" width="100" />
|
|
|
56
|
+ <el-table-column :label="dmT('colTownName')" prop="townName" align="center" min-width="120" :show-overflow-tooltip="true" />
|
|
|
57
|
+ <el-table-column :label="dmT('colVillageCount')" align="center" width="90">
|
|
|
58
|
+ <template slot-scope="scope">{{ formatCount(scope.row.villageCount) }}</template>
|
|
|
59
|
+ </el-table-column>
|
|
|
60
|
+ <el-table-column :label="dmT('colHerdsmanHouseholdCount')" align="center" width="90">
|
|
|
61
|
+ <template slot-scope="scope">{{ formatCount(scope.row.herdsmanHouseholdCount) }}</template>
|
|
|
62
|
+ </el-table-column>
|
|
|
63
|
+ <el-table-column :label="dmT('colYakTotal')" align="center" width="100">
|
|
|
64
|
+ <template slot-scope="scope">{{ formatCount(scope.row.yakTotal) }}</template>
|
|
|
65
|
+ </el-table-column>
|
|
|
66
|
+ <el-table-column :label="dmT('colBullTotal')" align="center" width="110">
|
|
|
67
|
+ <template slot-scope="scope">{{ formatCount(scope.row.bullTotal) }}</template>
|
|
|
68
|
+ </el-table-column>
|
|
|
69
|
+ <el-table-column :label="dmT('colCowTotal')" align="center" width="110">
|
|
|
70
|
+ <template slot-scope="scope">{{ formatCount(scope.row.cowTotal) }}</template>
|
|
|
71
|
+ </el-table-column>
|
|
|
72
|
+ <el-table-column :label="dmCommon('colOp')" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
|
|
|
73
|
+ <template slot-scope="scope">
|
|
|
74
|
+ <el-button v-hasPermi="['dataModel:yakHerdInventory:query']" type="text" size="mini" @click="handleView(scope.row)">{{ dmCommon("view") }}</el-button>
|
|
|
75
|
+ <el-button v-hasPermi="['dataModel:yakHerdInventory:edit']" type="text" size="mini" @click="handleEdit(scope.row)">{{ dmCommon("edit") }}</el-button>
|
|
|
76
|
+ <el-button v-hasPermi="['dataModel:yakHerdInventory:remove']" type="text" size="mini" @click="handleDelete(scope.row)">{{ dmCommon("delete") }}</el-button>
|
|
|
77
|
+ </template>
|
|
|
78
|
+ </el-table-column>
|
|
|
79
|
+ </el-table>
|
|
|
80
|
+ <pagination
|
|
|
81
|
+ v-show="total > 0"
|
|
|
82
|
+ :total="total"
|
|
|
83
|
+ :page.sync="queryParams.pageNum"
|
|
|
84
|
+ :limit.sync="queryParams.pageSize"
|
|
|
85
|
+ @pagination="getList"
|
|
|
86
|
+ />
|
|
|
87
|
+ </el-card>
|
|
|
88
|
+
|
|
|
89
|
+ <el-dialog :title="dialogTitle" :visible.sync="open" width="920px" append-to-body @close="cancel">
|
|
|
90
|
+ <el-form :key="formKey" ref="form" :model="form" label-width="150px" size="small">
|
|
|
91
|
+ <div class="yhi-section-title">{{ dmT("sectionBasic") }}</div>
|
|
|
92
|
+ <el-row :gutter="16">
|
|
|
93
|
+ <el-col :span="12">
|
|
|
94
|
+ <el-form-item prop="statYear" :rules="formRules.statYear">
|
|
|
95
|
+ <template slot="label">{{ dmT("formStatYear") }}</template>
|
|
|
96
|
+ <el-select v-model="form.statYear" :placeholder="dmCommon('pleaseSelect')" style="width: 100%">
|
|
|
97
|
+ <el-option v-for="y in yearOptions" :key="'f-' + y" :label="String(y)" :value="y" />
|
|
|
98
|
+ </el-select>
|
|
|
99
|
+ </el-form-item>
|
|
|
100
|
+ </el-col>
|
|
|
101
|
+ <el-col :span="12">
|
|
|
102
|
+ <el-form-item prop="townDeptId" :rules="formRules.townDeptId">
|
|
|
103
|
+ <template slot="label">{{ dmT("formTown") }}</template>
|
|
|
104
|
+ <el-select v-model="form.townDeptId" :placeholder="dmCommon('pleaseSelect')" filterable style="width: 100%">
|
|
|
105
|
+ <el-option v-for="item in townOptions" :key="'ft-' + item.deptId" :label="item.deptName" :value="item.deptId" />
|
|
|
106
|
+ </el-select>
|
|
|
107
|
+ </el-form-item>
|
|
|
108
|
+ </el-col>
|
|
|
109
|
+ </el-row>
|
|
|
110
|
+ <div class="yhi-section-title">{{ dmT("sectionInventory") }}</div>
|
|
|
111
|
+ <el-row :gutter="16">
|
|
|
112
|
+ <el-col v-for="field in countFields" :key="field.prop" :span="12">
|
|
|
113
|
+ <el-form-item :prop="field.prop" :rules="formRules.count">
|
|
|
114
|
+ <template slot="label">{{ dmT(field.labelKey) }}</template>
|
|
|
115
|
+ <div class="dm-input-with-unit">
|
|
|
116
|
+ <el-input-number
|
|
|
117
|
+ v-model="form[field.prop]"
|
|
|
118
|
+ :min="0"
|
|
|
119
|
+ :precision="0"
|
|
|
120
|
+ :controls="true"
|
|
|
121
|
+ controls-position="right"
|
|
|
122
|
+ class="dm-input-with-unit__input"
|
|
|
123
|
+ />
|
|
|
124
|
+ <span class="dm-input-with-unit__suffix">{{ dmT(field.unitKey) }}</span>
|
|
|
125
|
+ </div>
|
|
|
126
|
+ </el-form-item>
|
|
|
127
|
+ </el-col>
|
|
|
128
|
+ </el-row>
|
|
|
129
|
+ <el-form-item prop="remark" :rules="formRules.remark">
|
|
|
130
|
+ <template slot="label">{{ dmT("formRemark") }}</template>
|
|
|
131
|
+ <el-input v-model="form.remark" type="textarea" :rows="2" :placeholder="dmT('phRemark')" maxlength="500" show-word-limit />
|
|
|
132
|
+ </el-form-item>
|
|
|
133
|
+ </el-form>
|
|
|
134
|
+ <div slot="footer" class="dialog-footer">
|
|
|
135
|
+ <el-button type="primary" @click="submitForm">{{ dmCommon("ok") }}</el-button>
|
|
|
136
|
+ <el-button @click="cancel">{{ dmCommon("cancel") }}</el-button>
|
|
|
137
|
+ </div>
|
|
|
138
|
+ </el-dialog>
|
|
|
139
|
+
|
|
|
140
|
+ <el-dialog :title="dmCommon('viewTitle')" :visible.sync="viewOpen" width="920px" append-to-body>
|
|
|
141
|
+ <el-form label-width="150px" size="small">
|
|
|
142
|
+ <el-row :gutter="16">
|
|
|
143
|
+ <el-col :span="12">
|
|
|
144
|
+ <el-form-item :label="dmT('formStatYear')">
|
|
|
145
|
+ <span>{{ viewRow.statYear || dash }}</span>
|
|
|
146
|
+ </el-form-item>
|
|
|
147
|
+ </el-col>
|
|
|
148
|
+ <el-col :span="12">
|
|
|
149
|
+ <el-form-item :label="dmT('formTown')">
|
|
|
150
|
+ <span>{{ viewRow.townName || dash }}</span>
|
|
|
151
|
+ </el-form-item>
|
|
|
152
|
+ </el-col>
|
|
|
153
|
+ <el-col v-for="field in countFields" :key="'v-' + field.prop" :span="12">
|
|
|
154
|
+ <el-form-item :label="dmT(field.labelKey)">
|
|
|
155
|
+ <span>{{ formatCount(viewRow[field.prop]) }}</span>
|
|
|
156
|
+ </el-form-item>
|
|
|
157
|
+ </el-col>
|
|
|
158
|
+ <el-col :span="24">
|
|
|
159
|
+ <el-form-item :label="dmT('formRemark')">
|
|
|
160
|
+ <span class="yhi-view-text">{{ viewRow.remark || dash }}</span>
|
|
|
161
|
+ </el-form-item>
|
|
|
162
|
+ </el-col>
|
|
|
163
|
+ <el-col :span="12">
|
|
|
164
|
+ <el-form-item :label="dmCommon('colCreate')">
|
|
|
165
|
+ <span>{{ viewRow.createTime ? parseTime(viewRow.createTime) : dash }}</span>
|
|
|
166
|
+ </el-form-item>
|
|
|
167
|
+ </el-col>
|
|
|
168
|
+ <el-col :span="12">
|
|
|
169
|
+ <el-form-item :label="dmT('viewCreateBy')">
|
|
|
170
|
+ <span>{{ viewRow.createBy || dash }}</span>
|
|
|
171
|
+ </el-form-item>
|
|
|
172
|
+ </el-col>
|
|
|
173
|
+ <el-col :span="12">
|
|
|
174
|
+ <el-form-item :label="dmT('viewUpdateBy')">
|
|
|
175
|
+ <span>{{ viewRow.updateBy || dash }}</span>
|
|
|
176
|
+ </el-form-item>
|
|
|
177
|
+ </el-col>
|
|
|
178
|
+ <el-col :span="12">
|
|
|
179
|
+ <el-form-item :label="dmT('viewUpdateTime')">
|
|
|
180
|
+ <span>{{ viewRow.updateTime ? parseTime(viewRow.updateTime) : dash }}</span>
|
|
|
181
|
+ </el-form-item>
|
|
|
182
|
+ </el-col>
|
|
|
183
|
+ </el-row>
|
|
|
184
|
+ </el-form>
|
|
|
185
|
+ <div slot="footer" class="dialog-footer">
|
|
|
186
|
+ <el-button
|
|
|
187
|
+ v-hasPermi="['dataModel:yakHerdInventory:edit']"
|
|
|
188
|
+ type="primary"
|
|
|
189
|
+ @click="handleEditFromView"
|
|
|
190
|
+ >{{ dmCommon("edit") }}</el-button>
|
|
|
191
|
+ <el-button @click="viewOpen = false">{{ dmCommon("close") }}</el-button>
|
|
|
192
|
+ </div>
|
|
|
193
|
+ </el-dialog>
|
|
|
194
|
+
|
|
|
195
|
+ <el-dialog :title="dmT('importTitle')" :visible.sync="importOpen" width="480px" append-to-body @close="resetImport">
|
|
|
196
|
+ <el-form ref="importFormRef" :model="importForm" label-width="100px" size="small">
|
|
|
197
|
+ <el-form-item prop="statYear" :rules="importRules.statYear">
|
|
|
198
|
+ <template slot="label">{{ dmT("importStatYear") }}</template>
|
|
|
199
|
+ <el-select v-model="importForm.statYear" :placeholder="dmT('importStatYearPh')" style="width: 100%">
|
|
|
200
|
+ <el-option v-for="y in yearOptions" :key="'i-' + y" :label="String(y)" :value="y" />
|
|
|
201
|
+ </el-select>
|
|
|
202
|
+ </el-form-item>
|
|
|
203
|
+ <p class="yhi-import-tip">{{ dmT("importTip") }}</p>
|
|
|
204
|
+ <el-upload
|
|
|
205
|
+ ref="importUpload"
|
|
|
206
|
+ drag
|
|
|
207
|
+ :limit="1"
|
|
|
208
|
+ accept=".xlsx,.xls"
|
|
|
209
|
+ :auto-upload="false"
|
|
|
210
|
+ action="#"
|
|
|
211
|
+ >
|
|
|
212
|
+ <i class="el-icon-upload" />
|
|
|
213
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
214
|
+ <div slot="tip" class="el-upload__tip">
|
|
|
215
|
+ <el-link type="primary" :underline="false" @click="handleDownloadTemplate">{{ dmT("btnDownloadTemplate") }}</el-link>
|
|
|
216
|
+ </div>
|
|
|
217
|
+ </el-upload>
|
|
|
218
|
+ </el-form>
|
|
|
219
|
+ <div slot="footer" class="dialog-footer">
|
|
|
220
|
+ <el-button type="primary" :loading="importing" @click="handleImportSubmit">{{ dmCommon("ok") }}</el-button>
|
|
|
221
|
+ <el-button @click="importOpen = false">{{ dmCommon("cancel") }}</el-button>
|
|
|
222
|
+ </div>
|
|
|
223
|
+ </el-dialog>
|
|
|
224
|
+
|
|
|
225
|
+ <el-dialog :title="dmT('exportTitle')" :visible.sync="exportOpen" width="480px" append-to-body @close="resetExport">
|
|
|
226
|
+ <el-form ref="exportFormRef" :model="exportForm" label-width="100px" size="small">
|
|
|
227
|
+ <el-form-item prop="statYear" :rules="exportRules.statYear">
|
|
|
228
|
+ <template slot="label">{{ dmT("exportStatYear") }}</template>
|
|
|
229
|
+ <el-select v-model="exportForm.statYear" :placeholder="dmT('exportStatYearPh')" style="width: 100%">
|
|
|
230
|
+ <el-option v-for="y in yearOptions" :key="'e-' + y" :label="String(y)" :value="y" />
|
|
|
231
|
+ </el-select>
|
|
|
232
|
+ </el-form-item>
|
|
|
233
|
+ </el-form>
|
|
|
234
|
+ <div slot="footer" class="dialog-footer">
|
|
|
235
|
+ <el-button type="primary" :loading="exporting" @click="handleExportSubmit">{{ dmCommon("ok") }}</el-button>
|
|
|
236
|
+ <el-button @click="exportOpen = false">{{ dmCommon("cancel") }}</el-button>
|
|
|
237
|
+ </div>
|
|
|
238
|
+ </el-dialog>
|
|
|
239
|
+ </div>
|
|
|
240
|
+</template>
|
|
|
241
|
+
|
|
|
242
|
+<script>
|
|
|
243
|
+import dataModelLocaleMixin from "@/mixins/dataModelLocaleMixin"
|
|
|
244
|
+import {
|
|
|
245
|
+ listYakHerdInventory,
|
|
|
246
|
+ getYakHerdInventory,
|
|
|
247
|
+ addYakHerdInventory,
|
|
|
248
|
+ updateYakHerdInventory,
|
|
|
249
|
+ delYakHerdInventory,
|
|
|
250
|
+ listYakHerdInventoryYearOptions,
|
|
|
251
|
+ listYakHerdInventoryTownOptions,
|
|
|
252
|
+ importYakHerdInventory,
|
|
|
253
|
+ downloadYakHerdInventoryTemplate,
|
|
|
254
|
+ exportYakHerdInventory
|
|
|
255
|
+} from "@/api/dataModel/yakHerdInventory"
|
|
|
256
|
+import { blobValidate } from "@/utils/ruoyi"
|
|
|
257
|
+import { saveAs } from "file-saver"
|
|
|
258
|
+
|
|
|
259
|
+const COUNT_FIELDS = [
|
|
|
260
|
+ { prop: "villageCount", labelKey: "formVillageCount", unitKey: "unitGe" },
|
|
|
261
|
+ { prop: "herdsmanHouseholdCount", labelKey: "formHerdsmanHouseholdCount", unitKey: "unitHousehold" },
|
|
|
262
|
+ { prop: "yakTotal", labelKey: "formYakTotal", unitKey: "unitHead" },
|
|
|
263
|
+ { prop: "bullTotal", labelKey: "formBullTotal", unitKey: "unitHead" },
|
|
|
264
|
+ { prop: "cowTotal", labelKey: "formCowTotal", unitKey: "unitHead" },
|
|
|
265
|
+ { prop: "breedingBullCount", labelKey: "formBreedingBullCount", unitKey: "unitHead" },
|
|
|
266
|
+ { prop: "bullCastratedCount", labelKey: "formBullCastratedCount", unitKey: "unitHead" },
|
|
|
267
|
+ { prop: "cowUnder1Count", labelKey: "formCowUnder1Count", unitKey: "unitHead" },
|
|
|
268
|
+ { prop: "cow13Count", labelKey: "formCow13Count", unitKey: "unitHead" },
|
|
|
269
|
+ { prop: "cow312Count", labelKey: "formCow312Count", unitKey: "unitHead" },
|
|
|
270
|
+ { prop: "cowOver12Count", labelKey: "formCowOver12Count", unitKey: "unitHead" }
|
|
|
271
|
+]
|
|
|
272
|
+
|
|
|
273
|
+function createEmptyForm() {
|
|
|
274
|
+ const form = {
|
|
|
275
|
+ id: undefined,
|
|
|
276
|
+ statYear: undefined,
|
|
|
277
|
+ townDeptId: undefined,
|
|
|
278
|
+ remark: undefined
|
|
|
279
|
+ }
|
|
|
280
|
+ COUNT_FIELDS.forEach((field) => {
|
|
|
281
|
+ form[field.prop] = 0
|
|
|
282
|
+ })
|
|
|
283
|
+ return form
|
|
|
284
|
+}
|
|
|
285
|
+
|
|
|
286
|
+function normalizeCountFields(data) {
|
|
|
287
|
+ const row = Object.assign(createEmptyForm(), data || {})
|
|
|
288
|
+ COUNT_FIELDS.forEach((field) => {
|
|
|
289
|
+ const val = row[field.prop]
|
|
|
290
|
+ row[field.prop] = val == null || val === "" ? 0 : val
|
|
|
291
|
+ })
|
|
|
292
|
+ return row
|
|
|
293
|
+}
|
|
|
294
|
+
|
|
|
295
|
+export default {
|
|
|
296
|
+ name: "YakHerdInventory",
|
|
|
297
|
+ mixins: [dataModelLocaleMixin],
|
|
|
298
|
+ data() {
|
|
|
299
|
+ return {
|
|
|
300
|
+ dmNs: "yakHerdInventory",
|
|
|
301
|
+ loading: false,
|
|
|
302
|
+ importing: false,
|
|
|
303
|
+ exporting: false,
|
|
|
304
|
+ open: false,
|
|
|
305
|
+ viewOpen: false,
|
|
|
306
|
+ importOpen: false,
|
|
|
307
|
+ exportOpen: false,
|
|
|
308
|
+ dialogEdit: false,
|
|
|
309
|
+ formKey: 0,
|
|
|
310
|
+ total: 0,
|
|
|
311
|
+ tableList: [],
|
|
|
312
|
+ yearOptions: [],
|
|
|
313
|
+ townOptions: [],
|
|
|
314
|
+ viewRow: {},
|
|
|
315
|
+ importForm: {
|
|
|
316
|
+ statYear: undefined
|
|
|
317
|
+ },
|
|
|
318
|
+ exportForm: {
|
|
|
319
|
+ statYear: undefined
|
|
|
320
|
+ },
|
|
|
321
|
+ queryParams: {
|
|
|
322
|
+ pageNum: 1,
|
|
|
323
|
+ pageSize: 20,
|
|
|
324
|
+ statYear: undefined,
|
|
|
325
|
+ townDeptId: undefined
|
|
|
326
|
+ },
|
|
|
327
|
+ form: createEmptyForm()
|
|
|
328
|
+ }
|
|
|
329
|
+ },
|
|
|
330
|
+ computed: {
|
|
|
331
|
+ dash() {
|
|
|
332
|
+ return this.$t("dataModel.status.dash")
|
|
|
333
|
+ },
|
|
|
334
|
+ countFields() {
|
|
|
335
|
+ return COUNT_FIELDS
|
|
|
336
|
+ },
|
|
|
337
|
+ dialogTitle() {
|
|
|
338
|
+ return this.dialogEdit ? this.dmT("dialogEdit") : this.dmT("dialogAdd")
|
|
|
339
|
+ },
|
|
|
340
|
+ formRules() {
|
|
|
341
|
+ return {
|
|
|
342
|
+ statYear: [{ required: true, message: this.dmT("ruleStatYearRequired"), trigger: "change" }],
|
|
|
343
|
+ townDeptId: [{ required: true, message: this.dmT("ruleTownRequired"), trigger: "change" }],
|
|
|
344
|
+ count: [
|
|
|
345
|
+ { required: true, message: this.dmT("ruleCountRequired"), trigger: "change" },
|
|
|
346
|
+ { validator: this.validateRequiredCount, trigger: "change" }
|
|
|
347
|
+ ],
|
|
|
348
|
+ remark: [{ max: 500, message: this.dmCommon("ruleLen500"), trigger: "blur" }]
|
|
|
349
|
+ }
|
|
|
350
|
+ },
|
|
|
351
|
+ importRules() {
|
|
|
352
|
+ return {
|
|
|
353
|
+ statYear: [{ required: true, message: this.dmT("ruleStatYearRequired"), trigger: "change" }]
|
|
|
354
|
+ }
|
|
|
355
|
+ },
|
|
|
356
|
+ exportRules() {
|
|
|
357
|
+ return {
|
|
|
358
|
+ statYear: [{ required: true, message: this.dmT("exportStatYearRequired"), trigger: "change" }]
|
|
|
359
|
+ }
|
|
|
360
|
+ }
|
|
|
361
|
+ },
|
|
|
362
|
+ created() {
|
|
|
363
|
+ this.loadOptions()
|
|
|
364
|
+ this.getList()
|
|
|
365
|
+ },
|
|
|
366
|
+ methods: {
|
|
|
367
|
+ loadOptions() {
|
|
|
368
|
+ listYakHerdInventoryYearOptions().then((res) => {
|
|
|
369
|
+ this.yearOptions = Array.isArray(res.data) ? res.data : []
|
|
|
370
|
+ })
|
|
|
371
|
+ listYakHerdInventoryTownOptions().then((res) => {
|
|
|
372
|
+ this.townOptions = Array.isArray(res.data) ? res.data : []
|
|
|
373
|
+ })
|
|
|
374
|
+ },
|
|
|
375
|
+ formatCount(val) {
|
|
|
376
|
+ if (val == null || val === "") {
|
|
|
377
|
+ return this.dash
|
|
|
378
|
+ }
|
|
|
379
|
+ return val
|
|
|
380
|
+ },
|
|
|
381
|
+ validateRequiredCount(rule, value, callback) {
|
|
|
382
|
+ if (value == null || value === "") {
|
|
|
383
|
+ callback(new Error(this.dmT("ruleCountRequired")))
|
|
|
384
|
+ return
|
|
|
385
|
+ }
|
|
|
386
|
+ if (!Number.isInteger(value) || value < 0) {
|
|
|
387
|
+ callback(new Error(this.dmT("ruleCountNonNegative")))
|
|
|
388
|
+ return
|
|
|
389
|
+ }
|
|
|
390
|
+ callback()
|
|
|
391
|
+ },
|
|
|
392
|
+ buildListQuery() {
|
|
|
393
|
+ const q = {
|
|
|
394
|
+ pageNum: this.queryParams.pageNum,
|
|
|
395
|
+ pageSize: this.queryParams.pageSize
|
|
|
396
|
+ }
|
|
|
397
|
+ if (this.queryParams.statYear != null) {
|
|
|
398
|
+ q.statYear = this.queryParams.statYear
|
|
|
399
|
+ }
|
|
|
400
|
+ if (this.queryParams.townDeptId != null) {
|
|
|
401
|
+ q.townDeptId = this.queryParams.townDeptId
|
|
|
402
|
+ }
|
|
|
403
|
+ return q
|
|
|
404
|
+ },
|
|
|
405
|
+ buildPayload() {
|
|
|
406
|
+ const remarkText = this.form.remark != null ? String(this.form.remark).trim() : ""
|
|
|
407
|
+ const payload = {
|
|
|
408
|
+ statYear: this.form.statYear,
|
|
|
409
|
+ townDeptId: this.form.townDeptId,
|
|
|
410
|
+ remark: remarkText !== "" ? remarkText : undefined
|
|
|
411
|
+ }
|
|
|
412
|
+ COUNT_FIELDS.forEach((field) => {
|
|
|
413
|
+ payload[field.prop] = this.form[field.prop]
|
|
|
414
|
+ })
|
|
|
415
|
+ return payload
|
|
|
416
|
+ },
|
|
|
417
|
+ getList() {
|
|
|
418
|
+ this.loading = true
|
|
|
419
|
+ listYakHerdInventory(this.buildListQuery())
|
|
|
420
|
+ .then((res) => {
|
|
|
421
|
+ this.tableList = res.rows || []
|
|
|
422
|
+ this.total = res.total != null ? res.total : 0
|
|
|
423
|
+ })
|
|
|
424
|
+ .finally(() => {
|
|
|
425
|
+ this.loading = false
|
|
|
426
|
+ })
|
|
|
427
|
+ },
|
|
|
428
|
+ handleQuery() {
|
|
|
429
|
+ this.queryParams.pageNum = 1
|
|
|
430
|
+ this.getList()
|
|
|
431
|
+ },
|
|
|
432
|
+ resetQuery() {
|
|
|
433
|
+ this.queryParams.statYear = undefined
|
|
|
434
|
+ this.queryParams.townDeptId = undefined
|
|
|
435
|
+ this.resetForm("queryForm")
|
|
|
436
|
+ this.handleQuery()
|
|
|
437
|
+ },
|
|
|
438
|
+ handleAdd() {
|
|
|
439
|
+ this.formKey += 1
|
|
|
440
|
+ this.form = createEmptyForm()
|
|
|
441
|
+ this.dialogEdit = false
|
|
|
442
|
+ this.open = true
|
|
|
443
|
+ this.$nextTick(() => {
|
|
|
444
|
+ if (this.$refs.form) {
|
|
|
445
|
+ this.$refs.form.clearValidate()
|
|
|
446
|
+ }
|
|
|
447
|
+ })
|
|
|
448
|
+ },
|
|
|
449
|
+ handleEdit(row) {
|
|
|
450
|
+ getYakHerdInventory(row.id).then((res) => {
|
|
|
451
|
+ const data = res.data || {}
|
|
|
452
|
+ this.formKey += 1
|
|
|
453
|
+ this.dialogEdit = true
|
|
|
454
|
+ this.form = normalizeCountFields(data)
|
|
|
455
|
+ this.open = true
|
|
|
456
|
+ this.viewOpen = false
|
|
|
457
|
+ this.$nextTick(() => {
|
|
|
458
|
+ if (this.$refs.form) {
|
|
|
459
|
+ this.$refs.form.clearValidate()
|
|
|
460
|
+ }
|
|
|
461
|
+ })
|
|
|
462
|
+ })
|
|
|
463
|
+ },
|
|
|
464
|
+ handleEditFromView() {
|
|
|
465
|
+ this.handleEdit(this.viewRow)
|
|
|
466
|
+ },
|
|
|
467
|
+ handleView(row) {
|
|
|
468
|
+ getYakHerdInventory(row.id).then((res) => {
|
|
|
469
|
+ this.viewRow = res.data || {}
|
|
|
470
|
+ this.viewOpen = true
|
|
|
471
|
+ })
|
|
|
472
|
+ },
|
|
|
473
|
+ handleDelete(row) {
|
|
|
474
|
+ this.$modal
|
|
|
475
|
+ .confirm(this.dmT("confirmDelete"))
|
|
|
476
|
+ .then(() => delYakHerdInventory(row.id))
|
|
|
477
|
+ .then(() => {
|
|
|
478
|
+ this.$modal.msgSuccess(this.dmCommon("msgDelOk"))
|
|
|
479
|
+ this.viewOpen = false
|
|
|
480
|
+ this.getList()
|
|
|
481
|
+ })
|
|
|
482
|
+ .catch(() => {})
|
|
|
483
|
+ },
|
|
|
484
|
+ submitForm() {
|
|
|
485
|
+ this.$refs.form.validate((valid) => {
|
|
|
486
|
+ if (!valid) {
|
|
|
487
|
+ return
|
|
|
488
|
+ }
|
|
|
489
|
+ const payload = this.buildPayload()
|
|
|
490
|
+ if (this.dialogEdit) {
|
|
|
491
|
+ payload.id = this.form.id
|
|
|
492
|
+ updateYakHerdInventory(payload).then(() => {
|
|
|
493
|
+ this.$modal.msgSuccess(this.dmCommon("msgModOk"))
|
|
|
494
|
+ this.open = false
|
|
|
495
|
+ this.getList()
|
|
|
496
|
+ })
|
|
|
497
|
+ } else {
|
|
|
498
|
+ addYakHerdInventory(payload).then(() => {
|
|
|
499
|
+ this.$modal.msgSuccess(this.dmCommon("msgAddOk"))
|
|
|
500
|
+ this.open = false
|
|
|
501
|
+ this.getList()
|
|
|
502
|
+ })
|
|
|
503
|
+ }
|
|
|
504
|
+ })
|
|
|
505
|
+ },
|
|
|
506
|
+ cancel() {
|
|
|
507
|
+ this.open = false
|
|
|
508
|
+ this.form = createEmptyForm()
|
|
|
509
|
+ },
|
|
|
510
|
+ handleImportOpen() {
|
|
|
511
|
+ this.importForm.statYear = this.queryParams.statYear
|
|
|
512
|
+ this.importOpen = true
|
|
|
513
|
+ this.$nextTick(() => {
|
|
|
514
|
+ this.resetImportFiles()
|
|
|
515
|
+ })
|
|
|
516
|
+ },
|
|
|
517
|
+ resetImportFiles() {
|
|
|
518
|
+ if (this.$refs.importUpload) {
|
|
|
519
|
+ this.$refs.importUpload.clearFiles()
|
|
|
520
|
+ }
|
|
|
521
|
+ },
|
|
|
522
|
+ resetImport() {
|
|
|
523
|
+ this.importing = false
|
|
|
524
|
+ this.importForm.statYear = undefined
|
|
|
525
|
+ this.resetImportFiles()
|
|
|
526
|
+ },
|
|
|
527
|
+ handleDownloadTemplate() {
|
|
|
528
|
+ const filename = `yak_herd_inventory_template_${new Date().getTime()}.xlsx`
|
|
|
529
|
+ this.$modal.loading("正在下载模板,请稍候")
|
|
|
530
|
+ downloadYakHerdInventoryTemplate()
|
|
|
531
|
+ .then(async (data) => {
|
|
|
532
|
+ if (blobValidate(data)) {
|
|
|
533
|
+ saveAs(new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), filename)
|
|
|
534
|
+ } else {
|
|
|
535
|
+ const resText = await data.text()
|
|
|
536
|
+ const rspObj = JSON.parse(resText)
|
|
|
537
|
+ this.$modal.msgError(rspObj.msg || "下载模板失败")
|
|
|
538
|
+ }
|
|
|
539
|
+ })
|
|
|
540
|
+ .catch(() => {
|
|
|
541
|
+ this.$modal.msgError("下载模板失败")
|
|
|
542
|
+ })
|
|
|
543
|
+ .finally(() => {
|
|
|
544
|
+ this.$modal.closeLoading()
|
|
|
545
|
+ })
|
|
|
546
|
+ },
|
|
|
547
|
+ handleExportOpen() {
|
|
|
548
|
+ this.exportForm.statYear = this.queryParams.statYear
|
|
|
549
|
+ this.exportOpen = true
|
|
|
550
|
+ this.$nextTick(() => {
|
|
|
551
|
+ if (this.$refs.exportFormRef) {
|
|
|
552
|
+ this.$refs.exportFormRef.clearValidate()
|
|
|
553
|
+ }
|
|
|
554
|
+ })
|
|
|
555
|
+ },
|
|
|
556
|
+ resetExport() {
|
|
|
557
|
+ this.exporting = false
|
|
|
558
|
+ this.exportForm.statYear = undefined
|
|
|
559
|
+ },
|
|
|
560
|
+ handleExportSubmit() {
|
|
|
561
|
+ this.$refs.exportFormRef.validate((valid) => {
|
|
|
562
|
+ if (!valid) {
|
|
|
563
|
+ return
|
|
|
564
|
+ }
|
|
|
565
|
+ const statYear = this.exportForm.statYear
|
|
|
566
|
+ if (!this.yearOptions.includes(statYear)) {
|
|
|
567
|
+ this.$modal.msgError(this.dmT("exportStatYearInvalid"))
|
|
|
568
|
+ return
|
|
|
569
|
+ }
|
|
|
570
|
+ const filename = `${statYear}年牦牛存栏数据.xlsx`
|
|
|
571
|
+ this.exporting = true
|
|
|
572
|
+ this.$modal.loading(this.dmT("exportLoading"))
|
|
|
573
|
+ exportYakHerdInventory(statYear)
|
|
|
574
|
+ .then(async (data) => {
|
|
|
575
|
+ if (blobValidate(data)) {
|
|
|
576
|
+ saveAs(new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), filename)
|
|
|
577
|
+ this.exportOpen = false
|
|
|
578
|
+ } else {
|
|
|
579
|
+ const resText = await data.text()
|
|
|
580
|
+ const rspObj = JSON.parse(resText)
|
|
|
581
|
+ this.$modal.msgError(rspObj.msg || this.dmT("exportFail"))
|
|
|
582
|
+ }
|
|
|
583
|
+ })
|
|
|
584
|
+ .catch(() => {
|
|
|
585
|
+ this.$modal.msgError(this.dmT("exportFail"))
|
|
|
586
|
+ })
|
|
|
587
|
+ .finally(() => {
|
|
|
588
|
+ this.exporting = false
|
|
|
589
|
+ this.$modal.closeLoading()
|
|
|
590
|
+ })
|
|
|
591
|
+ })
|
|
|
592
|
+ },
|
|
|
593
|
+ handleImportSubmit() {
|
|
|
594
|
+ this.$refs.importFormRef.validate((valid) => {
|
|
|
595
|
+ if (!valid) {
|
|
|
596
|
+ return
|
|
|
597
|
+ }
|
|
|
598
|
+ const upload = this.$refs.importUpload
|
|
|
599
|
+ const files = upload && upload.uploadFiles
|
|
|
600
|
+ if (!files || !files.length) {
|
|
|
601
|
+ this.$modal.msgError("请选择要上传的文件")
|
|
|
602
|
+ return
|
|
|
603
|
+ }
|
|
|
604
|
+ const raw = files[0].raw
|
|
|
605
|
+ const name = (raw.name || "").toLowerCase()
|
|
|
606
|
+ if (!name.endsWith(".xlsx") && !name.endsWith(".xls")) {
|
|
|
607
|
+ this.$modal.msgError('请选择后缀为 "xls" 或 "xlsx" 的文件')
|
|
|
608
|
+ return
|
|
|
609
|
+ }
|
|
|
610
|
+ this.importing = true
|
|
|
611
|
+ this.$modal.loading(this.dmT("importLoading"))
|
|
|
612
|
+ importYakHerdInventory(raw, this.importForm.statYear)
|
|
|
613
|
+ .then((res) => {
|
|
|
614
|
+ this.importOpen = false
|
|
|
615
|
+ this.showImportResult(res.data || {})
|
|
|
616
|
+ this.getList()
|
|
|
617
|
+ })
|
|
|
618
|
+ .finally(() => {
|
|
|
619
|
+ this.importing = false
|
|
|
620
|
+ this.$modal.closeLoading()
|
|
|
621
|
+ this.resetImportFiles()
|
|
|
622
|
+ })
|
|
|
623
|
+ })
|
|
|
624
|
+ },
|
|
|
625
|
+ showImportResult(data) {
|
|
|
626
|
+ const insert = data.insertCount != null ? data.insertCount : 0
|
|
|
627
|
+ const update = data.updateCount != null ? data.updateCount : 0
|
|
|
628
|
+ const fail = data.failCount != null ? data.failCount : 0
|
|
|
629
|
+ let html = this.dmT("importSummary", { insert, update, fail })
|
|
|
630
|
+ if (data.warnMessages && data.warnMessages.length) {
|
|
|
631
|
+ html += `<p><strong>${this.dmT("importWarnTitle")}</strong></p><p>${data.warnMessages.join("<br/>")}</p>`
|
|
|
632
|
+ }
|
|
|
633
|
+ if (data.failMessages && data.failMessages.length) {
|
|
|
634
|
+ html += `<p><strong>${this.dmT("importFailTitle")}</strong></p><p>${data.failMessages.join("<br/>")}</p>`
|
|
|
635
|
+ }
|
|
|
636
|
+ this.$alert(
|
|
|
637
|
+ `<div style='overflow:auto;overflow-x:hidden;max-height:70vh;padding:10px 20px 0;'>${html}</div>`,
|
|
|
638
|
+ this.dmT("importTitle"),
|
|
|
639
|
+ { dangerouslyUseHTMLString: true }
|
|
|
640
|
+ )
|
|
|
641
|
+ }
|
|
|
642
|
+ }
|
|
|
643
|
+}
|
|
|
644
|
+</script>
|
|
|
645
|
+
|
|
|
646
|
+<style scoped>
|
|
|
647
|
+.yhi-section-title {
|
|
|
648
|
+ margin: 4px 0 12px;
|
|
|
649
|
+ padding-left: 8px;
|
|
|
650
|
+ font-size: 14px;
|
|
|
651
|
+ font-weight: 600;
|
|
|
652
|
+ color: #303133;
|
|
|
653
|
+ border-left: 3px solid #409eff;
|
|
|
654
|
+}
|
|
|
655
|
+
|
|
|
656
|
+.yhi-view-text {
|
|
|
657
|
+ white-space: pre-wrap;
|
|
|
658
|
+ word-break: break-word;
|
|
|
659
|
+}
|
|
|
660
|
+
|
|
|
661
|
+.yhi-import-tip {
|
|
|
662
|
+ margin: 0 0 12px;
|
|
|
663
|
+ font-size: 12px;
|
|
|
664
|
+ color: #909399;
|
|
|
665
|
+ line-height: 1.6;
|
|
|
666
|
+}
|
|
|
667
|
+
|
|
|
668
|
+.dm-input-with-unit {
|
|
|
669
|
+ display: flex;
|
|
|
670
|
+ align-items: center;
|
|
|
671
|
+ width: 100%;
|
|
|
672
|
+}
|
|
|
673
|
+.dm-input-with-unit__input {
|
|
|
674
|
+ flex: 1;
|
|
|
675
|
+ width: 0;
|
|
|
676
|
+}
|
|
|
677
|
+.dm-input-with-unit__input ::v-deep.el-input-number {
|
|
|
678
|
+ width: 100%;
|
|
|
679
|
+}
|
|
|
680
|
+.dm-input-with-unit__suffix {
|
|
|
681
|
+ flex-shrink: 0;
|
|
|
682
|
+ margin-left: 8px;
|
|
|
683
|
+ color: #606266;
|
|
|
684
|
+ font-size: 14px;
|
|
|
685
|
+ white-space: nowrap;
|
|
|
686
|
+}
|
|
|
687
|
+</style>
|