Fixiaobai
2023-11-16 5676e658cf19f371ca059104889c33685a6416b9
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<template>
  <div>
    <ttable
      :table="table"
      :uploadInfo="{
        isShow: false
      }"
      :paramObj="{
        queryType: 1
      }"
      :options="options"
      :ajaxFun="ajaxFun"
      :bottomOffset="80"
      ref="reportTableNewTab2"
      @currentChange="currentChange"
    >
      <template #toolbar />
    </ttable>
  </div>
</template>
 
<script>
import {
  fetchList,
  putReportSubmit,
  putReportCancelSubmit,
  delReport
} from '@/api/quality/newReport'
import { remote } from '@/api/admin/dict'
import { mapGetters } from 'vuex'
import ttable from '@/views/common/ztt-table.vue'
 
export default {
  data() {
    const tt = (prop, label, config) => {
      const w = (label.length - 1) * 20 + 15
      return Object.assign(
        {
          minWidth: w,
          width: w < 110 ? 110 : w,
          prop,
          label,
          sort: true,
          isTrue: true,
          isSearch: true,
          searchInfoType: 'text'
        },
        config
      )
    }
    return {
      ajaxFun: fetchList,
      options: {
        height: 300, // 默认高度-为了表头固定
        stripe: true, // 是否为斑马纹 table
        highlightCurrentRow: false, // 是否要高亮当前行
        border: true, // 是否有纵向边框
        lazy: false, // 是否需要懒加载
        fit: true, // 列的宽度是否自撑开
        multiSelect: false, //
        seqNo: true,
        isRefresh: true, // 是否显示刷新按钮
        isShowHide: true, // 是否显示显影按钮
        isSearch: false, // 高级查询按钮
        defaultOrderBy: { column: 'reportNo', direction: 'desc' }
      },
      table: {
        total: 0,
        currentPage: 1,
        pageSize: 20,
        data: [],
        // 标题
        column: [
          tt('reportState', '提交状态', {
            searchInfoType: 'select',
            formatter: (row, column, cellValue) => {
              return cellValue.replace('汇报', '')
            },
            optList: () => {
              return [
                { label: '已提交', value: '汇报已提交' },
                { label: '未提交', value: '汇报未提交' }
              ]
            }
          }),
          tt('applyNo', '申请编号'),
          tt('reportNo', '汇报编号', {
            render: { fun: this.goEdit }
          }),
          tt('applyType', '汇报类型', {
            searchInfoType: 'select',
            formatter: (row, column, cellValue) => {
              const i = this.applyTypeList.find((e) => e.value === cellValue)
              return i ? i.label : ''
            },
            optList: () => {
              return this.applyTypeList
            }
          }),
          tt('moNo', '车间订单号'),
          tt('systemNo', '系统号'),
          tt('reelNumber', '载具编号'),
          tt('outBatchNo', 'SN号'),
          tt('partNo', '零件号'),
          tt('partName', '零件名称'),
          tt('replacePartNo', '替代零件号'),
          tt('checkLength', '入库长度'),
          tt('totalLength', '报检长度'),
          tt('scrapArrived', '报废长度'),
          tt('operationName', '工序'),
          tt('workstationName', '机台'),
          tt('reportPerson', '检测人员'),
          tt('checkTime', '检测时间', {
            searchInfoType: 'datetimerange'
          }),
          tt('produceUser', '生产人员'),
          tt('applyUser', '报检人员')
        ],
        toolbar: [
          {
            text: '提交',
            type: 'primary',
            fun: this.goSubmit,
            disabled: true
          },
          {
            text: '撤回',
            type: 'primary',
            fun: this.goRevert,
            disabled: true
          },
          {
            text: '删除',
            type: 'primary',
            fun: this.goDel,
            disabled: true
          }
        ]
      },
      applyTypeList: [],
      currentRow: null,
      visible: {
        库位: false
      }
    }
  },
  components: {
    ttable
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  created() {
    remote('apply_report_type').then((response) => {
      if (response.data.code === 0) {
        this.applyTypeList = response.data.data
      } else {
        this.applyTypeList = []
      }
    })
  },
 
  activated() {},
  methods: {
    // 获取数据列表
    getData() {
      return this.$refs.reportTableNewTab2.getDataList()
    },
    currentChange(row) {
      this.currentRow = row
      this.table.toolbar.forEach((e) => (e.disabled = true))
      if (row) {
        if (row.reportState === '汇报未提交') {
          this.table.toolbar[0].disabled = false
          this.table.toolbar[2].disabled = false
        } else {
          this.table.toolbar[1].disabled = false
        }
      }
    },
    goEdit(row) {
      sessionStorage.setItem('ztt-newReportRow', JSON.stringify(row))
      this.$router.push({
        name: 'newReportForm',
        query: {
          type: 'edit'
        }
      })
    },
    goSubmit() {
      putReportSubmit({}, this.currentRow.reportId).then((response) => {
        const resData = response.data
        if (resData.code === 0) {
          this.getData()
          this.$message.success('检测汇报提交成功!')
        } else {
          this.$message.error('检测汇报提交失败!')
        }
      })
    },
    goRevert() {
      putReportCancelSubmit({}, this.currentRow.reportId).then((response) => {
        const resData = response.data
        if (resData.code === 0) {
          this.getData()
          this.$message.success('检测汇报撤销成功!')
        } else {
          this.$message.error('检测汇报撤销失败!')
        }
      })
    },
    goDel() {
      this.$confirm(
        '是否确认删除汇报编号为:' + this.currentRow.reportNo,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          closeOnClickModal: false,
          type: 'warning'
        }
      )
        .then(() => {
          return delReport(this.currentRow.reportId)
        })
        .then((data) => {
          this.$message.success('删除成功')
          this.getData()
        })
    }
  }
}
</script>