Fixiaobai
2023-11-16 5676e658cf19f371ca059104889c33685a6416b9
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
<template>
  <el-dialog
    width="75%"
    title="同步更新工艺配置单订单行待选列表"
    top="5vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
  >
    <el-table
      ref="otherCustomerOrderLineTable"
      :data="otherCustomerOrderLineList"
      style="width: 100%"
      @row-click="rowClick"
      height="500px"
    >
      <el-table-column align="center" width="55">
        <template slot="header" slot-scope="scope">
          <el-button type="text" @click="selectAll()">全选</el-button>
        </template>
        <template slot-scope="scope">
          <el-checkbox
            class="other-customer-table-single-checkbox"
            v-model="scope.row.commonChecked"
            disabled
          ></el-checkbox>
        </template>
      </el-table-column>
      <el-table-column
        prop="existProcessConfig"
        align="center"
        label="是否已有工艺配置单"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <span>{{ scope.row.existProcessConfig ? '已配置' : '未配置' }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="otcLineNo"
        align="center"
        label="OTC行号"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="customerNo"
        align="center"
        label="客户编号"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column prop="customerName" align="center" label="客户名称">
      </el-table-column>
      <el-table-column prop="salesPartNo" align="center" label="销售件号">
      </el-table-column>
      <el-table-column prop="salesPartName" align="center" label="销售件名称">
      </el-table-column>
      <el-table-column prop="productGroup" align="center" label="产品分组">
      </el-table-column>
      <el-table-column prop="productType" align="center" label="产品类型">
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="updateCurrOrder">只更新当前订单行</el-button>
      <el-button @click="updateCheckOrder">同步更新勾选订单行</el-button>
      <el-button @click="innerVisible = false">关 闭</el-button>
    </div>
  </el-dialog>
</template>
<style>
/*自定义disabled状态下checkbox的样式*/
.other-customer-table-single-checkbox
  .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  background-color: #006eff;
  border-color: #006eff;
}
.other-customer-table-single-checkbox
  .el-checkbox__input.is-disabled
  .el-checkbox__inner {
  background-color: #ffffff;
  cursor: pointer;
}
.other-customer-table-single-checkbox .el-checkbox__inner::after {
  border: 1px solid #fff !important;
  border-left: 0 !important;
  border-top: 0 !important;
  cursor: pointer !important;
}
</style>
<script>
import {
  getBeSelectedLineNoList,
  newProcessConfigEditOne,
  newProcessConfigAddOne,
  newProcessConfigEdit
} from '@/api/plan/customerorder'
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    configContent: {
      type: Object,
      default: () => {
        return {}
      }
    },
    customerOrderId: {
      type: String,
      default: ''
    },
    otherCustomerOrderLineList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      innerVisible: false
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.$nextTick(() => {})
      }
    }
  },
  methods: {
    selectAll() {
      this.otherCustomerOrderLineList.forEach((item) => {
        item.commonChecked = true
      })
    },
    rowClick(row) {
      if (row.commonChecked) {
        row.commonChecked = false
      } else {
        row.commonChecked = true
      }
    },
    updateCurrOrder() {
      const configId = this.configContent.id
      console.log(this.configContent)
      for (
        let i = this.configContent.processConfigDataList.length - 1;
        i >= 0;
        i--
      ) {
        if (
          !this.configContent.processConfigDataList[i].frequency &&
          !this.configContent.processConfigDataList[i].deliveryReduce &&
          !this.configContent.processConfigDataList[i].couplingLoss
        ) {
          this.configContent.processConfigDataList.splice(i, 1)
        }
      }
      if (configId) {
        newProcessConfigEditOne(this.configContent).then((res) => {
          console.log(res)
          if (res.data.code === 0) {
            this.innerVisible = false
            this.$message.success('保存成功')
            this.$emit('refreshCustomerOrderForm', this.configContent.orderId)
          } else {
            this.$message.success('保存失败')
          }
        })
      } else {
        newProcessConfigAddOne(this.configContent).then((res) => {
          console.log(res)
          if (res.data.code === 0) {
            this.innerVisible = false
            this.$message.success('保存成功')
            this.$emit('refreshCustomerOrderForm', this.configContent.orderId)
          } else {
            this.$message.success('保存失败')
          }
        })
      }
    },
    updateCheckOrder() {
      // 刷选出选中的otherCustomerOrderLineList行订单
      const orderIds = []
      this.otherCustomerOrderLineList.forEach((item) => {
        if (item.commonChecked) {
          orderIds.push(item.id)
        }
      })
      if (orderIds.length > 0) {
        orderIds.push(this.customerOrderId)
        const configId = this.configContent.id
        console.log(this.configContent)
        for (
          let i = this.configContent.processConfigDataList.length - 1;
          i >= 0;
          i--
        ) {
          if (
            !this.configContent.processConfigDataList[i].frequency &&
            !this.configContent.processConfigDataList[i].deliveryReduce &&
            !this.configContent.processConfigDataList[i].couplingLoss
          ) {
            this.configContent.processConfigDataList.splice(i, 1)
          }
        }
        this.configContent.orderIdList = orderIds
        newProcessConfigEdit(this.configContent).then((res) => {
          console.log(res)
          if (res.data.code === 0) {
            this.innerVisible = false
            this.$message.success('保存成功')
            this.$emit('refreshCustomerOrderForm', this.configContent.orderId)
          } else {
            this.$message.success('保存失败')
          }
        })
      } else {
        this.$message.error('请选择行订单')
      }
    }
  }
}
</script>