Commit 6cba22dec64e6f49a504f2ae8372df657816ff21
1 parent
3bea8ade
图片上传
Showing
8 changed files
with
185 additions
and
25 deletions
App.vue
| @@ -17,6 +17,7 @@ export default { | @@ -17,6 +17,7 @@ export default { | ||
| 17 | <style lang="scss"> | 17 | <style lang="scss"> |
| 18 | page { | 18 | page { |
| 19 | background-color: #F4F4F4; | 19 | background-color: #F4F4F4; |
| 20 | + color: #333; | ||
| 20 | } | 21 | } |
| 21 | @import './components/thorui/fui-css/firstui.scss'; | 22 | @import './components/thorui/fui-css/firstui.scss'; |
| 22 | </style> | 23 | </style> |
pages.json
| @@ -296,7 +296,20 @@ | @@ -296,7 +296,20 @@ | ||
| 296 | "style": { | 296 | "style": { |
| 297 | "navigationBarTitleText": "录入树木" | 297 | "navigationBarTitleText": "录入树木" |
| 298 | } | 298 | } |
| 299 | + }, | ||
| 300 | + { | ||
| 301 | + "path": "treePage/editTree", | ||
| 302 | + "style": { | ||
| 303 | + "navigationBarTitleText": "修改树木" | ||
| 304 | + } | ||
| 305 | + }, | ||
| 306 | + { | ||
| 307 | + "path": "treePage/treeDeatil", | ||
| 308 | + "style": { | ||
| 309 | + "navigationBarTitleText": "树木详情" | ||
| 310 | + } | ||
| 299 | } | 311 | } |
| 312 | + | ||
| 300 | ] | 313 | ] |
| 301 | } | 314 | } |
| 302 | ], | 315 | ], |
pages/work/treePage/treeFiles.vue deleted
subPackages/treePage/addTree.vue
| @@ -207,14 +207,14 @@ const rules = [{ | @@ -207,14 +207,14 @@ const rules = [{ | ||
| 207 | name: "oldtreeownership", | 207 | name: "oldtreeownership", |
| 208 | rule: ["required"], | 208 | rule: ["required"], |
| 209 | msg: ["请选择权属分类"] | 209 | msg: ["请选择权属分类"] |
| 210 | -}, { | 210 | +},{ |
| 211 | name: "treeImgList", | 211 | name: "treeImgList", |
| 212 | - // 自定义验证函数处理数组类型 | ||
| 213 | - rule: [(value) => { | ||
| 214 | - // 验证逻辑:数组长度至少为1 | ||
| 215 | - return Array.isArray(value) && value.length > 0; | ||
| 216 | - }], | ||
| 217 | - msg: ["请上传图片"] | 212 | + rule: ["required", "custom"], // 增加required强制必选 |
| 213 | + msg: ["请上传图片", "请至少上传一张图片"], // 对应两个规则的提示 | ||
| 214 | + custom: function(value) { | ||
| 215 | + // 即使required通过,再校验数组长度 | ||
| 216 | + return value.length > 0; | ||
| 217 | + } | ||
| 218 | }]; | 218 | }]; |
| 219 | export default { | 219 | export default { |
| 220 | props: { | 220 | props: { |
| @@ -278,6 +278,8 @@ export default { | @@ -278,6 +278,8 @@ export default { | ||
| 278 | }, | 278 | }, |
| 279 | onReady() { | 279 | onReady() { |
| 280 | //开启即时校验,开启后输入即校验【参数必传】,第一参数:是否开启;第二参数:校验规则 | 280 | //开启即时校验,开启后输入即校验【参数必传】,第一参数:是否开启;第二参数:校验规则 |
| 281 | + // 开启即时校验,参数:是否开启、校验规则 | ||
| 282 | + this.$refs.form && this.$refs.form.immediateValidate(true, rules); | ||
| 281 | // this.$refs.form && this.$refs.form.immediateValidate(true, rules) | 283 | // this.$refs.form && this.$refs.form.immediateValidate(true, rules) |
| 282 | }, | 284 | }, |
| 283 | methods: { | 285 | methods: { |
| @@ -290,7 +292,11 @@ export default { | @@ -290,7 +292,11 @@ export default { | ||
| 290 | 292 | ||
| 291 | if (e.status == 1){ | 293 | if (e.status == 1){ |
| 292 | console.log(e) | 294 | console.log(e) |
| 293 | - this.formData.treeImgList.push(e.imgArr); | 295 | + // this.formData.treeImgList.push(e.imgArr); |
| 296 | + | ||
| 297 | + this.formData.treeImgList = e.imgArr; | ||
| 298 | + // 手动触发treeImgList字段的校验 | ||
| 299 | + this.$refs.form.validateField("treeImgList"); | ||
| 294 | console.log(this.formData.treeImgList) | 300 | console.log(this.formData.treeImgList) |
| 295 | console.log(this.formData.treeImgList.length) | 301 | console.log(this.formData.treeImgList.length) |
| 296 | } | 302 | } |
| @@ -322,6 +328,13 @@ export default { | @@ -322,6 +328,13 @@ export default { | ||
| 322 | 328 | ||
| 323 | }, | 329 | }, |
| 324 | submit() { | 330 | submit() { |
| 331 | + // 3. 打印提交时的数据 | ||
| 332 | + console.log("提交时treeImgList:", this.formData.treeImgList); | ||
| 333 | + // 手动校验图片 | ||
| 334 | + if (!this.formData.treeImgList || this.formData.treeImgList.length === 0) { | ||
| 335 | + uni.showToast({ title: "请上传图片", icon: "none" }); | ||
| 336 | + return; // 阻止提交 | ||
| 337 | + } | ||
| 325 | //注:结合FormItem校验,validate方法第三个参数必须传true | 338 | //注:结合FormItem校验,validate方法第三个参数必须传true |
| 326 | this.$refs.form.validate(this.formData, rules, true).then(res => { | 339 | this.$refs.form.validate(this.formData, rules, true).then(res => { |
| 327 | if (res.isPass) { | 340 | if (res.isPass) { |
subPackages/treePage/editTree.vue
0 → 100644
| 1 | + | ||
| 2 | +<template> | ||
| 3 | + | ||
| 4 | + <view class="container"> | ||
| 5 | + <tui-tab :tabs="tabs" scroll @change="tabChange"></tui-tab> | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + <view class="content-container"> | ||
| 9 | + <view v-if="currentName === '基本信息'">xiugai基本信息</view> | ||
| 10 | + | ||
| 11 | + <treeLog v-if="currentName === '变更日志'" :logId="id" /> | ||
| 12 | + </view> | ||
| 13 | + </view> | ||
| 14 | + | ||
| 15 | +</template> | ||
| 16 | +<script > | ||
| 17 | +import treeLog from "./treeLog.vue"; | ||
| 18 | +export default { | ||
| 19 | + components:{treeLog}, | ||
| 20 | + name: "editTree", | ||
| 21 | + data(){ | ||
| 22 | + return{ | ||
| 23 | + tabs:['基本信息','变更日志',], | ||
| 24 | + currentName:'基本信息', | ||
| 25 | + id:'' | ||
| 26 | + } | ||
| 27 | + }, | ||
| 28 | + onLoad(options){ | ||
| 29 | + this.id = options.id | ||
| 30 | + }, | ||
| 31 | + methods:{ | ||
| 32 | + tabChange(i){ | ||
| 33 | + console.log(i.item.name) | ||
| 34 | + this.currentName = i.item.name | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | +} | ||
| 38 | +</script> | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +<style scoped> | ||
| 43 | +.content-container{ | ||
| 44 | + padding-top: 20rpx; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +</style> | ||
| 0 | \ No newline at end of file | 48 | \ No newline at end of file |
subPackages/treePage/treeDetail.vue
0 → 100644
| 1 | +<script lang="ts"> | ||
| 2 | +import {defineComponent} from 'vue' | ||
| 3 | + | ||
| 4 | +export default defineComponent({ | ||
| 5 | + name: "treeDetail" | ||
| 6 | +}) | ||
| 7 | +</script> | ||
| 8 | + | ||
| 9 | +<template> | ||
| 10 | + <template> | ||
| 11 | + | ||
| 12 | + <view class="container"> | ||
| 13 | + <tui-tab :tabs="tabs" scroll @change="tabChange"></tui-tab> | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + <view class="content-container"> | ||
| 17 | + <view v-if="currentName === '基本信息'">xiugai基本信息</view> | ||
| 18 | + | ||
| 19 | + <treeLog v-if="currentName === '变更日志'" :logId="id" /> | ||
| 20 | + </view> | ||
| 21 | + </view> | ||
| 22 | + | ||
| 23 | + </template> | ||
| 24 | + <script > | ||
| 25 | + import treeLog from "./treeLog.vue"; | ||
| 26 | + export default { | ||
| 27 | + components:{treeLog}, | ||
| 28 | + name: "editTree", | ||
| 29 | + data(){ | ||
| 30 | + return{ | ||
| 31 | + tabs:['基本信息','变更日志',], | ||
| 32 | + currentName:'基本信息', | ||
| 33 | + id:'' | ||
| 34 | + } | ||
| 35 | + }, | ||
| 36 | + onLoad(options){ | ||
| 37 | + this.id = options.id | ||
| 38 | + }, | ||
| 39 | + methods:{ | ||
| 40 | + tabChange(i){ | ||
| 41 | + console.log(i.item.name) | ||
| 42 | + this.currentName = i.item.name | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + </script> | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + <style scoped> | ||
| 51 | + .content-container{ | ||
| 52 | + padding-top: 20rpx; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + </style> | ||
| 56 | + | ||
| 57 | +</template> | ||
| 58 | + | ||
| 59 | +<style scoped> | ||
| 60 | + | ||
| 61 | +</style> | ||
| 0 | \ No newline at end of file | 62 | \ No newline at end of file |
subPackages/treePage/treeFiles.vue
| @@ -25,7 +25,9 @@ | @@ -25,7 +25,9 @@ | ||
| 25 | <view v-for="(i,index) in 7" class="teamsItem" :key="index" | 25 | <view v-for="(i,index) in 7" class="teamsItem" :key="index" |
| 26 | @click="teamsChange(i)" | 26 | @click="teamsChange(i)" |
| 27 | :class="{teamsActive:index==currentIndex}" | 27 | :class="{teamsActive:index==currentIndex}" |
| 28 | - >{{ i }} | 28 | + > |
| 29 | + <view class="fs-ellipsis fs-pt16 fs-pb16 fs-pl8 fs-pr8">归属班组归属班组归属班组</view> | ||
| 30 | + | ||
| 29 | </view> | 31 | </view> |
| 30 | </view> | 32 | </view> |
| 31 | <view class="full-height-col right-con"> | 33 | <view class="full-height-col right-con"> |
| @@ -150,7 +152,6 @@ export default { | @@ -150,7 +152,6 @@ export default { | ||
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | .teamsItem { | 154 | .teamsItem { |
| 153 | - padding: 10rpx 10rpx 0; | ||
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | .teamsActive { | 157 | .teamsActive { |
subPackages/treePage/treeLog.vue
0 → 100644
| 1 | +<script> | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +export default { | ||
| 5 | + name: "treeLog", | ||
| 6 | + props: { | ||
| 7 | + logId: { | ||
| 8 | + type: String, | ||
| 9 | + required: true | ||
| 10 | + } | ||
| 11 | + }, | ||
| 12 | + data() { | ||
| 13 | + return {} | ||
| 14 | + }, | ||
| 15 | + watch: { | ||
| 16 | + logId: { | ||
| 17 | + immediate: true, | ||
| 18 | + handler(newVal, oldVal) { | ||
| 19 | + if (newVal !== oldVal) { | ||
| 20 | + this.initLog() | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + }, | ||
| 25 | + methods: { | ||
| 26 | + async initLog() { | ||
| 27 | + } | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | +</script> | ||
| 31 | + | ||
| 32 | +<template> | ||
| 33 | + <view>log</view> | ||
| 34 | + | ||
| 35 | +</template> | ||
| 36 | + | ||
| 37 | +<style scoped> | ||
| 38 | + | ||
| 39 | +</style> | ||
| 0 | \ No newline at end of file | 40 | \ No newline at end of file |