jiaosong
2023-08-11 c2e4ed1a6e3a14406db471304360cd45ac8177d1
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
<template>
  <GlobalWindow
    title="选择工序"
    width="80%"
    :visible.sync="visible"
  >
    <div style="margin-bottom:10px">
      <el-form ref="searchForm" :model="searchForm" label-width="85px" inline >
        <el-form-item label="工序名称:" prop="name" >
          <el-input v-model="searchForm.name" placeholder="请输入工序名称"></el-input>
        </el-form-item>
        <el-form-item label="工序编码:" prop="code">
          <el-input v-model="searchForm.code" placeholder="请输入工序编码"></el-input>
        </el-form-item>
        <div style="display: inline;">
          <el-button type="primary" @click="search">搜索</el-button>
          <el-button @click="reset">重置</el-button>
        </div>
      </el-form>
    </div>
    <el-table
      v-loading="isSearch"
      :data="productes"
      stripe
      border
      @selection-change="handleSelectionProductes"
    >
      <el-table-column type="selection" fixed="left" width="55"></el-table-column>
      <el-table-column prop="name" label="工序名称" min-width="100px"></el-table-column>
      <el-table-column prop="code" label="工序编码" fixed="left" min-width="100px"></el-table-column>
      <!-- <el-table-column prop="sortNum" label="加工顺序" min-width="100px"></el-table-column> -->
      <el-table-column label="加工顺序" prop="sortnum" min-width="100px"></el-table-column>
      <el-table-column label="工序类型" min-width="100px">
        <template slot-scope="{row}">
          {{ row.level == 1 ? '委外' : '自有'  }}
        </template>
      </el-table-column>
      <el-table-column label="负责人" min-width="100px">
        <template slot-scope="{row}">
          {{ row.umodel.realname + '-' + row.umodel.mobile }}
        </template>
      </el-table-column>
      <el-table-column label="设备收集层次" min-width="100px">
        <template slot-scope="{row}">
          {{ row.level == 0 ? '设备' : '设备组' }}
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" min-width="140px">
      </el-table-column>
    </el-table>
    <el-pagination
      style="margin-top:10px"
      :current-page="pagination.pageIndex"
      :page-size="pagination.pageSize"
      layout="total, prev, pager, next, jumper"
      :total="pagination.total"
      @current-change="handlePageChange"
      background
    ></el-pagination>
    <div slot="footer" class="window__header">
      <div style="width:200px; text-align: center; margin: 0 auto; padding-top:10px">
        <el-button type="primary" @click="determine">提交</el-button>
        <el-button @click="cancel">取消</el-button>
      </div>
    </div>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import { fetchList as procedurePage } from '@/api/ext/proceduresExt'
export default {
  name: 'SelectProcedure',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      form: {
        ids: null,
        departId: null
      },
      isSearch: false,
      productes: [],
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      },
      // 筛选条件
      searchForm: {
        name: null,
        code: null
      },
  
      // 已选工序(index : array)
      selectedProcedures: {},
    }
  },
  mounted() {
    // console.log('加载完成');
  },
  methods: {
    open (title, target) {
      // console.log(target)
      this.title = title
      this.visible = true
      
      if (target) {
        this.selectedProcedures = {}
        this.searchForm.code = null
        this.searchForm.name = null
        this.pagination = {
          pageIndex: 1,
          pageSize: 10,
          total: 0
        }
        this.$nextTick(() => {
          for (const key in this.form) {
              this.form[key] = target[key]
            }
          })
          this.form = JSON.parse(JSON.stringify(target))
          // console.log('赋值结束', this.form)
          this.search()
        }
    },
    determine () {
      let lastSelect = []
      for (const key in this.selectedProcedures) {
        lastSelect = lastSelect.concat(this.selectedProcedures[key])
      }
      this.$emit('selectData', {
        selectedProcedures: lastSelect
      })
      this.visible = false
    },
    reset () {
      this.selectedProcedures = {}
      this.$refs.searchForm.resetFields()
      this.search()
    },
    /**
     * 搜索物料
     */
    search () {
      // console.log('搜索')
      this.handlePageChange(1)
    },
    // 选择物料(多选)
    handleSelectionProductes (selectedRows) {
      this.selectedProcedures[this.pagination.pageIndex] = selectedRows
    },
    cancel () {
      this.visible = false
    },
    handlePageChange (page) {
      const {departId, ids} = this.form
      // console.log(this.form, this.form.departId)
      this.pagination.pageIndex = page
      this.isSearch = true
      procedurePage({
        capacity: this.pagination.pageSize,
        model: {
          name: this.searchForm.name,
          orgId: departId,
          code: this.searchForm.code,
          niIds: ids
        },
        page: this.pagination.pageIndex,
        sorts: null
      })
        .then(res => {
          this.productes = res.records
          this.pagination.pageIndex = res.page
          this.pagination.total = res.total
          this.pagination.pageSize = res.capacity
        })
        .catch(err => {
          this.$tip.error(err)
          // console.log(err)
        })
        .finally(() => {
          this.isSearch = false
        })
    },
    // 判断是否被被选中
    isSelectRow (row) {
      if (this.selectedProcedures[this.pagination.pageIndex]) {
        return this.selectedProcedures[this.pagination.pageIndex].includes(row)
      }
      return false
    }
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep .el-dialog {
  // height: calc(100% - 190px);
  
  margin-top: 0 !important;
  top: 10%;
  bottom: 10%;
  height: 80%;
  min-height: 600px;
}
::v-deep .el-dialog__footer {
  padding: 0px;
}
::v-deep .el-dialog__body {
  padding: 10px 20px;
  height: calc(100% - 114px);
}
 
.main-materail {
  display: flex;
  justify-content: space-between;
  height: 100%;
  .left {
    width: calc(20% - 20px);
    height: calc(100% - 20px);
    border: #EEEEEE solid 1px;
    padding: 10px;
    font-size: 18px;
  }
  .right {
    width: calc(80% - 20px);
    height: calc(100% - 20px);
    padding: 0, 20px;
    section {
      display: inline-block;
      margin-left: 16px;
      margin-bottom: 18px;
    }
  }
}
</style>