实现省市二级联动效果

实现效果:
在这里插入图片描述
代码:

<template><div class="main_tableau"><div class="page_title">百城精算编辑</div><CFlex type="flex" justify="space-between"><div style="margin-top:15px;"><div class="top_box" style=" font-weight: bold;">选择区域</div><div class="top_box"><span>已选区域:</span><span class="margin_citys" v-for="(item, index) in city" :key="index">{{ item }}<span class="margin_citys_delete" @click="citydelete(index)">x</span></span><!-- <span class="margin_c_d" @click="clear">清空</span> --></div></div></CFlex><!-- 多选区域 --><div class="deliverySetting" style="z-index:0px"> <div class="content" :style="openShow ? 'max-height:1000px;' : ''" ><div class="content_between"><div style="margin-top:10px"><el-checkbox:indeterminate="indeterminate"v-model="ischeckAll"@change="handleCheckAllChange"></el-checkbox>全选</div><div style="margin-top:10px"><div class="openShow" @click="openShow = !openShow"><span><img:class="openShow ? 'openShow_transition' : ''"src="@/assets/svg/icon_展开.svg"/><span v-show="!openShow" style="cursor: pointer;">展开</span><span v-show="openShow" style="cursor: pointer;">收起</span></span></div></div></div><div><CFlex class="project_info_content"><div class="project_info_content_dataa " ><CollapseTransition><divv-show="openShow"class="project_info_content_dataa"style="width:100%;padding:10px;overflow:visible"><divclass="table-body"v-for="(partition, partitionIndex) in distributorsInfo":key="partitionIndex"><div class="selection" style="z-index:0px"><el-checkbox:indeterminate="partition.indeterminate"v-model="partition.selected"@change="handleCheckedCountryAllChange(partitionIndex,partition,$event)":key="partitionIndex"></el-checkbox><span @click="isopenshow(partitionIndex)">{{ partition.value }}</span></div><div class="width265" v-if="partition.actived" style="z-index:1000px" ><el-checkboxv-for="children in partition.children":key="children.value"v-model="children.selected"@change="handleCheckedCountryChange(partitionIndex,children,$event)":label="children">{{ children.value }}</el-checkbox></div></div></div></CollapseTransition></div></CFlex></div></div></div><!-- Table 栏 --><div style="margin-top:20px;"><div class="top_box" style=" font-weight: bold;">选择药品</div><div class="top_box" style=" font-weight: bold;"><div class="search"><div class="search_content"><Form :model="formItem" :label-width="85" inline><FormItem label="疾病种类:" style="margin-bottom:0px;"><Input v-model.trim="searchData.virustype" /></FormItem><FormItem label="药品名称:" style="margin-bottom:0px;"><Input v-model.trim="searchData.drugstype" /></FormItem></Form></div><div class="search_btns"><CButton type="default" @click.native="reset">重置</CButton><CButtontype="primary"@click.native="searchUserData()"style="margin-left: 8px;width:0px;height:0px">查找</CButton></div></div></div></div><Tableclass="table"ref="selection":columns="columns4":data="data1"@on-selection-change="handleSelectAll"@on-select-cancel="cancel"@on-select="change"></Table><div class="page_bottom"><Page:total="count"@on-change="onchangePage":page-size="pageSize":current="page"></Page></div><div class="vw_bottom"><CButton @click.native="remove" style="padding-right:10px;">取消</CButton><CButton type="primary" @click.native="Submit">保存</CButton></div></div>
</template>
<script>
import Api from "../../api/isip/hundredcitiesactuarial";
import ChinaAddressV4Data from "@/datas/china_address_other";
import CollapseTransition from "@/components/transition/collapse-transition";
// import api from '../schedulePlan/actuarialModel/api';
export default {name: "edithundredcity",components: {CollapseTransition,},data() {return {city: [],projectid: this.$route.query.projectId,versionId: "v01",//省province: "",//市citys: "",// actuaryCityInfos: [],// 多选// sonIdlist: [],// sonId:'',openShow: true,distributorsInfo: "",ischeckAll: false,indeterminate: false,// 多选数据回收overalldata: [],// 展开与隐藏Provinces: ChinaAddressV4Data,// table 数据searchData: {virustype: "",drugstype: "",},page: 1,pageSize: 10,count: 0, //总条数columns4: [{type: "selection",width: 60,align: "center",},{title: "商品名",key: "drugN",align: "center",},{title: "通用名",key: "drugName",align: "center",},{title: "厂商",key: "drugProductor",align: "center",},{title: "疾病种类",key: "cancerType",align: "center",},{title: "适应症限制",key: "indication",align: "center",},{title: "选药优先级",key: "chooseDrugPri",align: "center",},],data1: [],ids: [],idss: [],};},mounted() {this.getCitys();this.querylist();this.getActuaryDrugSalesInfos();},methods: {querylist() {let data = {cancerType: this.searchData.virustype,drugName: this.searchData.drugstype,pageSize: this.pageSize,page: this.page,};new Promise((resolve, reject) => {Api.getChoosedDrugInfos(data).then((response) => {this.data1 = response.result.records.map((item) => {item._checked = (this.ids && this.ids.includes(item.id)) || false;return item;});this.count = response.result.total;}).catch((error) => {reject(error);});});},citydelete(index) {this.city.splice(index, 1);},// clear() {//   console.log("清除");// },reset() {(this.searchData.virustype = ""),(this.searchData.drugstype = ""),this.querylist();},//查找searchUserData() {let data = {cancerType: this.searchData.virustype,drugName: this.searchData.drugstype,pageSize: this.pageSize,page: this.page,};console.log(this.ids);new Promise((resolve, reject) => {Api.getChoosedDrugInfos(data).then((response) => {this.data1 = response.result.records.map((item) => {item._checked = (this.ids && this.ids.includes(item.id)) || false;return item;});}).catch((error) => {reject(error);});});},// 全选反选handleSelectAll(status) {status.forEach((item)=>{this.ids.push(item.id)})// this.ids = status},//勾选change(item) {item.forEach((data) => {this.idss.push(data.id);});for (let i = 0; i < this.idss.length; i++) {if (this.ids.indexOf(this.idss[i]) == -1) {this.ids.push(this.idss[i]);}}},//取消勾选cancel(item, row) {let index = this.ids.indexOf(row.id);this.ids.splice(index, 1);},onchangePage(page) {this.page = page;this.querylist();},remove() {this.$router.push({path: "/hundredactuarial",});},Submit() {this.$Spin.show({render: (h) => {return h("div", [h("Icon", {class: "demo-spin-icon-load",props: {type: "ios-loading",size: 18,},}),h("div", "系统努力运算中,请稍等…"),]);},});setTimeout(() => {this.$Spin.hide();}, 2000);let arr = [];this.distributorsInfo.map((item) => {item.children.map((cityitem) => {let isd = {};if (cityitem.selected) {isd.province = item.value;isd.city = cityitem.value;arr.push(isd);}});});let data = {actuaryCityInfos: arr,ids: this.ids,};// if(this.ids=[]){//   this.$Modal.info('药品没选')// }// if(this.actuaryCityInfos = []){//     this.$Modal.info('城市没有选择')// }// if(data = []){//   this.$Modal.info('请选择您的城市和药品')// }new Promise((reslove, resject) => {Api.saveActuaryWord(data).then((rp) => {this.$router.go(-1);}).catch((error) => {});});},// 多选handleCheckAllChange(e) {//一级change事件this.ischeckAll = e;this.indeterminate = false;for (var i = 0, len = this.distributorsInfo.length; i < len; i++) {//二级全选反选this.distributorsInfo[i].selected = e;this.distributorsInfo[i].indeterminate = false; //去掉二级不确定状态for (var j = 0, len1 = this.distributorsInfo[i].children.length;j < len1;j++) {//三级全选反选this.distributorsInfo[i].children[j].selected = e;}}},handleCheckedCountryAllChange(index, sonId, e) {console.log("父级", index, sonId, e);//二级change事件this.distributorsInfo[index].selected = e; //二级勾选后,子级全部勾选或者取消this.distributorsInfo[index].indeterminate = false; //去掉二级不确定状态var childrenArray = this.distributorsInfo[index].children;if (childrenArray)for (var i = 0, len = childrenArray.length; i < len; i++)childrenArray[i].selected = e;this.getIsCheckAll();//省// if (sonId.selected == true) {//   this.distributorsInfo.push(sonId);// }},handleCheckedCountryChange(topIndex, sonId, e) {console.log("子级", topIndex, sonId, e);//三级change事件var childrenArray = this.distributorsInfo[topIndex].children;var tickCount = 0,unTickCount = 0,len = childrenArray.length;for (var i = 0; i < len; i++) {if (sonId == childrenArray[i].value) childrenArray[i].selected = e;if (childrenArray[i].selected == true) tickCount++;if (childrenArray[i].selected == false) unTickCount++;}if (tickCount == len) {//三级级全勾选this.distributorsInfo[topIndex].selected = true;this.distributorsInfo[topIndex].indeterminate = false;} else if (unTickCount == len) {//三级级全不勾选this.distributorsInfo[topIndex].selected = false;this.distributorsInfo[topIndex].indeterminate = false;} else {this.distributorsInfo[topIndex].selected = false;this.distributorsInfo[topIndex].indeterminate = true; //添加二级不确定状态}this.getIsCheckAll();//    if (sonId.selected == true){//       this.distributorsInfo.push(sonId);//  }},getIsCheckAll() {var tickCount = 0,unTickCount = 0,indeterminateCount = 0,ArrLength = this.distributorsInfo.length;for (var j = 0; j < ArrLength; j++) {//全选checkbox状态if (this.distributorsInfo[j].selected == true) tickCount++;if (this.distributorsInfo[j].selected == false) unTickCount++;if (this.distributorsInfo[j].indeterminate == true)indeterminateCount++;}if (tickCount == ArrLength) {//二级全勾选this.ischeckAll = true;this.indeterminate = false;} else if (unTickCount == ArrLength) {//二级全不勾选this.ischeckAll = false;if (indeterminateCount > 0) {this.indeterminate = true;} else {this.indeterminate = false;}} else {this.ischeckAll = false;this.indeterminate = true; //添加一级不确定状态}},// 展示与隐藏isopenshow(activedIndex) {this.distributorsInfo.filter(function(value, index, arr) {return activedIndex === index? (value.actived = !value.actived): (value.actived = false);});},//省市egetCitys() {new Promise((reslove, resject) => {Api.getCitys().then((rp) => {let arr = [];rp.result.map((item) => {let a = {};a.actived = false;a.selected = false;a.value = item.city;a.children = [];arr.push(a);item.children.map((item) => {let b = {};b.selected = false;b.value = item.city;a.children.push(b);});});this.distributorsInfo = arr;this.getActuaryDrugSalesInfos(this.distributorsInfo);}).catch((error) => {});});},//回显数据getActuaryDrugSalesInfos(arry) {console.log(arry);let data = {};return new Promise((resolve, resject) => {Api.getActuaryDrugSalesInfos(data).then((rp) => {console.log(rp);//回显的数据// this.distributorsInfo = rp.result.actuaryCityInfoslet data = rp.result.actuaryCityInfos;data.forEach((item) => {if (this.city.indexOf(item.province) == -1) {this.city.push(item.province);}arry.forEach((it) => {if (item.province == it.value) {it.selected = true;}it.children.forEach((im) => {if (item.city == im.value) {im.selected = true;}});});});}).catch((error) => {});});},},
};
</script>
<style lang="less" scoped>
@import "hundrecity.less";
.page_title {font-size: 25px;color: #333333;font-weight: 500;
}
.main_tableau {position: relative;margin-top: 10px;padding: 10px;
}
/deep/ .cus_btn_primary {width: 150px;height: 50px;
}
.top_box {font-size: 18px;margin-top: 8px;.margin_citys {padding: 7px;font-size: 15px;font-weight: bold;background: #eeeeee;margin-right: 20px;.margin_citys_delete {background: #ccc;padding: 2px;cursor: pointer;border-radius: 15px;color: #ffffff;display: inline-block;height: 15px;line-height: 10px;}}.margin_c_d {cursor: pointer;color: white;padding: 10px 30px;font-size: 15px;font-weight: bold;background: #156cee;border-radius: 15px;margin-right: 20px;}
}
</style>
<style lang="less" scoped>
.content {margin-top: 20px;width: 100%;z-index: 0px !important;.content_between {border-top-left-radius: 8px;border-top-right-radius: 8px;padding: 5px 10px;box-shadow: 1px 1px 5px 0 #a0a0a0;border-bottom: 1px solid #ccc;display: flex;justify-content: space-between;}
}
.project_info_content {box-shadow: 1px 1px 5px 0 #a0a0a0;border-bottom-left-radius: 8px;border-bottom-right-radius: 8px;border-top: none;background: #ffffff;position: relative;transition: max-height 1s;max-height: 500px;.project_info_content_data {display: flex;flex-wrap: wrap;// z-index: 0;// justify-content: space-between;> div {min-width: 150px;}}.project_info_content_dataa{display: flex;flex-wrap: wrap;> div {min-width: 150px;}}.openShow {position: absolute;bottom: 20px;left: 20px;cursor: pointer;color: #156cee;user-select: none;img {transform: rotate(0deg);transition: transform 0.3s;}}
}
.openShow_transition {transform: rotate(180deg) !important;
}
.ivu-checkbox-wrapper {cursor: pointer;font-size: 14px;display: inline-block;padding-top: 10px;margin-right: 70px;
}
// table
.search {display: flex;padding: 10px 0;.search_content {.item_class {width: 250px;padding: 5px;}}.search_item {width: 200px;margin-right: 20px;margin-bottom: 15px;}.search_btns {display: flex;}
}
/deep/ .cus_btn_primary {width: 60px;height: 35px;
}
.page_bottom {display: flex;justify-content: flex-end;padding-bottom: 10px;
}
.table {border-radius: 8px;box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.1);margin-bottom: 20px;
}
.vw_bottom {position: absolute;bottom: -30px;right: 10px;/* margin-bottom: 10px; */padding-bottom: 5px;
}
.chec_box {padding: 10px 0;// padding-right: 50px;// position: relative;
}
.table-body {position: relative;.selection {padding: 5px 0;cursor: pointer;}.width265 {width: 250px;padding: 10px;border-radius: 10px;z-index: 10 !important;background: #ffffff;box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.1);position: absolute;}
}
</style>
<style lang="less" scoped>
.demo-spin-icon-load {animation: ani-demo-spin 1s linear infinite;
}
/deep/ .project_info_content_dataa{visibility: visible !important;overflow: visible !important;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/247822.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jquery操作select(取值,设置选中)

jquery操作select(增加&#xff0c;删除&#xff0c;清空) http://huapengpeng1989412.blog.163.com/blog/static/58828754201342841940720/ jQuery获取Select选择的Text和Value: 123456789$("#select_id").change(function(){//code...}); //为Select添加事件&am…

手机验证码获取

<el-form-item label"短信验证码" required><el-input v-model"ruleForm.verificationcode" placeholder"请添加验证码"><el-button v-if"isdisabled" slot"suffix" style"color:#409EFF;" type&…

关于RGB屏调试的一些知识(转)

关于RGB屏调试的一些知识转载于:https://www.cnblogs.com/LittleTiger/p/10983212.html

在bootstrap table中使用Tooltip

//偏好主题function preferenceFormatter(value, row, index) {var nameString "";if (value.length > 6) {nameString value.substring(0,6) ...;} else{nameString value;}return [<a href"#" data-toggle"tooltip" title value >…

实现值两者之间添加 , 、 | 等字符

展示效果&#xff1a; <span v-for"(item, index) in projectData.bdOwnerList" :key"index"><span style"white-space: nowrap">{{ item.userName }}<spanv-if"projectData.bdOwnerList.length - 1 ! index"style&qu…

spring-cloud搭建

1、myApplicaion 启动服务类上层必须有一层包 2、报错 com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect 或者com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known…

JS ===和==区别

这是一种隐式类型转换 var a 12; var b 12; alert(a b);//先把两边的转换成一样的&#xff0c;再进行比较 。结果会返回true alert(a b);//不转换两边类型&#xff0c;直接比较,结果返回false

单页面轮播图滚动

现在网上好多类似的效果&#xff0c;今天心情好&#xff0c;就私自模仿一个去&#xff0c;代码如下。 单页面网站 网站首页公司简介公司产品公司荣誉招聘英才联系我们window.οnscrοllfunction(){ var scTopdocument.documentElement.scrollTop||document.body.scrollTop; va…

xBIM 基础16 IFC的空间层次结构

系列目录 【已更新最新开发文章&#xff0c;点击查看详细】 本篇介绍如何从文件中检索空间结构。IFC中的空间结构表示层次结构的嵌套结构&#xff0c;表示项目&#xff0c;站点&#xff0c;建筑物&#xff0c;楼层和空间。如果您查看IFC文档&#xff0c; 您会发现建筑物可以…

如何判断两个jq对象是同一个对象

如果说要判断是否同一对象&#xff0c;当然是用 来判断&#xff0c;但实际上两个不同的 jQuery 对象可能是对同一个/组 DOM 对象的封装&#xff0c;这个时候可以用 is 来判断&#xff0c;比如 var a $(".editor"); var b $(".editor");console.log(a b…

状态管理工具vuex的基本使用(vuebus的理解)

vuex的展示图 1. vuex 的基本结构 const store new Vuex.Store({state: {} //相当于 vue结构中的 data getters: {}, // 相当于vue结构中的计算属性使用actions: {}, // 相当于vue结构中的监听属性使用mutations: {},//相当于vue结构中的 methods 方法集合 &#xff08;其中方…

Memcache

前戏 Memcached是一个高性能的分布式内存对象缓存系统&#xff0c;用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象减少读取数据库的次数&#xff0c;从而减小数据库的压力&#xff0c;提高动态&#xff0c;数据库网站的速度。Memcached基于一个存储 键/值对的…

解决Button自动刷新页面的问题

一、问题 <button class"am-btn am-btn-default am-btn-xs am-text-secondary" data-id"99" data-type1><span class"am-icon-pencil-square-o"></span>修改</button>11 页面上有这样一个按钮&#xff0c;每次点击这个…

Django.1

Django官方网站&#xff1a;https://www.djangoproject.com/ 使用终端创建Django文件 创建工程 django-admin startproject XXX 创建应用 python manage.py startapp YYY 迁移系统指令&#xff1a; 首先生成迁移文件 python manage.py makemigrations 执行迁移文件 python ma…

vue项目水印添加

import DomSize from wd-domsize-monitor; // 此处为 npm 下载的第三方模块包 import Api_login from "/assets/api/login" // 此处是用户信息接口调用var id shuiyinDiv var isInit false let callback function (ele) {DomSize.bind(ele, function () {//水印被…

mybatis传参

在mybatis的学习中&#xff0c;会发现经常需要传参&#xff0c;这里以上一节写的实体类为基础&#xff0c;当我们要添加一个员工时&#xff0c;需要添加员工的基本信息&#xff0c;以及所属部门&#xff0c;按照以前的方法&#xff0c;在实体类中&#xff0c;添加部门id属性&am…

自定义步骤条

展示图&#xff1a; <template><div classcreateorder><!-- 顶部步骤条 --><div class"createorder_top"><div class"createorder_top_left"><!-- 0 --><span class"createorder_left_set" :class"…

jquery让页面滚动到底部

function scrollToEnd(){//滚动到底部var h $(document).height()-$(window).height();$(document).scrollTop(h); }

迭代器

一、定义 1.iterator.(迭代器&#xff09; 2.iterable.&#xff08;可迭代的&#xff09; 一般来说&#xff0c;可以被for循环的就是可以迭代的&#xff0c;迭代器一定可以迭代&#xff0c;但是可迭代的类型不一定是迭代器。 二、说明 1.有__iter__方法&#xff0c;说明可迭代 …

css获取到指定元素的宽度,在回调返回宽度值

<script type"text/javascript">//获取到指定元素的宽度&#xff0c;在回调返回宽度值//通过处理这个value&#xff0c;重新设置新的宽度$(.sixth).css("width",function(index,value){//value带单位&#xff0c;先分解value value.split(px);//返回…