Browse Source

封装选择人员组件,修改设备台账选择人员

zhoupeng 1 year ago
parent
commit
e7e4f0b856

+ 22 - 8
industry-admin/src/views/device/deviceLedger/deviceLedger.vue

@@ -58,15 +58,16 @@
                     </el-col>
                     <el-col :span="8">
                         <el-form-item label="使用部门" prop="deviceDeptName" label-width="22%">
-                            <el-input v-model="deviceLedgerForm.deviceDeptName" disabled placeholder="使用部门" maxlength="10">
+                            <el-input v-model="deviceLedgerForm.deviceDeptName" disabled placeholder="请选择使用部门" maxlength="10">
                                 <el-button slot="append" icon="el-icon-search" @click="chooseDept"></el-button>
                             </el-input>
                         </el-form-item>
                     </el-col>
                     <el-col :span="8">
-                        <el-form-item label="责任人" prop="devicePerson" label-width="22%">
-                            <el-input type="number" v-model="deviceLedgerForm.devicePerson" placeholder="责任人" maxlength="10">
-                                <!-- <el-button slot="append" icon="el-icon-search" @click="chooseDeviceType"></el-button> -->
+                        <el-form-item label="责任人" prop="devicePersonName" label-width="22%">
+                            <el-input v-model="deviceLedgerForm.devicePersonName" disabled placeholder="请选择责任人" maxlength="10">
+                                <el-button type="primary" slot="append" icon="el-icon-search"
+                                    @click="chooseDevicePerson">选择</el-button>
                             </el-input>
                         </el-form-item>
                     </el-col>
@@ -179,6 +180,8 @@
         <ChooseDeviceType ref="chooseDeviceType" @receiveChooseDeviceType="receiveChooseDeviceType"></ChooseDeviceType>
         <!-- 选择部门 -->
         <ChooseDept ref="chooseDept" @receiveChooseDept="receiveChooseDept"></ChooseDept>
+        <!-- 选择责任人 -->
+        <ChooseStaff ref="chooseDevicePerson" @receiveChooseStaff="receiveChooseStaff"></ChooseStaff>
     </div>
 </template>
 
@@ -186,6 +189,7 @@
 import SelectTree from '@/components/SelectTree/index.vue'
 import ChooseDeviceType from '@/views/device/deviceType/chooseDeviceType.vue'
 import ChooseDept from '@/views/system/dept/chooseDept.vue'
+import ChooseStaff from '@/views/system/staff/chooseStaff.vue'
 import { getDictListByType } from '@/api/system/dict';
 import {
     addDeviceLedger,
@@ -195,7 +199,8 @@ export default {
     components: {
         SelectTree,
         ChooseDeviceType,
-        ChooseDept
+        ChooseDept,
+        ChooseStaff
     },
     mounted() {
         this.getDictListByType('device_level', (data) => {
@@ -237,6 +242,7 @@ export default {
                 deviceDeptId: null,
                 deviceDeptName: null,
                 devicePerson: null,
+                devicePersonName: null,
                 buyTime: null,
                 useTime: null,
                 supplier: null,
@@ -287,8 +293,8 @@ export default {
                 deviceDeptName: [
                     { required: true, message: '使用部门不能为空', trigger: 'blur' }
                 ],
-                devicePerson: [
-                    { type: 'number', message: '目前责任人只能输入数字,后续使用关联选择' }
+                devicePersonName: [
+                    { required: true, message: '责任人不能为空', trigger: 'blur' }
                 ],
                 buyTime: [],
                 useTime: [
@@ -439,11 +445,19 @@ export default {
         chooseDept() {
             this.$refs.chooseDept.visible = true
         },
-        /** 接收选择设备类别传过来的值 */
+        /** 接收选择部门传过来的值 */
         receiveChooseDept(data) {
             this.deviceLedgerForm.deviceDeptId = data.id
             this.deviceLedgerForm.deviceDeptName = data.departmentName
         },
+        /** 选择责任人 */
+        chooseDevicePerson() {
+            this.$refs.chooseDevicePerson.visible = true
+        },
+        receiveChooseStaff(data) {
+            this.deviceLedgerForm.devicePerson = data.id
+            this.deviceLedgerForm.devicePersonName = data.staffName
+        },
         /** 设备技术参数改变 */
         handleChangeTechnical(file, fileList) {
             const obj = new Object();

+ 211 - 0
industry-admin/src/views/system/staff/chooseStaff.vue

@@ -0,0 +1,211 @@
+<template>
+    <div>
+        <el-dialog :title="title" width="80%" top="10vh" center :before-close="dialogClose" :visible.sync="visible"
+            @open="handleOpen" @close="handleClose">
+            <el-row>
+                <el-col :span="5">
+                    <el-tree v-if="treeData.length !== 0" :data="treeData" :props="defaultProps" node-key="id"
+                        default-expand-all @node-click="handleNodeClick">
+                        <span class="custom-tree-node" slot-scope="{ node, data }">
+                            <i class="el-icon-folder" style="color: #DFBA49; margin-right: 5px;"></i>
+                            <span style="font-size: 15px;">{{ node.label }}</span>
+                        </span>
+                    </el-tree>
+                </el-col>
+                <el-col :span="19">
+                    <!-- 搜索信息 -->
+                    <el-form ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="80px">
+                        <el-form-item label="姓名" prop="staffName">
+                            <el-input v-model="queryParams.staffName" placeholder="请输入姓名" clearable style="width: 230px" />
+                        </el-form-item>
+                        <el-form-item>
+                            <el-button type="primary" icon="el-icon-search" size="mini" @click="searchEvent">查询</el-button>
+                            <el-button ref="btn" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+                        </el-form-item>
+                    </el-form>
+                    <!-- 数据组表格信息 -->
+                    <CommonTable ref="staffTable" :tableHeaderTitle="tableHeaderTitle" :tableData="tableData"
+                        :isShowCheckbox="isShowCheckbox" :isShowIndex="isShowIndex" :tableHight="tableHight"
+                        :tableOperate="tableOperate" @receiveCheckedData="receiveCheckedData"
+                        @chooseStaffEvent="chooseStaffEvent">
+                    </CommonTable>
+                    <!-- 分页信息 -->
+                    <pagination v-show="tableTotal > 0" small :total="tableTotal" :page.sync="queryParams.page"
+                        :limit.sync="queryParams.limit" align="right" @pagination="getStaffPage" />
+                </el-col>
+            </el-row>
+
+            <!-- 设备台账,新增修改详情界面 -->
+            <Staff ref="staff" @getStaffPage="getStaffPage"></Staff>
+        </el-dialog>
+    </div>
+</template>
+
+<script>
+import CommonTable from '@/components/CommonTable/index.vue'
+import Staff from './staff.vue'
+import { getDepartmentTree } from '@/api/system/dept'
+import { getStaffPage } from '@/api/system/staff'
+import { getDictListByType } from '@/api/system/dict';
+export default {
+    name: 'Index',
+    components: {
+        CommonTable,
+        Staff
+    },
+    created() {
+        this.getDictListByType('post', (data) => {
+            this.postList = data
+        })
+    },
+    data() {
+        return {
+            visible: false,
+            title: '选择人员',
+            //字典回显参数
+            postList: [],
+            //部门机构树参数
+            treeData: [],
+            defaultProps: {
+                children: 'children',
+                label: 'departmentName'
+            },
+            //表格参数
+            isShowCheckbox: false,
+            isShowIndex: false,
+            tableHight: '45vh',
+            tableHeaderTitle: [
+                {
+                    propName: "staffName",
+                    labelName: "姓名",
+                },
+                {
+                    propName: "sex",
+                    labelName: "性别",
+                    formatter: (row, column, cellValue, index) => {
+                        let sex = row.sex
+                        if (sex == 0) {
+                            return '男'
+                        }
+                        if (sex == 1) {
+                            return '女'
+                        }
+                    }
+                },
+                {
+                    propName: "postId",
+                    labelName: "岗位",
+                    formatter: (row, column, cellValue, index) => {
+                        let postId = row.postId
+                        for (let a of this.postList) {
+                            if (a.id == postId) {
+                                return a.dictValue
+                            }
+                        }
+                    }
+                }
+            ],
+            tableData: [],
+            tableOperate: [
+                {
+                    btnName: '选择',
+                    size: "mini",
+                    style: '',
+                    icon: 'el-icon-search',
+                    methodName: "chooseStaffEvent",
+                }
+            ],
+            queryParams: {
+                page: 1,
+                limit: 10,
+                deptId: null,
+                staffName: null
+            },
+            tableTotal: 0
+        }
+    },
+    methods: {
+        /** 关闭弹出层 */
+        dialogClose() {
+            this.visible = false
+        },
+        /** 弹窗打开事件 */
+        handleOpen() {
+            this.getDepartmentTree()
+        },
+        /** 弹窗关闭事件 */
+        handleClose() {
+            this.deviceLedgerList = []
+            this.isSelectAllLedgerItem = false
+            this.ledgerItemList = []
+            this.currentLedgerItem = []
+            this.isSelectAllSelectedItem = false
+            this.selectedItemList = []
+        },
+        /** 多选框的结果 */
+        receiveCheckedData(checked) {
+            // this.checkItemList = checked
+        },
+        /** 搜索 */
+        searchEvent() {
+            this.queryParams.page = 1
+            this.queryParams.limit = 10
+            this.getStaffPage()
+        },
+        /** 重置按钮操作 */
+        resetQuery(event) {
+            this.$refs['queryForm'].resetFields()
+        },
+        /** 获取字典数据 */
+        getDictListByType(params, callback) {
+            getDictListByType({ keyType: params }).then(res => {
+                callback(res.data);
+            })
+        },
+        /** 获取部门机构树 */
+        getDepartmentTree() {
+            getDepartmentTree().then(res => {
+                if (res.data) {
+                    this.treeData = res.data
+                }
+            })
+        },
+        /** 处理节点点击 */
+        handleNodeClick(event, data, node) {
+            this.queryParams.deptId = event.id
+            this.getStaffPage()
+        },
+        /** 分页查询人员信息 */
+        getStaffPage() {
+            if (!this.queryParams.deptId) {
+                this.$message({
+                    message: '请先选中部门!',
+                    type: 'warning'
+                })
+                return
+            }
+            let params = JSON.parse(JSON.stringify(this.queryParams))
+            getStaffPage(params).then(res => {
+                if (!res || !res.data) {
+                    this.$message({
+                        message: '数据查询失败!',
+                        type: 'warning'
+                    })
+                    return
+                }
+                this.tableTotal = res.data.count
+                this.tableData = res.data.staffList
+            })
+        },
+        /** 选择人员事件 */
+        chooseStaffEvent(row){
+            this.$emit('receiveChooseStaff', row)
+            this.visible = false
+        }
+    }
+}
+</script>
+
+<style rel="stylesheet/scss" lang="scss" scoped>
+// @import './index.css';
+</style>

+ 2 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/DeviceLedger.java

@@ -44,6 +44,8 @@ public class DeviceLedger {
     private String departmentName;
     //责任人(目前采用输入框,后面使用关联)
     private Integer devicePerson;
+    //责任人名称,虚拟字段,用于回显
+    private String devicePersonName;
     //购买时间
     private String buyTime;
     //投用时间

+ 2 - 0
industry-system/industry-da/src/main/resources/mapper/DeviceLedgerDao.xml

@@ -290,6 +290,7 @@
         tdl.device_dept_id,
         sd.department_name,
         tdl.device_person,
+        ss.staff_name as device_person_name,
         tdl.buy_time,
         tdl.use_time,
         tdl.supplier,
@@ -303,6 +304,7 @@
         from t_device_ledger tdl
         left join t_device_type tdt on tdl.device_type_id = tdt.id
         left join sys_department sd on tdl.device_dept_id = sd.id
+        left join sys_staff ss on tdl.device_person=ss.id
         where tdl.directory_id = #{deviceLedger.directoryId}
         <if test="deviceLedger.deviceTypeId !=null">
             AND tdl.device_type_id=#{deviceLedger.deviceTypeId}