lyh
14 小时以前 b6247699693bdc200539f20851b3d2105fe8b674
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
<template>
  <div>
    <el-row class="el-row-tab" @contextmenu.prevent.native="">
      <el-table
        id="processTable"
        :data="tableData"
        highlight-current-row
        @row-contextmenu="procRightClick"
        @row-click="handleCurrentChange"
        height="250"
        border
        class="show_table"
        size='mini'
        style="width: 100%">
         <el-table-column
          prop="processCode"
          label="工序号"
          sortable
        >
        </el-table-column>
          <el-table-column
          prop="craftNo"
          label="工艺编号"
          sortable
          class-name="right"
            align="center"
        >
        </el-table-column>
        <el-table-column
          prop="processName"
          label="工序名称"
          sortable
          class-name="left"
        >
        </el-table-column>
 
 
      </el-table>
      <div class="tableRightMenu">
        <ContextMenu
          ref="ContextMenu"
          @showProcessAddDialog="showProcessAddDialog"
          @showProcessEditDialog="showProcessEditDialog"
          @showUploadDialog="showUploadDialog"
          @processDelete="processDelete"
        />
      </div>
    </el-row>
  </div>
</template>
 
<script>
  import * as productApi from '../api/product'
  import Bus from './bus.js'
  import ContextMenu from '@/module/productManager/components/processContextMenu.vue'
  export default {
    name: "process_table_info",
    props:['nodeList'],
    components:{
      ContextMenu
    },
    data(){
      return {
        processMenuVisible :false,
        processFromVisible:false,
        processUploadVisible:false,
        addLoading:false,
        deleteParam:{
          id:''
        },
        processRow:[],
        nodeData:{
          index:'',
          list:[]
        },
        params:{
          productId:'',
          componentId:'',
          partsId:''
        },
        contextQueryParams:{
          flag:2, //查询按钮的范围 1 菜单 2 对象
          param:'process', //查询参数,按类型而不同 1 菜单路径 2 对象权限码
          objectId:null, //flag 为2时需要传递该参数 该参数与param对应数据id
          relativeObjectId:null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的id
          relativeParam:null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的对象权限码
        },
        tableData: [],
        fileList:[],
        fileLen:0,
        docUploadParams:{
          attributionId:'',
          attributionType:5,
          docClassCode:'NC',
        }
      }
    },
    methods: {
      queryProcessList(){
        this.params.productId = JSON.parse(JSON.stringify(this.nodeList.list)).productId;
        this.params.componentId = JSON.parse(JSON.stringify(this.nodeList.list)).componentId;
        if (this.nodeList.index == 3){
          this.params.partsId = JSON.parse(JSON.stringify(this.nodeList.list)).partsId;
        }else {
          this.params.partsId = '';
        }
        productApi.query_process_list(this.params).then((res)=>{
          if (res.success) {
            this.tableData = res.list;
          }
        });
      },
      handleSizeChange(val) {
        this.params.size = val;
        //this.query();
      },
      //右键菜单
      procRightClick(row, column, event) { // 鼠标右击触发事件
        if (event != undefined) {
          this.processRow = row;
          if (this.nodeList.index == 2) {
            this.contextQueryParams.relativeParam ='component';
            this.contextQueryParams.relativeObjectId = this.nodeList.list.componentId;
          }else if (this.nodeList.index == 3) {
            this.contextQueryParams.relativeParam ='parts';
            this.contextQueryParams.relativeObjectId = this.nodeList.list.partsId;
          }
          this.contextQueryParams.objectId = row.processId;
          this.$refs.ContextMenu.processRightClick(row, column, event,this.contextQueryParams);
        }
      },
      //点击
      handleCurrentChange(val) {
        this.nodeData.index = 5;
        this.nodeData.list = val;
        this.$emit('indexChange', this.nodeData); // 调用父组件传递过来的方法,同时把数据传递出去
      },
      showProcessAddDialog(){
        this.$emit('showProcessAddDialog')
      },
      showProcessEditDialog(){
        this.$emit('showProcessEditDialog',this.processRow)
      },
      showUploadDialog(){
        this.docUploadParams.attributionId = this.processRow.processId;
        this.$emit('showUploadDialog',this.docUploadParams)
      },
      processDelete(){
        this.$confirm('确认提交吗?', '提示', {}).then(() => {
          this.deleteParam.id = this.processRow.processId;
          productApi.process_delete( this.deleteParam).then((res) => {
            if (res.success) {
              this.queryProcessList();
              this.$emit('indexChange', this.nodeList); // 调用父组件传递过来的方法,同时把数据传递出去
              this.$message({
                message: res.message,
                type: 'success'
              });
            } else if (res.message) {
              this.$message({
                message: res.message,
                type: 'error'
              });
            }
          });
        });
      }
    },
    //监听
    watch:{
      nodeList:{
        deep: true,  // 深度监听
        handler(newValue, oldValue) {
          if (this.nodeList.index > 1) {
            this.queryProcessList()
          }
        }
      }
    },
    //初始化  模板渲染前调用
    created(){
      Bus.$off('queryProcessList');
      Bus.$on("queryProcessList",()=>{
        this.queryProcessList()
      });
    },
    mounted(){
      this.queryProcessList();
    },
  }
</script>
 
<style scoped lang="scss">
  .el-row-tab{
    border: 1px solid #EBEEF5;
  }
  .tableRightMenu{
    position: absolute;
    top: 0;
    height: 100%;
  }
 
</style>