jiangping
2023-08-21 2837bdd57f72e386bbf9a725e7b3a13e5eb9e930
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
<template>
  <GlobalWindow
    :title="title"
    :visible.sync="visible"
    width="80%"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <el-table
      ref="orderTable"
      :data="form.list"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" fixed="left" width="55"></el-table-column>
      <el-table-column prop="code" label="工单编号" min-width="140px"></el-table-column>
      <el-table-column prop="code" label="工单类型" min-width="80px">
         <template slot-scope="{row}">
          {{ typeToStr(row.type)}}
        </template>
      </el-table-column>
      <el-table-column prop="mmodel.name" label="物料名称" min-width="100px"></el-table-column>
      <el-table-column prop="mmodel.code" label="物料编码" min-width="160px"></el-table-column>
      <el-table-column prop="procedureName" label="工序" show-overflow-tooltip min-width="100px">
        <template slot-scope="{row}">
          <span class="long-title-style">{{ row.procedureName }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="planNum" label="计划生产数量" min-width="80px">
        <template slot-scope="{row}">
          {{ row.planNum + row.umodel.name }}
        </template>
      </el-table-column>
      <el-table-column prop="proUserName" label="生产人员" show-overflow-tooltip min-width="140px">
        <template slot-scope="{row}">
          <span class="long-title-style">{{ proUserName(row.proUserList) }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="pgmodel.name" label="生产设备" show-overflow-tooltip min-width="100px">
        <template slot-scope="{row}">
          <span class="long-title-style">{{ '【' + row.pgmodel.code + '】' + row.pgmodel.name }}</span>
        </template>
      </el-table-column>
    </el-table>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { preparationWTransfer } from '@/api/ext/workorderExt'
export default {
  name: 'OperaWorkorderExtWindow',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      // 表单数据
      form: {
        list: [
        ]
      },
      // 验证规则
      rules: {
      },
      selectedRows: [],
      types: [
        // 0正常、1返工、2客户返修
        { name: '正常', id: 0 },
        { name: '返工返修', id: 2 },
        // { name: '客户返修', id: 2 }
      ],
    }
  },
  created () {
    this.config({
      api: '/ext/workorderExt',
      'field.id': 'id'
    })
  },
  methods: {
    open (title, target) {
      this.title = title
      this.visible = true
      // 编辑
      this.$nextTick(() => {
        this.form.list = target
      })
      setTimeout(()=>{
          this.form.list.forEach(item => {
            this.$refs.orderTable.toggleRowSelection(item)
          })
        },50)
    },
    handleSelectionChange (selectedRows) {
      this.selectedRows = selectedRows
    },
    confirm () {
      if (this.selectedRows.length === 0) {
        this.$tip.warning('请至少选择一条数据')
        return
      }
      const ids = this.selectedRows.map(element => {
        return element.id
      }).join(',')
      this.isWorking = true
      preparationWTransfer(ids)
        .then(() => {
          this.$tip.success('备料成功')
          this.$emit('success')
          this.visible = false
        })
        .catch(err => {
          this.$tip.error(err)
        })
        .finally(() => {
          this.isWorking = false
        })
    },
    typeToStr (type) {
      for (const item of this.types) {
        if (item.id === type) {
          return item.name
        }
      }
    },
    proUserName (proUserList) {
      return proUserList.map((item) => {return item.proUserDepartName}).join(',')
    }
  }
}
</script>