|
@@ -1,6 +1,22 @@
|
|
|
<template>
|
|
|
- <el-form ref="form" label-width="120px">
|
|
|
- <el-form-item label="选择收费项目" :required="true">
|
|
|
+ <el-form ref="form" :model="formData" label-width="120px" :rules="formRules">
|
|
|
+ <el-form-item label="所属社区" prop="communityId">
|
|
|
+ <el-select v-model="formData.communityId" placeholder="请选择所属社区" clearable @change="communityChange">
|
|
|
+ <el-option v-for="(item, index) in communityArr" :key="index" :label="item.name" :value="item.id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="选择房屋" prop="communityTreeIds">
|
|
|
+ <el-cascader
|
|
|
+ :options="communityTreeArr"
|
|
|
+ v-model="formData.communityTreeIds"
|
|
|
+ :props="defaultProps"
|
|
|
+ collapse-tags
|
|
|
+ ref="communityTreeArr"
|
|
|
+ @change="findTreeIds"
|
|
|
+ clearable
|
|
|
+ ></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="选择收费项目" prop="strategyIds">
|
|
|
<div class="contentScorll">
|
|
|
<div class="all">
|
|
|
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全部设置</el-checkbox>
|
|
@@ -10,6 +26,7 @@
|
|
|
<el-checkbox-group v-model="formData.strategyIds" @change="handleCheckedCitiesChange">
|
|
|
<el-checkbox v-for="item in list" :label="item.id" :key="item">{{ item.chargeName }}</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
+ <div v-if="list.length == 0" style="line-height: 150px; text-align: center; opacity: 0.5">社区暂无收费项目</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
@@ -25,8 +42,44 @@ export default {
|
|
|
checkAll: false,
|
|
|
isIndeterminate: false,
|
|
|
formData: {
|
|
|
- strategyIds: []
|
|
|
- }
|
|
|
+ strategyIds: [],
|
|
|
+ communityId: '',
|
|
|
+ communityTreeIds: []
|
|
|
+ },
|
|
|
+ defaultProps: {
|
|
|
+ multiple: true,
|
|
|
+ // emitPath: false,
|
|
|
+ value: 'value', // 唯一标识
|
|
|
+ label: 'name', // 标签显示
|
|
|
+ children: 'children' // 子级
|
|
|
+ },
|
|
|
+ formRules: {
|
|
|
+ communityId: [this.$valid.selectRequired('社区')],
|
|
|
+ communityTreeIds: this.$valid.custome({
|
|
|
+ validator(rule, value, cb) {
|
|
|
+ const rl = rule;
|
|
|
+ if (value.length == 0) {
|
|
|
+ rl.message = '请选择房间';
|
|
|
+ cb(new Error());
|
|
|
+ } else {
|
|
|
+ cb();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ strategyIds: this.$valid.custome({
|
|
|
+ validator(rule, value, cb) {
|
|
|
+ const rl = rule;
|
|
|
+ if (value.length == 0) {
|
|
|
+ rl.message = '请选择收费项目';
|
|
|
+ cb(new Error());
|
|
|
+ } else {
|
|
|
+ cb();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ communityArr: [],
|
|
|
+ communityTreeArr: []
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -47,36 +100,77 @@ export default {
|
|
|
this.isIndeterminate = false;
|
|
|
},
|
|
|
submit() {
|
|
|
- if (!this.formData.strategyIds.length) {
|
|
|
- this.$message.error('选择收费项目');
|
|
|
- return;
|
|
|
- }
|
|
|
- var loading = this.$loading();
|
|
|
+ let assetItemArr = [];
|
|
|
+ let thisArr = this.$refs.communityTreeArr.getCheckedNodes();
|
|
|
+ thisArr.map((item) => {
|
|
|
+ if (item.level == 2) {
|
|
|
+ assetItemArr.push({
|
|
|
+ address: `${item.parent.label}-${item.label}`,
|
|
|
+ value: item.value,
|
|
|
+ type: 4
|
|
|
+ });
|
|
|
+ } else if (item.level == 3) {
|
|
|
+ assetItemArr.push({
|
|
|
+ address: `${item.parent.parent.label}-${item.parent.label}-${item.label}`,
|
|
|
+ value: item.value,
|
|
|
+ type: 4
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let installData = {
|
|
|
+ strategyIds: this.formData.strategyIds,
|
|
|
+ assetItem: assetItemArr
|
|
|
+ };
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var loading = this.$loading();
|
|
|
+ this.$http
|
|
|
+ .post('/sc-charge/scChargeStrategyConfig/add', installData)
|
|
|
+ .then(({ status, msg }) => {
|
|
|
+ if (status == 0) {
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.params.callback();
|
|
|
+ this.$emit('close');
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ loading.close();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getList(id) {
|
|
|
+ this.$http.get('/sc-charge/scChargeStrategy/list?communityId=' + id).then(({ data, status, msg }) => {
|
|
|
+ this.list = data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getorgTree() {
|
|
|
this.$http
|
|
|
- .post('/sc-charge/scChargeStrategyConfig/add', this.formData)
|
|
|
- .then(({ status, msg }) => {
|
|
|
- if (status == 0) {
|
|
|
- this.$message.success(msg);
|
|
|
- this.params.callback();
|
|
|
- this.$emit('close');
|
|
|
- } else {
|
|
|
- this.$message.error(msg);
|
|
|
- }
|
|
|
- loading.close();
|
|
|
+ .get('/sc-community/assets/tree/community/find')
|
|
|
+ .then((data) => {
|
|
|
+ this.communityArr = data.data;
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
- loading.close();
|
|
|
- });
|
|
|
+
|
|
|
+ .catch(function () {});
|
|
|
},
|
|
|
- getList() {
|
|
|
- this.$http.get('/sc-charge/scChargeStrategy/list?communityId=' + this.params.communityId).then(({ data, status, msg }) => {
|
|
|
- this.list = data;
|
|
|
+ findTreeIds(va) {
|
|
|
+ console.log(va);
|
|
|
+ },
|
|
|
+ communityChange(val) {
|
|
|
+ this.communityArr.map((item) => {
|
|
|
+ if (item.id == val) {
|
|
|
+ this.communityTreeArr = item.children;
|
|
|
+ }
|
|
|
});
|
|
|
+ this.getList(val);
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- Object.assign(this.formData, this.params.data);
|
|
|
- this.getList();
|
|
|
+ this.getorgTree();
|
|
|
+ // Object.assign(this.formData, this.params.data);
|
|
|
}
|
|
|
};
|
|
|
</script>
|