| | |
| | | <template> |
| | | <div style="margin-top: -40px;"> |
| | | <el-form ref="formData" :model="formData" label-width="100px"> |
| | | <div style="padding: 10px; "> |
| | | <el-button type="primary" size="small" @click="printClick" v-if=false>报表打印</el-button> |
| | | <el-button type="primary" size="small" @click="printClickWeb">报表打印(网页)</el-button> |
| | | </div> |
| | | <el-table v-loading="loading" :data="printdata" ref="printTable" max-height="540" |
| | | @selection-change="handleSelectionChange" :row-class-name="rowSysIndex" border> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column align="center" label="模块代码" prop="HNumber" v-if="hideFlag" /> |
| | | <el-table-column align="center" label="模板名称" prop="模板名称" /> |
| | | </el-table> |
| | | </el-form> |
| | | <el-dialog title="报表打印" :visible.sync="openPrint" width="800px" append-to-body> |
| | | <div ref="print" id="printId">111</div> |
| | | <el-button type="primary" size="small" @click="printClick">打印</el-button> |
| | | </el-dialog> |
| | | </div> |
| | | <div style="margin-top: -40px;"> |
| | | <el-form ref="formData" :model="formData" label-width="100px"> |
| | | <div style="padding: 10px; "> |
| | | <el-button type="primary" size="small" @click="printClick">报表打印</el-button> |
| | | <el-button type="primary" size="small" @click="printClickWeb">报表打印(网页)</el-button> |
| | | <a-button type="primary" icon="eye" @click="preView">预览</a-button> |
| | | </div> |
| | | <el-table v-loading="loading" :data="printdata" ref="printTable" max-height="540" |
| | | @selection-change="handleSelectionChange" :row-class-name="rowSysIndex" border> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column align="center" label="模块代码" prop="HNumber" v-if="hideFlag" /> |
| | | <el-table-column align="center" label="模板名称" prop="模板名称" /> |
| | | </el-table> |
| | | </el-form> |
| | | <el-dialog title="报表打印" :visible.sync="openPrint" width="800px" append-to-body> |
| | | <div ref="print" id="printId">111</div> |
| | | <el-button type="primary" size="small" @click="printClick">打印</el-button> |
| | | </el-dialog> |
| | | <print-preview ref="preView" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import axios from 'axios' |
| | | |
| | | import printPreview from './preview' |
| | | export default { |
| | | name: 'PrintList', |
| | | props: { |
| | | linterid: { type: Number, }, |
| | | MyMsg: { type: Number, }, |
| | | Type: { type: String, }, |
| | | HModName: { type: String, } |
| | | }, |
| | | data() { |
| | | return { |
| | | openPrint: false, |
| | | selRowData: [], |
| | | baseURL: process.env.VUE_APP_BASE_API, |
| | | user: 'admin',//登录用户名 |
| | | // 表格数据 |
| | | printdata: [], |
| | | // 选中数组index |
| | | selIndex: [], |
| | | // 非单个禁用 |
| | | single: true, |
| | | // 非多个禁用 |
| | | multiple: true, |
| | | // 遮罩层 |
| | | loading: true, |
| | | formData: { |
| | | HFixCols: '', |
| | | HFontSize: '', |
| | | HColumnWidth: '', |
| | | HPageSize: '', |
| | | HSortFlag: '', |
| | | HSelTotal: '' |
| | | }, |
| | | colTitleName: '', |
| | | tableIns: null, |
| | | option: {}, |
| | | tableData: [], |
| | | hideFlag:false, //隐藏标记。用于设置某些不希望显示的标签 // 当前选中的行 |
| | | } |
| | | }, |
| | | created() { |
| | | this.getDisplay() |
| | | }, |
| | | methods: { |
| | | handlePrint() { |
| | | this.openPrint = true |
| | | }, |
| | | printClickWeb() { |
| | | const routeUrl = this.$router.resolve({ path: '/hBarPlanPrintWeb',query:{linterid:this.linterid.toString(),Type:this.Type.toString(),OpenTmp: encodeURIComponent(this.rowForm.模板名称)} }); |
| | | window.open(routeUrl.href, '_blank'); |
| | | }, |
| | | printClick() { |
| | | const routeUrl = this.$router.resolve({ path: '/hBarPlanPrint',query:{linterid:this.linterid.toString(),Type:this.Type.toString(),OpenTmp: encodeURIComponent(this.rowForm.模板名称)} }); |
| | | window.open(routeUrl.href, '_blank'); |
| | | }, |
| | | getDisplay() { |
| | | this.loading = true |
| | | axios.get(this.$baseUrl + '/Open_PrintTem/GetOpenTmpList_Json', { |
| | | params: { "HNumber": this.Type }, |
| | | }).then(response => { |
| | | console.log(response) |
| | | var result = response.data |
| | | this.printdata = result.data |
| | | this.loading = false |
| | | }).catch(error => { |
| | | console.log(error) |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }, |
| | | //上一行 |
| | | handleMoveRowUp(row) { |
| | | if (this.selRowData.length != 1) { |
| | | this.$modal.msgError("请选择一行数据!") |
| | | } else { |
| | | let num = row.index - 1 |
| | | if (num == 0) { |
| | | this.$modal.msgError("第一行数据无法上移"); |
| | | } else { // 确保不是第一行 |
| | | const record = this.rowTitleData.splice(num, 1)[0]; |
| | | this.rowTitleData.splice(num - 1, 0, record); |
| | | } |
| | | } |
| | | console.log(this.rowTitleData) |
| | | }, |
| | | //下一行 |
| | | handleMoveRowDown(row) { |
| | | if (this.selRowData.length != 1) { |
| | | this.$modal.msgError("请选择一行数据") |
| | | } else { |
| | | let num = row.index - 1 |
| | | if (num == this.rowTitleData.length - 1) { |
| | | this.$modal.msgError("最后一行数据无法下移"); |
| | | } else { // 确保不是第一行 |
| | | const record = this.rowTitleData.splice(num, 1)[0]; |
| | | this.rowTitleData.splice(num + 1, 0, record); |
| | | } |
| | | } |
| | | }, |
| | | // 多选框选中数据 |
| | | handleSelectionChange(selection) { |
| | | //单选 |
| | | if (selection.length > 1) { |
| | | const del_row = selection.shift() |
| | | this.$refs.printTable.toggleRowSelection(del_row, false) //设置这一行取消选中 |
| | | } |
| | | this.rowForm = {} |
| | | this.ids = selection.map(item => item.HItemID) |
| | | this.rowForm = selection[0] |
| | | }, |
| | | //表格行索引 |
| | | rowSysIndex({ row, rowIndex }) { |
| | | row.index = rowIndex + 1; |
| | | }, |
| | | //全选 |
| | | handleCheckAll() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].IsHide = true; |
| | | } |
| | | }, |
| | | //全清 |
| | | handleClearBill() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].IsHide = false; |
| | | } |
| | | }, |
| | | //全居中 |
| | | handleCenter() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].Alignment = 'M'; |
| | | } |
| | | }, |
| | | //保存 |
| | | handleSave() { |
| | | const cache = this.rowTitleData |
| | | const num = cache.filter(item => item !== "").map((item, i) => { |
| | | item.LAY_TABLE_INDEX = i |
| | | return item |
| | | }) |
| | | // 验证分页参数 |
| | | const HPageSize = this.formData.HPageSize |
| | | if (HPageSize && !/^[0-9]+$/.test(HPageSize)) { |
| | | this.$modal.msgError("默认分页不为正整数!") |
| | | return |
| | | } |
| | | const sMainStr = JSON.stringify(this.formData) |
| | | const sSubStr = JSON.stringify(num) |
| | | const OperationType = "1" |
| | | const sMainSub = `${sMainStr};${sSubStr};${this.HModName};${OperationType};${this.user}` |
| | | axios({ |
| | | method: 'post', |
| | | url: this.$baseUrl + "/Xt_grdAlignment_WMES/AddgrdAlignmentWMES", |
| | | data: { |
| | | 'sMainSub': sMainSub |
| | | }, |
| | | }).then(response => { |
| | | console.log(1, response) |
| | | if (response.data.count == 1) { |
| | | this.$modal.msgSuccess("提交成功") |
| | | } else { |
| | | this.$modal.msgError(response.data.Message); |
| | | } |
| | | }).catch(error => { |
| | | console.log(2, error) |
| | | |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }, |
| | | //退出 |
| | | handleExit() { |
| | | this.$emit('rowEditClose', false) |
| | | }, |
| | | // 删除 |
| | | handleDel() { |
| | | this.$modal.confirm('确认要删除吗,删除后不能恢复').then(() => { |
| | | console.log(this.rowForm.hmainid.toString()) |
| | | axios.get(this.$baseUrl + "/Xt_grdAlignment_WMES/DelgrdAlignmentWMES", { |
| | | params: { "HModName": this.HModName, "user": this.user } |
| | | }).then(response => { |
| | | let result = response.data |
| | | if (response.data.count == 1) { |
| | | this.getList() |
| | | this.$modal.msgSuccess(result.Message) |
| | | } else { |
| | | this.$modal.msgError("错误:" + result.code + result.Message); |
| | | } |
| | | }).catch(error => { |
| | | console.log(error) |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }).catch(() => { }) |
| | | }, |
| | | name: 'PrintList', |
| | | props: { |
| | | linterid: { type: Number | String, }, |
| | | MyMsg: { type: Number | String, default: '' }, |
| | | Type: { type: String, }, |
| | | HModName: { type: String, } |
| | | }, |
| | | components: { printPreview }, |
| | | data() { |
| | | return { |
| | | openPrint: false, |
| | | selRowData: [], |
| | | baseURL: process.env.VUE_APP_BASE_API, |
| | | user: 'admin',//登录用户名 |
| | | // 表格数据 |
| | | printdata: [], |
| | | // 选中数组index |
| | | selIndex: [], |
| | | // 非单个禁用 |
| | | single: true, |
| | | // 非多个禁用 |
| | | multiple: true, |
| | | // 遮罩层 |
| | | loading: true, |
| | | formData: { |
| | | HFixCols: '', |
| | | HFontSize: '', |
| | | HColumnWidth: '', |
| | | HPageSize: '', |
| | | HSortFlag: '', |
| | | HSelTotal: '' |
| | | }, |
| | | colTitleName: '', |
| | | tableIns: null, |
| | | option: {}, |
| | | tableData: [], |
| | | hideFlag: false, //隐藏标记。用于设置某些不希望显示的标签 // 当前选中的行 |
| | | } |
| | | }, |
| | | created() { |
| | | this.getDisplay() |
| | | }, |
| | | methods: { |
| | | async preView() { |
| | | console.log(this.rowForm) |
| | | let templateName = this.rowForm["模板名称"] |
| | | if (templateName) { |
| | | let printTemplate = await axios.get(`/static/printTemplate/${templateName}.json`) |
| | | let printData = await this.getPrintData() |
| | | |
| | | this.openPrint = false |
| | | this.$refs.preView.show(printTemplate.data, printData.data.data) |
| | | } else { |
| | | this.$modal.msgWarning("未选中模板,请选中模板后再预览"); |
| | | } |
| | | }, |
| | | handlePrint() { |
| | | this.openPrint = true |
| | | }, |
| | | printClickWeb() { |
| | | const routeUrl = this.$router.resolve({ path: '/hBarPlanPrintWeb', query: { linterid: this.linterid.toString(), Type: this.Type.toString(), OpenTmp: encodeURIComponent(this.rowForm.模板名称) } }); |
| | | window.open(routeUrl.href, '_blank'); |
| | | }, |
| | | printClick() { |
| | | const routeUrl = this.$router.resolve({ path: '/hBarPlanPrint', query: { linterid: this.linterid.toString(), Type: this.Type.toString(), OpenTmp: encodeURIComponent(this.rowForm.模板名称) } }); |
| | | window.open(routeUrl.href, '_blank'); |
| | | }, |
| | | getDisplay() { |
| | | this.loading = true |
| | | axios.get(this.$baseUrl + '/Open_PrintTem/GetOpenTmpList_Json', { |
| | | params: { "HNumber": this.Type }, |
| | | }).then(response => { |
| | | console.log(response) |
| | | var result = response.data |
| | | this.printdata = result.data |
| | | this.loading = false |
| | | }).catch(error => { |
| | | console.log(error) |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }, |
| | | //上一行 |
| | | handleMoveRowUp(row) { |
| | | if (this.selRowData.length != 1) { |
| | | this.$modal.msgError("请选择一行数据!") |
| | | } else { |
| | | let num = row.index - 1 |
| | | if (num == 0) { |
| | | this.$modal.msgError("第一行数据无法上移"); |
| | | } else { // 确保不是第一行 |
| | | const record = this.rowTitleData.splice(num, 1)[0]; |
| | | this.rowTitleData.splice(num - 1, 0, record); |
| | | } |
| | | } |
| | | console.log(this.rowTitleData) |
| | | }, |
| | | //下一行 |
| | | handleMoveRowDown(row) { |
| | | if (this.selRowData.length != 1) { |
| | | this.$modal.msgError("请选择一行数据") |
| | | } else { |
| | | let num = row.index - 1 |
| | | if (num == this.rowTitleData.length - 1) { |
| | | this.$modal.msgError("最后一行数据无法下移"); |
| | | } else { // 确保不是第一行 |
| | | const record = this.rowTitleData.splice(num, 1)[0]; |
| | | this.rowTitleData.splice(num + 1, 0, record); |
| | | } |
| | | } |
| | | }, |
| | | // 多选框选中数据 |
| | | handleSelectionChange(selection) { |
| | | //单选 |
| | | if (selection.length > 1) { |
| | | const del_row = selection.shift() |
| | | this.$refs.printTable.toggleRowSelection(del_row, false) //设置这一行取消选中 |
| | | } |
| | | this.rowForm = {} |
| | | this.ids = selection.map(item => item.HItemID) |
| | | this.rowForm = selection[0] |
| | | }, |
| | | //表格行索引 |
| | | rowSysIndex({ row, rowIndex }) { |
| | | row.index = rowIndex + 1; |
| | | }, |
| | | //全选 |
| | | handleCheckAll() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].IsHide = true; |
| | | } |
| | | }, |
| | | //全清 |
| | | handleClearBill() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].IsHide = false; |
| | | } |
| | | }, |
| | | //全居中 |
| | | handleCenter() { |
| | | for (var i = 0; i < this.rowTitleData.length; i++) { |
| | | this.rowTitleData[i].Alignment = 'M'; |
| | | } |
| | | }, |
| | | //保存 |
| | | handleSave() { |
| | | const cache = this.rowTitleData |
| | | const num = cache.filter(item => item !== "").map((item, i) => { |
| | | item.LAY_TABLE_INDEX = i |
| | | return item |
| | | }) |
| | | // 验证分页参数 |
| | | const HPageSize = this.formData.HPageSize |
| | | if (HPageSize && !/^[0-9]+$/.test(HPageSize)) { |
| | | this.$modal.msgError("默认分页不为正整数!") |
| | | return |
| | | } |
| | | const sMainStr = JSON.stringify(this.formData) |
| | | const sSubStr = JSON.stringify(num) |
| | | const OperationType = "1" |
| | | const sMainSub = `${sMainStr};${sSubStr};${this.HModName};${OperationType};${this.user}` |
| | | axios({ |
| | | method: 'post', |
| | | url: this.$baseUrl + "/Xt_grdAlignment_WMES/AddgrdAlignmentWMES", |
| | | data: { |
| | | 'sMainSub': sMainSub |
| | | }, |
| | | }).then(response => { |
| | | console.log(1, response) |
| | | if (response.data.count == 1) { |
| | | this.$modal.msgSuccess("提交成功") |
| | | } else { |
| | | this.$modal.msgError(response.data.Message); |
| | | } |
| | | }).catch(error => { |
| | | console.log(2, error) |
| | | |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }, |
| | | //退出 |
| | | handleExit() { |
| | | this.$emit('rowEditClose', false) |
| | | }, |
| | | // 删除 |
| | | handleDel() { |
| | | this.$modal.confirm('确认要删除吗,删除后不能恢复').then(() => { |
| | | console.log(this.rowForm.hmainid.toString()) |
| | | axios.get(this.$baseUrl + "/Xt_grdAlignment_WMES/DelgrdAlignmentWMES", { |
| | | params: { "HModName": this.HModName, "user": this.user } |
| | | }).then(response => { |
| | | let result = response.data |
| | | if (response.data.count == 1) { |
| | | this.getList() |
| | | this.$modal.msgSuccess(result.Message) |
| | | } else { |
| | | this.$modal.msgError("错误:" + result.code + result.Message); |
| | | } |
| | | }).catch(error => { |
| | | console.log(error) |
| | | this.$modal.msgError("接口请求失败!"); |
| | | }); |
| | | }).catch(() => { }) |
| | | }, |
| | | getPrintData() { |
| | | let sql = ""; |
| | | if (this.Type == "Kf_SellOutBillList") { |
| | | sql = |
| | | "exec h_p_Kf_SellOutBillList_PrintSellOutBill " + |
| | | this.linterid; |
| | | } else if (this.Type == "HGy_BarCodeBill") { |
| | | sql = |
| | | "select * from h_v_IF_BarCodeBillList where hmainid in(" + |
| | | this.linterid + |
| | | ") order by hmainid desc"; |
| | | } else if (this.Type == "HPOInStockBill") { |
| | | sql = |
| | | "select * from h_v_Sc_PrintMouldProdOutBillList where hmainid=" + |
| | | this.linterid + |
| | | " order by hmainid"; |
| | | } else if (this.Type == "HGyStockPlaceBarCode") { |
| | | let condition = decodeURI(this.linterid); |
| | | sql = `SELECT |
| | | CEILING(CAST(t.row_num AS FLOAT) / 2) AS orderid, |
| | | MAX(CASE WHEN t.row_num % 2 = 1 THEN t.条码编号 END) AS 条码编号1, |
| | | MAX(CASE WHEN t.row_num % 2 = 1 THEN t.仓位名称 END) AS 仓位名称1, |
| | | MAX(CASE WHEN t.row_num % 2 = 0 THEN t.条码编号 END) AS 条码编号2, |
| | | MAX(CASE WHEN t.row_num % 2 = 0 THEN t.仓位名称 END) AS 仓位名称2 |
| | | FROM ( |
| | | SELECT |
| | | 条码编号, 仓位名称, |
| | | ROW_NUMBER() OVER (ORDER BY t1.HItemID) AS row_num |
| | | FROM h_v_IF_StockPlaceList t1 where 条码编号 in (${condition}) |
| | | ) AS t |
| | | GROUP BY CEILING(CAST(t.row_num AS FLOAT) / 2) |
| | | ORDER BY orderid;`; |
| | | } else if (this.Type == "WL_YayBill") { |
| | | |
| | | sql = "select * from h_v_WL_YayBilllist where hmainid in(" + |
| | | this.linterid + |
| | | ") order by hmainid desc"; |
| | | } |
| | | |
| | | return axios.get(this.$baseUrl + "/CommonModel/searchMethod", { |
| | | params: { |
| | | sql: sql, |
| | | user: sessionStorage["HUserName"], |
| | | ModRightNameCheck: " ", |
| | | // , "HSubID": data[i].hsubid |
| | | }, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |