payne
2024-05-03 09542900534645e28c23f16caa94aa8a2c20cc5b
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
<template>
  <div class="ex-warehouse1-info-block">
    <s-table
      ref="table"
      :columns="columns"
      :data="loadData"
      :alert="true"
      rowKey="tableRowKey"
      :pageSize="queried.PageSize"
      :pageSizeOptions="['5','10','20','30']"
      :rowSelection="null">
      <template class="table-operator" slot="operator" >
        <span style="font-weight:bold;cursor:default;"><a style="cursor:default;">{{orderNo}}</a>单据详情</span>
      </template>
      <template slot="index" slot-scope="text,record,index">{{(queried.PageNo-1)*queried.PageSize+(index+1)}}</template>
      <template slot="statusSlots" slot-scope="text,record">
        <a-tag :color="text==='完成'?'#008000':(
          text==='执行中'?'#1e90ff':(
            text==='取消'?'#556b2f':(
              text==='暂停'?'#8b0000':(
                text==='撤回'?'#ff00ff':'gray'
              )
            )
          )
        )">{{text}}</a-tag>
      </template>
      <template slot="action" slot-scope="text, record">
        <a @click="onDistribute(record)">下发</a>
      </template>
    </s-table>
  </div>
</template>
 
<script>
import { STable } from '@/components'
import { CncTakeMaterialsDetailPage,DetailDistribute } from '@/api/modular/main/ExWarehouseManage1'
const pagination = {PageNo:1,PageSize:5}
export default {
  name:'exWarehouse1InfoBlock',
  components:{STable},
  props:{
    queryId:{
      type:[Number,null],
      default:null
    },
    orderNo:{
      type:String,
      default:''
    }
  },
  data(){
    return {
      columns:[
        { title: '序号', key: 'index', width: 70, align:'center', fixed:"left", scopedSlots: { customRender: 'index' }},
        { title: '物料编号', align:'center', dataIndex: 'materialNo', key: 'materialNo' },
        { title: '图号', align:'center', dataIndex: 'drawingNo', key: 'drawingNo' },
        { title: '入库时间', align: 'center', dataIndex: 'createdTime', width: 170},
        { title: '任务状态', align:'center', dataIndex: 'taskStatusName', scopedSlots: { customRender: 'statusSlots' }, width: 150 },
        { title: '操作', width: '80px', align: 'center', dataIndex: 'action', scopedSlots: { customRender: 'action' } }
      ],
      queried:{...pagination},
      refreshKey:true,
    }
  },
  watch:{
    queryId(newV,oldV){
      if (newV!==oldV){
        this.initData()
      }
    }
  },
  methods:{
    initData(){
      this.refreshKey = true
      this.$refs.table.refresh()
    },
    loadData(parameter){
      parameter.OrderId = this.queryId
      if (this.queryId) {
        if (this.refreshKey) {
          parameter.pageNo = pagination.PageNo
          parameter.pageSize = pagination.PageSize
        } 
        this.refreshKey = false
        this.queried.PageNo = parameter.pageNo 
        this.queried.PageSize = parameter.pageSize 
        return CncTakeMaterialsDetailPage(parameter).then((res) => {
          if (res.data.rows) {
            res.data.rows = res.data.rows.map((item,index)=>{
              item.tableRowKey = index
              return item
            })
          }
          return res.data
        })
      } else {
        return new Promise((resolve,reject)=>{
          resolve({
            pageNo:pagination.PageNo,
            pageSize:pagination.PageSize,
            rows:[],
            totalPage:0,
            totalRows:0
          })
        })
      } 
    },
    onDistribute(obj){
      this.$confirm({
        title: '系统提示',
        content: '您将要进行下发的操作,确认要继续嘛?',
        okText:'确认',
        cancelText:'取消',
        onOk:()=>{
          this.dealDistribute(obj.id,(f)=>{
            if (f) {
              this.$message.success('操作成功')
              this.$refs.table.refresh()
            }
          })
        }
      });
    },
    dealDistribute(id,callback){
      this.$loading.show()
      DetailDistribute(id).then(()=>{
        this.$loading.hide()
        callback && callback(true)
      }).catch(()=>{
        this.$loading.hide()
        callback && callback(false)
      })
    }
  }
}
</script>
 
<style lang="less" scoped>
.ex-warehouse1-info-block{
  padding-top: 8px;
}
</style>