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)
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()
Example #3
0
class UserLoginModule(QDialog, Ui_Dialog):
    def __init__(self, menu, parent=None):
        super(UserLoginModule, self).__init__(parent)
        self.setupUi(self)
        self.menu = menu
        self.label_tips.setVisible(False)
        self.CC = ClerksController()
        return_row = ('autoid', 'clerkid', 'clerkname')
        condition_key = ('clerkid', 'clerkname')
        treeheader_name = ["id", "编号", "姓名"]
        self.lineEdit_username.setup('Clerks', return_row, condition_key,
                                     treeheader_name, None, 250, 200)

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        try:
            userid, username = self.lineEdit_username.text().split(' ')
        except:
            self.label_tips.setVisible(True)
            self.lineEdit_username.setFocus()
            return
        password = md5(
            self.lineEdit_password.text().encode('UTF-8')).hexdigest()
        condition = {
            'clerkid': userid,
            'clerkname': username,
            'password': password
        }
        res = self.CC.get_data(0, False, *VVALUES_TUPLE_CL, **condition)
        if len(res):
            user.user_id = userid
            user.user_name = username
            if res[0]['powers'] != '':
                try:
                    user.powers = json.loads(res[0]['powers'])
                except json.decoder.JSONDecodeError:
                    pass
            condition = {'clerkid': res[0]['autoid']}
            dept_res = self.CC.get_data(1, False,
                                        **condition).order_by('-defaultdept')
            if len(dept_res):
                user.dept_id = dept_res[0].deptid.deptid
                user.dept_name = dept_res[0].deptid.deptname

            self.menu.showMaximized()
            self.menu.set_module()
            self.setHidden(True)
        else:
            self.label_tips.setVisible(True)

    pyqtSlot(str)

    def on_lineEdit_username_textChanged(self, p_str):
        self.label_tips.setVisible(False)

    pyqtSlot(str)

    def on_lineEdit_password_textChanged(self, p_str):
        self.label_tips.setVisible(False)
Example #4
0
 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()
Example #5
0
    def __init__(self, parent=None):
        super(EditPostWorkerModule, self).__init__(parent)
        self.setupUi(self)
        self.LC = LinepostController()
        self.PC = ProductLineConroller()
        self.CC = ClerksController()

        self.get_productline()
        self.get_worker()
Example #6
0
    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()
Example #7
0
 def __init__(self, menu, parent=None):
     super(UserLoginModule, self).__init__(parent)
     self.setupUi(self)
     self.menu = menu
     self.label_tips.setVisible(False)
     self.CC = ClerksController()
     return_row = ('autoid', 'clerkid', 'clerkname')
     condition_key = ('clerkid', 'clerkname')
     treeheader_name = ["id", "编号", "姓名"]
     self.lineEdit_username.setup('Clerks', return_row, condition_key,
                                  treeheader_name, None, 250, 200)
    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()
Example #9
0
    def __init__(self, parent=None):
        super(DeptClerksModule, self).__init__(parent)
        self.setupUi(self)
        if '0' not in  user.powers:
            self.close()
        if user.powers['0'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['0'])

        self.treeWidget_deptlist.hideColumn(2)
        self.treeWidget_userlist.hideColumn(0)
        self.CC = ClerksController()
        self.current_deptid = None
        self.disabled = 0
        # 全部部门信息
        self.alldeptment = []
        # 全部人员信息
        self.allclerks = []

        # 增加部门列表里的内容
        self.get_deptment_list()
        self.get_clerks_list()
Example #10
0
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()
Example #11
0
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()
Example #12
0
class DeptClerksModule(QWidget, Ui_clerks):
    def __init__(self, parent=None):
        super(DeptClerksModule, self).__init__(parent)
        self.setupUi(self)
        if '0' not in  user.powers:
            self.close()
        if user.powers['0'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['0'])

        self.treeWidget_deptlist.hideColumn(2)
        self.treeWidget_userlist.hideColumn(0)
        self.CC = ClerksController()
        self.current_deptid = None
        self.disabled = 0
        # 全部部门信息
        self.alldeptment = []
        # 全部人员信息
        self.allclerks = []

        # 增加部门列表里的内容
        self.get_deptment_list()
        self.get_clerks_list()

    def get_clerks_list(self):
        self.treeWidget_userlist.clear()
        condition = {'disabled': self.disabled}
        if self.current_deptid is None or self.current_deptid == '0':
            res = self.CC.get_data(0, False, *VALUES_TUPLE_CL, **condition)
        else:
            res = self.CC.get_data(0, False, **condition).extra(
                tables=['clerkdept'],
                where=['clerkdept.deptid=' + self.current_deptid,
                       'clerks.autoid=clerkdept.clerkid']
            ).values(*VALUES_TUPLE_CL)
        if not len(res):
            return
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_userlist)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['clerkid'])
            qtreeitem.setText(2, item['clerkname'])
            qtreeitem.setText(3, item['sex'])
            qtreeitem.setText(
                4, str(item['birthday']) if type(item['birthday']) is
                                            datetime.date else ''
            )
            qtreeitem.setText(
                5, str(item['entranceday']) if type(item['entranceday']) is
                                            datetime.date else '')
            qtreeitem.setText(6, item['edudegree'])
            qtreeitem.setText(7, item['marrystatus'])
            qtreeitem.setText(8, '*'*14 + item['idno'][-4:])
            qtreeitem.setText(9, item['telno'])
        for i in range(10):
            self.treeWidget_userlist.resizeColumnToContents(i)

    # 人员列表双击的功能
    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_userlist_itemDoubleClicked(self,  qtreeitem, p_int):
        if self.power[1] == '0':
            return
        autoid = int(qtreeitem.text(0))
        detail = ClerkDtailModule(autoid, self)
        detail.accepted.connect(self.get_clerks_list)
        detail.show()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_deptlist_itemClicked(self, qtreeitem, p_int):
        self.current_deptid = qtreeitem.text(2)
        self.get_clerks_list()

    @pyqtSlot(int)
    def on_tabWidget_currentChanged(self, p_int):
        getattr(self, 'tab_' + str(p_int)).setLayout(self.gridLayout_2)
        self.disabled = p_int
        self.get_clerks_list()

    # 部门菜单右键功能
    @pyqtSlot(QPoint)
    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

    # 人员菜单右键功能
    @pyqtSlot(QPoint)
    def on_treeWidget_userlist_customContextMenuRequested(self, pos):
        if self.power[1] == '0':
            return
        menu = QMenu()
        item1 = menu.addAction("新增人员信息")
        item2 = menu.addAction("修改人员信息")
        item3 = menu.addAction("删除人员信息")
        # 把坐标转换为屏幕坐标
        screenpos = self.treeWidget_userlist.mapToGlobal(pos)
        # 设置菜单显示的位置,返回点击了哪个功能
        action = menu.exec(screenpos)
        # 根据点击了哪个功能绑定对应的事件

        if action == item1:
            detail = CreateClerkModule(self)
            detail.accepted.connect(self.get_clerks_list)
            detail.show()
        elif action == item2:
            self.modify_deptment(self.treeWidget_deptlist)
        elif action == item3:
            self.delete_deptment()
        else:
            pass

    # 刷新部门列表的内容
    def get_deptment_list(self):
        # 清空“全部部门”下的所有子节点
        self.treeWidget_deptlist.clear()
        # 查询所有部门信息
        self.alldeptment = self.CC.get_data(2, False, *VALUES_TUPLE_DEPT)

        # 获得“全部部门”的item地址
        alldeptitem = QTreeWidgetItem(self.treeWidget_deptlist)
        alldeptitem.setText(1, "全部部门")
        alldeptitem.setText(2, "0")
        # 把全部部门作为父节点,把查询到的部门信息添加到“全部部门”下
        self.adddeptitem(alldeptitem, *self.alldeptment)
        # 设置“全部部门”为当前选中项目
        self.treeWidget_deptlist.setCurrentItem(alldeptitem)
        self.current_deptid = '0'
        # 展开“所有部门”
        self.treeWidget_deptlist.expandAll()

        for i in range(2):
            self.treeWidget_deptlist.resizeColumnToContents(i)

    # 添加部门列表的内容
    # parent  树根节点
    # aldeptitem    “全部部门”的地址,作为其他节点的父节点
    # items         需要增加的节点内容
    # 方法:首先遍历item,判断parentid是否为空,若为空,则判断deptid对应的节点
    #       是否已经被创建,若已存在则设置deptid和deptname的值,若没有被创建
    #       则建立对应的节点(父节点为alldeptitem),并设置deptid和deptname的值
    #
    #       若parentid不为空,则把父节点设置为parentid对应的节点,若父节点还没
    #       被创建则先建立父节点并设置deptid  = parentid,用于后续查询节点用。
    def adddeptitem(self, alldeptitem, *items):
        for item in items:
            if 'hasset' in item:
                continue
            # 有上级部门
            if item['parentid'] != '':
                # 获取/建立上级部门的节点
                parent_treeitem = self.create_parent_treeitem(
                    alldeptitem, item['parentid'], *items
                )
            else:
                parent_treeitem = alldeptitem
            childtreeitem = QTreeWidgetItem(parent_treeitem)
            childtreeitem.setText(0, item["deptid"])
            childtreeitem.setText(1, item["deptname"])
            childtreeitem.setText(2, str(item["autoid"]))

    # 添加所有部门,逐层添加上级部门,直到上级部门已经存在
    def create_parent_treeitem(self, alldeptitem, parent_id, *items):

        # 直接在树节点中寻找上级节点
        parent_item = self.treeWidget_deptlist.findItems(
            parent_id, Qt.MatchExactly | Qt.MatchRecursive, 0
        )
        # 存在上级节点
        if len(parent_item):
            return parent_item[0]
        # 不存在上级节点,则遍历所有部门,找到对应的记录后新建一个子节点
        else:
            flag = False
            for item in items:
                if parent_id == item['deptid']:
                    item['hasset'] = True
                    flag = True
                    if item['parentid'] == '':
                        grand_item = QTreeWidgetItem(alldeptitem)
                        grand_item.setText(0, item['deptid'])
                        grand_item.setText(1, item['deptname'])
                        grand_item.setText(2, str(item['autoid']))
                    else:
                        grand_item = self.create_parent_treeitem(
                            alldeptitem, item['parentid'], *items
                        )
                    return grand_item
            if not flag:
                return alldeptitem
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()
Example #14
0
class EditPostWorkerModule(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(EditPostWorkerModule, self).__init__(parent)
        self.setupUi(self)
        self.LC = LinepostController()
        self.PC = ProductLineConroller()
        self.CC = ClerksController()

        self.get_productline()
        self.get_worker()

    # 获取当前部门的生产线
    def get_productline(self):
        condition = {'deptid': user.dept_id}
        res = self.PC.get_data(0, False, *VALUES_TUPLE_PL, **condition)
        if not len(res):
            return
        for item in res:
            # parent_item = self.treeWidget_productline
            match_items = self.treeWidget_productline.findItems(
                item['kind'], Qt.MatchExactly, 0)
            if len(match_items):
                parent_item = match_items[0]
            else:
                parent_item = QTreeWidgetItem(self.treeWidget_productline)
                parent_item.setText(0, item['kind'])
                parent_item.setText(1, '0')
                parent_item.setText(2, '0')
                parent_item.setText(3, '0')
            qtreeitem = QTreeWidgetItem(parent_item)
            qtreeitem.setText(0, item['linename'])
            qtreeitem.setText(1, str(item['autoid']))
            qtreeitem.setText(2, '1')
            qtreeitem.setText(3, '0')
            self.get_workflow(qtreeitem, item['autoid'])

    # 获取plid(生产线id)的岗位
    def get_workflow(self, parentitem, plid):
        condition_wf = {'plid_id': plid}
        res = self.PC.get_data(1, False, *VALUES_TUPLE_WF,
                               **condition_wf).order_by('seqid')
        for item in res:
            qtreeitem = QTreeWidgetItem(parentitem)
            qtreeitem.setText(0, item['postname'])
            qtreeitem.setText(1, str(item['autoid']))
            qtreeitem.setText(2, '2')
            qtreeitem.setText(3, str(item['seqid']))
            self.get_postworker(qtreeitem, item['autoid'])

    # 获取wfid(岗位id)的现有工人
    def get_postworker(self, parentitem, wfid):
        parentitem.takeChildren()
        condition = {'wfid': wfid}
        res = self.LC.get_data(1, False, **condition).order_by('seqid')
        for item in res:
            qtreeitem = QTreeWidgetItem(parentitem)
            qtreeitem.setText(
                0, item.clerkid.clerkid + ' ' + item.clerkid.clerkname)
            qtreeitem.setText(1, str(item.autoid))
            qtreeitem.setText(2, '3')
            qtreeitem.setText(3, str(item.seqid))

    def get_worker(self):
        res = self.CC.get_data(1).extra(
            tables=['Department'],
            where=[
                'Department.autoid=Clerkdept.deptid',
                'Department.deptid=' + user.dept_id
            ])
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_worker)
            qtreeitem.setText(0, str(item.clerkid_id))
            qtreeitem.setText(1, item.clerkid.clerkid)
            qtreeitem.setText(2, item.clerkid.clerkname)

    @pyqtSlot(QDropEvent, QPoint)
    def on_treeWidget_productline_droped(self, event, pos):
        event.ignore()
        qtreeitem = self.treeWidget_productline.itemAt(pos)
        type = int(qtreeitem.text(2))
        if type not in (2, 3):
            return
        if event.source() == self.treeWidget_worker:
            current_item = self.treeWidget_worker.currentItem()
            if current_item is None:
                return
            clerkid = int(current_item.text(0))
            if type == 2:
                parentitem = qtreeitem
                wfid = int(qtreeitem.text(1))
                seqid = qtreeitem.childCount() + 1
            else:
                parentitem = qtreeitem.parent()
                wfid = int(qtreeitem.parent().text(1))
                seqid = int(qtreeitem.text(3))
                condition = {'wfid_id': wfid, 'seqid__gte': seqid}
                detail = {'seqid': F('seqid') + 1}
                self.LC.update_data(1, condition, **detail)
            new_detail = {
                'clerkid_id': clerkid,
                'wfid_id': wfid,
                'seqid': seqid
            }
            self.LC.update_data(1, **new_detail)
            self.get_postworker(parentitem, wfid)
        elif event.source() == self.treeWidget_productline:
            current_item = self.treeWidget_productline.currentItem()
            if current_item is None or current_item.text(2) != '3':
                return
            id = int(current_item.text(1))
            if type == 2:
                parentitem = qtreeitem
                wfid = int(qtreeitem.text(1))
                seqid = qtreeitem.childCount()
                condition = {'wfid_id': wfid, 'seqid__gt': seqid}
                detail = {'seqid': F('seqid') - 1}
                self.LC.update_data(1, condition, **detail)
            else:
                parentitem = qtreeitem.parent()
                wfid = int(parentitem.text(1))
                seqid = int(qtreeitem.text(3))
                condition = {'wfid_id': wfid, 'seqid__gte': seqid}
                detail = {'seqid': F('seqid') + 1}
                self.LC.update_data(1, condition, **detail)
            condition_ori = {'autoid': id}
            new_detail = {'seqid': seqid}
            self.LC.update_data(1, condition_ori, **new_detail)
            self.get_postworker(parentitem, wfid)
        else:
            return

    @pyqtSlot(QPoint)
    def on_treeWidget_productline_customContextMenuRequested(self, pos):
        current_item = self.treeWidget_productline.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("删除")
        global_pos = self.treeWidget_productline.mapToGlobal(pos)
        action = menu.exec(global_pos)
        if action == action_1:
            if current_item is None or current_item.text(2) != '3':
                return
            id = int(current_item.text(1))
            wfid = int(current_item.parent().text(1))
            seqid = int(current_item.text(3))
            condition = {'wfid_id': wfid, 'seqid__gt': seqid}
            detail = {'seqid': F('seqid') - 1}
            self.LC.update_data(1, condition, **detail)
            condition_delete = {'autoid': id}
            self.LC.delete_data(1, condition_delete)
            self.get_postworker(current_item.parent(), wfid)
Example #15
0
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)
Example #16
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()
Example #17
0
 def __init__(self, parent=None):
     super(CreateClerkModule, self).__init__(parent)
     self.setupUi(self)
     self.new_detail = {}
     self.CC = ClerksController()
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