bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
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
<template>
<!-- :permissions="['business:appliancechange:query']" -->
  <TableLayout :permissions="['ext:appliancechange:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" label-suffix=":" inline>
      <el-form-item label="更换单号" prop="code">
        <el-input v-model="searchForm.code" placeholder="请输入更换单号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="物料信息" prop="mmodelName">
        <el-input v-model="searchForm.mmodelName" placeholder="请输入当物料名称/编码" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="工序" prop="procedureId">
        <el-select v-model="searchForm.procedureId" filterable clearable placeholder="请选择工序">
          <el-option
            v-for="item in procedure"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在仓库" prop="warehouseId">
        <el-select v-model="searchForm.warehouseId" filterable clearable placeholder="请选择所在仓库">
          <el-option
            v-for="(item, index) in warehouse"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建日期" prop="planDate">
        <el-date-picker
          v-model="planDate"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="~"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="dateChange"
        ></el-date-picker>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <!-- v-permissions="['ext:workorderrecordext:exportExcel']" -->
        <li><el-button type="primary" :loading="isWorking.export" @click="exportExcel">导出</el-button></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        border
        :summary-method="getSummaries"
        show-summary
      >
        <el-table-column prop="code" label="更换单号" fixed="left" min-width="140px"></el-table-column>
        <el-table-column prop="mmodelName" label="物料名称" show-overflow-tooltip min-width="100px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.mmodelName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="mmodelCode" label="物料编码" min-width="180px">
          <template slot-scope="{ row }">
            <span>{{ row.mmodelCode }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="changenum" label="物料数量" min-width="100px">
          <template slot-scope="{ row }">
            <span>{{ row.changenum + row.umodelName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="batch" label="批次号" min-width="100px"></el-table-column>
        <el-table-column prop="pmodelName" label="加工工序" show-overflow-tooltip min-width="100px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.pmodelName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="smodelCode" label="工装属性" min-width="100px">
          <template slot-scope="{row}">
            <span :style="typeColor(row.smodelCode)">{{row.smodelCode}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="whmodelName" label="仓库" show-overflow-tooltip min-width="140px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.whmodelName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="lmodelUnionName" label="库位" show-overflow-tooltip min-width="140px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.lmodelUnionName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="createName" label="创建人" min-width="100px"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" min-width="140px"></el-table-column>
        <el-table-column label="操作" min-width="140px" fixed="right">
          <template slot-scope="{ row }">
            <el-button type="text" @click="showDetail(row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
    <OperaApplianceChangeDetailWindow ref="operaApplianceChangeDetailWindow"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaApplianceChangeDetailWindow from '@/components/ext/OperaApplianceChangeDetailWindow'
import { productesGroup } from '@/api/ext/proceduresExt'
import { queryWarehouseAllData } from '@/api/ext/warehouseExt'
import { addPrecision } from '@/utils/util'
export default {
  name: 'ApplianceChange',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaApplianceChangeDetailWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        code: '',
        mmodelName: '',
        procedureId: '',
        startDate: '',
        endDate: '',
        warehouseId: ''
      },
      planDate: [],
      procedure: [],
      warehouse: []
    }
  },
  created () {
    this.config({
      module: '设置类-工装器具更换记录表',
      api: '/ext/applianceChange',
      'field.id': 'id',
      'field.main': 'id'
    })
    productesGroup({})
      .then(res => {
        this.procedure = res
      })
      .catch(err => {
        console.log(err)
      })
    queryWarehouseAllData({ status: 1, rootDepartId: this.$store.state.userInfo.curComDepartment.id })
      .then(res => {
        this.warehouse = res
      })
      .catch(err => {
        console.log(err)
      })
    this.search()
  },
  methods: {
    dateChange (v) {
      this.searchForm.startDate = v[0]
      this.searchForm.endDate = v[1]
    },
    reset () {
      this.$refs.searchForm.resetFields()
      this.searchForm.startDate = null
      this.searchForm.endDate = null
      this.planDate = []
      this.search()
    },
    showDetail (row) {
      this.$refs.operaApplianceChangeDetailWindow.open('更换单详情', row)
      // applianceChangeDetail(id)
      //   .then(res => {
          
      //   })
      //   .catch(err => {
      //     this.$tip.error(err)
      //   })
    },
    typeColor (smodelCode) {
      switch (smodelCode) {
        case '合格': return 'color:#03AF76'
        case '报废': return 'color:#DE5243'
        case '不良': return 'color:#F5A400'
        default: return 'color: #111111'
      }
    },
    getSummaries (param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        } else if (index === 4) {
          sums[index] = '-';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = 0
          values.forEach(item => {
            sums[index] = addPrecision(item, sums[index])
          })
        } else {
          sums[index] = '-';
        }
      });
      return sums
    }
  }
}
/**
 *  
 */
</script>