xnzt/xnzt-h5/pages/formPages/enterprise/landManagementForm/index.vue
2024-11-11 10:27:27 +08:00

397 lines
9.7 KiB
Vue

<template>
<!-- <div class="landManagementForm">landManagementForm</div> -->
<view class="landManagementForm">
<view>
<uni-forms
ref="form"
:rules="rules"
:model="form"
class="form"
label-position="top"
label-width="100%"
validate-trigger="bind"
>
<uni-forms-item label="年度" name="baseYear">
<uni-easyinput
v-model="form.baseYear"
placeholder="请输入年度"
type="number"
/>
</uni-forms-item>
<uni-forms-item label="土地总面积(亩)" name="landArea">
<uni-easyinput
v-model="form.landArea"
placeholder="请输入土地总面积"
type="number"
/>
</uni-forms-item>
<uni-forms-item label="经营土地类型" name="landType">
<uni-data-select
v-model="form.landType"
:localdata="dictLists['sys_land_type']"
width="100%"
placeholder="请选择经营土地类型"
/>
</uni-forms-item>
<uni-forms-item label="经营方式" name="managementType">
<uni-data-select
v-model="form.managementType"
:localdata="dictLists['sys_management_type']"
width="100%"
placeholder="请选择经营方式"
/>
</uni-forms-item>
<uni-forms-item label="经营年限(年)" name="managementYears">
<uni-easyinput
v-model="form.managementYears"
placeholder="请输入经营年限(年)"
type="number"
/>
</uni-forms-item>
<uni-forms-item label="到期时间" name="expireTime">
<uni-datetime-picker
type="date"
v-model="form.expireTime"
placeholder="请选择到期时间"
/>
</uni-forms-item>
<uni-forms-item label="流转价格(万元)" name="circulationPrice">
<uni-easyinput
v-model="form.circulationPrice"
placeholder="请输入流转价格(万元)"
type="number"
/>
</uni-forms-item>
<uni-forms-item label="合同" name="contractUrl">
<uni-file-picker
fileMediatype="image"
limit="1"
mode="grid"
title=""
v-model="contractUrl"
@progress="progress"
@select="select"
/>
</uni-forms-item>
</uni-forms>
</view>
<view style="height: 44px">
<button v-if="false">
<text>{{ "测 试" }}</text>
</button>
</view>
<view v-if="true" class="foot">
<button @click="cencel" :plain="false" class="cencel">
<text>{{ "取 消" }}</text>
</button>
<button @click="showConfirm" type="primary" class="confirm">
<text>{{ "确 认" }}</text>
</button>
</view>
</view>
</template>
<script>
import {
listLandManagement,
getLandManagement,
delLandManagement,
addLandManagement,
updateLandManagement,
} from "@/api/enterprise/landManagement";
export default {
name: "landManagementForm",
components: {},
props: {},
data() {
return {
contractUrl: [],
options: {},
form: {},
dictLists: {},
list: [],
queryParams: {
pageNum: 1,
pageSize: 10,
baseId: null,
landType: null,
managementType: null,
landArea: null,
managementYears: null,
expireTime: null,
circulationPrice: null,
contractUrl: null,
addTime: null,
editTime: null,
baseYear: null,
state: "0",
},
rules: {
baseYear: {
rules: [
{
required: true,
errorMessage: "请输入年度",
},
],
},
landArea: {
rules: [
{
required: true,
errorMessage: "请输入土地总面积",
},
],
},
landType: {
rules: [
{
required: true,
errorMessage: "请选择经营土地类型",
},
],
},
managementType: {
rules: [
{
required: true,
errorMessage: "请选择经营方式",
},
],
},
},
};
},
computed: {},
methods: {
async initializeDict() {
this.dictByType("sys_land_type");
this.dictByType("sys_management_type");
},
dictByType(type) {
this.getDicts(type).then((response) => {
let dicts = [];
for (let dict of response.data) {
let element = {};
element["value"] = dict.dictValue;
element["text"] = dict.dictLabel;
element["label"] = dict.dictLabel;
dicts.push(element);
}
this.$set(this.dictLists, type, dicts);
});
},
getLandManagementById() {
this.loading = true;
getLandManagement(this.options.id).then((res) => {
this.form = res.data;
if (
this.form.contractUrl === "" ||
this.form.contractUrl === null ||
this.form.contractUrl === undefined
) {
this.$set(this.form, ["contractUrl"], []);
} else {
let contractUrl = [];
contractUrl.push(this.form.contractUrl);
this.$set(this.form, ["contractUrl"], contractUrl);
this.contractUrl = contractUrl;
}
this.loading = false;
});
},
async getRouter(options) {
this.options = options;
},
select(tempFiles) {
let contractUrl = [];
contractUrl.push(tempFiles.tempFilePaths);
this.form.contractUrl = contractUrl;
this.contractUrl = contractUrl;
},
progress(progress, tempFiles) {
console.log("-------> files <---------");
console.log(tempFiles);
console.log("-------> progress <---------");
console.log(progress);
},
naviBack(isNew) {
let pages = getCurrentPages(); //关于获取页面的官方文档https://uniapp.dcloud.io/api/window/window
let prevPage = pages[pages.length - 2];
uni.navigateBack({
delta: 1,
success: () => {
if (isNew !== undefined) {
setTimeout(function () {
prevPage.$vm.getMsg(isNew);
}, 200);
}
},
});
},
cencel() {
this.naviBack();
},
submitForm() {
let form = this.form;
let isNew =
this.form.id === null ||
this.form.id === undefined ||
this.form.id === "";
if (
form.contractUrl === undefined ||
form.contractUrl === [] ||
form.contractUrl === null ||
form.contractUrl.length === 0
) {
form.contractUrl = "";
} else {
form.contractUrl = form.contractUrl[0].toString(",");
}
if (isNew) {
addLandManagement(this.form).then((response) => {
this.naviBack(isNew);
});
} else {
updateLandManagement(this.form).then((response) => {
this.naviBack(isNew);
});
}
},
showConfirm() {
this.$refs["form"].validate().then((res) => {
this.$cus_modal.confirm().then((conf_res) => {
if (conf_res.confirm === true) {
this.submitForm();
}
});
});
},
},
watch: {
loading: {
handler: function (val, oldVal) {
if (val === true) {
this.$modal.loading("加载中,请耐心等待...");
} else {
this.$modal.closeLoading();
}
},
deep: true,
},
},
// 页面周期函数--监听页面加载
onLoad(options) {
this.initializeDict();
this.getRouter(options).then(() => {
if (options.id != undefined) {
this.getLandManagementById();
}
});
},
// 页面周期函数--监听页面初次渲染完成
onReady() {},
// 页面周期函数--监听页面显示(not-nvue)
onShow() {},
// 页面周期函数--监听页面隐藏
onHide() {},
// 页面周期函数--监听页面卸载
onUnload() {
const that = this
return that.$listenOB.goBack()
},
// 页面处理函数--监听用户下拉动作
// onPullDownRefresh() { uni.stopPullDownRefresh(); },
// 页面处理函数--监听用户上拉触底
// onReachBottom() {},
// 页面处理函数--监听页面滚动(not-nvue)
// onPageScroll(event) {},
// 页面处理函数--用户点击右上角分享
// onShareAppMessage(options) {},
};
</script>
<style lang="scss" scoped>
page {
background: white;
}
.landManagementForm {
background-color: white;
height: calc(100%);
.foot {
width: 100vw;
height: 44px;
bottom: 0px;
display: flex;
position: fixed;
z-index: 2;
.cencel {
border-radius: 0px;
border: 0px;
width: 50%;
background-color: white;
}
.confirm {
border-radius: 0px;
border: 0px;
width: 50%;
color: white;
}
}
}
.form {
text-align: center;
margin: auto;
width: 80%;
/deep/ .flex-radio {
uni-radio-group {
width: 100%;
.checklist-group {
display: flex;
justify-content: space-evenly;
}
}
}
/deep/ .uni-forms-item {
.uni-forms-item__content {
.uni-file-picker {
.uni-file-picker__header {
.file-title {
span {
color: #ff0000a6;
}
}
}
}
.uni-mt-5 {
.uni-icons {
background: #007aff21;
line-height: 35px;
height: 35px;
}
}
.uni-select-cy {
z-index: 1;
.uni-select-cy-select {
z-index: -500;
}
}
}
}
}
</style>