Mr.Zhang
2023-08-14 287934f48daa9889f824e12d1af687bc5aa3bbe2
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<template>
  <GlobalWindow
    :title="title"
    width="390px"
    :visible.sync="visible"
  >
    <div class="print-title">打印样式预览:</div>
    <div class="tip">当前标签尺寸为{{  '80mm x 80mm,' }}打印时请根据需要自行缩放</div>
    <div style="width:100%;">
      <div style="height:10px;background-color:#fff"></div>
      <div id="qr1" style="width:100%;">
        <div
          v-for="(item, index) in qrList" 
          :key="index" 
        >
          <div
            style="
              background-color:#fff;
              padding: 10px 0;
              margin: 1px auto;
              height: 322px;
              width: 303px;"
          >
            <table
              border="1"
              width="294px"
              style="
                margin: -5px 5px 0 0px;
                border-collapse:collapse"
            >
              <caption
                style="
                  margin-bottom:15px;
                  font-size:16px;
                  line-height:16px;
                  font-weight: 700;"
              >{{ item.dmodel.name }} 产品加工流转卡</caption>
              <tbody style="text-align: center; color: #333; font-size:12px; margin-top:10px">
                <tr>
                  <td style="width:70px;height:21px">产品编码</td>
                  <td style="text-align:left">{{ item.mmodel && item.mmodel.code }}</td>
                  <td colspan="3" rowspan="7">
                    <div style="
                      width: 79px;
                      height:150px;
                      margin: 5px auto;
                      color: #999;"
                    >
                      <vue-qr :text="qrStr(item.code)" :size="79" :margin="0"/>
                      <div>扫码查看</div>
                      <div>详细信息</div>
                    </div>
                  </td>
                </tr>
                <tr>
                  <td style="height:21px">产品名称</td>
                  <td style="text-align:left">{{ item.mmodel&&item.mmodel.name }}</td>
                </tr>
                <tr>
                  <td style="height:21px">生产批次</td>
                  <td style="text-align:left">{{ item.batch }}</td>
                </tr>
                <tr>
                  <td style="height:21px">生产工单</td>
                  <td style="text-align:left">{{ item.code }}</td>
                </tr>
                <tr>
                  <td style="height:21px">生产工序</td>
                  <td style="text-align:left">{{ item.procedureName }}</td>
                </tr>
                <tr>
                  <td style="height:21px">生产设备</td>
                  <td style="text-align:left">{{ item.pgmodel.code }}</td>
                </tr>
                <tr>
                  <td style="height:21px">加工数量</td>
                  <td style="text-align:left">{{ item.planNum + (item.umodel && item.umodel.name) }}</td>
                </tr>
                <tr>
                  <td>作业人员</td>
                  <td style="text-align:left; height:16px;line-height:16px;" colspan="2">
                    <!-- <span style="width:100%; overflow: hidden;text-overflow: ellipsis;">{{ proStr(item.proUserList)  }}</span> -->
                    <div style="
                      width:100%; 
                      overflow: hidden;
                      text-overflow: ellipsis;
                      display: -webkit-box; 
                      -webkit-box-orient: vertical;
                      -webkit-line-clamp: 1;"
                    >{{ proStr(item.proUserList) }}</div>
                  </td>
                </tr>
                <tr>
                  <td>打印信息</td>
                  <td style="text-align:left; line-height:16px;" colspan="2">
                    <div>{{ userInfo.realname + ', ' + current}}</div>
                  </td>
                </tr>
              </tbody>
            </table>
            <div
              style="
                border-right: 1px solid #111;
                border-bottom: 1px solid #111;
                border-left: 1px solid #111;
                width: 292px;
                line-height: 26px;
                min-height: 26px;
                font-size: 12px;
                margin: 0 0 1px 0px;
                display:flex;
                text-align: center;
                "
            >
            <!--  -->
              <div style="width: 30px; border-right: 1px solid #111; position:relative;">
                <div style="position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;height: 26px;">N</div>
              </div>
              <div 
                style="
                  flex: 1;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  display: -webkit-box;
                  -webkit-line-clamp: 2;
                  line-clamp: 2;
                  -webkit-box-orient: vertical;
                  height: 26px;
                  line-height: 13px;
                "
              >{{ routeStr(item.routeProcedureList) }}</div>
            </div>
          </div>
 
          <div v-if="index != qrList.length - 1" style="height:5px;background-color:#fff;"></div>
      </div>
    </div>
    </div>
    <div slot="footer" class="window__header">
      <el-button type="primary" @click="cancel" plain>返回</el-button>
      <el-button type="primary" @click="submit">去打印</el-button>
    </div>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import VueQr from 'vue-qr'
import printJS from 'print-js'
import { Divider } from 'element-ui'
 
export default {
  name: 'OrderQrCodeLabel',
  extends: BaseOpera,
  components: { GlobalWindow, VueQr, Divider },
  data () {
    return {
      // 表单数据
      qrList: [],
      prefix: '',
      needSelect: false,
      current: '',
      userInfo: {},
      printing: false
    }
  },
  created () {
    this.config({
      api: '/ext/materialExt',
      'field.id': 'id'
    })
    this.userInfo = this.$store.state.userInfo
  },
  methods: {
    open (title, qrList, prefix) {
      // console.log(this.$store.state.userInfo)
      this.title = title
      this.qrList = qrList
      this.prefix = prefix
      let d = new Date()
      let month = d.getMonth() + 1
      let day = d.getDate()
      let hours = d.getHours()
      let minutes = d.getMinutes()
      this.current = (month < 10 ? ('0' + month) : month) 
                      + '-' + (day < 10 ? ('0' + day) : day)
                      + ' ' + (hours < 10 ? ('0' + hours) : hours)
                      + ':' + (minutes < 10 ? ('0' + minutes) : minutes)
                
      this.visible = true
    },
    qrStr (code) {
      return this.prefix + code
    },
//  /ext/workorderCheckAttrExt/delete/{id}  点检 删除接口
// /ext/workorderCheckExt/delete/{id}  检验删除接口
    routeStr (routeProcedureList) {
      let list = JSON.parse(JSON.stringify(routeProcedureList))
      if (!list) {
        return '-'
      }
      list = list.map((item, index, arr) => {
        return item.pmodel.name
      })
      // console.log(list)
      if (list.length > 0) {
        
        return list.join(' > ')
      }
      return '-'
    },
    cancel () {
      this.visible = false
    },
    submit () {
      // console.log('提交');
      this.printing = true
      printJS(
        {
          printable: 'qr1',
          type:'html',
          header:null,
          targetStyles:['*'],
          style:"@page {margin: 3mm}",
          onPrintDialogClose: () => {
            this.printing = false
            this.visible = false
          }
        }
      )
    },
    proStr (proUserList) {
      return proUserList.map((item) => { return item.proUserDepartName}).join(',')
    }
  }
}
</script>
 
<style lang="scss" scoped>
#qr1 {
  @media print {
    .border-style {
      border: 1px solid #fff;
    }
  } 
}
#qr1 {
  .border-style {
    border: 1px solid #ccc;
  }
}
 
 
.print-title {
  width: 100px;
  text-align: right;
  height: 14px;
  line-height: 14px;
  font-size: 14px;
  font-weight: 500;
  color: #222222;
  padding: 10px 0;
}
.tip {
  color: #999;
  font-size: 12px;
}
.btn {
  margin: 0 16px;
  height: 38px;
  line-height: 38px;
  font-size: 14px;
  border-radius: 2px;
  cursor: pointer;
  
}
.btn-select {
  border-radius: 2px;
  background-color: #305ED5;
  color: #fff;
}
.btn-normal {
  // width: inherit;
  border-radius: 2px;
  background-color: #F4F5FA;
  color: #305ED5;
}
 
.foot-table-style {
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  border-left: 1px solid #111;
  width: 422px;
  height: 26px; 
  line-height: 26px;
  font-size: 12px;
  margin: 0 15px 15px 15px;
  display:flex;
  text-align: center;
}
</style>