“linengliang”
2023-08-29 78bdb5114382f006fb53fd461c7b90f4f43afc39
src/views/eam/modules/equipmentCategory/EquipmentCategoryLeft.vue
@@ -66,7 +66,51 @@
        @select="onSelect"
        @expand="onExpand"
      >
      <template
          slot="title"
          slot-scope="{key,entity,title,leaf}"
        >
        <span>{{ title }}</span>
          <a-dropdown
            v-if="entity"
            :trigger="['click']"
            placement="bottomCenter"
          >
            <a-menu slot="overlay">
              <a-menu-item v-if="key!=-1">
                <a
                  href="javascript:;"
                  @click="handleEdit(entity)"
                >编辑</a>
              </a-menu-item>
              <a-menu-item>
                <a
                  href="javascript:;"
                  @click="handleAdd(entity)"
                >
               添加子类别
                </a>
              </a-menu-item>
              <a-menu-item v-if="key!=-1&&leaf">
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(entity.id)"
                >
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
            <span :style="{position: 'absolute',right: 0}">
              <a-icon type="down" />
            </span>
          </a-dropdown>
        </template>
      </a-tree>
      <equipment-category-model
      ref="modalForm"
      @ok="modalFormOk"
      :mainId="mainId"
    ></equipment-category-model>
    </a-spin>
  </a-card>
</template>
@@ -75,24 +119,33 @@
import { getAction } from '@/api/manage'
import Tooltip from 'ant-design-vue/es/tooltip'
import JEllipsis from "@/components/jeecg/JEllipsis"
import EquipmentCategoryModel from './EquipmentCategoryModel'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { deleteAction } from '../../../../api/manage'
export default {
  name: 'EquipmentCategoryLeft',
  mixins: [JeecgListMixin],
  components: {
    Tooltip,
    JEllipsis
    JEllipsis,
    EquipmentCategoryModel,
  },
  props: ['value'],
  data() {
    return {
      searchInput: '',
      disableMixinCreated:true,
      cardLoading: false,
      loading: false,
      treeDataSource: [],
      selectedKeys: [],
      expandedKeys: [],
      mainId:'',
      url: {
        equipmentCategoryTreeList: '/eam/equipmentCategory/loadTree'
        equipmentCategoryTreeList: '/eam/equipmentCategory/loadTree',
        delete: "/eam/equipmentCategory/delete",
        list: "/eam/equipmentCategory/getAllChildren",
      },
      searchValue: '',
      dataList: [],
@@ -111,6 +164,12 @@
    getCurrSelectedTitle() {
      return !this.currSelected.title ? '' : this.currSelected.title;
    },
    handleAdd: function (record) {
      this.$refs.modalForm.add({ parentNum: record.num, parentName: record.name });
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;
      this.$refs.modalForm.parentId = record.id;
    },
    onClearSelected() {
      this.hiding = true;
      this.currSelected = {};
@@ -121,6 +180,7 @@
      let record = e.node.dataRef;
      this.currSelected = Object.assign({}, record);
      this.selectedKeys = [record.key];
      this.mainId = record.key;
    },
    onExpand(expandedKeys) {
      this.expandedKeys = expandedKeys;
@@ -190,7 +250,25 @@
      }
      return parentKey;
    },
    handleDelete(id) {
      if (!this.url.delete) {
        this.$message.error("请设置url.delete属性!")
        return
      }
      var that = this;
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message);
          that.queryTreeData();
          that.$bus.$emit('loadData')
          that.alterFlag = new Date();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    generateList(data) {
      for (let i = 0; i < data.length; i++) {
        const node = data[i];