@nstc-business/imes 1.0.31 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nstc-business/imes",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,6 +2,7 @@
2
2
  <div class="measure-eval-flat">
3
3
  <vxe-table
4
4
  border
5
+ class="v3-n20-table-pro"
5
6
  :data="rows"
6
7
  :row-config="{ keyField: '_rowKey' }"
7
8
  :scroll-y="{ enabled: false }"
@@ -29,7 +29,7 @@
29
29
  <vxe-table
30
30
  v-show="isExpanded(index)"
31
31
  border
32
- class="qual-table"
32
+ class="qual-table v3-n20-table-pro"
33
33
  :data="group.children"
34
34
  :row-config="{ keyField: '_rowKey' }"
35
35
  :scroll-y="{ enabled: false }"
@@ -4,6 +4,7 @@
4
4
  <vxe-table
5
5
  v-else
6
6
  border
7
+ class="v3-n20-table-pro"
7
8
  :data="rows"
8
9
  :merge-cells="mergeCells"
9
10
  :row-config="{ keyField: '_rowKey' }"
@@ -2,7 +2,7 @@
2
2
  <vxe-table
3
3
  border
4
4
  ref="xTable"
5
- :class="['measure-tree-table', 'level-' + level]"
5
+ :class="['measure-tree-table', 'v3-n20-table-pro', 'level-' + level]"
6
6
  :row-config="{ keyField: '_rowKey' }"
7
7
  :data="nodes"
8
8
  :expand-config="{ lazy: false, visibleMethod: canExpand }"
@@ -191,6 +191,42 @@
191
191
  </div>
192
192
  </div>
193
193
  <calculate-detail-dialog ref="calculateDetailDialog" />
194
+ <el-dialog
195
+ title="选择打印"
196
+ :visible.sync="printDialogVisible"
197
+ width="480px"
198
+ append-to-body
199
+ @closed="onPrintDialogClosed"
200
+ >
201
+ <el-form label-width="90px">
202
+ <el-form-item label="打印选项" required>
203
+ <el-select
204
+ v-model="selectedTemplateName"
205
+ placeholder="请选择"
206
+ clearable
207
+ filterable
208
+ :loading="printTemplateLoading"
209
+ style="width: 100%"
210
+ >
211
+ <el-option
212
+ v-for="item in printTemplateList"
213
+ :key="item.ptId || item.ptNo || item.ptName"
214
+ :label="item.ptName"
215
+ :value="item.ptName"
216
+ />
217
+ </el-select>
218
+ </el-form-item>
219
+ </el-form>
220
+ <div slot="footer" class="dialog-footer">
221
+ <el-button type="primary" size="small" :loading="printLoading" @click="confirmPrintDownload('download')">
222
+ 下载
223
+ </el-button>
224
+ <el-button type="primary" size="small" :loading="printLoading" @click="confirmPrintDownload('print')">
225
+ 打印
226
+ </el-button>
227
+ <el-button size="small" @click="printDialogVisible = false">取消</el-button>
228
+ </div>
229
+ </el-dialog>
194
230
  </div>
195
231
  </template>
196
232
 
@@ -341,6 +377,10 @@ export default {
341
377
  loading: false,
342
378
  calcLoading: false,
343
379
  printLoading: false,
380
+ printDialogVisible: false,
381
+ printTemplateList: [],
382
+ selectedTemplateName: '',
383
+ printTemplateLoading: false,
344
384
  model: { type: 1, name: '', code: '', digits: 2, modelTreeVO: {} },
345
385
  sections: [],
346
386
  anchorTabs: [],
@@ -1082,6 +1122,42 @@ export default {
1082
1122
  }
1083
1123
  },
1084
1124
  async printFn() {
1125
+ const logId = this.currentLogId()
1126
+ const modelId = this.currentModelId()
1127
+ if (!logId || !modelId) {
1128
+ this.$message.warning('请先完成测算后再打印')
1129
+ return
1130
+ }
1131
+ this.selectedTemplateName = ''
1132
+ this.printDialogVisible = true
1133
+ await this.loadPrintTemplates()
1134
+ },
1135
+ onPrintDialogClosed() {
1136
+ this.selectedTemplateName = ''
1137
+ },
1138
+ async loadPrintTemplates() {
1139
+ this.printTemplateLoading = true
1140
+ try {
1141
+ const ptType =
1142
+ this.model && this.model.type != null && this.model.type !== '' ? String(this.model.type) : undefined
1143
+ const res = await this.$axios.get(
1144
+ '/imes/print-template/list',
1145
+ ptType ? { ptType } : {},
1146
+ { loading: false }
1147
+ )
1148
+ const list = Array.isArray(res) ? res : (res && res.data) || []
1149
+ this.printTemplateList = Array.isArray(list) ? list : []
1150
+ } catch (e) {
1151
+ this.printTemplateList = []
1152
+ } finally {
1153
+ this.printTemplateLoading = false
1154
+ }
1155
+ },
1156
+ async confirmPrintDownload(action) {
1157
+ if (!this.selectedTemplateName) {
1158
+ this.$message.warning('请选择打印选项')
1159
+ return
1160
+ }
1085
1161
  const logId = this.currentLogId()
1086
1162
  const modelId = this.currentModelId()
1087
1163
  if (!logId || !modelId) {
@@ -1095,24 +1171,47 @@ export default {
1095
1171
  {
1096
1172
  ...extra,
1097
1173
  logId,
1098
- modelId
1174
+ modelId,
1175
+ templateName: this.selectedTemplateName
1099
1176
  }
1100
1177
  ])
1101
1178
  if (res.code !== 0) {
1102
- // this.$message.error(res.msg || '打印失败')
1103
1179
  return
1104
1180
  }
1105
- printJS({
1106
- printable: res.data,
1107
- type: 'pdf',
1108
- base64: true
1109
- })
1181
+ if (action === 'print') {
1182
+ printJS({
1183
+ printable: res.data,
1184
+ type: 'pdf',
1185
+ base64: true
1186
+ })
1187
+ } else {
1188
+ this.downloadPdfBase64(res.data)
1189
+ }
1190
+ this.printDialogVisible = false
1110
1191
  } catch (e) {
1111
- // this.$message.error('打印异常')
1192
+ // keep quiet consistent with previous print catch
1112
1193
  } finally {
1113
1194
  this.printLoading = false
1114
1195
  }
1115
1196
  },
1197
+ downloadPdfBase64(base64) {
1198
+ const pure = String(base64 || '').replace(/^data:application\/pdf;base64,/, '')
1199
+ const binary = atob(pure)
1200
+ const len = binary.length
1201
+ const bytes = new Uint8Array(len)
1202
+ for (let i = 0; i < len; i++) {
1203
+ bytes[i] = binary.charCodeAt(i)
1204
+ }
1205
+ const blob = new Blob([bytes], { type: 'application/pdf' })
1206
+ const url = URL.createObjectURL(blob)
1207
+ const a = document.createElement('a')
1208
+ a.href = url
1209
+ a.download = `${(this.model && this.model.code) || '测算结果'}.pdf`
1210
+ document.body.appendChild(a)
1211
+ a.click()
1212
+ document.body.removeChild(a)
1213
+ URL.revokeObjectURL(url)
1214
+ },
1116
1215
  hasPrintObj(val) {
1117
1216
  return val && typeof val === 'object' && Object.keys(val).length > 0
1118
1217
  },