b951d827
刘淇
树木详情
|
1
2
3
|
<template>
<view class="container">
<tui-form ref="form" :show-message="false" :model="formData">
|
c42a36b8
刘淇
首页 图表新增排序
|
4
5
|
<tui-form-item asterisk label="名称" prop="treetype" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="30" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
6
7
8
9
|
v-model="formData.treetype"></tui-input>
</tui-form-item>
<tui-row>
|
73dee4bd
刘淇
高度非必填
|
10
|
|
b951d827
刘淇
树木详情
|
11
|
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
12
13
|
<tui-form-item label="胸径" asterisk prop="dbh" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
73dee4bd
刘淇
高度非必填
|
14
|
v-model="formData.dbh"></tui-input>
|
b951d827
刘淇
树木详情
|
15
|
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
16
|
<text style="padding-left: 12rpx;color:#ccc;font-size:14px">厘米</text>
|
b951d827
刘淇
树木详情
|
17
18
19
|
</template>
</tui-form-item>
</tui-col>
|
73dee4bd
刘淇
高度非必填
|
20
|
|
b951d827
刘淇
树木详情
|
21
|
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
22
23
|
<tui-form-item label="高度" prop="treeheight" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
73dee4bd
刘淇
高度非必填
|
24
|
v-model="formData.treeheight"></tui-input>
|
b951d827
刘淇
树木详情
|
25
|
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
26
|
<text style="padding-left: 12rpx;color:#ccc;font-size:14px;">米</text>
|
b951d827
刘淇
树木详情
|
27
28
29
30
31
32
33
34
35
36
37
|
</template>
</tui-form-item>
</tui-col>
</tui-row>
<tui-form-item
asterisk
label="位置"
class="location-form-item"
prop="growlocation"
|
c42a36b8
刘淇
首页 图表新增排序
|
38
|
:labelSize="32"
|
b951d827
刘淇
树木详情
|
39
|
>
|
c42a36b8
刘淇
首页 图表新增排序
|
40
|
<tui-input padding="0" :borderBottom="false" placeholder="" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
41
42
43
44
45
46
47
48
|
v-model="formData.growlocation"></tui-input>
<template v-slot:right>
<tui-icon name="gps" :size="20"></tui-icon>
</template>
</tui-form-item>
<tui-col :span="12">
<tui-form-item
|
137be4e2
刘淇
树木历史
|
49
|
label="经度"
|
b951d827
刘淇
树木详情
|
50
|
class="location-form-item"
|
b951d827
刘淇
树木详情
|
51
|
prop="latitude"
|
73dee4bd
刘淇
高度非必填
|
52
|
labelColor="#ccc"
|
c42a36b8
刘淇
首页 图表新增排序
|
53
|
:labelSize="32"
|
b951d827
刘淇
树木详情
|
54
|
>
|
c42a36b8
刘淇
首页 图表新增排序
|
55
|
<tui-input padding="0" :borderBottom="false" placeholder="" disabled :size="32"
|
f883eafa
刘淇
首次加载
|
56
57
|
v-model="formData.longitude"></tui-input>
<!-- <span style="color: #ccc;font-size: 14px"> {{ formData.longitude }}</span>-->
|
b951d827
刘淇
树木详情
|
58
59
|
</tui-form-item>
</tui-col>
|
137be4e2
刘淇
树木历史
|
60
|
|
b951d827
刘淇
树木详情
|
61
62
|
<tui-col :span="12">
<tui-form-item
|
137be4e2
刘淇
树木历史
|
63
|
label="纬度"
|
b951d827
刘淇
树木详情
|
64
|
class="location-form-item"
|
73dee4bd
刘淇
高度非必填
|
65
|
labelColor="#ccc"
|
b951d827
刘淇
树木详情
|
66
|
prop="latitude"
|
c42a36b8
刘淇
首页 图表新增排序
|
67
|
:labelSize="32"
|
b951d827
刘淇
树木详情
|
68
|
>
|
c42a36b8
刘淇
首页 图表新增排序
|
69
|
<tui-input padding="0" :borderBottom="false" placeholder="" disabled :size="32"
|
f883eafa
刘淇
首次加载
|
70
71
|
v-model="formData.latitude"></tui-input>
<!-- <span style="color: #ccc;font-size: 14px"> {{ formData.latitude }}</span>-->
|
b951d827
刘淇
树木详情
|
72
73
74
75
|
</tui-form-item>
</tui-col>
|
c42a36b8
刘淇
首页 图表新增排序
|
76
|
<tui-form-item asterisk label="管护单位" prop="managedutyunit" :labelSize="32">
|
b951d827
刘淇
树木详情
|
77
|
|
c42a36b8
刘淇
首页 图表新增排序
|
78
|
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="30" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
79
80
81
82
83
|
v-model="formData.managedutyunit"></tui-input>
<!-- <tui-input padding="0" :borderBottom="false" placeholder="请选择" disabled-->
<!-- backgroundColor="transparent" v-model="formData.managedutyunit"></tui-input>-->
</tui-form-item>
|
c42a36b8
刘淇
首页 图表新增排序
|
84
85
|
<tui-form-item asterisk label="权属分类" arrow highlight prop="oldtreeownershipText" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
86
87
88
|
backgroundColor="transparent" v-model="formData.oldtreeownershipText"></tui-input>
</tui-form-item>
|
c42a36b8
刘淇
首页 图表新增排序
|
89
|
<tui-form-item label="图片信息" asterisk prop="treeImgList" :labelSize="32">
|
b951d827
刘淇
树木详情
|
90
91
92
93
94
95
96
|
<!-- <tui-image-group :imageList="formData.treeImgList" radius="0"></tui-image-group>-->
<!-- 图片组组件 -->
<tui-image-group
:imageList="formData.treeImgList"
radius="0"
|
c872bdb3
刘淇
树木详情
|
97
|
@click="previewImage"
|
b951d827
刘淇
树木详情
|
98
99
100
101
102
103
104
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
|
>
</tui-image-group>
<!-- 使用ThorUI的tui-upload组件 -->
<!-- @remove="handleRemove" :multiple="true" :value="formData.treeImgList"-->
<!-- <tui-upload :disabled="true"-->
<!-- :height="140"-->
<!-- :width="140"-->
<!-- :value="formData.treeImgListFile"-->
<!-- :serverUrl="serverURL" :header="{'Authorization': userToken}"-->
<!-- @complete="handleComplete"-->
<!-- @remove="handleRemove"-->
<!-- :limit="3"-->
<!-- accept="image/*"-->
<!-- >-->
<!-- <!– 自定义上传按钮 –>-->
<!-- <view class="upload-btn">-->
<!-- <tui-icon name="plus" size="32" color="#999"></tui-icon>-->
<!-- </view>-->
<!-- <!– 提示信息 –>-->
<!-- <!– <view class="upload-tips">–>-->
<!-- <!– 最多上传3张图片,单张不超过5MB–>-->
<!-- <!– </view>–>-->
<!-- </tui-upload>-->
<!-- 提示信息 -->
<!-- <view class="upload-tips">-->
<!-- 最多上传3张图片,单张不超过5MB-->
<!-- </view>-->
</tui-form-item>
<tui-row>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
134
135
|
<tui-form-item label="拉丁文" prop="latinname" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="30" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
136
137
138
139
|
v-model="formData.latinname"></tui-input>
</tui-form-item>
</tui-col>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
140
141
|
<tui-form-item label="级别" arrow highlight prop="treeleveltext" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
142
143
144
145
146
|
backgroundColor="transparent" v-model="formData.treeleveltext"></tui-input>
</tui-form-item>
</tui-col>
</tui-row>
|
c42a36b8
刘淇
首页 图表新增排序
|
147
148
|
<tui-form-item label="生长环境" prop="growthenvironment" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="50" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
149
150
151
152
153
154
|
v-model="formData.growthenvironment"></tui-input>
</tui-form-item>
<tui-row>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
155
156
|
<tui-form-item label="预估树龄" prop="estimationtreeage" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
157
158
|
v-model="formData.estimationtreeage"></tui-input>
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
159
|
<text style="padding-left: 12rpx;color:#ccc;font-size: 14px">年</text>
|
b951d827
刘淇
树木详情
|
160
161
162
163
|
</template>
</tui-form-item>
</tui-col>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
164
165
|
<tui-form-item label="干周" prop="weekday" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
166
167
|
v-model="formData.weekday"></tui-input>
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
168
|
<text style="padding-left: 12rpx;color:#ccc;font-size: 14px">厘米</text>
|
b951d827
刘淇
树木详情
|
169
170
171
172
173
174
175
176
|
</template>
</tui-form-item>
</tui-col>
</tui-row>
<tui-row>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
177
178
|
<tui-form-item label="东西冠幅" prop="canopyeastwest" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
179
180
|
v-model="formData.canopyeastwest"></tui-input>
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
181
|
<text style="padding-left: 12rpx;color:#ccc;font-size: 14px">米</text>
|
b951d827
刘淇
树木详情
|
182
183
184
185
|
</template>
</tui-form-item>
</tui-col>
<tui-col :span="12">
|
c42a36b8
刘淇
首页 图表新增排序
|
186
187
|
<tui-form-item label="南北冠幅" prop="canopysouthnorth" :position="2" :labelSize="32">
<tui-input padding="0" :borderBottom="false" placeholder="" maxlength="10" :disabled="true" :size="32"
|
b951d827
刘淇
树木详情
|
188
189
|
v-model="formData.canopysouthnorth"></tui-input>
<template v-slot:right>
|
c42a36b8
刘淇
首页 图表新增排序
|
190
|
<text style="padding-left: 12rpx;color:#ccc;font-size: 14px">米</text>
|
b951d827
刘淇
树木详情
|
191
192
193
194
195
196
|
</template>
</tui-form-item>
</tui-col>
</tui-row>
</tui-form>
|
b951d827
刘淇
树木详情
|
197
198
199
200
201
|
</view>
</template>
<script>
import { uploadURL, OSSURL } from '@/config/app'
|
7fc91f7a
刘淇
上传体验版优化
|
202
|
import { treeOwnership, treeLevelReq } from "@/subPackages/common/api/tree.js";
|
c872bdb3
刘淇
树木详情
|
203
|
import { useCounterStore } from '@/stores/counter'
|
b951d827
刘淇
树木详情
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
const rules = [{
name: "treetype",
rule: ["required"],
msg: ["请输入名称"]
}, {
name: "treeheight",
rule: ["required", "maxLength:10", "isAmount"],
msg: ["请输入数高", "数高不能超过10个字符", "请输入正确"]
}, {
name: "dbh",
rule: ["required", "maxLength:10", "isAmount"],
msg: ["请输入胸径", "胸径不能超过10个字符", "请输入正确"]
}, {
name: "estimationtreeage",
rule: ["maxLength:10", "isAmount"],
msg: ["胸径不能超过10个字符", "请输入正确"]
},
{
name: "weekday",
rule: ["maxLength:10", "isAmount"],
msg: ["胸径不能超过10个字符", "请输入正确"]
},
{
name: "canopyeastwest",
rule: ["maxLength:10", "isAmount"],
msg: ["胸径不能超过10个字符", "请输入正确"]
},
{
name: "canopysouthnorth",
rule: ["maxLength:10", "isAmount"],
msg: ["胸径不能超过10个字符", "请输入正确"]
}, {
name: "growlocation",
rule: ["required"],
msg: ["请地图选择位置"]
}, {
name: "managedutyunit",
rule: ["required"],
msg: ["请选择权属单位"]
}, {
name: "oldtreeownershipText",
rule: ["required"],
msg: ["请选择权属分类"]
}, {
name: "treeImgListFile",
rule: ["required", "custom"], // 增加required强制必选
msg: ["请上传图片", "请至少上传一张图片"], // 对应两个规则的提示
custom: function (value) {
// 即使required通过,再校验数组长度
return value.length > 0;
}
}];
export default {
data() {
return {
|
c872bdb3
刘淇
树木详情
|
259
|
// 当前预览索引
|
b951d827
刘淇
树木详情
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
currentIndex: 0,
// 是否显示预览弹窗
show: false,
urls: [],
treeOwnershipData: [],
treeLevelData: [], // 级别
//仅对部分数据进行收集演示
formData: {
//数名
treetype: '',
//树高
treeheight: '',
//胸径
dbh: '',
//级别
treelevel: '',
treeleveltext: '',
//权属单位
managedutyunit: '',
//权属分类
oldtreeownership: '',
oldtreeownershipText: '',
latinname: '', // 拉丁名
estimationtreeage: '', // 估测树龄
canopysouthnorth: '', // 冠幅南北
canopyeastwest: '', // 冠幅东西
weekday: '', // 干周
growlocation: '', // 位置
growthenvironment: '', // 生长环境
treeImgList: [], // 图片信息
treeImgListFile: [], // 图片信息
address: '', // 位置名称
latitude: '', // 纬度
longitude: '', // 经度
road: ''
},
}
},
|
c872bdb3
刘淇
树木详情
|
298
299
300
301
302
303
|
computed: {
// 获取共享store实例
useCounterStore() {
return useCounterStore()
}
},
|
b951d827
刘淇
树木详情
|
304
305
306
|
onReady() {
//开启即时校验,开启后输入即校验【参数必传】,第一参数:是否开启;第二参数:校验规则
// 开启即时校验,参数:是否开启、校验规则
|
c872bdb3
刘淇
树木详情
|
307
308
309
310
|
// this.$refs.form && this.$refs.form.immediateValidate(true, rules);
},
onUnload() {
|
b951d827
刘淇
树木详情
|
311
|
},
|
7fc91f7a
刘淇
上传体验版优化
|
312
313
314
|
onLoad() {
},
onShow(){
|
c872bdb3
刘淇
树木详情
|
315
|
const treeData = this.useCounterStore.treeData;
|
c872bdb3
刘淇
树木详情
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
this.formData = {
...treeData,
// 仅在当前组件中临时转换为对象数组,不修改Pinia源数据
treeImgList: treeData.treeImgList.map((item, index) => {
return { id: index*Math.random()*10, src: item };
})
};
this.urls = treeData.treeImgList
// this.formData.treeImgList = this.formData.treeImgList.map((item, index) => {
// return {
// id: index*Math.random()*10,
// src: item
// }
// });
|
b951d827
刘淇
树木详情
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
treeLevelReq().then(res => {
this.treeLevelData = res.data
const optiontreelevel = this.treeLevelData.find(item => item.dictValue === this.formData.treelevel);
if (optiontreelevel) {
this.formData.treelevel = optiontreelevel.dictValue;
this.formData.treeleveltext = optiontreelevel.dictLabel;
}
})
treeOwnership().then(res => {
this.treeOwnershipData = res.data
const option = this.treeOwnershipData.find(item => item.dictValue === this.formData.oldtreeownership);
if (option) {
this.formData.oldtreeownership = option.dictValue;
this.formData.oldtreeownershipText = option.dictLabel;
}
})
|
b951d827
刘淇
树木详情
|
347
348
|
},
methods: {
|
c872bdb3
刘淇
树木详情
|
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
// 图片预览
previewImage(e) {
// 获取当前点击的图片索引(不同版本组件可能参数不同)
const index = e.index || 0;
// 使用uni-app自带的图片预览API
uni.previewImage({
// 预览的图片地址列表
urls: this.urls,
// 初始显示的图片索引
current: index,
// 预览窗口关闭时的回调
success: function(res) {
console.log('预览图片成功');
},
// 预览失败的回调
fail: function(err) {
console.error('预览图片失败:', err);
}
});
|
b951d827
刘淇
树木详情
|
368
|
},
|
c872bdb3
刘淇
树木详情
|
369
|
|
b951d827
刘淇
树木详情
|
370
371
372
373
374
|
}
}
</script>
<style>
|
b951d827
刘淇
树木详情
|
375
|
|
b951d827
刘淇
树木详情
|
376
|
</style>
|