zhangherong
16 小时以前 4dfd11f526b7b4fe578561a9ea4c27a24a88acb4
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
<template>
  <div>
    <!---->
    <a-input @click="openModal" placeholder="请选择任务号" v-model="textVals" readOnly :disabled="submitDisabled">
      <a-icon slot="prefix" type="cluster" title="排产工单选择"/>
      <a-icon v-if="storeVals" slot="suffix" type="close-circle" @click="handleEmpty" title="清空"/>
    </a-input>
    <a-modal
      title="工单选择"
      :width="1000"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @ok="handleSubmit"
      @cancel="handleCancel">
      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
        :customRow="customTableRow"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio'}"></a-table>
    </a-modal>
  </div>
 
</template>
 
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 
export default {
  name: "WorkOrderSelectModal",
  mixins: [JeecgListMixin],
  props: {
    orderStatus: {
      type: String,
      default: 'null', //如果没有传值则查不到数据
    },
    submitDisabled: {
      type: Boolean,
      default: false,
    },
    workOrder: {
      type: Object,
      default: undefined,
    }
  },
  watch: {
    workOrder: {
      immediate: true,
      handler(val) {
        this.textVals = val.workOrderCode
        this.storeVals = val
      }
    }
  },
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      confirmLoading: false,
      storeVals: undefined, //[key values]
      textVals: this.value, //[label values]
      queryParam: {
        workOrderStatus: this.orderStatus,
      },
      url: {
        list: "/mes/mesProductionWorkOrder/list"
      },
      columns: [
        {
          title: '任务号',
          align: "center",
          dataIndex: 'workOrderCode',
          fixed: 'left',
          width: 200
        },
        {
          title: '物料编码',
          align: "center",
          dataIndex: 'materialNumber',
        },
        {
          title: '物料名称',
          align: "center",
          dataIndex: 'materialName'
        },
        {
          title: '计划生产数量',
          align: "center",
          dataIndex: 'planQuantity'
        },
        {
          title: '工单状态',
          align: "center",
          dataIndex: 'workOrderStatus_dictText'
        },
      ]
    }
  },
  created() {
    //加载排产工单数据
    this.queryParam.workOrderStatus = this.orderStatus;
  },
  methods: {
    openModal(){
      this.visible = true;
      if(this.workOrder){
        this.textVals = this.workOrder.workOrderCode;
        this.storeVals = this.workOrder;
        this.selectedRowKeys = [this.workOrder.id];
        this.selectedRows = [this.workOrder]
      }else {
        this.selectedRowKeys = []
        this.selectedRows = []
        this.textVals = '';
        this.storeVals = undefined;
      }
 
    },
    handleEmpty(){
      this.textVals = '';
      this.storeVals = undefined;
      this.selectedRowKeys = []
      this.selectedRows = []
      this.$emit('ok', []);
    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    /**
     * 自定义设备台账表格行
     * @param record 表格行信息
     * @returns {{style: {cursor: string}, on: {click: *}}} 样式对象与事件方法
     */
    customTableRow(record) {
      return {
        style: {
          cursor: 'pointer'
        },
        on: {
          click: () => {
            this.onSelectChange([record.id], [record]);
          }
        }
      }
    },
    handleCancel() {
      this.close()
    },
    handleSubmit() {
      if(this.selectionRows && this.selectionRows.length === 1){
        this.textVals = this.selectionRows[0].workOrderCode;
        this.storeVals = this.selectionRows[0];
        this.$emit('ok', this.selectionRows);
        this.close()
      }else {
        that.$message.warning('请选择一条记录!');
      }
    },
  }
}
</script>
 
<style>
 
</style>