yangys
2025-08-16 fd307873b67f5a71817fe54226b2a104b6081d48
src/views/basesetting/machine.vue
@@ -1,44 +1,66 @@
<template>
  <basic-container>
    <avue-crud
      :addBtn="false"
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      v-model:search="search"
      v-model:page="mypage"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left>
        <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">导出</el-button>
        <!-- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">导入</el-button> -->
        <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">新增</el-button>
      </template>
      <template #menu="scope">
        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">编辑</el-button>
        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">删除</el-button>
        <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleUp(scope.row, scope.index)">产生机床回传机构树</el-button>
      </template>
  <el-row>
    <el-col :span="5">
      <div class="box">
        <el-scrollbar>
          <basic-container>
            <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
          </basic-container>
        </el-scrollbar>
      </div>
    </el-col>
    <el-col :span="19">
      <basic-container>
        <avue-crud
          :addBtn="false"
          :option="option"
          :table-loading="loading"
          :data="data"
          ref="crud"
          v-model:search="search"
          v-model:page="mypage"
          @search-change="searchChange"
          @search-reset="searchReset"
          @current-change="currentChange"
          @size-change="sizeChange"
          @refresh-change="refreshChange"
          @on-load="onLoad"
        >
          <template #menu-left>
            <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">导出</el-button>
      <template #status="{ row }">
        <span>{{ row.status=="1"?"启用":"禁用" }}</span>
      </template>
    </avue-crud>
    <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%">
      <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm">
        <template #ownerDept="{}">
          <el-tree-select v-model="editForm.ownerDept" :data="organizationTreeList" :props="treePropsConfig"/>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
            <el-upload :show-file-list="false" class="upload-demo"
                action="/api/blade-mdm/machine/import"
                       :on-change="handleChange">
              <el-button type="primary" plain size="default">导入</el-button>
            </el-upload>
            <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">新增</el-button>
          </template>
          <template #menu="scope">
            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">编辑</el-button>
            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">删除</el-button>
            <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleUp(scope.row, scope.index)">产生机床回传机构树</el-button>
          </template>
          <template #status="{ row }">
            <span>{{ row.status=="1"?"启用":"禁用" }}</span>
          </template>
        </avue-crud>
        <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%">
          <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm">
            <template #ownerDept="{}">
              <el-tree-select v-model="editForm.ownerDept" :data="organizationTreeList" :props="treePropsConfig"/>
            </template>
          </avue-form>
        </el-dialog>
      </basic-container>
    </el-col>
  </el-row>
</template>
<script>
@@ -47,10 +69,38 @@
import NProgress from 'nprogress';
import { downloadXls } from '@/utils/util';
import 'nprogress/nprogress.css';
import { getDeptLazyTree } from '@/api/system/dept';
export default {
  data() {
    var that = this;
    return {
      treeOption: {
        nodeKey: 'id',
        lazy: true,
        treeLoad: function (node, resolve) {
          const parentId = node.level === 0 ? 0 : node.data.id;
          getDeptLazyTree(parentId).then(res => {
            resolve(
              res.data.data.map(item => {
                return {
                  ...item,
                  leaf: !item.hasChildren,
                };
              })
            );
          });
        },
        addBtn: false,
        menu: false,
        size: 'small',
        props: {
          labelText: '标题',
          label: 'title',
          value: 'value',
          children: 'children',
        },
      },
      treeData: [],
      treePropsConfig: {
        value:  'id',
        label: 'title',
@@ -259,6 +309,13 @@
            span: 12,
            dataType: 'string',
          },
        {
            label: '程序临时目录',
            prop: 'progTempDir',
            type: 'input',
            span: 12,
            dataType: 'string',
          },
          {
            label: '备注',
            prop: 'remark',
@@ -272,16 +329,13 @@
    };
  },
  methods: {
    initData(tenantId) {
      axios({
        url: 'blade-system/dept/tree',
        method: 'get'
      }).then(
        res => {
          //const column = this.findObject(this.option.column, 'parentId');
          //column.dicData = res.data.data;
        }
      );
    handleChange(a,b,c) {
      console.log(a,b,c);
    },
    nodeClick(data) {
      this.treeDeptId = data.id;
      this.mypage.current = 1;
      this.onLoad(this.page);
    },
    handleAdd() {
      this.machineTitle = "新增";
@@ -417,6 +471,7 @@
          machineGroupCode: this.search.machineGroupName,
          current: this.mypage.current,
          size: this.mypage.size,
          deptId: this.treeDeptId
        }
        axios({
          url: '/blade-mdm/machine/page',
@@ -461,5 +516,9 @@
</script>
<style lang="scss">
.upload-demo {
  display: inline-block;
  margin-left: 6px;
  margin-right: 6px;
}
</style>