Browse Source

地址 v1.1

Signed-off-by: liwenxuan <1298531568@qq.com>
space_permission
liwenxuan 3 months ago
parent
commit
c933c604ae
  1. 2
      package.json
  2. 5
      src/components/DesignForm/assembly/index.ts
  3. 38
      src/components/DesignForm/formControlPropertiNew.vue
  4. 4
      src/components/DesignForm/public/form/formItem.vue
  5. 4
      src/components/DesignForm/public/form/web/formItem.vue
  6. 361226
      src/widget/region/data.json
  7. 271
      src/widget/region/region.vue

2
package.json

@ -71,6 +71,7 @@
"path-browserify": "^1.0.1",
"path-to-regexp": "^6.2.0",
"pinia": "^2.1.6",
"province-city-china": "^8.5.8",
"quill-image-resize-custom-module": "^4.1.7",
"quill-image-uploader": "^1.3.0",
"react-dnd-html5-backend": "^16.0.1",
@ -82,6 +83,7 @@
"tinymce": "^6.8.6",
"ts-md5": "^1.3.1",
"uuid": "^9.0.1",
"v-region": "^3.4.1",
"vue": "^3.3.1",
"vue-baidu-map-3x": "^1.0.35",
"vue-demi": "^0.14.10",

5
src/components/DesignForm/assembly/index.ts

@ -410,11 +410,12 @@ export default [
},
{
type: 'organization',
label: '联系地址',
unitName: '联系地址',
label: '地址',
unitName: '地址',
icon: 'marker',
iconFont: 'fa-map-marker',
control: {
locationLevel: '详细地址',
},
config: {},
styles: {

38
src/components/DesignForm/formControlPropertiNew.vue

@ -821,6 +821,14 @@ const attrList = computed(() => {
vIf: state.isSearch,
vShow: ["lowcodeImage"],
},
{
label: "地址等级",
value: config.organization,
path: "config.organization",
type: "organization_location_level",
vIf: state.isSearch,
vShow: ["organization"],
},
/*{
label: '尺寸',
value: config.lowcodeImage,
@ -2245,6 +2253,25 @@ const transferDataSourceOptions = [
},
];
const locationLevelOptions = [
{
value: "省级",
label: "省级",
},
{
value: "市级",
label: "市级",
},
{
value: "区县级",
label: "区县级",
},
{
value: "详细地址",
label: "详细地址",
},
]
//const radio = ref(controlData.value.control.fit)
//liwenxuan20240313 lowcodeImage end
@ -4193,6 +4220,17 @@ const libraryList = ref([
/>
</el-row>
<el-row v-else-if="item.type === 'organization_location_level'">
<el-select v-model="controlData.control.locationLevel" placeholder="请选择地址精确到" style="width: 200px">
<el-option
v-for="i in locationLevelOptions"
:key="i.value"
:label="i.label"
:value="i.value"
/>
</el-select>
</el-row>
<el-row v-else-if="item.type === 'carousel'">
<el-button
type="primary"

4
src/components/DesignForm/public/form/formItem.vue

@ -31,6 +31,7 @@ import LowcodeImagePage from "@/components/DesignForm/public/expand/lowcodeImage
import UploadPage from "@/components/DesignForm/public/expand/uploadPage.vue";
import UploadPageList from "@/components/DesignForm/public/expand/uploadPageList.vue";
import OrgCitys from "@/components/DesignForm/public/expand/orgCitys.vue";
import Region from '@/widget/region/region.vue'
import DatePickerPage from "@/components/DesignForm/public/expand/datePicker.vue";
import CascaderPage from "@/components/DesignForm/public/expand/cascader.vue";
import AssociatedForms from "@/widget/associatedforms/index.vue";
@ -203,7 +204,8 @@ const currentComponent = computed(() => {
return markRaw(UploadPage);
}
if (props.data.type === "organization") {
return markRaw(OrgCitys);
//return markRaw(OrgCitys);
return markRaw(Region)
}
if (props.data.type === "datePicker") {
props.data.control.valueFormat = "x";

4
src/components/DesignForm/public/form/web/formItem.vue

@ -39,6 +39,7 @@ import LowcodeImagePage from '@/components/DesignForm/public/expand/lowcodeImage
import UploadPage from '@/components/DesignForm/public/expand/uploadPage.vue'
import UploadPageList from '@/components/DesignForm/public/expand/uploadPageList.vue'
import OrgCitys from '@/components/DesignForm/public/expand/orgCitys.vue'
import Region from '@/widget/region/region.vue'
import DatePickerPage from '@/components/DesignForm/public/expand/datePicker.vue'
import CascaderPage from '@/components/DesignForm/public/expand/cascader.vue'
@ -199,7 +200,8 @@ const currentComponent = computed(() => {
return markRaw(UploadPage)
}
if (props.data.type === 'organization') {
return markRaw(OrgCitys)
//return markRaw(OrgCitys)
return markRaw(Region)
}
if (props.data.type === 'datePicker') {
props.data.control.valueFormat="x"

361226
src/widget/region/data.json

File diff suppressed because it is too large

271
src/widget/region/region.vue

@ -0,0 +1,271 @@
<script lang='ts' setup>
import { RegionColumns } from 'v-region'
import type { RegionValues } from 'v-region'
import { AnalysisInputCss } from '@/components/DesignForm/public/form/calculate/cssInfo.ts'
import { FormList } from '@/api/DesignForm/types'
import areaObj from '@/widget/region/data.json'
import {
constFormProps,
} from '@/api/DesignForm/utils'
import { ref } from 'vue'
//
type RegionData = {
code: string;
name: string;
province: string;
city: number | string;
area: number | string;
town: number | string;
}[];
//
const provincesData = areaObj as unknown as RegionData;
const props = withDefaults(
defineProps<{
data: FormList
tablekey: any
numrun?: number
modelValue?: any //
tProp?: string // form-itemprop
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', numVal: any): void
}>()
const formProps = inject(constFormProps, {}) as any
const type = computed(() => {
return formProps.value.type
})
const config = computed(() => {
return props.data.config || {}
})
const control = computed(() => {
return props.data.control || {}
// return props.data
})
const level = props.data.control.locationLevel
//
const editDisabled = computed(() => {
if (type.value === 3) {
return true //
}
if (type.value === 1 && config.value.addDisabled) {
return true
}
if (type.value === 2 && config.value.editDisabled) {
return true //
}
return control.value.disabled
})
/* const region = ref<RegionValues>({
province: "110000",
city: "110000",
area: "110107"
}) */
const region = ref<RegionValues>({
province: undefined,
city: undefined,
area: undefined
})
const locDetail = ref('')
const cityFlag = computed(() => {
switch (level) {
case "省级":
return false;
case "市级":
return true;
case "区县级":
return true;
case "详细地址":
return true;
default:
return true;
}
})
const areaFlag = computed(() => {
switch (level) {
case "省级":
return true;
case "市级":
return false;
case "区县级":
return true;
case "详细地址":
return true;
default:
return true;
}
})
const detailFlag = computed(() => {
switch (level) {
case "省级":
return false;
case "市级":
return false;
case "区县级":
return false;
case "详细地址":
return true;
default:
return true;
}
})
const addressBox = ref(false)
const updateModel = (val: any) => {
let controlAttribute = ""
if(props.data.control){
if(props.data.control.type){
controlAttribute = props.data.control.type
}
}
// changeEvent &&
// changeEvent({
// key: props.data.name,
// value: val,
// data: props.data,
// tProp: props.tProp,
// type: props.data.type,
// attribute: controlAttribute
// })
}
const value = computed({
get: () => {
return props.modelValue
},
set: (newVal: any) => {
console.log(newVal)
emits('update:modelValue', newVal)
},
});
const configStyle = computed(() => {
return props.data.styles || {}
})
const getFormItemInputStyle = (ele: any, sty: number) => {
if (ele?.inputStyle) {
//console.log("4",AnalysisInputCss(ele?.inputStyle,sty))
return AnalysisInputCss(ele?.inputStyle, sty)
}
}
//
const openAddress = () => {
addressBox.value = true
}
//
const addressBoxClose = () => {
addressBox.value = false
}
//
const submitAddress = () => {
let str = ""
if(valueProv.value.length>0){
str = str+valueProv.value
if(valueCity.value.length>0){
str = str+" - "+valueCity.value
if(valueArea.value.length>0){
str = str+" - "+valueArea.value
if(locDetail.value.length>0){
str = str+" - "+locDetail.value
}else{
}
}else{
}
}else{
}
}else{
}
value.value = str
addressBoxClose()
}
function getAreaName(code: string): string {
const region = provincesData.find(item => item.code === code);
return region ? region.name : "";
}
const valueProv = computed(() => {
if (region.value.province && region.value.province.length > 0) {
return getAreaName(region.value.province)
} else {
return "";
}
})
const valueCity = computed(() => {
if (region.value.city && region.value.city.length > 0) {
return getAreaName(region.value.city)
} else {
return "";
}
})
const valueArea = computed(() => {
if (region.value.area && region.value.area.length > 0) {
return getAreaName(region.value.area)
} else {
return "";
}
})
</script>
<template>
<el-input v-model="value" :disabled="editDisabled" clearable placeholder="请选择地址" style="width:100%"
@click="openAddress" :style="getFormItemInputStyle(configStyle, 2)"
:input-style="getFormItemInputStyle(configStyle, 3)" />
<el-dialog v-model="addressBox" title="选择地址" width="700px" :append-to-body="true" :draggable="true"
:before-close="addressBoxClose">
<span class="region-container" style="padding-left: 12px;font-size:medium;color: blue;">
{{ valueProv }} {{ valueCity }} {{ valueArea }}
</span>
<RegionColumns v-model="region" class="region-container" :city="cityFlag" :area="areaFlag" />
<el-input v-if="detailFlag" v-model="locDetail" class="region-container1" rows="2" type="textarea"
placeholder="请输入详细地址" />
<template #footer>
<span class="dialog-footer">
<el-button @click="addressBoxClose">取消</el-button>
<el-button type="primary" @click="submitAddress">确定</el-button>
</span>
</template>
</el-dialog>
</template>
<style lang='scss' scoped>
.region-container {
margin-top: 10px;
margin-left: 50px;
width: calc(80%);
}
.region-container1 {
margin-top: 40px;
margin-left: 0px;
width: calc(70%);
margin-bottom: 10px;
}
</style>
Loading…
Cancel
Save