feature_0521
郑皇 5 years ago
parent 44d787ebac
commit 4715dc2d6e

@ -1,41 +1,29 @@
<template> <template>
<div style="padding: 0 40px;"> <div style="padding: 0 40px;">
<div class="selectClass"> <div class="selectClass">
<Checkbox :indeterminate="indeterminate" <Checkbox
:indeterminate="indeterminate"
:value="allSelect" :value="allSelect"
@click.prevent.native="handleCheckAll">&nbsp;&nbsp;&nbsp;全选</Checkbox> @click.prevent.native="handleCheckAll"
<i-input icon="search" >&nbsp;&nbsp;&nbsp;全选</Checkbox>
@on-change="doSearch" <i-input icon="search" @on-change="doSearch" placeholder="请输入零售公司名称" style="width: 250px"></i-input>
placeholder="请输入零售公司名称"
style="width: 250px"></i-input>
</div> </div>
<div class="companyTable"> <div class="companyTable">
<div class="companyListClass"> <div class="companyListClass">
<Row :gutter="10"> <Row :gutter="10">
<div v-show="loading" <div v-show="loading" style="padding: 50px 0" class="loading">
style="padding: 50px 0"
class="loading">
<Spin fix>加载中...</Spin> <Spin fix>加载中...</Spin>
</div> </div>
<CheckboxGroup size="large" <CheckboxGroup size="large" @on-change="onChange" v-model="checkCompanys">
@on-change="onChange" <i-col span="8" v-if="!item.hide" :key="index" v-for="(item, index) in companyList">
v-model="checkCompanys"> <Checkbox size="large" :label="item.value" border>
<i-col span="8"
v-if="!item.hide"
:key="index"
v-for="(item, index) in companyList">
<Checkbox size="large"
:label="item.value"
border>
<span>{{ item.label }}</span> <span>{{ item.label }}</span>
</Checkbox> </Checkbox>
</i-col> </i-col>
</CheckboxGroup> </CheckboxGroup>
</Row> </Row>
</div> </div>
<Spin size="large" <Spin size="large" fix v-if="loading"></Spin>
fix
v-if="loading"></Spin>
</div> </div>
</div> </div>
</template> </template>
@ -44,7 +32,7 @@ import ActivityManager from "../../services/ActivityManager/ActivityManager";
import store from "../../store/index"; import store from "../../store/index";
export default { export default {
name: "useActivityStepTwo", name: "useActivityStepTwo",
data () { data() {
return { return {
indeterminate: false, indeterminate: false,
allSelect: false, allSelect: false,
@ -52,29 +40,33 @@ export default {
companyListdata: [], companyListdata: [],
checkCompanys: [], checkCompanys: [],
orginCompanyList: [], orginCompanyList: [],
loading: false, loading: false
}; };
}, },
mounted () { mounted() {
let _this = this; let _this = this;
console.log(111, store.getters.useData); console.log(111, store.getters.useData);
if (store.getters.useData.company) { if (
store.getters.useData.company.forEach((item) => { store.getters.useData.company &&
store.getters.useData.company.length > 0
) {
store.getters.useData.company.forEach(item => {
if (_this.checkCompanys.indexOf(item.id) == -1) { if (_this.checkCompanys.indexOf(item.id) == -1) {
_this.checkCompanys.push(item.id); _this.checkCompanys.push(item.id);
} }
}); });
} else if (store.getters.useData.stores) { } else if (store.getters.useData.stores) {
store.getters.useData.stores.forEach((item) => { store.getters.useData.stores.forEach(item => {
console.log(112221, item.parentId);
if (item.parentId && _this.checkCompanys.indexOf(item.parentId) == -1) { if (item.parentId && _this.checkCompanys.indexOf(item.parentId) == -1) {
_this.checkCompanys.push(item.parentId); _this.checkCompanys.push(item.parentId);
} }
}); });
} }
this.getCompanyInfo() this.getCompanyInfo();
}, },
methods: { methods: {
onChange (data) { onChange(data) {
let _this = this; let _this = this;
if (data.length === this.companyList.length) { if (data.length === this.companyList.length) {
this.indeterminate = false; this.indeterminate = false;
@ -87,58 +79,58 @@ export default {
this.allSelect = false; this.allSelect = false;
} }
store.getters.useData.company = []; store.getters.useData.company = [];
data.forEach((item) => { data.forEach(item => {
const c = _this._.find( const c = _this._.find(_this.companyListdata, shop => shop.id == item);
_this.companyListdata,
(shop) => shop.id == item
);
if (c) { if (c) {
store.getters.useData.company.push(c); store.getters.useData.company.push(c);
} }
}); });
}, },
doSearch (e) { doSearch(e) {
const keyword = e.target.value; const keyword = e.target.value;
let that = this; let that = this;
if (keyword.length > 0) { if (keyword.length > 0) {
that.companyList.forEach((item) => { that.companyList.forEach(item => {
if (item.label.indexOf(keyword) == -1) { if (item.label.indexOf(keyword) == -1) {
item.hide = true; item.hide = true;
} }
}); });
} else { } else {
that.companyList.forEach((item) => { that.companyList.forEach(item => {
item.hide = false item.hide = false;
}); });
} }
this.$forceUpdate(); this.$forceUpdate();
console.log(1, that.companyList) console.log(1, that.companyList);
}, },
getCompanyInfo () { getCompanyInfo() {
let that = this; let that = this;
let data = { let data = {
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId, userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId
}; };
this.loading = true; this.loading = true;
ActivityManager.getCompany(data, function (data) { ActivityManager.getCompany(data, function(data) {
that.companyList = []; that.companyList = [];
that.companyListdata = data.data.results; that.companyListdata = data.data.results;
if (store.getters.useData.company && store.getters.useData.company.length == that.companyListdata.length) { if (
store.getters.useData.company &&
store.getters.useData.company.length == that.companyListdata.length
) {
that.allSelect = true; that.allSelect = true;
} }
data.data.results.forEach((element) => { data.data.results.forEach(element => {
that.companyList.push({ that.companyList.push({
label: element.name, label: element.name,
value: element.id, value: element.id
}); });
that.orginCompanyList = that.companyList; that.orginCompanyList = that.companyList;
}); });
store.getters.useData.company = []; store.getters.useData.company = [];
console.log(123, that.checkCompanys, that.companyListdata) console.log(123, that.checkCompanys, that.companyListdata);
that.checkCompanys.forEach((item) => { that.checkCompanys.forEach(item => {
const c = that._.find( const c = that._.find(
that.companyListdata, that.companyListdata,
(company) => company.id == item company => company.id == item
); );
if (c) { if (c) {
store.getters.useData.company.push(c); store.getters.useData.company.push(c);
@ -147,7 +139,7 @@ export default {
that.loading = false; that.loading = false;
}); });
}, },
handleCheckAll () { handleCheckAll() {
let _this = this; let _this = this;
if (this.indeterminate) { if (this.indeterminate) {
this.allSelect = false; this.allSelect = false;
@ -158,24 +150,24 @@ export default {
if (this.allSelect) { if (this.allSelect) {
this.checkCompanys = []; this.checkCompanys = [];
this.companyList.forEach((item) => { this.companyList.forEach(item => {
this.checkCompanys.push(item.value); this.checkCompanys.push(item.value);
}); });
} else { } else {
this.checkCompanys = []; this.checkCompanys = [];
} }
store.getters.useData.company = []; store.getters.useData.company = [];
this.checkCompanys.forEach((item) => { this.checkCompanys.forEach(item => {
const c = _this._.find( const c = _this._.find(
_this.companyListdata, _this.companyListdata,
(company) => company.id == item company => company.id == item
); );
if (c) { if (c) {
store.getters.useData.company.push(c); store.getters.useData.company.push(c);
} }
}); });
}, }
}, }
}; };
</script> </script>

@ -107,7 +107,7 @@
<Button type="primary" @click="okMini"></Button> <Button type="primary" @click="okMini"></Button>
</div> </div>
</Modal> </Modal>
<selectStoreStep @doShow="doShow" :schedule="welcome" :show="showStoreCheck"></selectStoreStep> <selectStoreStep :isModify="id>0" @doShow="doShow" :schedule="welcome" :show="showStoreCheck"></selectStoreStep>
</div> </div>
</template> </template>
@ -166,7 +166,7 @@ export default {
}, },
created() { created() {
this.id = this.$route.query.id; this.id = this.$route.query.id;
store.commit("SET_useData", { ...store.getters.useData, ...this.welcome }); // store.commit("SET_useData", { ...store.getters.useData, ...this.welcome });
console.log(this.$route); console.log(this.$route);
if (this.id) { if (this.id) {
this.getDetail(this.id); this.getDetail(this.id);
@ -189,14 +189,19 @@ export default {
}, },
res => { res => {
_this.welcome = res.data.results; _this.welcome = res.data.results;
store.commit("SET_useData", {
...store.getters.useData,
...this.welcome
});
} }
); );
}, },
showStores() { showStores() {
console.log({ ...store.getters.useData, ...this.welcome }); console.log({ ...store.getters.useData, ...this.welcome });
store.commit("SET_useData", { store.commit("SET_useData", {
...store.getters.useData, ...this.welcome,
...this.welcome ...store.getters.useData
}); });
this.showStoreCheck = true; this.showStoreCheck = true;
}, },

@ -103,7 +103,7 @@ export default {
http.getWelcomeList(params, res => { http.getWelcomeList(params, res => {
const data = res.data.results.this || {}; const data = res.data.results.this || {};
this.data = data.list || []; this.data = data.list || [];
this.totalSize = data.total || 0; this.total = data.total || 0;
this.loading = false; this.loading = false;
}); });
}, },

Loading…
Cancel
Save