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="医院名称:">
@ -24,12 +29,12 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item field="county_id" label="选择省市区:"> <a-form-item field="county_id" label="选择省市区:">
<div class="row"> <div class="row">
<a-select <a-select
v-model="modalForm.province_id" v-model="modalForm.province_id"
placeholder="请选择省份" placeholder="请选择省份"
:style="{ width: '162px',marginRight:'10px' }" :style="{ width: '162px', marginRight: '10px' }"
@change="changeProvice" @change="changeProvice"
> >
<a-option <a-option
@ -40,12 +45,11 @@
>{{ item.area_name }}</a-option >{{ item.area_name }}</a-option
> >
</a-select> </a-select>
<a-select <a-select
v-model="modalForm.city_id" v-model="modalForm.city_id"
placeholder="请选择城市" placeholder="请选择城市"
:style="{ width: '162px',marginRight:'10px' }" :style="{ width: '162px', marginRight: '10px' }"
@change="changeCity" @change="changeCity"
> >
<a-option <a-option
@ -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,16 +89,19 @@
</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
<a-option value="一级">一级</a-option> v-model="modalForm.hospital_level_name"
<a-option value="二级">二级</a-option> placeholder="请选择药品类型"
<a-option value="三级">三级</a-option> :style="{ width: '182px' }"
<a-option value="三甲">三甲</a-option> >
<a-option value="其他">其他</a-option> <a-option value="一级">一级</a-option>
</a-select> <a-option value="二级">二级</a-option>
<a-option value="三级">三级</a-option>
<a-option value="三甲">三甲</a-option>
<a-option value="其他">其他</a-option>
</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,34 +126,41 @@
<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
minRows:2, v-model="modalForm.desc"
maxRows:5 :auto-size="{
}" /> minRows: 2,
maxRows: 5,
}"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-divider /> <a-divider />
</a-form> </a-form>
<div class="titlebox" > <div class="titlebox">
<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
</a-space> type="primary"
</a-form-item> @click="handleSubmit"
</a-col> v-has="'admin:sysHospitalList:save'"
</a-row> >保存</a-button
>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-modal> </a-modal>
</template> </template>
<script setup> <script setup>
import { ref, toRefs,watch,getCurrentInstance} from 'vue'; import { ref, toRefs, watch, getCurrentInstance } from 'vue';
import { getAreaList,addHospital,updateHospital } from '@/api/basic/list'; import { getAreaList, addHospital, updateHospital } from '@/api/basic/list';
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const props = defineProps({ const props = defineProps({
// //
@ -156,7 +168,7 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
id:{ id: {
type: String, type: String,
default: '', default: '',
}, },
@ -164,8 +176,8 @@ const props = defineProps({
type: Object, type: Object,
}, },
}); });
const title=ref(''); const title = ref('');
const emits = defineEmits(['familyVisibleChange','freshDetail']); const emits = defineEmits(['familyVisibleChange', 'freshDetail']);
const { modalVisible, modalForm } = toRefs(props); const { modalVisible, modalForm } = toRefs(props);
const provinceData = ref([]); const provinceData = ref([]);
const cityData = ref([]); const cityData = ref([]);
@ -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,81 +215,93 @@ const changeCity = (value) => {
modalForm.county_id = ''; modalForm.county_id = '';
handelAreaList('', value, 4); handelAreaList('', value, 4);
}; };
watch(()=>props.id,()=>{ watch(
if(props.id){ () => props.id,
title.value="编辑医院" () => {
}else{ if (props.id) {
title.value="修改医院" title.value = '编辑医院';
} } else {
title.value = '修改医院';
},{immediate:true}) }
},
{ immediate: true }
);
const rules = { const rules = {
hospital_name: [{ required: true, message: '请输入医院名称' }], hospital_name: [{ required: true, message: '请输入医院名称' }],
county_id:[{ required: true, message: '请选择省市区' }], county_id: [{ required: true, message: '请选择省市区' }],
hospital_level_name:[{ required: true, message: '请选择医院等级' }], hospital_level_name: [{ required: true, message: '请选择医院等级' }],
address:[{ required: true, message: '请输入详细地址' }], address: [{ required: true, message: '请输入详细地址' }],
}; };
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 {
if (!valid) { hospital_name,
if(props.id){ hospital_status,
data= await updateHospital(props.id,{ hospital_level_name,
hospital_name, post_code,
hospital_status, tele_phone,
hospital_level_name, province_id,
post_code, city_id,
tele_phone, county_id,
province_id, address,
city_id, desc,
county_id, } = modalForm.value;
address, if (!valid) {
desc if (props.id) {
}) data = await updateHospital(props.id, {
}else{ hospital_name,
data= await addHospital({ hospital_status,
hospital_name, hospital_level_name,
hospital_status, post_code,
hospital_level_name, tele_phone,
post_code, province_id,
tele_phone, city_id,
province_id, county_id,
city_id, address,
county_id, desc,
address, });
desc } else {
}); data = await addHospital({
} hospital_name,
if(data.code==200){ hospital_status,
props.id?proxy.$message.success('修改成功'):proxy.$message.success('添加成功'); hospital_level_name,
emits('freshDetail'); post_code,
} tele_phone,
handleClose(); province_id,
emits('freshDetail'); city_id,
county_id,
}else { address,
console.log(valid) desc,
proxy.$message.error('表单校验失败'); });
//done(false); }
} if (data.code == 200) {
}); props.id
}; ? proxy.$message.success('修改成功')
: proxy.$message.success('添加成功');
emits('freshDetail');
}
handleClose();
emits('freshDetail');
} else {
console.log(valid);
proxy.$message.error('表单校验失败');
//done(false);
}
});
};
// Akiraka 20230210 // Akiraka 20230210
const handleClose = () => { const handleClose = () => {
proxy.$refs.modalFormRef.resetFields(); proxy.$refs.modalFormRef.resetFields();
emits('familyVisibleChange', false); emits('familyVisibleChange', false);
}; };
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=="添加区域"){