futian.liu
2023-12-13 494fbb222f0ec270f764f84f13987984fad09b82
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
<template>
  <win-md title="规格型号" @close="close" :width="'800px'">
    <!--列表-->
    <my-table-v2 ref="myTable" :table="table"/>
    <div slot="footer" align="center" class="dialog-footer">
      <my-button name="取消" site="form" @click="close"/>
    </div>
    <specsAdd v-if="specsSetting.show" :setting="specsSetting" @close="specsSetting.show = false" @search="search"/>
  </win-md>
</template>
 
<script>
import winMd from '@/components/win/win-md'
import myButton from '@/components/myButton/myButton'
import {delSpecs} from "@/api/foudation/material";
import specsAdd from "@/views/foundation/material/specs/specsAdd.vue";
import {mapGetters} from 'vuex'
import MyTableV2 from "@/components/myTable/myTableV2.vue";
import SettingIplatform from "@/utils/settingIplatform";
 
export default {
  name: 'specs',
  components: {MyTableV2, winMd, myButton, specsAdd},
  props: {
    setting: {
      type: Object,
      default: () => {
      }
    }
  },
  data() {
    return {
      specsSetting: {
        title: '',
        id: '',
        show: false,
      },
      // 表格数据
      table: {
        showIndex: true, // 是否显示序号
        expand: false, // 是否显示详情数据
        dataIndex: 'goodsTemplatesId',
        url: SettingIplatform.apiBaseURL + '/pc/base/goods/models/query/goodsModel', // 请求地址
        // 工具条
        tools: {
          columnsCtrl: {// 列控制按钮
            show: false
          },
          generalExport: {// 通用导出按钮
            show: false
          },
          // 自定义工具条按钮
          custom: [
            {
              name: '新增',
              click: () => {
                this.showAdd(null);
              },
            },
          ]
        },
        // 列信息
        columns: [
          {title: '规格型号', field: 'goodsCode', align: 'left', minWidth: 120},
          {title: '单位', field: 'classification', align: 'center', width: 100},
          {
            field: 'states',
            title: '状态',
            align: 'center',
            width: 100,
            switch: row => {
              const result = {}
              if (row.states == 1) {
                Object.assign(result, {
                  value: true, // 开
                  label: '是', // 开的描述
                  click: () => { // 点击事件
                    this.updState(row)
                  }
                })
              } else {
                Object.assign(result, {
                  value: false, // 关
                  label: '否', // 关的描述
                  click: () => {
                    this.updState(row)
                  }
                })
              }
              return result
            }
          }
        ],
        // 操作信息
        operation: {
          show: true, // 显示操作列
          width: 100, // 列宽
          attr: [
            {
              title: '删除',
              events: (row) => {
                this.del(row);
              },
            },
          ],
        },
        paging: {
          show: true, // 显示分页
          // 分页信息
          page: {
            small: false,
            pageNum: 1,
            pageSize: 10,
            total: 0
          }
        }
      },
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  created() {
  },
  methods: {
    showAdd(){
      this.specsSetting.mid = this.setting.id;//物品ID
      this.specsSetting.show = true;
    },
    del(row) {
      this.$modal
        .confirm('是否确认删除名称为"' + row.categoryName + '"的机构吗?')
        .then(function () {
          delSpecs({ id: row.id }).then((res) => {});
        })
        .then((res) => {
          this.$message.success('删除成功!');this.$refs.myTable.search();
        })
        .catch(() => {});
    },
    close() {
      this.$emit('close')
    },
    // 查询table列表
    search() {
      this.$refs.myTable.search()
    },
 
  }
}
</script>