class CreateClerkModule(QDialog, Ui_Dialog): def __init__(self, parent=None): super(CreateClerkModule, self).__init__(parent) self.setupUi(self) self.new_detail = {} self.CC = ClerksController() @pyqtSlot() 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() @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close()
class ExprienceDetailModule(QDialog, Ui_Dialog): def __init__(self, autoid=None, clerkid=None, parent=None): super(ExprienceDetailModule, self).__init__(parent) self.setupUi(self) self.CC = ClerksController() self.autoid = autoid self.clerkid = clerkid self.ori_detail = {} self.new_detail = {} self.get_detail() def get_detail(self): if self.autoid is None: self.dateEdit_fromdate.setDate(user.now_date) self.dateEdit_todate.setDate(user.now_date) else: condition = {'autoid': self.autoid} res = self.CC.get_data(3, False, *VALUES_TUPLE_EXP, **condition) if len(res) != 1: return self.ori_detail = res[0] self.comboBox_exptype.setCurrentIndex(self.ori_detail['exptype']) self.dateEdit_fromdate.setDate(self.ori_detail['fromdate']) self.dateEdit_todate.setDate(self.ori_detail['todate']) self.lineEdit_company.setText(self.ori_detail['company']) self.plainTextEdit_experience.setPlainText( self.ori_detail['experience'] ) self.lineEdit_position.setText(self.ori_detail['position']) self.lineEdit_remark.setText(self.ori_detail['remark']) @pyqtSlot(int) def on_comboBox_exptype_currentIndexChanged(self, p_int): try: if p_int != self.ori_detail['exptype']: self.new_detail['exptype'] = p_int else: try: del self.new_detail['exptype'] except KeyError: pass except KeyError: self.new_detail['exptype'] = p_int @pyqtSlot(QDate) def on_dateEdit_fromdate_dateChanged(self, q_date): try: if type(self.ori_detail['fromdate']) is str: self.new_detail['fromdate'] = q_date.toPyDate() return if q_date != QDate(self.ori_detail['fromdate']): self.new_detail['fromdate'] = q_date.toPyDate() else: try: del self.new_detail['fromdate'] except KeyError: pass except KeyError: self.new_detail['fromdate'] = q_date.toPyDate() @pyqtSlot(QDate) def on_dateEdit_todate_dateChanged(self, q_date): try: if type(self.ori_detail['todate']) is str: self.new_detail['todate'] = q_date.toPyDate() return if q_date != QDate(self.ori_detail['todate']): self.new_detail['todate'] = q_date.toPyDate() else: try: del self.new_detail['todate'] except KeyError: pass except KeyError: self.new_detail['todate'] = q_date.toPyDate() @pyqtSlot(str) def on_lineEdit_company_textChanged(self, p_str): try: if p_str != self.ori_detail['company']: self.new_detail['company'] = p_str else: try: del self.new_detail['company'] except KeyError: pass except KeyError: self.new_detail['company'] = p_str @pyqtSlot() def on_plainTextEdit_experience_textChanged(self): p_str = self.plainTextEdit_experience.toPlainText() try: if p_str != self.ori_detail['experience']: self.new_detail['experience'] = p_str else: try: del self.new_detail['experience'] except KeyError: pass except KeyError: self.new_detail['experience'] = p_str @pyqtSlot(str) def on_lineEdit_position_textChanged(self, p_str): try: if p_str != self.ori_detail['position']: self.new_detail['position'] = p_str else: try: del self.new_detail['position'] except KeyError: pass except KeyError: self.new_detail['position'] = p_str @pyqtSlot(str) def on_lineEdit_remark_textChanged(self, p_str): try: if p_str != self.ori_detail['remark']: self.new_detail['remark'] = p_str else: try: del self.new_detail['remark'] except KeyError: pass except KeyError: self.new_detail['remark'] = p_str @pyqtSlot() def on_pushButton_accept_clicked(self): if not len(self.new_detail): return if self.autoid is None: self.new_detail['clerkid_id'] = self.clerkid self.CC.update_data(3, **self.new_detail) else: condition = {'autoid': self.autoid} self.CC.update_data(3, condition, **self.new_detail) self.accept() @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close()
class HealthRecordDetailModule(QDialog, Ui_Dialog): def __init__(self, autoid=None, clerkid=None, parent=None): super(HealthRecordDetailModule, self).__init__(parent) self.setupUi(self) self.CC = ClerksController() self.clerkid = clerkid self.autoid = autoid self.ori_detail = {} self.new_detail = {} self.get_detail() def get_detail(self): if self.autoid is None: self.dateEdit_checkdate.setDate(user.now_date) else: condition = {'autoid': self.autoid} res = self.CC.get_data(5, False, *VALUES_TUPLE_HEALTH, **condition) if len(res) != 1: return self.ori_detail = res[0] self.dateEdit_checkdate.setDate(self.ori_detail['checkdate']) self.lineEdit_hospital.setText(self.ori_detail['hospital']) self.plainTextEdit_checkitem.setPlainText( self.ori_detail['checkitem']) self.plainTextEdit_healthstatus.setPlainText( self.ori_detail['healthstatus']) if self.ori_detail['status'] == 1: self.pushButton_accept.setVisible(False) self.pushButton_cancel.setVisible(False) @pyqtSlot(QDate) def on_dateEdit_checkdate_dateChanged(self, q_date): try: if type(self.ori_detail['checkdate']) is str: self.new_detail['checkdate'] = q_date.toPyDate() return if q_date != QDate(self.ori_detail['checkdate']): self.new_detail['checkdate'] = q_date.toPyDate() else: try: del self.new_detail['checkdate'] except KeyError: pass except KeyError: self.new_detail['checkdate'] = q_date.toPyDate() @pyqtSlot(str) def on_lineEdit_hospital_textChanged(self, p_str): try: if p_str != self.ori_detail['hospital']: self.new_detail['hospital'] = p_str else: try: del self.new_detail['hospital'] except KeyError: pass except KeyError: self.new_detail['hospital'] = p_str @pyqtSlot() def on_plainTextEdit_checkitem_textChanged(self): p_str = self.plainTextEdit_checkitem.toPlainText() try: if p_str != self.ori_detail['checkitem']: self.new_detail['checkitem'] = p_str else: try: del self.new_detail['checkitem'] except KeyError: pass except KeyError: self.new_detail['checkitem'] = p_str @pyqtSlot() def on_plainTextEdit_healthstatus_textChanged(self): p_str = self.plainTextEdit_healthstatus.toPlainText() try: if p_str != self.ori_detail['healthstatus']: self.new_detail['healthstatus'] = p_str else: try: del self.new_detail['healthstatus'] except KeyError: pass except KeyError: self.new_detail['healthstatus'] = p_str @pyqtSlot() def on_pushButton_accept_clicked(self): if not len(self.new_detail): return if self.autoid is None: self.new_detail['clerkid_id'] = self.clerkid self.CC.update_data(5, **self.new_detail) else: condition = {'autoid': self.autoid} self.CC.update_data(5, condition, **self.new_detail) self.accept() @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close()
class TrainingRecordDetailModule(QDialog, Ui_Dialog): def __init__(self, autoid=None, clerkid=None, parent=None): super(TrainingRecordDetailModule, self).__init__(parent) self.setupUi(self) self.CC = ClerksController() self.clerkid = clerkid self.autoid = autoid self.ori_detail = {} self.new_detail = {} self.get_detail() def get_detail(self): if self.autoid is None: self.dateEdit_fromdate.setDate(user.now_date) self.dateEdit_todate.setDate(user.now_date) else: condition = {'autoid': self.autoid} res = self.CC.get_data(4, False, *VALUES_TUPLE_TRAIN, **condition) if len(res) != 1: return self.ori_detail = res[0] self.dateEdit_fromdate.setDate(self.ori_detail['fromdate']) self.dateEdit_todate.setDate(self.ori_detail['todate']) self.plainTextEdit_training.setPlainText( self.ori_detail['training']) self.lineEdit_position.setText(self.ori_detail['position']) self.lineEdit_teachingtime.setText(self.ori_detail['teachingtime']) self.lineEdit_teacher.setText(self.ori_detail['teacher']) self.lineEdit_score.setText(self.ori_detail['score']) if self.ori_detail['status'] == 1: self.pushButton_accept.setVisible(False) self.pushButton_cancel.setVisible(False) @pyqtSlot(QDate) def on_dateEdit_fromdate_dateChanged(self, q_date): try: if type(self.ori_detail['fromdate']) is str: self.new_detail['fromdate'] = q_date.toPyDate() return if q_date != QDate(self.ori_detail['fromdate']): self.new_detail['fromdate'] = q_date.toPyDate() else: try: del self.new_detail['fromdate'] except KeyError: pass except KeyError: self.new_detail['fromdate'] = q_date.toPyDate() @pyqtSlot(QDate) def on_dateEdit_todate_dateChanged(self, q_date): try: if type(self.ori_detail['todate']) is str: self.new_detail['todate'] = q_date.toPyDate() return if q_date != QDate(self.ori_detail['todate']): self.new_detail['todate'] = q_date.toPyDate() else: try: del self.new_detail['todate'] except KeyError: pass except KeyError: self.new_detail['todate'] = q_date.toPyDate() @pyqtSlot(str) def on_lineEdit_position_textChanged(self, p_str): try: if p_str != self.ori_detail['position']: self.new_detail['position'] = p_str else: try: del self.new_detail['position'] except KeyError: pass except KeyError: self.new_detail['position'] = p_str @pyqtSlot() def on_plainTextEdit_training_textChanged(self): p_str = self.plainTextEdit_training.toPlainText() try: if p_str != self.ori_detail['training']: self.new_detail['training'] = p_str else: try: del self.new_detail['training'] except KeyError: pass except KeyError: self.new_detail['training'] = p_str @pyqtSlot(str) def on_lineEdit_teachingtime_textChanged(self, p_str): try: if p_str != self.ori_detail['teachingtime']: self.new_detail['teachingtime'] = p_str else: try: del self.new_detail['teachingtime'] except KeyError: pass except KeyError: self.new_detail['teachingtime'] = p_str @pyqtSlot(str) def on_lineEdit_teacher_textChanged(self, p_str): try: if p_str != self.ori_detail['teacher']: self.new_detail['teacher'] = p_str else: try: del self.new_detail['teacher'] except KeyError: pass except KeyError: self.new_detail['teacher'] = p_str @pyqtSlot(str) def on_lineEdit_score_textChanged(self, p_str): try: if p_str != self.ori_detail['score']: self.new_detail['score'] = p_str else: try: del self.new_detail['score'] except KeyError: pass except KeyError: self.new_detail['score'] = p_str @pyqtSlot() def on_pushButton_accept_clicked(self): if not len(self.new_detail): return if self.autoid is None: self.new_detail['clerkid_id'] = self.clerkid self.CC.update_data(4, **self.new_detail) else: condition = {'autoid': self.autoid} self.CC.update_data(4, condition, **self.new_detail) self.accept() @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close()
class ClerkDtailModule(QDialog, Ui_Dialog): def __init__(self, autoid, parent=None): # 根据人员权限确定是否能打开模块;是否能修改人员信息 super(ClerkDtailModule, self).__init__(parent) self.setupUi(self) # 当前人员的clerkid,主键 self.autoid = autoid self.trainingstatus = 0 self.healthstatus = 0 self.CC = ClerksController() self.IC = ImageController() self.ori_detail = {} self.new_detail = {} self.treeWidget_deptlist.hideColumn(0) self.treeWidget_experience.hideColumn(0) self.treeWidget_train.hideColumn(0) self.treeWidget_health.hideColumn(0) self.get_detail() self.get_clerkdept() self.get_experience() self.get_training() self.get_health() # 初始化填写格式 self.init_lineedit_content() # 初始化权限列表 self.init_authority() # 初始化下拉菜单的内容 self.init_combo_content() return_row = ('autoid', 'deptid', 'deptname') condition_key = {'deptid', 'deptname', 'inputcode'} treeheader_name = ["id", "编号", "部门名"] self.lineEdit_deptment.setup('Department', return_row, condition_key, treeheader_name, None, 300, 200) def get_detail(self): if self.autoid is None: return condition = {'autoid': self.autoid} res = self.CC.get_data(0, False, *VALUES_TUPLE_CL, **condition) if len(res) != 1: return self.ori_detail = res[0] self.clerkid.setText(self.ori_detail['clerkid']) self.clerkname.setText(self.ori_detail['clerkname']) self.inputcode.setText(self.ori_detail['inputcode']) self.sex.setCurrentText(self.ori_detail['sex']) self.birthday.setText(str(self.ori_detail['birthday'])) self.marrystatus.setCurrentText(self.ori_detail['marrystatus']) self.nation.setCurrentText(self.ori_detail['nation']) self.native_2.setText(self.ori_detail['native']) self.policystatus.setCurrentText(self.ori_detail['policystatus']) self.idno.setText('*' * 14 + self.ori_detail['idno'][-4:]) self.address.setText(self.ori_detail['address']) self.telno.setText(self.ori_detail['telno']) self.entranceday.setText(str(self.ori_detail['entranceday'])) self.special.setText(self.ori_detail['special']) self.schoolname.setText(self.ori_detail['schoolname']) self.strongsuit.setText(self.ori_detail['strongsuit']) if self.ori_detail['portraitid'] not in ('', 0): condition = {'autoid': self.ori_detail['portraitid']} res = self.IC.get_data(1, True, *VALUES_TUPLE_IM, **condition) if len(res) == 1: img = res[0] pixmap = QPixmap.fromImage(QImage.fromData(img)) self.clerk_image.setPixmap( pixmap.scaled(340, 290, Qt.KeepAspectRatio)) def get_clerkdept(self): if self.autoid is None: return self.treeWidget_deptlist.clear() condition = {'clerkid_id': self.autoid} res = self.CC.get_data(1, False, **condition) if not len(res): return for item in res: qtreeitem = QTreeWidgetItem(self.treeWidget_deptlist) qtreeitem.setText(0, str(item.autoid)) qtreeitem.setText(1, item.deptid.deptid) qtreeitem.setText(2, item.deptid.deptname) qtreeitem.setText(3, item.position) for i in range(3): self.treeWidget_deptlist.resizeColumnToContents(i) def get_experience(self): if self.autoid is None: return self.treeWidget_experience.clear() condition = {'clerkid_id': self.autoid} res = self.CC.get_data(3, False, *VALUES_TUPLE_EXP, **condition) if not len(res): return for item in res: qtreeitem = QTreeWidgetItem(self.treeWidget_experience) qtreeitem.setText(0, str(item['autoid'])) qtreeitem.setText(1, EXPTYPE[item['exptype']]) qtreeitem.setText(2, str(item['fromdate'])) qtreeitem.setText(3, str(item['todate'])) qtreeitem.setText(4, item['company']) qtreeitem.setText(5, item['experience']) qtreeitem.setText(6, item['position']) qtreeitem.setText(7, item['remark']) for i in range(1, 8): self.treeWidget_experience.resizeColumnToContents(i) def get_training(self): if self.autoid is None: return self.treeWidget_train.clear() condition = {'clerkid_id': self.autoid, 'status': self.trainingstatus} res = self.CC.get_data(4, False, *VALUES_TUPLE_TRAIN, **condition) if not len(res): return for item in res: qtreeitem = QTreeWidgetItem(self.treeWidget_train) qtreeitem.setText(0, str(item['autoid'])) qtreeitem.setText(1, str(item['fromdate'])) qtreeitem.setText(2, str(item['todate'])) qtreeitem.setText(3, item['position']) qtreeitem.setText(4, item['training']) qtreeitem.setText(5, item['teachingtime']) qtreeitem.setText(6, item['teacher']) qtreeitem.setText(7, item['score']) for i in range(1, 8): self.treeWidget_train.resizeColumnToContents(i) def get_health(self): if self.autoid is None: return self.treeWidget_health.clear() condition = {'clerkid_id': self.autoid, 'status': self.healthstatus} res = self.CC.get_data(5, False, *VALUES_TUPLE_HEALTH, **condition) if not len(res): return for item in res: qtreeitem = QTreeWidgetItem(self.treeWidget_health) qtreeitem.setText(0, str(item['autoid'])) qtreeitem.setText(1, str(item['checkdate'])) qtreeitem.setText(2, item['hospital']) qtreeitem.setText(3, item['checkitem']) qtreeitem.setText(4, item['healthstatus']) for i in range(1, 5): self.treeWidget_health.resizeColumnToContents(i) @pyqtSlot(int) def on_tabWidget_2_currentChanged(self, p_int): self.trainingstatus = p_int self.tabWidget_2.currentWidget().setLayout(self.gridLayout_11) self.get_training() @pyqtSlot(int) def on_tabWidget_3_currentChanged(self, p_int): self.healthstatus = p_int self.tabWidget_3.currentWidget().setLayout(self.gridLayout_3) self.get_health() @pyqtSlot(QTreeWidgetItem, int) def on_treeWidget_experience_itemDoubleClicked(self, qtreeitem, p_int): id = int(qtreeitem.text(0)) detail = ExprienceDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_experience) detail.show() @pyqtSlot(QTreeWidgetItem, int) def on_treeWidget_train_itemDoubleClicked(self, qtreeitem, p_int): id = int(qtreeitem.text(0)) detail = TrainingRecordDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_training) detail.show() @pyqtSlot(QTreeWidgetItem, int) def on_treeWidget_health_itemDoubleClicked(self, qtreeitem, p_int): id = int(qtreeitem.text(0)) detail = HealthRecordDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_health) detail.show() # 校验人员编号的修改 @pyqtSlot(str) def on_clerkid_textChanged(self, p_str): try: if p_str != self.ori_detail['clerkid']: self.new_detail['clerkid'] = p_str else: try: del self.new_detail['clerkid'] except KeyError: pass except KeyError: self.new_detail['clerkid'] = p_str # 人员姓名 @pyqtSlot(str) def on_clerkname_textChanged(self, p_str): # 把人员名称拼音关联到输入码 self.inputcode.setText(Inputcode.make_inputcode(p_str)) try: if p_str != self.ori_detail['clerkname']: self.new_detail['clerkname'] = p_str else: try: del self.new_detail['clerkname'] except KeyError: pass except KeyError: self.new_detail['clerkname'] = p_str # 快速输入码 @pyqtSlot(str) def on_inputcode_textChanged(self, p_str): try: if p_str != self.ori_detail['inputcode']: self.new_detail['inputcode'] = p_str else: try: del self.new_detail['inputcode'] except KeyError: pass except KeyError: self.new_detail['inputcode'] = p_str # 性别 @pyqtSlot(str) def on_sex_currentTextChanged(self, p_str): try: if p_str != self.ori_detail['sex']: self.new_detail['sex'] = p_str else: try: del self.new_detail['sex'] except KeyError: pass except KeyError: self.new_detail['sex'] = p_str # 出生日期 @pyqtSlot(str) def on_birthday_textChanged(self, p_str): try: if p_str != str(self.ori_detail['birthday']): self.new_detail['birthday'] = p_str else: try: del self.new_detail['birthday'] except KeyError: pass except KeyError: self.new_detail['birthday'] = p_str # 婚姻状态 @pyqtSlot(str) def on_marrystatus_currentTextChanged(self, p_str): try: if p_str != self.ori_detail['marrystatus']: self.new_detail['marrystatus'] = p_str else: try: del self.new_detail['marrystatus'] except KeyError: pass except KeyError: self.new_detail['marrystatus'] = p_str # 民族 @pyqtSlot(str) def on_nation_textChanged(self, p_str): try: if p_str != self.ori_detail['nation']: self.new_detail['nation'] = p_str else: try: del self.new_detail['nation'] except KeyError: pass except KeyError: self.new_detail['nation'] = p_str # 籍贯 @pyqtSlot(str) def on_native_2_textChanged(self, p_str): try: if p_str != self.ori_detail['native']: self.new_detail['native'] = p_str else: try: del self.new_detail['native'] except KeyError: pass except KeyError: self.new_detail['native'] = p_str # 政治面貌 @pyqtSlot(str) def on_policystatus_currentTextChanged(self, p_str): try: if p_str != self.ori_detail['policystatus']: self.new_detail['policystatus'] = p_str else: try: del self.new_detail['policystatus'] except KeyError: pass except KeyError: self.new_detail['policystatus'] = p_str # 身份证号码 @pyqtSlot(str) def on_idno_textEdited(self, p_str): try: if p_str != self.ori_detail['idno']: self.new_detail['idno'] = p_str else: try: del self.new_detail['idno'] except KeyError: pass except KeyError: self.new_detail['idno'] = p_str # 地址 @pyqtSlot(str) def on_address_textChanged(self, p_str): try: if p_str != self.ori_detail['address']: self.new_detail['address'] = p_str else: try: del self.new_detail['address'] except KeyError: pass except KeyError: self.new_detail['address'] = p_str # 雇佣日期 @pyqtSlot(str) def on_entranceday_textChanged(self, p_str): try: if p_str != str(self.ori_detail['entranceday']): self.new_detail['entranceday'] = p_str else: try: del self.new_detail['entranceday'] except KeyError: pass except KeyError: self.new_detail['entranceday'] = p_str # 文化程度 @pyqtSlot(str) def on_edudegree_currentTextChanged(self, p_str): try: if p_str != self.ori_detail['edudegree']: self.new_detail['edudegree'] = p_str else: try: del self.new_detail['edudegree'] except KeyError: pass except KeyError: self.new_detail['edudegree'] = p_str # 专业 @pyqtSlot(str) def on_special_textChanged(self, p_str): try: if p_str != self.ori_detail['special']: self.new_detail['special'] = p_str else: try: del self.new_detail['special'] except KeyError: pass except KeyError: self.new_detail['special'] = p_str # 毕业学校 @pyqtSlot(str) def on_schoolname_textChanged(self, p_str): try: if p_str != self.ori_detail['schoolname']: self.new_detail['schoolname'] = p_str else: try: del self.new_detail['schoolname'] except KeyError: pass except KeyError: self.new_detail['schoolname'] = p_str # 职称 @pyqtSlot(str) def on_techtitle_currentTextChanged(self, p_str): try: if p_str != self.ori_detail['techtitle']: self.new_detail['techtitle'] = p_str else: try: del self.new_detail['techtitle'] except KeyError: pass except KeyError: self.new_detail['techtitle'] = p_str # 工作前年限 @pyqtSlot(str) def on_strongsuit_textChanged(self, p_str): try: p_float = float(p_str) if p_float != self.ori_detail['strongsuit']: self.new_detail['strongsuit'] = p_float else: try: del self.new_detail['strongsuit'] except KeyError: pass except KeyError: self.new_detail['strongsuit'] = p_float # 上传图片功能 @pyqtSlot() def on_setimage_clicked(self): img_name, img_type = QFileDialog.getOpenFileName( self.clerk_image, "打开图片", "c:\\", "*.jpg;;*.png;;All Files(*)") img = QPixmap(img_name).scaled(self.clerk_image.width(), self.clerk_image.height(), Qt.KeepAspectRatio) fp = open(img_name, 'rb') with fp: image_byte = fp.read() fp.close() image_ext = img_name.split(".")[1] detail = {'img': image_byte, 'ext': image_ext} if len(self.ori_detail) and self.ori_detail['portraitid'] not in ('', 0): condition = {'autoid': self.ori_detail['portraitid']} self.IC.update_data(1, condition, **detail) else: image = self.IC.update_data(1, **detail) self.new_detail['portraitid'] = image.autoid self.clerk_image.setPixmap(img) # 修改权限 @pyqtSlot() def on_pushButton_editpower_clicked(self): detail = EditPowersModule(self.autoid, self) detail.accepted.connect(self.init_authority) detail.show() @pyqtSlot() def on_pushButton_add_clicked(self): try: deptid = int(self.lineEdit_deptment.namelist.currentItem().text(0)) except ValueError: return post = self.comboBox_post.currentText() detail = { 'position': post, 'deptid_id': deptid, 'clerkid_id': self.autoid } self.CC.update_data(1, **detail) self.get_clerkdept() @pyqtSlot(QPoint) def on_treeWidget_deptlist_customContextMenuRequested(self, pos): screenpos = self.treeWidget_deptlist.mapToGlobal(pos) current_item = self.treeWidget_deptlist.currentItem() menu = QMenu(self.treeWidget_deptlist) action_1 = menu.addAction("删除") action = menu.exec(screenpos) if action == action_1: if current_item is None: return id = int(current_item.text(0)) conditin = {'autoid': id} self.CC.delete_data(1, conditin) self.get_clerkdept() @pyqtSlot(QPoint) def on_treeWidget_experience_customContextMenuRequested(self, pos): screenpos = self.treeWidget_experience.mapToGlobal(pos) current_item = self.treeWidget_experience.currentItem() menu = QMenu(self.treeWidget_deptlist) action_1 = menu.addAction("增加") action_2 = menu.addAction("修改") action_3 = menu.addAction("删除") action = menu.exec(screenpos) if action == action_1: detail = ExprienceDetailModule(clerkid=self.autoid, parent=self) detail.accepted.connect(self.get_experience) detail.show() elif action == action_2: if current_item is None: return id = int(current_item.text(0)) detail = ExprienceDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_experience) detail.show() elif action == action_3: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} self.CC.delete_data(3, condition) self.get_experience() @pyqtSlot(QPoint) def on_treeWidget_train_customContextMenuRequested(self, pos): screenpos = self.treeWidget_train.mapToGlobal(pos) current_item = self.treeWidget_train.currentItem() menu = QMenu(self.treeWidget_deptlist) action_1 = menu.addAction("增加") action_2 = menu.addAction("修改") action_3 = menu.addAction("删除") menu.addSeparator() action_4 = menu.addAction("提交") action = menu.exec(screenpos) if action == action_1: detail = TrainingRecordDetailModule(clerkid=self.autoid, parent=self) detail.accepted.connect(self.get_training) detail.show() elif action == action_2: if current_item is None: return id = int(current_item.text(0)) detail = TrainingRecordDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_training) detail.show() elif action == action_3: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} self.CC.delete_data(4, condition) self.get_training() elif action == action_4: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} detail = {'status': 1} self.CC.update_data(4, condition, **detail) self.get_training() @pyqtSlot(QPoint) def on_treeWidget_health_customContextMenuRequested(self, pos): screenpos = self.treeWidget_health.mapToGlobal(pos) current_item = self.treeWidget_health.currentItem() menu = QMenu(self.treeWidget_deptlist) action_1 = menu.addAction("增加") action_2 = menu.addAction("修改") action_3 = menu.addAction("删除") menu.addSeparator() action_4 = menu.addAction("提交") action = menu.exec(screenpos) if action == action_1: detail = HealthRecordDetailModule(clerkid=self.autoid, parent=self) detail.accepted.connect(self.get_health) detail.show() elif action == action_2: if current_item is None: return id = int(current_item.text(0)) detail = HealthRecordDetailModule(autoid=id, parent=self) detail.accepted.connect(self.get_health) detail.show() elif action == action_3: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} self.CC.delete_data(5, condition) self.get_health() elif action == action_4: if current_item is None: return id = int(current_item.text(0)) condition = {'autoid': id} detail = {'status': 1} self.CC.update_data(5, condition, **detail) self.get_health() # 确认功能 @pyqtSlot() def on_pushButton_accept_clicked(self): print(self.new_detail) if not len(self.new_detail): return condition = {'autoid': self.autoid} self.CC.update_data(0, condition, **self.new_detail) self.accept() # 取消功能 @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close() # 初始化填写内容的格式 def init_lineedit_content(self): # 入职前工作年限,格式应该为纯数字 double_valitor = QDoubleValidator() double_valitor.setRange(0, 100) double_valitor.setDecimals(1) self.strongsuit.setValidator(double_valitor) # 出生日期、雇佣日期,格式yyyy-MM-DD reg = QRegExp('^[23][0-9]{3}-[0-9]{2}-[0-9]{2}$') day_validator = QRegExpValidator() day_validator.setRegExp(reg) self.birthday.setValidator(day_validator) self.entranceday.setValidator(day_validator) # 匹配身份证 reg = QRegExp('^\d{17}(\d|X)$') id_validator = QRegExpValidator() id_validator.setRegExp(reg) self.idno.setValidator(id_validator) # 匹配电话号码,纯数字 reg = QRegExp('[0-9]{11}') tel_validator = QRegExpValidator() tel_validator.setRegExp(reg) self.telno.setValidator(tel_validator) # 初始化下拉列表 def init_combo_content(self): items = self.CC.get_data(0, True, *VALUES_TUPLE_ED).distinct() if len(items): self.edudegree.addItems(items) if len(self.ori_detail): self.edudegree.setCurrentText(self.ori_detail['edudegree']) items = self.CC.get_data(0, True, *VALUES_TUPLE_TE).distinct() if len(items): self.techtitle.addItems(items) if len(self.ori_detail): self.techtitle.setCurrentText(self.ori_detail['techtitle']) items = self.CC.get_data(1, True, *VALUES_TUPLE_PO).distinct() if len(items): self.comboBox_post.addItems(items) # 初始化权限列表 def init_authority(self): if not len(self.ori_detail): return self.treeWidget_powers.clear() condition = {'autoid': self.autoid} res = self.CC.get_data(0, True, *VALUES_TUPLE_POWERS, **condition) if len(res) != 1: return authority = res[0] if authority == '': return authority = json.loads(authority) for k in sorted(authority, key=int): qtreeitem = QTreeWidgetItem(self.treeWidget_powers) power = '{:03b}'.format(int(authority[k])) qtreeitem.setText(0, MODULE_NAME[int(k)]) qtreeitem.setCheckState(1, 2 if power[0] == '1' else 0) qtreeitem.setCheckState(2, 2 if power[1] == '1' else 0) qtreeitem.setCheckState(3, 2 if power[2] == '1' else 0)
class EditPowersModule(QDialog, Ui_Dialog): def __init__(self, clerkid, parent=None): super(EditPowersModule, self).__init__(parent) self.setupUi(self) self.clerkid = clerkid self.CC = ClerksController() self.detail = {} self.get_detail() self.init_powers() def get_detail(self): condition = {'autoid': self.clerkid} res = self.CC.get_data(0, True, *VALUES_TUPLE_POWERS, **condition) if not len(res): return powers = res[0] if powers != '': self.detail = json.loads(powers) def init_powers(self): for i in range(len(MODULE_NAME)): qtreeitem = QTreeWidgetItem(self.treeWidget) qtreeitem.setText(0, MODULE_NAME[i]) if str(i) in self.detail: power = '{:03b}'.format(int(self.detail[str(i)])) qtreeitem.setCheckState(1, 2 if power[0] == '1' else 0) qtreeitem.setCheckState(2, 2 if power[1] == '1' else 0) qtreeitem.setCheckState(3, 2 if power[2] == '1' else 0) else: qtreeitem.setCheckState(1, 0) qtreeitem.setCheckState(2, 0) qtreeitem.setCheckState(3, 0) @pyqtSlot(QTreeWidgetItem, int) def on_treeWidget_itemDoubleClicked(self, qtreeitem, p_int): qtreeitem.setCheckState(1, 2 if qtreeitem.checkState(1) == 0 else 0) qtreeitem.setCheckState(2, 2 if qtreeitem.checkState(2) == 0 else 0) qtreeitem.setCheckState(3, 2 if qtreeitem.checkState(3) == 0 else 0) key = str(MODULE_NAME.index(qtreeitem.text(0))) self.detail[key] = self.power_value(qtreeitem) @pyqtSlot(QTreeWidgetItem, int) def on_treeWidget_itemClicked(self, qtreeitem, p_int): key = str(MODULE_NAME.index(qtreeitem.text(0))) self.detail[key] = self.power_value(qtreeitem) def power_value(self, qtreeitem): value_1 = 4 if qtreeitem.checkState(1) == 2 else 0 value_2 = 2 if qtreeitem.checkState(2) == 2 else 0 value_3 = 1 if qtreeitem.checkState(3) == 2 else 0 return value_1 + value_2 + value_3 @pyqtSlot() def on_pushButton_accept_clicked(self): if len(self.detail): for key in list(self.detail): if self.detail[key] == 0: del self.detail[key] detail = {'powers': json.dumps(self.detail)} condition = {'autoid': self.clerkid} self.CC.update_data(0, condition, **detail) self.accept() @pyqtSlot() def on_pushButton_cancel_clicked(self): self.close()
class ModifyDeptmentModule(QDialog, Ui_Dialog): def __init__(self, autoid=None, parent=None): super(ModifyDeptmentModule, self).__init__(parent) # 初始化对话框 self.setupUi(self) # 原始部门id,仅修改部门时有用 self.autoid = autoid self.CC = ClerksController() self.ori_detail = {} self.new_detail = {} return_row = ('autoid', 'deptid', 'deptname') condition_key = {'deptid', 'deptname', 'inputcode'} treeheader_name = ["id", "编号", "名称"] self.lineEdit_parent.setup('Department', return_row, condition_key, treeheader_name) self.get_department_detail() # parentname:上级部门当前选择的部门名称,默认为空 # args:全部部门列表 def get_department_detail(self): if self.autoid is None: return condition = {'autoid': self.autoid} res = self.CC.get_data(2, False, *VALUES_TUPLE_DP, **condition) if len(res) != 1: return self.ori_detail = res[0] self.lineEdit_deptid.setText(self.ori_detail['deptid']) self.lineEdit_deptname.setText(self.ori_detail['deptname']) self.lineEdit_inputcode.setText(self.ori_detail['inputcode']) condition_PD = {'deptid': self.ori_detail['parentid']} PD_list = self.CC.get_data(2, False, *VALUES_TUPLE_PD, **condition_PD) if len(PD_list): self.lineEdit_parent.setText(PD_list[0]['deptid'] + ' ' + PD_list[0]['deptname']) section = '{:08b}'.format(self.ori_detail['sectiontype']) for i in range(8): getattr(self, 'checkBox_' + str(2**i)).setChecked(True if section[7 - i] == '1' else False) @pyqtSlot(str) def on_lineEdit_deptid_textChanged(self, p_str): try: if p_str != self.ori_detail['deptid']: self.new_detail['deptid'] = p_str else: try: del self.new_detail['deptid'] except KeyError: pass except KeyError: self.new_detail['deptid'] = p_str # 输入码动态关联部门名称 @pyqtSlot(str) def on_lineEdit_deptname_textChanged(self, p_str): self.lineEdit_inputcode.setText(Inputcode.make_inputcode(p_str)) try: if p_str != self.ori_detail['deptname']: self.new_detail['deptname'] = p_str else: try: del self.new_detail['deptname'] except KeyError: pass except KeyError: self.new_detail['deptname'] = p_str @pyqtSlot(str) def on_lineEdit_inputcode_textChanged(self, p_str): try: if p_str != self.ori_detail['inputcode']: self.new_detail['inputcode'] = p_str else: try: del self.new_detail['inputcode'] except KeyError: pass except KeyError: self.new_detail['inputcode'] = p_str @pyqtSlot() def on_lineEdit_parent_acceptmsg(self): try: parentid = self.lineEdit_parent.text().split(' ')[0] if parentid == self.lineEdit_deptid.text(): return if parentid != self.ori_detail['parentid']: self.new_detail['parentid'] = parentid else: try: del self.new_detail['parentid'] except KeyError: pass except KeyError: self.new_detail['parentid'] = parentid except AttributeError: pass @pyqtSlot(bool) def on_checkBox_1_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_2_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_4_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_8_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_16_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_32_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_64_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state @pyqtSlot(bool) def on_checkBox_128_toggled(self, p_bool): state = int(self.sender().objectName().split('_')[1]) * \ (1 if p_bool else -1) if 'sectiontype' in self.new_detail: self.new_detail['sectiontype'] += state else: self.new_detail['sectiontype'] = state # 确认功能 @pyqtSlot() 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 on_pushButton_cancel_clicked(self): self.close() # 检查部门编号是否存在 def check_deptid_exist(self): # 存在当前部门返回False,不存在返回True condition = {'deptid': self.lineEdit_deptid.text()} res = self.CC.get_data(2, False, *VALUES_TUPLE_PD, **condition) if len(res): return True else: return False # 检查上级部门是否符合规定 def check_parent_exist(self): parentid = self.lineEdit_parent.text().split(' ')[0] if parentid != '': condition = {'deptid': parentid} res = self.CC.get_data(2, False, *VALUES_TUPLE_PD, **condition) if len(res): return True else: return False