123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <view>
- <tree :checkList="checkList" :props="prop" @sendValue="confirm" :isCheck="true" :trees="tree" />
-
- <view class="btn box_sizing">
- <button class="sureBtn" type="primary" @click="backConfirm">确认</button>
- </view>
- </view>
- </template>
- <script>
- import {getMaterialTree} from '@/common/api/commonApi.js';
-
- export default {
-
- data() {
- return {
- tree: [],
- checkList: [],
- prop: {
- label: 'name',
- children: 'children',
- multiple:false,
- nodes:true
- }
- }
- },
- onLoad(o) {
- // var that = this
- this.$util.persistLogin(this);
- },
- created:function(){
- let classCode=this.$util.getQuery("classCode");
- this.getMaterialTree(classCode);
- },
- updated:function(){
-
- },
- mounted:function(){
-
- },
- methods: {
- //检查默认选中,要是字段钟本身包含了checked字段就不需要这个
- checks() {
- var that = this;
- for (var i = 0, len = that.tree.length; i < len; i++) {
- for (var j = 0, lens = that.checkList.length; j < lens; j++) {
- if (that.checkList[j].id === that.tree[i].id) {
- that.$set(that.tree[i], 'checked', true)
- break
- } else {
- that.$set(that.tree[i], 'checked', false)
- }
- }
- }
- },
- //获取选中的
- confirm(val) {
- this.checkList = val
- console.log(this.checkList,588)
- },
- backConfirm() {
- var pages = getCurrentPages();
- var currPage = pages[pages.length - 1]; //当前页面
- //var prevPage = pages[pages.length - 2]; //上一个页面
- //h5写法
- //prevPage.query = this.checkList;
- console.info('prevPage.query ',this.checkList);
- uni.$emit("outtype",this.checkList);
- //return;
- //小程序写法
- //prevPage.$vm.query =this.checkList;
- uni.navigateBack();
- },
- getMaterialTree(classCode){
- let that=this;
- return new Promise((resolve,reject)=>{
- getMaterialTree(classCode).then(
- (res)=>{
- console.info(JSON.stringify(res));
- //that.tree=res;
- res.forEach((item,index,array)=>{
- that.$set(that.tree,index,item);
- });
- console.info(that.tree);
- resolve('suc');
-
- }).catch((err)=>{
- reject(err);
- });
- })
-
- },
-
-
- }
- }
- </script>
- <style lang="scss">
- .box_sizing {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- }
- .btn {
- position: fixed;
- bottom: 0;
- padding: 10px;
- background-color: #fff;
- width: 100%;
- .sureBtn {
- background-color: #007AFF;
- color: #fff;
- }
- }
-
- .btn1 {
- position: fixed;
- bottom: 600px;
- padding: 10px;
- background-color: #fff;
- width: 100%;
-
- }
- .btn2 {
- position: fixed;
- bottom: 150px;
- padding: 10px;
- background-color: #fff;
- width: 100%;
-
- }
- </style>
|