标签:val cts shift ddr object 插件 bsp not span
// 前端js操作csv文件插件用法 插件下载地址:https://github.com/okfn/csv.js/ $(‘#id_mac_file‘).change(function () { $(‘#id_mac_address‘).parent().next().text(‘‘); $(‘input[type=checkbox]‘)[0].checked = false; if (!(window.File || window.FileReader || window.FileList || window.Blob)) { alert(‘请使用Chrome浏览器!‘); } var mac_str=‘‘; var files = $(‘input[name="mac_file"]‘).prop(‘files‘);//获取到文件列表 if (files.length === 0) return; var reader = new FileReader();//新建一个FileReader reader.readAsText(files[0], "gbk");//读取文件 reader.onload = function(evt){ //读取完文件之后会回来这里 var fileString = evt.target.result; var a = CSV.parse(fileString, { header: [‘mac‘] }); a.shift(); // 去a列表的第一个元素 for (var i=0; i < a.length; i++ ){ mac_str = mac_str + a[i][0]+‘\r\n‘ } $(‘#id_mac_address‘).val(mac_str) $(‘#id_nums‘).val(a.length) } })
# 这个是在没有直接关联的几张表中四个字段按与的关系搜索(采用的是集合方式完成此功能的) if request.method == ‘POST‘: mac_address = request.POST.get(‘mac_address‘) date_rang = request.POST.get(‘date_rang‘) Audit_status = request.POST.get(‘Audit_status‘) model = request.POST.get(‘model‘) if request.mac.user.depart_id.all()[0].department_name == ‘系统管理部门‘: notice_query = models.Notice.objects.all().order_by(‘-delivery_date‘) else: notice_query = models.Notice.objects.filter(user=request.mac.user).order_by(‘-delivery_date‘) set_list = [] mac_set = set() if mac_address: for i in notice_query: if mac_address in i.mac_address.split(‘\r\n‘): mac_set.add(i) break set_list.append(mac_set) date_set = set() if date_rang: date_start = date_rang.split(‘ - ‘)[0] date_end = date_rang.split(‘ - ‘)[1] date_start = datetime.strptime(date_start, ‘%Y-%m-%d‘) date_end = datetime.strptime(date_end, ‘%Y-%m-%d‘) for i in notice_query: if i.delivery_date.replace(tzinfo=None) >= date_start and i.delivery_date.replace(tzinfo=None) <= date_end: date_set.add(i) set_list.append(date_set) status_set = set() if Audit_status and Audit_status == ‘待处理‘ or Audit_status == ‘备货中‘: if Audit_status == ‘待处理‘: Audit_status = 0 else: Audit_status = 1 for i in notice_query: if Audit_status == i.status: status_set.add(i) set_list.append(status_set) model_set = set() if model: mac_query = models.Macs.objects.filter(model=model).values_list(‘mac‘) mac_lst = [] for i in mac_query: mac_lst.append(i[0]) for i in notice_query: for y in i.mac_address.split(‘\r\n‘): if y in mac_lst: model_set.add(i) set_list.append(model_set) res = None a = 0 for i in set_list: if a == 0: res = i else: res = res & i a += 1 notice_query = res print(type(res))
标签:val cts shift ddr object 插件 bsp not span
原文地址:https://www.cnblogs.com/xiongfanyong/p/13292529.html