|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <a-button type="primary" @click="showDrawer">编辑企业</a-button>
|
|
|
+ <a-drawer
|
|
|
+ v-model:visible="visible"
|
|
|
+ class="custom-class"
|
|
|
+ title="编辑企业档案"
|
|
|
+ placement="right"
|
|
|
+ width="600"
|
|
|
+ :closable="false"
|
|
|
+ @close="onClose"
|
|
|
+ >
|
|
|
+ <a-form :model="form" ref="formRef" size="small" layout="vertical">
|
|
|
+ <a-row :gutter="16">
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="企业名称" name="enterprisename" :rules="[{ required: true, message: '请输入企业名称' }]">
|
|
|
+ <a-input v-model:value="form.enterprisename"
|
|
|
+ placeholder="输入企业名称">
|
|
|
+ <template #addonAfter>
|
|
|
+ <business-info :value="form.enterprisename" @onSelect="onSelect"></business-info>
|
|
|
+ </template>
|
|
|
+ </a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="12">
|
|
|
+ <a-form-item label="企业联系人" name="contact">
|
|
|
+ <a-input v-model:value="form.contact" placeholder="输入企业联系人"></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="12">
|
|
|
+ <a-form-item label="联系电话" name="phonenumber">
|
|
|
+ <a-input v-model:value="form.phonenumber" placeholder="输入企业联系电话"></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="省市县" name="cascaderValue">
|
|
|
+ <a-cascader v-model:value="form.cascaderValue" :options="Provinces" placeholder="选择省市县" change-on-select clear @change="onChange"/>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-row>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="详细地址" name="address">
|
|
|
+ <a-input
|
|
|
+ v-model:value="form.address"
|
|
|
+ placeholder="输入详细地址"
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form>
|
|
|
+ <template #extra>
|
|
|
+ <a-space>
|
|
|
+ <a-button @click="onClose">关闭</a-button>
|
|
|
+ <a-button type="primary" @click="submit">保存</a-button>
|
|
|
+ </a-space>
|
|
|
+ </template>
|
|
|
+ </a-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import {ref,defineEmits,defineProps} from 'vue'
|
|
|
+import Api from '@/api/api'
|
|
|
+import utils from '@/utils/utils'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
+import { useBaseStore } from '@/stores/modules/base'
|
|
|
+import businessInfo from '@/template/businessInfo/index.vue'
|
|
|
+const props = defineProps(['data'])
|
|
|
+const emit = defineEmits(['onSuccess'])
|
|
|
+const base = useBaseStore()
|
|
|
+const visible = ref(false)
|
|
|
+const form = ref({
|
|
|
+ sys_enterpriseid:0,
|
|
|
+ enterprisename:'',
|
|
|
+ cascaderValue:null
|
|
|
+})
|
|
|
+const formRef = ref()
|
|
|
+const Provinces = ref([])
|
|
|
+const showDrawer = async ()=>{
|
|
|
+ visible.value = true
|
|
|
+ form.value = Object.assign({},form.value,props.data)
|
|
|
+ form.value.cascaderValue = [props.data.province,props.data.city,props.data.county]
|
|
|
+ Provinces.value = await base.ProvincesData()
|
|
|
+}
|
|
|
+const onClose = () => {
|
|
|
+ visible.value = false;
|
|
|
+ formRef.value.resetFields();
|
|
|
+};
|
|
|
+const submit = async ()=>{
|
|
|
+ try {
|
|
|
+ const values = await formRef.value.validateFields();
|
|
|
+ const res = await Api.requested({
|
|
|
+ "id": 20220920084101,
|
|
|
+ "content":form.value
|
|
|
+ })
|
|
|
+ utils.message(res,'创建成功',()=>{
|
|
|
+ onClose()
|
|
|
+ emit('onSuccess')
|
|
|
+ })
|
|
|
+ } catch (errorInfo) {
|
|
|
+ console.log('Failed:', errorInfo);
|
|
|
+ }
|
|
|
+}
|
|
|
+const onChange = ()=>{
|
|
|
+ if (!form.value.cascaderValue)
|
|
|
+ return false
|
|
|
+ let arr = ['province','city','county']
|
|
|
+ arr.forEach((e,index)=>{
|
|
|
+ form.value[e] = form.value.cascaderValue[index]?form.value.cascaderValue[index]:''
|
|
|
+ })
|
|
|
+}
|
|
|
+const onSelect = (info)=>{
|
|
|
+ form.value = {
|
|
|
+ enterprisename:info.companyName,
|
|
|
+ contact:info.legalPerson,
|
|
|
+ phonenumber:info.phone,
|
|
|
+ province:info.regProvince,
|
|
|
+ city:info.regCity,
|
|
|
+ county:info.regArea,
|
|
|
+ address:info.address,
|
|
|
+ cascaderValue:[info.regProvince,info.regCity,info.regArea]
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+</style>
|