zouyu
2023-11-15 d9f709d113bb83b59eb5bec19187975a218c0ca7
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
<template>
  <div class="tech__wrap">
    <div class="l">
      <el-card>
        <el-table
          v-adaptive="{ bottomOffset: 40, fixedHeight: 0 }"
          :data="tableData"
          height="100px"
          border
          style="width: 100%;"
        >
          <el-table-column
            v-for="(col, i) in columnList"
            :key="i"
            :prop="col.createUser"
            :label="col.label"
            :width="col.width"
            align="center"
          >
            <template slot-scope="x">
              <template v-if="!col.custom">{{ x.row[col.prop] }}</template>
              <template v-else-if="col.label === '工艺配置单'">
                <el-button
                  type="primary"
                  size="mini"
                  @click="goCheckPeizhi(x.row)"
                  >查看</el-button
                >
              </template>
              <template v-else-if="col.label === '工艺结构'">
                <el-button
                  type="primary"
                  size="mini"
                  @click="goCheckJiegou(x.row)"
                  >查看</el-button
                >
              </template>
              <template v-else-if="col.label === '结构图'">
                <el-button type="primary" size="mini" @click="goCheckJgt(x.row)"
                  >查看</el-button
                >
              </template>
              <template v-else-if="col.label === '印字要求'">
                <span> </span>
                {{
                  `${x.row.printType || '--'} | ${x.row.printingRequirements ||
                    '--'} | ${x.row.printContent || '--'}`
                }}
              </template>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </div>
    <div class="r">
      <el-card class="r__card">
        <div slot="header" class="clearfix">
          <span>OTC附件列表</span>
        </div>
        <div v-for="(x, i) in otcList" :key="i">
          <el-tag @click="goDownload(x, 'otc')" class="tags">
            <i class="el-icon-document"></i>
            <span>{{ x.original }}</span>
          </el-tag>
        </div>
      </el-card>
      <el-card class="r__card">
        <div slot="header" class="clearfix">
          <span>技术部附件列表</span>
        </div>
        <div v-for="(x, i) in configList" :key="i">
          <el-tag @click="goDownload(x, 'config')" class="tags">
            <i class="el-icon-document"></i>
            <span>{{ x.originalFileName }}</span>
          </el-tag>
        </div>
      </el-card>
    </div>
    <PeizhiModal v-if="visible.peizhi" ref="peizhi" />
    <JiegouModal v-if="visible.jiegou" ref="jiegou" />
    <JgtModal v-if="visible.jgt" ref="jgt" />
  </div>
</template>
<script>
import adaptive from '@/util/adaptive'
import PeizhiModal from './PeizhiModal'
import JiegouModal from './JiegouModal'
import JgtModal from './JgtModal'
import {
  getOADetailDTO,
  getOTC,
  downOTC,
  getCONFIG,
  downCONFIG
} from '@/api/oa/technologyDocument'
export default {
  components: { PeizhiModal, JiegouModal, JgtModal },
  directives: {
    adaptive
  },
  data() {
    const col = (label, prop, custom = false) => {
      const config = { label, prop, custom }
      if (label === '单位') {
        config.width = '50px'
      }
      return config
    }
    return {
      columnList: [
        col('工艺配置单', null, true),
        col('订单编号', 'customerOrderNo'),
        col('订单行号', 'otcLineNo'),
        col('工程名称', 'entityName'),
        col('产品名称', 'productName'),
        col('产品类型', 'productType'),
        col('零件名称', 'partName'),
        col('外护颜色', 'outerColor'),
        col('数量', 'otcQuantity'),
        col('单位', 'otcUnit'),
        col('印字要求', 'printingRequirements', true),
        col('盘长要求', 'lengthRequirement'),
        col('备注', 'remark'),
        col('订单说明', 'orderDescription'),
        col('工艺结构', null, true),
        col('结构图', null, true)
      ],
      tableData: [],
      otcList: [],
      configList: [],
      visible: {
        peizhi: false,
        jiegou: false,
        jgt: false
      }
    }
  },
  created() {
    document.title = '工艺详情'
    console.log(window.location.href)
    var url = window.location.href
    var param = url.split('?')[1]
    if (param) {
      const params = param.split('&')
      const ids = params[0].split('=')[1].split(',')
      getOADetailDTO(ids).then((res) => {
        this.tableData = res.data.data
        if (this.tableData.length) {
          getOTC({ orderNumber: this.tableData[0].customerOrderNo }).then(
            (res) => {
              this.otcList = res.data.data
            }
          )
          getCONFIG({
            customerOrderNo: this.tableData[0].customerOrderNo
          }).then((res) => {
            this.configList = res.data.data
          })
        }
      })
    }
  },
  methods: {
    goDownload(x, type) {
      if (type === 'otc') {
        downOTC(x.id).then((response) => {
          // 处理返回的文件流
          const blob = response.data
          const link = document.createElement('a')
          link.href = URL.createObjectURL(blob)
          link.download = x.original
          document.body.appendChild(link)
          link.click()
          window.setTimeout(function() {
            URL.revokeObjectURL(blob)
            document.body.removeChild(link)
          }, 0)
        })
      } else {
        downCONFIG(x.fileName, x.bucketName, x.originalFileName)
      }
    },
    goCheckPeizhi(x) {
      this.visible.peizhi = true
      this.$nextTick(() => {
        this.$refs.peizhi.init(x)
      })
    },
    goCheckJiegou(x) {
      if (x.technologyDocumentId) {
        this.visible.jiegou = true
        this.$nextTick(() => {
          this.$refs.jiegou.init(x)
        })
      } else {
        this.$message.warning('无关联工艺结构')
      }
    },
    goCheckJgt(x) {
      if (x.technologyDocumentId) {
        this.visible.jgt = true
        this.$nextTick(() => {
          this.$refs.jgt.init(x)
        })
      } else {
        this.$message.warning('无关联结构图')
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.tech__wrap {
  display: flex;
  height: 100%;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  .l {
    width: calc(100% - 320px);
    padding: 10px;
  }
  .r {
    width: 350px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    .r__card {
      & + .r__card {
        margin-top: 15px;
      }
    }
    .el-card {
      flex: 1;
    }
  }
}
.tags {
  cursor: pointer;
  margin-bottom: 8px;
  margin-left: 5px;
}
.tags + .tags {
}
</style>