更新
This commit is contained in:
parent
20db6f0d48
commit
3f8c0900a6
@ -12,7 +12,12 @@
|
||||
<div class="bar"></div>
|
||||
<div class="name">基本信息</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-col :span="12">
|
||||
<a-form-item field="hospital_name" label="医院名称:">
|
||||
@ -24,12 +29,12 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item field="county_id" label="选择省市区:">
|
||||
<a-form-item field="county_id" label="选择省市区:">
|
||||
<div class="row">
|
||||
<a-select
|
||||
v-model="modalForm.province_id"
|
||||
placeholder="请选择省份"
|
||||
:style="{ width: '162px',marginRight:'10px' }"
|
||||
:style="{ width: '162px', marginRight: '10px' }"
|
||||
@change="changeProvice"
|
||||
>
|
||||
<a-option
|
||||
@ -40,12 +45,11 @@
|
||||
>{{ item.area_name }}</a-option
|
||||
>
|
||||
</a-select>
|
||||
|
||||
|
||||
|
||||
<a-select
|
||||
v-model="modalForm.city_id"
|
||||
placeholder="请选择城市"
|
||||
:style="{ width: '162px',marginRight:'10px' }"
|
||||
:style="{ width: '162px', marginRight: '10px' }"
|
||||
@change="changeCity"
|
||||
>
|
||||
<a-option
|
||||
@ -69,10 +73,8 @@
|
||||
>{{ item.area_name }}</a-option
|
||||
>
|
||||
</a-select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="24">
|
||||
@ -87,16 +89,19 @@
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item field="hospital_level_name" label="医院等级:">
|
||||
<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-select>
|
||||
<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-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
</a-row>
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="12">
|
||||
@ -121,34 +126,41 @@
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="12">
|
||||
<a-form-item field="desc" label="描述:">
|
||||
<a-textarea v-model="modalForm.desc " :auto-size="{
|
||||
minRows:2,
|
||||
maxRows:5
|
||||
}" />
|
||||
<a-textarea
|
||||
v-model="modalForm.desc"
|
||||
:auto-size="{
|
||||
minRows: 2,
|
||||
maxRows: 5,
|
||||
}"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
</a-row>
|
||||
<a-divider />
|
||||
<a-divider />
|
||||
</a-form>
|
||||
<div class="titlebox" >
|
||||
<div class="bar"></div>
|
||||
<div class="name">操作</div>
|
||||
</div>
|
||||
<a-row :gutter="24" style="margin-top: 35px;" >
|
||||
<a-col :span="24">
|
||||
<a-form-item field="" label="" no-style>
|
||||
<a-space >
|
||||
<a-button type="primary" @click="handleSubmit" v-has="'admin:sysHospitalList:save'">保存</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="titlebox">
|
||||
<div class="bar"></div>
|
||||
<div class="name">操作</div>
|
||||
</div>
|
||||
<a-row :gutter="24" style="margin-top: 35px">
|
||||
<a-col :span="24">
|
||||
<a-form-item field="" label="" no-style>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="handleSubmit"
|
||||
v-has="'admin:sysHospitalList:save'"
|
||||
>保存</a-button
|
||||
>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, toRefs,watch,getCurrentInstance} from 'vue';
|
||||
import { getAreaList,addHospital,updateHospital } from '@/api/basic/list';
|
||||
import { ref, toRefs, watch, getCurrentInstance } from 'vue';
|
||||
import { getAreaList, addHospital, updateHospital } from '@/api/basic/list';
|
||||
const { proxy } = getCurrentInstance();
|
||||
const props = defineProps({
|
||||
// 是否显示
|
||||
@ -156,7 +168,7 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
id:{
|
||||
id: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
@ -164,8 +176,8 @@ const props = defineProps({
|
||||
type: Object,
|
||||
},
|
||||
});
|
||||
const title=ref('');
|
||||
const emits = defineEmits(['familyVisibleChange','freshDetail']);
|
||||
const title = ref('');
|
||||
const emits = defineEmits(['familyVisibleChange', 'freshDetail']);
|
||||
const { modalVisible, modalForm } = toRefs(props);
|
||||
const provinceData = ref([]);
|
||||
const cityData = ref([]);
|
||||
@ -182,11 +194,9 @@ const handelAreaList = (area_id = '', parent_id = '', area_type) => {
|
||||
if (code == 200) {
|
||||
if (area_type == 2) {
|
||||
provinceData.value = data;
|
||||
|
||||
}
|
||||
if (area_type == 3) {
|
||||
cityData.value = data;
|
||||
|
||||
}
|
||||
if (area_type == 4) {
|
||||
countryData.value = data;
|
||||
@ -205,81 +215,93 @@ const changeCity = (value) => {
|
||||
modalForm.county_id = '';
|
||||
handelAreaList('', value, 4);
|
||||
};
|
||||
watch(()=>props.id,()=>{
|
||||
if(props.id){
|
||||
title.value="编辑医院"
|
||||
}else{
|
||||
title.value="修改医院"
|
||||
}
|
||||
|
||||
},{immediate:true})
|
||||
|
||||
watch(
|
||||
() => props.id,
|
||||
() => {
|
||||
if (props.id) {
|
||||
title.value = '编辑医院';
|
||||
} else {
|
||||
title.value = '修改医院';
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const rules = {
|
||||
hospital_name: [{ required: true, message: '请输入医院名称' }],
|
||||
county_id:[{ required: true, message: '请选择省市区' }],
|
||||
hospital_level_name:[{ required: true, message: '请选择医院等级' }],
|
||||
address:[{ required: true, message: '请输入详细地址' }],
|
||||
};
|
||||
const handleSubmit=()=>{
|
||||
proxy.$refs.modalFormRef.validate(async (valid) => {
|
||||
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;
|
||||
if (!valid) {
|
||||
if(props.id){
|
||||
data= await updateHospital(props.id,{
|
||||
hospital_name,
|
||||
hospital_status,
|
||||
hospital_level_name,
|
||||
post_code,
|
||||
tele_phone,
|
||||
province_id,
|
||||
city_id,
|
||||
county_id,
|
||||
address,
|
||||
desc
|
||||
})
|
||||
}else{
|
||||
data= await addHospital({
|
||||
hospital_name,
|
||||
hospital_status,
|
||||
hospital_level_name,
|
||||
post_code,
|
||||
tele_phone,
|
||||
province_id,
|
||||
city_id,
|
||||
county_id,
|
||||
address,
|
||||
desc
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
hospital_name: [{ required: true, message: '请输入医院名称' }],
|
||||
county_id: [{ required: true, message: '请选择省市区' }],
|
||||
hospital_level_name: [{ required: true, message: '请选择医院等级' }],
|
||||
address: [{ required: true, message: '请输入详细地址' }],
|
||||
};
|
||||
const handleSubmit = () => {
|
||||
proxy.$refs.modalFormRef.validate(async (valid) => {
|
||||
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;
|
||||
if (!valid) {
|
||||
if (props.id) {
|
||||
data = await updateHospital(props.id, {
|
||||
hospital_name,
|
||||
hospital_status,
|
||||
hospital_level_name,
|
||||
post_code,
|
||||
tele_phone,
|
||||
province_id,
|
||||
city_id,
|
||||
county_id,
|
||||
address,
|
||||
desc,
|
||||
});
|
||||
} else {
|
||||
data = await addHospital({
|
||||
hospital_name,
|
||||
hospital_status,
|
||||
hospital_level_name,
|
||||
post_code,
|
||||
tele_phone,
|
||||
province_id,
|
||||
city_id,
|
||||
county_id,
|
||||
address,
|
||||
desc,
|
||||
});
|
||||
}
|
||||
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 关闭弹窗
|
||||
const handleClose = () => {
|
||||
proxy.$refs.modalFormRef.resetFields();
|
||||
emits('familyVisibleChange', false);
|
||||
};
|
||||
const getData = (flag=false) => {
|
||||
const getData = (flag = false) => {
|
||||
handelAreaList('', '', 2);
|
||||
if(flag){
|
||||
handelAreaList('',modalForm.value.province_id
|
||||
,3)
|
||||
handelAreaList('',modalForm.value.city_id
|
||||
,4)
|
||||
if (flag) {
|
||||
handelAreaList('', modalForm.value.province_id, 3);
|
||||
handelAreaList('', modalForm.value.city_id, 4);
|
||||
}
|
||||
};
|
||||
defineExpose({
|
||||
|
||||
@ -116,6 +116,7 @@ const handleNodeClick = (data) => {
|
||||
current.parent_id=data.parent_id;
|
||||
current.level=data.level;
|
||||
form.area_name='';
|
||||
form.area_id='';
|
||||
// console.log(data)
|
||||
// const newChild = { id: id++, label: 'testtest', children: [] };
|
||||
// tree.value.append(newChild,data.id)
|
||||
@ -192,9 +193,11 @@ const handleNodeClick = (data) => {
|
||||
let {code,data}= title.value=="添加区域"?await addArea({
|
||||
area_name:form.area_name,
|
||||
parent_id:form.parent_id,
|
||||
area_id:form.area_id,
|
||||
area_type:type
|
||||
}):await updateArea(form.parent_id,{
|
||||
area_name:form.area_name
|
||||
area_name:form.area_name,
|
||||
area_id:form.area_id,
|
||||
})
|
||||
if(code==200){
|
||||
if(title.value=="添加区域"){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user