fix:页面修改为VUE3模式。

This commit is contained in:
tianyongbao
2024-06-05 13:48:37 +08:00
parent 1b91ca7ebd
commit 568125d792
5 changed files with 193 additions and 195 deletions

View File

@@ -1,12 +1,10 @@
<template> <template>
<u-cell :border="false">
<view slot="title" class="title"> <view slot="title" class="title">
{{ title }} {{ title }}
</view> </view>
<view slot="value" class="value" :style="valueStyle"> <view slot="value" class="value" :style="valueStyle">
{{ value }} {{ value }}
</view> </view>
</u-cell>
</template> </template>
<script> <script>

View File

@@ -99,7 +99,7 @@
{ {
"path": "pages/work/heartJourney/addEdit", "path": "pages/work/heartJourney/addEdit",
"style": { "style": {
"navigationBarTitleText": "心路历程添加修改" "navigationBarTitleText": "心路历程"
} }
} }
], ],

View File

@@ -1,8 +1,13 @@
<template> <template>
<view class="container" style="paddingBottom:1rpx;"> <view class="container" style="paddingBottom:1rpx;">
<uni-navbar title="心路历程"></uni-navbar> <u-navbar
leftIconSize="40rpx"
leftIconColor="#333333"
title="心路历程"
>
</u-navbar>
<view class="section"> <view class="section">
<view class="section-title">心路历程</view> <view class="section-title">{{ title}}</view>
<view class="form-view"> <view class="form-view">
<u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" label-width="auto" <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" label-width="auto"
:labelStyle="{ color: '#333333', fontSize: '30rpx' }"> :labelStyle="{ color: '#333333', fontSize: '30rpx' }">
@@ -43,101 +48,99 @@
</view> </view>
</template> </template>
<script> <script setup>
import { listHeartJourney, getHeartJourney, delHeartJourney, addHeartJourney, updateHeartJourney } from '@/api/invest/heartJourney' import {getHeartJourney, addHeartJourney, updateHeartJourney } from '@/api/invest/heartJourney'
import { getDicts } from '@/api/system/dict/data.js' import { getDicts } from '@/api/system/dict/data.js'
const { proxy } = getCurrentInstance()
import dayjs from 'dayjs' import dayjs from 'dayjs'
export default { import {onLoad,onReady} from "@dcloudio/uni-app";
data() { // 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
return { import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
form: { const datePickShow = ref(false)
createTime: '', const showTeam = ref(false)
name: '', const title = ref("心路历程")
remark: '', const journeyTypeList = ref([])
type: '', const data = reactive({
createTime: '', form: {},
typeName: '',
id: '',
},
rules: { rules: {
name: [{ type: 'string', required: true, message: '请输入标题', trigger: ['change', 'blur'] }], name: [{ type: 'string', required: true, message: '请输入标题', trigger: ['change', 'blur'] }],
createTime: [{ type: 'string', required: true, message: '请选择记录时间', trigger: ['change', 'blur'] }], createTime: [{ type: 'string', required: true, message: '请选择记录时间', trigger: ['change', 'blur'] }],
type: [{ type: 'string', required: true, message: '请选择类型', trigger: ['change', 'blur'] }], type: [{ type: 'string', required: true, message: '请选择类型', trigger: ['change', 'blur'] }],
remark: [{ type: 'string', required: true, message: '请输入内容', trigger: ['change', 'blur'] }], remark: [{ type: 'string', required: true, message: '请输入内容', trigger: ['change', 'blur'] }],
},
datePickShow: false,
id: '',
showTeam: false,
journeyTypeList: []
} }
}, })
onLoad(option) { const { form, rules} = toRefs(data)
this.form.id = option.id
this.getDict() onLoad((option) => {
}, form.value.id = option.id
onReady() { if(form.value.id!=null){
this.$refs.uForm.setRules(this.rules) title.value="心路历程-修改"
}, }else{
methods: { title.value="心路历程-新增"
getDict() { }
getDict()
})
onReady(() => {
proxy.$refs['uForm'].setRules(rules.value)
})
function getDict() {
// 工单状态 // 工单状态
getDicts('journey_type').then(res => { getDicts('journey_type').then(res => {
this.journeyTypeList =[res.data] journeyTypeList.value =[res.data]
}) })
if(this.form.id!=null){ if(form.value.id!=null){
getHeartJourney(this.form.id).then(res => { getHeartJourney(form.value.id).then(res => {
this.form = res.data form.value = res.data
}) })
} }
}, }
handleShowTeam() {
if (this.journeyTypeList[0].length === 0) {
this.$refs.uToast.show({ function handleShowTeam() {
if (journeyTypeList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '类型为空 ', type: 'warning' message: '类型为空 ', type: 'warning'
}) })
} else { } else {
this.showTeam = true showTeam.value = true
} }
}, }
handleConfirm(e) { function handleConfirm(e) {
this.form.typeName = e.value[0].dictLabel form.value.typeName = e.value[0].dictLabel
this.form.type = e.value[0].dictValue form.value.type = e.value[0].dictValue
this.showTeam = false showTeam.value = false
}, }
handleCancel() { function handleCancel() {
this.showTeam = false showTeam.value = false
}, }
selectDate() { function selectDate() {
this.datePickShow = true datePickShow.value = true
this.$refs.createTimeRef.innerValue = new Date().getTime() proxy.$refs['createTimeRef'].innerValue = new Date().getTime()
}, }
datePickConfirm(e) { function datePickConfirm(e) {
this.form.createTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss") form.value.createTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
this.datePickShow = false datePickShow.value = false
}, }
submit() { function submit() {
this.$refs.uForm.validate().then(() => { proxy.$refs['uForm'].validate().then(() => {
if (this.form.id != null) { if (form.value.id != null) {
updateHeartJourney({ ...this.form}).then(res => { updateHeartJourney(form.value).then(res => {
this.$refs.uToast.show({ proxy.$refs['uToast'].show({
message: '修改成功', complete() { message: '修改成功', complete() {
uni.navigateTo({ url: `/pages/work/heartJourney/list` }) uni.navigateTo({ url: `/pages/work/heartJourney/list` })
} }
}) })
}) })
}else { }else {
addHeartJourney({ ...this.form}).then(res => { addHeartJourney(form.value).then(res => {
this.$refs.uToast.show({ proxy.$refs['uToast'].show({
message: '新增成功', complete() { message: '新增成功', complete() {
uni.navigateTo({ url: `/pages/work/heartJourney/list` }) uni.navigateTo({ url: `/pages/work/heartJourney/list` })
} }
}) })
}) })
} }
}) })
},
}
} }
</script> </script>
@@ -149,7 +152,7 @@
border-radius: 8rpx; border-radius: 8rpx;
.section-title { .section-title {
width: 160rpx; width: 360rpx;
color: #333333; color: #333333;
line-height: 44rpx; line-height: 44rpx;
font-size: 30rpx; font-size: 30rpx;

View File

@@ -1,38 +1,39 @@
<template> <template>
<view class="container" style="paddingBottom:1rpx;"> <view class="container" style="paddingBottom:1rpx;">
<!-- <uni-navbar title="心路历程详情"></uni-navbar> --> <u-navbar
leftIconSize="40rpx"
leftIconColor="#333333"
title="心路历程详情"
>
</u-navbar>
<view class="section"> <view class="section">
<view class="section-title">{{ detailInfo.name }}</view> <!-- <view class="section-title">{{ detailInfo.name }}</view> -->
<!-- <uni-cellItem title="标题:" :value="detailInfo.name"></uni-cellItem> <uni-cellItem title="标题:" :value="detailInfo.name"></uni-cellItem>
<uni-cellItem title="记录时间:" :value="detailInfo.createTime"></uni-cellItem> <uni-cellItem title="记录时间:" :value="detailInfo.createTime"></uni-cellItem>
<uni-cellItem title="内容:"></uni-cellItem> --> <uni-cellItem title="内容:"></uni-cellItem>
<view class="content">{{ detailInfo.remark }}</view> <view class="content">{{ detailInfo.remark }}</view>
</view> </view>
<u-toast ref="uToast"></u-toast> <u-toast ref="uToast"></u-toast>
</view> </view>
</template> </template>
<script> <script setup>
import { getHeartJourney} from '@/api/invest/heartJourney' import { getHeartJourney} from '@/api/invest/heartJourney'
import {onLoad} from "@dcloudio/uni-app";
export default { import {reactive ,toRefs,ref,computed }from "vue";
data() { const id = ref('')
return { const data = reactive({
detailInfo: {}, detailInfo: {}
id: '', })
} const {detailInfo} = toRefs(data)
}, onLoad((option) => {
onLoad(option) { id.value = option.id
this.id = option.id getInfo()
this.getInfo() })
}, function getInfo() {
methods: { getHeartJourney(id.value).then(res => {
getInfo() { detailInfo.value = res.data
getHeartJourney(this.id).then(res => {
this.detailInfo = res.data
}) })
}
}
} }
</script> </script>

View File

@@ -64,78 +64,76 @@
</view> </view>
</template> </template>
<script> <script setup>
import { listHeartJourney, delHeartJourney } from '@/api/invest/heartJourney' import { listHeartJourney, delHeartJourney } from '@/api/invest/heartJourney'
import { getDicts } from '@/api/system/dict/data.js' import { getDicts } from '@/api/system/dict/data.js'
import {onLoad,onShow} from "@dcloudio/uni-app";
export default { // 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
data() { import {reactive ,toRefs,ref,computed }from "vue";
return { const pageNum = ref(1)
const listData = ref([])
const isShow = ref(false)
const status = ref('loadmore')
const journeyTypeList = ref([])
const settingPickShow = ref(false)
const settingColumns = ref([])
const data = reactive({
filterPanel: false, filterPanel: false,
listData: [],
pageNum: 1,
queryParams: { queryParams: {
name: '', name: '',
type: '', type: '',
},
status: 'loadmore',
journeyTypeList: [],
settingPickShow: false,
settingColumns: [],
columns: [],
isShow: false
} }
}, })
computed: { const { filterPanel, queryParams} = toRefs(data)
windowHeight() { const windowHeight = computed(() => {
return uni.getSystemInfoSync().windowHeight - 50 uni.getSystemInfoSync().windowHeight - 50
})
onLoad(() => {
getDict()
getList()
});
onShow(() => {
if (isShow.value) {
getList()
isShow.value = false
} }
}, });
onLoad() {
this.getDict() function loadmore() {
this.getList() pageNum.value += 1
}, if (status.value == 'loadmore') {
onShow() { getList()
if (this.isShow) {
this.getList()
this.isShow = false
} }
},
methods: {
loadmore() {
this.pageNum += 1
if (this.status == 'loadmore') {
this.getList()
} }
}, function getList() {
getList() { status.value = 'loading'
this.status = 'loading' listHeartJourney({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
listHeartJourney({ pageSize: 10, pageNum: this.pageNum, ...this.queryParams }).then(res => { listData.value = listData.value.concat(res.rows)
this.listData = this.listData.concat(res.rows) if (listData.length < res.total) {
if (this.listData.length < res.total) { status.value = 'loadmore'
this.status = 'loadmore'
} else { } else {
this.status = 'nomore' status.value = 'nomore'
} }
}).catch(() => { }).catch(() => {
this.status = 'nomore' status.value = 'nomore'
}) })
}, }
getDict() { function getDict() {
// 工单状态 // 工单状态
getDicts('journey_type').then(res => { getDicts('journey_type').then(res => {
this.journeyTypeList = res.data journeyTypeList.value = res.data
}) })
}, }
settingConfirm(e) { function settingConfirm(e) {
this.queryParams.settingId = e.value[0].settingId queryParams.value.settingId = e.value[0].settingId
this.queryParams.settingName = e.value[0].settingName queryParams.value.settingName = e.value[0].settingName
this.settingPickShow = false settingPickShow.value = false
}, }
settingCancel() { function settingCancel() {
this.settingPickShow = false settingPickShow.value = false
}, }
dictStr(val, arr) { function dictStr(val, arr) {
let str = '' let str = ''
arr.map(item => { arr.map(item => {
if (item.dictValue === val) { if (item.dictValue === val) {
@@ -143,48 +141,48 @@ export default {
} }
}) })
return str return str
}, }
selectStatus(item) { function selectStatus(item) {
this.queryParams.type = item.dictValue queryParams.value.type = item.dictValue
this.journeyTypeList.map(ele => { journeyTypeList.value.map(ele => {
if (ele.dictValue == item.dictValue) { if (ele.dictValue == item.dictValue) {
ele.selected = true ele.selected = true
this.$set(ele, 'selected', true) Reflect.set(ele, 'selected', true)
} else { } else {
this.$set(ele, 'selected', false) Reflect.set(ele, 'selected', false)
} }
}) })
}, }
searchSubmit() { function searchSubmit() {
this.pageNum = 1 pageNum.value = 1
this.listData = [] listData.value = []
this.getList() getList()
this.filterPanel = false filterPanel.value = false
}, }
searchBlur() { function searchBlur() {
this.pageNum = 1 pageNum.value = 1
this.listData = [] listData.value = []
this.getList() getList()
}, }
resetQuery() { function resetQuery() {
this.queryParams.name = '', queryParams.value.name = '',
this.queryParams.type = '' queryParams.value.type = ''
this.journeyTypeList.map(ele => { journeyTypeList.value.map(ele => {
this.$set(ele, 'selected', false) Reflect.set(ele, 'selected', false)
}) })
}, }
enterDetails(item) { function enterDetails(item) {
uni.navigateTo({ url: `/pages/work/heartJourney/details?id=${item.id}` }) uni.navigateTo({ url: `/pages/work/heartJourney/details?id=${item.id}` })
}, }
handleEdit(item) { function handleEdit(item) {
uni.navigateTo({ url: `/pages/work/heartJourney/addEdit?id=${item.id}` }) uni.navigateTo({ url: `/pages/work/heartJourney/addEdit?id=${item.id}` })
this.isShow = true isShow.value = true
}, }
handleAdd() { function handleAdd() {
uni.navigateTo({ url: `/pages/work/heartJourney/addEdit` }) uni.navigateTo({ url: `/pages/work/heartJourney/addEdit` })
this.isShow = true isShow.value = true
}, }
handleDelete(item) { function handleDelete(item) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '你确定要删除吗', content: '你确定要删除吗',
@@ -197,10 +195,8 @@ export default {
} }
} }
}); });
}
},
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>