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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<template>
  <TableLayout v-permissions="['ext:wtransferext:query']">
    <!-- 搜索表单 -->
    <el-form slot="search-form" ref="searchForm" :model="searchForm" label-width="110px" label-suffix=":" inline>
      <el-form-item label="转出组织" prop="outDepartId">
        <el-select v-model="searchForm.outDepartId" clearable filterable placeholder="请选择转出组织" @change="selectOutD">
          <el-option
            v-for="(item, index) in departments"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="转出仓库" prop="outWarehouseId">
        <el-select v-model="searchForm.outWarehouseId" clearable filterable placeholder="请选择转出仓库">
          <el-option
            v-for="(item, index) in outWarehouse"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="转库类型" prop="type">
        <el-select v-model="searchForm.type" placeholder="请选择转库类型" clearable>
          <el-option
            v-for="(item, index) in transferTypes"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="单据类型" prop="type">
        <el-select v-model="searchForm.type" placeholder="请选择单据类型" clearable filterable>
          <el-option
            v-for="(item, index) in billType"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="转入组织" prop="inDepartId">
        <el-select v-model="searchForm.inDepartId" placeholder="请选择转入组织" clearable filterable @change="selectInD">
          <el-option
            v-for="(item, index) in departments"
            :key="index"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="转入仓库" prop="inWarehouseId">
        <el-select v-model="searchForm.inWarehouseId" clearable filterable placeholder="请选择转入仓库">
          <el-option
            v-for="(item, index) in inWarehouse"
            :key="index"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <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="status">
        <el-select v-model="searchForm.status" clearable placeholder="请选择单据状态">
          <el-option
            v-for="(item, index) in statusList"
            :key="index"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="计划转出日期">
        <el-date-picker
          v-model="Plandate"
          type="daterange"
          value-format="yyyy-MM-dd"
          range-separator="~"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="selectDate"
        ></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:wtransferext:create']">
        <li>
          <el-button
            type="primary"
            @click="$refs.operaWrollOutStoreExt.open('新增转库')"
          >新增</el-button>
        </li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        border
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column type="selection" width="55"></el-table-column> -->
        <el-table-column prop="code" label="转库单号" fixed="left" min-width="140px">
          <template slot-scope="{ row }">
            <el-button
              type="text"
              @click="showDetail(row)"
              >{{ row.code }}</el-button
            >
          </template>
        </el-table-column>
        <!-- <el-table-column prop="outPlandate" label="转库类型" min-width="80px">
          <template slot-scope="{ row }">
            {{ typeToStr(row.type) }}
          </template>
        </el-table-column> -->
        <el-table-column label="单据类型" min-width="100px">
          <template slot-scope="{ row }">
            {{ billToStr(row.type) }}
          </template>
        </el-table-column>
        <el-table-column prop="name" label="物料信息" min-width="180px">
          <template slot-scope="{row}">
            <div :title="materailsStr(row)" style="width:100%">
              <div v-if="row.wtransferDetailList.length >= 1" class="long-title-style">{{ materailStr(row.wtransferDetailList[0]) }}</div>
              <div v-if="row.wtransferDetailList.length >= 2" class="long-title-style">{{ materailStr(row.wtransferDetailList[1]) }}</div>
              <div v-if="row.wtransferDetailList.length >= 3" class="long-title-style">{{ materailStr(row.wtransferDetailList[2]) }}</div>
              <div v-if="row.wtransferDetailList.length >= 4" class="long-title-style">{{ materailStr(row.wtransferDetailList[3]) }}</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="outPlandate" label="来源单据类型" min-width="100px">
          <template slot-scope="{row}">{{ originTypeToStr(row.originType) }}</template>
        </el-table-column>
        <el-table-column prop="originCode" label="来源单据编号" min-width="130px">
          <template slot-scope="{row}">{{ row.originCode || '-' }}</template>
        </el-table-column>
        <el-table-column prop="outPlandate" label="计划转出日期" min-width="130px"></el-table-column>
        <el-table-column prop="outDepartName" label="转出组织" min-width="100px"></el-table-column>
        <el-table-column prop="outWarehouseName" show-overflow-tooltip label="转出仓库" min-width="100px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.outWarehouseName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="outActdate" label="实际转出日期" min-width="130px">
          <template slot-scope="{ row }">
            {{ row.outActdate || '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="inPlandate" label="计划转入日期" min-width="130px"></el-table-column>
        <el-table-column prop="inDepartName" label="转入组织" min-width="100px"></el-table-column>
        <el-table-column prop="inWarehouseName" show-overflow-tooltip label="转入库仓" min-width="100px">
          <template slot-scope="{ row }">
            <span class="long-title-style">{{ row.inWarehouseName }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="inActdate" label="实际转入日期" min-width="130px">
          <template slot-scope="{ row }">
            {{ row.inActdate || '-' }}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" min-width="140px"></el-table-column>
        <el-table-column prop="createName" label="创建人" min-width="140px"></el-table-column>
        <el-table-column fixed="right" prop="status" label="单据状态" min-width="100px">
          <template slot-scope="{ row }">
            <span v-if="row.status == '0'">已计划</span>
            <span v-if="row.status == '1'">已转出</span>
            <span v-if="row.status == '2'">已转入</span>
            <span v-if="row.status == '3'">已取消</span>
            <span v-if="row.status == '4'">已退回</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="80px" fixed="right">
          <template slot-scope="{ row }">
            <div v-if="row.status == '0'">
              <el-button type="text" @click="cancelOrder(row)" style="color: red" v-permissions="['ext:wtransferext:cancel']" >取消</el-button>
            </div>
            <div v-else-if="row.status == '1'">
              <el-button type="text" @click="withdraw(row.id)" v-permissions="['ext:wtransferext:cancel']" >退回</el-button>
            </div>
            <div v-else>-</div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
    <OperaWrollOutStore ref="operaWrollOutStoreExt" @success="handlePageChange"/>
    <OperaWrollOutStoreDetail ref="operaWrollOutStoreDetailExt"/>
    <OrderCancel ref="orderCancel" @success="handlePageChange"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaWrollOutStore from '@/components/ext/OperaWrollOutStore'
import OperaWrollOutStoreDetail from '@/components/ext/OperaWrollOutStoreDetail'
import OrderCancel from '@/components/ext/OperaWOrderCancel'
import { wTransferExt, withdrawWithId } from '@/api/ext/wTransferExt'
import { getDepartmentListByConditon } from '@/api/ext/departmentExt'
import { queryWarehouseAllData } from '@/api/ext/warehouseExt'
export default {
  name: 'WTransferExt',
  extends: BaseTable,
  components: {
    TableLayout,
    Pagination,
    OperaWrollOutStore,
    OperaWrollOutStoreDetail,
    OrderCancel
  },
  data () {
    return {
      options: [
        { name: '11', id: '1' },
        { name: '22', id: '2' }
      ],
      departments: [],
      inWarehouse: [],
      outWarehouse: [],
      statusList: [
        { name: '已计划', id: '0' },
        { name: '已转出', id: '1' },
        { name: '已转入', id: '2' },
        { name: '已取消', id: '3' },
        { name: '已退回', id: '4' }
      ],
      transferTypes: [
        /**
         * 1、车间领料;
         * 2、机台备料;
         * 3、 车间转库;
         * 4、完工入库;
         * 5、计划领料;
         * 6、外协领料  ;
         * 7、外协完工转库;
         * 8、产品入库  ;
         * 9、产品转库  ;
         * 10、让步放行入库 ;
         * 11、让步放行转库;
         * 12、客返返修领料;
         * 13、客返返修入库;
         * 14、跨组织转库;
         * 15、工单投料(出库),工单产出(入);
         * 16、销售出库;
         * 17、让步销售
         */
 
        { name: '车间领料', id: 1 },
        { name: '计划领料;', id: 2 },
        { name: '机台备料', id: 3 },
        { name: '完工入库', id: 4 },
        { name: '车间转库', id: 5 },
        { name: '外协领料', id: 6 },
        { name: '外协完工转库', id: 7 },
        { name: '产品入库', id: 8 },
        { name: '产品转库', id: 9 },
        { name: '让步放行入库', id: 10 },
        { name: '让步放行转库', id: 11 },
        { name: '客返返修领料', id: 12 },
        { name: '客返返修入库', id: 13 },
        { name: '跨组织转库', id: 14 },
        { name: '工序报废', id: 15 },
        { name: '客退返修领料', id: 16 },
        { name: '客退返修入库', id: 17 },
        { name: '废品入库', id: 30 },
        
      ],
      // billType: [
      //   { name: '车间领料', id: 1 },
      //   { name: '计划领料', id: 2 },
      //   { name: '机台备料', id: 3 },
      //   { name: '完工入库', id: 4 },
      //   { name: '车间转库', id: 5 },
      //   { name: '外协领料转库', id: 6 },
      //   { name: '外协完工转库', id: 7 },
      //   { name: '产品入库', id: 8 },
      //   { name: '产品转库', id: 9 },
      //   { name: '让步放行入库', id: 10 },
      //   { name: '让步放行转库', id: 11 },
      //   { name: '客返品返修领料', id: 12 },
      //   { name: '客返返修入库', id: 13 },
      //   { name: '跨组织转库', id: 14 },
      //   { name: '工序报废', id: 15 },
      //   { name: '客退品返修领料', id: 16 },
      //   { name: '客退品返修入库', id: 17 },
      // ],
      billType: [
        { name: '车间领料', id: 1 },
        { name: '计划领料', id: 2 },
        { name: '机台备料', id: 3 },
        { name: '完工入库', id: 4 },
        { name: '车间转库', id: 5 },
        { name: '外协领料转库', id: 6 },
        { name: '外协完工转库', id: 7 },
        { name: '产品入库', id: 8 },
        { name: '产品转库', id: 9 },
        { name: '让步放行入库', id: 10 },
        { name: '让步放行转库', id: 11 },
        { name: '客返返修领料', id: 12 },
        { name: '客返返修入库', id: 13 },
        { name: '跨组织转库', id: 14 },
        { name: '工序报废', id: 15 },
        { name: '客退返修领料', id: 16 },
        { name: '客退返修入库', id: 17 },
        { name: '废品入库', id: 30 },
      ],
      originTypes: [
        { name: '销售订单', id: 0 },
        { name: '生产工单', id: 1 },
        { name: '其他', id: 2 },
        { name: '申请单', id: 3 }
      ],
      Plandate: [],
      // 搜索
      searchForm: {
        outPlanDateStart: '',
        outPlanDateEnd: '',
        code: '',
        outDepartId: this.$store.state.userInfo.curComDepartment.id,
        outWarehouseId: '',
        inDepartId: this.$store.state.userInfo.curComDepartment.id,
        inWarehouseId: '',
        status: '',
        type: ''
      }
    }
  },
  created () {
    this.config({
      module: '换库单信息',
      api: '/ext/wTransferExt',
      'field.id': 'id',
      'field.main': 'name',
      sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }]
    })
    getDepartmentListByConditon({ type: 0 })
      .then(res => {
        // console.log(res)
        this.departments = res
      })
      .catch(err => {
        console.log(err)
      })
    this.search()
    this.getWhouseByRootDepartment(2, this.$store.state.userInfo.curComDepartment.id)
  },
  methods: {
    selectDate (v) {
      this.searchForm.outPlanDateStart = v[0]
      this.searchForm.outPlanDateEnd = v[1]
    },
    selectOutD (v) {
      this.outWarehouse = []
      this.getWhouseByRootDepartment(0, v)
    },
    selectInD (v) {
      this.inWarehouse = []
      this.getWhouseByRootDepartment(1, v)
    },
    getWhouseByRootDepartment (type, id) {
      queryWarehouseAllData({ status: 1, rootDepartId: id })
        .then(res => {
          if (type === 0) {
            this.outWarehouse = res
          } else if (type === 1) {
            this.inWarehouse = res
          } else {
            this.outWarehouse = res
            this.inWarehouse = res
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    reset () {
      this.$refs.searchForm.resetFields()
      this.Plandate = []
      this.outWarehouse = []
      this.inWarehouse = []
      this.searchForm.outPlanDateStart = null
      this.searchForm.outPlanDateEnd = null
      this.search()
    },
    showDetail (row) {
      wTransferExt(row.id)
        .then(res => {
          this.$refs.operaWrollOutStoreDetailExt.open('转库详情', res)
        })
        .catch(err => {
          this.$tip.error(err)
        })
    },
    materailsStr (row) {
      let str = ''
      for (const item of row.wtransferDetailList) {
        if (str) {
          str = str.concat('\n')
        }
        str = str.concat(this.materailStr(item))
      }
      return str
    },
    cancelOrder (row) {
      this.$refs.orderCancel.open('取消转库', { id: row.id }, 1)
    },
    materailStr (item) {
      let str = '';
      str += `【${item.materialCode}】${item.materialName}`
      if (item.batch) {
        str += item.batch
      }
      if (item.procedureName) {
        str += ` | ${item.procedureName}`
      }
      switch (item.qualityType) {
        case 0: str += ' | 合格'; break;
        case 1: str += ' | 不良'; break
        case 2: str += ' | 报废'; break
      }
      str += ` X ${item.outPlannum}`
      return str
    },
    typeToStr (type) {
      for (const item of this.transferTypes) {
        if (item.id === type) return item.name
      }
      return '-'
    },
    originTypeToStr (type) {
      for (const item of this.originTypes) {
        if (item.id === type) return item.name
      }
      return '-'
    },
    billToStr (type) {
      for (const item of this.billType) {
        if (item.id === type) return item.name
      }
      return '-'
    },
    withdraw (id) {
      this.$confirm('确认退回当前出库物料?', '确认退回', {
        distinguishCancelAndClose: true,
        confirmButtonText: '确认',
        cancelButtonText: '取消'
      })
        .then(() => {
          withdrawWithId(id)
            .then(res => {
              this.$message.success('退回成功')
              this.handlePageChange()
            })
            .catch(err => {
              this.$tip.error(err)
            })
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.divide {
  width: 100%;
  height: 2px;
  background-color: rgb(204, 204, 204);
}
</style>