baotian
2024-06-04 b959135a1139fb66646523d92e5bd20c5910f283
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
190
191
192
193
194
195
196
197
198
<template>
  <div>
    <a-spin :spinning="confirmLoading">
      <a-button
        type="primary"
        icon="plus"
        @click="$refs.addEditForm.showModal('add',planType)"
        v-if="hasPerm('iEdoShiftTeamShift:add')"
      >
        新增
      </a-button>
 
      <!-- 表格 -->
      <a-table
        style="padding: 20px"
        :columns="columns"
        :data-source="data"
        :pagination="pages"
        :rowKey="(record) => record.id"
      >
        <!-- 序号 -->
        <span slot="indexScopedSlots" slot-scope="text, record, index">{{ index + 1 }}</span>
        <!-- 时间处理 -->
        <span slot="planTimeScopedSlots" slot-scope="text, record, index">
          <span v-if="planType==1">{{ moment(moment(text,'YYYY-MM-DD')).format('YYYY-MM-DD') }}</span>
          <span v-else>{{ moment(moment(text)).format('YYYY-MM') }}</span>
        </span>
        <!-- 操作 -->
        <template slot="actionScopedSlots" slot-scope="text, record">
          <a v-if="hasPerm('iEdoShiftTeamShift:edit')" @click="$refs.addEditForm.showModal('edit',planType,record)">编辑</a>
          <!-- <a-divider type="vertical" v-if="hasPerm('iEdoShiftTeamShift:edit') && hasPerm('iEdoShiftTeamShift:delete')" />
          <a v-if="hasPerm('iEdoShiftTeamShift:delete')" @click="deleteHandle(record.id)">删除</a> -->
        </template>
      </a-table>
    </a-spin>
 
    <addEditForm ref="addEditForm" @reflesh="getProductionPlaninfo" />
  </div>
</template>
 
    <script>
import addEditForm from './addEditForm.vue'
import { getProductionPlaninfo } from '@/api/modular/main/YieldMaintenanceManage'
import moment from 'moment'
export default {
  components: { addEditForm },
  data() {
    return {
      confirmLoading: false,
      visible: false,
      columns1: [
        {
          title: '序',
          align: 'center',
          widthL: '50px',
          sorter: false,
          scopedSlots: { customRender: 'indexScopedSlots' }
        },
        {
          title: '计划类型',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planType'
        },
        {
          title: '计划时间',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planTime',
          scopedSlots: { customRender: 'planTimeScopedSlots' }
        },
        {
          title: '班组类型',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'teamType'
        },
        {
          title: '计划产量',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planProductionNum'
        },
        {
          title: '备注',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'remarks'
        }
      ],
      columns2: [
        {
          title: '序',
          align: 'center',
          widthL: '50px',
          sorter: false,
          scopedSlots: { customRender: 'indexScopedSlots' }
        },
        {
          title: '计划类型',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planType'
        },
        {
          title: '计划时间',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planTime',
          scopedSlots: { customRender: 'planTimeScopedSlots' }
        },
        {
          title: '计划产量',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'planProductionNum'
        },
        {
          title: '备注',
          align: 'center',
          sorter: true,
          ellipsis: true,
          dataIndex: 'remarks'
        }
      ],
      columns: [],
      queryParam: { planType: 1 },
      data: [],
      pages: {
        current: 1,
        pageSize: 10,
        total: 0,
        showSizeChanger: true,
        showTotal: (total, range) => `${range[0]}-${range[1]}共${total}条`,
        pageSizeOptions: ['10', '20', '30', '40'],
        onChange: this.getProductionPlaninfo,
        onShowSizeChange: this.pageSizeChange
      }
    }
  },
  props: ['planType'],
  created() {
    this.setColumns()
    if (this.hasPerm('iEdoShiftTeamShift:edit') || this.hasPerm('iEdoShiftTeamShift:delete')) {
      this.columns.push({
        title: '操作',
        align: 'center',
        sorter: false,
        scopedSlots: { customRender: 'actionScopedSlots' }
      })
    }
    this.getProductionPlaninfo()
  },
  methods: {
    moment,
    // 获取计划产量数据
    async getProductionPlaninfo(pageNo) {
      if (pageNo) {
        this.pages.current = pageNo
      }
      this.queryParam.pageNo = this.pages.current
      this.queryParam.pageSize = this.pages.pageSize
      this.queryParam.planType = this.planType
      this.confirmLoading = true
      try {
        const { data } = await getProductionPlaninfo(this.queryParam)
        this.data = data.rows
        this.pages.total = data.totalRows
      } catch (error) {
        console.log(error)
      }
      this.confirmLoading = false
    },
    // pageSize 变化的回调
    pageSizeChange(current, size) {
      this.pages.pageSize = size
      this.getProductionPlaninfo(1)
    },
    setColumns() {
      if (this.planType == 1) {
        this.columns = this.columns1
      } else {
        this.columns = this.columns2
      }
    }
  }
}
</script>
 
    <style></style>