| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <template>
- <el-dialog
- title="选择"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- top="5vh"
- :close-on-press-escape="false"
- append-to-body
- width="70%"
- >
- <el-card shadow="never">
- <searchProduct @search="reload"></searchProduct>
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- row-key="id"
- height="calc(100vh - 480px)"
- class="dict-table"
- @cell-click="cellClick"
- :selection.sync="selection"
- >
- <!-- 表头工具栏 -->
- <template v-slot:action="{ row }">
- <el-radio class="radio" v-model="radio" :label="row.code"
- ><i></i
- ></el-radio>
- </template>
- </ele-pro-table>
- </el-card>
- <div slot="footer">
- <el-button type="primary" size="small" @click="selected">选择</el-button>
- <el-button size="small" @click="handleClose">关闭</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { getProduceTreeByCode } from '@/api/saleManage/quotation';
- import searchProduct from './searchProduct.vue';
- import { getInventoryTotalAPI } from '@/api/wms';
- import { getByCode } from '@/api/system/dictionary-data';
- import {
- businessStatus,
- networkStatus,
- treeClassifyCodeEnum
- } from '@/enum/dict';
- import { assetPageAPI } from '@/api/main';
- export default {
- components: {
- searchProduct
- },
- props: {
- code: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- visible: false,
- currentIndex: null,
- radio: null,
- dictList: {},
- selection: []
- };
- },
- watch: {},
- computed: {
- treeClassifyCodeEnum() {
- return treeClassifyCodeEnum;
- },
- columns() {
- return [
- {
- action: 'action',
- slot: 'action',
- align: 'center',
- label: '选择',
- show: this.currentIndex != -1
- },
- {
- label: '选择',
- show: this.currentIndex == -1,
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center'
- },
- {
- columnKey: 'index',
- type: 'index',
- label: '序号',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- columnKey: 'code',
- prop: 'code',
- slot: 'code',
- label: '编码',
- showOverflowTooltip: true,
- minWidth: 180,
- align: 'center'
- },
- // {
- // columnKey: 'code',
- // prop: 'code',
- // label: '设备编码',
- // showOverflowTooltip: true,
- // minWidth: 110,
- // slot: 'code'
- // },
- {
- prop: 'name',
- label: '名称',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'category.brandNum',
- label: '牌号',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'fixCode',
- label: '固资编码',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'postName',
- label: '使用岗位',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'codeNumber',
- label: '编号',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'category.modelType',
- label: '型号',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'category.specification',
- label: '规格',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'usePerson',
- label: '使用人',
- showOverflowTooltip: true,
- minWidth: 80,
- align: 'center'
- },
- {
- prop: 'chargePerson',
- label: '负责人',
- showOverflowTooltip: true,
- minWidth: 80,
- align: 'center'
- },
- {
- prop: 'endTime',
- label: '有效结束时间',
- showOverflowTooltip: true,
- minWidth: 150,
- align: 'center'
- },
- {
- prop: 'source',
- label: '生命周期',
- showOverflowTooltip: true,
- minWidth: 110,
- align: 'center'
- },
- {
- prop: 'level',
- label: '级别',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- return this.getDictV('asset_level', _row.level);
- },
- align: 'center'
- },
- {
- prop: 'networkStatus',
- label: '网络状态',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- if (_row.networkStatus) {
- return networkStatus.filter(
- (item) => item.code == _row.networkStatus
- )[0].label;
- } else {
- return '离线';
- }
- },
- align: 'center'
- },
- {
- prop: 'status',
- label: '状态',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- if (_row.status) {
- return businessStatus.filter(
- (item) => item.code == _row.status
- )[0].label;
- } else {
- return '空闲';
- }
- },
- align: 'center'
- },
- {
- prop: 'pathName',
- label: '位置',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row) => {
- const positionDetail =
- _row.position &&
- _row.position.length != 0 &&
- _row.position[0].detailPosition
- ? _row.position[0].detailPosition
- : '-';
- return _row.deviceLocationName
- ? _row.deviceLocationName + '-' + positionDetail
- : '';
- },
- align: 'center'
- }
- ];
- }
- },
- methods: {
- getDictV(code, val) {
- if (!this.dictList[code]) return '';
- return this.dictList[code].find((item) => item.value == val)?.label;
- },
- async getDictList(code) {
- let { data: res } = await getByCode(code);
- this.dictList[code] = res.map((item) => {
- let values = Object.keys(item);
- return {
- value: values[0],
- label: item[values[0]]
- };
- });
- },
- async open(item, currentIndex) {
- this.currentIndex = currentIndex;
- this.visible = true;
- await this.getDictList('asset_level');
- },
- /* 表格数据源 */
- async datasource({ page, limit, where, order }) {
- let typeObj = await getProduceTreeByCode(this.code);
- return assetPageAPI({
- pageNum: page,
- size: limit,
- categoryLevelId: typeObj[0]?.id || '-1',
- ...where
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ pageNum: 1, where: where });
- },
- handleNodeClick(data, node) {
- this.curNodeData = data;
- this.reload({ categoryLevelId: data.id });
- },
- // 单击获取id
- cellClick(row) {
- if (this.currentIndex == -1) return;
- this.current = row;
- this.radio = row.id;
- },
- handleClose() {
- this.visible = false;
- this.current = null;
- this.selection = [];
- this.$refs.table.clearSelection();
- this.radio = '';
- },
- async selected() {
- if (!this.current && !this.selection.length) {
- return this.$message.warning('请至少选择一条数据');
- }
- let list = this.currentIndex == -1 ? this.selection : [this.current];
- this.$emit('changeParent', list, this.currentIndex);
- this.handleClose();
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .tree_col {
- border: 1px solid #eee;
- padding: 10px 0;
- box-sizing: border-box;
- height: 500px;
- overflow: auto;
- }
- .table_col {
- padding-left: 10px;
- ::v-deep .el-table th.el-table__cell {
- background: #f2f2f2;
- }
- }
- .pagination {
- text-align: right;
- padding: 10px 0;
- }
- .btns {
- text-align: center;
- padding: 10px 0;
- }
- .topsearch {
- margin-bottom: 15px;
- }
- </style>
|