Пример #1
0
class SelfCheckListModule(QWidget, Ui_Form):

    def __init__(self, parent=None):
        super(SelfCheckListModule, self).__init__(parent)
        self.setupUi(self)
        self.SC = SelfCheckController()
        self.status = 0
        # self.treeWidget_checklist.hideColumn(0)
        self.get_detail()


    def get_detail(self):
        self.treeWidget_checklist.clear()
        condition = {'status': self.status}
        res = self.SC.get_data(1, False, *VALUES_TUPLE_ITEM, **condition)
        if not len(res):
            return
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_checklist)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['title'])
            qtreeitem.setText(2, str(item['cdate']))
            qtreeitem.setText(3, item['creatorid'] + ' ' + item['creatorname'])
        for i in range(1, 4):
            self.treeWidget_checklist.resizeColumnToContents(i)

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

    @pyqtSlot(QPoint)
    def on_treeWidget_checklist_customContextMenuRequested(self, pos):
        global_pos =  self.treeWidget_checklist.mapToGlobal(pos)
        current_item = self.treeWidget_checklist.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("增加")
        action_2 = menu.addAction("修改")
        action_3 = menu.addAction("删除")
        action = menu.exec(global_pos)
        if action == action_1:
            detail = SelfCheckReportModule(parent=self)
            detail.modified.connect(self.get_detail)
            detail.show()
        elif action == action_2:
            if current_item is None:
                return
            id = int(current_item.text(0))
            detail = SelfCheckReportModule(id, self)
            detail.modified.connect(self.get_detail)
            detail.show()
        elif action == action_3:
            if current_item is None:
                return
            id = int(current_item.text(0))
            condition = {'autoid': id}
            self.SC.delete_data(0, **condition)
            # self.get_item_kind()
            self.get_detail()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_checklist_itemDoubleClicked(self, qtreeitem, p_int):
        id = int(qtreeitem.text(0))
        detail = SelfCheckReportModule(id, self)
        # detail.accepted.connect(self.get_item_kind)
        detail.modified.connect(self.get_detail)
        detail.show()
Пример #2
0
class SelfCheckItemListModule(QWidget, Ui_Form):

    def __init__(self, parent=None):
        super(SelfCheckItemListModule, self).__init__(parent)
        self.setupUi(self)
        self.SC = SelfCheckController()
        self.current_kind = ''
        self.treeWidget_items.hideColumn(0)
        self.get_item_kind()

    def get_item_kind(self):
        temp_kind = self.current_kind
        self.comboBox_kind.clear()
        res = self.SC.get_data(0, True, *VALUES_TUPLE_KIND).distinct()
        if len(res):
            self.comboBox_kind.addItems(res)
        if temp_kind != '':
            self.comboBox_kind.setCurrentText(temp_kind)

    def get_detail(self):
        self.treeWidget_items.clear()
        condition = {'kind': self.current_kind}
        res = self.SC.get_data(0, False, *VALUES_TUPLE_ITEM, **condition)
        if not len(res):
            return
        for item in res.order_by('seqid'):
            qtreeitem = QTreeWidgetItem(self.treeWidget_items)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, str(item['seqid']))
            qtreeitem.setText(2, item['itemname'])
            qtreeitem.setText(3, item['basic'])
        for i in range(1, 4):
            self.treeWidget_items.resizeColumnToContents(i)

    @pyqtSlot(str)
    def on_comboBox_kind_currentTextChanged(self, p_str):
        self.current_kind = p_str
        self.get_detail()

    @pyqtSlot(QPoint)
    def on_treeWidget_items_customContextMenuRequested(self, pos):
        global_pos =  self.treeWidget_items.mapToGlobal(pos)
        current_item = self.treeWidget_items.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("增加")
        action_2 = menu.addAction("修改")
        action_3 = menu.addAction("删除")
        action = menu.exec(global_pos)
        if action == action_1:
            detail = EditSelfCheckItemModule(parent=self)
            detail.accepted.connect(self.get_item_kind)
            detail.accepted.connect(self.get_detail)
            detail.show()
        elif action == action_2:
            if current_item is None:
                return
            id = int(current_item.text(0))
            detail = EditSelfCheckItemModule(id, self)
            detail.accepted.connect(self.get_item_kind)
            detail.accepted.connect(self.get_detail)
            detail.show()
        elif action == action_3:
            if current_item is None:
                return
            id = int(current_item.text(0))
            condition = {'autoid': id}
            self.SC.delete_data(0, **condition)
            self.get_item_kind()
            self.get_detail()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_items_itemDoubleClicked(self, qtreeitem, p_int):
        id = int(qtreeitem.text(0))
        detail = EditSelfCheckItemModule(id, self)
        detail.accepted.connect(self.get_item_kind)
        detail.accepted.connect(self.get_detail)
        detail.show()
Пример #3
0
class SelfCheckReportModule(QDialog, Ui_Dialog):
    modified = pyqtSignal()

    def __init__(self, autoid=None, parent=None):
        super(SelfCheckReportModule, self).__init__(parent)
        self.setupUi(self)
        self.autoid = autoid
        # 自检项目的id
        self.dscrid = 0
        self.scrid = None
        self.rectify_status = 0
        self.temp_dept = ''
        self.SC = SelfCheckController()
        self.ori_detail_record = {}
        self.new_detail_record = {}
        self.ori_detail_report = {}
        self.new_detail_report = {}
        self.ori_detail_kind = {}
        self.new_detail_kind = {}
        self.checkkindlist = []
        self.treeWidget_checkitem.hideColumn(0)
        # self.treeWidget_checkrecords.hideColumn(0)
        self.get_detail()
        self.get_dept_list()
        self.get_rectify_report_list()
        self.get_checkreport()

    def get_detail(self):
        if self.autoid is None:
            self.dateEdit_cdate.setDate(user.now_date)
            self.label_creator.setText(
                user.user_id + ' ' + user.user_name
            )
            self.tabWidget.setTabVisible(1, False)
            self.tabWidget.setTabVisible(2, False)
            return
        condition = {'autoid': self.autoid}
        res = self.SC.get_data(1, False, *VALUES_TUPLE_ITEM, **condition)
        if len(res) != 1:
            return
        self.ori_detail_record = res[0]
        self.dateEdit_cdate.setDate(self.ori_detail_record['cdate'])
        self.lineEdit_title.setText(self.ori_detail_record['title'])
        self.label_creator.setText(
            self.ori_detail_record['creatorid'] + ' ' +
            self.ori_detail_record['creatorname']
        )
        self.plainTextEdit_summary.setPlainText(
            self.ori_detail_record['summary']
        )


    def get_dept_list(self):
        self.comboBox_dept.clear()
        condition = {'scrid': self.autoid}
        res = self.SC.get_data(3, True, *VALUES_TUPLE_DEPT, **condition).\
            distinct()
        if len(res):
            self.comboBox_dept.addItems(res)
        if self.comboBox_dept.findText(self.temp_dept, Qt.MatchExactly):
            self.comboBox_dept.setCurrentText(self.temp_dept)

    def get_rectify_report_list(self):
        self.treeWidget_rectify.clear()
        condition = {'scrid': self.autoid, 'status': self.rectify_status}
        res = self.SC.get_data(5, False, *VALUES_TUPLE_RECTIFY, **condition)
        if not len(res):
            return
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_rectify)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['deptid'] + ' ' + item['deptname'])
            qtreeitem.setText(2, item['accordance'])
            qtreeitem.setText(3, item['qaid'] + ' ' + item['qaname'])
        for i in range(1, 4):
            self.treeWidget_rectify.resizeColumnToContents(i)

    @pyqtSlot(int)
    def on_tabWidget_2_currentChanged(self, p_int):
        self.rectify_status = p_int
        getattr(self, 'rectify_' + str(p_int)).setLayout(self.gridLayout_7)
        self.get_rectify_report_list()


    @pyqtSlot(str)
    def on_lineEdit_seqid_textChanged(self, p_str):
        p_int = int(p_str)
        try:
            if p_int != self.ori_detail['seqid']:
                self.new_detail['seqid'] = p_int
            else:
                try:
                    del self.new_detail['seqid']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['seqid'] = p_int

    @pyqtSlot(str)
    def on_comboBox_dept_currentTextChanged(self, p_str):
        self.treeWidget_checkitem.clear()
        condition = {'deptname': p_str, 'scrid_id': self.autoid}
        self.checkkindlist = self.SC.get_data(
            3, False, *VALUES_TUPLE_KIND, **condition
        )
        if not len(self.checkkindlist):
            return
        for item in self.checkkindlist:
            qtreeitem = QTreeWidgetItem(self.treeWidget_checkitem)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['kind'])

    @pyqtSlot(QPoint)
    def on_treeWidget_checkitem_customContextMenuRequested(self, pos):
        if self.autoid is None:
            return
        current_item = self.treeWidget_checkitem.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("新增自检记录")
        action_2 = menu.addAction("删除自检记录")
        global_pos = self.treeWidget_checkitem.mapToGlobal(pos)
        action = menu.exec(global_pos)
        if action == action_1:
            detail = AddCheckRecord(self.autoid, self)
            self.temp_dept = self.comboBox_dept.currentText()
            detail.accepted.connect(self.added_dept)
            detail.accepted.connect(self.get_dept_list)
            detail.show()
        elif action == action_2:
            if current_item is None:
                return
            id = int(current_item.text(0))
            condition = {'autoid': id}
            self.SC.delete_data(3, condition)
            self.temp_dept = self.comboBox_dept.currentText()
            self.get_dept_list()

    @pyqtSlot(QPoint)
    def on_treeWidget_rectify_customContextMenuRequested(self, pos):
        current_item = self.treeWidget_rectify.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("新增整改通知")
        action_2 = menu.addAction("修改整改通知")
        action_3 = menu.addAction("删除整改通知")
        global_pos = self.treeWidget_rectify.mapToGlobal(pos)
        action = menu.exec(global_pos)
        if action == action_1:
            detail = RectifyReportModule(scrid=self.autoid, parent=self)
            detail.saved.connect(self.get_rectify_report_list)
            detail.accepted.connect(self.get_rectify_report_list)
            detail.show()
        elif action == action_2:
            if current_item is None:
                return
            id = int(current_item.text(0))
            detail = RectifyReportModule(autoid=id, parent=self)
            detail.saved.connect(self.get_rectify_report_list)
            detail.accepted.connect(self.get_rectify_report_list)
            detail.show()
        elif action == action_3:
            if current_item is None:
                return
            id = int(current_item.text(0))
            condition = {'autoid': id}
            self.SC.delete_data(5, condition)
            self.get_rectify_report_list()

    @pyqtSlot(QPoint)
    def on_treeWidget_scsigns_customContextMenuRequested(self, pos):
        current_item = self.treeWidget_scsigns.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("删除")
        global_pos = self.treeWidget_scsigns.mapToGlobal(pos)
        action = menu.exec(global_pos)
        if action == action_1:
            if current_item is None:
                return
            index = self.treeWidget_scsigns.indexOfTopLevelItem(current_item)
            self.treeWidget_scsigns.takeTopLevelItem(index)

    @pyqtSlot(QPoint)
    def on_treeWidget_deptsigns_customContextMenuRequested(self, pos):
        current_item = self.treeWidget_deptsigns.currentItem()
        menu = QMenu()
        action_1 = menu.addAction("删除")
        global_pos = self.treeWidget_deptsigns.mapToGlobal(pos)
        action = menu.exec(global_pos)
        if action == action_1:
            if current_item is None:
                return
            index = self.treeWidget_deptsigns.indexOfTopLevelItem(current_item)
            self.treeWidget_deptsigns.takeTopLevelItem(index)

    def added_dept(self):
        self.temp_dept = user.dept_name

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_checkitem_itemClicked(self, qtreeitem, p_int):
        # 点击种类列表中的项目
        self.dscrid = int(qtreeitem.text(0))
        self.get_checkrecords()

    def get_checkrecords(self):
        self.treeWidget_checkrecords.clear()

        condition = {'dscrid_id': self.dscrid}
        res = self.SC.get_data(4, False, *VALUES_TUPLE_CHECKITEM, **condition)
        if not len(res):
            return
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_checkrecords)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, str(item['seqid']))
            qtreeitem.setText(2, item['itemname'])
            qtreeitem.setText(3, item['gist'])
            qtreeitem.setText(4, item['result'])
            qtreeitem.setText(5, item['rdate'])
            qtreeitem.setText(6, item['cdate'])
        for i in range(1, 7):
            self.treeWidget_checkrecords.resizeColumnToContents(i)
        self.ori_detail_kind = None
        for item in self.checkkindlist:
            if item['autoid'] == self.dscrid:
                self.ori_detail_kind = item
                break
        if self.ori_detail_kind is None:
            return
        self.label_dept.setText(
            self.ori_detail_kind['deptid'] + ' ' + self.ori_detail_kind['deptname']
        )
        self.label_checkitem.setText(self.ori_detail_kind['kind'])
        self.dateEdit_checkdate.setDate(self.ori_detail_kind['checkdate'])
        self.lineEdit_checkers.setText(self.ori_detail_kind['checkers'])
        self.plainTextEdit_measure.setPlainText(self.ori_detail_kind['measure'])
        self.plainTextEdit_evaluation.setPlainText(
            self.ori_detail_kind['evaluation']
        )
        self.lineEdit_conclusion.setText(self.ori_detail_kind['conclusion'])
        self.label_charger.setText(
            self.ori_detail_kind['chargerid'] + ' ' +
            self.ori_detail_kind['chargername']
        )
        self.dateEdit_chdate.setDate(self.ori_detail_kind['chdate'])

    def get_checkreport(self):
        if self.autoid is None:
            return
        condition = {'scrid': self.autoid}
        res = self.SC.get_data(2, False, *VALUES_TUPLE_REPORT, **condition)

        if not len(res):
            self.dateEdit_fromdate.setDate(user.now_date)
            self.dateEdit_todate.setDate(user.now_date)
            return
        self.ori_detail_report = res[0]
        self.scrid = self.ori_detail_report['autoid']
        self.dateEdit_fromdate.setDate(self.ori_detail_report['fromdate'])
        self.dateEdit_todate.setDate((self.ori_detail_report['todate']))
        self.pushButton_charger.setText(
            self.ori_detail_report['chargerid'] + ' ' +
            self.ori_detail_report['chargername']
        )
        self.plainTextEdit_scrange.setPlainText(
            self.ori_detail_report['scrange']
        )
        self.plainTextEdit_assess.setPlainText(
            self.ori_detail_report['assess']
        )
        self.plainTextEdit_flaws.setPlainText(
            self.ori_detail_report['flaws']
        )
        self.plainTextEdit_description.setPlainText(
            self.ori_detail_report['description']
        )
        scsigns = self.ori_detail_report['scsigns']
        for item in scsigns.split(';'):
            try:
                id, name = item.split(' ')
                qtreeitem = QTreeWidgetItem(self.treeWidget_scsigns)
                qtreeitem.setText(0, id)
                qtreeitem.setText(1, name)
            except ValueError:
                pass
        deptsigns = self.ori_detail_report['deptsigns']
        for item in deptsigns.split(';'):
            try:
                id, name = item.split(' ')
                qtreeitem = QTreeWidgetItem(self.treeWidget_deptsigns)
                qtreeitem.setText(0, id)
                qtreeitem.setText(1, name)
            except ValueError:
                pass


    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_checkrecords_itemDoubleClicked(self, qtreeitem, p_int):
        id = int(qtreeitem.text(0))
        detail = EditSelfCheckRecordModule(id, self)
        detail.accepted.connect(self.get_checkrecords)
        detail.show()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_rectify_itemDoubleClicked(self, qtreeitem, p_int):
        id = int(qtreeitem.text(0))
        detail = RectifyReportModule(autoid=id, parent=self)
        detail.saved.connect(self.get_rectify_report_list)
        detail.accepted.connect(self.get_rectify_report_list)
        detail.show()



    @pyqtSlot(QDate)
    def on_dateEdit_cdate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail_record['cdate']) is str:
                self.new_detail_record['cdate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail_record['cdate']):
                self.new_detail_record['cdate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail_record['cdate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_record['cdate'] = q_date.toPyDate()

    @pyqtSlot(str)
    def on_lineEdit_title_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail_record['title']:
                self.new_detail_record['title'] = p_str
            else:
                try:
                    del self.new_detail_record['title']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_record['title'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_summary_textChanged(self):
        p_str = self.plainTextEdit_evaluation.toPlainText()
        try:
            if p_str != self.ori_detail_record['summary']:
                self.new_detail_record['summary'] = p_str
            else:
                try:
                    del self.new_detail_record['summary']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_record['summary'] = p_str

    @pyqtSlot()
    def on_pushButton_modify_clicked(self):
        if len(self.new_detail_record):
            self.new_detail_record['creatorid'] = user.user_id
            self.new_detail_record['creatorname'] = user.user_name
            self.label_creator.setText(user.user_id + ' ' + user.user_name)
            if self.autoid is None:
                res = self.SC.update_data(1, **self.new_detail_record)
                self.autoid = res.autoid
                self.tabWidget.setTabVisible(1, True)
                self.tabWidget.setTabVisible(2, True)
            else:
                condition = {'autoid': self.autoid}
                self.SC.update_data(1, condition, **self.new_detail_record)
            self.modified.emit()

    @pyqtSlot()
    def on_plainTextEdit_itemname_textChanged(self):
        p_str = self.plainTextEdit_itemname.toPlainText()
        try:
            if p_str != self.ori_detail['itemname']:
                self.new_detail['itemname'] = p_str
            else:
                try:
                    del self.new_detail['itemname']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['itemname'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_basic_textChanged(self):
        p_str = self.plainTextEdit_basic.toPlainText()
        try:
            if p_str != self.ori_detail['basic']:
                self.new_detail['basic'] = p_str
            else:
                try:
                    del self.new_detail['basic']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['basic'] = p_str

    @pyqtSlot(QDate)
    def on_dateEdit_checkdate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail_kind['checkdate']) is str:
                self.new_detail_kind['checkdate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail_kind['checkdate']):
                self.new_detail_kind['checkdate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail_kind['checkdate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['checkdate'] = q_date.toPyDate()

    @pyqtSlot(str)
    def on_lineEdit_checkers_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail_kind['checkers']:
                self.new_detail_kind['checkers'] = p_str
            else:
                try:
                    del self.new_detail_kind['checkers']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['checkers'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_measure_textChanged(self):
        p_str = self.plainTextEdit_measure.toPlainText()
        try:
            if p_str != self.ori_detail_kind['measure']:
                self.new_detail_kind['measure'] = p_str
            else:
                try:
                    del self.new_detail_kind['measure']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['measure'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_evaluation_textChanged(self):
        p_str = self.plainTextEdit_evaluation.toPlainText()
        try:
            if p_str != self.ori_detail_kind['evaluation']:
                self.new_detail_kind['evaluation'] = p_str
            else:
                try:
                    del self.new_detail_kind['evaluation']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['evaluation'] = p_str

    @pyqtSlot(str)
    def on_lineEdit_conclusion_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail_kind['conclusion']:
                self.new_detail_kind['conclusion'] = p_str
            else:
                try:
                    del self.new_detail_kind['conclusion']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['conclusion'] = p_str

    @pyqtSlot(QDate)
    def on_dateEdit_chdate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail_kind['chdate']) is str:
                self.new_detail_kind['chdate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail_kind['chdate']):
                self.new_detail_kind['chdate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail_kind['chdate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_kind['chdate'] = q_date.toPyDate()

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        if len(self.new_detail_kind):
            self.new_detail_kind['chargerid'] = user.user_id
            self.new_detail_kind['chargername'] = user.user_name
            self.label_charger.setText(user.user_id + ' ' + user.user_name)
            if self.dscrid:
                condition = {'autoid': self.dscrid}
                self.SC.update_data(3, condition, **self.new_detail_kind)
                self.new_detail_kind = {}
            self.modified.emit()

    @pyqtSlot()
    def on_pushButton_cancel_clicked(self):
        self.close()


    @pyqtSlot(QDate)
    def on_dateEdit_fromdate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail_report['fromdate']) is str:
                self.new_detail_report['fromdate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail_report['fromdate']):
                self.new_detail_report['fromdate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail_report['fromdate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['fromdate'] = q_date.toPyDate()

    @pyqtSlot(QDate)
    def on_dateEdit_todate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail_report['todate']) is str:
                self.new_detail_report['todate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail_report['todate']):
                self.new_detail_report['todate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail_report['todate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['todate'] = q_date.toPyDate()

    @pyqtSlot(bool, str)
    def on_pushButton_charger_signChanged(self, p_bool, p_str):
        id, name = p_str.split(' ') if p_bool else ('', '')
        try:
            if id != self.ori_detail_report['chargerid'] or \
                    name != self.ori_detail_report['chargername']:
                self.new_detail_report['chargerid'] = id
                self.new_detail_report['chargername'] = name
            else:
                try:
                    del self.new_detail_report['chargerid']
                    del self.new_detail_report['chargername']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['chargerid'] = id
            self.new_detail_report['chargername'] = name


    @pyqtSlot()
    def on_pushButton_scsign_clicked(self):
        detail = SignModule(self)
        detail.userchanged.connect(self.scsign)
        detail.show()

    @pyqtSlot()
    def on_pushButton_deptsign_clicked(self):
        detail = SignModule(self)
        detail.userchanged.connect(self.deptsign)
        detail.show()

    def scsign(self, p_bool, p_str):
        if p_bool:
            id, name = p_str.split(' ')
            qtreeitem = QTreeWidgetItem(self.treeWidget_scsigns)
            qtreeitem.setText(0, id)
            qtreeitem.setText(1, name)

    def deptsign(self, p_bool, p_str):
        if p_bool:
            id, name = p_str.split(' ')
            qtreeitem = QTreeWidgetItem(self.treeWidget_deptsigns)
            qtreeitem.setText(0, id)
            qtreeitem.setText(1, name)

    @pyqtSlot()
    def on_plainTextEdit_scrange_textChanged(self):
        p_str = self.plainTextEdit_scrange.toPlainText()
        try:
            if p_str != self.ori_detail_report['scrange']:
                self.new_detail_report['scrange'] = p_str
            else:
                try:
                    del self.new_detail_report['scrange']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['scrange'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_assess_textChanged(self):
        p_str = self.plainTextEdit_assess.toPlainText()
        try:
            if p_str != self.ori_detail_report['assess']:
                self.new_detail_report['assess'] = p_str
            else:
                try:
                    del self.new_detail_report['assess']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['assess'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_flaws_textChanged(self):
        p_str = self.plainTextEdit_flaws.toPlainText()
        try:
            if p_str != self.ori_detail_report['flaws']:
                self.new_detail_report['flaws'] = p_str
            else:
                try:
                    del self.new_detail_report['flaws']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['flaws'] = p_str

    @pyqtSlot()
    def on_plainTextEdit_description_textChanged(self):
        p_str = self.plainTextEdit_description.toPlainText()
        try:
            if p_str != self.ori_detail_report['description']:
                self.new_detail_report['description'] = p_str
            else:
                try:
                    del self.new_detail_report['description']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail_report['description'] = p_str

    @pyqtSlot()
    def on_pushButton_save_clicked(self):
        self.get_scsigns()
        self.get_deptsigns()
        if len(self.new_detail_report):
            if self.scrid is None:
                self.new_detail_report['scrid'] = self.autoid
                self.SC.update_data(2, **self.new_detail_report)
            else:
                condition = {'autoid': self.scrid}
                self.SC.update_data(2, condition, **self.new_detail_report)

    def get_scsigns(self):
        user_list = ''
        it = QTreeWidgetItemIterator(self.treeWidget_scsigns)
        while it.value():
            qtreeitem = it.value()
            user_list += qtreeitem.text(0) + ' ' + qtreeitem.text(1) + ';'
            it += 1
        try:
            if user_list != self.ori_detail_report['scsigns']:
                self.new_detail_report['scsigns'] = user_list
        except KeyError:
            pass

    def get_deptsigns(self):
        user_list = ''
        it = QTreeWidgetItemIterator(self.treeWidget_deptsigns)
        while it.value():
            qtreeitem = it.value()
            user_list += qtreeitem.text(0) + ' ' + qtreeitem.text(1) + ';'
            it += 1
        try:
            if user_list != self.ori_detail_report['deptsigns']:
                self.new_detail_report['deptsigns'] = user_list
        except KeyError:
            pass