|
@@ -3,8 +3,11 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
<el-col :span="24" class="one"> <span>平台活动商品添加</span> </el-col>
|
|
|
- <el-col :span="24" class="two">
|
|
|
- <el-autocomplete v-model="goods" :fetch-suggestions="querySearchAsync" placeholder="请输入商品名称" @select="handleSelect"></el-autocomplete>
|
|
|
+ <el-col :span="4" class="two">
|
|
|
+ <!-- <el-autocomplete v-model="goods" :fetch-suggestions="querySearchAsync" placeholder="请输入商品名称" @select="handleSelect"></el-autocomplete> -->
|
|
|
+ <el-input placeholder="请输入商品名称" v-model="goods">
|
|
|
+ <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
|
|
|
+ </el-input>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="thr">
|
|
|
<el-button type="primary" size="mini" @click="toBack()">返回</el-button>
|
|
@@ -50,49 +53,57 @@ export default {
|
|
|
total: 0,
|
|
|
// 商品搜索
|
|
|
goods: '',
|
|
|
- goodsList: [],
|
|
|
- timeout: null,
|
|
|
+ // goodsList: [],
|
|
|
+ // timeout: null,
|
|
|
// 商品状态
|
|
|
statusList: [],
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
|
await this.searchOther();
|
|
|
- await this.search();
|
|
|
+ // await this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
...dictData({ dictQuery: 'query' }),
|
|
|
...goods({ gQuery: 'query' }),
|
|
|
...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
// 查询
|
|
|
- async search() {
|
|
|
- let res = await this.gQuery();
|
|
|
+ // async search() {
|
|
|
+ // let res = await this.gQuery();
|
|
|
+ // if (this.$checkRes(res)) {
|
|
|
+ // for (const val of res.data) {
|
|
|
+ // val.value = val.name;
|
|
|
+ // }
|
|
|
+ // this.$set(this, 'goodsList', res.data);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ if (this.goods) info.name = this.goods;
|
|
|
+ let res = await this.gQuery({ skip, limit, ...info });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- for (const val of res.data) {
|
|
|
- val.value = val.name;
|
|
|
- }
|
|
|
- this.$set(this, 'goodsList', res.data);
|
|
|
+ this.$set(this, 'list', res.data);
|
|
|
+ this.$set(this, 'total', res.total);
|
|
|
}
|
|
|
},
|
|
|
// 点击选中
|
|
|
- handleSelect(item) {
|
|
|
- this.list.push(item);
|
|
|
- this.$set(this, 'total', 1);
|
|
|
- },
|
|
|
+ // handleSelect(item) {
|
|
|
+ // this.list.push(item);
|
|
|
+ // this.$set(this, 'total', 1);
|
|
|
+ // },
|
|
|
//获取搜索商品信息
|
|
|
- querySearchAsync(queryString, cb) {
|
|
|
- var goodsList = this.goodsList;
|
|
|
- var results = queryString ? goodsList.filter(this.createStateFilter(queryString)) : goodsList;
|
|
|
- clearTimeout(this.timeout);
|
|
|
- this.timeout = setTimeout(() => {
|
|
|
- cb(results);
|
|
|
- }, 3000 * Math.random());
|
|
|
- },
|
|
|
- createStateFilter(queryString) {
|
|
|
- return (state) => {
|
|
|
- return state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
|
|
|
- };
|
|
|
- },
|
|
|
+ // querySearchAsync(queryString, cb) {
|
|
|
+ // var goodsList = this.goodsList;
|
|
|
+ // var results = queryString ? goodsList.filter(this.createStateFilter(queryString)) : goodsList;
|
|
|
+ // clearTimeout(this.timeout);
|
|
|
+ // this.timeout = setTimeout(() => {
|
|
|
+ // cb(results);
|
|
|
+ // }, 3000 * Math.random());
|
|
|
+ // },
|
|
|
+ // createStateFilter(queryString) {
|
|
|
+ // return (state) => {
|
|
|
+ // return state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
|
|
|
+ // };
|
|
|
+ // },
|
|
|
// 新增
|
|
|
async toAdd({ data }) {
|
|
|
let form = { platformAct: this.id, shop: data.shop._id, goods: data._id };
|
|
@@ -129,7 +140,7 @@ export default {
|
|
|
test: {
|
|
|
deep: true,
|
|
|
immediate: true,
|
|
|
- handler(val) { },
|
|
|
+ handler(val) {},
|
|
|
},
|
|
|
},
|
|
|
};
|