def on_accept_button_clicked(self): if self.prodname.flat == 0: text = "没有找到对应的产品信息,请修改后重试!" informative = "选择好产品名称后请不要再修改,否则将导致系统无法找到正确的产品!" errordialig = MessageBox(self, text=text, informative=informative) errordialig.exec() self.prodname.setFocus() return if len(self.no_enough_stuff_list): text = "以下物料不足!" informative = ";\n".join(self.no_enough_stuff_list) errordialig = MessageBox(self, text=text, informative=informative, yes_text="继续下达指令") res = errordialig.exec() if res == 65536: self.prodname.setFocus() return # 有修改过数据 if self.new_detail: try: # 修改过记录,把当前的人员和日期存入修改记录中 self.new_detail['instructorid'] = user.user_id self.new_detail['instructorname'] = user.user_name self.new_detail['plandate'] = user.now_date self.new_detail['deptid'] = user.dept_id self.new_detail['deptname'] = user.dept_name self.new_detail['bpconstitutorid'] = user.user_id self.new_detail['bpconstitutorname'] = user.user_name self.new_detail['bpconsdate'] = user.now_date # autoid不为空,则为修改记录 # 否则为插入记录 if self.autoid: self.PC.update_producingplan(autoid=self.autoid, **self.new_detail) condition = {'ppid': self.autoid} self.PC.delete_data(7, condition) else: prodtype = self.productkind.currentIndex() prod_id = self.prodname.namelist.currentItem().text(0) self.new_detail['id'] = prod_id ppid = self.PC.update_producingplan(prodtype=prodtype, **self.new_detail) self.autoid = ppid self.created.emit(self.autoid) for item in self.stuff_list: detail = { 'ppid': self.autoid, 'srid': item['autoid'], 'drawamount': item['drawamount'], 'stuffkind': item['stuffkind'] } self.PC.update_data(7, **detail) self.accept() except Exception as e: SaveExcept(e, "提交生产指令时出错", **self.new_detail) else: self.close()
def on_pushButton_pi_clicked(self): if self.label_checkstatus.text() != '检验合格': mesgbox = MessageBox(parent=self, title="提示", text="当前产品尚未检验合格无法入库") mesgbox.exec() return self.new_detail['warehousemanid'] = user.user_id self.new_detail['warehousemanname'] = user.user_name self.new_detail['pidate'] = user.now_date self.new_detail['pistatus'] = 3 # 计算要入库的产品信息 putin_msg = self.get_putin_msg() res = self.WC.update_preproductputinnote(self.autoid, putin_msg, **self.new_detail) if not res: return self.pushButton_piwsman.setSign(True, user.user_id + ' ' + user.user_name) self.pushButton_save.setVisible(False) self.pushButton_accept.setVisible(False) self.pushButton_cancel.setVisible(False) self.pushButton_pi.setVisible(False) self.accepted.emit()
def on_pushButton_accept_clicked(self): if not len(self.new_detail): return if self.autoid is None: if self.check_deptid_exist(): msg = MessageBox(parent=self, text="部门编号重复", informative="当前编号已被使用, 请修改后重试!") msg.exec() self.lineEdit_deptid.setFocus() return if not self.check_parent_exist(): msg = MessageBox(parent=self, text="上级部门不存在", informative="没有找到对应的上级部门, 请修改后重试!") msg.exec() self.lineEdit_parent.setFocus() return # 取消功能 self.CC.update_data(2, **self.new_detail) else: condition = {'autoid': self.autoid} self.CC.update_data(2, condition, **self.new_detail) self.accept()
def closeEvent(self, qcloseevent): if self.power[1] == '0' or self.ori_detail['status'] > 2: return if len(self.new_detail): qdialog = MessageBox(self, title="提醒", text="检验报告书", informative="是否保存修改?") res = qdialog.exec() if res == 16384: self.on_pushButton_save_clicked() for i in range(2, self.tabWidget.count() + 1): widgets = self.tabWidget.widget(i) try: for item in widgets.children(): try: if item.current_content.flat == 1: qdialog = MessageBox( self, title="提醒", text=self.tabWidget.tabText(i), informative="是否保存修改?") res = qdialog.exec() if res == 16384: item.on_pushButton_accept_clicked() except AttributeError: pass except AttributeError: pass
def on_treeWidget_qrcode_customContextMenuRequested(self, pos): if self.power[1] == '0': return menu = QMenu() button1 = menu.addAction("上传二维码文件") g_pos = self.treeWidget_qrcode.mapToGlobal(pos) action = menu.exec(g_pos) if action == button1: clipboard = QApplication.clipboard() dir = clipboard.property("fileurl") if not dir: dir = "c:\\" files_route, file_types = QFileDialog.getOpenFileNames( self, "选择文件", dir, "*.txt;;All Files(*)") if not files_route: return informative = '' selected_dir = re.split(r'\w+.txt', files_route[0])[0] clipboard.setProperty("fileurl", selected_dir) for file_route in files_route: if not file_route.endswith(".txt"): informative += file_route + "文件后缀错误\n" continue filename = re.findall(r'\w+.txt', file_route)[0].split(".")[0] with open(file_route) as f: try: lines = f.readlines() except UnicodeDecodeError: informative += filename + ":编码格式错误\n" continue qrcode_list = [] for i in range(1, len(lines)): content = lines[i].strip() text = re.split(r',|,', content) if len(text) != 5: continue text.append(user.now_date) qrcode_list.append(text) if not len(qrcode_list): informative += filename + ":文件格式错误\n" continue res = self.QC.update_qrcoderep(None, *qrcode_list) if res != "OK": try: qrcode = re.findall('\d+', res)[0] informative += filename + ":" + qrcode + "重复\n" except Exception: pass if informative: msg = MessageBox(text="以下文件上传失败:", informative=informative) msg.exec() self.get_qrcoderepository()
def on_pushButton_audit_clicked(self): if len(self.no_enough_stuff_list): text = "以下物料不足!无法执行指令!" informative = ";\n".join(self.no_enough_stuff_list) errordialig = MessageBox(self, text=text, informative=informative) errordialig.exec() return if self.autoid is None: self.new_detail['instructorid'] = user.user_id self.new_detail['instructorname'] = user.user_name self.new_detail['plandate'] = user.now_date self.new_detail['deptid'] = user.dept_id self.new_detail['deptname'] = user.dept_name self.new_detail['bpconstitutorid'] = user.user_id self.new_detail['bpconstitutorname'] = user.user_name self.new_detail['bpconsdate'] = user.now_date self.new_detail['status'] = 1 self.new_detail['statustime'] = user.now_time self.new_detail['warrantorid'] = user.user_id self.new_detail['warrantorname'] = user.user_name self.new_detail['warrantdate'] = user.now_date self.new_detail['qadate'] = user.now_date self.new_detail['bpwarrantorid'] = user.user_id self.new_detail['bpwarrantorname'] = user.user_name self.new_detail['bpwarrantdate'] = user.now_date if self.autoid is None: prodtype = self.productkind.currentIndex() prod_id = self.prodname.namelist.currentItem().text(0) self.new_detail['id'] = prod_id ppid = self.PC.update_producingplan(prodtype=prodtype, **self.new_detail) self.autoid = ppid self.created.emit(self.autoid) # self.PC.update_data(3, **self.new_detail) else: condition = {'autoid': self.autoid} self.PC.update_data(3, condition, **self.new_detail) for item in self.stuff_list: if item['drawamount'] == 0: continue detail = { 'ppid': self.autoid, 'srid': item['autoid'], 'drawamount': item['drawamount'], 'stuffkind': item['stuffkind'] } self.PC.update_data(7, **detail) self.accept()
def on_pushButton_accept_clicked(self): it = QTreeWidgetItemIterator(self.treeWidget_drawstuff) draw_list = [] key_list = ['srid', 'stuffkind'] while it.value(): treeitem = it.value() item = self.qtreeitem2dict(key_list, treeitem) for stuff in self.stuff_repository: if stuff['autoid'] == int(item['srid']): item['stuffid'] = stuff['stuffid'] item['stuffname'] = stuff['stuffname'] item['stufftype'] = stuff['stufftype'] item['stuffkind'] = stuff['stuffkind'] item['spec'] = stuff['spec'] item['package'] = stuff['package'] item['producer'] = stuff['producer'] item['batchno'] = stuff['batchno'] item['lrid'] = stuff['lrid'] item['content'] = stuff['content'] item['cunit'] = stuff['cunit'] item['water'] = stuff['water'] item['impurity'] = stuff['impurity'] item['rdensity'] = stuff['rdensity'] item['mbatchno'] = stuff['mbatchno'] break item['sdpid'] = self.sdpid item['ppid'] = self.ppid draw_list.append(item) it += 1 sdpid_list = { 'autoid': self.sdpid, 'status': 2, 'providerid': user.user_id, 'providername': user.user_name, 'drawdate': user.now_date } res = self.WC.update_stuffrepository_amount(self.ppid, *draw_list, **sdpid_list) if res == 'accept': self.accept() elif res == 'rollback': msg = MessageBox(parent=self, text="领料信息异常!", informative="请刷新后重试!") msg.exec() timer = QTimer(self) timer.start(1000) timer.timeout.connect(msg.close)
def on_treeWidget_revalution_itemDoubleClicked(self, qtreeitem, p_int): if hasattr(self.current_content, 'flat'): if self.current_content.flat: dialog = MessageBox(self, title="提醒", text="文档尚未保存", informative="是否要保存文档", yes_text="保存", no_text="放弃保存") result = dialog.exec() if result == QMessageBox.Yes: # 调用保存的槽函数 self.on_pushButton_save_clicked() self.docid = int(qtreeitem.text(0)) key_dict = {'autoid': self.docid} res = self.SC.get_data(4, True, *VALUE_TUPLE_SD, **key_dict) if not len(res): return content = str(res[0]) if not self.gridLayout_7.isEmpty(): self.gridLayout_7.removeWidget(self.current_content) self.current_content.close() self.current_content = XMLReadWrite(self) self.current_content.openxml(content) self.gridLayout_7.addWidget(self.current_content) self.current_content.__setattr__('autoid', self.docid)
def on_treeWidget_report_itemDoubleClicked(self, qtreeitem, p_int): if hasattr(self.current_content, 'flat'): if self.current_content.flat: dialog = MessageBox(self, title="提醒", text="文档尚未保存", informative="是否要保存文档", yes_text="保存", no_text="放弃保存") result = dialog.exec() if result == QMessageBox.Yes: # 调用保存的槽函数 self.on_pushButton_accept_clicked() self.reportid = int(qtreeitem.text(0)) condition = {'autoid': self.reportid} res = self.VC.get_data(2, True, *VALUES_TUPLE_RP_DETAIL, **condition) if not len(res): return content = str(res[0]) if not self.gridLayout_11.isEmpty(): self.gridLayout_11.removeWidget(self.current_content) self.current_content.close() self.current_content = XMLReadWrite(self) self.current_content.openxml(content) self.gridLayout_11.addWidget(self.current_content) self.current_content.__setattr__('autoid', self.reportid)
def on_treeWidget_deptlist_customContextMenuRequested(self, pos): if self.power[1] == '0': return current_item = self.treeWidget_deptlist.currentItem() menu = QMenu() item1 = menu.addAction("新建部门") item2 = menu.addAction("修改部门") item3 = menu.addAction("删除部门") # 把坐标转换为屏幕坐标 screenpos = self.treeWidget_deptlist.mapToGlobal(pos) # 设置菜单显示的位置,返回点击了哪个功能 action = menu.exec(screenpos) # 根据点击了哪个功能绑定对应的事件 if action == item1: detail = ModifyDeptmentModule(parent=self) detail.accepted.connect(self.get_deptment_list) detail.show() elif action == item2: if current_item is None: return autoid = int(current_item.text(2)) if autoid == 0: return detail = ModifyDeptmentModule(autoid, self) detail.accepted.connect(self.get_deptment_list) detail.show() elif action == item3: if current_item is None: return autoid = int(current_item.text(2)) if autoid == 0: return s = QTreeWidgetItem() if current_item.childCount() > 0: msg = MessageBox( self, text='无法删除部门', informative='当前部门下还有子部门' ) msg.exec() return condition = {'autoid': autoid} self.CC.delete_data(2, condition) self.get_deptment_list() else: pass
def on_pushButton_accept_clicked(self): self.new_detail['clerkid'] = self.lineEdit_clerkid.text() self.new_detail['clerkname'] = self.lineEdit_clerkname.text() if self.new_detail['clerkid'] == '': msg = MessageBox(text="编号不能为空!") msg.exec() self.lineEdit_clerkid.setFocus() return else: res = self.CC.get_data(0, False, **self.new_detail) if len(res): msg = MessageBox(text="该编号已被使用!") msg.exec() self.lineEdit_clerkid.setFocus() return res = self.CC.update_data(0, **self.new_detail) clerk = ClerkDtailModule(res.autoid, self.parent()) clerk.show() self.accept()
def set_package_rate(self, package): lv = self.comboBox_packageLv.currentIndex() + 1 items = re.split(r'\*|×|x|X', package) if len(items) != lv: msg = MessageBox(title="错误1!", informative="包装比例错误!") msg.exec() return False num_tuple = ('basicamount', 'spamount', 'mpamount') unit_tuple = ('basicunit', 'spunit', 'mpunit', 'bpunit') try: for i in range(len(items)): values = re.findall(r'\d+|\w+', items[i]) self.new_detail[num_tuple[i]] = values[0] self.new_detail[unit_tuple[i]] = values[1] self.new_detail[unit_tuple[i + 1]] = values[2] return True except: msg = MessageBox(title="错误2!", informative="包装比例错误!") msg.exec() return False
def on_treeWidget_revalution_customContextMenuRequested(self, pos): if self.power[1] == '0': return if self.autoid is None: return sender_widget = self.sender() current_item = sender_widget.currentItem() menu = QMenu() button1 = menu.addAction("增加记录") button2 = menu.addAction("修改记录") button3 = menu.addAction("删除记录") global_pos = sender_widget.mapToGlobal(pos) action = menu.exec(global_pos) if action == button1: detail = SelectSelfDefineFormatModule('4', self) detail.selected.connect(self.new_records) detail.accepted.connect(self.get_format) detail.show() elif action == button2: if current_item is None: return if hasattr(self.current_content, 'flat'): if self.current_content.flat: dialog = MessageBox(self, title="提醒", text="文档尚未保存", informative="是否要保存文档", yes_text="保存", no_text="放弃保存") result = dialog.exec() if result == QMessageBox.Yes: # 调用保存的槽函数 self.on_pushButton_accept_clicked() self.docid = int(current_item.text(0)) key_dict = {'autoid': self.docid} res = self.SC.get_data(4, True, *VALUE_TUPLE_SD, **key_dict) if not len(res): return content = str(res[0]) if not self.gridLayout_7.isEmpty(): self.gridLayout_7.removeWidget(self.current_content) self.current_content.close() self.current_content = XMLReadWrite(self) self.current_content.openxml(content) self.gridLayout_7.addWidget(self.current_content) self.current_content.__setattr__('autoid', self.docid) elif action == button3: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} self.SC.delete_data(4, condition) self.get_format()
def on_treeWidget_report_customContextMenuRequested(self, pos): current_item = self.treeWidget_report.currentItem() global_pos = self.treeWidget_report.mapToGlobal(pos) menu = QMenu() action_1 = menu.addAction("增加") action_2 = menu.addAction("修改") action_3 = menu.addAction("删除") action = menu.exec(global_pos) if action == action_1: detail = SelectSelfDefineFormatModule("512", self) detail.selected.connect(self.add_oricheckpaper) detail.selected.connect(self.get_report) detail.show() elif action == action_2: if current_item is None: return if hasattr(self.current_content, 'flat'): if self.current_content.flat: dialog = MessageBox(self, title="提醒", text="文档尚未保存", informative="是否要保存文档", yes_text="保存", no_text="放弃保存") result = dialog.exec() if result == QMessageBox.Yes: # 调用保存的槽函数 self.on_pushButton_accept_clicked() self.reportid = int(current_item.text(0)) condition = {'autoid': self.reportid} res = self.VC.get_data(2, True, *VALUES_TUPLE_RP_DETAIL, **condition) if not len(res): return content = str(res[0]) if not self.gridLayout_11.isEmpty(): self.gridLayout_11.removeWidget(self.current_content) self.current_content.close() self.current_content = XMLReadWrite(self) self.current_content.openxml(content) self.gridLayout_11.addWidget(self.current_content) self.current_content.__setattr__('autoid', self.reportid) elif action == action_3: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} self.VC.delete_data(2, condition) self.get_report()
def on_treeWidget_orderlist_customContextMenuRequested(self, pos): if self.power[1] == '0': return id = 0 snid = 0 index = self.tabWidget.currentIndex() if index != 0: return # 返回调用者的对象 sender_widget = self.sender() current_item = sender_widget.currentItem() if current_item is not None: id = int(current_item.text(0)) snid = int(current_item.text(1)) menu = QMenu() button1 = menu.addAction("新增出库单") button2 = menu.addAction("修改出库单") button3 = menu.addAction("删除出库单") menu.addSeparator() button4 = menu.addAction("提交出库") menu.addSeparator() button5 = menu.addAction("查看销售订单") global_pos = sender_widget.mapToGlobal(pos) action = menu.exec(global_pos) if action == button1: detail = EditProductPutOutPaperModule(parent=self) detail.accepted.connect(self.get_order_list) detail.show() elif action == button2: if id is None: return detail = EditProductPutOutPaperModule(id, self) detail.accepted.connect(self.get_order_list) detail.show() elif action == button3: if id is None: return key_dict_output = {'ppopid': id} res = self.WC.get_ppopqrcode(True, *VALUES_TUPLE_OUTPUT, **key_dict_output) if len(res): msg = MessageBox(self, text="已有出库记录,无法删除出库单!") msg.show() return key_dict = {'autoid': id} self.WC.delete_productputoutpaper(**key_dict) self.get_order_list() elif action == button4: if id is None: return key_dict = { 'status': 1, 'auditorid': user.user_id, 'auditorname': user.user_name, 'putoutdate': user.now_date } res = self.WC.apply_productputoutpaper(id, snid, **key_dict) if res == "OK": if snid != 0: key_dict_salenote = { 'status': 3, 'deliverid': user.user_id, 'delivername': user.user_name } self.SC.update_salenotes(snid, **key_dict_salenote) self.get_order_list() else: REP_KIND = ("整箱", "零头", "合箱") if not len(self.prod_list): self.ppopid = id self.get_qrcode_list() informative = '' prodname = '' batchno = '' for item in res[1]: for it in self.prod_list: if it['ppid'] == item[1]: prodname = it['prodname'] batchno = it['batchno'] kind = REP_KIND[item[0]] informative += prodname + '(' + kind + '),批号:' + batchno + '\n' msg = MessageBox(self, text="以下产品库存不足", informative=informative) msg.exec() return elif action == button5: if snid == 0: msg = MessageBox(self, text="没有找到关联的销售订单") msg.show() return detail = SaleOrderModule(snid, self) detail.show()
def on_treewidget_filetree_itemClicked(self, qitem, p_int): try: # 判断之前是否有打开过文档且没有保存 if self.current_content.flat: dialog = MessageBox(self, title="提醒", text="文档尚未保存", informative="是否要保存文档", yes_text="保存", no_text="放弃保存") result = dialog.exec() if result == QtWidgets.QMessageBox.Yes: # 调用保存的槽函数 self.on_pushButton_accept_clicked() except (AttributeError, TypeError): pass finally: if not self.gridLayout_4.isEmpty(): self.gridLayout_4.removeWidget(self.current_content) self.current_content.close() self.label_filename.setText(qitem.text(0)) self.current_docid = qitem.text(3) # 点击的是内建文档 if qitem.text(1) == '2': doctype = int(qitem.text(3)) # 生产指令 if doctype == -1: self.current_content = PorductionInstructionModule( self.autoid, self) # 领料单 if doctype in (-2, -3, -4): self.current_content = StuffdrawpaperModule( qitem.text(4), self) # 退料单 elif doctype in (-5, -6, -7): self.current_content = StuffReturnPaperModule( qitem.text(4), self) # 批包装指令 elif doctype == -8: self.current_content = PackageInstructionModule( self.autoid, self) # 批剩余(残次)标签、包装材料销毁记录 elif doctype == -9: pass # 称量配料记录 elif doctype == -10: pass # 半成品登记/发放记录 elif doctype in (-11, -12): self.current_content = MidproddrawnoteModule( self.autoid, abs(doctype) - 11) # 前处理入库单 elif doctype == -14: self.current_content = PreProdPutInModule(autoid=self.autoid, parent=self) # 成品寄库单 elif doctype == -13: self.current_content = ProductputinModule( int(qitem.text(4)), self) # 请验单 if doctype in (-15, -16, -17, -18): docid = qitem.text(2) if docid == "-1": self.current_content = CheckreportModule(autoid=int( qitem.text(4)), is_view=True, parent=self) else: self.current_content = ApplycheckModule(autoid=int( qitem.text(4)), parent=self) # 清场合格证(副本) elif doctype == -19: self.current_content = CleanconfirmityCopyModule( int(qitem.text(4)), self) # 清场合格证(正本) elif doctype == -20: self.current_content = CleanconfirmityOriginalModule( qitem.text(4), int(qitem.parent().text(3)), self) # 库存零头领取单 elif doctype == -21: pass # 尾料销毁记录 elif doctype == -22: pass # 产品二维码 elif doctype == -23: self.current_content = QrcodelistModule(self.autoid, self) # 小、中包装二维码关联 elif doctype == -24: pass # 大、中包装二维码关联 elif doctype == -25: pass # 巨、大包装二维码关联 elif doctype == -26: pass # 零头登记记录 elif doctype == -27: self.current_content = OddmentregisternoteModule( self.autoid, self) # 零头发放记录 elif doctype == -28: self.current_content = OddmentdrawnoteModule(self.autoid, self) # 退货产品领料单 elif doctype == -29: pass self.gridLayout_4.addWidget(self.current_content) # 点击的是自定义文档 elif qitem.text(1) == '3': # 自定义文档在Forms表里的id formatid = qitem.text(3) document = self.wsmodels.get_form(formatid) if document is not None: content = document.format self.current_content = XMLReadWrite(self) self.current_content.openxml(content) self.gridLayout_4.addWidget(self.current_content) self.current_content.__setattr__('autoid', self.autoid) # 点击的是岗位名 elif qitem.text(1) == '1': self.current_content = PostdetailModule(qitem.text(2), self.detail[0].lineid, qitem.text(3), qitem.text(0), self) self.gridLayout_4.addWidget(self.current_content) # 点击的是封面 elif qitem.text(1) == '0': self.current_content = HomePageModule(self.autoid, self) self.gridLayout_4.addWidget(self.current_content)