Blame view

subPackages/treePage/treeInfo.vue 12.9 KB
b951d827   刘淇   树木详情
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <template>
    <view class="container">
      <tui-form ref="form" :show-message="false" :model="formData">
        <tui-form-item asterisk label="名称" prop="treetype">
          <tui-input padding="0" :borderBottom="false" placeholder="请输入名称" maxlength="30" :disabled="true"
                     v-model="formData.treetype"></tui-input>
        </tui-form-item>
  
        <tui-row>
          <tui-col :span="12">
            <tui-form-item label="高度" asterisk prop="treeheight" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.treeheight"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
15
                <text style="padding-left: 12rpx;color:#ccc;font-size:14px;">米</text>
b951d827   刘淇   树木详情
16
17
18
19
20
21
22
23
              </template>
            </tui-form-item>
          </tui-col>
          <tui-col :span="12">
            <tui-form-item label="胸径" asterisk prop="dbh" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.dbh"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
24
                <text style="padding-left: 12rpx;color:#ccc;font-size:14px">厘米</text>
b951d827   刘淇   树木详情
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
              </template>
            </tui-form-item>
          </tui-col>
        </tui-row>
  
  
        <tui-form-item
            asterisk
            label="位置"
            class="location-form-item"
            prop="growlocation"
        >
          <tui-input padding="0" :borderBottom="false" placeholder="请选择" :disabled="true"
                     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   刘淇   树木历史
46
              label="经度"
b951d827   刘淇   树木详情
47
              class="location-form-item"
b951d827   刘淇   树木详情
48
49
              prop="latitude"
          >
137be4e2   刘淇   树木历史
50
            {{ formData.longitude }}
b951d827   刘淇   树木详情
51
52
          </tui-form-item>
        </tui-col>
137be4e2   刘淇   树木历史
53
  
b951d827   刘淇   树木详情
54
55
        <tui-col :span="12">
          <tui-form-item
137be4e2   刘淇   树木历史
56
57
  
              label="纬度"
b951d827   刘淇   树木详情
58
              class="location-form-item"
137be4e2   刘淇   树木历史
59
  
b951d827   刘淇   树木详情
60
61
              prop="latitude"
          >
137be4e2   刘淇   树木历史
62
            {{ formData.latitude }}
b951d827   刘淇   树木详情
63
64
65
66
          </tui-form-item>
        </tui-col>
  
  
b951d827   刘淇   树木详情
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
        <tui-form-item asterisk label="管护单位" prop="managedutyunit">
  
          <tui-input padding="0" :borderBottom="false" placeholder="请输入" maxlength="30" :disabled="true"
                     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>
        <tui-form-item asterisk label="权属分类" arrow highlight prop="oldtreeownershipText">
          <tui-input padding="0" :borderBottom="false" placeholder="请选择" :disabled="true"
                     backgroundColor="transparent" v-model="formData.oldtreeownershipText"></tui-input>
        </tui-form-item>
  
        <tui-form-item label="图片信息" asterisk prop="treeImgList">
  
          <!--        <tui-image-group :imageList="formData.treeImgList" radius="0"></tui-image-group>-->
  
          <!-- 图片组组件 -->
          <tui-image-group
              :imageList="formData.treeImgList"
              radius="0"
c872bdb3   刘淇   树木详情
88
              @click="previewImage"
b951d827   刘淇   树木详情
89
90
91
92
93
94
95
96
97
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
          >
          </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/*"-->
          <!--        >-->
          <!--          &lt;!&ndash; 自定义上传按钮 &ndash;&gt;-->
          <!--          <view class="upload-btn">-->
          <!--            <tui-icon name="plus" size="32" color="#999"></tui-icon>-->
  
          <!--          </view>-->
          <!--          &lt;!&ndash; 提示信息 &ndash;&gt;-->
          <!--          &lt;!&ndash;        <view class="upload-tips">&ndash;&gt;-->
          <!--          &lt;!&ndash;          最多上传3张图片,单张不超过5MB&ndash;&gt;-->
          <!--          &lt;!&ndash;        </view>&ndash;&gt;-->
  
  
          <!--        </tui-upload>-->
          <!-- 提示信息 -->
          <!--        <view class="upload-tips">-->
          <!--          最多上传3张图片,单张不超过5MB-->
          <!--        </view>-->
        </tui-form-item>
  
  
        <tui-row>
          <tui-col :span="12">
            <tui-form-item label="拉丁文" prop="latinname">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" maxlength="30" :disabled="true"
                         v-model="formData.latinname"></tui-input>
            </tui-form-item>
          </tui-col>
          <tui-col :span="12">
            <tui-form-item label="级别" arrow highlight prop="treeleveltext">
              <tui-input padding="0" :borderBottom="false" placeholder="请选择" :disabled="true"
                         backgroundColor="transparent" v-model="formData.treeleveltext"></tui-input>
            </tui-form-item>
          </tui-col>
        </tui-row>
  
        <tui-form-item label="生长环境" prop="growthenvironment">
          <tui-input padding="0" :borderBottom="false" placeholder="请输入" maxlength="50" :disabled="true"
                     v-model="formData.growthenvironment"></tui-input>
        </tui-form-item>
  
  
        <tui-row>
          <tui-col :span="12">
            <tui-form-item label="预估树龄" prop="estimationtreeage" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.estimationtreeage"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
150
                <text style="padding-left: 12rpx;color:#ccc;font-size: 14px">年</text>
b951d827   刘淇   树木详情
151
152
153
154
155
156
157
158
              </template>
            </tui-form-item>
          </tui-col>
          <tui-col :span="12">
            <tui-form-item label="干周" prop="weekday" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.weekday"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
159
                <text style="padding-left: 12rpx;color:#ccc;font-size: 14px">厘米</text>
b951d827   刘淇   树木详情
160
161
162
163
164
165
166
167
168
169
170
171
              </template>
            </tui-form-item>
          </tui-col>
        </tui-row>
  
  
        <tui-row>
          <tui-col :span="12">
            <tui-form-item label="东西冠幅" prop="canopyeastwest" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.canopyeastwest"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
172
                <text style="padding-left: 12rpx;color:#ccc">米</text>
b951d827   刘淇   树木详情
173
174
175
176
177
178
179
180
              </template>
            </tui-form-item>
          </tui-col>
          <tui-col :span="12">
            <tui-form-item label="南北冠幅" prop="canopysouthnorth" :position="3">
              <tui-input padding="0" :borderBottom="false" placeholder="请输入" textRight maxlength="10" :disabled="true"
                         v-model="formData.canopysouthnorth"></tui-input>
              <template v-slot:right>
c872bdb3   刘淇   树木详情
181
                <text style="padding-left: 12rpx;color:#ccc;font-size: 14px">米</text>
b951d827   刘淇   树木详情
182
183
184
185
186
187
              </template>
            </tui-form-item>
          </tui-col>
        </tui-row>
  
      </tui-form>
b951d827   刘淇   树木详情
188
189
190
191
192
193
    </view>
  </template>
  
  <script>
  import { uploadURL, OSSURL } from '@/config/app'
  import { treeOwnership, treeLevelReq } from "@/api/tree";
c872bdb3   刘淇   树木详情
194
  import { useCounterStore } from '@/stores/counter'
b951d827   刘淇   树木详情
195
196
197
198
199
200
201
202
203
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
  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   刘淇   树木详情
250
        // 当前预览索引
b951d827   刘淇   树木详情
251
252
253
254
255
256
257
258
259
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
        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   刘淇   树木详情
289
290
291
292
293
294
    computed: {
      // 获取共享store实例
      useCounterStore() {
        return useCounterStore()
      }
    },
b951d827   刘淇   树木详情
295
296
297
    onReady() {
      //开启即时校验,开启后输入即校验【参数必传】,第一参数:是否开启;第二参数:校验规则
      // 开启即时校验,参数:是否开启、校验规则
c872bdb3   刘淇   树木详情
298
299
300
301
      // this.$refs.form && this.$refs.form.immediateValidate(true, rules);
    },
    onUnload() {
  
b951d827   刘淇   树木详情
302
303
    },
    onLoad(options) {
c872bdb3   刘淇   树木详情
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
      // this.formData = this.useCounterStore.treeData
      const treeData = this.useCounterStore.treeData;
  
      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
      //   }
      // });
137be4e2   刘淇   树木历史
322
  
b951d827   刘淇   树木详情
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
      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   刘淇   树木详情
339
340
    },
    methods: {
c872bdb3   刘淇   树木详情
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
      // 图片预览
      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   刘淇   树木详情
360
      },
c872bdb3   刘淇   树木详情
361
  
b951d827   刘淇   树木详情
362
363
364
365
366
    }
  }
  </script>
  
  <style>
b951d827   刘淇   树木详情
367
  
b951d827   刘淇   树木详情
368
  </style>