金五联管理系统PC前端
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.
jwl-manage-web/src/views/zs/clue/components/DistributeFormDialog.vue

114 lines
3.7 KiB

2 years ago
<template>
<el-dialog title="分发" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="600px" @close="closeDialog">
<el-form ref="dialogForm" :model="dialogForm" :rules="rules" label-width="110px">
<el-row>
<el-col :span="24">
2 years ago
<el-form-item label="场地" prop="placeId">
<el-select v-model="dialogForm.placeId" filterable placeholder="请选择" clearable style="width: 100%;">
2 years ago
<el-option v-for="dict in placeOptions" :key="dict.placeId" :label="dict.name" :value="dict.placeId" />
</el-select>
</el-form-item>
</el-col>
2 years ago
<el-col :span="24">
<el-form-item label="教练" prop="coachId">
<el-select v-model="dialogForm.coachId" filterable placeholder="请选择" clearable style="width: 100%;">
<el-option v-for="dict in coachOptions" :key="dict.coachId" :label="dict.coachName" :value="dict.coachId" />
</el-select>
</el-form-item>
</el-col>
2 years ago
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button plain @click="(visible = false)">取消</el-button>
<el-button v-jclick type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
2 years ago
<script>
2 years ago
import { getCluePlaceList, saveCluePlace } from '@/api/zs/clue';
import { getAllPlaces } from '@/api/sch/place';
export default {
name: 'DistributeFormDialog',
2 years ago
data () {
2 years ago
return {
visible: false,
canSubmit: true,
dialogForm: {},
oldForm: {},
rules: {
2 years ago
placeId: { required: true, message: '场地不能为空', trigger: 'blur, change' },
coachId: { required: true, message: '教练不能为空', trigger: 'blur, change' }
2 years ago
},
placeOptions: []
};
},
methods: {
2 years ago
init (info = undefined) {
this.getPlaces();
2 years ago
this.visible = true;
this.$nextTick(() => {
this.resetDialogForm();
this.$refs['dialogForm'].resetFields();
if (info) {
this.dialogForm.clueId = info;
2 years ago
// 查询该线索的分发情况
2 years ago
this.getDistributePlaces(info);
}
});
},
2 years ago
resetDialogForm () {
2 years ago
this.dialogForm = {
2 years ago
placeId: undefined,
clueId: undefined,
coachId: undefined
2 years ago
};
2 years ago
this.oldForm = {};
2 years ago
},
2 years ago
closeDialog () {
2 years ago
this.$emit('update:dialog.batchUpdateVisible', false);
},
2 years ago
getDistributePlaces (clueId) {
2 years ago
getCluePlaceList({ clueId: clueId }).then(resp => {
if (resp.code == 200) {
2 years ago
this.oldForm = resp.data;
2 years ago
this.dialogForm.oldPlaceList = this.oldForm.placeIdList;
if (this.oldForm.placeIdList && this.oldForm.placeIdList) {
2 years ago
this.placeOptions = this.placeOptions.filter(item => this.oldForm.placeIdList.indexOf(item.placeId) == -1);
2 years ago
}
}
2 years ago
});
2 years ago
},
// 表单提交
2 years ago
dialogFormSubmit () {
2 years ago
this.$refs.dialogForm.validate((valid) => {
if (valid) {
this.canSubmit = false;
2 years ago
this.dialogForm.placeIdList = this.dialogForm.oldPlaceList.concat(this.dialogForm.newPlaceList);
2 years ago
// 校验完成,调接口
saveCluePlace(this.dialogForm)
.then((resp) => {
this.canSubmit = true;
if (resp.code == 200) {
this.$message.success('分发成功');
this.$emit('refreshDataList');
this.visible = false;
}
})
.catch(() => {
this.canSubmit = true;
});
}
});
},
2 years ago
getPlaces () {
2 years ago
getAllPlaces({ status: '0' }).then((resp) => {
this.placeOptions = resp.data;
});
2 years ago
}
2 years ago
}
};
2 years ago
</script>