You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

686 lines
21 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script>
import { save, show, index, destroy, imports } from "@/api/system/baseForm";
import { CreateDialog } from "@/utils/createDialog";
import { deepCopy } from "@/utils";
import { resolveFormInfo } from "@/utils/createTable";
import { show as customFormFieldShow } from '@/api/system/customFormField'
export default {
components: {},
props: {
tableName: String,
},
render(h) {
const _this = this;
let dialog = new CreateDialog(
this,
[
{
show: true,
key: "qiandingnianyue",
label: "签订年月",
render: h("el-date-picker", {
style: { width: "100%" },
props: {
type: "month",
placeholder: "请选择签订年月",
value: _this.originalForm.qiandingnianyue,
format: "yyyy-MM",
valueFormat: "yyyy-MM",
},
on: {
["input"]: (e) => {
_this.form.qiandingnianyue = e;
_this.form = Object.assign({}, _this.form);
},
},
}),
}
],
{
disabled: true,
notUseRules: true
},
false
);
let oldDialog = new CreateDialog(
this,
[
{
show: true,
key: "qiandingnianyue",
label: "签订年月",
render: h("el-date-picker", {
style: { width: "100%" },
props: {
type: "month",
placeholder: "请选择签订年月",
value: _this.oldLease.qiandingnianyue,
format: "yyyy-MM",
valueFormat: "yyyy-MM",
}
}),
},
{
key: "biangengshijian",
show: false
}
],
{
disabled: true,
fromData: "oldLease",
fromFile: "oldFile",
formRef: "oldElForm"
},
false
);
return (
<div style="padding: 10px 20px;">
<el-card shadow="never" body-style={{'padding': '10px'}}>
<el-page-header content="合同变更记录" on={{['back']: _ => {this.$router.go(-1)}}}></el-page-header>
</el-card>
<el-row gutter={10}>
<el-col
span={12}
>
<el-card style="margin-top: 20px;">
<div slot="header" style="display: flex;align-items: center;">
<i
className="el-icon-back"
style="padding-right: 20px;font-size: 20px;font-weight: 600;cursor: pointer;"
on={{
["click"]: (_) => {
this.$router.go(-1);
},
}}
></i>
<p>变更后数据</p>
</div>
{/* 资产信息 */}
<div style="margin-bottom: 10px;">
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<p style="font-weight: 700;line-height: 2;">资产信息</p>
</div>
<xy-table
row-style={({ row }) => {
if (!this.originalForm.id_hisleases_to_assets_hislease_id_relation?.find(j => ((j.land_id === row.land_id && row.land_id) || (j.house_id === row.house_id && row.house_id)))) {
return { 'background': 'rgba(0,255,0,0.06)' }
}
}}
list={this.oldLease.id_leases_to_assets_lease_id_relation}
height="300"
isHandlerKey={false}
is-page={false}
table-item={[
{
prop: "name",
label: "资产名称",
width: 0,
fixed: "left",
align: "left",
customFn: row => (
<span>
{
row.land_id ? (
this.oldLease.land.find(i => i.id === row.land_id)?.name
) : (
this.oldLease.houses.find(i => i.id === row.house_id)?.name
)
}
</span>
)
},
{
prop: "type",
label: "分类",
"fixed": "left",
customFn: row => (
<span>{ row.land_id ? '土地' : '房产' }</span>
)
},
{
prop: "zuoluo",
label: "坐落",
width: 0,
align: "left",
customFn: row => (
<span>
{
row.land_id ? (
this.oldLease.land.find(i => i.id === row.land_id)?.zuoluo
) : (
this.oldLease.houses.find(i => i.id === row.house_id)?.zuoluo
)
}
</span>
)
},
{
prop: "shijimianji",
label: "实际面积",
width: 0,
align: "center",
customFn: row => (
<span>
{
row.land_id ? (
this.oldLease.land.find(i => i.id === row.land_id)?.shijimianji
) : (
this.oldLease.houses.find(i => i.id === row.house_id)?.shijimianji
)
}
</span>
)
},
{
prop: "chuzumianji",
label: "出租面积",
width: 160,
customFn: row => (
<span style={{
color: (() => {
return row.chuzumianji === this.originalForm?.id_hisleases_to_assets_hislease_id_relation?.find(j => (j.land_id === row.land_id) || (j.house_id === row.house_id))?.chuzumianji ? '' : 'red'
})()
}}>{ row.chuzumianji }</span>
)
},
]}
></xy-table>
</div>
{/* 租金收取计划 */}
<div style="margin-bottom: 10px;">
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<p style="font-weight: 700;line-height: 2;">
租金收取计划
</p>
</div>
<div style="display: grid;grid-gap: 10px;grid-template-columns: repeat(3, 1fr);">
{this.oldLease?.id_lease_plans_lease_id_relation?.map((leasePlan, index) => (
<Card padding={10}>
<div
slot="title"
style="display: flex;align-items: center;height: 100%;"
>
<p style="font-size: 14px;">
租金收取计划{index + 1}
</p>
</div>
<div>
<el-form
disabled={true}
ref={"leasePlan" + index}
size="mini"
label-position="top"
props={{
model: leasePlan,
}}
>
<el-form-item label="租金到位时间">
<el-date-picker
style="width: 100%;"
value-format="yyyy-MM-dd"
vModel={leasePlan.zujindiyicidaoweishijian}
></el-date-picker>
</el-form-item>
<el-form-item label="应收租金">
<el-input-number
controls={false}
precision={2}
style="width: 100%"
vModel={leasePlan.yingshou}
></el-input-number>
</el-form-item>
</el-form>
</div>
</Card>
))}
</div>
</div>
{oldDialog.render()}
</el-card>
</el-col>
<el-col
span={12}
>
<el-card style="margin-top: 20px;">
<div slot="header" style="display: flex;align-items: center;">
<p>
变更前数据
</p>
</div>
{/* 资产信息 */}
<div style="margin-bottom: 10px;">
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<p style="font-weight: 700;line-height: 2;">资产信息</p>
</div>
<xy-table
list={this.originalForm.id_hisleases_to_assets_hislease_id_relation}
row-style={({ row }) => {
return this.oldLease.id_leases_to_assets_lease_id_relation?.find(j => ((j.land_id === row.land_id) || (j.house_id === row.house_id))) ? '' : { 'background': 'rgba(255,0,0,0.06)' }
}}
height="300"
isHandlerKey={false}
is-page={false}
table-item={[
{
prop: "name",
label: "资产名称",
width: 0,
fixed: "left",
align: "left",
customFn: row => (
<span>
{
row.land_id ? (
this.originalForm?.land?.find(i => i.id === row.land_id)?.name
) : (
this.originalForm?.houses?.find(i => i.id === row.house_id)?.name
)
}
</span>
)
},
{
prop: "type",
label: "分类",
"fixed": "left",
customFn: row => (
<span>{ row.land_id ? '土地' : '房产' }</span>
)
},
{
prop: "zuoluo",
label: "坐落",
width: 0,
align: "left",
customFn: row => (
<span>
{
row.land_id ? (
this.originalForm?.land?.find(i => i.id === row.land_id)?.zuoluo
) : (
this.originalForm?.houses?.find(i => i.id === row.house_id)?.zuoluo
)
}
</span>
)
},
{
prop: "shijimianji",
label: "实际面积",
width: 0,
align: "center",
customFn: row => (
<span>
{
row.land_id ? (
this.originalForm?.land?.find(i => i.id === row.land_id)?.shijimianji
) : (
this.originalForm?.houses?.find(i => i.id === row.house_id)?.shijimianji
)
}
</span>
)
},
{
prop: "chuzumianji",
label: "出租面积",
width: 160,
},
]}
></xy-table>
</div>
{/* 租金收取计划 */}
<div style="margin-bottom: 10px;">
<div style="display: flex;margin-bottom: 10px;align-items: center;">
<p style="font-weight: 700;line-height: 2;">租金收取计划</p>
</div>
<div style="display: grid;grid-gap: 10px;grid-template-columns: repeat(3, 1fr);">
{this.originalForm?.id_hislease_plans_hislease_id_relation?.map((leasePlan, index) => (
<Card padding={10}>
<div
slot="title"
style="display: flex;align-items: center;"
>
<p style="font-size: 14px;">租金收取计划{index + 1}</p>
</div>
<div>
<el-form
ref={"leasePlan" + index}
size="mini"
label-position="top"
props={{
model: leasePlan,
}}
>
<el-form-item label="租金到位时间">
<el-date-picker
style="width: 100%;"
value-format="yyyy-MM-dd"
disabled={true}
vModel={leasePlan.zujindiyicidaoweishijian}
></el-date-picker>
</el-form-item>
<el-form-item label="应收租金">
<el-input-number
controls={false}
precision={2}
disabled={true}
style="width: 100%"
vModel={leasePlan.yingshou}
></el-input-number>
</el-form-item>
</el-form>
</div>
</Card>
))}
</div>
</div>
{dialog.render()}
</el-card>
</el-col>
</el-row>
</div>
);
},
data() {
return {
wxAreas: new Map(),
isShowOldData: true,
nowAssets: [],
oldNowAssets: [],
houseDialog: false,
landDialog: false,
leasePlans: [],
oldLeasePlans: [],
landSelect: {
table_name: "lands",
keyword: "",
},
houseSelect: {
table_name: "houses",
keyword: "",
},
customForm: {
customFormId: "",
tableName: "",
},
columns: 1,
row: {},
formInfo: [],
id: "",
type: "add",
form: {},
originalForm: {},
oldLease: {},
oldFile: {},
rules: {},
file: {},
};
},
methods: {
async getWxAreas () {
try {
const res = await customFormFieldShow({ id: 120 })
let keys = Object.keys(res.select_item)
if (keys.length > 0) {
this.wxAreas = new Map(keys.map((key) => {
return [
/^\d*$/.test(res.select_item[key])
? Number(res.select_item[key])
: res.select_item[key],
key
]
}))
}
} catch (err) {
}
},
getCustomForm () {
if (this.$route.meta.params?.custom_form) {
let decode = decodeURIComponent(this.$route.meta.params?.custom_form);
try {
let custom_form = JSON.parse(decode);
this.customForm.customFormId = custom_form.custom_form_id;
this.customForm.tableName = custom_form.table_name;
} catch (err) {
console.warn(err);
}
}
},
index,
setRow(row) {
this.row = row;
},
init() {
for (let key in this.form) {
if (this.form[key] instanceof Array) {
this.form[key] = [];
} else {
this.form[key] = "";
}
}
this.$refs["elForm"].clearValidate();
},
setType(type = "add") {
let types = ["add", "editor", "change"];
if (types.includes(type)) {
this.type = type;
} else {
console.warn("Unknown type: " + type);
}
},
setId(id) {
if (typeof id == "number") {
this.id = id;
} else {
console.error("error typeof id: " + typeof id);
}
},
async getDetail() {
const res = await show({ id: this.id, table_name: "leases_histories" });
this.$integrateData(this.form, res);
this.formInfo.forEach((i) => {
if (i.edit_input === "file") {
}
if (i.edit_input === "files") {
this.file[i.field] = res[`${i.field}_upload_details`];
}
});
this.form = Object.assign({}, this.form);
this.originalForm = deepCopy(res);
if (res.original_lease_id) {
const oldLease = await show({
id: res.original_lease_id,
table_name: "leases"
})
this.oldLease = oldLease;
this.formInfo.forEach((i) => {
if (i.edit_input === "file") {
}
if (i.edit_input === "files") {
this.oldFile[i.field] = oldLease[`${i.field}_upload_details`];
}
});
}
},
},
computed: {},
watch: {
oldLease: {
handler: function (newVal) {
this.formInfo.forEach((i) => {
if (i.field) {
this.rules[i.field] = [
{
validator: (rule, value, callback) => {
if (i.edit_input === 'file' || i.edit_input === 'files') {
if (this.oldLease[i.field].toString() === this.originalForm[i.field].toString()) {
callback()
} else {
callback(new Error('数据变更'))
}
} else {
if (this.oldLease[i.field] === this.originalForm[i.field]) {
callback()
} else {
callback(new Error('数据变更'))
}
}
}
}
];
}
})
this.$nextTick(() => {
this.$refs['oldElForm'].validate()
})
}
},
formInfo: {
handler: function (newVal) {
this.form = {};
this.rules = {};
this.file = {};
newVal.forEach((i) => {
if (i.field) {
this.form[i.field] = "";
if (i.edit_input === "files") {
this.form[i.field] = [];
}
if (i.edit_input === "files" || i.edit_input === "file") {
this.file[i.field] = [];
}
if (i.edit_input === "checkbox") {
this.form[i.field] = [];
}
if (i._relations) {
this.form[i._relations?.link_with_name] = [];
}
}
});
},
//immediate: true,
},
dialogVisible(val) {
if (val) {
if (this.type === "editor" || this.type === "change") {
this.$nextTick(() => this.getDetail());
}
} else {
this.id = "";
this.type = "";
this.init();
this.$refs["elForm"].clearValidate();
delete this.form.id;
for (let key in this.file) {
this.file[key] = [];
}
this.$refs["landLinkTable"].clearSelection();
this.$refs["houseLinkTable"].clearSelection();
}
},
},
created() {
this.getWxAreas()
this.id = this.$route.params.id;
this.getCustomForm();
resolveFormInfo(this.customForm.customFormId).then((res) => {
this.formInfo = res;
this.$nextTick(() => this.getDetail());
});
},
mounted() {},
beforeDestroy() {
this.id = "";
this.type = "";
this.init();
this.$refs["elForm"].clearValidate();
delete this.form.id;
for (let key in this.file) {
this.file[key] = [];
}
},
};
</script>
<style>
:root {
--column-num: 2;
}
</style>
<style scoped lang="scss">
::v-deep .ivu-card-head {
padding: 10px 12px;
height: 49px;
}
.uploaded-a {
color: $primaryColor;
text-decoration: none;
transition: all 0.2s;
}
.uploaded-a:hover {
color: $primaryColor;
text-decoration: underline;
}
.form-body {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(2, 1fr);
}
::v-deep .el-input-number input {
text-align: right;
}
.show-old-data-btn {
cursor: pointer;
filter: drop-shadow(2px 4px 6px #0005);
border-radius: 6px 0 0 6px;
padding: 12px 4px;
z-index: 10;
writing-mode: vertical-rl;
color: #fff;
position: fixed;
top: 50%;
right: 0;
transform: translateY(-50%);
background: rgb(53, 122, 199);
transition: all .3s;
&:hover {
transform: translateY(-50%) scale(1.05,1.05);
}
}
::v-deep .el-form-item__error {
transform: none;
left: 0 !important;
}
::v-deep .is-error .el-form-item__content > div:nth-child(1) {
filter: drop-shadow(0 0 4px red);
}
</style>