Ben Lin
2024-07-19 a41c87a94a0b52688420a7af3b242bc771628e28
src/views/tigerprojects/mes/eng/route/components/PostProps.vue
@@ -1,27 +1,25 @@
<!--
 * @Description: file content
 * @Author: your name
 * @Author: Ben Lin
 * @version: 
 * @Date: 2024-06-11 21:07:04
 * @LastEditors: your name
 * @LastEditTime: 2024-06-12 17:29:41
 * @LastEditTime: 2024-06-13 08:55:09
-->
<!--
 * @Description: 右侧属性面板控件 表单属性面板
-->
<template>
  <div class="mt-3">
    <Button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 新增 </Button>
    <a-table :columns="columns" :data-source="data" bordered>
      <template #name="{ text }">
        <a>{{ text }}</a>
  <div class="m-1">
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 新增 </a-button>
      </template>
      <template #action="{ record }">
        <TableAction :actions="[
          {
            icon: 'ant-design:delete-outlined',
            color: 'error',
            tooltip: '删除',
            popConfirm: {
              title: '是否确认删除?',
              placement: 'left',
@@ -30,23 +28,25 @@
          },
        ]" />
      </template>
    </a-table>
    </BasicTable>
  </div>
  <NormalModal @register="register" @success="handleSuccess"></NormalModal>
  <GeneralModal @register="register" @success="handleSuccess"></GeneralModal>
</template>
<script lang="ts" setup>
import { Table, notification } from 'ant-design-vue';
import { Button } from '/@/components/Button';
import { TableAction } from '/@/components/Table';
import { notification } from 'ant-design-vue';
import { BasicTable, TableAction, useTable } from '/@/components/Table';
import { SizeType } from 'ant-design-vue/es/config-provider';
import { ref } from 'vue';
import { nextTick, onMounted, ref, unref, watch } from 'vue';
import { useModal } from '/@/components/Modal';
import NormalModal from '/@/views/components/NormalModal.vue';
import GeneralModal from '/@/views/components/GeneralModal.vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { DeleteEntity, DeleteWhere, SaveEntity, getEntity, getListByPage } from '/@/api/tigerapi/system';
import { useRouteDesignState } from '../hooks/useRouteDesignState';
import { SaveRouteNodePost } from '/@/api/tigerapi/mes/router';
const { t } = useI18n();
const ATable = Table;
const { routeConfig, mesRoute } = useRouteDesignState();
const size = ref<SizeType>('small');
const columns = [
  {
@@ -60,31 +60,43 @@
    dataIndex: 'POST_CODE',
    key: 'POST_CODE',
  },
  {
    title: '操作',
    key: 'operation',
    fixed: 'right',
    width: 65,
    slots: { customRender: 'action' },
  },
];
const data: DataItem[] = [];
for (let i = 0; i < 5; i++) {
  data.push({
    key: i,
    POST_NAME: `Edrward ${i}`,
    POST_CODE: 32,
  });
}
interface DataItem {
  key: number;
  POST_NAME: string;
  POST_CODE: number;
}
const [register, { openModal }] = useModal();
const [registerTable, { reload }] = useTable({
  title: '列表',
  api: getListByPage,
  searchInfo: { TABLE_NAME: 'V_MES_ROUTE_NODE_POST', NODE_ID: routeConfig.currentItem.ID },
  columns,
  useSearchForm: false,
  showTableSetting: false,
  bordered: true,
  showIndexColumn: false,
  pagination: { pageSize: 10 },
  actionColumn: {
    width: 80,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
  },
});
defineExpose({
  reload
});
// watch(
//   () => routeConfig.currentItem.ID,
//   (newVal, oldVal) => {
//     if (newVal != oldVal) {
//       nextTick(() => {
//         reload();
//       });
//     }
//   },
//   { deep: true, immediate: true },
// );
onMounted(() => {
});
/**
 * @description: 新增方法
@@ -121,6 +133,7 @@
    ],
    tableName: 'MES_POSITION',
    rowKey: 'POST_CODE',
    searchInfo: {TABLE_NAME: 'MES_POSITION'}
  });
}
@@ -130,11 +143,26 @@
   * @return {*}
   */
function handleDelete(record: Recordable) {
  DeleteWhere(`POST_CODE = '${record.POST_CODE}' And NODE_ID = '${record.NODE_ID}'`, 'MES_ROUTE_NODE_POST').then((res) => {
    reload();
  });
}
/**
 * @description: 选择岗位资源成功返回方法
 * @param {*} d
 * @param {*} u
 * @return {*}
 */
function handleSuccess(d, u) {
  let xx = d.values.val.split(',');
  let a = '';
 }
  let codes = d.values.val.split(',');
  let eintity: any[] = [];
  var i;
  for (i = 0; i < codes.length; i++) {
    eintity.push({ NODE_ID: routeConfig.currentItem.ID, POST_CODE: codes[i], REMARK: '' });
  }
  SaveRouteNodePost(eintity).then((res) => {
    reload();
  });
}
</script>