| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <template>
- <el-dialog
- :title="title"
- :visible.sync="visible"
- :before-close="handleClose"
- class="productModal_dialog"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- width="90%"
- >
- <el-card shadow="never">
- <ele-split-layout
- width="244px"
- allow-collapse
- :right-style="{ overflow: 'hidden' }"
- >
- <div class="ele-border-lighter split-layout-right-content">
- <el-tree
- :data="treeList"
- :props="defaultProps"
- ref="treeRef"
- :expand-on-click-node="false"
- :default-expanded-keys="categoryId ? [categoryId] : []"
- :highlight-current="true"
- node-key="id"
- @node-click="handleNodeClick"
- :default-checked-keys="checkedKeys"
- ></el-tree>
- </div>
- <!-- 数据表格 -->
- <template v-slot:content>
- <ProductSearch @search="reload" ref="searchRef" />
- <ele-pro-table
- height="400"
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :selection.sync="selection"
- row-key="id"
- :initLoad="false"
- >
- <template v-slot:modelType="{ row }">
- <span>{{ row.category.modelType }}</span>
- </template>
- <template v-slot:specification="{ row }">
- <span>{{ row.category.specification }}</span>
- </template>
- <template v-slot:pathName="{ row }">
- <span>{{
- row.position.length > 0 ? row.position[0].pathName : ''
- }}</span>
- </template>
- </ele-pro-table>
- </template>
- </ele-split-layout>
- </el-card>
- <div class="rx-sc">
- <el-button type="primary" size="small" @click="selected">选择</el-button>
- <el-button size="small" @click="handleClose">关闭</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import ProductSearch from './product-search.vue';
- import { getAssetList } from '@/api/ruleManagement/plan';
- import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
- export default {
- data() {
- return {
- ruleIdListIndex: 0,
- visible: false,
- title: '选择设备',
- categoryLevelId: null,
- categoryId: 1,
- treeList: [],
- treeLoading: false,
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- type: null,
- // 表格列配置
- columns: [
- {
- columnKey: 'selection',
- type: 'selection',
- width: 45,
- align: 'center',
- selectable: (row, index) => {
- return !this.processData.some((id) => id == row.id);
- },
- reserveSelection: true,
- fixed: 'left'
- },
- {
- label: '设备名称',
- prop: 'name'
- },
- {
- label: '编号',
- prop: 'codeNumber'
- },
- {
- label: '固资编码',
- prop: 'fixCode'
- },
- {
- label: '使用人',
- prop: 'usePerson'
- },
- {
- label: '使用岗位',
- prop: 'postName'
- },
- {
- label: '负责人',
- prop: 'chargePerson'
- },
- {
- label: '有效开始时间',
- prop: 'startTime'
- },
- {
- label: '有效结束时间',
- prop: 'endTime'
- },
- {
- label: '型号',
- prop: 'modelType',
- slot: 'modelType'
- },
- {
- label: '规格',
- prop: 'specification',
- slot: 'specification'
- },
- {
- label: '设备位置',
- prop: 'pathName',
- slot: 'pathName'
- }
- ],
- // 表格选中数据
- selection: [],
- processData: [],
- checkedKeys: []
- };
- },
- components: {
- ProductSearch
- },
- methods: {
- /* 表格数据源 */
- async datasource({ page, limit, where }) {
- const res = await getAssetList({
- ...where,
- pageNum: page,
- size: limit,
- categoryLevelId: this.categoryLevelId,
- rootCategoryLevelId: this.rootId
- });
- console.log('res---------', res);
- this.categoryId = res.list[0]?.categoryId;
- return res;
- },
- open(ruleIdList, ruleIdListIndex) {
- let list = ruleIdList
- .map((item) => {
- return item.equipmentList;
- })
- .flat();
- if (list.length > 0) {
- this.processData = list.map((item) => item.id);
- } else {
- this.processData = [];
- }
- this.ruleIdListIndex = ruleIdListIndex;
- this.visible = true;
- this.getTreeData();
- },
- async getTreeData() {
- try {
- this.treeLoading = true;
- const res = await getTreeByGroup({ type: 4 });
- this.treeLoading = false;
- if (res?.code === '0') {
- this.treeList = res.data;
- return this.treeList;
- }
- } catch (error) {}
- this.treeLoading = false;
- },
- handleNodeClick(data) {
- this.rootId = data.rootCategoryLevelId;
- this.categoryLevelId = data.id;
- this.$refs.table.reload({ pageNum: 1, where: {} });
- },
- /* 刷新表格 */
- reload(where) {
- if (this.rootId && this.categoryLevelId) {
- this.$refs.table.reload({ page: 1, where: where });
- } else {
- this.$message.error('请选择设备');
- }
- },
- handleClose() {
- this.visible = false;
- this.$refs.table.setSelectedRows([]);
- this.selection = [];
- },
- selected() {
- if (!this.selection.length) {
- this.$message.error('请至少选择一条数据');
- return;
- }
- const selectList = this.$refs.treeRef.getCheckedNodes();
- console.log('selectList-----------', selectList);
- this.$emit(
- 'chooseEquipment',
- this.selection,
- this.ruleIdListIndex,
- this.categoryId
- );
- this.handleClose();
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .productModal_dialog {
- overflow: hidden;
- ::v-deep .el-dialog {
- margin: 50px auto !important;
- height: 90%;
- overflow: hidden;
- .el-dialog__body {
- position: absolute;
- left: 0;
- top: 54px;
- bottom: 0;
- right: 0;
- padding: 0;
- z-index: 1;
- overflow: hidden;
- overflow-y: auto;
- // 下边设置字体,我的需求是黑底白字
- color: #ffffff;
- line-height: 30px;
- padding: 0 15px;
- display: flex;
- flex-direction: column;
- > div {
- flex: 1;
- .el-card__body {
- height: 100%;
- display: flex;
- flex-direction: column;
- > div {
- flex: 1;
- .ele-split-panel-body {
- display: flex;
- flex-direction: column;
- > div {
- height: 100%;
- display: flex;
- flex-direction: column;
- .el-table {
- flex: 1 0 auto;
- height: 0;
- overflow: auto;
- }
- }
- }
- }
- }
- }
- .rx-sc {
- flex: 0 0 50px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- }
- }
- ::v-deep {
- .el-checkbox__input.is-disabled .el-checkbox__inner {
- background-color: #c1c1c1 !important;
- }
- }
- .ml60 {
- margin-left: 60px;
- }
- </style>
|