This commit is contained in:
zoujiandong 2024-06-13 17:21:23 +08:00
parent 20db6f0d48
commit 3f8c0900a6
2 changed files with 135 additions and 110 deletions

View File

@ -12,7 +12,12 @@
<div class="bar"></div> <div class="bar"></div>
<div class="name">基本信息</div> <div class="name">基本信息</div>
</div> </div>
<a-form :model="modalForm" ref="modalFormRef" :auto-label-width="true" :rules="rules"> <a-form
:model="modalForm"
ref="modalFormRef"
:auto-label-width="true"
:rules="rules"
>
<a-row :gutter="24" style="margin-top: 35px"> <a-row :gutter="24" style="margin-top: 35px">
<a-col :span="12"> <a-col :span="12">
<a-form-item field="hospital_name" label="医院名称:"> <a-form-item field="hospital_name" label="医院名称:">
@ -41,7 +46,6 @@
> >
</a-select> </a-select>
<a-select <a-select
v-model="modalForm.city_id" v-model="modalForm.city_id"
placeholder="请选择城市" placeholder="请选择城市"
@ -69,10 +73,8 @@
>{{ item.area_name }}</a-option >{{ item.area_name }}</a-option
> >
</a-select> </a-select>
</div> </div>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
@ -87,7 +89,11 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item field="hospital_level_name" label="医院等级:"> <a-form-item field="hospital_level_name" label="医院等级:">
<a-select v-model="modalForm.hospital_level_name" placeholder="请选择药品类型" :style="{ width: '182px' }"> <a-select
v-model="modalForm.hospital_level_name"
placeholder="请选择药品类型"
:style="{ width: '182px' }"
>
<a-option value="一级">一级</a-option> <a-option value="一级">一级</a-option>
<a-option value="二级">二级</a-option> <a-option value="二级">二级</a-option>
<a-option value="三级">三级</a-option> <a-option value="三级">三级</a-option>
@ -96,7 +102,6 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
@ -121,13 +126,15 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="12"> <a-col :span="12">
<a-form-item field="desc" label="描述:"> <a-form-item field="desc" label="描述:">
<a-textarea v-model="modalForm.desc " :auto-size="{ <a-textarea
v-model="modalForm.desc"
:auto-size="{
minRows: 2, minRows: 2,
maxRows:5 maxRows: 5,
}" /> }"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-divider /> <a-divider />
</a-form> </a-form>
@ -135,11 +142,16 @@
<div class="bar"></div> <div class="bar"></div>
<div class="name">操作</div> <div class="name">操作</div>
</div> </div>
<a-row :gutter="24" style="margin-top: 35px;" > <a-row :gutter="24" style="margin-top: 35px">
<a-col :span="24"> <a-col :span="24">
<a-form-item field="" label="" no-style> <a-form-item field="" label="" no-style>
<a-space> <a-space>
<a-button type="primary" @click="handleSubmit" v-has="'admin:sysHospitalList:save'">保存</a-button> <a-button
type="primary"
@click="handleSubmit"
v-has="'admin:sysHospitalList:save'"
>保存</a-button
>
</a-space> </a-space>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -182,11 +194,9 @@ const handelAreaList = (area_id = '', parent_id = '', area_type) => {
if (code == 200) { if (code == 200) {
if (area_type == 2) { if (area_type == 2) {
provinceData.value = data; provinceData.value = data;
} }
if (area_type == 3) { if (area_type == 3) {
cityData.value = data; cityData.value = data;
} }
if (area_type == 4) { if (area_type == 4) {
countryData.value = data; countryData.value = data;
@ -205,15 +215,17 @@ const changeCity = (value) => {
modalForm.county_id = ''; modalForm.county_id = '';
handelAreaList('', value, 4); handelAreaList('', value, 4);
}; };
watch(()=>props.id,()=>{ watch(
() => props.id,
() => {
if (props.id) { if (props.id) {
title.value="编辑医院" title.value = '编辑医院';
} else { } else {
title.value="修改医院" title.value = '修改医院';
} }
},
},{immediate:true}) { immediate: true }
);
const rules = { const rules = {
hospital_name: [{ required: true, message: '请输入医院名称' }], hospital_name: [{ required: true, message: '请输入医院名称' }],
@ -224,7 +236,18 @@ const rules = {
const handleSubmit = () => { const handleSubmit = () => {
proxy.$refs.modalFormRef.validate(async (valid) => { proxy.$refs.modalFormRef.validate(async (valid) => {
let data = null; let data = null;
let {hospital_name,hospital_status,hospital_level_name,post_code,tele_phone,province_id,city_id,county_id,address,desc}=modalForm.value; let {
hospital_name,
hospital_status,
hospital_level_name,
post_code,
tele_phone,
province_id,
city_id,
county_id,
address,
desc,
} = modalForm.value;
if (!valid) { if (!valid) {
if (props.id) { if (props.id) {
data = await updateHospital(props.id, { data = await updateHospital(props.id, {
@ -237,8 +260,8 @@ const rules = {
city_id, city_id,
county_id, county_id,
address, address,
desc desc,
}) });
} else { } else {
data = await addHospital({ data = await addHospital({
hospital_name, hospital_name,
@ -250,18 +273,19 @@ const rules = {
city_id, city_id,
county_id, county_id,
address, address,
desc desc,
}); });
} }
if (data.code == 200) { if (data.code == 200) {
props.id?proxy.$message.success('修改成功'):proxy.$message.success('添加成功'); props.id
? proxy.$message.success('修改成功')
: proxy.$message.success('添加成功');
emits('freshDetail'); emits('freshDetail');
} }
handleClose(); handleClose();
emits('freshDetail'); emits('freshDetail');
} else { } else {
console.log(valid) console.log(valid);
proxy.$message.error('表单校验失败'); proxy.$message.error('表单校验失败');
//done(false); //done(false);
} }
@ -276,10 +300,8 @@ const handleClose = () => {
const getData = (flag = false) => { const getData = (flag = false) => {
handelAreaList('', '', 2); handelAreaList('', '', 2);
if (flag) { if (flag) {
handelAreaList('',modalForm.value.province_id handelAreaList('', modalForm.value.province_id, 3);
,3) handelAreaList('', modalForm.value.city_id, 4);
handelAreaList('',modalForm.value.city_id
,4)
} }
}; };
defineExpose({ defineExpose({

View File

@ -116,6 +116,7 @@ const handleNodeClick = (data) => {
current.parent_id=data.parent_id; current.parent_id=data.parent_id;
current.level=data.level; current.level=data.level;
form.area_name=''; form.area_name='';
form.area_id='';
// console.log(data) // console.log(data)
// const newChild = { id: id++, label: 'testtest', children: [] }; // const newChild = { id: id++, label: 'testtest', children: [] };
// tree.value.append(newChild,data.id) // tree.value.append(newChild,data.id)
@ -192,9 +193,11 @@ const handleNodeClick = (data) => {
let {code,data}= title.value=="添加区域"?await addArea({ let {code,data}= title.value=="添加区域"?await addArea({
area_name:form.area_name, area_name:form.area_name,
parent_id:form.parent_id, parent_id:form.parent_id,
area_id:form.area_id,
area_type:type area_type:type
}):await updateArea(form.parent_id,{ }):await updateArea(form.parent_id,{
area_name:form.area_name area_name:form.area_name,
area_id:form.area_id,
}) })
if(code==200){ if(code==200){
if(title.value=="添加区域"){ if(title.value=="添加区域"){