更新
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable */
|
||||
require('script-loader!file-saver');
|
||||
// import XLSX from 'xlsx'
|
||||
import XLSX from 'xlsx-style'
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
function generateArray(table) {
|
||||
var out = [];
|
||||
var rows = table.querySelectorAll('tr');
|
||||
@@ -145,74 +145,70 @@ export function export_table_to_excel(id) {
|
||||
}
|
||||
|
||||
export function export_json_to_excel({
|
||||
headerGroup,
|
||||
dataGroup,
|
||||
sheetGroup,
|
||||
multiHeader = [],
|
||||
header,
|
||||
data,
|
||||
filename,
|
||||
merges = [],
|
||||
autoWidth = true,
|
||||
bookType= 'xlsx'
|
||||
} = {}) {
|
||||
var wb = new Workbook()
|
||||
for (let i = 0; i < dataGroup.length; i++) {
|
||||
/* original data */
|
||||
let data = dataGroup[i]
|
||||
filename = filename || 'excel-list'
|
||||
data = [...data]
|
||||
data.unshift(headerGroup[i]);
|
||||
var ws_name = sheetGroup[i];
|
||||
var ws = sheet_from_array_of_arrays(data);
|
||||
/* original data */
|
||||
filename = filename || 'excel-list'
|
||||
data = [...data]
|
||||
data.unshift(header);
|
||||
|
||||
if (autoWidth) {
|
||||
/*设置worksheet每列的最大宽度*/
|
||||
const colWidth = data.map(row => row.map(val => {
|
||||
/*先判断是否为null/undefined*/
|
||||
if (val == null) {
|
||||
return {
|
||||
'wch': 10
|
||||
};
|
||||
}
|
||||
/*再判断是否为中文*/
|
||||
else if (val.toString().charCodeAt(0) > 255) {
|
||||
return {
|
||||
'wch': val.toString().length * 2
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'wch': val.toString().length
|
||||
};
|
||||
}
|
||||
}))
|
||||
/*以第一行为初始值*/
|
||||
let result = colWidth[0];
|
||||
for (let i = 1; i < colWidth.length; i++) {
|
||||
for (let j = 0; j < colWidth[i].length; j++) {
|
||||
if (result[j]['wch'] < colWidth[i][j]['wch']) {
|
||||
result[j]['wch'] = colWidth[i][j]['wch'];
|
||||
}
|
||||
for (let i = multiHeader.length-1; i > -1; i--) {
|
||||
data.unshift(multiHeader[i])
|
||||
}
|
||||
|
||||
var ws_name = "SheetJS";
|
||||
var wb = new Workbook(),
|
||||
ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
if (merges.length > 0) {
|
||||
if (!ws['!merges']) ws['!merges'] = [];
|
||||
merges.forEach(item => {
|
||||
ws['!merges'].push(XLSX.utils.decode_range(item))
|
||||
})
|
||||
}
|
||||
|
||||
if (autoWidth) {
|
||||
/*设置worksheet每列的最大宽度*/
|
||||
const colWidth = data.map(row => row.map(val => {
|
||||
/*先判断是否为null/undefined*/
|
||||
if (val == null) {
|
||||
return {
|
||||
'wch': 10
|
||||
};
|
||||
}
|
||||
/*再判断是否为中文*/
|
||||
else if (val.toString().charCodeAt(0) > 255) {
|
||||
return {
|
||||
'wch': val.toString().length * 2
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'wch': val.toString().length
|
||||
};
|
||||
}
|
||||
}))
|
||||
/*以第一行为初始值*/
|
||||
let result = colWidth[0];
|
||||
for (let i = 1; i < colWidth.length; i++) {
|
||||
for (let j = 0; j < colWidth[i].length; j++) {
|
||||
if (result[j]['wch'] < colWidth[i][j]['wch']) {
|
||||
result[j]['wch'] = colWidth[i][j]['wch'];
|
||||
}
|
||||
}
|
||||
ws['!cols'] = result;
|
||||
}
|
||||
let R = 0;
|
||||
data.map(item => {
|
||||
let C = 0;
|
||||
item.map(itm => {
|
||||
var cell_ref = XLSX.utils.encode_cell({c:C,r:R});
|
||||
var cell = {v: itm }
|
||||
cell.s= {
|
||||
alignment: {
|
||||
horizontal: "center"
|
||||
}
|
||||
}
|
||||
ws[cell_ref] = cell;
|
||||
C++;
|
||||
})
|
||||
R++;
|
||||
})
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
ws['!cols'] = result;
|
||||
}
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {
|
||||
bookType: bookType,
|
||||
bookSST: false,
|
||||
|
||||
@@ -706,11 +706,20 @@
|
||||
<el-dialog :visible.sync="dialogVisible2" :title="title2" center style="min-height: 300px" width="400px">
|
||||
<el-form ref="form2" :model="form2" :rules="rules2" label-position="left" label-width="90px">
|
||||
<el-form-item label="询价单号" prop="inquirySheetNum">
|
||||
<el-input v-model="form2.inquirySheetNum" size="small"/>
|
||||
<el-input v-model="form2.inquirySheetNum" readonly size="small"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商" prop="supplierName">
|
||||
<el-input v-model="form2.supplierName" size="small" readonly @focus="dialogVisible1=true;enterpriseNature = '';createDate = '';registeredCapital = '';taxNum = '';EMail = '';address = '';account = '';openingBank = '';phone = '';fax = '';goodTime = ''"/>
|
||||
<el-form-item label="供应商" prop="supplierNameValue">
|
||||
<el-select v-model="form2.supplierNameValue" style="width:200px" placeholder="供应商" size="small" filterable>
|
||||
<el-option
|
||||
v-for="item in supplierNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!--<el-form-item label="供应商" prop="supplierName">-->
|
||||
<!--<el-input v-model="form2.supplierName" size="small" readonly @focus="dialogVisible1=true;enterpriseNature = '';createDate = '';registeredCapital = '';taxNum = '';EMail = '';address = '';account = '';openingBank = '';phone = '';fax = '';goodTime = ''"/>-->
|
||||
<!--</el-form-item>-->
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="dialogVisible2=false">取消</el-button>
|
||||
@@ -718,7 +727,7 @@
|
||||
v-show="title2==='创建询价单'"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="submitCreateInquirySheet">确定</el-button>
|
||||
@click="submitCreateInquirySheet1">确定</el-button>
|
||||
<el-button
|
||||
v-show="title2==='编辑询价单'"
|
||||
type="primary"
|
||||
@@ -857,7 +866,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { searchMaterial, searchPart, searchSupplier, searchCreateInquirySheet, searchCreateInquirySheet2, searchSheetDetail, editInquirySheet,
|
||||
import { getBillNum, searchMaterial, searchPart, searchSupplier, searchCreateInquirySheet, searchCreateInquirySheet2, searchSheetDetail, editInquirySheet,
|
||||
createInquirySheet, deleteInquirySheet, addInquirySheet1, addInquirySheet2, outInquirySheet, searchAllMaterial, materialChange, saveOrder,
|
||||
submitUseInventory, initProject, searchMachine, searchGroup, searchBaseInfo, editBaseInfo, getExport1, getExport2, searchMerge } from '@/api/PurchasingCenter/CreateInquirySheet'
|
||||
import { mapGetters } from 'vuex'
|
||||
@@ -869,6 +878,7 @@ export default {
|
||||
name: '', // 创建询价单
|
||||
data() {
|
||||
return {
|
||||
supplierNames: [], // 供应商下拉框
|
||||
switchValue: false, // 物料变更列显示开关
|
||||
source: [
|
||||
{
|
||||
@@ -992,11 +1002,13 @@ export default {
|
||||
inquirySheetNumValue: '', // 询价单流水号
|
||||
inquirySheetNum: '',
|
||||
supplierName: '',
|
||||
supplierValue: ''
|
||||
supplierValue: '',
|
||||
supplierNameValue: ''
|
||||
},
|
||||
rules2: { // 表单验证规则
|
||||
inquirySheetNum: [{ required: true, message: '请填写询价单号' }],
|
||||
supplierName: [{ required: true, message: '请选择供应商' }]
|
||||
supplierName: [{ required: true, message: '请选择供应商' }],
|
||||
supplierNameValue: [{ required: true, message: '请选择供应商', trigger: 'change' }]
|
||||
},
|
||||
groupPartNum: [], // 组件零件流水号
|
||||
groupPartBasicNum: [], // 组件零件基本件流水号
|
||||
@@ -1284,6 +1296,14 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
searchSupplier(0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '').then(response => {
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
this.supplierNames.push({
|
||||
label: response.data[i].供应商名称,
|
||||
value: response.data[i].供应商流水号
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
projectChange() {
|
||||
this.machine = []
|
||||
@@ -1460,15 +1480,18 @@ export default {
|
||||
this.pageCurrent2 = val
|
||||
this.searchTable2()
|
||||
},
|
||||
createInquirySheet() { // 创建空单据--询价单
|
||||
createInquirySheet() { // 创建空单据--询价单9745
|
||||
if (this.$refs['form2'] !== undefined) {
|
||||
this.$refs['form2'].resetFields()
|
||||
}
|
||||
this.title2 = '创建询价单'
|
||||
this.form2.inquirySheetNum = ''
|
||||
this.form2.supplierValue = ''
|
||||
this.form2.supplierName = ''
|
||||
this.dialogVisible2 = true
|
||||
getBillNum().then(response => { // 查询询价单号
|
||||
this.form2.inquirySheetNum = response.data[0].单号
|
||||
this.form2.supplierValue = ''
|
||||
this.form2.supplierNameValue = ''
|
||||
this.form2.supplierName = ''
|
||||
this.dialogVisible2 = true
|
||||
})
|
||||
},
|
||||
submitCreateInquirySheet() { // 提交创建询价单
|
||||
this.$refs['form2'].validate((valid) => {
|
||||
@@ -1482,7 +1505,7 @@ export default {
|
||||
if (numGroup1.indexOf(this.form2.inquirySheetNum) !== -1) {
|
||||
this.$message.error('该询价单号已存在')
|
||||
} else {
|
||||
createInquirySheet(this.form2.inquirySheetNum, this.form2.supplierValue, '', this.id).then(response => {
|
||||
createInquirySheet(this.form2.inquirySheetNum, this.id, this.form2.supplierValue, '').then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.$message.success('创建成功')
|
||||
this.inquirySheetNum = ''
|
||||
@@ -1500,6 +1523,24 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
submitCreateInquirySheet1() { // 提交创建询价单
|
||||
this.$refs['form2'].validate((valid) => {
|
||||
if (valid) {
|
||||
createInquirySheet(this.form2.inquirySheetNum, this.id, this.form2.supplierNameValue, '').then(response => {
|
||||
console.log(response.data)
|
||||
if (response.data[0].result === '1') {
|
||||
this.$message.success('创建成功')
|
||||
this.form2.supplierNameValue = ''
|
||||
this.inquirySheetNum = ''
|
||||
this.supplierName = ''
|
||||
this.supplierValue = ''
|
||||
this.dialogVisible2 = false
|
||||
this.searchTable2()
|
||||
} else { this.$message.error('操作失败') }
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteInquirySheet(row) { // 删除询价单
|
||||
this.$confirm('确定删除该询价单?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
|
||||
Reference in New Issue
Block a user