343 lines
10 KiB
Vue
343 lines
10 KiB
Vue
<template>
|
|
<div class="AddBuildingBox">
|
|
<PageHeader></PageHeader>
|
|
<div class="AddBuildingBody">
|
|
<div class="title">基本信息</div>
|
|
<div class="addBuildingFormBody">
|
|
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
|
|
<el-form-item label="账单名称" prop="billName">
|
|
<el-input v-model.trim="form.billName" placeholder="请输入账单名称" />
|
|
</el-form-item>
|
|
<el-form-item label="收费项目" prop="chargeItemId">
|
|
<el-select v-model="form.chargeItemId" @change="handleChange">
|
|
<el-option v-for="(item, index) in chargeitemlist" :key="index" :value="item.id" :label="item.itemName"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="收费范围" prop="chargeScope">
|
|
<el-radio-group v-model="form.chargeScope">
|
|
<el-radio v-for="(item, index) in com_bill_charge_scope_house" :key="index" :value="item.value" :label="item.label"></el-radio>
|
|
</el-radio-group>
|
|
<div @click="handleClearCheckout" v-if="form.chargeScope === '1'" class="ml-10px cursor-pointer color-red">清空</div>
|
|
</el-form-item>
|
|
<el-form-item v-if="form.chargeScope === '1'">
|
|
<div class="residentBox">
|
|
<ul class="checkoutSideUsesbox">
|
|
<li v-for="(item, index) in checkoutUses" :key="index">
|
|
<span>{{ item.buildingName }}/</span>
|
|
<span>{{ item.unitNo }}单元/</span>
|
|
<span>{{ item.floorNo }}楼/</span>
|
|
<span>{{ item.houseNo }}室</span>
|
|
<el-icon @click="delteUse(item.houseId)">
|
|
<Delete></Delete>
|
|
</el-icon>
|
|
</li>
|
|
<House returnvalue="*" ref="HolderRef" :isMultiple="true" :userid="form.houseIds.join(',')" @change="handleSelect">
|
|
<template #default>
|
|
<li @click="OpenUseTablesfun" class="add justify-center">
|
|
<el-icon>
|
|
<DocumentAdd></DocumentAdd>
|
|
</el-icon>
|
|
<span>添加房屋</span>
|
|
</li>
|
|
</template>
|
|
</House>
|
|
</ul>
|
|
</div>
|
|
</el-form-item>
|
|
<el-form-item label="费用周期" prop="chargePeriod">
|
|
<el-select v-model="form.chargePeriod">
|
|
<el-option v-for="(item, index) in com_bill_charge_period" :key="index" :value="item.value" :label="item.label"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="起止日期" prop="price">
|
|
<el-date-picker
|
|
v-model="StartEndDate"
|
|
@update:model-value="handleDate"
|
|
:value-format="datepicker[form.chargePeriod].format"
|
|
:format="datepicker[form.chargePeriod].format"
|
|
:type="datepicker[form.chargePeriod].type"
|
|
range-separator="到"
|
|
start-placeholder="开始"
|
|
end-placeholder="结束"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入" />
|
|
</el-form-item>
|
|
|
|
<el-form-item style="margin-top: 30px">
|
|
<el-button type="primary" @click="submitForm">提交</el-button>
|
|
<el-button @click="cancelForm">返回</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import House from '@/components/Holder/house.vue';
|
|
import PageHeader from '@/components/Pageheader/index.vue';
|
|
import { listChargeItem } from '@/api/system/SdbChargeItem';
|
|
import { getBill, updateBill, addBill, BillHouse, listBillHouse } from '@/api/system/SdbBill';
|
|
import type { DatePickerType } from 'element-plus';
|
|
import { formatDate, formatDate2 } from '@/utils';
|
|
import { Delete } from '@element-plus/icons-vue';
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
const { com_bill_charge_scope_house } = toRefs<any>(proxy?.useDict('com_bill_charge_scope_house'));
|
|
const { com_bill_charge_period } = toRefs<any>(proxy?.useDict('com_bill_charge_period'));
|
|
|
|
type PickerConfig = {
|
|
type: DatePickerType;
|
|
format: string;
|
|
};
|
|
const datepicker: Record<string, PickerConfig> = {
|
|
'0': { type: 'yearrange', format: 'YYYY' },
|
|
'1': { type: 'monthrange', format: 'YYYY-MM' },
|
|
'2': { type: 'daterange', format: 'YYYY-MM-DD' }
|
|
};
|
|
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
const formRef = ref();
|
|
const form = ref({
|
|
'id': null,
|
|
'billName': '',
|
|
'chargeItemId': '', // 收费项目
|
|
'chargeScope': '0', // 业主范围
|
|
'chargePeriod': '2', // 费用周期
|
|
houseIds: [], // 部分业主
|
|
charegeTypeId: '', // typeid
|
|
'startDate': '', // 开始
|
|
'endDate': '', // 结束
|
|
'remark': ''
|
|
});
|
|
const rules = ref({
|
|
billName: [{ required: true, message: '请输入 项目名称', trigger: 'blur' }],
|
|
chargeItemId: [{ required: true, message: '请选择 收费项目', trigger: 'blur' }],
|
|
chargePeriod: [{ required: true, message: '请选择 费用周期', trigger: 'blur' }],
|
|
startDate: [{ required: true, message: '请选择 起止日期', trigger: 'blur' }],
|
|
endDate: [{ required: true, message: '请选择 起止日期', trigger: 'blur' }]
|
|
});
|
|
const userid = ref(null);
|
|
|
|
// 开始结束日期
|
|
const StartEndDate = ref([]);
|
|
function handleDate(val: string[]) {
|
|
form.value.startDate = formatDate2(val[0]);
|
|
form.value.endDate = formatDate2(val[1]);
|
|
}
|
|
|
|
// 收费类型
|
|
const chargeitemlist = ref([]);
|
|
|
|
// 房屋列表
|
|
const houselist = ref([]);
|
|
async function init() {
|
|
listChargeItem().then((res) => {
|
|
chargeitemlist.value = res.rows;
|
|
});
|
|
|
|
const res = await listBillHouse({ pageNum: 1, pageSize: 999999 });
|
|
houselist.value = res.rows;
|
|
|
|
if (route.query.id) {
|
|
userid.value = route.query.id;
|
|
getBill(userid.value).then((res) => {
|
|
form.value = {
|
|
...form.value,
|
|
...res.data
|
|
};
|
|
form.value.houseIds = res.data.houseIds || [];
|
|
form.value.startDate = formatDate2(form.value.startDate);
|
|
form.value.endDate = formatDate2(form.value.endDate);
|
|
StartEndDate.value = [form.value.startDate, form.value.endDate];
|
|
|
|
checkoutUses.value = form.value.houseIds
|
|
.map((item) => {
|
|
if (item) {
|
|
const find = houselist.value.find((it) => it.houseId === item);
|
|
if (find) {
|
|
return find;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
})
|
|
.filter((item) => item !== null);
|
|
});
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
init();
|
|
});
|
|
|
|
// 获取收费类型id
|
|
function handleChange(val) {
|
|
const find = chargeitemlist.value.find((item) => item.id === val);
|
|
if (find) {
|
|
form.value.charegeTypeId = find.typeId;
|
|
}
|
|
}
|
|
// !== 业主 =============================================================================
|
|
|
|
// 打开
|
|
const HolderRef = ref<InstanceType<typeof House>>();
|
|
function OpenUseTablesfun() {
|
|
HolderRef.value.open();
|
|
}
|
|
// 多选
|
|
const checkoutUses = ref<BillHouse[]>([]);
|
|
function handleSelect(val: BillHouse[]) {
|
|
checkoutUses.value = val;
|
|
form.value.houseIds = checkoutUses.value.map((item) => item.houseId);
|
|
}
|
|
|
|
/** 删除房屋 */
|
|
function delteUse(id: string | number) {
|
|
checkoutUses.value = checkoutUses.value.filter((item) => item.houseId !== id);
|
|
}
|
|
|
|
/** 清空 */
|
|
function handleClearCheckout() {
|
|
checkoutUses.value = [];
|
|
form.value.houseIds = [];
|
|
}
|
|
// !== 业主 =============================================================================
|
|
|
|
// !== 提交 =============================================================================
|
|
const submitForm = () => {
|
|
formRef.value?.validate(async (valid: boolean) => {
|
|
if (valid) {
|
|
if (userid.value) {
|
|
updateBill(form.value).then((res) => {
|
|
ElMessage.success('编辑成功');
|
|
cancelForm();
|
|
});
|
|
} else {
|
|
addBill(form.value).then((res) => {
|
|
ElMessage.success('添加成功');
|
|
cancelForm();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
// 推出
|
|
const cancelForm = () => {
|
|
router.back();
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.AddBuildingBox {
|
|
padding: 15px;
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
.AddBuildingBody {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
background-color: white;
|
|
padding: 15px;
|
|
.title {
|
|
height: 40px;
|
|
line-height: 40px;
|
|
padding-left: 20px;
|
|
background-color: rgba(255, 255, 255, 1);
|
|
color: rgba(16, 16, 16, 1);
|
|
border-bottom: 1px solid #bbbbbb;
|
|
margin-bottom: 60px;
|
|
}
|
|
|
|
.formBody {
|
|
width: 950px;
|
|
margin: 0 auto;
|
|
|
|
.residentBox {
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
padding: 10px 5px;
|
|
}
|
|
.checkoutSideUsesbox {
|
|
// display: grid;
|
|
// grid-template-columns: repeat(3, 1fr);
|
|
// gap: 5px;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-content: flex-start;
|
|
justify-content: space-between;
|
|
padding: 10px 5px;
|
|
li {
|
|
margin-right: 10px;
|
|
margin-bottom: 10px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
|
|
min-width: 240px;
|
|
height: 35px;
|
|
padding: 0 10px;
|
|
line-height: 35px;
|
|
|
|
background-color: #f3f9ff;
|
|
border: 1px solid #8fc0f1;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
@media (max-width: 2000px) {
|
|
font-size: 12px;
|
|
}
|
|
@media (max-width: 1650px) {
|
|
font-size: 10px;
|
|
}
|
|
@media (max-width: 1650px) {
|
|
font-size: 8px;
|
|
}
|
|
.el-icon {
|
|
margin-left: 20px;
|
|
cursor: pointer;
|
|
&:hover {
|
|
color: red;
|
|
}
|
|
}
|
|
&.add {
|
|
cursor: pointer;
|
|
justify-content: center;
|
|
color: #409eff;
|
|
border: 1px dashed #409eff;
|
|
background-color: transparent;
|
|
&:hover {
|
|
background-color: #40a0ff10;
|
|
}
|
|
span {
|
|
margin-left: 10px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
&:deep(.el-form-item__content, .el-select, .el-input) {
|
|
width: 350px !important;
|
|
margin-right: 10px;
|
|
.el-cascader {
|
|
width: 100%;
|
|
}
|
|
}
|
|
.el-form-item {
|
|
margin-bottom: 20px;
|
|
align-items: center;
|
|
}
|
|
.el-button {
|
|
width: 80px;
|
|
height: 35px;
|
|
margin-right: 20px;
|
|
}
|
|
}
|
|
}
|
|
</style>
|