huangsijun
2025-09-22 a78c011de350b188afb03beb2f26a73f35f71986
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<template>
  <!--
        作者:luoyiming
        时间:2020-06-08
        描述:超链接选择-产品
    -->
  <div class="marketing-box">
    <el-tabs v-model="activeTab">
      <el-tab-pane label="详情" name="detail"></el-tab-pane>
    </el-tabs>
 
    <div class="product-list" v-if="activeTab == 'detail'" v-loading="loading">
      <!--搜索表单-->
      <div class="common-seach-wrap">
        <el-form size="small" :inline="true" :model="searchForm" class="demo-form-inline">
          <el-form-item label="商品名称"><el-input size="small" v-model="searchForm.product_name" placeholder="请输入商品名称"></el-input></el-form-item>
          <el-form-item>
            <el-button size="small" icon="el-icon-search" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
 
      <!--内容-->
      <div class="product-content">
        <div class="table-wrap setlink-product-table">
          <el-table size="mini" :data="tableData" border style="width: 100%">
            <el-table-column prop="product_name" label="产品">
              <template slot-scope="scope">
                <div class="product-info">
                  <div class="pic"><img v-img-url="scope.row.image[0].file_path" alt="" /></div>
                  <div class="info">
                    <div class="name text-ellipsis">{{ scope.row.product_name }}</div>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="product_price" label="价格" width="100">
              <template slot-scope="scope">
                <span class="red">{{scope.row.product_price}}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="80">
              <template slot-scope="scope">
                <el-button size="mini" @click="changeFunc(scope.row)">选择</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
 
<script>
import PorductApi from '@/api/product.js';
export default {
  data() {
    return {
      /*是否正在加载*/
      loading: true,
      /*tab切换选择中值*/
      activeTab: 'detail',
      /*产品类别列表*/
      categoryList:[],
      /*当前选中*/
      categoryActive:[],
      /*搜索表单对象*/
      searchForm: {
        product_name: ''
      },
      /*产品数据表*/
      tableData: [],
      /*一页多少条*/
      pageSize: 5,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*选中的页面值*/
      activePage: null
    };
  },
  created() {
 
    /*获取产品类别*/
    this.getData();
 
  },
  watch: {
    activeTab: function(n, o) {
      if (n != o) {
        this.tableData = [];
        if (n == 'detail') {
          this.getData();
        }
      }
    }
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.getData();
    },
 
    /*每页多少条*/
    handleSizeChange(val) {
      this.pageSize = val;
      this.curPage=0;
      this.getData();
    },
 
    /*获取列表*/
    getData() {
      let self = this;
      self.loading = true;
      let Params = {};
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      Params.product_name = self.searchForm.product_name;
      PorductApi.productList(Params, true)
        .then(data => {
          self.loading = false;
          self.tableData = data.data.list.data;
          self.totalDataNumber = data.data.list.total;
          if(self.curPage==1&&self.tableData.length>0){
            self.changeFunc(self.tableData[0]);
          }
        })
        .catch(error => {
          self.loading = false;
        });
    },
 
    /*搜索查询*/
    onSubmit() {
      this.curPage=0;
      this.getData();
    },
 
    /*选中的值*/
    changeFunc(e) {
      let obj={};
      if (this.activeTab == 'detail') {
        obj.name = e.product_name;
        obj.url = 'pages/product/detail/detail?product_id=' + e.product_id;
        obj.type = '商品详情';
      }
 
      this.$emit('changeData', obj);
    }
 
 
  }
};
</script>
<style scoped>
.table-wrap.setlink-product-table .product-info .pic {
  width: 20px;
  height: 20px;
  background: #FFFFFF;
}
 
.table-wrap.setlink-product-table .product-info .pic img {
  width: 20px;
  height: 20px;
}
 
.marketing-box .el-tree-node__content {
  height: 30px;
}
 
.marketing-box .el-tree-node__content {
  margin-bottom: 10px;
}
</style>