import_cma 优化

This commit is contained in:
caoqianming 2020-12-21 16:16:50 +08:00
parent 430a41a7e0
commit b3232df682
3 changed files with 33 additions and 60 deletions

View File

@ -435,6 +435,7 @@ export default {
this.getList(); this.getList();
this.getList2(); this.getList2();
this.getGroup(); this.getGroup();
this.getGroup2();
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;
@ -443,6 +444,7 @@ export default {
this.listQuery2.search = this.listQuery.search; this.listQuery2.search = this.listQuery.search;
this.getList2(); this.getList2();
this.getGroup(); this.getGroup();
this.getGroup2();
}, },
handleAdd() { handleAdd() {
this.cma = Object.assign({}, defaultCMA); this.cma = Object.assign({}, defaultCMA);
@ -485,6 +487,13 @@ export default {
this.listQuery.page = 1; this.listQuery.page = 1;
this.getList(); this.getList();
}, },
filterChange2(obj) {
for (let key in obj) {
this.listQuery2[key] = obj[key][0];
}
this.listQuery2.page = 1;
this.getList2();
},
async confirm(form) { async confirm(form) {
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (valid) { if (valid) {

View File

@ -89,7 +89,7 @@
highlight-current-row highlight-current-row
max-height="700" max-height="700"
ref="filterTable" ref="filterTable"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange"
@filter-change="filterChange" @filter-change="filterChange"
> >
<el-table-column <el-table-column
@ -324,7 +324,6 @@ export default {
data.group_by = key; data.group_by = key;
getCMAGroup(data).then((response) => { getCMAGroup(data).then((response) => {
this.groupBy[key] = response.data; this.groupBy[key] = response.data;
console.log(this.groupBy);
}); });
} }
}, },
@ -372,7 +371,6 @@ export default {
}); });
}) })
.catch((err) => { .catch((err) => {
console.error(err);
}); });
}, },
@ -399,7 +397,6 @@ export default {
}) })
}) })
.catch((err) => { .catch((err) => {
console.error(err);
}); });
}, },
@ -407,6 +404,7 @@ export default {
this.multipleSelection = val; this.multipleSelection = val;
}, },
filterChange(obj) { filterChange(obj) {
console.log(obj)
for (let key in obj) { for (let key in obj) {
this.listQuery[key] = obj[key][0]; this.listQuery[key] = obj[key][0];
} }

View File

@ -432,84 +432,49 @@ def import_cma2(filename, path):
CMA.objects.filter(sszx=sszx, type='sub').delete() CMA.objects.filter(sszx=sszx, type='sub').delete()
i = 3 i = 3
max_row = sheet.max_row max_row = sheet.max_row
defaultv = {}
while i<max_row+1: while i<max_row+1:
data = {} data = {}
if sheet['a'+str(i)].value: if sheet['a'+str(i)].value:
data['dlxh'] = sheet['a'+str(i)].value data['dlxh'] = sheet['a'+str(i)].value
elif sheet['a3'].value: defaultv['dlxh'] = data['dlxh']
m = i - 1 else:
while True: data['dlxh'] = defaultv['dlxh']
if sheet['a'+str(m)].value:
data['dlxh'] = sheet['a'+str(m)].value
break
m = m - 1
if sheet['b'+str(i)].value: if sheet['b'+str(i)].value:
data['dlmc'] = sheet['b'+str(i)].value data['dlmc'] = sheet['b'+str(i)].value
elif sheet['b3'].value: defaultv['dlmc'] = data['dlmc']
m = i - 1 else:
while True: data['dlmc'] = defaultv['dlmc']
if sheet['b'+str(m)].value:
data['dlmc'] = sheet['b'+str(m)].value
break
m = m - 1
if sheet['c'+str(i)].value: if sheet['c'+str(i)].value:
data['lbxh'] = sheet['c'+str(i)].value data['lbxh'] = sheet['c'+str(i)].value
defaultv['lbxh'] = data['lbxh']
else: else:
m = i - 1 data['lbxh'] = defaultv['lbxh']
while True:
if sheet['c'+str(m)].value:
data['lbxh'] = sheet['c'+str(m)].value
break
m = m - 1
if sheet['d'+str(i)].value: if sheet['d'+str(i)].value:
data['lbmc'] = sheet['d'+str(i)].value data['lbmc'] = sheet['d'+str(i)].value
defaultv['lbmc'] = data['lbmc']
else: else:
m = i - 1 data['lbmc'] = defaultv['lbmc']
while True:
if sheet['d'+str(m)].value:
data['lbmc'] = sheet['d'+str(m)].value
break
m = m - 1
if sheet['e'+str(i)].value: if sheet['e'+str(i)].value:
data['xmxh'] = sheet['e'+str(i)].value data['xmxh'] = sheet['e'+str(i)].value
elif sheet['e3'].value: # 该表存在项目序号 defaultv['xmxh'] = data['xmxh']
m = i - 1 else:
while True: data['xmxh'] = defaultv['xmxh']
if sheet['e'+str(m)].value:
data['xmxh'] = sheet['e'+str(m)].value
break
m = m - 1
else: #该表没有项目序号,自己定
pass
if sheet['f'+str(i)].value: if sheet['f'+str(i)].value:
data['xmmc'] = sheet['f'+str(i)].value data['xmmc'] = sheet['f'+str(i)].value
elif sszx=='枣庄公司': defaultv['xmmc'] = data['xmmc']
pass
else: else:
m = i - 1 data['xmmc'] = defaultv['xmmc']
while True:
if sheet['f'+str(m)].value:
data['xmmc'] = sheet['f'+str(m)].value
break
m = m - 1
if sheet['g'+str(i)].value: if sheet['g'+str(i)].value:
data['bzmc'] = sheet['g'+str(i)].value data['bzmc'] = sheet['g'+str(i)].value
defaultv['bzmc'] = data['bzmc']
else: else:
m = i - 1 data['bzmc'] = defaultv['bzmc']
while True:
if sheet['g'+str(m)].value:
data['bzmc'] = sheet['g'+str(m)].value
break
m = m - 1
if sheet['h'+str(i)].value: if sheet['h'+str(i)].value:
data['bzbh'] = sheet['h'+str(i)].value data['bzbh'] = sheet['h'+str(i)].value
elif sheet['h3'].value: defaultv['bzbh'] = data['bzbh']
m = i - 1 else:
while True: data['bzbh'] = defaultv['bzbh']
if sheet['h'+str(m)].value:
data['bzbh'] = sheet['h'+str(m)].value
break
m = m - 1
data['xzfw'] = sheet['i'+str(i)].value if (sheet['i'+str(i)].value and sheet['i'+str(i)].value !='') else None data['xzfw'] = sheet['i'+str(i)].value if (sheet['i'+str(i)].value and sheet['i'+str(i)].value !='') else None
data['bz'] = sheet['j'+str(i)].value if (sheet['j'+str(i)].value and sheet['j'+str(i)].value !='') else None data['bz'] = sheet['j'+str(i)].value if (sheet['j'+str(i)].value and sheet['j'+str(i)].value !='') else None
data['glzz'] = sheet['k'+str(i)].value if (sheet['k'+str(i)].value and sheet['k'+str(i)].value !='') else None data['glzz'] = sheet['k'+str(i)].value if (sheet['k'+str(i)].value and sheet['k'+str(i)].value !='') else None
@ -527,6 +492,7 @@ def import_inspection(filename, path):
Inspection.objects.filter(sszx=sszx).delete() Inspection.objects.filter(sszx=sszx).delete()
i = 3 i = 3
max_row = sheet.max_row max_row = sheet.max_row
defaultv = {}
while i<max_row+1: while i<max_row+1:
data = {} data = {}
if sheet['a'+str(i)].value: if sheet['a'+str(i)].value: