实现省市二级联动效果

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

<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&…

在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…

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

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

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"…

element组件库中table自定义分页效果

1.在data中设置初始值 // 页数 页码search: { offset: 1, // 当前页limit: 10, // 条数total:0, //总数},2.设置获取后的数据分配 :data"tableData.slice((search.offset - 1) * search.limit, search.offset * search.limit)" 3.展示效果&#xff1a;

数据轮播图翻页封装(左右点击)

效果图&#xff1a; <template><div class"box" style"height:200px;"><!-- 左 --><div class"box-left" click"submitrote(left)" mouseenter"chenge_menu(1)" mouseleave"chenge_menu(2)"…

087-把PHP数组中的元素按随机顺序重新排列shuffle

<?php$arrarray(3,23,A,f,123,hello); //定义一个数组echo 排序之前的数组信息&#xff1a;<br>;print_r($arr);shuffle($arr); //对数组进行随机排序echo <br>排序之后的数组信息&#xff1a;<br>;print_r($arr); //输出数组信息#…

基于Element ui 实现输入框只能输入数字并支持千分位

实现效果 设置子组件 <template><el-inputref"money"v-model.trim"money":placeholder"placeholder"v-bind"$attrs"v-on"$listeners"input"formatNumber(money,money)"keyup.enter.native"moneyCh…

Vue-使用webpack+vue-cli搭建项目

一、准备 安装NodeJs 安装Webpack 配置环境变量 技巧使用&#xff1a; 1. npm 淘宝路径配置&#xff1a;npm config set registryhttps://registry.npm.taobao.org  2.查看npm命令列表 > $ npm help 二、搭建项目 1、全局安装vue脚手架工具 vue-cli npm install vue…

CSS-合理使用z-index控制盒子视轴高度,解决z-index失效

关于z-index我们的共识 共识一 首先&#xff0c;我们都同意&#xff0c;z-index对于普通盒子是无效的&#xff0c;这里的“普通盒子”是除了下文我会提到的“神奇盒子”外的所有盒子&#xff0c;至于什么是“神奇盒子”请慢慢看。 对于普通盒子&#xff0c;不管z-index值如何&…

Activiti6.0教程 Eclipse安装Activiti Diagram插件(一)

最近这段时间打算出一个Activiti6.0的详细教程&#xff0c;Activiti作为一个流行的开源工作流引擎&#xff0c;正在不断发展&#xff0c;其6.0版本以API形式提供服务&#xff0c;而之前版本基本都是要求我们的应用以JDK方式与其交互&#xff0c;只能将其携带到我们的应用中&…

JS性能优化之文档碎片-document.createDocumentFragment

讲这个方法之前&#xff0c;我们应该先了解下插入节点时浏览器会做什么。 在浏览器中&#xff0c;我们一旦把节点添加到document.body&#xff08;或者其他节点&#xff09;中&#xff0c;页面就会更新并反映出这个变化&#xff0c;对于少量的更新&#xff0c;一条条循…

左右滑动栏

展示效果图&#xff1a; 父 <template><div ref"topBox" class"swiper-in page-container bg-white"><div class"page-body"><drag-box class"drag-box"><div class"relative" :class"{ex…

Active MQ

转载于:https://www.cnblogs.com/ygl888/p/11020647.html

jQuery Ajax 实例

一、$.ajax的一般格式 $.ajax({ type: POST, url: url , data: data , success: success , dataType: dataType }); 二、$.ajax的参数描述 参数 描述 url 必需。规定把请求发送到哪个 URL。 data 可选。映射或字符串值。规定连同请求发送到服务器的数据。 success(data, textSt…