haoxuan
2023-09-21 c87a6f7310ca992d7f058a8f286b095c9a632c90
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
<template>
  <div class="rightContent">
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入产品类型'"
        :amount-view="false"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
      />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView
          ref="tableListRef"
          :table-list="tableList"
          :show-checkcol="false"
          @tableRowClick="tableRowClick"
        ></TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddProductCategoryDialog v-if="editConfig.visible" :productCategoryList="tableList.tableInfomation" @refresh="refresh" :edit-common-config="editConfig" />
  </div>
</template>
 
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getProductCategoryList } from "@/api/product/productCategory"
import AddProductCategoryDialog from "@/views/productManage/productCategory/AddProductCategoryDialog"
 
export default {
  name: "ProductCategory",
  props: {},
  components: { AddProductCategoryDialog },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      searchOptions: [],
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      }
    }
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectBox: true,
        tableColumn: [
          {
            label: "产品类型",
            prop: "name",
            isShowColumn: true,
            default: true
          }
        ]
      }
    },
    // 请求数据
    async getData() {
      await getProductCategoryList({
        keyword: this.keyword,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        if (res.code === 200) {
          const list = res.data?res.data:[]
          this.tableList.tableInfomation = list
          this.pagerOptions.totalCount = res.total
        }
      })
    },
    refresh(){
      this.pagerOptions.currPage=1
      this.getData()
    },
    // 搜索
    getList(val) {
      this.keyword=val;
      this.pagerOptions.currPage=1
      this.getData()
    },
    // 行点击
    tableRowClick(row) {
      this.editConfig.title = "编辑"
      this.editConfig.infomation = { ...row }
      this.editConfig.visible = true
    },
    // 新建
    addBtnClick() {
      this.editConfig.title = "新建"
      this.editConfig.infomation={
        costingMethod:null,
        forceRemovalStrategy:null,
        inventoryValuation:null,
        name:'',
        parentId:null,
      }
      this.editConfig.visible = true
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
// .rightContent {
//   height: 100%;
//   background: #e6ecf2;
//   padding: 10px;
//   .top {
//     margin-bottom: 20px;
//     height: 60px;
//     background: #fff;
//     border-radius: 8px;
//   }
//   .list-view {
//     height: calc(100% - 120px);
//   }
// }
</style>