<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> 
 |