| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 |
- <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"
- ></el-tree>
- </div>
- <!-- 数据表格 -->
- <template v-slot:content>
- <ProductSearch
- @search="reload"
- ref="searchRef"
- :factoryName="factoryName"
- />
- <ele-pro-table
- height="400"
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :selection.sync="selection"
- row-key="id"
- :initLoad="false"
- cache-key="main-material-add-2511121044"
- >
- <template v-slot:radio="{ row }">
- <el-radio
- v-model="currentId"
- :label="row.id"
- @change="currentInfo = row"
- >
- <i></i>
- </el-radio>
- </template>
- <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';
- import { getMaterialList } from '@/api/material/list';
- export default {
- components: {
- ProductSearch
- },
- props: {
- // 是否支持多选
- multiple: {
- type: Boolean,
- default: true
- },
- //是否主数据
- isMain: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- ruleIdListIndex: 0,
- visible: false,
- title: '选择设备',
- categoryLevelId: null,
- categoryId: 1,
- treeList: [],
- treeLoading: false,
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- type: null,
- factoryId: '',
- factoryName: '',
- // 表格选中数据
- selection: [],
- processData: [],
- checkedKeys: [],
- currentId: null,
- currentInfo: null
- };
- },
- computed: {
- // 表格列配置
- columns() {
- let list = this.isMain
- ? [
- {
- columnKey: 'index',
- type: 'index',
- width: 50,
- align: 'center',
- showOverflowTooltip: true,
- label: '序号'
- },
- {
- prop: 'code',
- label: '编码',
- align: 'center',
- showOverflowTooltip: true,
- sortable: true,
- minWidth: 110
- },
- {
- prop: 'name',
- label: '名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'categoryLevelPath',
- label: '分类',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'brandNum',
- align: 'center',
- label: '牌号',
- showOverflowTooltip: true
- },
- {
- prop: 'modelType',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'level',
- label: '级别',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'bomStatus',
- label: 'MBOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.bomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'pBomStatus',
- label: 'PBOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.pbomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'aBomStatus',
- label: 'ABOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.abomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isUnpack',
- label: '是否允许拆包',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isUnpack == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isComeCheck',
- label: '是否采购来料检验',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isComeCheck == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isOutsourcingCheck',
- label: '是否委外来料检验',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isOutsourcingCheck == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'measuringUnit',
- label: '计量单位',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'weightUnit',
- label: '重量单位',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'roughWeight',
- label: '毛重',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'netWeight',
- label: '净重',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'packingUnit',
- align: 'center',
- label: '包装单位',
- showOverflowTooltip: true
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'createUserName',
- label: '创建人',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'isEnabled',
- align: 'center',
- label: '状态',
- slot: 'isEnabled',
- showOverflowTooltip: true,
- fixed: 'right',
- formatter: (row, column) => {
- return row.isEnabled === 0
- ? '停用'
- : row.isEnabled === 1
- ? '启用'
- : '';
- }
- }
- ]
- : [
- {
- label: '设备名称',
- prop: 'name'
- },
- {
- label: '编号',
- prop: 'codeNumber'
- },
- {
- label: '固资编码',
- prop: 'fixCode'
- },
- {
- label: '所属工厂',
- prop: 'factoryName'
- },
- {
- 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'
- }
- ];
- if (this.multiple) {
- list.unshift({
- columnKey: 'selection',
- type: 'selection',
- width: 45,
- align: 'center',
- selectable: (row, index) => {
- return !this.processData.some((id) => id == row.id);
- },
- reserveSelection: true,
- fixed: 'left'
- });
- } else {
- list.unshift({
- slot: 'radio',
- width: 50,
- align: 'center',
- fixed: 'left'
- });
- }
- return list;
- }
- },
- methods: {
- /* 表格数据源 */
- async datasource({ page, limit, where }) {
- let api = this.isMain ? getMaterialList : getAssetList;
- const res = await api({
- ...where,
- pageNum: page,
- size: limit,
- categoryLevelId: this.categoryLevelId,
- rootCategoryLevelId: this.rootId,
- factoryId: this.factoryId||''
- });
- console.log('res---------', res);
- this.categoryId = res.list[0]?.categoryId;
- return res;
- },
- open(ruleIdList, ruleIdListIndex, factoryId,factoryName) {
- 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.factoryId = factoryId;
- this.factoryName = factoryName;
- 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;
- // 默认选中第一个节点
- if (this.treeList.length > 0) {
- this.$nextTick(() => {
- this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
- this.handleNodeClick(this.treeList[0]);
- });
- }
- 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.currentInfo = null;
- this.currentId = null;
- this.selection = [];
- },
- selected() {
- if (this.multiple) {
- if (!this.selection.length) {
- this.$message.error('请选择设备');
- return;
- }
- } else {
- if (!this.currentInfo) {
- this.$message.error('请选择设备');
- return;
- }
- }
- const selectList = this.$refs.treeRef.getCheckedNodes();
- console.log('selectList-----------', selectList);
- this.$emit(
- 'chooseEquipment',
- this.multiple ? this.selection : this.currentInfo,
- 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>
|