绑定区域

master
xy 2 years ago
parent 0a32f29f96
commit ebea67e841

@ -12,7 +12,7 @@
securityJsCode: '68787c7a64e7240670e6a538b326d64b',
}
</script>
<script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.4&key=1a9ee0079fcb3c6c64c96dc903989994&plugin=AMap.PlaceSearch,AMap.DistrictSearch'></script>
<script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.4&key=1a9ee0079fcb3c6c64c96dc903989994&plugin=AMap.PlaceSearch,AMap.DistrictSearch,AMap.MarkerClusterer'></script>
<script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
</head>
<body>

@ -0,0 +1,70 @@
<template>
<div>
<el-cascader ref="elCascader"
style="width: 100%;"
v-model="val"
:placeholder="placeholder"
:options="village_codes"
clearable
:props="props"
@change="pick"
@expand-change="expand"></el-cascader>
</div>
</template>
<script>
import { mapGetters } from "vuex"
import { getVillages } from "@/api/common";
export default {
props: {
placeholder: {
type: String,
default: "请选择区域"
},
level: {
type: Number,
default: 5
},
value: [Number,String]
},
data() {
return {
resolveData: [],
val: [],
props: {
lazy: true,
value: "code",
label: "name",
lazyLoad: (node, resolve) => {
const { code, level } = node.data;
getVillages({ pcode: code }).then(res => {
let nodes = res.list.map(i => ({
...i,
leaf: i.level >= this.level
}))
this.resolveData = nodes;
resolve(nodes)
}).catch(err => resolve())
}
}
}
},
methods: {
pick (e) {
this.$emit('input', e.at(-1))
},
expand (e) {
this.$store.commit('app/SET_VILLAGE_CODES', { val: this.resolveData, pcode: e })
}
},
computed: {
...mapGetters(['village_codes']),
},
}
</script>
<style scoped lang="scss">
::v-deep .el-input > input::placeholder {
color: #606266;
}
</style>

@ -50,7 +50,7 @@ Vue.use(avue)
import VueAMap from "vue-amap";
VueAMap.initAMapApiLoader({
key:'1a9ee0079fcb3c6c64c96dc903989994',
plugins:['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor','MarkerClusterer','AMap.DistrictSearch'],
plugins:['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor','AMap.MarkerClusterer','AMap.DistrictSearch'],
v: "1.4.4",
'uVersion':'1.0'
})
@ -77,6 +77,8 @@ import XyDialog from '@/components/XyDialog'
Vue.component('xy-dialog',XyDialog)
import XySelectors from '@/components/XySelectors'
Vue.component('xy-selectors',XySelectors)
import VillagePick from "@/components/villagePick/index.vue";
Vue.component('village-pick', VillagePick)
Vue.prototype.$integrateData = (target,value) => {
for(let i in target){

@ -5,6 +5,7 @@ const getters = {
avatar: state => state.user.avatar,
name: state => state.user.name,
roles: state => state.user.roles,
permission_routes: state => state.permission.routes
permission_routes: state => state.permission.routes,
village_codes: state => state.app.villageCodes
}
export default getters

@ -18,4 +18,5 @@ const store = new Vuex.Store({
getters
})
store.dispatch('app/getVillageCodes')
export default store

@ -1,14 +1,33 @@
import Cookies from 'js-cookie'
import { getVillages } from "@/api/common"
const state = {
sidebar: {
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
withoutAnimation: false
},
device: 'desktop'
device: 'desktop',
villageCodes: [],
}
const mutations = {
SET_VILLAGE_CODES: (state, { val, pcode = 0 }) => {
if (pcode === 0) {
state.villageCodes = val
} else {
if (pcode instanceof Array) {
let temp = state.villageCodes;
pcode.forEach((ipcode, index) => {
temp = index === 0 ? temp?.find(i => i.code === ipcode) : temp?.children?.find(i => i.code === ipcode)
})
if (temp && !temp._isload) {
temp.children = val
temp._isload = true
}
}
}
},
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
@ -29,6 +48,14 @@ const mutations = {
}
const actions = {
getVillageCodes({ commit }, pcode) {
return new Promise((resolve, reject) => {
getVillages({ pcode },false).then(res => {
commit('SET_VILLAGE_CODES', { val: res.list, pcode })
resolve(res)
}).catch(err => reject(err))
})
},
toggleSideBar({ commit }) {
commit('TOGGLE_SIDEBAR')
},

@ -24,6 +24,8 @@ const getDefaultState = () => {
typeAuth: [],
areaAuth: [],
myRoles: [],
myInfo: {}
}
}

@ -8,7 +8,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>名称
</div>
<div class="xy-table-item-content">
<el-input v-model="form.name" clearable placeholder="请输入客户名称" style="width: 300px;"></el-input>
<el-input v-model="form.name" clearable placeholder="请输入客户名称" style="width: 400px;"></el-input>
</div>
</div>
</template>
@ -23,7 +23,7 @@
multiple
:value="form.product_type_customer_links.map(item => item.product_type_id)"
placeholder="请选择业务板块"
style="width: 300px"
style="width: 400px"
@change="productTypePick">
<el-option v-for="item in types" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
@ -37,7 +37,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>联系电话
</div>
<div class="xy-table-item-content">
<el-input v-model="form.phone" clearable placeholder="请输入联系电话" style="width: 300px;"></el-input>
<el-input v-model="form.phone" clearable placeholder="请输入联系电话" style="width: 400px;"></el-input>
</div>
</div>
</template>
@ -48,7 +48,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>身份证号
</div>
<div class="xy-table-item-content">
<el-input v-model="form.idcard" clearable placeholder="请输入身份证号" style="width: 300px;"></el-input>
<el-input v-model="form.idcard" clearable placeholder="请输入身份证号" style="width: 400px;"></el-input>
</div>
</div>
</template>
@ -59,7 +59,7 @@
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span> -->委托人
</div>
<div class="xy-table-item-content">
<el-input v-model="form.contact_name " clearable placeholder="请输入委托人姓名" style="width: 300px;"></el-input>
<el-input v-model="form.contact_name " clearable placeholder="请输入委托人姓名" style="width: 400px;"></el-input>
</div>
</div>
</template>
@ -70,7 +70,7 @@
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span> -->委托人电话
</div>
<div class="xy-table-item-content">
<el-input v-model="form.contact_phone " clearable placeholder="请输入委托人电话" style="width: 300px;"></el-input>
<el-input v-model="form.contact_phone " clearable placeholder="请输入委托人电话" style="width: 400px;"></el-input>
</div>
</div>
</template>
@ -81,28 +81,39 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>户籍地址
</div>
<div class="xy-table-item-content">
<el-input v-model="form.idcard_address " clearable placeholder="请输入户籍地址" style="width: 300px;"></el-input>
<el-input v-model="form.idcard_address " clearable placeholder="请输入户籍地址" style="width: 400px;"></el-input>
</div>
</div>
</template>
<template v-slot:area>
<!-- <template v-slot:area>-->
<!-- <div class="xy-table-item">-->
<!-- <div class="xy-table-item-label">-->
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>区域-->
<!-- </div>-->
<!-- <div class="xy-table-item-content">-->
<!-- <el-cascader-->
<!-- v-model="form.area"-->
<!-- style="width: 300px;"-->
<!-- placeholder="区域选择"-->
<!-- :options="cities"-->
<!-- :props="{-->
<!-- label:'value',-->
<!-- value:'id',-->
<!-- }"-->
<!-- @change="areaPick">-->
<!-- </el-cascader>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<template #village_code>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>区域
</div>
<div class="xy-table-item-content">
<el-cascader
v-model="form.area"
style="width: 300px;"
placeholder="区域选择"
:options="cities"
:props="{
label:'value',
value:'id',
}"
@change="areaPick">
</el-cascader>
<village-pick ref="villagePick" :placeholder="villageText" style="width: 400px;" :level="5" v-model="form.village_code"></village-pick>
</div>
</div>
</template>
@ -143,7 +154,7 @@
备注
</div>
<div class="xy-table-item-content">
<el-input v-model="form.remark" :autosize="{minRows:2}" clearable placeholder="请输入备注" style="width: 300px;"
<el-input v-model="form.remark" :autosize="{minRows:2}" clearable placeholder="请输入备注" style="width: 400px;"
type="textarea"></el-input>
</div>
</div>
@ -155,7 +166,7 @@
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span> -->失能等级
</div>
<div class="xy-table-item-content">
<el-select v-model="form.level_id" placeholder="请选择失能等级" style="width: 300px;">
<el-select v-model="form.level_id" placeholder="请选择失能等级" style="width: 400px;">
<el-option v-for="item in disabilityLevel" :key="item.id" :label="item.value"
:value="item.id"></el-option>
</el-select>
@ -169,7 +180,7 @@
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span> -->失能类型
</div>
<div class="xy-table-item-content">
<el-select v-model="form.level_type" placeholder="请选择失能类型" style="width: 300px;">
<el-select v-model="form.level_type" placeholder="请选择失能类型" style="width: 400px;">
<el-option v-for="item in levelTypes" :key="item.id" :label="item.value"
:value="item.id"></el-option>
</el-select>
@ -189,7 +200,7 @@
:value="pickedProduct.name"
v-load-more="productLoad"
placeholder="请选择产品"
style="width: 300px"
style="width: 400px"
@change="productPick">
<el-option
v-for="item in productFilter"
@ -213,7 +224,7 @@
v-model="form1.date"
end-placeholder="结束时间"
start-placeholder="开始时间"
style="width: 300px;"
style="width: 400px;"
type="daterange"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd"
@ -231,7 +242,7 @@
<el-select
v-model="form1.account_id"
placeholder="请选择结算对象"
style="width: 300px">
style="width: 400px">
<el-option v-for="item in accounts" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
@ -271,7 +282,6 @@ import {getList as productList} from "@/api/product";
import {getBirth,getSex,getAgeByIdcard} from '@/utils'
import {getAuthAreas} from "@/utils/auth"
import moment from "moment";
export default {
props: {
disabilityLevel: {
@ -315,6 +325,7 @@ export default {
}
}
return {
villageText: "",
//
log:[],
logTable:[
@ -443,6 +454,7 @@ export default {
contact_phone: '',
idcard_address: '',
area:'',
village_code: '',
customer_address_list: [],
sex: '',
birthday: '',
@ -482,7 +494,10 @@ export default {
// ],
product_type_customer_links:[
{validator: validateProductType}
]
],
village_code: [
{required: true, message: '请选择区域'},
],
},
map: [],
option: {
@ -556,6 +571,7 @@ export default {
account_id:'',
status: 0,
customer_id: '',
village_code: '',
},
rules1: {
customer_id:[
@ -603,6 +619,7 @@ export default {
contact_phone: '',
idcard_address: '',
area:'',
village_code: '',
status:1,
customer_address_list: [],
sex: '',
@ -622,6 +639,7 @@ export default {
account_id:'',
status: 0,
customer_id: '',
village_code: '',
}
},
areaPick(e){
@ -646,29 +664,14 @@ export default {
this.form.area = [Number(res.city_id),Number(res.area_id),Number(res.street_id)]
this.log = res.schedule_list_update_logs
console.log(this.form)
this.form.village_code = res.village?.at(-1) ? Number(res.village?.at(-1)?.village_code) : ''
this.villageText = res.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
this.$refs['villagePick'].val = res.village?.map(i => Number(i.village_code))
},
submit() {
this.form.sex = getSex(this.form.idcard)
this.form.birthday = getBirth(this.form.idcard)
Object.defineProperty(this.form,'city_id',{
value:this.form.area[0] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'area_id',{
value:this.form.area[1] || '',
enumerable: true,
writable: true,
configurable: true
})
Object.defineProperty(this.form,'street_id',{
value:this.form.area[2] || '',
enumerable: true,
writable: true,
configurable: true
})
if (this.type === 'editor') {
Object.defineProperty(this.form, 'id', {
@ -678,10 +681,10 @@ export default {
configurable: true
})
}
console.log(this.form)
save(this.form).then(res => {
if(this.type === 'add'){
this.form1.customer_id = res.id
this.form1.customer_id = res.id;
this.form1.village_code = this.form.village_code;
Object.defineProperty(this.form1,'start_date',{
value:this.form1.date[0],

@ -28,6 +28,13 @@
></el-option>
</el-select>
<el-input
size="small"
placeholder="区域搜索"
v-model="select.village_name"
style="width: 140px; margin-right: 10px"
/>
<el-input
size="small"
placeholder="关键字搜索"
@ -224,6 +231,7 @@ export default {
page: 1,
page_size: 10,
keyword: "",
village_name: "",
},
disabilityLevel: [],
levelTypes: [],
@ -349,6 +357,20 @@ export default {
prop: "sex",
width: 100,
},
{
label: "区域",
prop: 'villate',
width: 200,
customFn: row => {
return (
<span>
{
row.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
}
</span>
)
}
},
{
label: "订单产品",
width: 220,

@ -229,6 +229,48 @@ export default {
console.log(this.customers)
},
addCluster() {
if (this.cluster) {
this.cluster.setMap(null);
}
this.cluster = new AMap.MarkerClusterer(this.map, this.markers, {
gridSize: 50, //
renderClusterMarker: this.renderClusterMarker, //
renderMarker: this.renderMarker, //
});
},
renderClusterMarker(context) {
let factor = Math.pow(context.count / this.customers.length, 1 / 18);
let div = document.createElement("div");
let Hue = 180 - factor * 180;
let bgColor = "hsla(" + Hue + ",100%,40%,0.7)";
let fontColor = "hsla(" + Hue + ",100%,90%,1)";
let borderColor = "hsla(" + Hue + ",100%,40%,1)";
let shadowColor = "hsla(" + Hue + ",100%,90%,1)";
div.style.backgroundColor = bgColor;
let size = Math.round(
30 + Math.pow(context.count / this.customers.length, 1 / 5) * 20
);
div.style.width = div.style.height = size + "px";
div.style.border = "solid 1px " + borderColor;
div.style.borderRadius = size / 2 + "px";
div.style.boxShadow = "0 0 5px " + shadowColor;
div.innerHTML = context.count;
div.style.lineHeight = size + "px";
div.style.color = fontColor;
div.style.fontSize = "14px";
div.style.textAlign = "center";
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
context.marker.setContent(div);
},
renderMarker(context) {
let content =
'<div style="background-color: hsla(180, 100%, 50%, 0.3); height: 18px; width: 18px; border: 1px solid hsl(180, 100%, 40%); border-radius: 12px; box-shadow: hsl(180, 100%, 50%) 0px 0px 3px;"></div>';
let offset = new AMap.Pixel(-9, -9);
context.marker.setContent(content);
context.marker.setOffset(offset);
},
drawMarkers(){
this.markers = []
for(let i of this.customers){
@ -249,9 +291,15 @@ export default {
marker.on('mouseout',e => {
this.isShowCard = false
})
marker.on('click',e => {
this.map.panTo([i.lng,i.lat]);
this.map.setZoom(28);
})
this.markers.push(marker)
marker.setMap(this.map)
}
this.addCluster();
},
draw(){

@ -32,27 +32,37 @@
</div>
</template>
<template v-slot:area_id>
<template #village_code>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>所属区域
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>区域
</div>
<div class="xy-table-item-content">
<el-cascader
:value="form.area_id"
style="width: 300px;"
placeholder="区域选择"
:options="cities"
:props="{
checkStrictly: true,
label:'value',
value:'id',
}"
@change="areaPick">
</el-cascader>
<village-pick ref="villagePick" :placeholder="villageText" style="width: 300px;" :level="3" v-model="form.village_code"></village-pick>
</div>
</div>
</template>
<!-- <template v-slot:area_id>-->
<!-- <div class="xy-table-item">-->
<!-- <div class="xy-table-item-label">-->
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>所属区域-->
<!-- </div>-->
<!-- <div class="xy-table-item-content">-->
<!-- <el-cascader-->
<!-- :value="form.area_id"-->
<!-- style="width: 300px;"-->
<!-- placeholder="区域选择"-->
<!-- :options="cities"-->
<!-- :props="{-->
<!-- checkStrictly: true,-->
<!-- label:'value',-->
<!-- value:'id',-->
<!-- }"-->
<!-- @change="areaPick">-->
<!-- </el-cascader>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
</xy-dialog>
</div>
</template>
@ -74,6 +84,7 @@ export default {
},
data() {
return {
villageText: "",
isShow:false,
id:'',
type:'',
@ -82,6 +93,7 @@ export default {
name:'',
product_type_id:'',
area_id:'',
village_code: '',
},
rules:{
name:[
@ -98,6 +110,9 @@ export default {
async getDetail(){
const res = await getForm(this.id)
this.$integrateData(this.form,res)
this.form.village_code = res.village?.at(-1) ? Number(res.village?.at(-1)?.village_code) : ''
this.villageText = res.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
this.$refs['villagePick'].val = res.village?.map(i => Number(i.village_code))
},
submit(){

@ -59,9 +59,16 @@ export default {
align:'left'
},
{
prop:'area_detail.value',
prop:'village',
label:'所属区域',
width: 140
width: 160,
customFn: row => (
<span>
{
row.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur?.village_name),"")
}
</span>
)
},
{
prop:'product_type_id',

@ -34,29 +34,39 @@
</div>
</template>
<template v-slot:area_id>
<template #village_code>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>区域
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>区域
</div>
<div class="xy-table-item-content">
<el-select
v-model="form.area_id"
placeholder="请选择区域"
style="width: 300px"
>
<el-option
v-for="item in areas"
:key="item.id"
:label="item.value"
:value="item.id"
></el-option>
</el-select>
<village-pick ref="villagePick" :placeholder="villageText" style="width: 300px;" :level="3" v-model="form.village_code"></village-pick>
</div>
</div>
</template>
<!-- <template v-slot:area_id>-->
<!-- <div class="xy-table-item">-->
<!-- <div class="xy-table-item-label">-->
<!-- <span style="color: red; font-weight: 600; padding-right: 4px"-->
<!-- >*</span-->
<!-- >区域-->
<!-- </div>-->
<!-- <div class="xy-table-item-content">-->
<!-- <el-select-->
<!-- v-model="form.area_id"-->
<!-- placeholder="请选择区域"-->
<!-- style="width: 300px"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in areas"-->
<!-- :key="item.id"-->
<!-- :label="item.value"-->
<!-- :value="item.id"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<template v-slot:name>
<div class="xy-table-item">
@ -319,12 +329,14 @@ export default {
},
data() {
return {
villageText: "",
id: "",
isShow: false,
type: "add",
form: {
product_type_id: "",
village_code: "",
area_id: "",
name: "",
cycle: "",
@ -356,6 +368,9 @@ export default {
const res = await getForm(this.id);
this.$integrateData(this.form, res);
this.form.service_rule = res.service_rule === 2;
this.form.village_code = res.village?.at(-1) ? Number(res.village?.at(-1)?.village_code) : ''
this.villageText = res.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
this.$refs['villagePick'].val = res.village?.map(i => Number(i.village_code))
},
submit() {

@ -47,6 +47,16 @@
</el-col>
</el-row>
<el-row type="flex" align="middle">
<el-col :span="4" :push="1">
区域
</el-col>
<el-col :span="18">
<el-input :value="villageComputed" readonly style="width: 300px;">
</el-input>
</el-col>
</el-row>
<el-row type="flex" align="middle">
<el-col :span="4" :push="1">
评估等级
@ -175,6 +185,7 @@ export default {
methods: {
datePick(date,data,type,schedule){
console.log(schedule)
this.date = data.day
this.$refs['timeSelect'].form.nurse_id = this.nurseId
if(data.type === 'current-month'){
@ -217,6 +228,10 @@ export default {
},
},
computed: {
villageComputed () {
return this.detail.customer?.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
},
ageComputed() {
return getAgeByIdcard(this.detail.customer.idcard)
//return moment().diff(moment(this.detail.customer.birthday).format(),'year')

@ -19,7 +19,7 @@
</div>
<div style="overflow: auto;" :style="{height:height+'px'}">
<el-scrollbar style="flex: 1">
<el-tabs tab-position="left" v-model="activeUser" @tab-click="getAdminAreas(),getAdminTypes()">
<el-tabs tab-position="left" v-model="activeUser" @tab-click="getAdminAreas(),getAdminTypes(),checkNewTreeNodes()">
<el-tab-pane v-for="item in users" :label="item.name" :name="String(item.id)"></el-tab-pane>
</el-tabs>
</el-scrollbar>
@ -45,7 +45,7 @@
</div>
<div>
<h4 style="padding: 16px 0;">区域权限</h4>
<h4 style="padding: 16px 0;">区域权限</h4>
<el-tree
ref="elTree"
@ -56,6 +56,24 @@
show-checkbox>
</el-tree>
</div>
<div>
<h4 style="padding: 16px 0;">区域权限</h4>
<el-tree :data="list"
ref="newElTree"
node-key="code"
lazy
show-checkbox
:props="{
label: 'name',
isLeaf: (data, node) => {
return data.level >= 5;
}
}"
:load="loadNode"></el-tree>
</div>
</el-scrollbar>
</div>
</Card>
@ -66,6 +84,7 @@
</template>
<script>
import { save } from "@/api/system/user"
import { listuser } from "@/api/system/user"
import { getList as getProductTypes } from "@/api/productType"
import { getparameter } from "@/api/system/dictionary"
@ -73,6 +92,7 @@ import { getList as getAdminType,save as saveType,destroy as destroyType } from
import { getList as getAdminArea,save as saveArea,destroy as destroyArea } from "@/api/system/adminArea"
import LxHeader from "@/components/LxHeader/index.vue";
import {getVillages} from "@/api/common";
export default {
components: {
LxHeader
@ -92,14 +112,45 @@ export default {
originalArea:[],
originalType:[],
list:[],
}
},
methods: {
async loadNode (node, resolve) {
const list = await this.getList(node?.data?.code || 0)
resolve(list)
},
checkNewTreeNodes () {
this.$nextTick(() => {
this.$refs['newElTree'].setCheckedKeys([])
let user = this.users.find(i => i.id == this.activeUser)
if (user && user.village) {
this.$refs['newElTree'].setCheckedKeys(user.village.map(i => Number(i.village_code)))
}
})
},
async getList(pcode = 0){
const res = await getVillages({ pcode });
this.checkNewTreeNodes()
if (pcode === 0) {
this.list = res.list
return []
} else {
return res.list
}
// const res = await getList(this.select)
// this.total = res.total
// this.list = res.data
// console.log(this.list)
},
async getAdminTypes(){
const res = await getAdminType({
admin_id:Number(this.activeUser)
})
console.log('type',res)
this.originalType = res
this.checkedTypes = res.map(item => item.product_type_id)
},
@ -107,7 +158,6 @@ export default {
const res = await getAdminArea({
admin_id:Number(this.activeUser)
})
console.log('area',res)
this.originalArea = res
this.$refs['elTree'].setCheckedKeys(res.map(item => item.area_id))
},
@ -202,7 +252,13 @@ export default {
}
})
Promise.all([...areaPromiseAll,...typePromiseAll]).then(res => {
let submitUser = this.users.find(i => i.id == this.activeUser)
if (!submitUser) {
this.$message.warning("用户不存在")
return
}
submitUser.village_code = this.$refs['newElTree']?.getCheckedNodes()?.filter(i => i.level === 5)?.map(i => i.code)?.toString()
Promise.all([...areaPromiseAll,...typePromiseAll,save(submitUser)]).then(res => {
this.getAdminTypes()
this.getAdminAreas()
@ -216,13 +272,18 @@ export default {
created(){
this.initLoad()
this.getCity()
this.getUsers()
this.getUsers().then(_ => {
this.getList()
})
this.getProductTypes()
},
};
</script>
<style lang="less" scoped>
<style lang="scss" scoped>
::v-deep .el-checkbox .is-disabled {
// display: none;
}
.t-tree {
position: absolute;
width: 100%;

@ -19,18 +19,18 @@
</div>
</template>
<template v-slot:serve_area_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>主服务区
</div>
<div class="xy-table-item-content">
<el-select v-model="form.serve_area_id" placeholder="请选择主服务区" style="width: 300px;">
<el-option v-for="item in serveArea" :key="item.id" :label="item.value" :value="item.id"></el-option>
</el-select>
</div>
</div>
</template>
<!-- <template v-slot:serve_area_id>-->
<!-- <div class="xy-table-item">-->
<!-- <div class="xy-table-item-label">-->
<!-- <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>主服务区-->
<!-- </div>-->
<!-- <div class="xy-table-item-content">-->
<!-- <el-select v-model="form.serve_area_id" placeholder="请选择主服务区" style="width: 300px;">-->
<!-- <el-option v-for="item in serveArea" :key="item.id" :label="item.value" :value="item.id"></el-option>-->
<!-- </el-select>-->
<!-- </div>-->
<!-- </div>-->
<!-- </template>-->
<template v-slot:product_type_id>
<div class="xy-table-item">
@ -100,6 +100,17 @@
</div>
</template>
<template #village_code>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>主服务区
</div>
<div class="xy-table-item-content">
<village-pick ref="villagePick" :placeholder="villageText" style="width: 300px;" :level="3" v-model="form.village_code"></village-pick>
</div>
</div>
</template>
<template v-slot:sex>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -282,18 +293,19 @@ export default {
},
data() {
let passwordValidator = (rule, value, callback) => {
if(this.type === 'add'){
if(value){
if (this.type === 'add') {
if (value) {
callback()
}else{
} else {
return callback(new Error('请填写密码'))
}
}
if(this.type === 'editor'){
if (this.type === 'editor') {
callback()
}
}
return {
villageText: "",
id: '',
type: '',
isShow: false,
@ -302,6 +314,7 @@ export default {
form: {
name: '',
serve_area_id: '',
village_code: '',
product_type_id: '',
mobile: '',
avatar: '',
@ -390,7 +403,10 @@ export default {
async getDetail() {
const res = await getForm(this.id)
this.$integrateData(this.form, res)
this.form.avatar_url = res.upload?.url
this.form.avatar_url = res.upload?.url;
this.form.village_code = res.village?.at(-1) ? Number(res.village?.at(-1)?.village_code) : ''
this.villageText = res.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
this.$refs['villagePick'].val = res.village?.map(i => Number(i.village_code))
},
submit() {
if (this.type === 'editor') {

@ -116,6 +116,17 @@ export default {
width: 180,
fixed: 'left'
},
{
prop: "village",
label: "主服务区",
customFn: row => (
<span>
{
row.village?.reduce((pre, cur, index) => (pre + (index === 0 ? "" : "/") + cur.village_name),"")
}
</span>
)
},
{
prop: 'idcard',
label: "身份证号",

Loading…
Cancel
Save