aosiyiliaouniapp/pages/project/projectIndex.vue

270 lines
9.6 KiB
Vue
Raw Normal View History

<template>
<view class="page">
2024-04-09 14:01:38 +00:00
<hqs-popup class="hqs-popup" height="40vh" title="向下滑动关闭" from="top" :mask-click="maskClick" @back="onBack" v-model="showPop">
<view class="from-item">
<view class="from-item-label">项目名称:</view>
<u-search class="from-item-input" @focus="selectShow = true" v-model="queryFrom.projectName" :showAction="false"
disabledColor="#ffffff" placeholder="请选择项目名称"></u-search>
</view>
<view class="from-item">
<view class="from-item-label">开始时间:</view>
<u-search class="from-item-input" @focus="showTime = true; type = 'createdStartDt'" v-model="queryFrom.createdStartDt" :showAction="false"
disabledColor="#ffffff" placeholder="请选择开始时间"></u-search>
</view>
<view class="from-item">
<view class="from-item-label">结束时间:</view>
<u-search class="from-item-input" @focus="showTime = true; type = 'createdEndDt'" v-model="queryFrom.createdEndDt" :showAction="false"
disabledColor="#ffffff" placeholder="请选择结束时间"></u-search>
</view>
<template v-slot:bottom>
<view class="chaxunx">
<u-button type="info" size="medium" :ripple="true" ripple-bg-color="#909399"
@click="resultFunc">重置</u-button>
<u-button type="primary" size="medium" :ripple="true" ripple-bg-color="#909399"
@click="queryFunc">查询</u-button>
</view>
</template>
</hqs-popup>
<view class="query-view">
<view class="header">
<u-search placeholder="请查询" input-align="center" :show-action="false" @focus="onShowPopup"></u-search>
</view>
</view>
2024-04-09 03:35:33 +00:00
<view class="list-view" >
2024-04-10 09:13:31 +00:00
<view class="list-view-item" :key="index" v-for="(item,index) in tableData">
<view style="display: flex;flex-direction: column;flex:4.5">
<span class="span-porject span-porject-top">
<ul>项目名称</ul>
<ul>{{item.projectName}}</ul>
</span>
<span class="span-porject">
<ul>创建时间</ul>
<ul>{{item.createdDtFormatted}}</ul>
</span>
<span class="span-porject">
<ul>修改时间</ul>
<ul>{{item.updateDt?item.updateDt:''}}</ul>
</span>
</view>
<view style="display: block;flex: 0.01;background-color: #58b6ec;height: 82%;margin-top: 4%;"></view>
2024-04-09 14:01:38 +00:00
<view style="margin-left: 1ex;display: flex;flex-direction: column;flex:3.5">
<span class="span-porject span-porject-top">
<ul>单价</ul>
<ul>{{item.unitPrice}}</ul>
</span>
<span class="span-porject">
<ul>创建人</ul>
<ul>{{item.createdBy}}</ul>
</span>
<span class="span-porject">
<ul>修改人</ul>
<ul>{{item.updateBy?item.updateBy:''}}</ul>
</span>
</view>
<view style="flex:2;display:flex;flex-direction:column;">
<view style="margin-top:auto;">
<u-button type="warning" size="mini" ripple-bg-color="#909399"
@click="editItem(item)">修改项目</u-button>
</view>
<view style="margin-top:1ex;margin-bottom: 0ex;">
<u-button type="error" size="mini" :ripple="true" ripple-bg-color="#909399"
@click="delItem(item)">删除项目</u-button>
</view>
</view>
</view>
</view>
2024-04-09 00:49:07 +00:00
<view class="foot-view">
<view class="chaxunx">
2024-04-09 14:01:38 +00:00
<u-button type="primary" size="medium" :ripple="true" ripple-bg-color="#909399" @click="addItem">新增项目</u-button>
</view>
2024-04-09 00:49:07 +00:00
</view>
2024-04-10 09:13:31 +00:00
<u-picker :show="selectShow" :columns="columns" @confirm="confirm" @cancel="selectShow = false" :closeOnClickOverlay="true" @close="close1"></u-picker>
<u-datetime-picker :show="showTime" v-model="time" format="YYYY-MM-DD HH:mm:ss" mode="date"
2024-04-10 09:13:31 +00:00
closeOnClickOverlay @confirm="timeConfirm" @cancel="showTime = false" @close = "showTime = false"></u-datetime-picker>
<u-popup :show="addAndEditShow" :round="10" mode="top" @close="close" >
2024-04-09 14:01:38 +00:00
<view>
<view class="from-item">
<view class="from-item-label">项目名称:</view>
<u--input class="from-item-input" v-model="selectRow.projectName"
disabledColor="#ffffff" placeholder="请输入项目名称"></u--input>
</view>
<view class="from-item">
<view class="from-item-label">单价():</view>
<u--input class="from-item-input" placeholder="请输入单价" v-model="selectRow.unitPrice"></u--input>
</view>
<view class="chaxunx" style="margin-top: 2ex;">
<u-button type="primary" size="medium" :ripple="true" ripple-bg-color="#909399" @click="commitInfo">提交</u-button>
<u-button type="info" size="medium" :ripple="true" ripple-bg-color="#909399" @click="addAndEditShow = false">关闭</u-button>
</view>
</view>
</u-popup>
<view class="" >
<u-notify style="height: 50upx;line-height: 50upx;" ref="uNotify" message="Hi uView"></u-notify>
2024-04-09 00:49:07 +00:00
</view>
</view>
</template>
<script>
import { commonPost } from "../../api/api.js"
export default {
data() {
return {
2024-04-09 00:49:07 +00:00
selectRow: {},
type: '',
2024-04-09 00:49:07 +00:00
addAndEditShow: false,
maskClick: true,
showPop: false,
queryFrom: {projectName:'',createdStartDt:'',createdEndDt:''},
selectShow: false,
showTime: false,
2024-04-10 09:13:31 +00:00
columns: ["拔火罐"],
time: Number(new Date()),
tableData: []
}
},
2024-04-10 09:13:31 +00:00
async onLoad() {
this.queryFunc()
2024-04-10 09:13:31 +00:00
const res = await commonPost('project/findProjectNameList','{}')
console.log(res)
this.columns[0] = res.data
console.log(this.columns)
},
methods: {
onBack() {
uni.showToast({
title: 'test',
})
},
onShowPopup() {
this.showPop = true
},
2024-04-10 09:13:31 +00:00
close(){
this.addAndEditShow = false
},
confirm(e) {
console.log(e)
this.queryFrom.projectName = e.value
this.selectShow = false
},
timeConfirm(e) {
// this.$set(this.queryFrom, this.type, this.time)
this.queryFrom[this.type] = this.formatMillisecondsToDate(e.value)
this.showTime = false
},
async queryFunc() {
this.showPop = false
2024-04-09 03:35:33 +00:00
const res = await commonPost('project/findProjectList',this.queryFrom)
// console.log(res)
if(res.code == 200){
this.tableData = res.data
}
},
2024-04-10 09:13:31 +00:00
close1(){
this.selectShow = false
},
formatMillisecondsToDate(milliseconds) {
// 创建一个新的Date对象参数为毫秒值
var date = new Date(milliseconds);
// 提取年、月、日
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份从0开始所以加1并格式化为两位数
var day = ("0" + date.getDate()).slice(-2); // 格式化为两位数
// 返回年月日的字符串格式
return year + "-" + month + "-" + day;
},
resultFunc() {
this.queryFrom = {projectName:'', createdStartDt:'', createdEndDt:''}
},
2024-04-10 09:13:31 +00:00
editItem(item) {
2024-04-09 00:49:07 +00:00
this.selectRow = item
this.addAndEditShow = true
},
addItem(){
this.addAndEditShow = true
},
async delItem(item) {
const res = await commonPost('project/delProject',{sid:item.sid})
2024-04-09 00:49:07 +00:00
if(res.code == 200){
2024-04-09 14:01:38 +00:00
this.queryFunc()
this.$refs.uNotify.show({
top: 20,
type: 'success',
message: "删除成功",
duration: 1000 * 3,
fontSize: 40,
safeAreaInsetTop:false
})
}
2024-04-09 14:04:35 +00:00
this.queryFunc()
2024-04-09 00:49:07 +00:00
},
2024-04-10 09:13:31 +00:00
2024-04-09 00:49:07 +00:00
async commitInfo(){
const {projectName,unitPrice,sid} = this.selectRow
2024-04-09 13:58:21 +00:00
2024-04-09 00:49:07 +00:00
if(!projectName){
2024-04-10 09:13:31 +00:00
this.$refs.uNotify.show({
top: 20,
type: 'success',
message: "项目名称不能为空",
duration: 1000 * 3,
fontSize: 40,
safeAreaInsetTop:false
})
2024-04-09 00:49:07 +00:00
return
}
if(!unitPrice){
2024-04-10 09:13:31 +00:00
this.$refs.uNotify.show({
top: 20,
type: 'success',
message: "单价不能为空",
duration: 1000 * 3,
fontSize: 40,
safeAreaInsetTop:false
})
2024-04-09 00:49:07 +00:00
return
}
if(sid){
const res = await commonPost('project/editProject',this.selectRow)
2024-04-09 00:49:07 +00:00
if(res.code == 200){
this.addAndEditShow = false
2024-04-09 14:01:38 +00:00
this.$refs.uNotify.show({
top: 20,
type: 'success',
message: "修改成功",
duration: 1000 * 3,
fontSize: 40,
safeAreaInsetTop:false
})
2024-04-10 09:13:31 +00:00
this.selectRow = {}
2024-04-09 00:49:07 +00:00
this.queryFunc()
}
2024-04-10 09:13:31 +00:00
2024-04-09 00:49:07 +00:00
}else{
const res = await commonPost('project/addProject',this.selectRow)
2024-04-09 00:49:07 +00:00
if(res.code == 200){
this.addAndEditShow = false
2024-04-09 14:01:38 +00:00
this.$refs.uNotify.show({
top: 20,
type: 'success',
message: "新增成功",
duration: 1000 * 3,
fontSize: 40,
safeAreaInsetTop:false
})
2024-04-10 09:13:31 +00:00
this.selectRow = {}
2024-04-09 00:49:07 +00:00
this.queryFunc()
}
2024-04-10 09:13:31 +00:00
2024-04-09 00:49:07 +00:00
}
}
}
}
</script>
<style>
2024-04-09 13:58:21 +00:00
@import 'project.css'
</style>