Blame view

pages-sub/data/tree-archive/editTree.vue 27 KB
12e66ec8   刘淇   新增树
1
2
  <template>
    <view class="container">
03b006dc   刘淇   树修改
3
      <!-- 顶部固定吸顶Tabs区域 -->
12e66ec8   刘淇   新增树
4
5
6
7
8
9
10
11
12
13
14
15
16
      <up-sticky bg-color="#ffffff">
        <view class="header-wrap">
          <up-tabs
              v-model="activeTab"
              :list="tabList"
              active-color="#1989fa"
              inactive-color="#666"
              font-size="30rpx"
              @click="handleTabChange"
              :scrollable="false"
          />
        </view>
      </up-sticky>
8ddc6f6e   刘淇   登录 修改样式
17
  
ecbfbe06   刘淇   树巡检记录
18
      <!-- Tab0 基本信息页面 -->
12e66ec8   刘淇   新增树
19
      <view v-show="activeTab === 0" class="base-info-wrap">
03b006dc   刘淇   树修改
20
21
22
23
24
        <up-form :model="formData" ref="formRef" label-width="140rpx" border-bottom>
          <up-form-item label="名称" prop="treetype" required>
            <up-input v-model.trim="formData.treetype" placeholder="请输入名称" maxlength="30" border="none"/>
          </up-form-item>
  
1d3624b0   刘淇   首页。养护任务
25
26
27
28
29
30
31
32
33
34
35
          <!-- 新增:树种类型 底部弹窗选择 -->
          <!-- <up-form-item label="树种类型" prop="treeSpeciesType" required arrow @click="openTreeSpeciesType">
            <up-input
              v-model="formData.treeSpeciesTypeName"
              placeholder="请选择树种类型"
              readonly
              border="none"
              bg-color="transparent"
            />
          </up-form-item> -->
  
03b006dc   刘淇   树修改
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
          <view class="form-row-wrap">
            <up-row gutter="10">
              <up-col span="6">
                <up-form-item label="胸径" prop="dbh" required>
                  <up-input v-model.trim="formData.dbh" placeholder="请输入" maxlength="10" border="none"
                            input-align="left"/>
                  <template #right>
                    <text style="padding-left: 12rpx;color:#ccc;font-size:14px">厘米</text>
                  </template>
                </up-form-item>
              </up-col>
              <up-col span="6">
                <up-form-item label="高度" prop="treeheight">
                  <up-input v-model.trim="formData.treeheight" placeholder="请输入" maxlength="10" border="none"
                            input-align="left"/>
                  <template #right>
                    <text style="padding-left: 12rpx;color:#ccc;font-size:14px;">米</text>
                  </template>
                </up-form-item>
              </up-col>
            </up-row>
          </view>
  
          <up-form-item label="位置" prop="growlocation" required class="location-form-item" @click="openMap">
            <up-input v-model="formData.growlocation" placeholder="请选择" readonly border="none"/>
            <template #right>
              <up-icon name="map" size="22"></up-icon>
            </template>
          </up-form-item>
  
          <up-row gutter="10">
            <up-col span="6">
              <up-form-item label="经度" :borderBottom="false">
                <up-input v-model="formData.longitude" placeholder="" readonly border="none"/>
              </up-form-item>
            </up-col>
            <up-col span="6">
              <up-form-item label="纬度" :borderBottom="false">
                <up-input v-model="formData.latitude" placeholder="" readonly border="none"/>
              </up-form-item>
            </up-col>
          </up-row>
  
          <up-form-item label="管护单位" prop="managedutyunit" required>
            <up-input v-model.trim="formData.managedutyunit" placeholder="请输入" maxlength="30" border="none"/>
          </up-form-item>
  
          <up-form-item label="权属分类" prop="oldtreeownershipText" required arrow
                        @click="handleActionSheetOpen('ownership')">
            <up-input v-model.trim="formData.oldtreeownershipText" placeholder="请选择" readonly border="none"
                      bg-color="transparent"/>
          </up-form-item>
  
03b006dc   刘淇   树修改
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
          <up-form-item label="图片信息" prop="treeImgList" required>
            <up-upload
                name="treeImgList"
                :file-list="treeImgList.imgList.value"
                @after-read="treeImgList.uploadImgs"
                @delete="treeImgList.deleteImg"
                multiple
                :width="70"
                :height="70"
                :max-count="treeImgList.uploadConfig.maxCount"
                :upload-text="treeImgList.uploadConfig.uploadText"
                :size-type="treeImgList.uploadConfig.sizeType"
            ></up-upload>
          </up-form-item>
  
          <view
              class="animated-area"
              :style="{
              height: isShow ? contentHeight + 'px' : '0',
              opacity: isShow ? 1 : 0,
              overflow: 'hidden'
            }"
          >
            <up-row gutter="10">
              <up-col span="6">
                <up-form-item label="拉丁文" prop="latinname">
                  <up-input v-model.trim="formData.latinname" placeholder="请输入" maxlength="30" border="none"/>
                </up-form-item>
              </up-col>
              <up-col span="6">
                <up-form-item label="级别" arrow @click="handleActionSheetOpen('level')">
                  <up-input v-model.trim="formData.treeleveltext" placeholder="请选择" readonly border="none"
                            bg-color="transparent"/>
                </up-form-item>
              </up-col>
            </up-row>
  
            <up-form-item label="生长环境" prop="growthenvironment">
              <up-input v-model.trim="formData.growthenvironment" placeholder="请输入" maxlength="50" border="none"/>
            </up-form-item>
  
            <view class="form-row-wrap">
              <up-row gutter="10">
                <up-col span="6">
ecbfbe06   刘淇   树巡检记录
133
134
135
                  <!-- 改成栽种年月+年月选择器 -->
                  <up-form-item label="栽种年月" arrow @click="openPlantDatePicker">
                    <up-input v-model.trim="formData.plantingDate" placeholder="请选择栽种年月" readonly border="none" bg-color="transparent"/>
03b006dc   刘淇   树修改
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
                  </up-form-item>
                </up-col>
                <up-col span="6">
                  <up-form-item label="干周" prop="weekday">
                    <up-input v-model.trim="formData.weekday" placeholder="请输入" maxlength="10" border="none"
                              input-align="left"/>
                    <template #right>
                      <text style="padding-left:12rpx;color:#ccc;font-size:14px">厘米</text>
                    </template>
                  </up-form-item>
                </up-col>
              </up-row>
            </view>
  
            <view class="form-row-wrap">
              <up-row gutter="10">
                <up-col span="6">
                  <up-form-item label="东西冠幅" prop="canopyeastwest">
                    <up-input v-model.trim="formData.canopyeastwest" placeholder="请输入" maxlength="10" border="none"
                              input-align="left"/>
                    <template #right>
                      <text style="padding-left:12rpx;color:#ccc;font-size:14px">米</text>
                    </template>
                  </up-form-item>
                </up-col>
                <up-col span="6">
                  <up-form-item label="南北冠幅" prop="canopysouthnorth">
                    <up-input v-model.trim="formData.canopysouthnorth" placeholder="请输入" maxlength="10" border="none"
                              input-align="left"/>
                    <template #right>
                      <text style="padding-left:12rpx;color:#ccc;font-size:14px">米</text>
                    </template>
                  </up-form-item>
                </up-col>
              </up-row>
12e66ec8   刘淇   新增树
171
172
            </view>
          </view>
03b006dc   刘淇   树修改
173
174
175
176
177
178
179
180
181
182
183
  
          <up-button
              @click="toggleArea"
              type="primary"
              plain
              size="large"
              style="margin-top:20rpx"
          >
            {{ isShow ? '- 隐藏区域' : '+ 显示区域' }}
          </up-button>
        </up-form>
12e66ec8   刘淇   新增树
184
      </view>
8ddc6f6e   刘淇   登录 修改样式
185
  
ecbfbe06   刘淇   树巡检记录
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      <!-- Tab1 巡检记录页面 -->
      <view v-show="activeTab === 1" class="inspect-wrap">
        <up-empty v-if="inspectRows.length === 0" marginTop="100" text="暂无巡检记录"></up-empty>
        <view class="record-wrap" v-else>
          <up-card
              v-for="item in inspectRows"
              :key="item.id"
              :border="false"
              :show-head="false"
              class="tree-card"
              :foot-border-top="false"
              @click="toInspectDetailPage(item)"
          >
            <template #body>
              <view class="inspect-item">
                <view class="inspect-row">巡检时间:{{ item.inspectionTime || '' }}</view>
                <view class="inspect-row">巡检人:{{ item.inspectorName || '' }}</view>
                <view class="inspect-row up-flex up-flex-between up-flex-items-center">
                  <text>风险评估结果:{{ item.result.normalResult.level || '无风险' }}</text>
                  <text class="detail-text">详情</text>
                </view>
              </view>
            </template>
          </up-card>
        </view>
      </view>
  
      <!-- Tab2 变更日志页面 -->
      <view v-show="activeTab === 2" class="log-wrap">
03b006dc   刘淇   树修改
215
        <up-empty v-if="logRows.length === 0" marginTop="100" text="暂无变更日志"></up-empty>
12e66ec8   刘淇   新增树
216
217
218
219
220
221
222
223
        <view class="record-wrap" v-else>
          <up-card
              v-for="item in logRows"
              :key="item.id"
              :border="false"
              :show-head="false"
              class="tree-card"
              :foot-border-top="false"
c5fdc60a   刘淇   树详情
224
              @click="toLogDetailPage(item)"
12e66ec8   刘淇   新增树
225
226
227
          >
            <template #body>
              <view class="card-body-inner">
12e66ec8   刘淇   新增树
228
229
                <view class="record-list-left" :style="`background-image: url(${item.treephotoone});`"></view>
                <view class="record-list-right">
cf70629b   刘淇   养护计划 照片 自己写样式
230
                  <view class="up-flex up-flex-items-center up-flex-between">
12e66ec8   刘淇   新增树
231
232
233
                    <view class="u-line-1 treetypeName">{{ item.treetype }}</view>
                    <view style="text-align: right">{{ timeFormat(item.updatetime) }}</view>
                  </view>
cf70629b   刘淇   养护计划 照片 自己写样式
234
235
                  <view class=" fs-align__center" style="margin: 8px 0">
                    <img src="../../../static/imgs/tree/tree-high.png" style="width:12px;height:12px;margin-right:6px;"
03b006dc   刘淇   树修改
236
                         alt=""> 高度:{{ item.treeheight }} 米
12e66ec8   刘淇   新增树
237
238
                  </view>
                  <view class=" fs-align__center">
cf70629b   刘淇   养护计划 照片 自己写样式
239
                    <img src="../../../static/imgs/tree/treearound.png" style="width:12px;height:12px;margin-right:6px;"
03b006dc   刘淇   树修改
240
                         alt="">胸径:{{ item.dbh }} 厘米
12e66ec8   刘淇   新增树
241
242
243
244
245
246
247
248
249
250
251
                  </view>
                </view>
              </view>
              <view class="treenumber-no">
                树木编号:{{ item.treenumber }}
              </view>
            </template>
          </up-card>
        </view>
      </view>
  
ecbfbe06   刘淇   树巡检记录
252
253
      <!-- 底部按钮区域 -->
      <!-- 基本信息Tab:修改按钮 -->
03b006dc   刘淇   树修改
254
255
      <view class="fixed-bottom-btn-wrap" v-show="activeTab === 0">
        <up-button type="primary" @click="submit" :loading="loadingFlag" size="large" >修改树木信息</up-button>
12e66ec8   刘淇   新增树
256
      </view>
8ddc6f6e   刘淇   登录 修改样式
257
  
ecbfbe06   刘淇   树巡检记录
258
259
260
261
262
      <!-- 巡检记录Tab:新增巡检按钮 -->
      <view class="fixed-bottom-btn-wrap" v-show="activeTab === 1">
        <up-button type="primary" size="large" @click="toAddInspect">新增巡检记录</up-button>
      </view>
  
03b006dc   刘淇   树修改
263
264
265
266
267
268
269
270
271
      <!-- 字典选择弹窗 -->
      <up-action-sheet
          :show="showActionSheet"
          :actions="currentActionSheetData.list"
          :title="currentActionSheetData.title"
          @close="handleActionSheetClose"
          @select="handleActionSheetSelect"
      ></up-action-sheet>
  
ecbfbe06   刘淇   树巡检记录
272
273
274
275
276
277
278
279
280
281
      <!-- 栽种年月选择弹窗 -->
      <up-datetime-picker
          v-model="plantingDate"
          :show="showDatePicker"
          :closeOnClickOverlay="true"
          mode="year-month"
          minDate="1000"
          @confirm="onSelectPlantDate"
          @cancel="showDatePicker=false"
      ></up-datetime-picker>
12e66ec8   刘淇   新增树
282
    </view>
8ddc6f6e   刘淇   登录 修改样式
283
284
  </template>
  
12e66ec8   刘淇   新增树
285
  <script setup>
03b006dc   刘淇   树修改
286
  import { ref, reactive, nextTick } from 'vue'
c5fdc60a   刘淇   树详情
287
  import { onReady, onLoad, onShow, onUnload } from '@dcloudio/uni-app';
4f475013   刘淇   k线图
288
  
ecbfbe06   刘淇   树巡检记录
289
290
  import { treeRoadReq, treeLogReq, treeDetailReq, updateTree, inspectionLogReq }
  from "@/api/tree-archive/tree-archive.js";
ecbfbe06   刘淇   树巡检记录
291
  
03b006dc   刘淇   树修改
292
293
294
295
  import { timeFormat } from '@/uni_modules/uview-plus';
  import { useUploadImgs } from '@/common/utils/useUploadImgs'
  import { useUserStore } from '@/pinia/user';
  
4f475013   刘淇   k线图
296
  // ========== 常量配置区
03b006dc   刘淇   树修改
297
  const CONST = {
03b006dc   刘淇   树修改
298
299
300
    UPLOAD_CONFIG: { maxCount: 3, uploadText: '选择图片', sizeType: ['compressed'] }
  }
  
12e66ec8   刘淇   新增树
301
302
303
304
  // ========== 基础变量 ==========
  const rows = ref([])
  const roadId = ref('')
  const count = ref(0)
ecbfbe06   刘淇   树巡检记录
305
  const treeId = ref('')
03b006dc   刘淇   树修改
306
  const loadingFlag = ref(false)
ecbfbe06   刘淇   树巡检记录
307
308
309
310
311
312
313
314
315
316
317
  const isInit = ref(false)
  // 年月选择器开关
  const showDatePicker = ref(false)
  const plantingDate = ref(Date.now())
  // ========== Tab切换变量(顺序:基本信息、巡检记录、变更日志) ==========
  const activeTab = ref(0);
  const tabList = ref([
    {name: '基本信息'},
    {name: '巡检记录'},
    {name: '变更日志'}
  ]);
12e66ec8   刘淇   新增树
318
319
  
  // ========== 数据变量 ==========
ecbfbe06   刘淇   树巡检记录
320
321
  const logRows = ref([])
  const inspectRows = ref([]) // 巡检记录列表
03b006dc   刘淇   树修改
322
323
324
325
326
327
  const userStore = useUserStore();
  const formRef = ref(null)
  const isShow = ref(false)
  const contentHeight = ref(200)
  const treeOwnershipData = ref([])
  const treeLevelData = ref([])
1d3624b0   刘淇   首页。养护任务
328
  const treeSpeciesTypeList = ref([]) // 树种类型字典列表
03b006dc   刘淇   树修改
329
330
331
  const showActionSheet = ref(false);
  const currentActionSheetData = reactive({type: '', list: [], title: ''});
  
ecbfbe06   刘淇   树巡检记录
332
  // ========== 图片上传配置  ==========
03b006dc   刘淇   树修改
333
334
335
336
337
  const treeImgList = useUploadImgs({
    ...CONST.UPLOAD_CONFIG,
    formRef: formRef,
    fieldName: 'treeImgList'
  })
03b006dc   刘淇   树修改
338
339
340
  treeImgList.imgList.value = []
  treeImgList.rawImgList.value = []
  
1d3624b0   刘淇   首页。养护任务
341
  // ========== 表单数据 ==========
03b006dc   刘淇   树修改
342
  const formData = reactive({
ecbfbe06   刘淇   树巡检记录
343
    id: '',
12e66ec8   刘淇   新增树
344
    treetype: '',
1d3624b0   刘淇   首页。养护任务
345
346
    // treeSpeciesType: '',    // 树种类型编码(提交接口)
    treeSpeciesTypeName: '', // 树种类型名称(页面展示)
12e66ec8   刘淇   新增树
347
348
    treeheight: '',
    dbh: '',
03b006dc   刘淇   树修改
349
350
351
352
353
354
    treelevel: '',
    treeleveltext: '',
    managedutyunit: '',
    oldtreeownership: '',
    oldtreeownershipText: '',
    latinname: '',
ecbfbe06   刘淇   树巡检记录
355
    plantingDate: '', //栽种年月 yyyy-MM
03b006dc   刘淇   树修改
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
    canopysouthnorth: '',
    canopyeastwest: '',
    weekday: '',
    growlocation: '',
    growthenvironment: '',
    treeImgList: [],
    address: '',
    latitude: '',
    longitude: '',
    road: '',
    maintainunit: '',
    treephotoone: '',
    treephototwo: '',
    treephotothree: '',
    treephotofour: '',
    treephotofive: ''
  })
  
ecbfbe06   刘淇   树巡检记录
374
  // ========== 表单校验规则 ==========
03b006dc   刘淇   树修改
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  const isPureZero = (val) => {
    if (!val) return false;
    const pureZeroReg = /^0+$/;
    return pureZeroReg.test(val.trim());
  };
  const trimFormData = (obj) => {
    for (const key in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
        obj[key] = obj[key].trim();
      }
    }
  };
  const emojiReg = /[\uD83C\uD83D\uD83E][\uDC00-\uDFFF]+|[\u2702\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299\ufe0f\u200d]+/g;
  const filterEmoji = (val) => typeof val === 'string' ? val.replace(emojiReg, '') : val;
  const hasEmoji = (val) => val && emojiReg.test(val);
  const rules = reactive({
    treetype: [
      {
        validator: (rule, val, callback) => hasEmoji(val) ? callback(new Error('禁止输入表情符号')) : callback(),
        trigger: ['blur', 'change', 'input'],
        priority: 10
      },
      {required: true, message: '请输入名称', trigger: ['blur', 'change', 'input']},
      {max: 30, message: '名称最多输入30个字符', trigger: ['blur', 'change', 'input']}
    ],
1d3624b0   刘淇   首页。养护任务
400
401
402
403
    // 树种类型 必填校验
    // treeSpeciesType: [
    //   { required: true, message: '请选择树种类型', trigger: ['change'] }
    // ],
03b006dc   刘淇   树修改
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
    treeheight: [
      {max: 10, message: '树高不能超过10个字符', trigger: ['blur', 'change', 'input']},
      {pattern: /^\d+(\.\d{1,2})?$/, message: '格式不正确,支持数字或两位小数', trigger: ['blur', 'change', 'input']},
      {
        validator: (rule, val, callback) => isPureZero(val) ? callback(new Error('不能输入纯0无效值')) : callback(),
        trigger: ['blur', 'change', 'input']
      }
    ],
    dbh: [
      {
        validator: (rule, val, callback) => hasEmoji(val) ? callback(new Error('禁止输入表情符号')) : callback(),
        trigger: ['blur', 'change', 'input'],
        priority: 10
      },
      {required: true, message: '请输入胸径', trigger: ['blur', 'change', 'input']},
      {max: 10, message: '胸径不能超过10个字符', trigger: ['blur', 'change', 'input']},
      {pattern: /^\d+(\.\d{1,2})?$/, message: '格式不正确,支持数字或两位小数', trigger: ['blur', 'change', 'input']},
      {
        validator: (rule, val, callback) => isPureZero(val) ? callback(new Error('不能输入纯0无效值')) : callback(),
        trigger: ['blur', 'change', 'input']
      }
    ],
03b006dc   刘淇   树修改
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
    weekday: [
      {max: 10, message: '干周不能超过10个字符', trigger: ['blur', 'change', 'input']},
      {pattern: /^\d+(\.\d{1,2})?$/, message: '格式不正确,支持数字或两位小数', trigger: ['blur', 'change', 'input']},
      {
        validator: (rule, val, callback) => isPureZero(val) ? callback(new Error('不能输入纯0无效值')) : callback(),
        trigger: ['blur', 'change', 'input']
      }
    ],
    canopyeastwest: [
      {max: 10, message: '东西冠幅不能超过10个字符', trigger: ['blur', 'change', 'input']},
      {pattern: /^\d+(\.\d{1,2})?$/, message: '格式不正确,支持数字或两位小数', trigger: ['blur', 'change', 'input']},
      {
        validator: (rule, val, callback) => isPureZero(val) ? callback(new Error('不能输入纯0无效值')) : callback(),
        trigger: ['blur', 'change', 'input']
      }
    ],
    canopysouthnorth: [
      {max: 10, message: '南北冠幅不能超过10个字符', trigger: ['blur', 'change', 'input']},
      {pattern: /^\d+(\.\d{1,2})?$/, message: '格式不正确,支持数字或两位小数', trigger: ['blur', 'change', 'input']},
      {
        validator: (rule, val, callback) => isPureZero(val) ? callback(new Error('不能输入纯0无效值')) : callback(),
        trigger: ['blur', 'change', 'input']
      }
    ],
    growlocation: [{required: true, message: '请选择地图位置', trigger: ['blur', 'change', 'manual']}],
    managedutyunit: [
      {
        validator: (rule, val, callback) => hasEmoji(val) ? callback(new Error('禁止输入表情符号')) : callback(),
        trigger: ['blur', 'change', 'input'],
        priority: 10
      },
      {required: true, message: '请输入管护单位', trigger: ['blur', 'change', 'input']},
      {max: 30, message: '管护单位最多输入30个字符', trigger: ['blur', 'change', 'input']}
    ],
    oldtreeownershipText: [{required: true, message: '请选择权属分类', trigger: ['blur', 'change']}],
    latinname: [
      {
        validator: (rule, val, callback) => hasEmoji(val) ? callback(new Error('禁止输入表情符号')) : callback(),
        trigger: ['blur', 'change', 'input'],
        priority: 10
      },
      {max: 30, message: '拉丁文最多输入30个字符', trigger: ['blur', 'change', 'input']}
    ],
    growthenvironment: [
      {
        validator: (rule, val, callback) => hasEmoji(val) ? callback(new Error('禁止输入表情符号')) : callback(),
        trigger: ['blur', 'change', 'input'],
        priority: 10
      },
      {max: 50, message: '生长环境最多输入50个字符', trigger: ['blur', 'change', 'input']}
    ],
    treeImgList: [treeImgList.imgValidateRule]
12e66ec8   刘淇   新增树
478
  })
12e66ec8   刘淇   新增树
479
480
481
482
483
484
  
  // ========== 生命周期 ==========
  onLoad((options) => {
    console.log('编辑页入参', options)
    roadId.value = options.roadId || ''
    count.value = options.count || 0
ecbfbe06   刘淇   树巡检记录
485
486
487
488
    treeId.value = options.id || ''
    formData.id = treeId.value
    formData.road = roadId.value
    isInit.value = false
03b006dc   刘淇   树修改
489
490
491
  });
  
  onShow(async () => {
1d3624b0   刘淇   首页。养护任务
492
    // 加载全部字典
03b006dc   刘淇   树修改
493
494
    treeLevelData.value = uni.$dict.transformLabelValueToNameValue(uni.$dict.getDictSimpleList('tree_level'))
    treeOwnershipData.value = uni.$dict.transformLabelValueToNameValue(uni.$dict.getDictSimpleList('tree_ownership'))
1d3624b0   刘淇   首页。养护任务
495
496
    treeSpeciesTypeList.value = uni.$dict.transformLabelValueToNameValue(uni.$dict.getDictSimpleList('tree_species_type'))
  
03b006dc   刘淇   树修改
497
498
    if (activeTab.value === 0 && treeId.value && !isInit.value) {
      await getTreeDetail()
ecbfbe06   刘淇   树巡检记录
499
500
501
502
503
      isInit.value = true
    }
    if(treeId.value){
      getTreeLogList()
      getInspectList()
12e66ec8   刘淇   新增树
504
505
506
    }
  })
  
03b006dc   刘淇   树修改
507
508
509
  onReady(() => {
    nextTick(() => formRef.value?.setRules(rules));
  });
c5fdc60a   刘淇   树详情
510
  
12e66ec8   刘淇   新增树
511
  // ========== Tab切换事件 ==========
03b006dc   刘淇   树修改
512
  const handleTabChange = async (item) => {
12e66ec8   刘淇   新增树
513
    activeTab.value = item.index
ecbfbe06   刘淇   树巡检记录
514
515
516
517
    // 切换Tab自动加载对应数据
    if (activeTab.value === 1) {
      getInspectList()
    } else if (activeTab.value === 2) {
03b006dc   刘淇   树修改
518
      getTreeLogList()
12e66ec8   刘淇   新增树
519
520
521
522
    }
  }
  
  // ========== 接口请求 ==========
12e66ec8   刘淇   新增树
523
  const treeRoadQuery = async () => {
03b006dc   刘淇   树修改
524
    const res = await treeRoadReq({road: roadId.value})
12e66ec8   刘淇   新增树
525
526
527
    rows.value = res.list
  }
  
1d3624b0   刘淇   首页。养护任务
528
  // 获取树木详情(回显树种类型名称+编码)
03b006dc   刘淇   树修改
529
530
531
  const getTreeDetail = async () => {
    const res = await treeDetailReq({id: treeId.value})
    Object.assign(formData, res)
1d3624b0   刘淇   首页。养护任务
532
    // 字典回显
03b006dc   刘淇   树修改
533
534
    formData.oldtreeownershipText = uni.$dict.getDictLabel('tree_ownership', res.oldtreeownership)
    formData.treeleveltext = uni.$dict.getDictLabel('tree_level', formData.treelevel)
1d3624b0   刘淇   首页。养护任务
535
    // formData.treeSpeciesTypeName = uni.$dict.getDictLabel('tree_species_type', formData.treeSpeciesType)
03b006dc   刘淇   树修改
536
  
03b006dc   刘淇   树修改
537
538
539
540
    treeImgList.imgList.value = []
    treeImgList.rawImgList.value = []
    formData.treephotoone = ''
    formData.treephototwo = ''
03b006dc   刘淇   树修改
541
542
543
544
    formData.treephotothree = ''
    formData.treephotofour = ''
    formData.treephotofive = ''
  
03b006dc   刘淇   树修改
545
546
547
548
549
550
    if (Array.isArray(res.treeImgList) && res.treeImgList.length > 0) {
      const imgList = res.treeImgList.map((url, idx) => ({
        url,
        name: `renew_img_${idx}`,
        status: 'success'
      }));
03b006dc   刘淇   树修改
551
552
553
554
      treeImgList.imgList.value = imgList
      treeImgList.rawImgList.value = imgList
    }
  }
12e66ec8   刘淇   新增树
555
  
ecbfbe06   刘淇   树巡检记录
556
  // 获取变更日志
12e66ec8   刘淇   新增树
557
  const getTreeLogList = async () => {
03b006dc   刘淇   树修改
558
    const res = await treeLogReq({treeid: treeId.value})
12e66ec8   刘淇   新增树
559
560
561
    logRows.value = res.list
  }
  
ecbfbe06   刘淇   树巡检记录
562
563
  // 获取巡检记录列表
  const getInspectList = async () => {
ecbfbe06   刘淇   树巡检记录
564
565
566
567
568
569
570
571
572
573
    const res = await inspectionLogReq({treeId: treeId.value,pageNo:1,pageSize:100})
    console.log(res)
    inspectRows.value = res.list || []
  }
  
  // ========== 年月选择方法 ==========
  const openPlantDatePicker = () => {
    showDatePicker.value = true
  }
  const onSelectPlantDate = (date) => {
ecbfbe06   刘淇   树巡检记录
574
575
576
577
    formData.plantingDate =  timeFormat(plantingDate.value, 'yyyy-mm')
    showDatePicker.value = false
  }
  
03b006dc   刘淇   树修改
578
579
580
  // ========== 表单相关方法 ==========
  const toggleArea = () => isShow.value = !isShow.value
  
1d3624b0   刘淇   首页。养护任务
581
  // 打开权属/级别弹窗
03b006dc   刘淇   树修改
582
583
584
585
586
587
588
589
590
  const handleActionSheetOpen = (type) => {
    const configMap = {
      ownership: {title: '请选择权属分类', list: treeOwnershipData.value},
      level: {title: '请选择树木级别', list: treeLevelData.value}
    };
    Object.assign(currentActionSheetData, configMap[type], {type});
    showActionSheet.value = true;
  };
  
1d3624b0   刘淇   首页。养护任务
591
592
593
594
595
596
597
598
599
600
  // 打开树种类型弹窗
  const openTreeSpeciesType = () => {
    Object.assign(currentActionSheetData, {
      title: '请选择树种类型',
      list: treeSpeciesTypeList.value,
      type: 'treeSpecies'
    })
    showActionSheet.value = true
  }
  
03b006dc   刘淇   树修改
601
602
603
604
605
  const handleActionSheetClose = () => {
    showActionSheet.value = false;
    Object.assign(currentActionSheetData, {type: '', list: [], title: ''});
  };
  
1d3624b0   刘淇   首页。养护任务
606
  // 弹窗选中回调(区分三种类型)
03b006dc   刘淇   树修改
607
608
609
610
611
612
613
614
615
  const handleActionSheetSelect = (e) => {
    const {type} = currentActionSheetData;
    if (type === 'ownership') {
      formData.oldtreeownership = e.value
      formData.oldtreeownershipText = e.name
      formRef.value?.validateField('oldtreeownershipText');
    } else if (type === 'level') {
      formData.treelevel = e.value
      formData.treeleveltext = e.name
1d3624b0   刘淇   首页。养护任务
616
617
618
619
620
    } else if (type === 'treeSpecies') {
      // 树种类型:编码存接口字段,名称页面展示
      formData.treeSpeciesType = e.value
      formData.treeSpeciesTypeName = e.name
      formRef.value?.validateField('treeSpeciesType');
03b006dc   刘淇   树修改
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
    }
    handleActionSheetClose();
  };
  
  // 地图选址
  const openMap = () => {
    uni.chooseLocation({
      success: async (res) => {
        formData.growlocation = res.address
        formData.latitude = res.latitude
        formData.longitude = res.longitude
        await nextTick()
        formRef.value?.validateField('growlocation');
      },
      fail: (err) => {
        console.error('地图选择失败', err);
        err.errMsg.includes('auth deny') && uni.showToast({title: '请授权位置权限', icon: 'none'});
      }
    });
12e66ec8   刘淇   新增树
640
641
  }
  
ecbfbe06   刘淇   树巡检记录
642
  // 表单提交
03b006dc   刘淇   树修改
643
644
  const submit = async () => {
    if (loadingFlag.value) return
03b006dc   刘淇   树修改
645
646
647
648
649
    for (const key in formData) {
      if (typeof formData[key] === 'string') {
        formData[key] = filterEmoji(formData[key]).trim();
      }
    }
03b006dc   刘淇   树修改
650
651
    const valid = await formRef.value.validate()
    if (!valid) return
03b006dc   刘淇   树修改
652
653
654
655
656
657
658
659
660
661
662
663
664
665
    const uploadImgUrls = treeImgList.getSuccessImgUrls()
    formData.maintainunit = userStore.userInfo.user.companyId
    formData.treeImgList = uploadImgUrls
    loadingFlag.value = true
    try {
      await updateTree(formData)
      uni.showToast({title: "修改成功", icon: "success"});
      uni.redirectTo({url: '/pages-sub/data/tree-archive/index'});
    } catch (err) {
      uni.showToast({title: "修改失败,请重试", icon: "none"});
      console.error(err)
    } finally {
      loadingFlag.value = false
    }
12e66ec8   刘淇   新增树
666
667
  }
  
03b006dc   刘淇   树修改
668
  // ========== 页面跳转 ==========
ecbfbe06   刘淇   树巡检记录
669
  // 变更日志详情
c5fdc60a   刘淇   树详情
670
  const toLogDetailPage = (i) => {
12e66ec8   刘淇   新增树
671
    uni.navigateTo({
c5fdc60a   刘淇   树详情
672
      url: `/pages-sub/data/tree-archive/logDetail`,
c5fdc60a   刘淇   树详情
673
      success: (res) => {
c5fdc60a   刘淇   树详情
674
675
        res.eventChannel.emit('logData', i);
      }
12e66ec8   刘淇   新增树
676
677
    })
  }
ecbfbe06   刘淇   树巡检记录
678
679
680
681
682
683
684
685
686
687
688
  
  // 巡检详情页跳转
  const toInspectDetailPage = (item) => {
    uni.navigateTo({
      url: `/pages-sub/data/tree-archive/addInspect?id=${item.id}&type=detail`
    })
  }
  
  // 跳转到新增巡检页面
  const toAddInspect = () => {
    const firstItem = inspectRows.value.length > 0 ? inspectRows.value[0] : null
ecbfbe06   刘淇   树巡检记录
689
690
691
    if (firstItem) {
      uni.setStorageSync('temp_inspect_fill_data', JSON.stringify(firstItem))
    } else {
ecbfbe06   刘淇   树巡检记录
692
693
694
695
696
697
      uni.removeStorageSync('temp_inspect_fill_data')
    }
    uni.navigateTo({
      url: `/pages-sub/data/tree-archive/addInspect?treeId=${treeId.value}`
    })
  }
12e66ec8   刘淇   新增树
698
699
  </script>
  
8ddc6f6e   刘淇   登录 修改样式
700
  <style scoped lang="scss">
12e66ec8   刘淇   新增树
701
702
  .container {
    min-height: 100vh;
03b006dc   刘淇   树修改
703
    padding-bottom: 100rpx;
12e66ec8   刘淇   新增树
704
705
  }
  
12e66ec8   刘淇   新增树
706
707
708
  .header-wrap {
    background-color: #fff;
    padding: 10rpx 0;
03b006dc   刘淇   树修改
709
    box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.03);
12e66ec8   刘淇   新增树
710
711
  }
  
12e66ec8   刘淇   新增树
712
  .base-info-wrap {
cf70629b   刘淇   养护计划 照片 自己写样式
713
714
    padding: 15px 15px;
    background: #fff;
12e66ec8   刘淇   新增树
715
716
  }
  
ecbfbe06   刘淇   树巡检记录
717
  .log-wrap, .inspect-wrap {
12e66ec8   刘淇   新增树
718
719
    min-height: calc(100vh - 120rpx);
  }
03b006dc   刘淇   树修改
720
  
12e66ec8   刘淇   新增树
721
722
723
724
725
726
  .record-wrap {
    padding-bottom: 20px;
  }
  
  .treetypeName {
    flex: 1;
cf70629b   刘淇   养护计划 照片 自己写样式
727
    font-size: 14px;
12e66ec8   刘淇   新增树
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
    font-weight: bold;
  }
  
  .record-list-left {
    height: 70px;
    width: 70px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
  }
  
  .record-list-right {
    margin-left: 20px;
    flex: 1;
    overflow: hidden;
  }
  
12e66ec8   刘淇   新增树
745
746
747
748
749
750
751
  .treenumber-no {
    padding: 3px 10px;
    background: #bdefd0;
    font-size: 12px;
    margin-top: 8px;
  }
  
03b006dc   刘淇   树修改
752
  .card-body-inner {
12e66ec8   刘淇   新增树
753
    display: flex;
cf70629b   刘淇   养护计划 照片 自己写样式
754
    font-size: 12px;
12e66ec8   刘淇   新增树
755
756
  }
  
03b006dc   刘淇   树修改
757
758
759
760
  .fs-align__center {
    display: flex;
    align-items: center;
  }
12e66ec8   刘淇   新增树
761
  
03b006dc   刘淇   树修改
762
763
764
  .animated-area {
    transition: all 0.3s ease-out;
    margin-top: 10rpx;
12e66ec8   刘淇   新增树
765
766
  }
  
03b006dc   刘淇   树修改
767
768
769
  .location-form-item {
    padding-right: 10rpx;
  }
12e66ec8   刘淇   新增树
770
  
03b006dc   刘淇   树修改
771
772
  .form-row-wrap {
    width: 100%;
12e66ec8   刘淇   新增树
773
    display: flex;
03b006dc   刘淇   树修改
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
    flex-direction: column;
  
    :deep(.u-form-item) {
      position: relative;
      margin-bottom: 0 !important;
    }
  
    :deep(.u-form-item__body__right__message ) {
      position: absolute;
      left: 0;
      bottom: -20rpx;
      line-height: 20rpx;
      font-size: 22rpx;
      color: #f56c6c;
      width: 100%;
      box-sizing: border-box;
    }
12e66ec8   刘淇   新增树
791
  }
8ddc6f6e   刘淇   登录 修改样式
792
  
03b006dc   刘淇   树修改
793
794
795
  .form-row-wrap + .u-form-item {
    margin-top: 25rpx !important;
  }
ecbfbe06   刘淇   树巡检记录
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
  
  /* 底部固定按钮 */
  .fixed-bottom-btn-wrap {
    // position: fixed;
    // left: 0;
    // right: 0;
    // bottom: 0;
    // padding: 15rpx 30rpx;
    // background: #fff;
    // box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.05);
  }
  
  /* 巡检记录样式 */
  .inspect-row {
    font-size: 14px;
    line-height: 2.2;
  }
  .detail-text {
    color: #1989fa;
    font-size: 14px;
  }
8ddc6f6e   刘淇   登录 修改样式
817
  </style>