hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
  <el-dialog
    title="添加商品"
    :visible="value"
    width="60%"
    :modal="false"
    :show-close="false"
    :before-close="onCancel"
  >
    <div class="custom-box">
      <div class="serachContent">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item>
            <el-input v-model="ShopkeyWord" style="width:350px" size="small" placeholder="请输入话题、发布人、发布内容等关键词进行查看"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button size="small" type="primary" @click="onSearch()">查询</el-button>
            <el-button size="small" @click="Reset()">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="tableBox">
        <my-eltable
          id="printTable"
          ref="mt"
          :paginationDataSource="tableData"
          :tabheight="tabheight"
          :tableHeader="tableHeader"
          :loading="loading"
          :checkbox="checkboxTable"
          :isIndex="isIndex"
          @onPageSizeChange="onPageSizeChange"
          @onPaginationChange="onPaginationChange"
          @onSelectionChange="onSelectionChange"
        >
          <template v-slot:icon="{scope}">
            <span><img :src="scope.image" class="shop-image"></span>
          </template>
        </my-eltable>
      </div>
    </div>
    <!-- 底部按钮 -->
    <span slot="footer" class="dialog-footer">
      <el-button @click="onCancel">取 消</el-button>
      <el-button type="primary" @click="onOk()">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
// import MyEltable from '@/components/table/table';
// import * as interactionServer from '@/services/onlineInteractionService';
export default {
  name: 'Index',
  components: { MyEltable },
  props: {
    value: { type: Boolean }
  },
  data() {
    return {
      tableData: {},
      loading: false,
      checkboxTable: true,
      isIndex: true,
      shopId: [],
      tabheight: '100%',
      tableHeader: [
        { label: '所属商家', prop: 'merchantId' },
        { label: '商品名称', prop: 'merchantName' },
        { label: '商品图片', slot: 'icon' },
        { label: '商品价格', prop: ' price' }
      ],
      ShopkeyWord: '',
      /** 分页参数 */
      paginationParams: {
        currentPage: 1,
        pageSize: 5,
        total: 0
      }
    };
  },
 
  mounted() {
    this.init();
  },
  methods: {
    onCancel () {
      this.$emit('change', false);
    },
    async onOk() {
      if (this.shopId.length > 1) {
        return this.$message({
          message: '只能添加一个商品',
          type: 'warning'
        });
      }
      const params = {
        pageNum: this.paginationParams.currentPage,
        pageSize: this.paginationParams.pageSize,
        keyword: this.ShopkeyWord,
        productId: this.shopId[0].id
      }
      await interactionServer.getShop(params);
      this.$message('添加成功')
      this.$emit('success', this.shopId);
    },
    onSelectionChange(val) {
      this.shopId = val;
      console.log(this.shopId)
    },
    /** pageSize 改变时会触发 */
    onPageSizeChange (pageSize) {
      this.paginationParams.pageSize = pageSize;
      this.init();
    },
    /** 分页 */
    onPaginationChange (page) {
      this.paginationParams.currentPage = page;
      this.init();
    },
 
    onSearch() {
      this.init();
    },
    Reset() {
      this.ShopkeyWord = '';
      this.init();
    },
 
    async init() {
      const params = {
        pageNum: this.paginationParams.currentPage,
        pageSize: this.paginationParams.pageSize,
        keyword: this.ShopkeyWord
      }
      const res = await interactionServer.getShop(params)
      this.tableData = res;
    }
  }
};
</script>
<style lang="less" scoped>
  // @import '../../../../styles/table.less';
  .shop-image {
    width: 60px;
    height: 60px;
    display: inline-block;
  }
</style>