You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-front/src/pages/activity/useActivityStepThree.vue

206 lines
5.6 KiB
Vue

6 years ago
<template>
<div style="padding: 0 40px;">
<div class="selectClass">
5 years ago
<Checkbox :indeterminate="indeterminate"
:value="allSelect"
@click.prevent.native="handleCheckAll">&nbsp;&nbsp;&nbsp;全选</Checkbox>
<i-input icon="search"
@on-change="doSearch"
placeholder="请输入店铺名称"
style="width: 250px"></i-input>
6 years ago
</div>
<div class="companyTable">
<div class="companyListClass">
5 years ago
<Row :gutter="10">
5 years ago
<div v-if="loading"
style="padding: 50px 0"
class="loading">
5 years ago
<Spin fix>加载中...</Spin>
</div>
5 years ago
<CheckboxGroup size="large"
@on-change="onChange"
v-model="isSelect">
<i-col span="8"
v-if="!item.hide && index < block"
:key="index"
v-for="(item, index) in shopList">
<Checkbox size="large"
:label="item.value"
border>
<span :title="item.label">{{ item.label.substr(0, 18) }}</span>
5 years ago
</Checkbox>
</i-col>
</CheckboxGroup>
</Row>
6 years ago
</div>
5 years ago
<Spin size="large"
fix
v-if="loading"></Spin>
<Button type="info"
long
v-if="block < orginShopList.length"
@click="loadMore">加载更多</Button>
6 years ago
</div>
</div>
</template>
<script>
5 years ago
import ActivityManager from "../../services/ActivityManager/ActivityManager";
import store from "../../store/index";
6 years ago
export default {
name: "useActivityStepThree",
5 years ago
data () {
5 years ago
return {
indeterminate: false,
6 years ago
allSelect: false,
5 years ago
selected: [],
shopList: [],
5 years ago
isSelect: [],
6 years ago
selectValue: [],
5 years ago
shopListData: [],
loading: false,
5 years ago
block: 50,
5 years ago
companys: store.getters.useData.company,
5 years ago
orginShopList: []
5 years ago
};
6 years ago
},
5 years ago
props: {
isModify: Boolean
},
5 years ago
mounted () {
5 years ago
this.getShopInfo();
let _this = this;
if (store.getters.useData.stores) {
5 years ago
store.getters.useData.stores.forEach(item => {
5 years ago
_this.isSelect.push(item.id);
});
}
6 years ago
},
methods: {
5 years ago
handleCheckAll () {
5 years ago
let _this = this;
5 years ago
if (this.indeterminate) {
this.allSelect = false;
} else {
this.allSelect = !this.allSelect;
}
this.indeterminate = false;
if (this.allSelect) {
5 years ago
this.isSelect = [];
5 years ago
this.shopList.forEach(item => {
5 years ago
if (this.isSelect.indexOf(item.value) < 0 && item.value) {
this.isSelect.push(item.value);
}
5 years ago
});
} else {
this.isSelect = [];
}
5 years ago
store.getters.useData.stores = [];
5 years ago
this.isSelect.forEach(item => {
const s = _this._.find(_this.shopListData, shop => shop.id == item);
5 years ago
if (s) {
store.getters.useData.stores.push(
5 years ago
_this._.find(_this.shopListData, shop => shop.id == item)
5 years ago
);
}
});
5 years ago
},
5 years ago
doSearch (e) {
5 years ago
const keyword = e.target.value;
let that = this;
5 years ago
that.block = 50;
5 years ago
that.shopList = that.orginShopList;
5 years ago
if (keyword.length > 0) {
5 years ago
that.shopList = that._.filter(that.shopList, item => {
5 years ago
console.log(item.label, keyword)
5 years ago
return item.label.indexOf(keyword) >= 0;
5 years ago
});
} else {
5 years ago
that.shopList = that.orginShopList;
5 years ago
}
5 years ago
this.isSelect = this._.filter(this.isSelect, item => item);
5 years ago
},
5 years ago
onChange (data) {
5 years ago
let _this = this;
5 years ago
data = this._.filter(data, item => item);
5 years ago
if (data.length === this.shopListData.length) {
5 years ago
this.indeterminate = false;
this.allSelect = true;
} else if (data.length > 0) {
this.indeterminate = true;
this.allSelect = false;
} else {
this.indeterminate = false;
this.allSelect = false;
}
store.getters.useData.stores = [];
5 years ago
data.forEach(item => {
const s = _this._.find(_this.shopListData, shop => shop.id == item);
5 years ago
if (s) {
store.getters.useData.stores.push(
5 years ago
_this._.find(_this.shopListData, shop => shop.id == item)
5 years ago
);
}
});
},
5 years ago
loadMore () {
this.block += 50;
},
5 years ago
getShopInfo () {
5 years ago
let that = this;
let companyIds = [];
5 years ago
this.companys.forEach(item => {
5 years ago
companyIds.push(item.id);
});
let data = {
5 years ago
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId,
customerIds: companyIds.join(","),
5 years ago
scheduleId: store.getters.useData.scheduleId
5 years ago
};
5 years ago
if (this.isModify) {
data.scheduleId = null;
}
5 years ago
that.loading = true;
5 years ago
ActivityManager.getShop(data, function (data) {
5 years ago
that.shopList = [];
that.shopListData = data.data.results;
5 years ago
if (store.getters.useData.stores.length == that.shopListData.length) {
that.allSelect = true;
}
5 years ago
data.data.results.forEach(element => {
5 years ago
that.isSelect.push("");
that.selectValue.push("");
that.shopList.push({
label: element.name,
5 years ago
value: element.id
});
5 years ago
that.orginShopList = that.shopList;
});
that.loading = false;
});
5 years ago
}
}
5 years ago
};
6 years ago
</script>
5 years ago
<style scoped>
6 years ago
.selectClass {
display: flex;
justify-content: space-between;
}
.companyTable {
5 years ago
height: 250px;
overflow-y: scroll;
width: 100%;
overflow-x: hidden;
margin-top: 10px;
6 years ago
}
5 years ago
.ivu-checkbox-wrapper.ivu-checkbox-large {
width: 100%;
font-size: 12px;
margin-bottom: 10px;
}
.ivu-checkbox + span {
margin-left: 4px;
6 years ago
}
5 years ago
</style>